0029049: Visualization - restore removed class DsgPrs_DatumPrs
authorkgv <kgv@opencascade.com>
Fri, 25 Aug 2017 06:14:39 +0000 (09:14 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 29 Aug 2017 08:28:35 +0000 (11:28 +0300)
src/DsgPrs/DsgPrs_DatumPrs.cxx [new file with mode: 0644]
src/DsgPrs/DsgPrs_DatumPrs.hxx [new file with mode: 0644]
src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx
src/DsgPrs/FILES
src/Prs3d/Prs3d_DatumAspect.hxx

diff --git a/src/DsgPrs/DsgPrs_DatumPrs.cxx b/src/DsgPrs/DsgPrs_DatumPrs.cxx
new file mode 100644 (file)
index 0000000..ee90be8
--- /dev/null
@@ -0,0 +1,75 @@
+// Copyright (c) 2013-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.
+
+#include <DsgPrs_DatumPrs.hxx>
+#include <DsgPrs_XYZAxisPresentation.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Ax2.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_DatumAspect.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+
+// =======================================================================
+// function : Add
+// purpose  :
+// =======================================================================
+void DsgPrs_DatumPrs::Add (const Handle(Prs3d_Presentation)& thePresentation,
+                           const gp_Ax2& theDatum,
+                           const Handle(Prs3d_Drawer)& theDrawer)
+{
+  Handle(Prs3d_DatumAspect) aDatumAspect = theDrawer->DatumAspect();
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
+
+  gp_Ax2 anAxis (theDatum);
+  gp_Pnt anOrigin = anAxis.Location();
+  gp_Dir aXDir = anAxis.XDirection();
+  gp_Dir aYDir = anAxis.YDirection();
+  gp_Dir aZDir = anAxis.Direction();
+
+  Standard_Real anAxisLength;
+  const Standard_Boolean toDrawLabels = theDrawer->DatumAspect()->ToDrawLabels();
+
+  Prs3d_DatumAxes anAxes = aDatumAspect->DatumAxes();
+  Handle(Prs3d_ArrowAspect) anArrowAspect = aDatumAspect->ArrowAspect();
+  Handle(Prs3d_TextAspect) aTextAspect = theDrawer->TextAspect();
+
+  if ((anAxes & Prs3d_DA_XAxis) != 0)
+  {
+    anAxisLength = aDatumAspect->Attribute (Prs3d_DA_XAxisLength);
+    const gp_Pnt aPoint1 (anOrigin.XYZ() + aXDir.XYZ()*anAxisLength);
+    DsgPrs_XYZAxisPresentation::Add (thePresentation, aDatumAspect->LineAspect(Prs3d_DP_XAxis), anArrowAspect,
+                                     aTextAspect, aXDir, anAxisLength, toDrawLabels ? "X" : "", anOrigin, aPoint1);
+  }
+
+  if ((anAxes & Prs3d_DA_YAxis) != 0)
+  {
+    anAxisLength = aDatumAspect->Attribute (Prs3d_DA_YAxisLength);
+    const gp_Pnt aPoint2 (anOrigin.XYZ() + aYDir.XYZ()*anAxisLength);
+    DsgPrs_XYZAxisPresentation::Add (thePresentation, aDatumAspect->LineAspect(Prs3d_DP_YAxis), anArrowAspect,
+                                     aTextAspect, aYDir, anAxisLength, toDrawLabels ? "Y" : "", anOrigin, aPoint2);
+  }
+
+  if ((anAxes & Prs3d_DA_ZAxis) != 0)
+  {
+    anAxisLength = aDatumAspect->Attribute (Prs3d_DA_ZAxisLength);
+    const gp_Pnt aPoint3 (anOrigin.XYZ() + aZDir.XYZ()*anAxisLength);
+    DsgPrs_XYZAxisPresentation::Add (thePresentation, aDatumAspect->LineAspect(Prs3d_DP_ZAxis), anArrowAspect,
+                                     aTextAspect, aZDir, anAxisLength, toDrawLabels ? "Z" : "", anOrigin, aPoint3);
+  }
+}
diff --git a/src/DsgPrs/DsgPrs_DatumPrs.hxx b/src/DsgPrs/DsgPrs_DatumPrs.hxx
new file mode 100644 (file)
index 0000000..41bbe54
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright (c) 2013-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 _DsgPrs_DatumPrs_H__
+#define _DsgPrs_DatumPrs_H__
+
+#include <gp_Ax2.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Root.hxx>
+
+//! A framework for displaying an XYZ trihedron.
+class DsgPrs_DatumPrs : public Prs3d_Root
+{
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  //! Draw XYZ axes at specified location with attributes defined by the attribute manager theDrawer:
+  //! - Prs3d_DatumAspect defines arrow, line and lenght trihedron axis parameters,
+  //! - Prs3d_TextAspect defines displayed text.
+  //! The thihedron origin and axis directions are defined by theDatum coordinate system.
+  //! DsgPrs_XYZAxisPresentation framework is used to create graphical primitives for each axis.
+  //! Axes are marked with "X", "Y", "Z" text.
+  //! @param thePresentation [out] the modified presentation
+  //! @param theDatum [in] the source of trihedron position
+  //! @param theDrawer [in] the provider of display attributes
+  Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const gp_Ax2& theDatum,
+                                   const Handle(Prs3d_Drawer)& theDrawer);
+
+};
+#endif
index e1696578bbf0615385390d32fe6cb6061e724f9c..d11770d5f26390ad03624c48b21c0940ba9df9b2 100644 (file)
@@ -50,8 +50,11 @@ void DsgPrs_XYZAxisPresentation::Add(
  
   Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast,aDir, M_PI/180.*10., aVal/10.);
 
-  Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
-  Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
+  if (*aText != '\0')
+  {
+    Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
+    Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
+  }
 }
 
 
@@ -74,9 +77,13 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
   G->AddPrimitiveArray(aPrims);
 
   G->SetPrimitivesAspect( anArrowAspect->Aspect() );
-  Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast, aDir, M_PI/180.*10., aVal/10.);
+  Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast, aDir, anArrowAspect->Angle(), aVal/10.);
 
   G->SetPrimitivesAspect(aTextAspect->Aspect());
-  Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
-  Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
+
+  if (*aText != '\0')
+  {
+    Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
+    Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
+  }
 }
index 9e25703aa3cba83e86c6adf7914fdef778e3800d..b71d8cee4e3e2d8437dddd8d8c046045f99e84a8 100644 (file)
@@ -7,6 +7,8 @@ DsgPrs_Chamf2dPresentation.cxx
 DsgPrs_Chamf2dPresentation.hxx
 DsgPrs_ConcentricPresentation.cxx
 DsgPrs_ConcentricPresentation.hxx
+DsgPrs_DatumPrs.cxx
+DsgPrs_DatumPrs.hxx
 DsgPrs_DiameterPresentation.cxx
 DsgPrs_DiameterPresentation.hxx
 DsgPrs_EllipseRadiusPresentation.cxx
index 97762554c236d5e5a191b0e37878d4b7df686105..76706c1278e4368ba280e819d2132707c34be44c 100644 (file)
@@ -88,10 +88,10 @@ public:
   Standard_EXPORT Standard_Boolean DrawDatumPart (Prs3d_DatumParts thePart) const;
 
   //! Sets the axes used in the datum aspect
-   void SetDrawDatumAxes (Prs3d_DatumAxes theType) { myAxes = theType; }
+  void SetDrawDatumAxes (Prs3d_DatumAxes theType) { myAxes = theType; }
 
   //! Returns axes used in the datum aspect
-   Prs3d_DatumAxes DatumAxes() const { return myAxes; }
+  Prs3d_DatumAxes DatumAxes() const { return myAxes; }
 
   //! Sets the attribute of the datum type
   void SetAttribute (Prs3d_DatumAttribute theType, const Standard_Real& theValue)