From 475c2302d4e46524e9934d612174ee4da790d28a Mon Sep 17 00:00:00 2001 From: kgv Date: Mon, 10 Jul 2017 08:54:15 +0300 Subject: [PATCH] 0028889: Visualization, V3d_View - View specific Graphic3d_Structure should be removed if the view is removed V3d_View::Remove() - erase trihedron and grid structures from structure manager. --- src/Aspect/Aspect_CircularGrid.cxx | 5 +- src/Aspect/Aspect_CircularGrid.hxx | 13 +-- src/Aspect/Aspect_Grid.cxx | 155 +++++++++++--------------- src/Aspect/Aspect_Grid.hxx | 49 ++++---- src/Aspect/Aspect_RectangularGrid.cxx | 6 +- src/Aspect/Aspect_RectangularGrid.hxx | 16 ++- src/V3d/V3d_CircularGrid.cxx | 17 ++- src/V3d/V3d_CircularGrid.hxx | 31 ++---- src/V3d/V3d_RectangularGrid.cxx | 34 ++---- src/V3d/V3d_RectangularGrid.hxx | 39 ++----- src/V3d/V3d_Trihedron.cxx | 9 ++ src/V3d/V3d_Trihedron.hxx | 3 + src/V3d/V3d_View.cxx | 46 ++++---- src/V3d/V3d_View.hxx | 2 +- src/V3d/V3d_View_4.cxx | 119 +++++++------------- 15 files changed, 217 insertions(+), 327 deletions(-) diff --git a/src/Aspect/Aspect_CircularGrid.cxx b/src/Aspect/Aspect_CircularGrid.cxx index 8bddca6fb9..7ba90c1c55 100644 --- a/src/Aspect/Aspect_CircularGrid.cxx +++ b/src/Aspect/Aspect_CircularGrid.cxx @@ -11,14 +11,11 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI - #include -#include + #include #include #include -#include IMPLEMENT_STANDARD_RTTIEXT(Aspect_CircularGrid,Aspect_Grid) diff --git a/src/Aspect/Aspect_CircularGrid.hxx b/src/Aspect/Aspect_CircularGrid.hxx index 731d3e1da6..f3f82d1713 100644 --- a/src/Aspect/Aspect_CircularGrid.hxx +++ b/src/Aspect/Aspect_CircularGrid.hxx @@ -28,12 +28,9 @@ class Standard_NegativeValue; class Standard_NullValue; class Standard_NumericError; -class Aspect_CircularGrid; -DEFINE_STANDARD_HANDLE(Aspect_CircularGrid, Aspect_Grid) - class Aspect_CircularGrid : public Aspect_Grid { - + DEFINE_STANDARD_RTTIEXT(Aspect_CircularGrid, Aspect_Grid) public: //! creates a new grid. By default this grid is not @@ -49,7 +46,7 @@ public: Standard_EXPORT void SetGridValues (const Standard_Real XOrigin, const Standard_Real YOrigin, const Standard_Real RadiusStep, const Standard_Integer DivisionNumber, const Standard_Real RotationAngle); //! returns the point of the grid the closest to the point X,Y - Standard_EXPORT void Compute (const Standard_Real X, const Standard_Real Y, Standard_Real& gridX, Standard_Real& gridY) const Standard_OVERRIDE; + Standard_EXPORT virtual void Compute (const Standard_Real X, const Standard_Real Y, Standard_Real& gridX, Standard_Real& gridY) const Standard_OVERRIDE; //! returns the x step of the grid. Standard_EXPORT Standard_Real RadiusStep() const; @@ -57,9 +54,7 @@ public: //! returns the x step of the grid. Standard_EXPORT Standard_Integer DivisionNumber() const; - Standard_EXPORT void Init() Standard_OVERRIDE; - - DEFINE_STANDARD_RTTIEXT(Aspect_CircularGrid,Aspect_Grid) + Standard_EXPORT virtual void Init() Standard_OVERRIDE; private: @@ -71,4 +66,6 @@ private: }; +DEFINE_STANDARD_HANDLE(Aspect_CircularGrid, Aspect_Grid) + #endif // _Aspect_CircularGrid_HeaderFile diff --git a/src/Aspect/Aspect_Grid.cxx b/src/Aspect/Aspect_Grid.cxx index a67b7e050e..e06917f495 100644 --- a/src/Aspect/Aspect_Grid.cxx +++ b/src/Aspect/Aspect_Grid.cxx @@ -11,123 +11,96 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include -#include -#include IMPLEMENT_STANDARD_RTTIEXT(Aspect_Grid,Standard_Transient) -Aspect_Grid::Aspect_Grid( - const Standard_Real anXOrigin, - const Standard_Real anYOrigin, - const Standard_Real anAngle, - const Quantity_Color& aColor, - const Quantity_Color& aTenthColor) -: myRotationAngle(anAngle), - myXOrigin(anXOrigin), - myYOrigin(anYOrigin), - myColor(aColor), - myTenthColor(aTenthColor), - myIsActive(Standard_False), - myDrawMode(Aspect_GDM_Lines) +Aspect_Grid::Aspect_Grid (const Standard_Real theXOrigin, + const Standard_Real theYOrigin, + const Standard_Real theAngle, + const Quantity_Color& theColor, + const Quantity_Color& theTenthColor) +: myRotationAngle (theAngle), + myXOrigin (theXOrigin), + myYOrigin (theYOrigin), + myColor (theColor), + myTenthColor (theTenthColor), + myIsActive (Standard_False), + myDrawMode (Aspect_GDM_Lines) { + // } - -void Aspect_Grid::SetXOrigin(const Standard_Real anOrigin) { - myXOrigin = anOrigin; +void Aspect_Grid::SetXOrigin (const Standard_Real theOrigin) +{ + myXOrigin = theOrigin; Init(); UpdateDisplay(); } -void Aspect_Grid::SetYOrigin(const Standard_Real anOrigin) { - myYOrigin = anOrigin; +void Aspect_Grid::SetYOrigin (const Standard_Real theOrigin) +{ + myYOrigin = theOrigin; Init(); UpdateDisplay(); } -void Aspect_Grid::SetRotationAngle(const Standard_Real anAngle){ - - - myRotationAngle = anAngle; - Init(); - UpdateDisplay(); -} -void Aspect_Grid::Rotate(const Standard_Real anAngle) { - myRotationAngle += anAngle; - Init(); - UpdateDisplay(); -} -void Aspect_Grid::Translate(const Standard_Real aDx, - const Standard_Real aDy) { - myXOrigin += aDx; - myYOrigin += aDy; +void Aspect_Grid::SetRotationAngle (const Standard_Real theAngle) +{ + myRotationAngle = theAngle; Init(); UpdateDisplay(); } -void Aspect_Grid::SetColors(const Quantity_Color& aColor, - const Quantity_Color& aTenthColor) { - myColor = aColor; - myTenthColor = aTenthColor; +void Aspect_Grid::Rotate (const Standard_Real theAngle) +{ + myRotationAngle += theAngle; + Init(); UpdateDisplay(); } -void Aspect_Grid::Colors(Quantity_Color& aColor, - Quantity_Color& aTenthColor) const { - aColor = myColor; - aTenthColor = myTenthColor; +void Aspect_Grid::Translate (const Standard_Real theDx, + const Standard_Real theDy) +{ + myXOrigin += theDx; + myYOrigin += theDy; + Init(); + UpdateDisplay(); } -void Aspect_Grid::Hit(const Standard_Real X, - const Standard_Real Y, - Standard_Real& gridX, - Standard_Real& gridY) const { - if (myIsActive) { - Compute(X,Y,gridX,gridY);} - else{ - gridX = X; - gridY = Y; +void Aspect_Grid::SetColors (const Quantity_Color& theColor, + const Quantity_Color& theTenthColor) +{ + myColor = theColor; + myTenthColor = theTenthColor; + UpdateDisplay(); +} + +void Aspect_Grid::Colors (Quantity_Color& theColor, + Quantity_Color& theTenthColor) const +{ + theColor = myColor; + theTenthColor = myTenthColor; +} + +void Aspect_Grid::Hit (const Standard_Real theX, + const Standard_Real theY, + Standard_Real& theGridX, + Standard_Real& theGridY) const +{ + if (myIsActive) + { + Compute (theX, theY, theGridX, theGridY); + } + else + { + theGridX = theX; + theGridY = theY; } - } -void Aspect_Grid::Activate () { - myIsActive = Standard_True; } -void Aspect_Grid::Deactivate () { - myIsActive = Standard_False; -} - -Standard_Real Aspect_Grid::XOrigin() const { - return myXOrigin; -} - -Standard_Real Aspect_Grid::YOrigin() const { - return myYOrigin; -} - -Standard_Real Aspect_Grid::RotationAngle() const { - return myRotationAngle; -} - -Standard_Boolean Aspect_Grid::IsActive() const { - return myIsActive; -} -void Aspect_Grid::Display() {} - -void Aspect_Grid::Erase () const {} - -void Aspect_Grid::UpdateDisplay () {} - - -Standard_Boolean Aspect_Grid::IsDisplayed() const { - return Standard_False;} - -void Aspect_Grid::SetDrawMode(const Aspect_GridDrawMode aDrawMode) { - myDrawMode = aDrawMode; +void Aspect_Grid::SetDrawMode (const Aspect_GridDrawMode theDrawMode) +{ + myDrawMode = theDrawMode; UpdateDisplay(); } -Aspect_GridDrawMode Aspect_Grid::DrawMode() const { - return myDrawMode; -} diff --git a/src/Aspect/Aspect_Grid.hxx b/src/Aspect/Aspect_Grid.hxx index 556935dff8..8127e46bb8 100644 --- a/src/Aspect/Aspect_Grid.hxx +++ b/src/Aspect/Aspect_Grid.hxx @@ -25,12 +25,9 @@ #include #include -class Aspect_Grid; -DEFINE_STANDARD_HANDLE(Aspect_Grid, Standard_Transient) - class Aspect_Grid : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(Aspect_Grid, Standard_Transient) public: //! defines the x Origin of the grid. @@ -39,7 +36,7 @@ public: //! defines the y Origin of the grid. Standard_EXPORT void SetYOrigin (const Standard_Real anOrigin); - //! defines the orientation of the the grid. + //! defines the orientation of the grid. Standard_EXPORT void SetRotationAngle (const Standard_Real anAngle); //! Rotate the grid from a relative angle. @@ -62,23 +59,23 @@ public: //! activates the grid. The Hit method will return //! gridx and gridx computed according to the steps //! of the grid. - Standard_EXPORT void Activate(); + void Activate() { myIsActive = Standard_True; } //! deactivates the grid. The hit method will return //! gridx and gridx as the enter value X & Y. - Standard_EXPORT void Deactivate(); + void Deactivate() { myIsActive = Standard_False; } //! returns the x Origin of the grid. - Standard_EXPORT Standard_Real XOrigin() const; + Standard_Real XOrigin() const { return myXOrigin; } //! returns the x Origin of the grid. - Standard_EXPORT Standard_Real YOrigin() const; + Standard_Real YOrigin() const { return myYOrigin; } //! returns the x Angle of the grid. - Standard_EXPORT Standard_Real RotationAngle() const; + Standard_Real RotationAngle() const { return myRotationAngle; } //! Returns TRUE when the grid is active. - Standard_EXPORT Standard_Boolean IsActive() const; + Standard_Boolean IsActive() const { return myIsActive; } //! Returns the colors of the grid. Standard_EXPORT void Colors (Quantity_Color& aColor, Quantity_Color& aTenthColor) const; @@ -87,41 +84,43 @@ public: Standard_EXPORT void SetDrawMode (const Aspect_GridDrawMode aDrawMode); //! Returns the grid aspect. - Standard_EXPORT Aspect_GridDrawMode DrawMode() const; - + Aspect_GridDrawMode DrawMode() const { return myDrawMode; } + //! Display the grid at screen. - Standard_EXPORT virtual void Display(); + Standard_EXPORT virtual void Display() = 0; //! Erase the grid from screen. - Standard_EXPORT virtual void Erase() const; + Standard_EXPORT virtual void Erase() const = 0; //! Returns TRUE when the grid is displayed at screen. - Standard_EXPORT virtual Standard_Boolean IsDisplayed() const; + Standard_EXPORT virtual Standard_Boolean IsDisplayed() const = 0; Standard_EXPORT virtual void Init() = 0; - DEFINE_STANDARD_RTTIEXT(Aspect_Grid,Standard_Transient) - protected: - //! creates a new grid. By default this grid is not - //! active. - Standard_EXPORT Aspect_Grid(const Standard_Real anXOrigin = 0.0, const Standard_Real anYOrigin = 0.0, const Standard_Real aRotationAngle = 0, const Quantity_Color& aColor = Quantity_NOC_GRAY50, const Quantity_Color& aTenthColor = Quantity_NOC_GRAY70); + //! Creates a new grid. By default this grid is not active. + Standard_EXPORT Aspect_Grid (const Standard_Real theXOrigin = 0.0, + const Standard_Real theYOrigin = 0.0, + const Standard_Real theRotationAngle = 0, + const Quantity_Color& theColor = Quantity_NOC_GRAY50, + const Quantity_Color& theTenthColor = Quantity_NOC_GRAY70); //! Updates the grid parameters. - Standard_EXPORT virtual void UpdateDisplay(); + Standard_EXPORT virtual void UpdateDisplay() = 0; + +protected: Standard_Real myRotationAngle; Standard_Real myXOrigin; Standard_Real myYOrigin; Quantity_Color myColor; Quantity_Color myTenthColor; - -private: - Standard_Boolean myIsActive; Aspect_GridDrawMode myDrawMode; }; +DEFINE_STANDARD_HANDLE(Aspect_Grid, Standard_Transient) + #endif // _Aspect_Grid_HeaderFile diff --git a/src/Aspect/Aspect_RectangularGrid.cxx b/src/Aspect/Aspect_RectangularGrid.cxx index c470c2c058..b41c32f277 100644 --- a/src/Aspect/Aspect_RectangularGrid.cxx +++ b/src/Aspect/Aspect_RectangularGrid.cxx @@ -11,13 +11,11 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI - #include + #include #include #include -#include IMPLEMENT_STANDARD_RTTIEXT(Aspect_RectangularGrid,Aspect_Grid) @@ -157,5 +155,3 @@ Standard_Boolean Aspect_RectangularGrid::CheckAngle(const Standard_Real alpha, const Standard_Real beta) const { return (Abs( Sin(alpha) * Cos(beta + M_PI / 2.) - Cos(alpha) * Sin(beta + M_PI / 2.)) != 0) ; } - - diff --git a/src/Aspect/Aspect_RectangularGrid.hxx b/src/Aspect/Aspect_RectangularGrid.hxx index a00e1b3a9d..14dd93cdc5 100644 --- a/src/Aspect/Aspect_RectangularGrid.hxx +++ b/src/Aspect/Aspect_RectangularGrid.hxx @@ -27,15 +27,11 @@ class Standard_NegativeValue; class Standard_NullValue; class Standard_NumericError; -class Aspect_RectangularGrid; -DEFINE_STANDARD_HANDLE(Aspect_RectangularGrid, Aspect_Grid) - class Aspect_RectangularGrid : public Aspect_Grid { - + DEFINE_STANDARD_RTTIEXT(Aspect_RectangularGrid, Aspect_Grid) public: - //! creates a new grid. By default this grid is not //! active. //! The first angle is given relatively to the horizontal. @@ -56,7 +52,7 @@ public: Standard_EXPORT void SetGridValues (const Standard_Real XOrigin, const Standard_Real YOrigin, const Standard_Real XStep, const Standard_Real YStep, const Standard_Real RotationAngle); //! returns the point of the grid the closest to the point X,Y - Standard_EXPORT void Compute (const Standard_Real X, const Standard_Real Y, Standard_Real& gridX, Standard_Real& gridY) const Standard_OVERRIDE; + Standard_EXPORT virtual void Compute (const Standard_Real X, const Standard_Real Y, Standard_Real& gridX, Standard_Real& gridY) const Standard_OVERRIDE; //! returns the x step of the grid. Standard_EXPORT Standard_Real XStep() const; @@ -70,14 +66,14 @@ public: //! returns the y Angle of the grid, relatively to the vertical. Standard_EXPORT Standard_Real SecondAngle() const; - Standard_EXPORT void Init() Standard_OVERRIDE; - - DEFINE_STANDARD_RTTIEXT(Aspect_RectangularGrid,Aspect_Grid) + Standard_EXPORT virtual void Init() Standard_OVERRIDE; private: Standard_EXPORT Standard_Boolean CheckAngle (const Standard_Real alpha, const Standard_Real beta) const; +private: + Standard_Real myXStep; Standard_Real myYStep; Standard_Real myFirstAngle; @@ -91,4 +87,6 @@ private: }; +DEFINE_STANDARD_HANDLE(Aspect_RectangularGrid, Aspect_Grid) + #endif // _Aspect_RectangularGrid_HeaderFile diff --git a/src/V3d/V3d_CircularGrid.cxx b/src/V3d/V3d_CircularGrid.cxx index 23a55ab0aa..9e591e573e 100644 --- a/src/V3d/V3d_CircularGrid.cxx +++ b/src/V3d/V3d_CircularGrid.cxx @@ -34,7 +34,6 @@ IMPLEMENT_STANDARD_RTTIEXT(V3d_CircularGrid,Aspect_CircularGrid) * Constant */ #define DIVISION 8 -#define MYMINMAX 25. #define MYFACTOR 50. /*----------------------------------------------------------------------*/ @@ -57,6 +56,15 @@ V3d_CircularGrid::V3d_CircularGrid (const V3d_ViewerPointer& aViewer, const Quan 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 ) { @@ -144,10 +152,9 @@ void V3d_CircularGrid::UpdateDisplay () myCurViewPlane = ThePlane; } - switch (DrawMode()) + switch (myDrawMode) { - default: - //case Aspect_GDM_Points: + case Aspect_GDM_Points: DefinePoints (); myCurDrawMode = Aspect_GDM_Points; break; @@ -155,11 +162,9 @@ void V3d_CircularGrid::UpdateDisplay () DefineLines (); myCurDrawMode = Aspect_GDM_Lines; break; -#ifdef IMP210100 case Aspect_GDM_None: myCurDrawMode = Aspect_GDM_None; break; -#endif } myCurAreDefined = Standard_True; } diff --git a/src/V3d/V3d_CircularGrid.hxx b/src/V3d/V3d_CircularGrid.hxx index 6e3ec1c4f4..769c76bec9 100644 --- a/src/V3d/V3d_CircularGrid.hxx +++ b/src/V3d/V3d_CircularGrid.hxx @@ -29,21 +29,16 @@ #include class Graphic3d_Structure; class Graphic3d_Group; -class Quantity_Color; - - -class V3d_CircularGrid; -DEFINE_STANDARD_HANDLE(V3d_CircularGrid, Aspect_CircularGrid) - class V3d_CircularGrid : public Aspect_CircularGrid { - + DEFINE_STANDARD_RTTIEXT(V3d_CircularGrid, Aspect_CircularGrid) public: - Standard_EXPORT V3d_CircularGrid(const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor); - + + Standard_EXPORT virtual ~V3d_CircularGrid(); + Standard_EXPORT void SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) Standard_OVERRIDE; Standard_EXPORT void Display() Standard_OVERRIDE; @@ -56,25 +51,18 @@ public: Standard_EXPORT void SetGraphicValues (const Standard_Real Radius, const Standard_Real OffSet); - - - - DEFINE_STANDARD_RTTIEXT(V3d_CircularGrid,Aspect_CircularGrid) - protected: - Standard_EXPORT void UpdateDisplay() Standard_OVERRIDE; - - private: - Standard_EXPORT void DefineLines(); Standard_EXPORT void DefinePoints(); +private: + Handle(Graphic3d_Structure) myStructure; Handle(Graphic3d_Group) myGroup; gp_Ax3 myCurViewPlane; @@ -89,13 +77,8 @@ private: Standard_Real myRadius; Standard_Real myOffSet; - }; - - - - - +DEFINE_STANDARD_HANDLE(V3d_CircularGrid, Aspect_CircularGrid) #endif // _V3d_CircularGrid_HeaderFile diff --git a/src/V3d/V3d_RectangularGrid.cxx b/src/V3d/V3d_RectangularGrid.cxx index 3395f336a9..d5295981c1 100644 --- a/src/V3d/V3d_RectangularGrid.cxx +++ b/src/V3d/V3d_RectangularGrid.cxx @@ -11,21 +11,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -/*********************************************************************** - FONCTION : - ---------- - Classe V3d_CircularGrid : - HISTORIQUE DES MODIFICATIONS : - -------------------------------- - 16-08-98 : CAL ; S3892. Ajout grilles 3d. - 13-10-98 : CAL ; S3892. Ajout de la gestion de la taille des grilles 3d. - 23-10-98 : CAL ; PRO 15885. Patch K4403 et K4404 - 03-11-98 : CAL ; PRO 16161. Patch K4418 et K4419 -************************************************************************/ -/*----------------------------------------------------------------------*/ -/* - * Includes - */ +#include #include #include @@ -38,7 +24,6 @@ #include #include #include -#include #include IMPLEMENT_STANDARD_RTTIEXT(V3d_RectangularGrid,Aspect_RectangularGrid) @@ -47,7 +32,6 @@ IMPLEMENT_STANDARD_RTTIEXT(V3d_RectangularGrid,Aspect_RectangularGrid) /* * Constant */ -#define MYMINMAX 25. #define MYFACTOR 50. /*----------------------------------------------------------------------*/ @@ -72,6 +56,15 @@ V3d_RectangularGrid::V3d_RectangularGrid (const V3d_ViewerPointer& aViewer, cons SetYStep (step); } +V3d_RectangularGrid::~V3d_RectangularGrid() +{ + myGroup.Nullify(); + if (!myStructure.IsNull()) + { + myStructure->Erase(); + } +} + void V3d_RectangularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) { if( myColor != aColor || myTenthColor != aTenthColor ) { @@ -158,10 +151,9 @@ void V3d_RectangularGrid::UpdateDisplay () myCurViewPlane = ThePlane; } - switch (DrawMode ()) + switch (myDrawMode) { - default: - //case Aspect_GDM_Points: + case Aspect_GDM_Points: DefinePoints (); myCurDrawMode = Aspect_GDM_Points; break; @@ -169,11 +161,9 @@ void V3d_RectangularGrid::UpdateDisplay () DefineLines (); myCurDrawMode = Aspect_GDM_Lines; break; -#ifdef IMP210100 case Aspect_GDM_None: myCurDrawMode = Aspect_GDM_None; break; -#endif } myCurAreDefined = Standard_True; } diff --git a/src/V3d/V3d_RectangularGrid.hxx b/src/V3d/V3d_RectangularGrid.hxx index ad93debc47..de93636f13 100644 --- a/src/V3d/V3d_RectangularGrid.hxx +++ b/src/V3d/V3d_RectangularGrid.hxx @@ -28,52 +28,40 @@ #include class Graphic3d_Structure; class Graphic3d_Group; -class Quantity_Color; - - -class V3d_RectangularGrid; -DEFINE_STANDARD_HANDLE(V3d_RectangularGrid, Aspect_RectangularGrid) - class V3d_RectangularGrid : public Aspect_RectangularGrid { - + DEFINE_STANDARD_RTTIEXT(V3d_RectangularGrid, Aspect_RectangularGrid) public: - Standard_EXPORT V3d_RectangularGrid(const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor); + + Standard_EXPORT virtual ~V3d_RectangularGrid(); - Standard_EXPORT void SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) Standard_OVERRIDE; + Standard_EXPORT virtual void SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) Standard_OVERRIDE; - Standard_EXPORT void Display() Standard_OVERRIDE; + Standard_EXPORT virtual void Display() Standard_OVERRIDE; - Standard_EXPORT void Erase() const Standard_OVERRIDE; + Standard_EXPORT virtual void Erase() const Standard_OVERRIDE; - Standard_EXPORT Standard_Boolean IsDisplayed() const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_Boolean IsDisplayed() const Standard_OVERRIDE; Standard_EXPORT void GraphicValues (Standard_Real& XSize, Standard_Real& YSize, Standard_Real& OffSet) const; Standard_EXPORT void SetGraphicValues (const Standard_Real XSize, const Standard_Real YSize, const Standard_Real OffSet); - - - - DEFINE_STANDARD_RTTIEXT(V3d_RectangularGrid,Aspect_RectangularGrid) - protected: - - Standard_EXPORT void UpdateDisplay() Standard_OVERRIDE; - - + Standard_EXPORT virtual void UpdateDisplay() Standard_OVERRIDE; private: - Standard_EXPORT void DefineLines(); Standard_EXPORT void DefinePoints(); +private: + Handle(Graphic3d_Structure) myStructure; Handle(Graphic3d_Group) myGroup; gp_Ax3 myCurViewPlane; @@ -89,13 +77,8 @@ private: Standard_Real myYSize; Standard_Real myOffSet; - }; - - - - - +DEFINE_STANDARD_HANDLE(V3d_RectangularGrid, Aspect_RectangularGrid) #endif // _V3d_RectangularGrid_HeaderFile diff --git a/src/V3d/V3d_Trihedron.cxx b/src/V3d/V3d_Trihedron.cxx index a777e571a2..e02db0e4ce 100644 --- a/src/V3d/V3d_Trihedron.cxx +++ b/src/V3d/V3d_Trihedron.cxx @@ -127,6 +127,15 @@ V3d_Trihedron::V3d_Trihedron() myTextAspect->SetVerticalJustification (Graphic3d_VTA_BOTTOM); } +// ============================================================================ +// function : V3d_Trihedron +// purpose : +// ============================================================================ +V3d_Trihedron::~V3d_Trihedron() +{ + Erase(); +} + // ============================================================================ // function : SetLabelsColor // purpose : diff --git a/src/V3d/V3d_Trihedron.hxx b/src/V3d/V3d_Trihedron.hxx index 7c5a1811ed..d609857d4f 100644 --- a/src/V3d/V3d_Trihedron.hxx +++ b/src/V3d/V3d_Trihedron.hxx @@ -35,6 +35,9 @@ public: //! Creates a default trihedron. Standard_EXPORT V3d_Trihedron(); + //! Destructor. + Standard_EXPORT virtual ~V3d_Trihedron(); + //! Switch wireframe / shaded trihedron. void SetWireframe (const Standard_Boolean theAsWireframe) { myIsWireframe = theAsWireframe; } diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index 29f2b0fba6..3e85e84b4f 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -200,6 +200,15 @@ void V3d_View::SetWindow (const Handle(Aspect_Window)& theWindow, //============================================================================= void V3d_View::Remove() const { + if (!MyGrid.IsNull()) + { + MyGrid->Erase(); + } + if (!myTrihedron.IsNull()) + { + myTrihedron->Erase(); + } + MyViewer->DelView (this); myView->Remove(); Handle(Aspect_Window)& aWin = const_cast (MyWindow); @@ -2437,33 +2446,24 @@ Standard_Boolean V3d_View::ScreenAxis( const gp_Dir &Vpn, const gp_Dir &Vup, Gra //function : TrsPoint //purpose : //============================================================================= -Graphic3d_Vertex V3d_View::TrsPoint( const Graphic3d_Vertex &P, const TColStd_Array2OfReal &Matrix ) +gp_XYZ V3d_View::TrsPoint (const Graphic3d_Vertex& thePnt, const TColStd_Array2OfReal& theMat) { - Graphic3d_Vertex PP ; - Standard_Real X,Y,Z,XX,YY,ZZ ; - // CAL. S3892 - Standard_Integer lr, ur, lc, uc; - lr = Matrix.LowerRow (); - ur = Matrix.UpperRow (); - lc = Matrix.LowerCol (); - uc = Matrix.UpperCol (); - if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4) ) { - P.Coord(X,Y,Z) ; - PP.SetCoord(X,Y,Z) ; - return PP ; + const Standard_Integer lr = theMat.LowerRow(); + const Standard_Integer ur = theMat.UpperRow(); + const Standard_Integer lc = theMat.LowerCol(); + const Standard_Integer uc = theMat.UpperCol(); + if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4)) + { + return gp_XYZ (thePnt.X(), thePnt.Y(), thePnt.Z()); } - P.Coord(X,Y,Z) ; - XX = (Matrix(lr,lc+3) + X*Matrix(lr,lc) + Y*Matrix(lr,lc+1)+ - Z*Matrix(lr,lc+2))/Matrix(lr+3,lc+3) ; - YY = (Matrix(lr+1,lc+3) + X*Matrix(lr+1,lc) + Y*Matrix(lr+1,lc+1) + - Z*Matrix(lr+1,lc+2))/Matrix(lr+3,lc+3) ; - - ZZ = (Matrix(lr+2,lc+3) + X*Matrix(lr+2,lc) + Y*Matrix(lr+2,lc+1) + - Z*Matrix(lr+2,lc+2))/Matrix(lr+3,lc+3) ; - PP.SetCoord(XX,YY,ZZ) ; - return PP ; + Standard_Real X, Y, Z; + thePnt.Coord (X,Y,Z); + const Standard_Real XX = (theMat(lr,lc+3) + X*theMat(lr,lc) + Y*theMat(lr,lc+1) + Z*theMat(lr,lc+2)) / theMat(lr+3,lc+3); + const Standard_Real YY = (theMat(lr+1,lc+3) + X*theMat(lr+1,lc) + Y*theMat(lr+1,lc+1) + Z*theMat(lr+1,lc+2))/theMat(lr+3,lc+3); + const Standard_Real ZZ = (theMat(lr+2,lc+3) + X*theMat(lr+2,lc) + Y*theMat(lr+2,lc+1) + Z*theMat(lr+2,lc+2))/theMat(lr+3,lc+3); + return gp_XYZ (XX, YY, ZZ); } //======================================================================= diff --git a/src/V3d/V3d_View.hxx b/src/V3d/V3d_View.hxx index 05043afab5..5f8d860862 100644 --- a/src/V3d/V3d_View.hxx +++ b/src/V3d/V3d_View.hxx @@ -985,7 +985,7 @@ private: Standard_EXPORT static Standard_Boolean ScreenAxis (const gp_Dir& Vpn, const gp_Dir& Vup, Graphic3d_Vector& Xaxe, Graphic3d_Vector& Yaxe, Graphic3d_Vector& Zaxe); //! Transforms the Vertex V according to the matrice Matrix . - Standard_EXPORT static Graphic3d_Vertex TrsPoint (const Graphic3d_Vertex& V, const TColStd_Array2OfReal& Matrix); + Standard_EXPORT static gp_XYZ TrsPoint (const Graphic3d_Vertex& V, const TColStd_Array2OfReal& Matrix); //! Returns the objects number and the projection window //! of the objects contained in the view. diff --git a/src/V3d/V3d_View_4.cxx b/src/V3d/V3d_View_4.cxx index 6f3b5f43f2..b19f26f4dd 100644 --- a/src/V3d/V3d_View_4.cxx +++ b/src/V3d/V3d_View_4.cxx @@ -150,117 +150,74 @@ void toCartesianCoords (const Standard_Real theR, const Standard_Real thePhi, //function : Compute //purpose : //============================================================================= -Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex & AVertex) const +Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex& theVertex) const { - Graphic3d_Vertex CurPoint, NewPoint; - Standard_Real X1, Y1, Z1, X2, Y2, Z2; - Standard_Real XPp, YPp; - Handle(Graphic3d_Camera) aCamera = Camera(); + const Handle(Graphic3d_Camera)& aCamera = Camera(); + gp_Dir VPN = aCamera->Direction().Reversed(); // RefPlane + gp_Dir GPN = MyPlane.Direction(); - gp_Dir aRefPlane = aCamera->Direction().Reversed(); - X1 = aRefPlane.X(); Y1 = aRefPlane.Y(); Z1 = aRefPlane.Z(); - MyPlane.Direction ().Coord (X2, Y2, Z2); - - gp_Dir VPN (X1, Y1, Z1); - gp_Dir GPN (X2, Y2, Z2); - - AVertex.Coord (X1, Y1, Z1); - Project (X1, Y1, Z1, XPp, YPp); + Standard_Real XPp = 0.0, YPp = 0.0; + Project (theVertex.X(), theVertex.Y(), theVertex.Z(), XPp, YPp); // Casw when the plane of the grid and the plane of the view // are perpendicular to MYEPSILON2 close radians - if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2) { - NewPoint.SetCoord (X1, Y1, Z1); - return NewPoint; + if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2) + { + return theVertex; } - Standard_Boolean IsRectangular = - MyGrid->IsKind (STANDARD_TYPE (Aspect_RectangularGrid)); - - Graphic3d_Vertex P1; - - Standard_Real x0, y0, z0, x1, y1, z1, x2, y2, z2; - - P1.SetCoord (0.0, 0.0, 0.0); - CurPoint = V3d_View::TrsPoint (P1, MyTrsf); - CurPoint.Coord (x0, y0, z0); + const gp_XYZ aPnt0 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 0.0, 0.0), MyTrsf); // get grid axes in world space - P1.SetCoord (1.0, 0.0, 0.0); - CurPoint = V3d_View::TrsPoint (P1, MyTrsf); - CurPoint.Coord (x1, y1, z1); - gp_Vec aGridX (gp_Pnt (x0, y0, z0), gp_Pnt (x1, y1, z1)); + const gp_XYZ aPnt1 = V3d_View::TrsPoint (Graphic3d_Vertex (1.0, 0.0, 0.0), MyTrsf); + gp_Vec aGridX (aPnt0, aPnt1); aGridX.Normalize(); - P1.SetCoord (0.0, 1.0, 0.0); - CurPoint = V3d_View::TrsPoint (P1, MyTrsf); - CurPoint.Coord (x2, y2, z2); - gp_Vec aGridY (gp_Pnt (x0, y0, z0), gp_Pnt (x2, y2, z2)); + const gp_XYZ aPnt2 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 1.0, 0.0), MyTrsf); + gp_Vec aGridY (aPnt0, aPnt2); aGridY.Normalize(); - // get grid normal - MyPlane.Direction().Coord (x2, y2, z2); - gp_Vec aPlaneNormal (x2, y2, z2); - - gp_Vec aPointOnPlane = gp_Vec (0.0, 0.0, 0.0); - - AVertex.Coord (x1, y1, z1); - // project ray from camera onto grid plane - gp_Vec aProjection = aCamera->IsOrthographic() - ? gp_Vec (aCamera->Direction()) - : gp_Vec (aCamera->Eye(), gp_Pnt (x1, y1, z1)).Normalized(); - gp_Vec aPointOrigin = gp_Vec (gp_Pnt (x1, y1, z1), gp_Pnt (x0, y0, z0)); - Standard_Real aT = aPointOrigin.Dot (aPlaneNormal) / aProjection.Dot (aPlaneNormal); - aPointOnPlane = gp_Vec (x1, y1, z1) + aProjection * aT; - - if (IsRectangular) { - Standard_Real XS, YS; - Handle(Aspect_RectangularGrid) theGrid = - Handle(Aspect_RectangularGrid)::DownCast (MyGrid); - XS = theGrid->XStep (), YS = theGrid->YStep (); + const gp_Vec aProjection = aCamera->IsOrthographic() + ? gp_Vec (aCamera->Direction()) + : gp_Vec (aCamera->Eye(), gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z())).Normalized(); + const gp_Vec aPointOrigin = gp_Vec (gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z()), aPnt0); + const Standard_Real aT = aPointOrigin.Dot (MyPlane.Direction()) / aProjection.Dot (MyPlane.Direction()); + const gp_XYZ aPointOnPlane = gp_XYZ (theVertex.X(), theVertex.Y(), theVertex.Z()) + aProjection.XYZ() * aT; + if (Handle(Aspect_RectangularGrid) aRectGrid = Handle(Aspect_RectangularGrid)::DownCast (MyGrid)) + { // project point on plane to grid local space - gp_Vec aToPoint (gp_Pnt (x0, y0, z0), - gp_Pnt (aPointOnPlane.X(), aPointOnPlane.Y(), aPointOnPlane.Z())); - Standard_Real anXSteps = Round (aGridX.Dot (aToPoint) / XS); - Standard_Real anYSteps = Round (aGridY.Dot (aToPoint) / YS); + const gp_Vec aToPoint (aPnt0, aPointOnPlane); + const Standard_Real anXSteps = Round (aGridX.Dot (aToPoint) / aRectGrid->XStep()); + const Standard_Real anYSteps = Round (aGridY.Dot (aToPoint) / aRectGrid->YStep()); // clamp point to grid - gp_Vec aResult = aGridX * anXSteps * XS + aGridY * anYSteps * YS + gp_Vec (x0, y0, z0); - NewPoint.SetCoord (aResult.X(), aResult.Y(), aResult.Z()); - + const gp_Vec aResult = aGridX * anXSteps * aRectGrid->XStep() + + aGridY * anYSteps * aRectGrid->YStep() + + gp_Vec (aPnt0); + return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z()); } else // IsCircular { - Standard_Real RS; - Standard_Integer DN; - Standard_Real Alpha; - Handle(Aspect_CircularGrid) theGrid = - Handle(Aspect_CircularGrid)::DownCast (MyGrid); - RS = theGrid->RadiusStep (); - DN = theGrid->DivisionNumber (); - Alpha = M_PI / Standard_Real (DN); + 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 - gp_Vec aToPoint (gp_Pnt (x0, y0, z0), - gp_Pnt (aPointOnPlane.X(), aPointOnPlane.Y(), aPointOnPlane.Z())); - - Standard_Real anR = 0.0, aPhi = 0.0; + const gp_Vec aToPoint (aPnt0, aPointOnPlane); Standard_Real aLocalX = aGridX.Dot (aToPoint); Standard_Real aLocalY = aGridY.Dot (aToPoint); + Standard_Real anR = 0.0, aPhi = 0.0; toPolarCoords (aLocalX, aLocalY, anR, aPhi); // clamp point to grid - Standard_Real anRSteps = Round (anR / RS); - Standard_Real aPhiSteps = Round (aPhi / Alpha); - toCartesianCoords (anRSteps * RS, aPhiSteps * Alpha, aLocalX, aLocalY); + const Standard_Real anRSteps = Round (anR / aCircleGrid->RadiusStep()); + const Standard_Real aPhiSteps = Round (aPhi / anAlpha); + toCartesianCoords (anRSteps * aCircleGrid->RadiusStep(), aPhiSteps * anAlpha, aLocalX, aLocalY); - gp_Vec aResult = aGridX * aLocalX + aGridY * aLocalY + gp_Vec (x0, y0, z0); - NewPoint.SetCoord (aResult.X(), aResult.Y(), aResult.Z()); + const gp_Vec aResult = aGridX * aLocalX + aGridY * aLocalY + gp_Vec (aPnt0); + return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z()); } - - return NewPoint; } //=============================================================================