#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Vertex.hxx>
#include <Quantity_Color.hxx>
#include <Standard_Type.hxx>
#include <TColgp_SequenceOfPnt.hxx>
IMPLEMENT_STANDARD_RTTIEXT(V3d_CircularGrid,Aspect_CircularGrid)
-/*----------------------------------------------------------------------*/
-/*
- * Constant
- */
#define DIVISION 8
-#define MYMINMAX 25.
#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.;
SetRadiusStep (step);
}
+V3d_CircularGrid::~V3d_CircularGrid()
+{
+ myGroup.Nullify();
+ if (!myStructure.IsNull())
+ {
+ myStructure->Erase();
+ }
+}
+
void V3d_CircularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor)
{
if( myColor != aColor || myTenthColor != aTenthColor ) {
{
myStructure->SetDisplayPriority (1);
myStructure->Display();
+ UpdateDisplay();
}
void V3d_CircularGrid::Erase () const
myCurViewPlane = ThePlane;
}
- switch (DrawMode())
+ switch (myDrawMode)
{
- default:
- //case Aspect_GDM_Points:
+ case Aspect_GDM_Points:
DefinePoints ();
myCurDrawMode = Aspect_GDM_Points;
break;
DefineLines ();
myCurDrawMode = Aspect_GDM_Lines;
break;
-#ifdef IMP210100
case Aspect_GDM_None:
myCurDrawMode = Aspect_GDM_None;
break;
-#endif
}
myCurAreDefined = Standard_True;
}
|| 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