From c2d46822b5751adb65d6eb4e5c8d24e88b0bb4e5 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 18 Oct 2019 15:36:38 +0300 Subject: [PATCH] possibility to rename cube labels. --- src/AIS/AIS_ViewCube.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ src/AIS/AIS_ViewCube.hxx | 20 ++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/src/AIS/AIS_ViewCube.cxx b/src/AIS/AIS_ViewCube.cxx index 9af71f6f7f..9492755e66 100644 --- a/src/AIS/AIS_ViewCube.cxx +++ b/src/AIS/AIS_ViewCube.cxx @@ -403,6 +403,29 @@ Standard_Boolean AIS_ViewCube::SetPosition (const Graphic3d_Vec2i& thePosition) return SetPosition (thePosition, myView); } + +//======================================================================= +//function : BoxSideLabel +//purpose : +//======================================================================= +TCollection_AsciiString AIS_ViewCube::BoxSideLabel (const BRepPrim_Direction theSide) const +{ + Handle(Side) aSide = findSide (theSide); + return !aSide.IsNull() ? aSide->Text() : ""; +} + +//======================================================================= +//function : SetBoxSideLabel +//purpose : +//======================================================================= +void AIS_ViewCube::SetBoxSideLabel (const BRepPrim_Direction theSide, + const TCollection_AsciiString& theLabel) +{ + Handle(Side) aSide = findSide (theSide); + if (!aSide.IsNull()) + aSide->SetText (theLabel); +} + //======================================================================= //function : Size //purpose : @@ -2104,3 +2127,20 @@ void AIS_ViewCubeFlat::HilightSelected (const Handle(PrsMgr_PresentationManager3 { parent()->HilightSelected (thePM, theSeq); } + +//======================================================================= +//function : findSide +//purpose : +//======================================================================= +Handle(AIS_ViewCube::Side) AIS_ViewCube::findSide (const BRepPrim_Direction theSide) const +{ + for (MapOfOwnerPart::Iterator aPartsIt (myParts); aPartsIt.More(); aPartsIt.Next()) + { + Handle(Side) aSide = Handle(Side)::DownCast (aPartsIt.Value()); + if (aSide.IsNull()) + continue; + if (aSide->Direction() == theSide) + return aSide; + } + return Handle(Side)(); +} diff --git a/src/AIS/AIS_ViewCube.hxx b/src/AIS/AIS_ViewCube.hxx index b8be300d83..6b0aa19bd0 100644 --- a/src/AIS/AIS_ViewCube.hxx +++ b/src/AIS/AIS_ViewCube.hxx @@ -196,6 +196,14 @@ public: //! @name Geometry management API Standard_EXPORT Standard_Boolean SetPosition (const Graphic3d_Vec2i& thePosition, const Handle(V3d_View)& theView); + //! Return box side label or empty string if undefined. + //! Default labels: FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM. + Standard_EXPORT TCollection_AsciiString BoxSideLabel (const BRepPrim_Direction theSide) const; + + //! Set box side label. + Standard_EXPORT void SetBoxSideLabel (const BRepPrim_Direction theSide, + const TCollection_AsciiString& theLabel); + //! @return size (width and height) of View cube sides. Standard_EXPORT Standard_Real Size() const; @@ -675,6 +683,15 @@ protected: //! @name Auxilliary classes to fill presentation with proper primiti const Handle(Graphic3d_Group)& theTextGroup, const Handle(Prs3d_TextAspect)& theTextAspect); + //! Returns the cube direction + BRepPrim_Direction Direction() const { return myDirection; } + + //! Returns the cube text drawn in the middle of face. + TCollection_ExtendedString Text() const { return myText; } + + //! Sets the cube text drawn in the middle of face. + void SetText (const TCollection_ExtendedString& theText ) { myText = theText; } + protected: BRepPrim_Direction myDirection; //!< Defines cube face. @@ -949,6 +966,9 @@ protected: //! @name Map definitions typedef NCollection_IndexedDataMap MapOfOwnerPart; + //! Returns side for the direction + Standard_EXPORT Handle(Side) findSide (const BRepPrim_Direction theSide) const; + private: -- 2.39.5