From 67b3d2a8ad814ac30fb814fbf0a7e401988f21e9 Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 12 Jan 2018 10:36:18 +0300 Subject: [PATCH] 0029419: Make V3d_Viewer::PrivilegedPlane() return const reference rather than a temp object --- src/V3d/FILES | 1 - src/V3d/V3d_Viewer.cxx | 84 +++++++++++++++++++++++++ src/V3d/V3d_Viewer.hxx | 11 ++-- src/V3d/V3d_Viewer_3.cxx | 130 --------------------------------------- src/V3d/V3d_Viewer_4.cxx | 18 ------ 5 files changed, 89 insertions(+), 155 deletions(-) delete mode 100644 src/V3d/V3d_Viewer_3.cxx diff --git a/src/V3d/FILES b/src/V3d/FILES index bb363aad20..664068b949 100755 --- a/src/V3d/FILES +++ b/src/V3d/FILES @@ -44,7 +44,6 @@ V3d_View_3.cxx V3d_View_4.cxx V3d_Viewer.cxx V3d_Viewer.hxx -V3d_Viewer_3.cxx V3d_Viewer_4.cxx V3d_ViewerPointer.hxx V3d_ViewPointer.hxx diff --git a/src/V3d/V3d_Viewer.cxx b/src/V3d/V3d_Viewer.cxx index 8c5db1e2ed..a8747f75db 100644 --- a/src/V3d/V3d_Viewer.cxx +++ b/src/V3d/V3d_Viewer.cxx @@ -15,7 +15,10 @@ #include #include +#include +#include #include +#include #include #include #include @@ -464,3 +467,84 @@ void V3d_Viewer::SetDefaultLights() SetLightOn (aDirLight); SetLightOn (anAmbLight); } + +//======================================================================= +//function : SetPrivilegedPlane +//purpose : +//======================================================================= +void V3d_Viewer::SetPrivilegedPlane (const gp_Ax3& thePlane) +{ + myPrivilegedPlane = thePlane; + Grid()->SetDrawMode(Grid()->DrawMode()); + for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next()) + { + anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, Grid()); + } + + if (myDisplayPlane) + { + DisplayPrivilegedPlane (Standard_True, myDisplayPlaneLength); + } +} + +//======================================================================= +//function : DisplayPrivilegedPlane +//purpose : +//======================================================================= +void V3d_Viewer::DisplayPrivilegedPlane (const Standard_Boolean theOnOff, const Standard_Real theSize) +{ + myDisplayPlane = theOnOff; + myDisplayPlaneLength = theSize; + + if (!myDisplayPlane) + { + if (!myPlaneStructure.IsNull()) + { + myPlaneStructure->Erase(); + } + return; + } + + if (myPlaneStructure.IsNull()) + { + myPlaneStructure = new Graphic3d_Structure (StructureManager()); + myPlaneStructure->SetInfiniteState (Standard_True); + myPlaneStructure->Display(); + } + else + { + myPlaneStructure->Clear(); + } + + Handle(Graphic3d_Group) aGroup = myPlaneStructure->NewGroup(); + + Handle(Graphic3d_AspectLine3d) aLineAttrib = new Graphic3d_AspectLine3d (Quantity_NOC_GRAY60, Aspect_TOL_SOLID, 1.0); + aGroup->SetGroupPrimitivesAspect (aLineAttrib); + + Handle(Graphic3d_AspectText3d) aTextAttrib = new Graphic3d_AspectText3d(); + aTextAttrib->SetColor (Quantity_Color (Quantity_NOC_ROYALBLUE1)); + aGroup->SetGroupPrimitivesAspect (aTextAttrib); + + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (6); + + const gp_Pnt& p0 = myPrivilegedPlane.Location(); + + const gp_Pnt pX (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.XDirection().XYZ()); + aPrims->AddVertex (p0); + aPrims->AddVertex (pX); + aGroup->Text ("X", Graphic3d_Vertex (pX.X(), pX.Y(), pX.Z()), 1.0 / 81.0); + + const gp_Pnt pY (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.YDirection().XYZ()); + aPrims->AddVertex (p0); + aPrims->AddVertex (pY); + aGroup->Text ("Y", Graphic3d_Vertex (pY.X(), pY.Y(), pY.Z()), 1.0 / 81.0); + + const gp_Pnt pZ (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.Direction().XYZ()); + aPrims->AddVertex (p0); + aPrims->AddVertex (pZ); + aGroup->Text ("Z", Graphic3d_Vertex (pZ.X(), pZ.Y(), pZ.Z()), 1.0 / 81.0); + + aGroup->AddPrimitiveArray (aPrims); + + myPlaneStructure->Display(); +} diff --git a/src/V3d/V3d_Viewer.hxx b/src/V3d/V3d_Viewer.hxx index 11a56c2d2d..69184a2b78 100644 --- a/src/V3d/V3d_Viewer.hxx +++ b/src/V3d/V3d_Viewer.hxx @@ -322,7 +322,7 @@ public: public: //! @name privileged plane management - Standard_EXPORT gp_Ax3 PrivilegedPlane() const; + const gp_Ax3& PrivilegedPlane() const { return myPrivilegedPlane; } Standard_EXPORT void SetPrivilegedPlane (const gp_Ax3& thePlane); @@ -348,18 +348,17 @@ public: //! @name grid management //! marker size : 3.0 Standard_EXPORT void SetGridEcho (const Handle(Graphic3d_AspectMarker3d)& aMarker); - //! Returns TRUE when grid echo must be displayed - //! at hit point. - Standard_EXPORT Standard_Boolean GridEcho() const; + //! 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 . Standard_EXPORT Standard_Boolean IsActive() const; //! Returns the defined grid in . Standard_EXPORT Handle(Aspect_Grid) Grid() const; - + //! Returns the current grid type defined in . - Standard_EXPORT Aspect_GridType GridType() const; + Aspect_GridType GridType() const { return myGridType; } //! Returns the current grid draw mode defined in . Standard_EXPORT Aspect_GridDrawMode GridDrawMode() const; diff --git a/src/V3d/V3d_Viewer_3.cxx b/src/V3d/V3d_Viewer_3.cxx deleted file mode 100644 index 7d3805a31d..0000000000 --- a/src/V3d/V3d_Viewer_3.cxx +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -/*********************************************************************** - FONCTION : - ---------- - Classe V3d_Viewer_3.cxx : - HISTORIQUE DES MODIFICATIONS : - -------------------------------- - 00-09-92 : GG ; Creation. - 27-12-98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM) - REMARQUES : - ----------- -************************************************************************/ -// -> Remove the grid plane axis when it is requested. -// -> Redraw the privilegied grid plane after any change -/*----------------------------------------------------------------------*/ -/* - * Includes - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/*----------------------------------------------------------------------*/ - -void V3d_Viewer::SetPrivilegedPlane(const gp_Ax3& aPlane) -{ - myPrivilegedPlane = aPlane; - Grid()->SetDrawMode(Grid()->DrawMode()); - for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next()) - { - anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, Grid()); - } - - if(myDisplayPlane) - DisplayPrivilegedPlane(Standard_True,myDisplayPlaneLength); -} - -/*----------------------------------------------------------------------*/ - -gp_Ax3 V3d_Viewer::PrivilegedPlane() const -{ - return myPrivilegedPlane; -} - -/*----------------------------------------------------------------------*/ -void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Standard_Real aSize) -{ - myDisplayPlane = OnOff; - myDisplayPlaneLength = aSize; - - if(myDisplayPlane) - { - if(myPlaneStructure.IsNull()) { - myPlaneStructure = new Graphic3d_Structure(StructureManager()); - myPlaneStructure->SetInfiniteState(Standard_True); - myPlaneStructure->Display(); - } - else - myPlaneStructure->Clear(); - - Handle(Graphic3d_Group) Group = myPlaneStructure->NewGroup(); - - Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d() ; - LineAttrib->SetColor(Quantity_Color(Quantity_NOC_GRAY60)); - Group->SetPrimitivesAspect(LineAttrib) ; - - Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d(); - TextAttrib->SetColor(Quantity_Color(Quantity_NOC_ROYALBLUE1)); - Group->SetPrimitivesAspect(TextAttrib); - - Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); - - const gp_Pnt &p0 = myPrivilegedPlane.Location(); - - const gp_Pnt pX(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.XDirection().XYZ()); - aPrims->AddVertex(p0); - aPrims->AddVertex(pX); - Group->Text("X",Graphic3d_Vertex(pX.X(),pX.Y(),pX.Z()),1./81.); - - const gp_Pnt pY(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.YDirection().XYZ()); - aPrims->AddVertex(p0); - aPrims->AddVertex(pY); - Group->Text("Y",Graphic3d_Vertex(pY.X(),pY.Y(),pY.Z()),1./81.); - - const gp_Pnt pZ(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.Direction().XYZ()); - aPrims->AddVertex(p0); - aPrims->AddVertex(pZ); - Group->Text("Z",Graphic3d_Vertex(pZ.X(),pZ.Y(),pZ.Z()),1./81.); - - Group->AddPrimitiveArray(aPrims); - - myPlaneStructure->Display(); - } - else - { - if( !myPlaneStructure.IsNull() ) myPlaneStructure->Erase(); - } -} - -/*----------------------------------------------------------------------*/ diff --git a/src/V3d/V3d_Viewer_4.cxx b/src/V3d/V3d_Viewer_4.cxx index c04bb715e7..ab93f3c23b 100644 --- a/src/V3d/V3d_Viewer_4.cxx +++ b/src/V3d/V3d_Viewer_4.cxx @@ -43,15 +43,6 @@ Handle(Aspect_Grid) V3d_Viewer::Grid() const return Handle(Aspect_Grid) (myRGrid); } -// ======================================================================= -// function : GridType -// purpose : -// ======================================================================= -Aspect_GridType V3d_Viewer::GridType() const -{ - return myGridType; -} - // ======================================================================= // function : GridDrawMode // purpose : @@ -259,15 +250,6 @@ void V3d_Viewer::SetGridEcho (const Handle(Graphic3d_AspectMarker3d)& theMarker) myGridEchoGroup->SetPrimitivesAspect (theMarker); } -// ======================================================================= -// function : GridEcho -// purpose : -// ======================================================================= -Standard_Boolean V3d_Viewer::GridEcho() const -{ - return myGridEcho; -} - // ======================================================================= // function : ShowGridEcho // purpose :