1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0026154: Visualization - v3d viewer grid disappears due to automatic z-fit

V3d_RectangularGrid, V3d_CircularGrid, fixed initialization of presentation bounding box (lost Z offset).
This commit is contained in:
kgv 2019-07-29 17:49:58 +03:00 committed by bugmaster
parent f6b4e578cd
commit e36ee9677a
2 changed files with 37 additions and 19 deletions

View File

@ -28,8 +28,12 @@
IMPLEMENT_STANDARD_RTTIEXT(V3d_CircularGrid,Aspect_CircularGrid)
#define DIVISION 8
#define MYFACTOR 50.
namespace
{
static const Standard_Real THE_DEFAULT_GRID_STEP = 10.0;
#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
@ -58,7 +62,15 @@ V3d_CircularGrid::V3d_CircularGrid (const V3d_ViewerPointer& aViewer, const Quan
: Aspect_CircularGrid (1.,8),
myViewer (aViewer),
myCurAreDefined (Standard_False),
myToComputePrs (Standard_False)
myToComputePrs (Standard_False),
myCurDrawMode (Aspect_GDM_Lines),
myCurXo (0.0),
myCurYo (0.0),
myCurAngle (0.0),
myCurStep (0.0),
myCurDivi (0),
myRadius (0.5 * aViewer->DefaultViewSize()),
myOffSet (THE_DEFAULT_GRID_STEP / MYFACTOR)
{
myColor = aColor;
myTenthColor = aTenthColor;
@ -67,10 +79,7 @@ V3d_CircularGrid::V3d_CircularGrid (const V3d_ViewerPointer& aViewer, const Quan
myGroup = myStructure->NewGroup();
myStructure->SetInfiniteState (Standard_True);
const Standard_Real step = 10.;
const Standard_Real size = 0.5*myViewer->DefaultViewSize();
SetGraphicValues (size, step/MYFACTOR);
SetRadiusStep (step);
SetRadiusStep (THE_DEFAULT_GRID_STEP);
}
V3d_CircularGrid::~V3d_CircularGrid()
@ -263,7 +272,7 @@ void V3d_CircularGrid::DefineLines ()
myGroup->AddPrimitiveArray(aPrims3, Standard_False);
}
myGroup->SetMinMaxValues(-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0);
myGroup->SetMinMaxValues (-myRadius, -myRadius, -myOffSet, myRadius, myRadius, -myOffSet);
myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;
// update bounding box
@ -321,7 +330,7 @@ void V3d_CircularGrid::DefinePoints ()
}
myGroup->AddPrimitiveArray (Cercle, Standard_False);
}
myGroup->SetMinMaxValues(-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0);
myGroup->SetMinMaxValues (-myRadius, -myRadius, -myOffSet, myRadius, myRadius, -myOffSet);
myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;

View File

@ -28,7 +28,11 @@
IMPLEMENT_STANDARD_RTTIEXT(V3d_RectangularGrid,Aspect_RectangularGrid)
#define MYFACTOR 50.
namespace
{
static const Standard_Real THE_DEFAULT_GRID_STEP = 10.0;
#define MYFACTOR 50.
}
//! Dummy implementation of Graphic3d_Structure overriding ::Compute() method for handling Device Lost.
class V3d_RectangularGrid::RectangularGridStructure : public Graphic3d_Structure
@ -57,7 +61,16 @@ V3d_RectangularGrid::V3d_RectangularGrid (const V3d_ViewerPointer& aViewer, cons
: Aspect_RectangularGrid (1.,1.),
myViewer (aViewer),
myCurAreDefined (Standard_False),
myToComputePrs (Standard_True)
myToComputePrs (Standard_True),
myCurDrawMode (Aspect_GDM_Lines),
myCurXo (0.0),
myCurYo (0.0),
myCurAngle (0.0),
myCurXStep (0.0),
myCurYStep (0.0),
myXSize (0.5 * aViewer->DefaultViewSize()),
myYSize (0.5 * aViewer->DefaultViewSize()),
myOffSet (THE_DEFAULT_GRID_STEP / MYFACTOR)
{
myColor = aColor;
myTenthColor = aTenthColor;
@ -66,12 +79,8 @@ V3d_RectangularGrid::V3d_RectangularGrid (const V3d_ViewerPointer& aViewer, cons
myGroup = myStructure->NewGroup();
myStructure->SetInfiniteState (Standard_True);
const Standard_Real step = 10.;
const Standard_Real gstep = step/MYFACTOR;
const Standard_Real size = 0.5*myViewer->DefaultViewSize();
SetGraphicValues (size, size, gstep);
SetXStep (step);
SetYStep (step);
SetXStep (THE_DEFAULT_GRID_STEP);
SetYStep (THE_DEFAULT_GRID_STEP);
}
V3d_RectangularGrid::~V3d_RectangularGrid()
@ -261,7 +270,7 @@ void V3d_RectangularGrid::DefineLines ()
myGroup->AddPrimitiveArray(aPrims, Standard_False);
}
myGroup->SetMinMaxValues(-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0);
myGroup->SetMinMaxValues(-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
myCurXStep = aXStep, myCurYStep = aYStep;
// update bounding box
@ -321,7 +330,7 @@ void V3d_RectangularGrid::DefinePoints ()
myGroup->AddPrimitiveArray (Vertical, Standard_False);
}
myGroup->SetMinMaxValues(-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0);
myGroup->SetMinMaxValues(-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
myCurXStep = aXStep, myCurYStep = aYStep;
// update bounding box