0031729: Visualization, Prs3d_DatumAspect - provide per axis text aspects
authorkgv <kgv@opencascade.com>
Thu, 5 Nov 2020 14:34:08 +0000 (17:34 +0300)
committerbugmaster <bugmaster@opencascade.com>
Sat, 21 Nov 2020 09:19:45 +0000 (12:19 +0300)
Prs3d_DatumAspect::TextAspect() now takes Prs3d_DatumParts argument
and defined separately for Prs3d_DatumParts_XAxis/Prs3d_DatumParts_YAxis/Prs3d_DatumParts_ZAxis.
The method without arguments has been marked as deprecated.

V3d_Trihedron now stores per-label text attributes.
Added method V3d_View::Trihedron() returning V3d_Trihedron object for more straightforward definition.
V3d_Trihedron::SetWireframe() - added missing invalidation.

AIS_Trihedron::setOwnDatumAspect() implementation has been moved to Prs3d_DatumAspect::CopyAspectsFrom()
and now used by Prs3d_Drawer::SetOwnDatumAspects().
OpenGl_Text::render() - added NULL-check.

AIS_Trihedron::computePresentation() now takes into account Prs3d_Datum*Arrow shading/line aspects.

Command vtrihedron has been extended by "-textColor XAxis|YAxis|ZAxis Color" syntax.
Command vviewcube has been extended by "-xAxisTextColor|-yAxisTextColor|-zAxisTextColor" arguments.

13 files changed:
src/AIS/AIS_Trihedron.cxx
src/AIS/AIS_Trihedron.hxx
src/AIS/AIS_ViewCube.cxx
src/OpenGl/OpenGl_Text.cxx
src/Prs3d/Prs3d_DatumAspect.cxx
src/Prs3d/Prs3d_DatumAspect.hxx
src/Prs3d/Prs3d_Drawer.cxx
src/V3d/V3d_Trihedron.cxx
src/V3d/V3d_Trihedron.hxx
src/V3d/V3d_View.hxx
src/ViewerTest/ViewerTest_ObjectCommands.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/bugs/vis/bug27958

index 58432b1c396f174d5b8949a6a6a8a8d4744cc394..b93257d83d309d578de656ab89df6e9f4f0483cc 100644 (file)
@@ -103,29 +103,9 @@ void AIS_Trihedron::setOwnDatumAspect()
 
   Handle(Prs3d_DatumAspect) aNewAspect = new Prs3d_DatumAspect();
   myDrawer->SetDatumAspect (aNewAspect);
-  if (myDrawer->Link().IsNull())
+  if (!myDrawer->Link().IsNull())
   {
-    return;
-  }
-
-  const Handle(Prs3d_DatumAspect)& aLinkAspect = myDrawer->Link()->DatumAspect();
-  aNewAspect->SetDrawArrows (aLinkAspect->ToDrawArrows());
-  aNewAspect->SetDrawLabels (aLinkAspect->ToDrawLabels());
-  *aNewAspect->TextAspect()->Aspect()  = *aLinkAspect->TextAspect()->Aspect();
-  *aNewAspect->PointAspect()->Aspect() = *aLinkAspect->PointAspect()->Aspect();
-  *aNewAspect->ArrowAspect()->Aspect() = *aLinkAspect->ArrowAspect()->Aspect();
-
-  for (int aPartIter = Prs3d_DatumParts_Origin; aPartIter <= Prs3d_DatumParts_XOZAxis; ++aPartIter)
-  {
-    const Prs3d_DatumParts aPart = (Prs3d_DatumParts )aPartIter;
-    if (!aNewAspect->LineAspect (aPart).IsNull())
-    {
-      *aNewAspect->LineAspect (aPart)->Aspect() = *aLinkAspect->LineAspect (aPart)->Aspect();
-    }
-    if (!aNewAspect->ShadingAspect (aPart).IsNull())
-    {
-      *aNewAspect->ShadingAspect (aPart)->Aspect() = *aLinkAspect->ShadingAspect (aPart)->Aspect();
-    }
+    aNewAspect->CopyAspectsFrom (myDrawer->Link()->DatumAspect());
   }
 }
 
@@ -488,14 +468,21 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
       anAxisGroup->AddPrimitiveArray (arrayOfPrimitives (aPart));
 
       // draw arrow
-      Prs3d_DatumParts anArrowPart = anAspect->ArrowPartForAxis (aPart);
+      const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis (aPart);
       if (!anAspect->DrawDatumPart (anArrowPart))
       {
         continue;
       }
 
       Handle(Graphic3d_Group) anArrowGroup = thePrs->NewGroup();
-      anArrowGroup->SetGroupPrimitivesAspect (anAspect->ArrowAspect()->Aspect());
+      if (isShadingMode)
+      {
+        anArrowGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect (anArrowPart)->Aspect());
+      }
+      else
+      {
+        anArrowGroup->SetGroupPrimitivesAspect (anAspect->LineAspect (anArrowPart)->Aspect());
+      }
       anArrowGroup->AddPrimitiveArray (arrayOfPrimitives (anArrowPart));
     }
   }
@@ -525,7 +512,7 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
       }
       Handle(Graphic3d_Group) aLabelGroup = thePrs->NewGroup();
       const gp_Pnt aPoint = anOrigin.XYZ() + aDir.XYZ() * anAxisLength;
-      Prs3d_Text::Draw (aLabelGroup, anAspect->TextAspect(), aLabel, aPoint);
+      Prs3d_Text::Draw (aLabelGroup, anAspect->TextAspect (aPart), aLabel, aPoint);
     }
   }
 
@@ -562,6 +549,17 @@ void AIS_Trihedron::SetDatumPartColor (const Prs3d_DatumParts thePart,
   }
 }
 
+//=======================================================================
+//function : SetTextColor
+//purpose  :
+//=======================================================================
+void AIS_Trihedron::SetTextColor (const Prs3d_DatumParts thePart,
+                                  const Quantity_Color& theColor)
+{
+  setOwnDatumAspect();
+  myDrawer->DatumAspect()->TextAspect (thePart)->SetColor (theColor);
+}
+
 //=======================================================================
 //function : SetTextColor
 //purpose  :
@@ -569,7 +567,9 @@ void AIS_Trihedron::SetDatumPartColor (const Prs3d_DatumParts thePart,
 void AIS_Trihedron::SetTextColor (const Quantity_Color& theColor)
 {
   setOwnDatumAspect();
-  myDrawer->DatumAspect()->TextAspect()->SetColor (theColor);
+  myDrawer->DatumAspect()->TextAspect (Prs3d_DatumParts_XAxis)->SetColor (theColor);
+  myDrawer->DatumAspect()->TextAspect (Prs3d_DatumParts_YAxis)->SetColor (theColor);
+  myDrawer->DatumAspect()->TextAspect (Prs3d_DatumParts_ZAxis)->SetColor (theColor);
 }
 
 //=======================================================================
@@ -642,6 +642,20 @@ void AIS_Trihedron::SetColor (const Quantity_Color& theColor)
   SetDatumPartColor (Prs3d_DatumParts_ZAxis,  theColor);
 }
 
+//=======================================================================
+//function : SetArrowColor
+//purpose  :
+//=======================================================================
+void AIS_Trihedron::SetArrowColor (const Prs3d_DatumParts thePart,
+                                   const Quantity_Color& theColor)
+{
+  setOwnDatumAspect();
+  myHasOwnArrowColor = Standard_True;
+  const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis (thePart);
+  myDrawer->DatumAspect()->ShadingAspect(anArrowPart)->SetColor (theColor);
+  myDrawer->DatumAspect()->LineAspect   (anArrowPart)->SetColor (theColor);
+}
+
 //=======================================================================
 //function : SetArrowColor
 //purpose  :
@@ -652,6 +666,11 @@ void AIS_Trihedron::SetArrowColor (const Quantity_Color& theColor)
 
   myHasOwnArrowColor = Standard_True;
   myDrawer->DatumAspect()->ArrowAspect()->SetColor (theColor);
+  for (Standard_Integer anAxisIter = Prs3d_DatumParts_XArrow; anAxisIter <= Prs3d_DatumParts_ZArrow; ++anAxisIter)
+  {
+    myDrawer->DatumAspect()->ShadingAspect((Prs3d_DatumParts )anAxisIter)->SetColor (theColor);
+    myDrawer->DatumAspect()->LineAspect   ((Prs3d_DatumParts )anAxisIter)->SetColor (theColor);
+  }
 }
 
 //=======================================================================
@@ -660,7 +679,7 @@ void AIS_Trihedron::SetArrowColor (const Quantity_Color& theColor)
 //=======================================================================
 Quantity_Color AIS_Trihedron::TextColor() const
 {
-  return myDrawer->DatumAspect()->TextAspect()->Aspect()->Color();
+  return myDrawer->DatumAspect()->TextAspect (Prs3d_DatumParts_XAxis)->Aspect()->Color();
 }
 
 //=======================================================================
@@ -807,7 +826,7 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
         myPrimitives[aPart] = aPrims;
       }
 
-      Prs3d_DatumParts anArrowPart = theAspect->ArrowPartForAxis(aPart);
+      const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis (aPart);
       if (theAspect->DrawDatumPart(anArrowPart))
       {
         myPrimitives[anArrowPart] = Prs3d_Arrow::DrawSegments (anAxisPoints.Find(aPart), anAxisDirs.Find(aPart),
@@ -841,7 +860,7 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
       for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter)
       {
         const Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
-        const Prs3d_DatumParts anArrowPart = theAspect->ArrowPartForAxis(aPart);
+        const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis (aPart);
         const bool aDrawArrow = theAspect->DrawDatumPart(anArrowPart);
         const Standard_Real anAxisLength = theAspect->AxisLength(aPart);
         const gp_Ax1 anAxis(theOrigin, anAxisDirs.Find(aPart));
index 327136df4a6848a147c7436d1ed6407d244ab06a..0ad7f705ddc2584faf9bb06f9880a87958c06f45 100644 (file)
@@ -96,15 +96,23 @@ public:
   //! Sets color of label of trihedron axes.
   Standard_EXPORT void SetTextColor (const Quantity_Color& theColor);
 
+  //! Sets color of label of trihedron axis.
+  Standard_EXPORT void SetTextColor (const Prs3d_DatumParts thePart,
+                                     const Quantity_Color& theColor);
+
   //! Returns true if trihedron has own arrow color
   Standard_Boolean HasArrowColor() const { return myHasOwnArrowColor; }
 
   //! Returns trihedron arrow color
   Standard_EXPORT Quantity_Color ArrowColor() const;
 
-  //! Sets color of arrow of trihedron axes. Used only in wireframe mode
+  //! Sets color of arrow of trihedron axes.
   Standard_EXPORT void SetArrowColor (const Quantity_Color& theColor);
 
+  //! Sets color of arrow of trihedron axes.
+  Standard_EXPORT void SetArrowColor (const Prs3d_DatumParts thePart,
+                                      const Quantity_Color& theColor);
+
   //! Returns color of datum part: origin or some of trihedron axes.
   Standard_EXPORT Quantity_Color DatumPartColor (Prs3d_DatumParts thePart);
 
index f1b39c0784a4e6aefcf35aee75d101eabcb9a24c..3edb4f14a1a5b681cf30403e159acfcdcbb97c98 100644 (file)
@@ -614,7 +614,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
         gp_Pnt aTextOrigin = anAx1.Location().Translated (gp_Vec (anAx1.Direction().X() * (anAxisSize + anArrowLength),
                                                                   anAx1.Direction().Y() * (anAxisSize + anArrowLength),
                                                                   anAx1.Direction().Z() * (anAxisSize + anArrowLength)));
-        Prs3d_Text::Draw (anAxisLabelGroup, aDatumAspect->TextAspect(), TCollection_ExtendedString (anAxisLabel), aTextOrigin);
+        Prs3d_Text::Draw (anAxisLabelGroup, aDatumAspect->TextAspect (aPart), TCollection_ExtendedString (anAxisLabel), aTextOrigin);
       }
     }
 
index 09c63975d1efaae1f0338895464e6874b1e59d52..bbdb8505ae999e89bf99c8d5946e44d6d38da1a6 100644 (file)
@@ -679,7 +679,8 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   {
     myFont = FindFont (theCtx, theTextAspect, (Standard_Integer)myText->Height(), theResolution, aFontKey);
   }
-  if (!myFont->WasInitialized())
+  if (myFont.IsNull()
+  || !myFont->WasInitialized())
   {
     return;
   }
index e90785864ab114d4731d6e6e80060646c3c354dc..af8b95c96db9473c94f9c1cd14bc1cd726baa922 100644 (file)
@@ -39,21 +39,32 @@ Prs3d_DatumAspect::Prs3d_DatumAspect()
   myAttributes[Prs3d_DatumAttribute_ShadingOriginRadiusPercent] = 0.015;
   myAttributes[Prs3d_DatumAttribute_ShadingNumberOfFacettes]    = 12.0;
 
+  myPointAspect = new Prs3d_PointAspect (Aspect_TOM_EMPTY, aDefaultColor, 1.0);
+  myArrowAspect = new Prs3d_ArrowAspect();
   for (int aPartIter = Prs3d_DatumParts_Origin; aPartIter <= Prs3d_DatumParts_XOZAxis; ++aPartIter)
   {
     const Prs3d_DatumParts aPart = (Prs3d_DatumParts )aPartIter;
+
+    Quantity_Color aColor = aDefaultColor;
+    if (aPart >= Prs3d_DatumParts_XArrow
+     && aPart <= Prs3d_DatumParts_ZArrow)
+    {
+      aColor = myArrowAspect->Aspect()->Color();
+    }
+
     if (aPart != Prs3d_DatumParts_Origin) // origin point is used only in shading mode
     {
-      myLineAspects[aPart] = new Prs3d_LineAspect (aDefaultColor, Aspect_TOL_SOLID, 1.0);
+      myLineAspects[aPart] = new Prs3d_LineAspect (aColor, Aspect_TOL_SOLID, 1.0);
     }
 
     Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
-    aShadingAspect->SetColor (aDefaultColor);
+    aShadingAspect->SetColor (aColor);
     myShadedAspects[aPart] = aShadingAspect;
   }
-  myTextAspect  = new Prs3d_TextAspect();
-  myPointAspect = new Prs3d_PointAspect (Aspect_TOM_EMPTY, aDefaultColor, 1.0);
-  myArrowAspect = new Prs3d_ArrowAspect();
+
+  myTextAspects[Prs3d_DatumParts_XAxis] = new Prs3d_TextAspect();
+  myTextAspects[Prs3d_DatumParts_YAxis] = new Prs3d_TextAspect();
+  myTextAspects[Prs3d_DatumParts_ZAxis] = new Prs3d_TextAspect();
 }
 
 // =======================================================================
@@ -134,18 +145,48 @@ Standard_Real Prs3d_DatumAspect::AxisLength (Prs3d_DatumParts thePart) const
 // function : ArrowPartForAxis
 // purpose  :
 // =======================================================================
-Prs3d_DatumParts Prs3d_DatumAspect::ArrowPartForAxis (Prs3d_DatumParts thePart) const
+Prs3d_DatumParts Prs3d_DatumAspect::ArrowPartForAxis (Prs3d_DatumParts thePart)
 {
   switch (thePart)
   {
+    case Prs3d_DatumParts_XArrow:
     case Prs3d_DatumParts_XAxis: return Prs3d_DatumParts_XArrow;
+    case Prs3d_DatumParts_YArrow:
     case Prs3d_DatumParts_YAxis: return Prs3d_DatumParts_YArrow;
+    case Prs3d_DatumParts_ZArrow:
     case Prs3d_DatumParts_ZAxis: return Prs3d_DatumParts_ZArrow;
     default: break;
   }
   return Prs3d_DatumParts_None;
 }
 
+//=======================================================================
+//function : CopyAspectsFrom
+//purpose  :
+//=======================================================================
+void Prs3d_DatumAspect::CopyAspectsFrom (const Handle(Prs3d_DatumAspect)& theOther)
+{
+  myToDrawArrows = theOther->myToDrawArrows;
+  myToDrawLabels = theOther->myToDrawLabels;
+  *myPointAspect->Aspect() = *theOther->myPointAspect->Aspect();
+  *myArrowAspect->Aspect() = *theOther->myArrowAspect->Aspect();
+  *myTextAspects[Prs3d_DatumParts_XAxis]->Aspect() = *theOther->myTextAspects[Prs3d_DatumParts_XAxis]->Aspect();
+  *myTextAspects[Prs3d_DatumParts_YAxis]->Aspect() = *theOther->myTextAspects[Prs3d_DatumParts_YAxis]->Aspect();
+  *myTextAspects[Prs3d_DatumParts_ZAxis]->Aspect() = *theOther->myTextAspects[Prs3d_DatumParts_ZAxis]->Aspect();
+  for (int aPartIter = Prs3d_DatumParts_Origin; aPartIter <= Prs3d_DatumParts_XOZAxis; ++aPartIter)
+  {
+    const Prs3d_DatumParts aPart = (Prs3d_DatumParts )aPartIter;
+    if (!myLineAspects[aPart].IsNull())
+    {
+      *myLineAspects[aPart]->Aspect() = *theOther->myLineAspects[aPart]->Aspect();
+    }
+    if (!myShadedAspects[aPart].IsNull())
+    {
+      *myShadedAspects[aPart]->Aspect() = *theOther->myShadedAspects[aPart]->Aspect();
+    }
+  }
+}
+
 // =======================================================================
 // function : DumpJson
 // purpose  :
@@ -154,9 +195,23 @@ void Prs3d_DatumAspect::DumpJson (Standard_OStream& theOStream, Standard_Integer
 {
   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
 
-  OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get())
   OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPointAspect.get())
   OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myArrowAspect.get())
+  for (Standard_Integer anIter = 0; anIter < Prs3d_DatumParts_NB; anIter++)
+  {
+    const Handle(Prs3d_ShadingAspect)& aShadingAspect = myShadedAspects[anIter];
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aShadingAspect.get())
+  }
+  for (Standard_Integer anIter = 0; anIter < Prs3d_DatumParts_NB; anIter++)
+  {
+    const Handle(Prs3d_LineAspect)& aLineAspect = myLineAspects[anIter];
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aLineAspect.get())
+  }
+  for (Standard_Integer anIter = Prs3d_DatumParts_XAxis; anIter <= Prs3d_DatumParts_ZAxis; anIter++)
+  {
+    const Handle(Prs3d_TextAspect)& aTextAspect = myTextAspects[anIter];
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aTextAspect.get())
+  }
 
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAxes)
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDrawLabels)
index d4e364a6350f910c248479b3271dbc7b1969f1c8..1faabbe9511183405160fbfd846aab058dd7a50a 100644 (file)
@@ -43,11 +43,16 @@ public:
   //! Returns shading aspect for specified part.
   const Handle(Prs3d_ShadingAspect)& ShadingAspect (Prs3d_DatumParts thePart) const { return myShadedAspects[thePart]; }
 
-  //! Returns the text attributes for rendering labels.
-  const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspect; }
+  //! Returns the text attributes for rendering label of specified part (Prs3d_DatumParts_XAxis/Prs3d_DatumParts_YAxis/Prs3d_DatumParts_ZAxis).
+  const Handle(Prs3d_TextAspect)& TextAspect (Prs3d_DatumParts thePart) const { return myTextAspects[thePart]; }
 
   //! Sets text attributes for rendering labels.
-  void SetTextAspect (const Handle(Prs3d_TextAspect)& theTextAspect) { myTextAspect = theTextAspect; }
+  void SetTextAspect (const Handle(Prs3d_TextAspect)& theTextAspect)
+  {
+    myTextAspects[Prs3d_DatumParts_XAxis] = theTextAspect;
+    myTextAspects[Prs3d_DatumParts_YAxis] = theTextAspect;
+    myTextAspects[Prs3d_DatumParts_ZAxis] = theTextAspect;
+  }
 
   //! Returns the point aspect of origin wireframe presentation
   const Handle(Prs3d_PointAspect)& PointAspect() const { return myPointAspect; }
@@ -55,7 +60,7 @@ public:
   //! Returns the point aspect of origin wireframe presentation
   void SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect) { myPointAspect = theAspect; }
 
-  //! Returns the arrow aspect of presentation
+  //! Returns the arrow aspect of presentation.
   const Handle(Prs3d_ArrowAspect)& ArrowAspect() const { return myArrowAspect; }
 
   //! Sets the arrow aspect of presentation
@@ -100,14 +105,23 @@ public:
   //! Sets option to draw or not arrows for axes
   void SetDrawArrows (Standard_Boolean theToDraw) { myToDrawArrows = theToDraw; }
 
-  //! Returns type of arrow for a type of axis
-  Standard_EXPORT Prs3d_DatumParts ArrowPartForAxis (Prs3d_DatumParts thePart) const;
+  //! Performs deep copy of attributes from another aspect instance.
+  Standard_EXPORT void CopyAspectsFrom (const Handle(Prs3d_DatumAspect)& theOther);
 
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
 public:
 
+  //! Returns type of arrow for a type of axis
+  Standard_EXPORT static Prs3d_DatumParts ArrowPartForAxis (Prs3d_DatumParts thePart);
+
+public:
+
+  //! Returns the text attributes for rendering labels.
+  Standard_DEPRECATED("This method is deprecated - TextAspect() with axis parameter should be called instead")
+  const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspects[Prs3d_DatumParts_XAxis]; }
+
   //! Returns the attributes for display of the first axis.
   Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
   const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects[Prs3d_DatumParts_XAxis]; }
@@ -152,11 +166,11 @@ public:
   Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
   Standard_Real ThirdAxisLength() const { return myAttributes[Prs3d_DatumAttribute_ZAxisLength]; }
 
-private:
+protected:
 
   Handle(Prs3d_ShadingAspect) myShadedAspects[Prs3d_DatumParts_NB];
   Handle(Prs3d_LineAspect)    myLineAspects[Prs3d_DatumParts_NB];
-  Handle(Prs3d_TextAspect)    myTextAspect;
+  Handle(Prs3d_TextAspect)    myTextAspects[Prs3d_DatumParts_NB];
   Handle(Prs3d_PointAspect)   myPointAspect;
   Handle(Prs3d_ArrowAspect)   myArrowAspect;
   Standard_Real               myAttributes[Prs3d_DatumAttribute_NB];
index dbc32b828294163e265a00fa8f048e30b43c0c8f..f652bfefd8d1b833419dbe0b712a3f0166a5acb7 100644 (file)
@@ -1252,6 +1252,11 @@ Standard_Boolean Prs3d_Drawer::SetOwnDatumAspects (const Handle(Prs3d_Drawer)& t
   {
     isUpdateNeeded = true;
     myDatumAspect = new Prs3d_DatumAspect();
+    if (!aLink.IsNull()
+      && aLink->HasOwnDatumAspect())
+    {
+      myDatumAspect->CopyAspectsFrom (aLink->DatumAspect());
+    }
     myHasOwnDatumAspect = true;
   }
   return isUpdateNeeded;
index d5964e93ffc3888ff8715fabf4421c7c1b773ff8..bd6400725df769bf6de5923e66ed9d67e191de68 100644 (file)
@@ -23,7 +23,6 @@
 #include <Graphic3d_TransformPers.hxx>
 #include <Prs3d.hxx>
 #include <Prs3d_Arrow.hxx>
-#include <Prs3d_LineAspect.hxx>
 #include <Prs3d_ShadingAspect.hxx>
 #include <Prs3d_Text.hxx>
 #include <Prs3d_TextAspect.hxx>
@@ -97,34 +96,32 @@ V3d_Trihedron::V3d_Trihedron()
   for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
   {
     myArrowShadingAspects[anIt] = new Prs3d_ShadingAspect();
-    myArrowLineAspects[anIt]    = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
+    myTextAspects[anIt]         = new Prs3d_TextAspect();
 
     // mark texture map ON to actually disable environment map
     myArrowShadingAspects[anIt]->Aspect()->SetTextureMapOn();
     myArrowShadingAspects[anIt]->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
     myArrowShadingAspects[anIt]->SetMaterial (aShadingMaterial);
+
+    myTextAspects[anIt]->SetFont (Font_NOF_ASCII_MONO);
+    myTextAspects[anIt]->SetHeight (16);
+    myTextAspects[anIt]->SetHorizontalJustification (Graphic3d_HTA_LEFT);
+    myTextAspects[anIt]->SetVerticalJustification (Graphic3d_VTA_BOTTOM);
   }
-  myArrowShadingAspects[0]->SetColor (Quantity_NOC_RED);
-  myArrowLineAspects   [0]->SetColor (Quantity_NOC_RED);
-  myArrowShadingAspects[1]->SetColor (Quantity_NOC_GREEN);
-  myArrowLineAspects   [1]->SetColor (Quantity_NOC_GREEN);
-  myArrowShadingAspects[2]->SetColor (Quantity_NOC_BLUE1);
-  myArrowLineAspects   [2]->SetColor (Quantity_NOC_BLUE1);
+  myArrowShadingAspects[V3d_X]->SetColor (Quantity_NOC_RED);
+  myArrowShadingAspects[V3d_Y]->SetColor (Quantity_NOC_GREEN);
+  myArrowShadingAspects[V3d_Z]->SetColor (Quantity_NOC_BLUE);
 
-  mySphereShadingAspect = new Prs3d_ShadingAspect();
-  mySphereLineAspect    = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
+  myLabels[V3d_X] = "X";
+  myLabels[V3d_Y] = "Y";
+  myLabels[V3d_Z] = "Z";
 
+  mySphereShadingAspect = new Prs3d_ShadingAspect();
   // mark texture map ON to actually disable environment map
   mySphereShadingAspect->Aspect()->SetTextureMapOn();
   mySphereShadingAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
   mySphereShadingAspect->SetMaterial (aShadingMaterial);
   mySphereShadingAspect->SetColor (Quantity_NOC_WHITE);
-
-  myTextAspect = new Prs3d_TextAspect();
-  myTextAspect->SetFont ("Courier");
-  myTextAspect->SetHeight (16);
-  myTextAspect->SetHorizontalJustification (Graphic3d_HTA_LEFT);
-  myTextAspect->SetVerticalJustification (Graphic3d_VTA_BOTTOM);
 }
 
 // ============================================================================
@@ -142,7 +139,41 @@ V3d_Trihedron::~V3d_Trihedron()
 // ============================================================================
 void V3d_Trihedron::SetLabelsColor (const Quantity_Color& theColor)
 {
-  myTextAspect->SetColor (theColor);
+  myTextAspects[V3d_X]->SetColor (theColor);
+  myTextAspects[V3d_Y]->SetColor (theColor);
+  myTextAspects[V3d_Z]->SetColor (theColor);
+}
+
+// ============================================================================
+// function : SetLabels
+// purpose  :
+// ============================================================================
+void V3d_Trihedron::SetLabels (const TCollection_AsciiString& theX,
+                               const TCollection_AsciiString& theY,
+                               const TCollection_AsciiString& theZ)
+{
+  if (!myLabels[V3d_X].IsEqual (theX)
+   || !myLabels[V3d_Y].IsEqual (theY)
+   || !myLabels[V3d_Z].IsEqual (theZ))
+  {
+    invalidate();
+    myLabels[V3d_X] = theX;
+    myLabels[V3d_Y] = theY;
+    myLabels[V3d_Z] = theZ;
+  }
+}
+
+// ============================================================================
+// function : SetLabelsColor
+// purpose  :
+// ============================================================================
+void V3d_Trihedron::SetLabelsColor (const Quantity_Color& theXColor,
+                                    const Quantity_Color& theYColor,
+                                    const Quantity_Color& theZColor)
+{
+  myTextAspects[V3d_X]->SetColor (theXColor);
+  myTextAspects[V3d_Y]->SetColor (theYColor);
+  myTextAspects[V3d_Z]->SetColor (theZColor);
 }
 
 // ============================================================================
@@ -157,7 +188,6 @@ void V3d_Trihedron::SetArrowsColor (const Quantity_Color& theXColor,
   for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
   {
     myArrowShadingAspects[anIt]->SetColor (aColors[anIt]);
-    myArrowLineAspects   [anIt]->SetColor (aColors[anIt]);
   }
 }
 
@@ -306,7 +336,7 @@ void V3d_Trihedron::compute()
       anCircleArray->AddVertex (aRayon * Sin (THE_CIRCLE_SERMENTS_NB * THE_CIRCLE_SEGMENT_ANGLE),
                                 aRayon * Cos (THE_CIRCLE_SERMENTS_NB * THE_CIRCLE_SEGMENT_ANGLE), 0.0);
 
-      aSphereGroup->SetGroupPrimitivesAspect (mySphereLineAspect->Aspect());
+      aSphereGroup->SetGroupPrimitivesAspect (mySphereShadingAspect->Aspect());
       aSphereGroup->AddPrimitiveArray (anCircleArray);
     }
     else
@@ -331,7 +361,7 @@ void V3d_Trihedron::compute()
         anArray->AddVertex (0.0f, 0.0f, 0.0f);
         anArray->AddVertex (anAxes[anIter].Direction().XYZ() * aCylinderLength);
 
-        anAxisGroup->SetGroupPrimitivesAspect (myArrowLineAspects[anIter]->Aspect());
+        anAxisGroup->SetGroupPrimitivesAspect (myArrowShadingAspects[anIter]->Aspect());
         anAxisGroup->AddPrimitiveArray (anArray);
       }
 
@@ -349,13 +379,12 @@ void V3d_Trihedron::compute()
   // Display labels.
   {
     Handle(Graphic3d_Group) aLabelGroup = addGroup (myStructure, aGroupIter);
-    const TCollection_ExtendedString aLabels[3] = { "X", "Y", "Z" };
     const gp_Pnt aPoints[3] = { gp_Pnt (aScale + 2.0 * aRayon,                   0.0,               -aRayon),
                                 gp_Pnt (               aRayon, aScale + 3.0 * aRayon,          2.0 * aRayon),
                                 gp_Pnt (        -2.0 * aRayon,          0.5 * aRayon, aScale + 3.0 * aRayon) };
     for (Standard_Integer anAxisIter = 0; anAxisIter < 3; ++anAxisIter)
     {
-      Prs3d_Text::Draw (aLabelGroup, myTextAspect, aLabels[anAxisIter], aPoints[anAxisIter]);
+      Prs3d_Text::Draw (aLabelGroup, myTextAspects[anAxisIter], myLabels[anAxisIter], aPoints[anAxisIter]);
     }
   }
 }
@@ -369,18 +398,16 @@ void V3d_Trihedron::DumpJson (Standard_OStream& theOStream, Standard_Integer the
   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
   
   OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySphereShadingAspect.get())
-  OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySphereLineAspect.get())
-  OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get())
 
   for (Standard_Integer anIter = 0; anIter < 3; anIter++)
   {
-    const Handle(Prs3d_ShadingAspect)& anArrowShadinAspect = myArrowShadingAspects[anIter];
-    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anArrowShadinAspect.get())
+    const Handle(Prs3d_TextAspect)& aTextAspect = myTextAspects[anIter];
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aTextAspect.get())
   }
   for (Standard_Integer anIter = 0; anIter < 3; anIter++)
   {
-    const Handle(Prs3d_LineAspect)& anArrowLineAspect = myArrowLineAspects[anIter];
-    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anArrowLineAspect.get())
+    const Handle(Prs3d_ShadingAspect)& anArrowShadinAspect = myArrowShadingAspects[anIter];
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anArrowShadinAspect.get())
   }
 
   OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myStructure.get())
index 6ac0159d1270b71a30eda36ac62169c41a6e30e6..37028b0aed88bb39621d922b9a15769c3f46fd18 100644 (file)
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_ShadingAspect.hxx>
 #include <Prs3d_TextAspect.hxx>
+#include <V3d_TypeOfAxe.hxx>
 
 class V3d_View;
 
-//! Class for presentation of zbuffer trihedron object.
+//! Class for presentation of trihedron object.
 class V3d_Trihedron : public Standard_Transient
 {
   DEFINE_STANDARD_RTTIEXT(V3d_Trihedron, Standard_Transient)
@@ -38,32 +39,91 @@ public:
   //! Destructor.
   Standard_EXPORT virtual ~V3d_Trihedron();
 
+  //! Return TRUE if wireframe presentation is set; FALSE by default.
+  bool IsWireframe() const { return myIsWireframe; }
+
   //! Switch wireframe / shaded trihedron.
-  void SetWireframe (const Standard_Boolean theAsWireframe) { myIsWireframe = theAsWireframe; }
+  void SetWireframe (const Standard_Boolean theAsWireframe)
+  {
+    if (myIsWireframe != theAsWireframe)
+    {
+      invalidate();
+      myIsWireframe = theAsWireframe;
+    }
+  }
+
+  //! Return trihedron position.
+  const Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPers; }
 
   //! Setup the corner to draw the trihedron.
   Standard_EXPORT void SetPosition (const Aspect_TypeOfTriedronPosition thePosition);
 
+  //! Return scale factor.
+  Standard_Real Scale() const { return myScale; }
+
   //! Setup the scale factor.
   Standard_EXPORT void SetScale (const Standard_Real theScale);
 
+  //! Return size ratio factor.
+  Standard_Real SizeRatio() const { return myRatio; }
+
   //! Setup the size ratio factor.
   Standard_EXPORT void SetSizeRatio (const Standard_Real theRatio);
 
+  //! Return arrow diameter.
+  Standard_Real ArrowDiameter() const { return myDiameter; }
+
   //! Setup the arrow diameter.
   Standard_EXPORT void SetArrowDiameter (const Standard_Real theDiam);
 
+  //! Return number of facets for tessellation.
+  Standard_Integer NbFacets() const { return myNbFacettes; }
+
   //! Setup the number of facets for tessellation.
   Standard_EXPORT void SetNbFacets (const Standard_Integer theNbFacets);
 
+  //! Return text aspect for specified axis.
+  //! @param theAxis [in] axis index
+  //! @return text aspect
+  const Handle(Prs3d_TextAspect)& LabelAspect (V3d_TypeOfAxe theAxis) const { return myTextAspects[theAxis]; }
+
+  //! Setup per-label color.
+  Standard_EXPORT void SetLabelsColor (const Quantity_Color& theXColor,
+                                       const Quantity_Color& theYColor,
+                                       const Quantity_Color& theZColor);
+
   //! Setup color of text labels.
   Standard_EXPORT void SetLabelsColor (const Quantity_Color& theColor);
 
+  //! Return shading aspect for specified axis.
+  //! @param theAxis [in] axis index
+  //! @return shading aspect
+  const Handle(Prs3d_ShadingAspect)& ArrowAspect (V3d_TypeOfAxe theAxis) const { return myArrowShadingAspects[theAxis]; }
+
   //! Setup colors of arrows.
   Standard_EXPORT void SetArrowsColor (const Quantity_Color& theXColor,
                                        const Quantity_Color& theYColor,
                                        const Quantity_Color& theZColor);
 
+  //! Return shading aspect of origin sphere.
+  const Handle(Prs3d_ShadingAspect)& OriginAspect() const { return mySphereShadingAspect; }
+
+  //! Return axis text.
+  //! @param theAxis [in] axis index
+  //! @return text of the label
+  const TCollection_AsciiString& Label (V3d_TypeOfAxe theAxis) const { return myLabels[theAxis]; }
+
+  //! Setup per-axis text.
+  Standard_EXPORT void SetLabels (const TCollection_AsciiString& theX,
+                                  const TCollection_AsciiString& theY,
+                                  const TCollection_AsciiString& theZ);
+
+  //! Display trihedron.
+  void Display (const Handle(V3d_View)& theView)
+  {
+    Display (*theView);
+  }
+
   //! Display trihedron.
   Standard_EXPORT void Display (const V3d_View& theView);
 
@@ -95,12 +155,9 @@ private:
 protected:
 
   Handle(Prs3d_ShadingAspect)        mySphereShadingAspect;
-  Handle(Prs3d_LineAspect)           mySphereLineAspect;
-
-  Handle(Prs3d_TextAspect)           myTextAspect;
-
+  Handle(Prs3d_TextAspect)           myTextAspects[3];
   Handle(Prs3d_ShadingAspect)        myArrowShadingAspects[3];
-  Handle(Prs3d_LineAspect)           myArrowLineAspects[3];
+  TCollection_AsciiString            myLabels[3];
 
   Handle(Graphic3d_Structure)        myStructure;
   Handle(Graphic3d_TransformPers)    myTransformPers;
index 053bb4347d51bd8dde5dd77f04059de74d6184a3..e240166e148636afbabfa29cdb2ce7c2a4999278 100644 (file)
@@ -286,6 +286,9 @@ public:
   //! sets the immediate update mode and returns the previous one.
   Standard_EXPORT Standard_Boolean SetImmediateUpdate (const Standard_Boolean theImmediateUpdate);
 
+  //! Returns trihedron object.
+  const Handle(V3d_Trihedron)& Trihedron() const { return myTrihedron; }
+
   //! Customization of the ZBUFFER Triedron.
   //! XColor,YColor,ZColor - colors of axis
   //! SizeRatio - ratio of decreasing of the trihedron size when its physical
index e71edd7ccffae7fb985fa94e6f03149e529e8273..f8329e005994760119cf94e566a2d287ded9ef63 100644 (file)
@@ -426,24 +426,59 @@ namespace
 
     if (aMapOfArgs.Find ("textcolor", aValues))
     {
+      Prs3d_DatumParts aDatumPart = Prs3d_DatumParts_None;
+      if (!aValues->IsEmpty()
+        && convertToDatumPart (aValues->First(), aDatumPart)
+        && aDatumPart >= Prs3d_DatumParts_XAxis
+        && aDatumPart <= Prs3d_DatumParts_ZAxis)
+      {
+        aValues->Remove (1); // datum part is processed
+      }
+
       Quantity_Color aColor;
       if (!convertToColor (aValues, aColor))
       {
         Message::SendFail ("Syntax error: -textcolor wrong parameters");
         return Standard_False;
       }
-      theTrihedron->SetTextColor (aColor);
+
+      if (aDatumPart != Prs3d_DatumParts_None)
+      {
+        theTrihedron->SetTextColor (aDatumPart, aColor);
+      }
+      else
+      {
+        theTrihedron->SetTextColor (aColor);
+      }
     }
 
     if (aMapOfArgs.Find ("arrowcolor", aValues))
     {
+      Prs3d_DatumParts aDatumPart = Prs3d_DatumParts_None;
+      if (!aValues->IsEmpty()
+        && convertToDatumPart (aValues->First(), aDatumPart)
+        && ((aDatumPart >= Prs3d_DatumParts_XArrow && aDatumPart <= Prs3d_DatumParts_ZArrow)
+         || (aDatumPart >= Prs3d_DatumParts_XAxis  && aDatumPart <= Prs3d_DatumParts_ZAxis)))
+      {
+        aValues->Remove (1); // datum part is processed
+      }
+
       Quantity_Color aColor;
       if (!convertToColor (aValues, aColor))
       {
         Message::SendFail ("Syntax error: -arrowcolor wrong parameters");
         return Standard_False;
       }
-      theTrihedron->SetArrowColor (aColor);
+
+      if (aDatumPart != Prs3d_DatumParts_None)
+      {
+        Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis (aDatumPart);
+        theTrihedron->SetArrowColor (anArrowPart, aColor);
+      }
+      else
+      {
+        theTrihedron->SetArrowColor (aColor);
+      }
     }
 
     if (aMapOfArgs.Find ("attribute", aValues))
@@ -582,6 +617,11 @@ static int VTrihedron2D (Draw_Interpretor& /*theDI*/,
                          Standard_Integer  theArgsNum,
                          const char**      theArgVec)
 {
+  if (ViewerTest::CurrentView().IsNull())
+  {
+    Message::SendFail ("Error: no active viewer");
+    return 1;
+  }
   if (theArgsNum != 2)
   {
     Message::SendFail() << "Syntax error: wrong number of arguments.";
@@ -640,6 +680,11 @@ static int VTrihedron (Draw_Interpretor& ,
                        Standard_Integer theArgsNb,
                        const char** theArgVec)
 {
+  if (ViewerTest::CurrentView().IsNull())
+  {
+    Message::SendFail ("Error: no active viewer");
+    return 1;
+  }
   if (theArgsNb < 2)
   {
     Message::SendFail ("Syntax error: the wrong number of input parameters");
@@ -6868,8 +6913,8 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
                    "\n\t\t:             |ShadingNumberOfFacettes} value]"
                    "\n\t\t: [-color {Origin|XAxis|YAxis|ZAxis|XOYAxis|YOZAxis"
                    "\n\t\t:         |XOZAxis|Whole} {r g b | colorName}]"
-                   "\n\t\t: [-textColor {r g b | colorName}]"
-                   "\n\t\t: [-arrowColor {r g b | colorName}]"
+                   "\n\t\t: [-textColor  [XAxis|YAxis|ZAxis] {r g b | colorName}]"
+                   "\n\t\t: [-arrowColor [XAxis|YAxis|ZAxis] {r g b | colorName}]"
                    "\n\t\t: [-priority {Origin|XAxis|YAxis|ZAxis|XArrow"
                    "\n\t\t:            |YArrow|ZArrow|XOYAxis|YOZAxis"
                    "\n\t\t:            |XOZAxis|Whole} value]"
index 00478aa5f5e960dda5b51fc90c94ff8c8b003448..aa5c53a00b6522f479d8c91eddf4324cfa229f29 100644 (file)
@@ -63,6 +63,7 @@
 #include <OSD_Timer.hxx>
 #include <OpenGl_GraphicDriver.hxx>
 #include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_DatumAspect.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_Text.hxx>
@@ -83,6 +84,7 @@
 #include <V3d_DirectionalLight.hxx>
 #include <V3d_PositionalLight.hxx>
 #include <V3d_SpotLight.hxx>
+#include <V3d_Trihedron.hxx>
 
 #include <tcl.h>
 
@@ -3988,7 +3990,9 @@ static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/,
 
   Aspect_TypeOfTriedronPosition aPosition     = Aspect_TOTP_LEFT_LOWER;
   V3d_TypeOfVisualization       aVisType      = V3d_ZBUFFER;
-  Quantity_Color                aLabelsColor  = Quantity_NOC_WHITE;
+  Quantity_Color                aLabelsColorX = Quantity_NOC_WHITE;
+  Quantity_Color                aLabelsColorY = Quantity_NOC_WHITE;
+  Quantity_Color                aLabelsColorZ = Quantity_NOC_WHITE;
   Quantity_Color                anArrowColorX = Quantity_NOC_RED;
   Quantity_Color                anArrowColorY = Quantity_NOC_GREEN;
   Quantity_Color                anArrowColorZ = Quantity_NOC_BLUE1;
@@ -4132,51 +4136,51 @@ static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/,
       aNbFacets = Draw::Atoi (theArgVec[anArgIter]);
     }
     else if (aFlag == "-colorlabel"
-          || aFlag == "-colorlabels")
+          || aFlag == "-colorlabels"
+          || aFlag == "-colorlabelx"
+          || aFlag == "-colorlabely"
+          || aFlag == "-colorlabelz"
+          || aFlag == "-colorarrowx"
+          || aFlag == "-colorarrowy"
+          || aFlag == "-colorarrowz")
     {
+      Quantity_Color aColor;
       Standard_Integer aNbParsed = Draw::ParseColor (theArgNb  - anArgIter - 1,
                                                      theArgVec + anArgIter + 1,
-                                                     aLabelsColor);
+                                                     aColor);
       if (aNbParsed == 0)
       {
         Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
         return 1;
       }
-      anArgIter += aNbParsed;
-    }
-    else if (aFlag == "-colorarrowx")
-    {
-      Standard_Integer aNbParsed = Draw::ParseColor (theArgNb  - anArgIter - 1,
-                                                     theArgVec + anArgIter + 1,
-                                                     anArrowColorX);
-      if (aNbParsed == 0)
+
+      if (aFlag == "-colorarrowx")
       {
-        Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
-        return 1;
+        anArrowColorX = aColor;
       }
-      anArgIter += aNbParsed;
-    }
-    else if (aFlag == "-colorarrowy")
-    {
-      Standard_Integer aNbParsed = Draw::ParseColor (theArgNb  - anArgIter - 1,
-                                                     theArgVec + anArgIter + 1,
-                                                     anArrowColorY);
-      if (aNbParsed == 0)
+      else if (aFlag == "-colorarrowy")
       {
-        Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
-        return 1;
+        anArrowColorY = aColor;
       }
-      anArgIter += aNbParsed;
-    }
-    else if (aFlag == "-colorarrowz")
-    {
-      Standard_Integer aNbParsed = Draw::ParseColor (theArgNb  - anArgIter - 1,
-                                                     theArgVec + anArgIter + 1,
-                                                     anArrowColorZ);
-      if (aNbParsed == 0)
+      else if (aFlag == "-colorarrowz")
       {
-        Message::SendFail() << "Error: wrong syntax at '" << anArg << "'";
-        return 1;
+        anArrowColorZ = aColor;
+      }
+      else if (aFlag == "-colorlabelx")
+      {
+        aLabelsColorX = aColor;
+      }
+      else if (aFlag == "-colorlabely")
+      {
+        aLabelsColorY = aColor;
+      }
+      else if (aFlag == "-colorlabelz")
+      {
+        aLabelsColorZ = aColor;
+      }
+      else
+      {
+        aLabelsColorZ = aLabelsColorY = aLabelsColorX = aColor;
       }
       anArgIter += aNbParsed;
     }
@@ -4187,9 +4191,17 @@ static int VZBuffTrihedron (Draw_Interpretor& /*theDI*/,
     }
   }
 
-  aView->ZBufferTriedronSetup (anArrowColorX, anArrowColorY, anArrowColorZ,
-                               aSizeRatio, anArrowDiam, aNbFacets);
-  aView->TriedronDisplay (aPosition, aLabelsColor, aScale, aVisType);
+  const Handle(V3d_Trihedron)& aTrihedron = aView->Trihedron();
+  aTrihedron->SetArrowsColor  (anArrowColorX, anArrowColorY, anArrowColorZ);
+  aTrihedron->SetLabelsColor  (aLabelsColorX, aLabelsColorY, aLabelsColorZ);
+  aTrihedron->SetSizeRatio    (aSizeRatio);
+  aTrihedron->SetNbFacets     (aNbFacets);
+  aTrihedron->SetArrowDiameter(anArrowDiam);
+  aTrihedron->SetScale        (aScale);
+  aTrihedron->SetPosition     (aPosition);
+  aTrihedron->SetWireframe    (aVisType == V3d_WIREFRAME);
+  aTrihedron->Display (aView);
+
   aView->ZFitAll();
   return 0;
 }
@@ -13743,7 +13755,10 @@ static int VViewCube (Draw_Interpretor& ,
           || anArg == "-boxcornercolor"
           || anArg == "-cornercolor"
           || anArg == "-innercolor"
-          || anArg == "-textcolor")
+          || anArg == "-textcolor"
+          || anArg == "-xaxistextcolor"
+          || anArg == "-yaxistextcolor"
+          || anArg == "-zaxistextcolor")
     {
       Standard_Integer aNbParsed = Draw::ParseColor (theNbArgs - anArgIter - 1,
                                                      theArgVec + anArgIter + 1,
@@ -13784,6 +13799,18 @@ static int VViewCube (Draw_Interpretor& ,
       {
         aViewCube->SetTextColor (aColorRgb);
       }
+      else if (anArg == "-xaxistextcolor"
+            || anArg == "-yaxistextcolor"
+            || anArg == "-zaxistextcolor")
+      {
+        Prs3d_DatumParts aDatum = anArg.Value (2) == 'x'
+                                ? Prs3d_DatumParts_XAxis
+                                : (anArg.Value (2) == 'y'
+                                 ? Prs3d_DatumParts_YAxis
+                                 : Prs3d_DatumParts_ZAxis);
+        aViewCube->Attributes()->SetOwnDatumAspects();
+        aViewCube->Attributes()->DatumAspect()->TextAspect (aDatum)->SetColor (aColorRgb);
+      }
       else
       {
         aViewCube->SetColor (aColorRgb);
@@ -14320,6 +14347,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "\n\t\t:       [-scale value=0.1] [-size value=0.8] [-arrowDiam value=0.05]"
     "\n\t\t:       [-colorArrowX color=RED] [-colorArrowY color=GREEN] [-colorArrowZ color=BLUE]"
     "\n\t\t:       [-nbfacets value=12] [-colorLabels color=WHITE]"
+    "\n\t\t:       [-colorLabelX color] [-colorLabelY color] [-colorLabelZ color]"
     "\n\t\t: Displays a trihedron",
     __FILE__,VZBuffTrihedron,group);
   theCommands.Add("vrotate",
@@ -14978,7 +15006,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
                    "\n\t\t:   -reset                   reset geomertical and visual attributes'"
                    "\n\t\t:   -size Size               adapted size of View Cube"
                    "\n\t\t:   -boxSize Size            box size"
-                   "\n\t\t:   -axes {0|1 }             show/hide axes (trihedron)"
+                   "\n\t\t:   -axes  {0|1}             show/hide axes (trihedron)"
                    "\n\t\t:   -edges {0|1}             show/hide edges of View Cube"
                    "\n\t\t:   -vertices {0|1}          show/hide vertices of View Cube"
                    "\n\t\t:   -Yup {0|1} -Zup {0|1}    set Y-up or Z-up view orientation"
@@ -14991,6 +15019,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
                    "\n\t\t:   -innerColor Color        inner box color"
                    "\n\t\t:   -transparency Value      transparency of object within [0, 1] range"
                    "\n\t\t:   -boxTransparency Value   transparency of box    within [0, 1] range"
+                   "\n\t\t:   -xAxisTextColor Color    color of X axis label"
+                   "\n\t\t:   -yAxisTextColor Color    color of Y axis label"
+                   "\n\t\t:   -zAxisTextColor Color    color of Z axis label"
                    "\n\t\t:   -font Name               font name"
                    "\n\t\t:   -fontHeight Value        font height"
                    "\n\t\t:   -boxFacetExtension Value box facet extension"
index 952e0f0f59f045d23a28ed83249f2d8842c91225..b704e0080a353a55bc33b93cf43259c07e04c085 100644 (file)
@@ -7,6 +7,8 @@ pload VISUALIZATION
 vclear
 vinit View1
 
+vzbufftrihedron -colorLabelX RED -colorLabelY GREEN -colorLabelZ BLUE
+
 vtrihedron t0
 
 vtrihedron t1
@@ -23,15 +25,12 @@ vtrihedron t1 -xaxis 40 60 120 -zaxis -120 0 40
 
 vtrihedron t1 -attribute TubeRadiusPercent 0.03
 vtrihedron t1 -attribute ConeRadiusPercent|OriginRadiusPercent 0.05
-vtrihedron t1 -color XAxis Quantity_NOC_RED
-vtrihedron t1 -color YAxis Quantity_NOC_GREEN
-vtrihedron t1 -color ZAxis|Origin Quantity_NOC_BLUE
-
-vtrihedron t1 -textColor  1.0 1.0 1.0
-vtrihedron t1 -arrowColor 0.0 0.0 1.0
+vtrihedron t1 -color XAxis|XArrow RED         -textColor XAxis RED
+vtrihedron t1 -color YAxis|YArrow GREEN       -textColor YAxis GREEN
+vtrihedron t1 -color ZAxis|ZArrow|Origin BLUE -textColor ZAxis BLUE
 
 vtrihedron t2 -origin 0 0 -300
-vtrihedron t2 -color Whole Quantity_NOC_PEACHPUFF
+vtrihedron t2 -color Whole PEACHPUFF
 vselmode t2 1 1
 vselmode t2 2 1
 vselmode t2 3 1
@@ -39,7 +38,7 @@ vselmode t2 3 1
 vtrihedron t3 -dispMode shading -origin 200 200 -300 -color Whole 1.0 0.0 0.0
 vtrihedron t3 -drawAxes XY -hideLabels on
 
-vtrihedron t4  -origin -200 -200 300 -hideArrows
+vtrihedron t4 -origin -200 -200 300 -hideArrows
 
 vfit