Custom Graphic3d_Structure implementation has been added to V3d_RectangularGrid and V3d_CircularGrid to trigger recompute in case of device lost.
Primitive arrays are no more (re)computed while grid is not actually displayed.
IMPLEMENT_STANDARD_RTTIEXT(V3d_CircularGrid,Aspect_CircularGrid)
-/*----------------------------------------------------------------------*/
-/*
- * Constant
- */
#define DIVISION 8
#define MYFACTOR 50.
+//! Dummy implementation of Graphic3d_Structure overriding ::Compute() method for handling Device Lost.
+class V3d_CircularGrid::CircularGridStructure : public Graphic3d_Structure
+{
+public:
+ //! Main constructor.
+ CircularGridStructure (const Handle(Graphic3d_StructureManager)& theManager, V3d_CircularGrid* theGrid)
+ : Graphic3d_Structure (theManager), myGrid (theGrid) {}
+
+ //! Override method initiating recomputing in V3d_CircularGrid.
+ virtual void Compute() Standard_OVERRIDE
+ {
+ GraphicClear (Standard_False);
+ myGrid->myGroup = NewGroup();
+ myGrid->myCurAreDefined = Standard_False;
+ myGrid->UpdateDisplay();
+ }
+
+private:
+ V3d_CircularGrid* myGrid;
+};
+
/*----------------------------------------------------------------------*/
V3d_CircularGrid::V3d_CircularGrid (const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor)
: Aspect_CircularGrid (1.,8),
- myStructure (new Graphic3d_Structure (aViewer->StructureManager())),
- myGroup (myStructure->NewGroup()),
myViewer (aViewer),
- myCurAreDefined (Standard_False)
+ myCurAreDefined (Standard_False),
+ myToComputePrs (Standard_False)
{
myColor = aColor;
myTenthColor = aTenthColor;
+ myStructure = new CircularGridStructure (aViewer->StructureManager(), this);
+ myGroup = myStructure->NewGroup();
myStructure->SetInfiniteState (Standard_True);
const Standard_Real step = 10.;
{
myStructure->SetDisplayPriority (1);
myStructure->Display();
+ UpdateDisplay();
}
void V3d_CircularGrid::Erase () const
|| myCurDrawMode != Aspect_GDM_Lines
|| aDivision != myCurDivi
|| aStep != myCurStep;
- if (!toUpdate)
+ if (!toUpdate
+ && !myToComputePrs)
{
return;
}
+ else if (!myStructure->IsDisplayed())
+ {
+ myToComputePrs = Standard_True;
+ return;
+ }
+ myToComputePrs = Standard_False;
myGroup->Clear ();
const Standard_Integer Division = (Standard_Integer )( (aDivision >= DIVISION ? aDivision : DIVISION));
myGroup->SetMinMaxValues(-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0);
myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;
+
+ // update bounding box
+ myStructure->CalculateBoundBox();
+ myViewer->StructureManager()->Update (myStructure->GetZLayer());
}
void V3d_CircularGrid::DefinePoints ()
|| myCurDrawMode != Aspect_GDM_Points
|| aDivision != myCurDivi
|| aStep != myCurStep;
- if (!toUpdate)
+ if (!toUpdate
+ && !myToComputePrs)
{
return;
}
+ else if (!myStructure->IsDisplayed())
+ {
+ myToComputePrs = Standard_True;
+ return;
+ }
+ myToComputePrs = Standard_False;
myGroup->Clear ();
Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d ();
myGroup->SetMinMaxValues(-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0);
myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;
+
+ // update bounding box
+ myStructure->CalculateBoundBox();
+ myViewer->StructureManager()->Update (myStructure->GetZLayer());
}
void V3d_CircularGrid::GraphicValues (Standard_Real& theRadius, Standard_Real& theOffSet) const
Standard_EXPORT void DefinePoints();
+private:
+
+ //! Custom Graphic3d_Structure implementation.
+ class CircularGridStructure;
+
private:
Handle(Graphic3d_Structure) myStructure;
gp_Ax3 myCurViewPlane;
V3d_ViewerPointer myViewer;
Standard_Boolean myCurAreDefined;
+ Standard_Boolean myToComputePrs;
Aspect_GridDrawMode myCurDrawMode;
Standard_Real myCurXo;
Standard_Real myCurYo;
IMPLEMENT_STANDARD_RTTIEXT(V3d_RectangularGrid,Aspect_RectangularGrid)
-/*----------------------------------------------------------------------*/
-/*
- * Constant
- */
#define MYFACTOR 50.
+//! Dummy implementation of Graphic3d_Structure overriding ::Compute() method for handling Device Lost.
+class V3d_RectangularGrid::RectangularGridStructure : public Graphic3d_Structure
+{
+public:
+ //! Main constructor.
+ RectangularGridStructure (const Handle(Graphic3d_StructureManager)& theManager, V3d_RectangularGrid* theGrid)
+ : Graphic3d_Structure (theManager), myGrid (theGrid) {}
+
+ //! Override method initiating recomputing in V3d_RectangularGrid.
+ virtual void Compute() Standard_OVERRIDE
+ {
+ GraphicClear (Standard_False);
+ myGrid->myGroup = NewGroup();
+ myGrid->myCurAreDefined = Standard_False;
+ myGrid->UpdateDisplay();
+ }
+
+private:
+ V3d_RectangularGrid* myGrid;
+};
+
/*----------------------------------------------------------------------*/
V3d_RectangularGrid::V3d_RectangularGrid (const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor)
: Aspect_RectangularGrid (1.,1.),
- myStructure (new Graphic3d_Structure (aViewer->StructureManager())),
- myGroup (myStructure->NewGroup()),
myViewer (aViewer),
- myCurAreDefined (Standard_False)
+ myCurAreDefined (Standard_False),
+ myToComputePrs (Standard_True)
{
myColor = aColor;
myTenthColor = aTenthColor;
+ myStructure = new RectangularGridStructure (aViewer->StructureManager(), this);
+ myGroup = myStructure->NewGroup();
myStructure->SetInfiniteState (Standard_True);
const Standard_Real step = 10.;
{
myStructure->SetDisplayPriority (1);
myStructure->Display();
+ UpdateDisplay();
}
void V3d_RectangularGrid::Erase () const
|| myCurDrawMode != Aspect_GDM_Lines
|| aXStep != myCurXStep
|| aYStep != myCurYStep;
- if (!toUpdate)
+ if (!toUpdate
+ && !myToComputePrs)
{
return;
}
+ else if (!myStructure->IsDisplayed())
+ {
+ myToComputePrs = Standard_True;
+ return;
+ }
+ myToComputePrs = Standard_False;
myGroup->Clear();
Standard_Integer nblines;
myGroup->SetMinMaxValues(-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0);
myCurXStep = aXStep, myCurYStep = aYStep;
+
+ // update bounding box
+ myStructure->CalculateBoundBox();
+ myViewer->StructureManager()->Update (myStructure->GetZLayer());
}
void V3d_RectangularGrid::DefinePoints ()
|| myCurDrawMode != Aspect_GDM_Points
|| aXStep != myCurXStep
|| aYStep != myCurYStep;
- if (!toUpdate)
+ if (!toUpdate
+ && !myToComputePrs)
{
return;
}
+ else if (!myStructure->IsDisplayed())
+ {
+ myToComputePrs = Standard_True;
+ return;
+ }
+ myToComputePrs = Standard_False;
myGroup->Clear();
// horizontals
myGroup->SetMinMaxValues(-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0);
myCurXStep = aXStep, myCurYStep = aYStep;
+
+ // update bounding box
+ myStructure->CalculateBoundBox();
+ myViewer->StructureManager()->Update (myStructure->GetZLayer());
}
void V3d_RectangularGrid::GraphicValues (Standard_Real& theXSize, Standard_Real& theYSize, Standard_Real& theOffSet) const
Standard_EXPORT void DefinePoints();
+private:
+
+ //! Custom Graphic3d_Structure implementation.
+ class RectangularGridStructure;
+
private:
Handle(Graphic3d_Structure) myStructure;
gp_Ax3 myCurViewPlane;
V3d_ViewerPointer myViewer;
Standard_Boolean myCurAreDefined;
+ Standard_Boolean myToComputePrs;
Aspect_GridDrawMode myCurDrawMode;
Standard_Real myCurXo;
Standard_Real myCurYo;
--- /dev/null
+puts "=================="
+puts "0029395: Visualization, V3d_View - Grid disappears forever after enabling RayTracing"
+puts "=================="
+puts ""
+
+pload VISUALIZATION
+
+# Rectangular Grid
+vclear
+vinit View1
+vraytrace 0
+vgrid r
+vraytrace 1
+checkcolor 198 197 0.5 0.5 0.5
+vclose
+
+# Circular Grid
+vclear
+vinit View1
+vraytrace 0
+vgrid c
+vraytrace 1
+checkcolor 198 197 0.5 0.5 0.5