- moved creating of V3d_View::myTrihedron from constructor to first attempt of displaying or calling it;
- moved creating of V3d_Viewer::myRGrid and V3d_Viewer::myCGrid to to first attempt of displaying or calling them;
- renamed V3d_Viewer::IsActive() to V3d_Viewer::IsGridActive();
- redefined V3d_View::Trihedron() and V3d_Viewer::Grid() by adding new argument toCreate
for opportunity to check the existence of the objects without their recreating.
const Standard_Integer y,
const Handle(V3d_View)& aView)
{
- if(aView->Viewer()->Grid()->IsActive())
+ if (aView->Viewer()->IsGridActive())
{
Standard_Real aGridX=0,aGridY=0,aGridZ=0;
aView->ConvertToGrid(x,y,aGridX,aGridY,aGridZ);
void OCC_2dView::OnUpdateBUTTONGridValues(CCmdUI* pCmdUI)
{
Handle(V3d_Viewer) aViewer = myView->Viewer();
- pCmdUI-> Enable( aViewer->IsActive() );
+ pCmdUI-> Enable( aViewer->IsGridActive() );
}
void OCC_2dView::OnBUTTONGridCancel()
void OCC_2dView::OnUpdateBUTTONGridCancel(CCmdUI* pCmdUI)
{
Handle(V3d_Viewer) aViewer = myView->Viewer();
- pCmdUI-> Enable( aViewer->IsActive() );
+ pCmdUI-> Enable( aViewer->IsGridActive() );
}
void OCC_2dView::OnSize(UINT nType, int cx, int cy)
Handle(SelectMgr_EntityOwner) aNewPicked = theCtx->DetectedOwner();
- if (theView->Viewer()->Grid()->IsActive()
+ if (theView->Viewer()->IsGridActive()
&& theView->Viewer()->GridEcho())
{
if (aNewPicked.IsNull())
Handle(Graphic3d_AspectMarker3d) GridAsp = new Graphic3d_AspectMarker3d(AspectTypeOfMarker, Quantity_NOC_BLUE1, 10.);
aViewer->SetGridEcho(GridAsp);
- if (aViewer->IsActive()) {
+ if (aViewer->IsGridActive())
+ {
if (aViewer->GridEcho()) {
Standard_Real X,Y,Z;
aView->ConvertToGrid(x,y,X,Y,Z);
MyViewer (theViewer.operator->()),
SwitchSetFront (Standard_False),
myZRotation (Standard_False),
- myTrihedron (new V3d_Trihedron()),
MyTrsf (1, 4, 1, 4)
{
myView = theViewer->Driver()->CreateView (theViewer->StructureManager());
//function : Remove
//purpose :
//=============================================================================
-void V3d_View::Remove() const
+void V3d_View::Remove()
{
if (!MyGrid.IsNull())
{
//function : ConvertToGrid
//purpose :
//=======================================================================
-void V3d_View::ConvertToGrid(const Standard_Integer Xp,
- const Standard_Integer Yp,
- Standard_Real& Xg,
- Standard_Real& Yg,
- Standard_Real& Zg) const
+void V3d_View::ConvertToGrid(const Standard_Integer theXp,
+ const Standard_Integer theYp,
+ Standard_Real& theXg,
+ Standard_Real& theYg,
+ Standard_Real& theZg) const
{
- Graphic3d_Vertex aVrp;
- Standard_Real anX, anY, aZ;
- Convert (Xp, Yp, anX, anY, aZ);
- aVrp.SetCoord (anX, anY, aZ);
+ Graphic3d_Vec3d anXYZ;
+ Convert (theXp, theYp, anXYZ.x(), anXYZ.y(), anXYZ.z());
- if( MyViewer->Grid()->IsActive() ) {
- Graphic3d_Vertex aNewVrp = Compute (aVrp) ;
- aNewVrp.Coord (Xg,Yg,Zg) ;
- } else
- aVrp.Coord (Xg,Yg,Zg) ;
+ Graphic3d_Vertex aVrp;
+ aVrp.SetCoord (anXYZ.x(), anXYZ.y(), anXYZ.z());
+ if (MyViewer->IsGridActive())
+ {
+ Graphic3d_Vertex aNewVrp = Compute (aVrp);
+ aNewVrp.Coord (theXg, theYg, theZg);
+ }
+ else
+ {
+ aVrp.Coord (theXg, theYg, theZg);
+ }
}
//=======================================================================
//function : ConvertToGrid
//purpose :
//=======================================================================
-void V3d_View::ConvertToGrid(const Standard_Real X,
- const Standard_Real Y,
- const Standard_Real Z,
- Standard_Real& Xg,
- Standard_Real& Yg,
- Standard_Real& Zg) const
+void V3d_View::ConvertToGrid(const Standard_Real theX,
+ const Standard_Real theY,
+ const Standard_Real theZ,
+ Standard_Real& theXg,
+ Standard_Real& theYg,
+ Standard_Real& theZg) const
{
- if( MyViewer->Grid()->IsActive() ) {
- Graphic3d_Vertex aVrp (X,Y,Z) ;
- Graphic3d_Vertex aNewVrp = Compute (aVrp) ;
- aNewVrp.Coord(Xg,Yg,Zg) ;
- } else {
- Xg = X; Yg = Y; Zg = Z;
+ if (MyViewer->IsGridActive())
+ {
+ Graphic3d_Vertex aVrp (theX, theY, theZ);
+ Graphic3d_Vertex aNewVrp = Compute (aVrp);
+ aNewVrp.Coord (theXg, theYg, theZg);
+ }
+ else
+ {
+ theXg = theX; theYg = theY; theZg = theZ;
}
}
const Standard_Integer theY2);
//! Destroys the view.
- Standard_EXPORT void Remove() const;
+ Standard_EXPORT void Remove();
//! Deprecated, Redraw() should be used instead.
Standard_EXPORT void Update() const;
Standard_EXPORT Standard_Boolean SetImmediateUpdate (const Standard_Boolean theImmediateUpdate);
//! Returns trihedron object.
- const Handle(V3d_Trihedron)& Trihedron() const { return myTrihedron; }
+ const Handle(V3d_Trihedron)& Trihedron (bool theToCreate = true)
+ {
+ if (myTrihedron.IsNull() && theToCreate)
+ {
+ myTrihedron = new V3d_Trihedron();
+ }
+ return myTrihedron;
+ }
//! Customization of the ZBUFFER Triedron.
//! XColor,YColor,ZColor - colors of axis
+ gp_Vec (aPnt0);
return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
}
- else // IsCircular
+ else if (Handle(Aspect_CircularGrid) aCircleGrid = Handle(Aspect_CircularGrid)::DownCast (MyGrid))
{
- Handle(Aspect_CircularGrid) aCircleGrid = Handle(Aspect_CircularGrid)::DownCast (MyGrid);
const Standard_Real anAlpha = M_PI / Standard_Real (aCircleGrid->DivisionNumber());
// project point on plane to grid local space
const gp_Vec aResult = aGridX * aLocalX + aGridY * aLocalY + gp_Vec (aPnt0);
return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
}
+ return Graphic3d_Vertex (0.0, 0.0, 0.0);
}
//=============================================================================
const Standard_Real theAxisDiametr,
const Standard_Integer theNbFacettes)
{
- myTrihedron->SetArrowsColor (theXColor, theYColor, theZColor);
- myTrihedron->SetSizeRatio (theSizeRatio);
- myTrihedron->SetNbFacets (theNbFacettes);
- myTrihedron->SetArrowDiameter (theAxisDiametr);
+ const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
+ aTrihedron->SetArrowsColor (theXColor, theYColor, theZColor);
+ aTrihedron->SetSizeRatio (theSizeRatio);
+ aTrihedron->SetNbFacets (theNbFacettes);
+ aTrihedron->SetArrowDiameter (theAxisDiametr);
}
//=============================================================================
const Standard_Real theScale,
const V3d_TypeOfVisualization theMode)
{
- myTrihedron->SetLabelsColor (theColor);
- myTrihedron->SetScale (theScale);
- myTrihedron->SetPosition (thePosition);
- myTrihedron->SetWireframe (theMode == V3d_WIREFRAME);
+ const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
+ aTrihedron->SetLabelsColor (theColor);
+ aTrihedron->SetScale (theScale);
+ aTrihedron->SetPosition (thePosition);
+ aTrihedron->SetWireframe (theMode == V3d_WIREFRAME);
- myTrihedron->Display (*this);
+ aTrihedron->Display (*this);
}
//=============================================================================
//=============================================================================
void V3d_View::TriedronErase()
{
- myTrihedron->Erase();
+ if (!myTrihedron.IsNull())
+ {
+ myTrihedron->Erase();
+ }
}
//=============================================================================
myGridEcho (Standard_True),
myGridEchoLastVert (ShortRealLast(), ShortRealLast(), ShortRealLast())
{
- myRGrid = new V3d_RectangularGrid (this, Quantity_Color (Quantity_NOC_GRAY50), Quantity_Color (Quantity_NOC_GRAY70));
- myCGrid = new V3d_CircularGrid (this, Quantity_Color (Quantity_NOC_GRAY50), Quantity_Color (Quantity_NOC_GRAY70));
+ //
}
// ========================================================================
{
theView->SetLightOn (anActiveLightIter.Value());
}
-
- theView->SetGrid (myPrivilegedPlane, Grid ());
- theView->SetGridActivity (Grid ()->IsActive ());
+ if (Handle(Aspect_Grid) aGrid = Grid (false))
+ {
+ theView->SetGrid (myPrivilegedPlane, aGrid);
+ theView->SetGridActivity (aGrid->IsActive());
+ }
if (theView->SetImmediateUpdate (Standard_False))
{
theView->Redraw();
void V3d_Viewer::SetPrivilegedPlane (const gp_Ax3& thePlane)
{
myPrivilegedPlane = thePlane;
- Grid()->SetDrawMode(Grid()->DrawMode());
+ Handle(Aspect_Grid) aGrid = Grid (true);
+ aGrid->SetDrawMode (aGrid->DrawMode()); // aGrid->UpdateDisplay();
for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
{
- anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, Grid());
+ anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, aGrid);
}
if (myDisplayPlane)
if (!myDisplayPlane)
{
if (!myPlaneStructure.IsNull())
- {
+ {
myPlaneStructure->Erase();
}
return;
//! Returns TRUE when grid echo must be displayed at hit point.
Standard_Boolean GridEcho() const { return myGridEcho; }
-
+
//! Returns Standard_True if a grid is activated in <me>.
- Standard_EXPORT Standard_Boolean IsActive() const;
-
+ Standard_EXPORT Standard_Boolean IsGridActive();
+
//! Returns the defined grid in <me>.
- Standard_EXPORT Handle(Aspect_Grid) Grid() const;
+ Handle(Aspect_Grid) Grid (bool theToCreate = true) { return Grid (myGridType, theToCreate); }
+
+ //! Returns the defined grid in <me>.
+ Standard_EXPORT Handle(Aspect_Grid) Grid (Aspect_GridType theGridType, bool theToCreate = true);
//! Returns the current grid type defined in <me>.
Aspect_GridType GridType() const { return myGridType; }
-
+
//! Returns the current grid draw mode defined in <me>.
- Standard_EXPORT Aspect_GridDrawMode GridDrawMode() const;
-
+ Standard_EXPORT Aspect_GridDrawMode GridDrawMode();
+
//! Returns the definition of the rectangular grid.
- Standard_EXPORT void RectangularGridValues (Standard_Real& XOrigin, Standard_Real& YOrigin, Standard_Real& XStep, Standard_Real& YStep, Standard_Real& RotationAngle) const;
-
+ Standard_EXPORT void RectangularGridValues (Standard_Real& theXOrigin, Standard_Real& theYOrigin,
+ Standard_Real& theXStep, Standard_Real& theYStep,
+ Standard_Real& theRotationAngle);
+
//! Sets the definition of the rectangular grid.
//! <XOrigin>, <YOrigin> defines the origin of the grid.
//! <XStep> defines the interval between 2 vertical lines.
//! <YStep> defines the interval between 2 horizontal lines.
//! <RotationAngle> defines the rotation angle of the grid.
Standard_EXPORT void SetRectangularGridValues (const Standard_Real XOrigin, const Standard_Real YOrigin, const Standard_Real XStep, const Standard_Real YStep, const Standard_Real RotationAngle);
-
+
//! Returns the definition of the circular grid.
- Standard_EXPORT void CircularGridValues (Standard_Real& XOrigin, Standard_Real& YOrigin, Standard_Real& RadiusStep, Standard_Integer& DivisionNumber, Standard_Real& RotationAngle) const;
-
+ Standard_EXPORT void CircularGridValues (Standard_Real& theXOrigin, Standard_Real& theYOrigin,
+ Standard_Real& theRadiusStep,
+ Standard_Integer& theDivisionNumber,
+ Standard_Real& theRotationAngle);
+
//! Sets the definition of the circular grid.
//! <XOrigin>, <YOrigin> defines the origin of the grid.
//! <RadiusStep> defines the interval between 2 circles.
//! <DivisionNumber> defines the section number of one half circle.
//! <RotationAngle> defines the rotation angle of the grid.
Standard_EXPORT void SetCircularGridValues (const Standard_Real XOrigin, const Standard_Real YOrigin, const Standard_Real RadiusStep, const Standard_Integer DivisionNumber, const Standard_Real RotationAngle);
-
+
//! Returns the location and the size of the grid.
- Standard_EXPORT void CircularGridGraphicValues (Standard_Real& Radius, Standard_Real& OffSet) const;
-
+ Standard_EXPORT void CircularGridGraphicValues (Standard_Real& theRadius,
+ Standard_Real& theOffSet);
+
//! Sets the location and the size of the grid.
//! <XSize> defines the width of the grid.
//! <YSize> defines the height of the grid.
//! <OffSet> defines the displacement along the plane normal.
Standard_EXPORT void SetCircularGridGraphicValues (const Standard_Real Radius, const Standard_Real OffSet);
-
+
//! Returns the location and the size of the grid.
- Standard_EXPORT void RectangularGridGraphicValues (Standard_Real& XSize, Standard_Real& YSize, Standard_Real& OffSet) const;
-
+ Standard_EXPORT void RectangularGridGraphicValues (Standard_Real& theXSize, Standard_Real& theYSize,
+ Standard_Real& theOffSet);
+
//! Sets the location and the size of the grid.
//! <XSize> defines the width of the grid.
//! <YSize> defines the height of the grid.
public: //! @name deprecated methods
+ //! Returns Standard_True if a grid is activated in <me>.
+ Standard_DEPRECATED ("Deprecated method - IsGridActive() should be used instead")
+ Standard_Boolean IsActive() { return IsGridActive(); }
+
//! Initializes an internal iterator on the active views.
Standard_DEPRECATED ("Deprecated method - ActiveViews() should be used instead")
void InitActiveViews() { myActiveViewsIterator.Initialize (myActiveViews); }
// function : Grid
// purpose :
// =======================================================================
-Handle(Aspect_Grid) V3d_Viewer::Grid() const
+Handle(Aspect_Grid) V3d_Viewer::Grid (Aspect_GridType theGridType, bool theToCreate)
{
- switch (myGridType)
+ switch (theGridType)
{
- case Aspect_GT_Circular: return Handle(Aspect_Grid) (myCGrid);
- case Aspect_GT_Rectangular: return Handle(Aspect_Grid) (myRGrid);
+ case Aspect_GT_Circular:
+ {
+ if (myCGrid.IsNull() && theToCreate)
+ {
+ myCGrid = new V3d_CircularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
+ }
+ return Handle(Aspect_Grid) (myCGrid);
+ }
+ case Aspect_GT_Rectangular:
+ {
+ if (myRGrid.IsNull() && theToCreate)
+ {
+ myRGrid = new V3d_RectangularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
+ }
+ return Handle(Aspect_Grid) (myRGrid);
+ }
}
- return Handle(Aspect_Grid) (myRGrid);
+ return Handle(Aspect_Grid)();
}
// =======================================================================
// function : GridDrawMode
// purpose :
// =======================================================================
-Aspect_GridDrawMode V3d_Viewer::GridDrawMode() const
+Aspect_GridDrawMode V3d_Viewer::GridDrawMode()
{
- return Grid()->DrawMode();
+ Handle(Aspect_Grid) aGrid = Grid (false);
+ return !aGrid.IsNull() ? aGrid->DrawMode() : Aspect_GDM_Lines;
}
// =======================================================================
void V3d_Viewer::ActivateGrid (const Aspect_GridType theType,
const Aspect_GridDrawMode theMode)
{
- Grid()->Erase();
+ if (Handle(Aspect_Grid) anOldGrid = Grid (false))
+ {
+ anOldGrid->Erase();
+ }
+
myGridType = theType;
- Grid()->SetDrawMode (theMode);
+ Handle(Aspect_Grid) aGrid = Grid (true);
+ aGrid->SetDrawMode (theMode);
if (theMode != Aspect_GDM_None)
{
- Grid()->Display();
+ aGrid->Display();
}
- Grid()->Activate();
+ aGrid->Activate();
for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
{
- anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, Grid());
+ anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, aGrid);
}
}
// =======================================================================
void V3d_Viewer::DeactivateGrid()
{
- Grid()->Erase();
+ Handle(Aspect_Grid) aGrid = Grid (false);
+ if (aGrid.IsNull())
+ {
+ return;
+ }
+
+ aGrid->Erase();
+ aGrid->Deactivate();
+
myGridType = Aspect_GT_Rectangular;
- Grid()->Deactivate();
for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
{
anActiveViewIter.Value()->SetGridActivity (Standard_False);
}
// =======================================================================
-// function : IsActive
+// function : IsGridActive
// purpose :
// =======================================================================
-Standard_Boolean V3d_Viewer::IsActive() const
+Standard_Boolean V3d_Viewer::IsGridActive()
{
- return Grid()->IsActive();
+ Handle(Aspect_Grid) aGrid = Grid (false);
+ return !aGrid.IsNull() && aGrid->IsActive();
}
// =======================================================================
Standard_Real& theYOrigin,
Standard_Real& theXStep,
Standard_Real& theYStep,
- Standard_Real& theRotationAngle) const
+ Standard_Real& theRotationAngle)
{
+ Grid (Aspect_GT_Rectangular, true);
theXOrigin = myRGrid->XOrigin();
theYOrigin = myRGrid->YOrigin();
theXStep = myRGrid->XStep();
const Standard_Real theYStep,
const Standard_Real theRotationAngle)
{
+ Grid (Aspect_GT_Rectangular, true);
myRGrid->SetGridValues (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
{
Standard_Real& theYOrigin,
Standard_Real& theRadiusStep,
Standard_Integer& theDivisionNumber,
- Standard_Real& theRotationAngle) const
+ Standard_Real& theRotationAngle)
{
+ Grid (Aspect_GT_Circular, true);
theXOrigin = myCGrid->XOrigin();
theYOrigin = myCGrid->YOrigin();
theRadiusStep = myCGrid->RadiusStep();
const Standard_Integer theDivisionNumber,
const Standard_Real theRotationAngle)
{
+ Grid (Aspect_GT_Circular, true);
myCGrid->SetGridValues (theXOrigin, theYOrigin, theRadiusStep,
theDivisionNumber, theRotationAngle);
for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
// =======================================================================
void V3d_Viewer::RectangularGridGraphicValues (Standard_Real& theXSize,
Standard_Real& theYSize,
- Standard_Real& theOffSet) const
+ Standard_Real& theOffSet)
{
+ Grid (Aspect_GT_Rectangular, true);
myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
}
const Standard_Real theYSize,
const Standard_Real theOffSet)
{
+ Grid (Aspect_GT_Rectangular, true);
myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
}
// purpose :
// =======================================================================
void V3d_Viewer::CircularGridGraphicValues (Standard_Real& theRadius,
- Standard_Real& theOffSet) const
+ Standard_Real& theOffSet)
{
+ Grid (Aspect_GT_Circular, true);
myCGrid->GraphicValues (theRadius, theOffSet);
}
void V3d_Viewer::SetCircularGridGraphicValues (const Standard_Real theRadius,
const Standard_Real theOffSet)
{
+ Grid (Aspect_GT_Circular, true);
myCGrid->SetGraphicValues (theRadius, theOffSet);
}
return 1;
}
- const Standard_Boolean toEchoGrid = aContext->CurrentViewer()->Grid()->IsActive()
+ const Standard_Boolean toEchoGrid = aContext->CurrentViewer()->IsGridActive()
&& aContext->CurrentViewer()->GridEcho();
if (toEchoGrid)
{