1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0029395: Visualization, V3d_View - Grid disappears forever after enabling RayTracing

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.
This commit is contained in:
dipts
2018-02-05 22:11:42 +01:00
committed by kgv
parent f8e0c6c48a
commit 5f6e3a0711
5 changed files with 135 additions and 18 deletions

View File

@@ -28,25 +28,43 @@
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.;
@@ -78,6 +96,7 @@ void V3d_CircularGrid::Display ()
{
myStructure->SetDisplayPriority (1);
myStructure->Display();
UpdateDisplay();
}
void V3d_CircularGrid::Erase () const
@@ -176,11 +195,18 @@ void V3d_CircularGrid::DefineLines ()
|| 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));
@@ -239,6 +265,10 @@ void V3d_CircularGrid::DefineLines ()
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 ()
@@ -249,11 +279,18 @@ 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 ();
@@ -287,6 +324,10 @@ void V3d_CircularGrid::DefinePoints ()
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

View File

@@ -61,6 +61,11 @@ private:
Standard_EXPORT void DefinePoints();
private:
//! Custom Graphic3d_Structure implementation.
class CircularGridStructure;
private:
Handle(Graphic3d_Structure) myStructure;
@@ -68,6 +73,7 @@ private:
gp_Ax3 myCurViewPlane;
V3d_ViewerPointer myViewer;
Standard_Boolean myCurAreDefined;
Standard_Boolean myToComputePrs;
Aspect_GridDrawMode myCurDrawMode;
Standard_Real myCurXo;
Standard_Real myCurYo;

View File

@@ -28,24 +28,42 @@
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.;
@@ -79,6 +97,7 @@ void V3d_RectangularGrid::Display ()
{
myStructure->SetDisplayPriority (1);
myStructure->Display();
UpdateDisplay();
}
void V3d_RectangularGrid::Erase () const
@@ -176,11 +195,18 @@ void V3d_RectangularGrid::DefineLines ()
|| 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;
@@ -237,6 +263,10 @@ void V3d_RectangularGrid::DefineLines ()
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 ()
@@ -247,11 +277,18 @@ 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
@@ -286,6 +323,10 @@ void V3d_RectangularGrid::DefinePoints ()
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

View File

@@ -60,6 +60,11 @@ private:
Standard_EXPORT void DefinePoints();
private:
//! Custom Graphic3d_Structure implementation.
class RectangularGridStructure;
private:
Handle(Graphic3d_Structure) myStructure;
@@ -67,6 +72,7 @@ private:
gp_Ax3 myCurViewPlane;
V3d_ViewerPointer myViewer;
Standard_Boolean myCurAreDefined;
Standard_Boolean myToComputePrs;
Aspect_GridDrawMode myCurDrawMode;
Standard_Real myCurXo;
Standard_Real myCurYo;