0030857: Visualization - using one implementation of Text in graphic group IR-2019-08-23
authornds <nds@opencascade.com>
Fri, 23 Aug 2019 11:28:04 +0000 (14:28 +0300)
committerapn <apn@opencascade.com>
Fri, 23 Aug 2019 13:58:25 +0000 (16:58 +0300)
Graphic3d_Group::Text(...) are obsolete, AddText() should be used instead of these methods.
Graphic3d_Text is a new class for parameters necessary to fill OpenGl_Text. All parameters of Graphic3d_Group::Text() are moved into this class.

OpenGl_TextParam is removed, these fields were moved into Graphic3d_Text.
OpenGl_Text constructors/Init with OpenGl_TextParam parameter were removed. Constructor with Graphic3d_Text should be used instead of it.
Using OpenGl_Text Init() with OpenGl_TextParam should be now replaced on two cases. The first case is setting values into Graphic3d_Text and the second case is calling Reset() after. As example, look at modification in OpenGl_FrameStatsPrs.

21 files changed:
dox/dev_guides/upgrade/upgrade.md
src/AIS/AIS_ColorScale.cxx
src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx
src/Graphic3d/FILES
src/Graphic3d/Graphic3d_Group.cxx
src/Graphic3d/Graphic3d_Group.hxx
src/Graphic3d/Graphic3d_Text.cxx [new file with mode: 0644]
src/Graphic3d/Graphic3d_Text.hxx [new file with mode: 0644]
src/MeshVS/MeshVS_TextPrsBuilder.cxx
src/OpenGl/FILES
src/OpenGl/OpenGl_FrameStatsPrs.cxx
src/OpenGl/OpenGl_GraduatedTrihedron.cxx
src/OpenGl/OpenGl_GraphicDriver.cxx
src/OpenGl/OpenGl_Group.cxx
src/OpenGl/OpenGl_Group.hxx
src/OpenGl/OpenGl_Text.cxx
src/OpenGl/OpenGl_Text.hxx
src/OpenGl/OpenGl_TextParam.hxx [deleted file]
src/OpenGl/OpenGl_Workspace.hxx
src/Prs3d/Prs3d_Text.cxx
src/V3d/V3d_Viewer.cxx

index febe988..191c665 100644 (file)
@@ -1716,6 +1716,41 @@ aGroup->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< next array
 aGroup->AddPrimitiveArray (aLines);
 ~~~~
 
+@subsection upgrade_740_text Changes in Graphic3d_Text and OpenGl_Text API
+
+Parameters of *Text* in *Graphic3d_Group* are moved into a new *Graphic3d_Text* class. *AddText* of *Graphic3d_Group* should be used instead of the previous *Text*.
+
+The previous code:
+~~~~
+Standard_Real x, y, z;
+theAttachmentPoint.Coord(x,y,z);
+theGroup->Text (theText,
+                Graphic3d_Vertex(x,y,z),
+                theAspect->Height(),
+                theAspect->Angle(),
+                theAspect->Orientation(),
+                theAspect->HorizontalJustification(),
+                theAspect->VerticalJustification());
+~~~~
+should be replaced by the new code:
+~~~~
+Handle(Graphic3d_Text) aText = new Graphic3d_Text (theAspect->Height());
+aText->SetText (theText.ToExtString());
+aText->SetPosition (theAttachmentPoint);
+aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
+aText->SetVerticalAlignment (theAspect->VerticalJustification());
+theGroup->AddText (aText);
+~~~~
+
+*OpenGl_Text* contains *Graphic3d_Text* field.
+
+*OpenGl_TextParam* struct is removed. Constructor and *Init* of *OpenGl_Text* with *OpenGl_TextParam* are also removed.
+Instead of using them, change *OpenGl_Text*.
+
+Please, note, that after modifying *OpenGl_Text*, *Reset* of *OpenGl_Text* should be called.
+
+*FormatParams* of *OpenGl_Text* is replaced by *Text*.
+
 @subsection upgrade_740_prsupdate Presentation invalidation
 
 Historically AIS_InteractiveObject provided two independent mechanisms invalidating presentation (asking presentation manager to recompute specific display mode or all modes):
index ee37f00..ab69613 100644 (file)
@@ -26,6 +26,7 @@
 #include <Graphic3d_AspectText3d.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
 #include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Graphic3d_Text.hxx>
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_Root.hxx>
 #include <Prs3d_ShadingAspect.hxx>
@@ -796,16 +797,14 @@ void AIS_ColorScale::drawText (const Handle(Graphic3d_Group)& theGroup,
                                const Graphic3d_VerticalTextAlignment theVertAlignment)
 {
   const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
-  theGroup->Text (theText,
-                  gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
-                  anAspect->Height(),
-                  anAspect->Angle(),
-                  anAspect->Orientation(),
-                  Graphic3d_HTA_LEFT,
-                  theVertAlignment,
-                  Standard_True,
-                  Standard_False); // has own anchor
 
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)anAspect->Height());
+  aText->SetText (theText.ToExtString());
+  aText->SetOrientation (gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()));
+  aText->SetOwnAnchorPoint (Standard_False);
+  aText->SetVerticalAlignment (theVertAlignment);
+
+  theGroup->AddText (aText);
 }
 
 //=======================================================================
index d11770d..f17f840 100644 (file)
@@ -19,6 +19,7 @@
 #include <gp_Dir.hxx>
 #include <gp_Pnt.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_Text.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Prs3d_Arrow.hxx>
 #include <Prs3d_ArrowAspect.hxx>
@@ -36,7 +37,7 @@ void DsgPrs_XYZAxisPresentation::Add(
                       const Handle(Prs3d_LineAspect)& aLineAspect,          
                       const gp_Dir & aDir, 
                       const Standard_Real aVal,
-                      const Standard_CString aText,
+                      const Standard_CString theText,
                       const gp_Pnt& aPfirst,
                       const gp_Pnt& aPlast)
 {
@@ -50,10 +51,12 @@ void DsgPrs_XYZAxisPresentation::Add(
  
   Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast,aDir, M_PI/180.*10., aVal/10.);
 
-  if (*aText != '\0')
+  if (*theText != '\0')
   {
-    Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
-    Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
+    Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f/81.0f);
+    aText->SetText (theText);
+    aText->SetPosition (aPlast);
+    Prs3d_Root::CurrentGroup(aPresentation)->AddText (aText);
   }
 }
 
@@ -64,7 +67,7 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
                                     const Handle(Prs3d_TextAspect)& aTextAspect,
                                     const gp_Dir & aDir, 
                                     const Standard_Real aVal,
-                                    const Standard_CString aText,
+                                    const Standard_CString theText,
                                     const gp_Pnt& aPfirst,
                                     const gp_Pnt& aPlast)
 {
@@ -81,9 +84,11 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
 
   G->SetPrimitivesAspect(aTextAspect->Aspect());
 
-  if (*aText != '\0')
+  if (*theText != '\0')
   {
-    Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
-    Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
+    Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f/81.0f);
+    aText->SetText (theText);
+    aText->SetPosition (aPlast);
+    Prs3d_Root::CurrentGroup(aPresentation)->AddText(aText);
   }
 }
index c19fc1b..6ac062d 100755 (executable)
@@ -136,6 +136,8 @@ Graphic3d_StructureDefinitionError.hxx
 Graphic3d_StructureManager.cxx
 Graphic3d_StructureManager.hxx
 Graphic3d_TextPath.hxx
+Graphic3d_Text.cxx
+Graphic3d_Text.hxx
 Graphic3d_Texture1D.cxx
 Graphic3d_Texture1D.hxx
 Graphic3d_Texture1Dmanual.cxx
index e85870d..4e7966d 100644 (file)
@@ -29,6 +29,7 @@
 #include <Graphic3d_Structure.hxx>
 #include "Graphic3d_Structure.pxx"
 #include <Graphic3d_StructureManager.hxx>
+#include <Graphic3d_Text.hxx>
 #include <Graphic3d_TextureMap.hxx>
 #include <Graphic3d_TransModeFlags.hxx>
 #include <Message.hxx>
@@ -310,31 +311,21 @@ void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint,
 // function : Text
 // purpose  :
 // =======================================================================
-void Graphic3d_Group::Text (const Standard_CString                  /*theText*/,
+void Graphic3d_Group::Text (const Standard_CString                  theText,
                             const Graphic3d_Vertex&                 thePoint,
-                            const Standard_Real                     /*theHeight*/,
+                            const Standard_Real                     theHeight,
                             const Standard_Real                     /*theAngle*/,
                             const Graphic3d_TextPath                /*theTp*/,
-                            const Graphic3d_HorizontalTextAlignment /*theHta*/,
-                            const Graphic3d_VerticalTextAlignment   /*theVta*/,
+                            const Graphic3d_HorizontalTextAlignment theHta,
+                            const Graphic3d_VerticalTextAlignment   theVta,
                             const Standard_Boolean                  theToEvalMinMax)
 {
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  if (theToEvalMinMax)
-  {
-    Standard_ShortReal x, y, z;
-    thePoint.Coord (x, y, z);
-    myStructure->CStructure()->Is2dText = Standard_True;
-    myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (x),
-                                  static_cast<Standard_ShortReal> (y),
-                                  static_cast<Standard_ShortReal> (z),
-                                  1.0f));
-  }
-  Update();
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
+  aText->SetText (theText);
+  aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
+  aText->SetHorizontalAlignment (theHta);
+  aText->SetVerticalAlignment (theVta);
+  AddText (aText, theToEvalMinMax);
 }
 
 // =======================================================================
@@ -346,8 +337,10 @@ void Graphic3d_Group::Text (const Standard_CString  theText,
                             const Standard_Real     theHeight,
                             const Standard_Boolean  theToEvalMinMax)
 {
-  Text (theText, thePoint, theHeight, 0.0,
-        Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
+  aText->SetText (theText);
+  aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
+  AddText (aText, theToEvalMinMax);
 }
 
 // =======================================================================
@@ -357,15 +350,18 @@ void Graphic3d_Group::Text (const Standard_CString  theText,
 void Graphic3d_Group::Text (const TCollection_ExtendedString&       theText,
                             const Graphic3d_Vertex&                 thePoint,
                             const Standard_Real                     theHeight,
-                            const Standard_Real                     theAngle,
-                            const Graphic3d_TextPath                theTp,
+                            const Standard_Real                     /*theAngle*/,
+                            const Graphic3d_TextPath                /*theTp*/,
                             const Graphic3d_HorizontalTextAlignment theHta,
                             const Graphic3d_VerticalTextAlignment   theVta,
                             const Standard_Boolean                  theToEvalMinMax)
 {
-  const NCollection_String aText (theText.ToExtString());
-  Text (aText.ToCString(), thePoint, theHeight, theAngle,
-        theTp, theHta, theVta, theToEvalMinMax);
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
+  aText->SetText (theText.ToExtString());
+  aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
+  aText->SetHorizontalAlignment (theHta);
+  aText->SetVerticalAlignment (theVta);
+  AddText (aText, theToEvalMinMax);
 }
 
 // =======================================================================
@@ -375,53 +371,43 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString&       theText,
 void Graphic3d_Group::Text (const TCollection_ExtendedString&       theText,
                             const gp_Ax2&                           theOrientation,
                             const Standard_Real                     theHeight,
-                            const Standard_Real                     theAngle,
-                            const Graphic3d_TextPath                theTP,
-                            const Graphic3d_HorizontalTextAlignment theHTA,
-                            const Graphic3d_VerticalTextAlignment   theVTA,
+                            const Standard_Real                     /*theAngle*/,
+                            const Graphic3d_TextPath                /*theTP*/,
+                            const Graphic3d_HorizontalTextAlignment theHta,
+                            const Graphic3d_VerticalTextAlignment   theVta,
                             const Standard_Boolean                  theToEvalMinMax,
                             const Standard_Boolean                  theHasOwnAnchor)
 {
-  const NCollection_String aText (theText.ToExtString());
-  Text (aText.ToCString(),
-        theOrientation,
-        theHeight,
-        theAngle,
-        theTP,
-        theHTA,
-        theVTA,
-        theToEvalMinMax,
-        theHasOwnAnchor);
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
+  aText->SetText (theText.ToExtString());
+  aText->SetOrientation (theOrientation);
+  aText->SetOwnAnchorPoint (theHasOwnAnchor);
+  aText->SetHorizontalAlignment (theHta);
+  aText->SetVerticalAlignment (theVta);
+  AddText (aText, theToEvalMinMax);
 }
 
 // =======================================================================
 // function : Text
 // purpose  :
 // =======================================================================
-void Graphic3d_Group::Text (const Standard_CString                  /*theText*/,
+void Graphic3d_Group::Text (const Standard_CString                  theText,
                             const gp_Ax2&                           theOrientation,
-                            const Standard_Real                     /*theHeight*/,
+                            const Standard_Real                     theHeight,
                             const Standard_Real                     /*theAngle*/,
                             const Graphic3d_TextPath                /*theTp*/,
-                            const Graphic3d_HorizontalTextAlignment /*theHta*/,
-                            const Graphic3d_VerticalTextAlignment   /*theVta*/,
+                            const Graphic3d_HorizontalTextAlignment theHta,
+                            const Graphic3d_VerticalTextAlignment   theVta,
                             const Standard_Boolean                  theToEvalMinMax,
-                            const Standard_Boolean                  /*theHasOwnAnchor*/)
+                            const Standard_Boolean                  theHasOwnAnchor)
 {
-  if (IsDeleted())
-  {
-    return;
-  }
-
-  if (theToEvalMinMax)
-  {
-    myStructure->CStructure()->Is2dText = Standard_False;
-    myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (theOrientation.Location().X()),
-                                  static_cast<Standard_ShortReal> (theOrientation.Location().Y()),
-                                  static_cast<Standard_ShortReal> (theOrientation.Location().Z()),
-                                  1.0f));
-  }
-  Update();
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
+  aText->SetText (theText);
+  aText->SetOrientation (theOrientation);
+  aText->SetOwnAnchorPoint (theHasOwnAnchor);
+  aText->SetHorizontalAlignment (theHta);
+  aText->SetVerticalAlignment (theVta);
+  AddText (aText, theToEvalMinMax);
 }
 
 // =======================================================================
@@ -433,7 +419,31 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
                             const Standard_Real               theHeight,
                             const Standard_Boolean            theToEvalMinMax)
 {
-  const NCollection_String aText (theText.ToExtString());
-  Text (aText.ToCString(), thePoint, theHeight, 0.0,
-        Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
+  aText->SetText (theText.ToExtString());
+  aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
+  AddText (aText, theToEvalMinMax);
+}
+
+// =======================================================================
+// function : AddText
+// purpose  :
+// =======================================================================
+void Graphic3d_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
+                               const Standard_Boolean theToEvalMinMax)
+{
+  if (IsDeleted())
+  {
+    return;
+  }
+
+  if (theToEvalMinMax)
+  {
+    myStructure->CStructure()->Is2dText = !theTextParams->HasPlane();
+
+    gp_Pnt aPosition = theTextParams->Position();
+    myBounds.Add (Graphic3d_Vec4 ((Standard_ShortReal)aPosition.X(), (Standard_ShortReal)aPosition.Y(), (Standard_ShortReal)aPosition.Z(), 1.0f));
+  }
+
+  Update();
 }
index 4da4fc1..1e6fde6 100644 (file)
@@ -37,6 +37,7 @@
 
 class Graphic3d_Structure;
 class Graphic3d_ArrayOfPrimitives;
+class Graphic3d_Text;
 
 //! This class allows the definition of groups
 //! of primitives inside of graphic objects (presentations).
@@ -110,6 +111,66 @@ public:
   //! Replace aspects specified in the replacement map.
   virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
 
+  //! Adds a text for display
+  Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
+                                        const Standard_Boolean theToEvalMinMax = Standard_True);
+
+  //! Adds an array of primitives for display
+  Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
+                                                  const Handle(Graphic3d_IndexBuffer)& theIndices,
+                                                  const Handle(Graphic3d_Buffer)& theAttribs,
+                                                  const Handle(Graphic3d_BoundBuffer)& theBounds,
+                                                  const Standard_Boolean theToEvalMinMax = Standard_True);
+
+  //! Adds an array of primitives for display
+  Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
+
+  //! Creates a primitive array with single marker using AddPrimitiveArray().
+  Standard_EXPORT void Marker (const Graphic3d_Vertex& thePoint, const Standard_Boolean theToEvalMinMax = Standard_True);
+
+public:
+
+  //! sets the stencil test to theIsEnabled state;
+  Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) = 0;
+
+  //! sets the flipping to theIsEnabled state.
+  Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled, const gp_Ax2& theRefPlane) = 0;
+
+  //! Returns true if the group contains Polygons, Triangles or Quadrangles.
+  bool ContainsFacet() const { return myContainsFacet; }
+
+  //! Returns Standard_True if the group <me> is deleted.
+  //! <me> is deleted after the call Remove (me) or the
+  //! associated structure is deleted.
+  Standard_EXPORT Standard_Boolean IsDeleted() const;
+
+  //! Returns Standard_True if the group <me> is empty.
+  Standard_EXPORT Standard_Boolean IsEmpty() const;
+
+  //! Returns the coordinates of the boundary box of the group.
+  Standard_EXPORT void MinMaxValues (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
+                                     Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const;
+
+  //! Sets the coordinates of the boundary box of the group.
+  Standard_EXPORT void SetMinMaxValues (const Standard_Real theXMin, const Standard_Real theYMin, const Standard_Real theZMin,
+                                        const Standard_Real theXMax, const Standard_Real theYMax, const Standard_Real theZMax);
+
+  //! Returns boundary box of the group <me> without transformation applied,
+  const Graphic3d_BndBox4f& BoundingBox() const { return myBounds; }
+
+  //! Returns non-const boundary box of the group <me> without transformation applied,
+  Graphic3d_BndBox4f& ChangeBoundingBox() { return myBounds; }
+
+  //! Returns the structure containing the group <me>.
+  Standard_EXPORT Handle(Graphic3d_Structure) Structure() const;
+
+  //! Changes property shown that primitive arrays within this group form closed volume (do no contain open shells).
+  void SetClosed (const bool theIsClosed) { myIsClosed = theIsClosed; }
+
+  //! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells).
+  bool IsClosed() const { return myIsClosed; }
+
+//! @name obsolete methods
 public:
 
   //! Creates the string <AText> at position <APoint>.
@@ -122,7 +183,15 @@ public:
   //! Coordinates (NPC) Space).
   //! AAngle  : Orientation of the text
   //! (with respect to the horizontal).
-  Standard_EXPORT virtual void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Real AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
+  Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
+  Standard_EXPORT virtual void Text (const Standard_CString AText,
+                                     const Graphic3d_Vertex& APoint,
+                                     const Standard_Real AHeight,
+                                     const Standard_Real AAngle,
+                                     const Graphic3d_TextPath ATp,
+                                     const Graphic3d_HorizontalTextAlignment AHta,
+                                     const Graphic3d_VerticalTextAlignment AVta,
+                                     const Standard_Boolean EvalMinMax = Standard_True);
 
   //! Creates the string <AText> at position <APoint>.
   //! The 3D point of attachment is projected. The text is
@@ -137,7 +206,11 @@ public:
   //! ATp     : TP_RIGHT
   //! AHta    : HTA_LEFT
   //! AVta    : VTA_BOTTOM
-  Standard_EXPORT void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
+  Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
+  Standard_EXPORT void Text (const Standard_CString AText,
+                             const Graphic3d_Vertex& APoint,
+                             const Standard_Real AHeight,
+                             const Standard_Boolean EvalMinMax = Standard_True);
 
   //! Creates the string <AText> at position <APoint>.
   //! The 3D point of attachment is projected. The text is
@@ -149,7 +222,15 @@ public:
   //! Coordinates (NPC) Space).
   //! AAngle  : Orientation of the text
   //! (with respect to the horizontal).
-  Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Real AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
+  Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
+  Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
+                             const Graphic3d_Vertex& APoint,
+                             const Standard_Real AHeight,
+                             const Standard_Real AAngle,
+                             const Graphic3d_TextPath ATp,
+                             const Graphic3d_HorizontalTextAlignment AHta,
+                             const Graphic3d_VerticalTextAlignment AVta,
+                             const Standard_Boolean EvalMinMax = Standard_True);
 
   //! Creates the string <AText> at position <APoint>.
   //! The 3D point of attachment is projected. The text is
@@ -164,9 +245,14 @@ public:
   //! ATp     : TP_RIGHT
   //! AHta    : HTA_LEFT
   //! AVta    : VTA_BOTTOM
-  Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
+  Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
+  Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
+                             const Graphic3d_Vertex& APoint,
+                             const Standard_Real AHeight,
+                             const Standard_Boolean EvalMinMax = Standard_True);
 
   //! Creates the string <theText> at orientation <theOrientation> in 3D space.
+  Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
   Standard_EXPORT virtual void Text (const Standard_CString                  theTextUtf,
                                      const gp_Ax2&                           theOrientation,
                                      const Standard_Real                     theHeight,
@@ -178,6 +264,7 @@ public:
                                      const Standard_Boolean                  theHasOwnAnchor = Standard_True);
 
   //! Creates the string <theText> at orientation <theOrientation> in 3D space.
+  Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
   Standard_EXPORT virtual void Text (const TCollection_ExtendedString&       theText,
                                      const gp_Ax2&                           theOrientation,
                                      const Standard_Real                     theHeight,
@@ -189,57 +276,6 @@ public:
                                      const Standard_Boolean                  theHasOwnAnchor = Standard_True);
 
 
-  //! Adds an array of primitives for display
-  Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType, const Handle(Graphic3d_IndexBuffer)& theIndices, const Handle(Graphic3d_Buffer)& theAttribs, const Handle(Graphic3d_BoundBuffer)& theBounds, const Standard_Boolean theToEvalMinMax = Standard_True);
-
-  //! Adds an array of primitives for display
-  Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
-
-  //! Creates a primitive array with single marker using AddPrimitiveArray().
-  Standard_EXPORT void Marker (const Graphic3d_Vertex& thePoint, const Standard_Boolean theToEvalMinMax = Standard_True);
-
-public:
-
-  //! sets the stencil test to theIsEnabled state;
-  Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) = 0;
-
-  //! sets the flipping to theIsEnabled state.
-  Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled, const gp_Ax2& theRefPlane) = 0;
-
-  //! Returns true if the group contains Polygons, Triangles or Quadrangles.
-  bool ContainsFacet() const { return myContainsFacet; }
-
-  //! Returns Standard_True if the group <me> is deleted.
-  //! <me> is deleted after the call Remove (me) or the
-  //! associated structure is deleted.
-  Standard_EXPORT Standard_Boolean IsDeleted() const;
-
-  //! Returns Standard_True if the group <me> is empty.
-  Standard_EXPORT Standard_Boolean IsEmpty() const;
-
-  //! Returns the coordinates of the boundary box of the group.
-  Standard_EXPORT void MinMaxValues (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
-                                     Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const;
-
-  //! Sets the coordinates of the boundary box of the group.
-  Standard_EXPORT void SetMinMaxValues (const Standard_Real theXMin, const Standard_Real theYMin, const Standard_Real theZMin,
-                                        const Standard_Real theXMax, const Standard_Real theYMax, const Standard_Real theZMax);
-
-  //! Returns boundary box of the group <me> without transformation applied,
-  const Graphic3d_BndBox4f& BoundingBox() const { return myBounds; }
-
-  //! Returns non-const boundary box of the group <me> without transformation applied,
-  Graphic3d_BndBox4f& ChangeBoundingBox() { return myBounds; }
-
-  //! Returns the structure containing the group <me>.
-  Standard_EXPORT Handle(Graphic3d_Structure) Structure() const;
-
-  //! Changes property shown that primitive arrays within this group form closed volume (do no contain open shells).
-  void SetClosed (const bool theIsClosed) { myIsClosed = theIsClosed; }
-
-  //! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells).
-  bool IsClosed() const { return myIsClosed; }
-
 protected:
 
   //! Creates a group in the structure <AStructure>.
diff --git a/src/Graphic3d/Graphic3d_Text.cxx b/src/Graphic3d/Graphic3d_Text.cxx
new file mode 100644 (file)
index 0000000..9e7be63
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (c) 2019 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.
+
+#include <Graphic3d_Text.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
+
+// =======================================================================
+// function : Graphic3d_Text
+// purpose  :
+// =======================================================================
+Graphic3d_Text::Graphic3d_Text (const Standard_ShortReal theHeight)
+: myHeight (theHeight),
+  myHAlign (Graphic3d_HTA_LEFT),
+  myVAlign (Graphic3d_VTA_BOTTOM),
+  myHasPlane (Standard_False),
+  myHasOwnAnchor (Standard_True)
+{
+}
+
+// =======================================================================
+// function : SetOrientation
+// purpose  :
+// =======================================================================
+void Graphic3d_Text::SetOrientation (const gp_Ax2& theOrientation)
+{
+  myOrientation = theOrientation;
+  myHasPlane = Standard_True;
+}
+
+// =======================================================================
+// function : ResetOrientation
+// purpose  :
+// =======================================================================
+void Graphic3d_Text::ResetOrientation()
+{
+  myOrientation = gp_Ax2();
+  myHasPlane = Standard_False;
+}
diff --git a/src/Graphic3d/Graphic3d_Text.hxx b/src/Graphic3d/Graphic3d_Text.hxx
new file mode 100644 (file)
index 0000000..c1fd70b
--- /dev/null
@@ -0,0 +1,115 @@
+// Copyright (c) 2019 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.
+
+#ifndef _Graphic3d_Text_HeaderFile
+#define _Graphic3d_Text_HeaderFile
+
+#include <gp_Ax2.hxx>
+
+#include <Graphic3d_Vertex.hxx>
+#include <Graphic3d_HorizontalTextAlignment.hxx>
+#include <Graphic3d_VerticalTextAlignment.hxx>
+#include <NCollection_String.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
+#include <TCollection_AsciiString.hxx>
+
+//! This class allows the definition of a text object for display.
+//! The text might be defined in one of ways, using:
+//! - text value and position,
+//! - text value, orientation and the state whether the text uses position as point of attach.
+//! - text formatter. Formatter contains text, height and alignment parameter.
+//!
+//! This class also has parameters of the text height and H/V alignments.
+class Graphic3d_Text : public Standard_Transient
+{
+  DEFINE_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
+
+public:
+
+  //! Creates default text parameters.
+  Standard_EXPORT Graphic3d_Text (const Standard_ShortReal theHeight);
+
+  //! Destructor.
+  virtual ~Graphic3d_Text() {}
+
+  //! Returns text value.
+  const NCollection_String& Text() const { return myText; }
+
+  //! Sets text value.
+  void SetText (const NCollection_String& theText) { myText = theText; }
+
+  //! Sets text value.
+  void SetText (const TCollection_AsciiString& theText) { myText = theText.ToCString(); }
+
+  //! Sets text value.
+  void SetText (Standard_CString theText) { myText = theText; }
+
+  //! The 3D point of attachment is projected.
+  //! If the orientation is defined, the text is written in the plane of projection.
+  const gp_Pnt& Position() const { return myOrientation.Location(); }
+
+  //! Sets text point.
+  void SetPosition (const gp_Pnt& thePoint) { myOrientation.SetLocation (thePoint); }
+
+  //! Returns text orientation in 3D space.
+  const gp_Ax2& Orientation() const { return myOrientation; }
+
+  //! Returns true if the text is filled by a point
+  Standard_Boolean HasPlane() const { return myHasPlane; }
+
+  //! Sets text orientation in 3D space.
+  Standard_EXPORT void SetOrientation (const gp_Ax2& theOrientation);
+
+  //! Reset text orientation in 3D space.
+  Standard_EXPORT void ResetOrientation();
+
+  //! Returns true if the text has an anchor point
+  Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchor; }
+
+  //! Returns true if the text has an anchor point
+  void SetOwnAnchorPoint (const Standard_Boolean theHasOwnAnchor) { myHasOwnAnchor = theHasOwnAnchor; }
+
+  //! Sets height of text. (Relative to the Normalized Projection Coordinates (NPC) Space).
+  Standard_ShortReal Height() const { return myHeight; }
+
+  //! Returns height of text
+  void SetHeight (const Standard_ShortReal theHeight) { myHeight = theHeight; }
+
+  //! Returns horizontal alignment of text.
+  Graphic3d_HorizontalTextAlignment HorizontalAlignment() const { return myHAlign; }
+
+  //! Sets horizontal alignment of text.
+  void SetHorizontalAlignment (const Graphic3d_HorizontalTextAlignment theJustification) { myHAlign = theJustification; }
+
+  //! Returns vertical alignment of text.
+  Graphic3d_VerticalTextAlignment VerticalAlignment() const { return myVAlign; }
+
+  //! Sets vertical alignment of text.
+  void SetVerticalAlignment (const Graphic3d_VerticalTextAlignment theJustification) { myVAlign = theJustification; }
+
+protected:
+  NCollection_String myText; //!< text value
+  gp_Ax2 myOrientation; //!< Text orientation in 3D space.
+
+  Standard_ShortReal myHeight; //!< height of text
+  Graphic3d_HorizontalTextAlignment myHAlign; //!< horizontal alignment
+  Graphic3d_VerticalTextAlignment myVAlign; //!< vertical alignment
+
+  Standard_Boolean myHasPlane; //!< Check if text have orientation in 3D space.
+  Standard_Boolean myHasOwnAnchor; //!< flag if text uses position as point of attach
+};
+
+DEFINE_STANDARD_HANDLE(Graphic3d_Text, Standard_Transient)
+
+#endif // _Graphic3d_Text_HeaderFile
index 1aa141c..2e6ffdf 100644 (file)
@@ -18,6 +18,7 @@
 #include <Graphic3d_ArrayOfPoints.hxx>
 #include <Graphic3d_AspectMarker3d.hxx>
 #include <Graphic3d_AspectText3d.hxx>
+#include <Graphic3d_Text.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Graphic3d_Vertex.hxx>
 #include <MeshVS_Buffer.hxx>
@@ -251,8 +252,11 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
         }
 
         aPnts.Append (Graphic3d_Vec3 ((float )X, (float )Y, (float )Z));
-        Graphic3d_Vertex aPoint (X, Y, Z);
-        aTextGroup->Text (aStr.ToCString(), aPoint, aHeight);
+
+        Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)aHeight);
+        aText->SetText (aStr);
+        aText->SetPosition (gp_Pnt (X, Y, Z));
+        aTextGroup->AddText(aText);
       }
     }
   }
index fbfde8d..b0c1962 100755 (executable)
@@ -43,7 +43,6 @@ OpenGl_Material.hxx
 OpenGl_MaterialState.hxx
 OpenGl_Matrix.hxx
 OpenGl_MatrixState.hxx
-OpenGl_TextParam.hxx
 OpenGl_LineAttributes.hxx
 OpenGl_LineAttributes.cxx
 OpenGl_Window.hxx
index 07d9db5..8694979 100644 (file)
@@ -91,41 +91,45 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace)
   myTextAspect.SetAspect (aRendParams.StatsTextAspect);
 
   // adjust text alignment depending on corner
-  OpenGl_TextParam aParams;
-  aParams.Height = aRendParams.StatsTextHeight;
-  aParams.HAlign = Graphic3d_HTA_CENTER;
-  aParams.VAlign = Graphic3d_VTA_CENTER;
+  Graphic3d_Text aParams ((Standard_ShortReal)aRendParams.StatsTextHeight);
+  aParams.SetHorizontalAlignment (Graphic3d_HTA_CENTER);
+  aParams.SetVerticalAlignment (Graphic3d_VTA_CENTER);
   if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_LEFT) != 0)
   {
-    aParams.HAlign = Graphic3d_HTA_LEFT;
+    aParams.SetHorizontalAlignment (Graphic3d_HTA_LEFT);
   }
   else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
   {
-    aParams.HAlign = Graphic3d_HTA_RIGHT;
+    aParams.SetHorizontalAlignment (Graphic3d_HTA_RIGHT);
   }
   if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_TOP) != 0)
   {
-    aParams.VAlign = Graphic3d_VTA_TOP;
+    aParams.SetVerticalAlignment (Graphic3d_VTA_TOP);
   }
   else if (!myCountersTrsfPers.IsNull() && (myCountersTrsfPers->Corner2d() & Aspect_TOTP_BOTTOM) != 0)
   {
-    aParams.VAlign = Graphic3d_VTA_BOTTOM;
+    aParams.SetVerticalAlignment (Graphic3d_VTA_BOTTOM);
   }
-  if (aParams.Height != myCountersText.FormatParams().Height
-   || aParams.HAlign != myCountersText.FormatParams().HAlign
-   || aParams.VAlign != myCountersText.FormatParams().VAlign)
+  if (aParams.Height() != myCountersText.Text()->Height()
+   || aParams.HorizontalAlignment() != myCountersText.Text()->HorizontalAlignment()
+   || aParams.VerticalAlignment() != myCountersText.Text()->VerticalAlignment())
   {
     myCountersText.Release (aCtx.operator->());
   }
 
   if (!aStats->IsFrameUpdated (myStatsPrev)
-   && !myCountersText.Text().IsEmpty())
+   && !myCountersText.Text()->Text().IsEmpty())
   {
     return;
   }
 
-  TCollection_AsciiString aText = aStats->FormatStats (aRendParams.CollectedStats);
-  myCountersText.Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams);
+  Handle(Graphic3d_Text) aText = myCountersText.Text();
+  aText->SetText (aStats->FormatStats (aRendParams.CollectedStats).ToCString());
+  aText->SetHeight (aParams.Height());
+  aText->SetPosition (gp_Pnt());
+  aText->SetHorizontalAlignment (aParams.HorizontalAlignment());
+  aText->SetVerticalAlignment (aParams.VerticalAlignment());
+  myCountersText.Reset (aCtx);
 
   updateChart (theWorkspace);
 }
@@ -323,14 +327,13 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks
   }
 
   {
-    OpenGl_TextParam aParams;
-    aParams.Height = aRendParams.StatsTextHeight;
-    aParams.HAlign = (!myChartTrsfPers.IsNull()
+    Graphic3d_Text aParams ((Standard_ShortReal)aRendParams.StatsTextHeight);
+    aParams.SetHorizontalAlignment ((!myChartTrsfPers.IsNull()
                     && myChartTrsfPers->IsTrihedronOr2d()
                     && (myChartTrsfPers->Corner2d() & Aspect_TOTP_RIGHT) != 0)
                     ? Graphic3d_HTA_RIGHT
-                    : Graphic3d_HTA_LEFT;
-    aParams.VAlign = Graphic3d_VTA_CENTER;
+                    : Graphic3d_HTA_LEFT);
+    aParams.SetVerticalAlignment (Graphic3d_VTA_CENTER);
     TCollection_AsciiString aLabels[3] =
     {
       TCollection_AsciiString() + 0 + " ms",
@@ -338,12 +341,27 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks
       formatTimeMs(aMaxDuration)
     };
 
-    const float aLabX = aParams.HAlign == Graphic3d_HTA_RIGHT
+    const float aLabX = aParams.HorizontalAlignment() == Graphic3d_HTA_RIGHT
                       ? float(anOffset.x())
                       : float(anOffset.x() + aCharSize.x());
-    myChartLabels[0].Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()),                    0.0f), aParams);
-    myChartLabels[1].Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams);
-    myChartLabels[2].Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()),     0.0f), aParams);
+
+    myChartLabels[0].Text()->SetText (aLabels[isTopDown ? 0 : 2].ToCString());
+    myChartLabels[0].Text()->SetPosition (gp_Pnt (aLabX, float(anOffset.y()), 0.0f));
+
+    myChartLabels[1].Text()->SetText (aLabels[isTopDown ? 1 : 1].ToCString());
+    myChartLabels[1].Text()->SetPosition (gp_Pnt (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f));
+
+    myChartLabels[2].Text()->SetText (aLabels[isTopDown ? 2 : 0].ToCString());
+    myChartLabels[2].Text()->SetPosition (gp_Pnt (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f));
+
+    for (int i = 0; i < 3; i++)
+    {
+      myChartLabels[i].Text()->SetHeight (aParams.Height());
+      myChartLabels[i].Text()->SetHorizontalAlignment (aParams.HorizontalAlignment());
+      myChartLabels[i].Text()->SetVerticalAlignment (aParams.VerticalAlignment());
+
+      myChartLabels[i].Reset(aCtx);
+    }
   }
 }
 
index 1bcefce..c2d5b3d 100755 (executable)
@@ -20,6 +20,7 @@
 #include <Graphic3d_ArrayOfPolylines.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
+#include <Graphic3d_Text.hxx>
 #include <Graphic3d_TransformPers.hxx>
 #include <Graphic3d_TransformUtils.hxx>
 #include <gp_Ax3.hxx>
 
 namespace
 {
-  static const OpenGl_TextParam THE_LABEL_PARAMS =
-  {
-    16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
-  };
+  static Standard_ShortReal THE_LABEL_HEIGHT = 16;
+  static Graphic3d_HorizontalTextAlignment THE_LABEL_HALIGH = Graphic3d_HTA_LEFT;
+  static Graphic3d_VerticalTextAlignment THE_LABEL_VALIGH = Graphic3d_VTA_BOTTOM;
 }
 
 // =======================================================================
@@ -522,7 +522,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
 
     myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
     theWorkspace->SetAspects (&myAspectLabels);
-    anAxis.Label.SetPosition (aMiddle);
+    anAxis.Label.Text()->SetPosition (gp_Pnt (aMiddle.x(), aMiddle.y(), aMiddle.z()));
     anAxis.Label.Render (theWorkspace);
   }
 
@@ -536,7 +536,12 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
     {
       sprintf (aTextValue, "%g", theGridAxes.Ticks[theIndex].GetData()[theIndex] + anIt * aStep);
       OpenGl_Vec3 aPos (theGridAxes.Ticks[theIndex] + anAxis.Direction* (Standard_ShortReal) (anIt * aStep) + aDir * (Standard_ShortReal) (theDpix * anOffset));
-      myLabelValues.Init (theWorkspace->GetGlContext(), aTextValue, aPos);
+
+      Handle(Graphic3d_Text) aText = myLabelValues.Text();
+      aText->SetText (aTextValue);
+      aText->SetPosition (gp_Pnt(aPos.x(), aPos.y(), aPos.z()));
+
+      myLabelValues.Reset (theWorkspace->GetGlContext());
       myLabelValues.Render (theWorkspace);
     }
   }
@@ -715,11 +720,16 @@ void OpenGl_GraduatedTrihedron::SetMinMax (const OpenGl_Vec3& theMin, const Open
 OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect,
                                        const OpenGl_Vec3&          theDirection)
 : Direction (theDirection),
-  Label     (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS),
   Tickmark  (NULL),
   Line      (NULL),
   Arrow     (NULL)
 {
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text (THE_LABEL_HEIGHT);
+  aText->SetText ((Standard_Utf16Char* )theAspect.Name().ToExtString());
+  aText->SetPosition (gp_Pnt (theDirection.x(), theDirection.y(), theDirection.z()));
+  aText->SetHorizontalAlignment (THE_LABEL_HALIGH);
+  aText->SetVerticalAlignment (THE_LABEL_VALIGH);
+  Label = OpenGl_Text (aText);
   NameColor = theAspect.NameColor();
   LineAspect.Aspect()->SetColor (theAspect.Color());
 }
index 2e7e49b..b5afc25 100644 (file)
@@ -520,12 +520,10 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView,
   }
 
   const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
-  OpenGl_TextParam aTextParam;
-  aTextParam.Height = (int )aHeight;
   OpenGl_Aspects aTextAspect;
   TCollection_ExtendedString anExtText = theText;
   NCollection_String aText (anExtText.ToExtString());
-  OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
+  OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aHeight, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
 }
 
 //=======================================================================
index 61ae607..a6a8afa 100644 (file)
@@ -206,75 +206,27 @@ void OpenGl_Group::AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theTy
 }
 
 // =======================================================================
-// function : Text
+// function : AddText
 // purpose  :
 // =======================================================================
-void OpenGl_Group::Text (const Standard_CString                  theTextUtf,
-                         const Graphic3d_Vertex&                 thePoint,
-                         const Standard_Real                     theHeight,
-                         const Standard_Real                     theAngle,
-                         const Graphic3d_TextPath                theTp,
-                         const Graphic3d_HorizontalTextAlignment theHta,
-                         const Graphic3d_VerticalTextAlignment   theVta,
-                         const Standard_Boolean                  theToEvalMinMax)
+void OpenGl_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
+                            const Standard_Boolean theToEvalMinMax)
 {
   if (IsDeleted())
   {
     return;
   }
 
-  OpenGl_TextParam  aParams;
-  OpenGl_Structure* aStruct = GlStruct();
-  aParams.Height = int ((theHeight < 2.0) ? aStruct->GlDriver()->DefaultTextHeight() : theHeight);
-  aParams.HAlign = theHta;
-  aParams.VAlign = theVta;
-  const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z());
-  OpenGl_Text* aText = new OpenGl_Text (theTextUtf, aPoint, aParams);
-  AddElement (aText);
-  Graphic3d_Group::Text (theTextUtf, thePoint, theHeight, theAngle,
-                         theTp, theHta, theVta, theToEvalMinMax);
-}
-
-// =======================================================================
-// function : Text
-// purpose  :
-// =======================================================================
-void OpenGl_Group::Text (const Standard_CString                  theTextUtf,
-                         const gp_Ax2&                           theOrientation,
-                         const Standard_Real                     theHeight,
-                         const Standard_Real                     theAngle,
-                         const Graphic3d_TextPath                theTp,
-                         const Graphic3d_HorizontalTextAlignment theHTA,
-                         const Graphic3d_VerticalTextAlignment   theVTA,
-                         const Standard_Boolean                  theToEvalMinMax,
-                         const Standard_Boolean                  theHasOwnAnchor)
-{
-  if (IsDeleted())
+  if (theTextParams->Height() < 2.0)
   {
-    return;
+    // TODO - this should be handled in different way (throw exception / take default text height without modifying Graphic3d_Text / log warning, etc.)
+    OpenGl_Structure* aStruct = GlStruct();
+    theTextParams->SetHeight (aStruct->GlDriver()->DefaultTextHeight());
   }
-
-  OpenGl_TextParam  aParams;
-  OpenGl_Structure* aStruct = GlStruct();
-
-  aParams.Height      = int ((theHeight < 2.0) ? aStruct->GlDriver()->DefaultTextHeight() : theHeight);
-  aParams.HAlign      = theHTA;
-  aParams.VAlign      = theVTA;
-
-  OpenGl_Text* aText = new OpenGl_Text (theTextUtf, theOrientation, aParams, theHasOwnAnchor != Standard_False);
+  OpenGl_Text* aText = new OpenGl_Text (theTextParams);
 
   AddElement (aText);
-
-  Graphic3d_Group::Text (theTextUtf,
-                         theOrientation,
-                         theHeight,
-                         theAngle,
-                         theTp,
-                         theHTA,
-                         theVTA,
-                         theToEvalMinMax,
-                         theHasOwnAnchor);
-
+  Graphic3d_Group::AddText (theTextParams, theToEvalMinMax);
 }
 
 // =======================================================================
index 33400dc..9000821 100644 (file)
@@ -71,27 +71,9 @@ public:
                                                   const Handle(Graphic3d_BoundBuffer)& theBounds,
                                                   const Standard_Boolean               theToEvalMinMax) Standard_OVERRIDE;
 
-  //! Add text element
-  Standard_EXPORT virtual void Text (const Standard_CString                  theTextUtf,
-                                     const Graphic3d_Vertex&                 thePoint,
-                                     const Standard_Real                     theHeight,
-                                     const Standard_Real                     theAngle,
-                                     const Graphic3d_TextPath                theTp,
-                                     const Graphic3d_HorizontalTextAlignment theHta,
-                                     const Graphic3d_VerticalTextAlignment   theVta,
-                                     const Standard_Boolean                  theToEvalMinMax) Standard_OVERRIDE;
-
-  //! Add text element in 3D space.
-  Standard_EXPORT virtual void Text (const Standard_CString                  theTextUtf,
-                                     const gp_Ax2&                           theOrientation,
-                                     const Standard_Real                     theHeight,
-                                     const Standard_Real                     theAngle,
-                                     const Graphic3d_TextPath                theTp,
-                                     const Graphic3d_HorizontalTextAlignment theHTA,
-                                     const Graphic3d_VerticalTextAlignment   theVTA,
-                                     const Standard_Boolean                  theToEvalMinMax,
-                                     const Standard_Boolean                  theHasOwnAnchor = Standard_True) Standard_OVERRIDE;
-
+  //! Adds a text for display
+  Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
+                                        const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
   //! Add flipping element
   Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled,
                                                    const gp_Ax2&          theRefPlane) Standard_OVERRIDE;
index a7cf377..e1d5ea8 100644 (file)
@@ -75,56 +75,21 @@ namespace
 // =======================================================================
 OpenGl_Text::OpenGl_Text()
 : myScaleHeight (1.0f),
-  myPoint  (0.0f, 0.0f, 0.0f),
-  myIs2d   (false),
-  myHasPlane (false),
-  myHasAnchorPoint (true)
+  myIs2d        (Standard_False)
 {
-  myParams.Height = 10;
-  myParams.HAlign = Graphic3d_HTA_LEFT;
-  myParams.VAlign = Graphic3d_VTA_BOTTOM;
+  myText = new Graphic3d_Text (10.);
 }
 
-// =======================================================================
-// function : OpenGl_Text
-// purpose  :
-// =======================================================================
-OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
-                          const OpenGl_Vec3&       thePoint,
-                          const OpenGl_TextParam&  theParams)
-: myScaleHeight  (1.0f),
-  myExportHeight (1.0f),
-  myParams (theParams),
-  myString (theText),
-  myPoint  (thePoint),
-  myIs2d   (false),
-  myHasPlane (false),
-  myHasAnchorPoint (true)
-{
-  //
-}
 
 // =======================================================================
 // function : OpenGl_Text
 // purpose  :
 // =======================================================================
-OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
-                          const gp_Ax2&            theOrientation,
-                          const OpenGl_TextParam&  theParams,
-                          const bool               theHasOwnAnchor)
-: myScaleHeight  (1.0),
-  myExportHeight (1.0),
-  myParams       (theParams),
-  myString       (theText),
-  myIs2d         (false),
-  myOrientation  (theOrientation),
-  myHasPlane     (true),
-  myHasAnchorPoint (theHasOwnAnchor)
+OpenGl_Text::OpenGl_Text (const Handle(Graphic3d_Text)& theTextParams)
+: myText        (theTextParams),
+  myScaleHeight (1.0f),
+  myIs2d        (Standard_False)
 {
-  const gp_Pnt& aPoint = theOrientation.Location();
-  myPoint = OpenGl_Vec3 (static_cast<Standard_ShortReal> (aPoint.X()),
-                         static_cast<Standard_ShortReal> (aPoint.Y()),
-                         static_cast<Standard_ShortReal> (aPoint.Z()));
 }
 
 // =======================================================================
@@ -133,7 +98,7 @@ OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
 // =======================================================================
 void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
 {
-  myPoint = thePoint;
+  myText->SetPosition (gp_Pnt (thePoint.x(), thePoint.y(), thePoint.z()));
 }
 
 // =======================================================================
@@ -143,37 +108,20 @@ void OpenGl_Text::SetPosition (const OpenGl_Vec3& thePoint)
 void OpenGl_Text::SetFontSize (const Handle(OpenGl_Context)& theCtx,
                                const Standard_Integer        theFontSize)
 {
-  if (myParams.Height != theFontSize)
+  if (myText->Height() != theFontSize)
   {
     Release (theCtx.operator->());
   }
-  myParams.Height = theFontSize;
-}
-
-// =======================================================================
-// function : Init
-// purpose  :
-// =======================================================================
-void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
-                        const Standard_Utf8Char*      theText,
-                        const OpenGl_Vec3&            thePoint)
-{
-  releaseVbos (theCtx.operator->());
-  myIs2d   = false;
-  myPoint  = thePoint;
-  myString.FromUnicode (theText);
+  myText->SetHeight ((Standard_ShortReal)theFontSize);
 }
 
 // =======================================================================
-// function : Init
+// function : Reset
 // purpose  :
 // =======================================================================
-void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
-                        const Standard_Utf8Char*      theText,
-                        const OpenGl_Vec3&            thePoint,
-                        const OpenGl_TextParam&       theParams)
+void OpenGl_Text::Reset (const Handle(OpenGl_Context)& theCtx)
 {
-  if (myParams.Height != theParams.Height)
+  if (!myFont.IsNull() && myFont->FTFont()->PointSize() != myText->Height())
   {
     Release (theCtx.operator->());
   }
@@ -181,33 +129,23 @@ void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
   {
     releaseVbos (theCtx.operator->());
   }
-  myIs2d   = false;
-  myParams = theParams;
-  myPoint  = thePoint;
-  myString.FromUnicode (theText);
 }
 
 // =======================================================================
 // function : Init
 // purpose  :
 // =======================================================================
-void OpenGl_Text::Init (const Handle(OpenGl_Context)&     theCtx,
-                        const TCollection_ExtendedString& theText,
-                        const OpenGl_Vec2&                thePoint,
-                        const OpenGl_TextParam&           theParams)
+void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
+                        const Standard_Utf8Char*      theText,
+                        const OpenGl_Vec3&            thePoint)
 {
-  if (myParams.Height != theParams.Height)
-  {
-    Release (theCtx.operator->());
-  }
-  else
-  {
-    releaseVbos (theCtx.operator->());
-  }
-  myIs2d       = true;
-  myParams     = theParams;
-  myPoint.SetValues (thePoint, 0.0f);
-  myString.FromUnicode (theText.ToExtString());
+  Reset (theCtx);
+  Set2D (Standard_False);
+
+  NCollection_String aText;
+  aText.FromUnicode (theText);
+  myText->SetText (aText);
+  myText->SetPosition (gp_Pnt (thePoint.x(), thePoint.y(), thePoint.z()));
 }
 
 // =======================================================================
@@ -275,7 +213,7 @@ void OpenGl_Text::Release (OpenGl_Context* theCtx)
 void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
                               const NCollection_String&     theText,
                               const OpenGl_Aspects&         theTextAspect,
-                              const OpenGl_TextParam&       theParams,
+                              const Standard_ShortReal      theHeight,
                               const unsigned int            theResolution,
                               Standard_ShortReal&           theWidth,
                               Standard_ShortReal&           theAscent,
@@ -284,8 +222,8 @@ void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
   theWidth   = 0.0f;
   theAscent  = 0.0f;
   theDescent = 0.0f;
-  const TCollection_AsciiString aFontKey = FontKey (theTextAspect, theParams.Height, theResolution);
-  Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, theParams.Height, theResolution, aFontKey);
+  const TCollection_AsciiString aFontKey = FontKey (theTextAspect, (Standard_Integer)theHeight, theResolution);
+  Handle(OpenGl_Font) aFont = FindFont (theCtx, theTextAspect, (Standard_Integer)theHeight, theResolution, aFontKey);
   if (aFont.IsNull() || !aFont->IsValid())
   {
     return;
@@ -347,7 +285,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
   // Bind custom shader program or generate default version
   aCtx->ShaderManager()->BindFontProgram (aTextAspect->ShaderProgramRes (aCtx));
 
-  if (myHasPlane && myHasAnchorPoint)
+  if (myText->HasPlane() && myText->HasOwnAnchorPoint())
   {
     myOrientationMatrix = theWorkspace->View()->Camera()->OrientationMatrix();
     // reset translation part
@@ -411,7 +349,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
                                const OpenGl_Vec3& theDVec) const
 {
   OpenGl_Mat4d aModViewMat, aProjectMat;
-  if (myHasPlane && myHasAnchorPoint)
+  if (myText->HasPlane() && myText->HasOwnAnchorPoint())
   {
     aProjectMat = myProjMatrix * myOrientationMatrix;
   }
@@ -422,7 +360,8 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
 
   if (myIs2d)
   {
-    Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
+    const gp_Pnt& aPoint = myText->Position();
+    Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, aPoint.X() + theDVec.x(), aPoint.Y() + theDVec.y(), 0.f);
     Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
     Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.f, 0.f, 1.f);
   }
@@ -430,7 +369,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
   {
     OpenGl_Vec3d anObjXYZ;
     OpenGl_Vec3d aWinXYZ = myWinXYZ + OpenGl_Vec3d (theDVec);
-    if (!myHasPlane && !theTextAspect.Aspect()->IsTextZoomable())
+    if (!myText->HasPlane() && !theTextAspect.Aspect()->IsTextZoomable())
     {
       // Align coordinates to the nearest integer to avoid extra interpolation issues.
       // Note that for better readability we could also try aligning freely rotated in 3D text (myHasPlane),
@@ -443,20 +382,22 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
                                                         THE_IDENTITY_MATRIX, aProjectMat, theCtx->Viewport(),
                                                         anObjXYZ.x(), anObjXYZ.y(), anObjXYZ.z());
 
-    if (myHasPlane)
+    if (myText->HasPlane())
     {
-      const gp_Dir& aVectorDir   = myOrientation.XDirection();
-      const gp_Dir& aVectorUp    = myOrientation.Direction();
-      const gp_Dir& aVectorRight = myOrientation.YDirection();
+      const gp_Ax2& anOrientation = myText->Orientation();
+      const gp_Dir& aVectorDir   = anOrientation.XDirection();
+      const gp_Dir& aVectorUp    = anOrientation.Direction();
+      const gp_Dir& aVectorRight = anOrientation.YDirection();
 
       aModViewMat.SetColumn (2, OpenGl_Vec3d (aVectorUp.X(), aVectorUp.Y(), aVectorUp.Z()));
       aModViewMat.SetColumn (1, OpenGl_Vec3d (aVectorRight.X(), aVectorRight.Y(), aVectorRight.Z()));
       aModViewMat.SetColumn (0, OpenGl_Vec3d (aVectorDir.X(), aVectorDir.Y(), aVectorDir.Z()));
 
-      if (!myHasAnchorPoint)
+      if (!myText->HasOwnAnchorPoint())
       {
         OpenGl_Mat4d aPosMat;
-        aPosMat.SetColumn (3, OpenGl_Vec3d (myPoint.x(), myPoint.y(), myPoint.z()));
+        const gp_Pnt& aPoint = myText->Position();
+        aPosMat.SetColumn (3, OpenGl_Vec3d (aPoint.X(), aPoint.Y(), aPoint.Z()));
         aPosMat *= aModViewMat;
         aModViewMat.SetColumn (3, aPosMat.GetColumn (3));
       }
@@ -481,7 +422,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
     }
   }
 
-  if (myHasPlane && !myHasAnchorPoint)
+  if (myText->HasPlane() && !myText->HasOwnAnchorPoint())
   {
     OpenGl_Mat4d aCurrentWorldViewMat;
     aCurrentWorldViewMat.Convert (theCtx->WorldViewState.Current());
@@ -666,14 +607,14 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
                           const OpenGl_Vec4& theColorSubs,
                           unsigned int theResolution) const
 {
-  if (myString.IsEmpty())
+  if (myText->Text().IsEmpty())
   {
     return;
   }
 
   // Note that using difference resolution in different Views in same Viewer
   // will lead to performance regression (for example, text will be recreated every time).
-  const TCollection_AsciiString aFontKey = FontKey (theTextAspect, myParams.Height, theResolution);
+  const TCollection_AsciiString aFontKey = FontKey (theTextAspect, (Standard_Integer)myText->Height(), theResolution);
   if (!myFont.IsNull()
    && !myFont->ResourceKey().IsEqual (aFontKey))
   {
@@ -683,7 +624,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
 
   if (myFont.IsNull())
   {
-    myFont = FindFont (theCtx, theTextAspect, myParams.Height, theResolution, aFontKey);
+    myFont = FindFont (theCtx, theTextAspect, (Standard_Integer)myText->Height(), theResolution, aFontKey);
   }
   if (!myFont->WasInitialized())
   {
@@ -693,10 +634,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   if (myTextures.IsEmpty())
   {
     Font_TextFormatter aFormatter;
-    aFormatter.SetupAlignment (myParams.HAlign, myParams.VAlign);
+
+    aFormatter.SetupAlignment (myText->HorizontalAlignment(), myText->VerticalAlignment());
     aFormatter.Reset();
 
-    aFormatter.Append (myString, *myFont->FTFont().operator->());
+    aFormatter.Append (myText->Text(), *myFont->FTFont());
     aFormatter.Format();
 
     OpenGl_TextBuilder aBuilder;
@@ -720,7 +662,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
     return;
   }
 
-  myExportHeight = 1.0f;
   myScaleHeight  = 1.0f;
 
   theCtx->WorldViewState.Push();
@@ -729,16 +670,13 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   const GLdouble aPointSize = (GLdouble )myFont->FTFont()->PointSize();
   if (!myIs2d)
   {
-    Graphic3d_TransformUtils::Project<Standard_Real> (myPoint.x(), myPoint.y(), myPoint.z(),
+    const gp_Pnt& aPoint = myText->Position();
+    Graphic3d_TransformUtils::Project<Standard_Real> (aPoint.X(), aPoint.Y(), aPoint.Z(),
                                                       myModelMatrix, myProjMatrix, theCtx->Viewport(),
                                                       myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z());
 
     // compute scale factor for constant text height
-    if (theTextAspect.Aspect()->IsTextZoomable())
-    {
-      myExportHeight = aPointSize;
-    }
-    else
+    if (!theTextAspect.Aspect()->IsTextZoomable())
     {
       Graphic3d_Vec3d aPnt1, aPnt2;
       Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z(),
@@ -750,7 +688,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
       myScaleHeight = (aPnt2.y() - aPnt1.y()) / aPointSize;
     }
   }
-  myExportHeight = aPointSize / myExportHeight;
 
 #if !defined(GL_ES_VERSION_2_0)
   if (theCtx->core11 != NULL
index 94bbd06..47b12d1 100755 (executable)
 #include <OpenGl_Element.hxx>
 
 #include <OpenGl_Aspects.hxx>
-#include <OpenGl_TextParam.hxx>
 #include <OpenGl_TextBuilder.hxx>
 
 #include <TCollection_ExtendedString.hxx>
 #include <Graphic3d_Vertex.hxx>
 #include <Graphic3d_HorizontalTextAlignment.hxx>
 #include <Graphic3d_RenderingParams.hxx>
+#include <Graphic3d_Text.hxx>
 #include <Graphic3d_VerticalTextAlignment.hxx>
 
 #include <gp_Ax2.hxx>
@@ -36,33 +36,30 @@ class OpenGl_Text : public OpenGl_Element
 
 public:
 
-  //! Main constructor
-  Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
-                               const OpenGl_Vec3&       thePoint,
-                               const OpenGl_TextParam&  theParams);
-
   //! Creates new text in 3D space.
-  Standard_EXPORT OpenGl_Text (const Standard_Utf8Char* theText,
-                               const gp_Ax2&            theOrientation,
-                               const OpenGl_TextParam&  theParams,
-                               const bool               theHasOwnAnchor = true);
+  Standard_EXPORT OpenGl_Text (const Handle(Graphic3d_Text)& theTextParams);
 
   //! Destructor
   Standard_EXPORT virtual ~OpenGl_Text();
 
-  //! Setup new string and position
-  Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
-                             const Standard_Utf8Char*      theText,
-                             const OpenGl_Vec3&            thePoint);
+  //! Release cached VBO resources and the previous font if height changed.
+  //! Cached structures will be refilled by the next render.
+  //! Call Reset after modifying text parameters.
+  Standard_EXPORT void Reset (const Handle(OpenGl_Context)& theCtx);
 
-  //! Setup new string and parameters
-  Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
-                             const Standard_Utf8Char*      theText,
-                             const OpenGl_Vec3&            thePoint,
-                             const OpenGl_TextParam&       theParams);
+  //! Returns text parameters
+  //! @sa Reset()
+  const Handle(Graphic3d_Text)& Text() const { return myText; }
 
-  //! Setup new position
-  Standard_EXPORT void SetPosition (const OpenGl_Vec3& thePoint);
+  //! Sets text parameters
+  //! @sa Reset()
+  void SetText (const Handle(Graphic3d_Text)& theText) { myText = theText; }
+
+  //! Return true if text is 2D
+  Standard_Boolean Is2D() const { return myIs2d; }
+
+  //! Set true if text is 2D
+  void Set2D (const Standard_Boolean theEnable) { myIs2d = theEnable; }
 
   //! Setup new font size
   Standard_EXPORT void SetFontSize (const Handle(OpenGl_Context)& theContext,
@@ -71,12 +68,6 @@ public:
   Standard_EXPORT virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
   Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
 
-  //! Return defined text.
-  const NCollection_String& Text() const { return myString; }
-
-  //! Return text formatting parameters.
-  const OpenGl_TextParam& FormatParams() const { return myParams; }
-
 public: //! @name methods for compatibility with layers
 
   //! Empty constructor
@@ -98,23 +89,30 @@ public: //! @name methods for compatibility with layers
   Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
                                           const NCollection_String&     theText,
                                           const OpenGl_Aspects&         theTextAspect,
-                                          const OpenGl_TextParam&       theParams,
+                                          const Standard_ShortReal      theHeight,
                                           const unsigned int            theResolution,
                                           Standard_ShortReal&           theWidth,
                                           Standard_ShortReal&           theAscent,
                                           Standard_ShortReal&           theDescent);
 
-  //! Setup new string and parameters
-  Standard_EXPORT void Init (const Handle(OpenGl_Context)&     theCtx,
-                             const TCollection_ExtendedString& theText,
-                             const OpenGl_Vec2&                thePoint,
-                             const OpenGl_TextParam&           theParams);
-
   //! Perform rendering
   Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
                                const OpenGl_Aspects& theTextAspect,
                                unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
 
+//! @name obsolete methods
+public:
+
+  //! Setup new string and position
+  Standard_DEPRECATED("Deprecated method Init() with obsolete arguments, use Init() and Text() instead of it")
+  Standard_EXPORT void Init (const Handle(OpenGl_Context)& theCtx,
+                             const Standard_Utf8Char*      theText,
+                             const OpenGl_Vec3&            thePoint);
+
+  //! Setup new position
+  Standard_DEPRECATED("Deprecated method SetPosition(), use Graphic3d_Text for it")
+  Standard_EXPORT void SetPosition (const OpenGl_Vec3& thePoint);
+
 protected:
 
   friend class OpenGl_Trihedron;
@@ -148,6 +146,7 @@ private:
 
 protected:
 
+  Handle(Graphic3d_Text)                                  myText;     //!< text parameters
   mutable Handle(OpenGl_Font)                             myFont;
   mutable NCollection_Vector<GLuint>                      myTextures;   //!< textures' IDs
   mutable NCollection_Vector<Handle(OpenGl_VertexBuffer)> myVertsVbo;   //!< VBOs of vertices
@@ -162,18 +161,10 @@ protected:
   mutable OpenGl_Mat4d myOrientationMatrix;
   mutable OpenGl_Vec3d myWinXYZ;
   mutable GLdouble myScaleHeight;
-  mutable GLdouble myExportHeight;
 
 protected:
 
-  OpenGl_TextParam   myParams;
-  NCollection_String myString;
-  OpenGl_Vec3        myPoint;
-  bool               myIs2d;
-  gp_Ax2             myOrientation; //!< Text orientation in 3D space.
-  bool               myHasPlane;    //!< Check if text have orientation in 3D space.
-  bool               myHasAnchorPoint; //!< Shows if it has own attach point
-
+  Standard_Boolean myIs2d;
 public:
 
   DEFINE_STANDARD_ALLOC
diff --git a/src/OpenGl/OpenGl_TextParam.hxx b/src/OpenGl/OpenGl_TextParam.hxx
deleted file mode 100644 (file)
index 14dd7de..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Created on: 2011-09-20
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-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.
-
-#ifndef _OpenGl_TextParam_Header
-#define _OpenGl_TextParam_Header
-
-#include <Graphic3d_HorizontalTextAlignment.hxx>
-#include <Graphic3d_VerticalTextAlignment.hxx>
-
-struct OpenGl_TextParam
-{
-  int                               Height;
-  Graphic3d_HorizontalTextAlignment HAlign;
-  Graphic3d_VerticalTextAlignment   VAlign;
-  DEFINE_STANDARD_ALLOC
-};
-
-#endif //_OpenGl_TextParam_Header
index 9b330cf..3a6974e 100644 (file)
@@ -25,7 +25,6 @@
 #include <OpenGl_Matrix.hxx>
 #include <OpenGl_ShaderObject.hxx>
 #include <OpenGl_ShaderProgram.hxx>
-#include <OpenGl_TextParam.hxx>
 #include <OpenGl_TextureBufferArb.hxx>
 #include <OpenGl_RenderFilter.hxx>
 #include <OpenGl_Vec.hxx>
index f6705af..78dfb32 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <gp_Pnt.hxx>
 #include <Graphic3d_Group.hxx>
+#include <Graphic3d_Text.hxx>
 #include <Graphic3d_Vertex.hxx>
 #include <Prs3d_Presentation.hxx>
 #include <Prs3d_TextAspect.hxx>
@@ -33,17 +34,14 @@ void Prs3d_Text::Draw (const Handle(Graphic3d_Group)& theGroup,
                        const TCollection_ExtendedString& theText,
                        const gp_Pnt& theAttachmentPoint)
 {
-  Standard_Real x, y, z;
-  theAttachmentPoint.Coord(x,y,z);
-
   theGroup->SetPrimitivesAspect (theAspect->Aspect());
-  theGroup->Text (theText,
-                  Graphic3d_Vertex(x,y,z),
-                  theAspect->Height(),
-                  theAspect->Angle(),
-                  theAspect->Orientation(),
-                  theAspect->HorizontalJustification(),
-                  theAspect->VerticalJustification());
+
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height());
+  aText->SetText (theText.ToExtString());
+  aText->SetPosition (theAttachmentPoint);
+  aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
+  aText->SetVerticalAlignment (theAspect->VerticalJustification());
+  theGroup->AddText (aText);
 }
 
 // =======================================================================
@@ -57,13 +55,12 @@ void Prs3d_Text::Draw (const Handle(Graphic3d_Group)&    theGroup,
                        const Standard_Boolean            theHasOwnAnchor)
 {
   theGroup->SetPrimitivesAspect (theAspect->Aspect());
-  theGroup->Text (theText,
-                  theOrientation,
-                  theAspect->Height(),
-                  theAspect->Angle(),
-                  theAspect->Orientation(),
-                  theAspect->HorizontalJustification(),
-                  theAspect->VerticalJustification(),
-                  Standard_True,
-                  theHasOwnAnchor);
+
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theAspect->Height());
+  aText->SetText (theText.ToExtString());
+  aText->SetOrientation (theOrientation);
+  aText->SetOwnAnchorPoint (theHasOwnAnchor);
+  aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
+  aText->SetVerticalAlignment (theAspect->VerticalJustification());
+  theGroup->AddText (aText);
 }
index f6c2e90..951df37 100644 (file)
@@ -22,6 +22,7 @@
 #include <Graphic3d_GraphicDriver.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Graphic3d_Structure.hxx>
+#include <Graphic3d_Text.hxx>
 #include <Standard_ErrorHandler.hxx>
 #include <Standard_Type.hxx>
 #include <V3d.hxx>
@@ -547,17 +548,26 @@ void V3d_Viewer::DisplayPrivilegedPlane (const Standard_Boolean theOnOff, const
   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);
+  Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f / 81.0f);
+  aText->SetText ("X");
+  aText->SetPosition (pX);
+  aGroup->AddText (aText);
 
   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);
+  aText = new Graphic3d_Text (1.0f / 81.0f);
+  aText->SetText ("Y");
+  aText->SetPosition (pY);
+  aGroup->AddText (aText);
 
   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);
+  aText = new Graphic3d_Text (1.0f / 81.0f);
+  aText->SetText ("Z");
+  aText->SetPosition (pZ);
+  aGroup->AddText (aText);
 
   aGroup->AddPrimitiveArray (aPrims);