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

0029419: Make V3d_Viewer::PrivilegedPlane() return const reference rather than a temp object

This commit is contained in:
kgv 2018-01-12 10:36:18 +03:00 committed by apn
parent 1f59dfa9c2
commit 67b3d2a8ad
5 changed files with 89 additions and 155 deletions

View File

@ -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

View File

@ -15,7 +15,10 @@
#include <Aspect_Grid.hxx>
#include <Aspect_IdentDefinitionError.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
@ -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();
}

View File

@ -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 <me>.
Standard_EXPORT Standard_Boolean IsActive() const;
//! Returns the defined grid in <me>.
Standard_EXPORT Handle(Aspect_Grid) Grid() const;
//! Returns the current grid type defined in <me>.
Standard_EXPORT Aspect_GridType GridType() const;
Aspect_GridType GridType() const { return myGridType; }
//! Returns the current grid draw mode defined in <me>.
Standard_EXPORT Aspect_GridDrawMode GridDrawMode() const;

View File

@ -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 <Aspect_Background.hxx>
#include <Aspect_GradientBackground.hxx>
#include <Aspect_Grid.hxx>
#include <gp_Ax3.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
#include <Quantity_Color.hxx>
#include <V3d_BadValue.hxx>
#include <V3d_CircularGrid.hxx>
#include <V3d_Light.hxx>
#include <V3d_RectangularGrid.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
/*----------------------------------------------------------------------*/
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();
}
}
/*----------------------------------------------------------------------*/

View File

@ -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 :