]> OCCT Git - occt-copy.git/commitdiff
possibility to rename cube labels.
authornds <nds@opencascade.com>
Fri, 18 Oct 2019 12:36:38 +0000 (15:36 +0300)
committernds <nds@opencascade.com>
Fri, 18 Oct 2019 12:36:38 +0000 (15:36 +0300)
src/AIS/AIS_ViewCube.cxx
src/AIS/AIS_ViewCube.hxx

index 9af71f6f7fe571e219f5d56b40f6e65596f707f6..9492755e66a33c9b82310ae08d0a8857956115ea 100644 (file)
@@ -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)();
+}
index b8be300d830c463f5b15ec61448044e3d65f1b8d..6b0aa19bd059c2661ffe9ef647fde86712d42aa7 100644 (file)
@@ -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<Handle(SelectMgr_EntityOwner), Handle(Part), TColStd_MapTransientHasher>
   MapOfOwnerPart;
 
+  //! Returns side for the direction
+  Standard_EXPORT Handle(Side) findSide (const BRepPrim_Direction theSide) const;
+
 private: