]> OCCT Git - occt-copy.git/commitdiff
Patch of issue #27958 (Visualization, AIS_Trihedron - add Shading display mode) adapt...
authornds <nds@opencascade.com>
Fri, 10 Mar 2017 07:58:29 +0000 (10:58 +0300)
committernds <nds@opencascade.com>
Fri, 10 Mar 2017 07:58:29 +0000 (10:58 +0300)
PATCH_TO_OCCT_710 define is used for cases of difference for specific code for 7.1.0 version.

15 files changed:
src/AIS/AIS_Trihedron.cxx
src/AIS/AIS_Trihedron.hxx
src/AIS/AIS_TrihedronOwner.cxx [new file with mode: 0644]
src/AIS/AIS_TrihedronOwner.hxx [new file with mode: 0644]
src/AIS/FILES
src/Prs3d/FILES
src/Prs3d/Prs3d_Arrow.cxx
src/Prs3d/Prs3d_Arrow.hxx
src/Prs3d/Prs3d_DatumAspect.cxx
src/Prs3d/Prs3d_DatumAspect.hxx
src/Prs3d/Prs3d_DatumAttribute.hxx [new file with mode: 0644]
src/Prs3d/Prs3d_DatumAxes.hxx [new file with mode: 0644]
src/Prs3d/Prs3d_DatumMode.hxx [new file with mode: 0644]
src/Prs3d/Prs3d_DatumParts.hxx [new file with mode: 0644]
src/QADraw/QADraw.cxx

index 2bdee5f5797d9b221a22ce96d31b0cf172a1258d..c35661d2f00455070be9a7280b21f62e67268571 100644 (file)
 
 #include <AIS_Trihedron.hxx>
 
-#include <AIS_Axis.hxx>
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_InteractiveObject.hxx>
-#include <AIS_Plane.hxx>
-#include <AIS_Point.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <DsgPrs_DatumPrs.hxx>
+#include <AIS_TrihedronOwner.hxx>
+
 #include <Geom_Axis2Placement.hxx>
-#include <Geom_CartesianPoint.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Point.hxx>
 #include <Geom_Transformation.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Dir.hxx>
 #include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
-#include <gp_Vec.hxx>
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_AspectFillArea3d.hxx>
 #include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_MaterialAspect.hxx>
-#include <Graphic3d_Structure.hxx>
+
 #include <Prs3d_ArrowAspect.hxx>
 #include <Prs3d_DatumAspect.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_Presentation.hxx>
 #include <Prs3d_Projector.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_Text.hxx>
 #include <Prs3d_TextAspect.hxx>
+
 #include <Quantity_Color.hxx>
-#include <Select3D_SensitiveBox.hxx>
+
 #include <Select3D_SensitivePoint.hxx>
+#include <Select3D_SensitivePrimitiveArray.hxx>
 #include <Select3D_SensitiveSegment.hxx>
 #include <Select3D_SensitiveTriangle.hxx>
 #include <SelectBasics_EntityOwner.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <Standard_Type.hxx>
-#include <TColgp_Array1OfPnt.hxx>
 #include <UnitsAPI.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(AIS_Trihedron,AIS_InteractiveObject)
+//#define POINT_SELECTION_MODE
 
-//=======================================================================
-//function : AIS_Trihedron
-//purpose  : 
-//=======================================================================
-AIS_Trihedron::AIS_Trihedron(const Handle(Geom_Axis2Placement)& aComponent):
-myComponent (aComponent),
-myHasOwnSize (Standard_False),
-myHasOwnTextColor (Standard_False),
-myHasOwnArrowColor (Standard_False)
+#define PATCH_TO_OCCT_710
+
+IMPLEMENT_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
+
+static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
 {
-  LoadSubObjects();
+  TColStd_ListIteratorOfListOfInteger It(LL);
+  for (;It.More(); It.Next()){
+    if (It.Value() == aMode)
+      return Standard_True;
+  }
+  return Standard_False;
 }
 
 //=======================================================================
-//function : SetComponent
+//function : AIS_Trihedron
 //purpose  : 
 //=======================================================================
-
-void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& aComponent)
+AIS_Trihedron::AIS_Trihedron(const Handle(Geom_Axis2Placement)& theComponent)
+: myHasOwnSize(Standard_False),
+  myHasOwnTextColor(Standard_False),
+  myHasOwnArrowColor(Standard_False),
+  myComponent(theComponent),
+  myDisplayMode(Prs3d_DM_WireFrame)
 {
-  myComponent = aComponent;
-
-  // Remove from current context and nullify objects to update
-  Handle(AIS_InteractiveContext) anAISContext = GetContext();
-  Standard_Boolean hasContext = (anAISContext.IsNull() == Standard_False);
-  Standard_Integer anIdx;
-  for (anIdx = 0; anIdx < 7; anIdx++)
-  {
-    // Deselect object
-    if (hasContext)
-    {
-      if (anAISContext->IsSelected (myShapes[anIdx]))
-        anAISContext->AddOrRemoveSelected (myShapes[anIdx], Standard_False);
-
-      anAISContext->Remove (myShapes[anIdx], Standard_False);
-    }
-    myShapes[anIdx].Nullify();
-  }
-
-  LoadSubObjects();
+  // default presentation parameters
+  SetDisplayMode (0);
+  SetHilightMode (0);
+
+  // datum creation
+  Handle (Prs3d_DatumAspect) aDatumAspect = new Prs3d_DatumAspect();
+  myDrawer->SetDatumAspect(aDatumAspect);
+
+  // entities to provide custom selection
+  Quantity_Color aHighlightColor = Quantity_NOC_GRAY80;
+  myHighlightAspect = new Prs3d_ShadingAspect();
+  myHighlightAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
+  myHighlightAspect->SetColor(aHighlightColor);
+  Graphic3d_MaterialAspect aHighlightMaterial;
+  aHighlightMaterial.SetColor (aHighlightColor);
+  myHighlightAspect->SetMaterial (aHighlightMaterial);
+
+  Handle(Prs3d_LineAspect) aLineAspect = aDatumAspect->LineAspect(Prs3d_DP_XAxis);
+  myHighlightLineAspect = new Prs3d_LineAspect(aHighlightColor, aLineAspect->Aspect()->Type(),
+                                               aLineAspect->Aspect()->Width());
+  myHighlightPointAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, aHighlightColor, 1.0);
+
+  // selection priorities
+  mySelectionPriority.Bind(Prs3d_DP_None, 5); // complete triedron: priority 5 (same as faces)
+  mySelectionPriority.Bind(Prs3d_DP_Origin, 8); // origin: priority 8
+  for (int i = Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++)
+    mySelectionPriority.Bind((Prs3d_DatumParts)i, 7); // axes: priority: 7
+  for (int i = Prs3d_DP_XOYAxis; i <= Prs3d_DP_XOZAxis; i++)
+    mySelectionPriority.Bind((Prs3d_DatumParts)i, 5); // planes: priority: 5
+
+  // trihedron labels
+  myLabel.Bind(Prs3d_DP_XAxis, "X");
+  myLabel.Bind(Prs3d_DP_YAxis, "Y");
+  myLabel.Bind(Prs3d_DP_ZAxis, "Z");
+
+  Aspect_TypeOfMarker aPointMarker = Aspect_TOM_POINT;
+  myPointAspect = new Prs3d_PointAspect(aPointMarker, aHighlightColor, 0.1);
 }
 
 //=======================================================================
-//function : setLocalTransformation
-//purpose  :
+//function : SetComponent
+//purpose  : 
 //=======================================================================
-
-void AIS_Trihedron::setLocalTransformation (const Handle(Geom_Transformation)& theTrsf)
+void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& theComponent)
 {
-  // Update location to the subshapes
-  Standard_Integer anIdx;
-  for (anIdx = 0; anIdx < 7; anIdx++)
-    myShapes[anIdx]->SetLocalTransformation (theTrsf);
-
-  AIS_InteractiveObject::setLocalTransformation (theTrsf);
+  myComponent = theComponent;
+  LoadRecomputable (AIS_WireFrame);
 }
 
 //=======================================================================
@@ -123,28 +132,17 @@ void AIS_Trihedron::setLocalTransformation (const Handle(Geom_Transformation)& t
 void AIS_Trihedron::SetSize(const Standard_Real aValue)
 {
   myHasOwnSize = Standard_True;
-  if(!myDrawer->HasOwnDatumAspect()){
-    Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
-    myDrawer->SetDatumAspect(DA);
-  }
-  
-  myDrawer->DatumAspect()->SetAxisLength(aValue,aValue,aValue);
-  
-  for(Standard_Integer i=4;i<=6;i++) 
-    Handle(AIS_Plane)::DownCast (myShapes[i])->SetSize(aValue);
+  myDrawer->DatumAspect()->SetAxisLength(aValue, aValue, aValue);
 
   Update();
   UpdateSelection();
 }
 
-
-
 //=======================================================================
 //function : UnsetSize
 //purpose  : if the object has 1 color, the default size of the 
 //           drawer is reproduced, otherwise DatumAspect becomes null
 //=======================================================================
-
 void AIS_Trihedron::UnsetSize()
 {
   if(!myHasOwnSize) return;
@@ -153,14 +151,11 @@ void AIS_Trihedron::UnsetSize()
   if(hasOwnColor){
     const Handle(Prs3d_DatumAspect) DA =
       myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() : new Prs3d_DatumAspect();
-    myDrawer->DatumAspect()->SetAxisLength(DA->FirstAxisLength(),
-                                          DA->SecondAxisLength(),
-                                          DA->ThirdAxisLength());
+    myDrawer->DatumAspect()->SetAxisLength(DA->AxisLength(Prs3d_DP_XAxis),
+                                           DA->AxisLength(Prs3d_DP_YAxis),
+                                           DA->AxisLength(Prs3d_DP_ZAxis));
   }
   else
-  {
-    myDrawer->SetDatumAspect (Handle(Prs3d_DatumAspect)());
-  }
   Update();
   UpdateSelection();
 
@@ -173,498 +168,658 @@ void AIS_Trihedron::UnsetSize()
 
 Standard_Real AIS_Trihedron::Size() const 
 {
-  return myDrawer->DatumAspect()->FirstAxisLength();
+  return myDrawer->DatumAspect()->AxisLength(Prs3d_DP_XAxis);
 }
 
 //=======================================================================
-//function : XAxis
+//function : Compute
 //purpose  : 
 //=======================================================================
-Handle(AIS_Axis) AIS_Trihedron::XAxis() const 
+void AIS_Trihedron::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+                             const Handle(Prs3d_Presentation)& thePrs,
+                             const Standard_Integer /*theMode*/)
 {
-  Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[1]);
-  if (anAxis.IsNull())
-  {
-    anAxis = new AIS_Axis (myComponent,AIS_TOAX_XAxis);
-  }
-  return anAxis;
+  thePrs->SetInfiniteState (Standard_True);
+
+  gp_Ax2 anAxis(myComponent->Ax2());
+  myDrawer->DatumAspect()->UpdatePrimitives(myDisplayMode, anAxis.Location(),
+                                            anAxis.XDirection(), anAxis.YDirection(),
+                                            anAxis.Direction());
+  ComputePresentation (thePrsMgr, thePrs);
 }
 
 //=======================================================================
-//function : YAxis
-//purpose  : 
+//function : Compute
+//purpose  :
 //=======================================================================
-Handle(AIS_Axis) AIS_Trihedron::YAxis() const 
+void AIS_Trihedron::Compute (const Handle(Prs3d_Projector)& theProjector,
+                             const Handle(Geom_Transformation)& theTrsf,
+                             const Handle(Prs3d_Presentation)& thePrs)
 {
-  Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[2]);
-  if (anAxis.IsNull())
-  {
-    anAxis = new AIS_Axis (myComponent,AIS_TOAX_YAxis);
-  }
-
-  return anAxis;
+  PrsMgr_PresentableObject::Compute (theProjector, theTrsf, thePrs);
 }
 
 //=======================================================================
-//function : Axis
-//purpose  : 
+//function : ComputeSelection
+//purpose  :
 //=======================================================================
-Handle(AIS_Axis) AIS_Trihedron::Axis() const 
+void AIS_Trihedron::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
+                                      const Standard_Integer theMode)
 {
-  Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[3]);
-  if (anAxis.IsNull())
+  theSelection->Clear();
+
+  Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect();
+  switch (theMode)
   {
-    anAxis = new AIS_Axis (myComponent,AIS_TOAX_ZAxis);
+    case 0: // complete triedron: only 1 owner
+    {
+      Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this,
+                                                    mySelectionPriority.Find(Prs3d_DP_None));
+      bool isShadingMode = DatumDisplayMode() == Prs3d_DM_Shaded;
+      for (int i = isShadingMode ? Prs3d_DP_Origin : Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++)
+      {
+        Prs3d_DatumParts aPart = (Prs3d_DatumParts)i;
+        if (!anAspect->DrawDatumPart(aPart))
+          continue;
+        theSelection->Add (CreateSensitiveEntity(aPart, anOwner));
+      }
+    }
+    break;
+    case 1: // origin
+    {
+      Prs3d_DatumParts aPart = Prs3d_DP_Origin;
+      if (anAspect->DrawDatumPart(aPart))
+      {
+        Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart,
+                                                              mySelectionPriority.Find(aPart));
+        Handle(Graphic3d_ArrayOfPrimitives) aPrimitives = anAspect->ArrayOfPrimitives(aPart);
+        theSelection->Add (CreateSensitiveEntity(aPart, anOwner));
+      }
+    }
+    break;
+    case 2: // axes
+    {
+      for (int i = Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++)
+      {
+        Prs3d_DatumParts aPart = (Prs3d_DatumParts)i;
+        if (!anAspect->DrawDatumPart(aPart))
+          continue;
+        Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart,
+                                                            mySelectionPriority.Find(aPart));
+        theSelection->Add (CreateSensitiveEntity(aPart, anOwner));
+      }
+    }
+    break;
+    case 3: // main planes
+    {
+      /// Creates Trihedron owner for each trihedron plane
+      {
+#ifndef PATCH_TO_OCCT_710
+        for (int i = Prs3d_DP_XOYAxis; i <= Prs3d_DP_XOZAxis; i++)
+        {
+          Prs3d_DatumParts aPart = (Prs3d_DatumParts)i;
+          if (!anAspect->DrawDatumPart(aPart))
+            continue;
+          Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart,
+                                                              mySelectionPriority.Find(aPart));
+          theSelection->Add (CreateSensitiveEntity(aPart, anOwner));
+        }
+#endif
+      }
+    }
+    break;
+    default:
+      break;
   }
-  return anAxis;
 }
 
 //=======================================================================
-//function : Position
-//purpose  : 
+//function : IsAutoHilight
+//purpose  :
 //=======================================================================
-Handle(AIS_Point) AIS_Trihedron::Position() const 
+Standard_Boolean AIS_Trihedron::IsAutoHilight() const
 {
-  Handle(AIS_Point) aPt = Handle(AIS_Point)::DownCast(myShapes[0]);
-  if (aPt.IsNull()) {
-    gp_Pnt aPnt = myComponent->Ax2().Location();
-    Handle(Geom_Point) aPoint = new Geom_CartesianPoint(aPnt);
-    aPt = new AIS_Point (aPoint);
-  }
-  return aPt;
+  // highlight is processed in the current presentation
+  return false;
 }
 
 //=======================================================================
-//function : XYPlane
-//purpose  : 
+//function : HilightOwnerWithColor
+//purpose  :
 //=======================================================================
-Handle(AIS_Plane) AIS_Trihedron::XYPlane() const 
+void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
+                                           const Handle(Graphic3d_HighlightStyle)& theStyle,
+                                           const Handle(SelectMgr_EntityOwner)& theOwner)
 {
-  Handle(AIS_Plane) aPl = Handle(AIS_Plane)::DownCast(myShapes[4]);
-  if (aPl.IsNull()) aPl = new AIS_Plane (myComponent,AIS_TOPL_XYPlane);
-  return aPl;
-}
+  Handle(AIS_TrihedronOwner) anOwner = Handle(AIS_TrihedronOwner)::DownCast (theOwner);
+  if (anOwner.IsNull())
+  {
+    /// default 0 selectin mode
+    Standard_Integer aHiMode = HasHilightMode() ? HilightMode() : 0;
+    thePM->Color (this, theStyle, aHiMode, NULL, Graphic3d_ZLayerId_Top);
+  }
+  else {
+    Handle(Prs3d_Presentation) aPresentation = GetHilightPresentation(thePM);
+    if (!aPresentation.IsNull())
+    {
+      aPresentation->Clear();
+      const Prs3d_DatumParts& aPart = anOwner->DatumPart();
+      Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPresentation);
+      Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect();
+      if (aPart >= Prs3d_DP_XOYAxis && aPart <= Prs3d_DP_XOZAxis)
+      {
+        // planes selection is equal in both shading and wireframe mode
+        aGroup->SetGroupPrimitivesAspect (myHighlightLineAspect->Aspect());
+      }
+      else {
+        if (DatumDisplayMode() == Prs3d_DM_Shaded)
+          aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect());
+        else {
+          if (aPart == Prs3d_DP_Origin)
+            aGroup->SetGroupPrimitivesAspect (myHighlightPointAspect->Aspect());
+          else
+            aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect(aPart)->Aspect());
+        }
+      }
+      aGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart));
 
-//=======================================================================
-//function : XZPlane
-//purpose  : 
-//=======================================================================
-Handle(AIS_Plane) AIS_Trihedron::XZPlane() const 
-{
-  Handle(AIS_Plane) aPl = Handle(AIS_Plane)::DownCast(myShapes[5]);
-  if (aPl.IsNull()) aPl = new AIS_Plane (myComponent,AIS_TOPL_XZPlane);
-  return aPl;
+      aPresentation->Highlight (theStyle);
+      thePM->AddToImmediateList (aPresentation);
+    }
+  }
 }
 
-//=======================================================================
-//function : YZPlane
-//purpose  : 
-//=======================================================================
-Handle(AIS_Plane) AIS_Trihedron::YZPlane() const 
+//========================================================================
+//function : HilightSelected
+//purpose  :
+//========================================================================
+void AIS_Trihedron::HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
+                                     const SelectMgr_SequenceOfOwner& theOwners)
 {
-  Handle(AIS_Plane) aPl = Handle(AIS_Plane)::DownCast(myShapes[6]);
-  if (aPl.IsNull()) aPl = new AIS_Plane (myComponent,AIS_TOPL_YZPlane);
-  return aPl;
-}
+  if (theOwners.IsEmpty() || GetContext().IsNull())
+  {
+    return;
+  }
 
-//=======================================================================
-//function : Compute
-//purpose  : 
-//=======================================================================
-void AIS_Trihedron::Compute(
- const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
- const Handle(Prs3d_Presentation)& aPresentation, 
- const Standard_Integer aMode)
-{
-  aPresentation->SetInfiniteState (Standard_True);
-  switch(aMode){
-  case 0: 
-    DsgPrs_DatumPrs::Add(aPresentation,myComponent->Ax2(),myDrawer);
-    break;
-  case 1:
-    break;
-  case 2:
-    break;
+  Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect();
+  bool isShadingMode = DatumDisplayMode() == Prs3d_DM_Shaded;
+
+  SelectMgr_SequenceOfOwner::Iterator anIterator(theOwners);
+
+#ifndef PATCH_TO_OCCT_710
+  const Handle(Prs3d_Drawer)& aContextSelStyle = GetContext()->SelectionStyle();
+  const Quantity_Color& aSelectionColor = aContextSelStyle->Color();
+#else
+  const Quantity_Color& aSelectionColor = GetContext()->SelectionStyle()->Color();
+#endif
+  for (; anIterator.More(); anIterator.Next())
+  {
+    const Handle(SelectMgr_EntityOwner)& anOwner = anIterator.Value();
+    if (!anOwner->IsKind (STANDARD_TYPE (AIS_TrihedronOwner)))
+    {
+#ifdef PATCH_TO_OCCT_710
+      thePM->Color (this, GetContext()->SelectionStyle(), 0);
+#else
+      thePM->Color (this, aContextSelStyle, 0);
+#endif
+    }
+    else
+    {
+      Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast
+                                                                             (anOwner);
+      const Prs3d_DatumParts& aPart = aTrihedronOwner->DatumPart();
+      if (mySelectedParts.Contains(aPart))
+      {
+        // the owner has been already selected
+        continue;
+      }
+      Handle(Graphic3d_Group) aGroup;
+      if (!myPartToGroup.Find(aTrihedronOwner->DatumPart(), aGroup) )
+      {
+        // graphical group for this owner was not created
+        continue;
+      }
+
+      if (aPart >= Prs3d_DP_XOYAxis && aPart <= Prs3d_DP_XOZAxis) {
+        Handle(Prs3d_LineAspect) aLineAspect = myHighlightLineAspect;
+        aLineAspect->SetColor(aSelectionColor);
+        aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect());
+      }
+      else {
+        if (isShadingMode) {
+          Handle(Prs3d_ShadingAspect) aShadingAspect = myHighlightAspect;
+          aShadingAspect->SetColor(aSelectionColor);
+          aGroup->SetGroupPrimitivesAspect (aShadingAspect->Aspect());
+        }
+        else {
+          if (aPart == Prs3d_DP_Origin) {
+#ifndef POINT_SELECTION_MODE
+#ifdef PATCH_TO_OCCT_710
+            myPointAspect->SetColor(aSelectionColor);
+            myPointAspect->SetTypeOfMarker(Aspect_TOM_PLUS);
+#else
+            Handle(Prs3d_PointAspect) aPointAspect = myHighlightPointAspect;
+            aPointAspect->SetColor(aSelectionColor);
+            aGroup->SetGroupPrimitivesAspect (aPointAspect->Aspect());
+#endif
+#else
+            anAspect->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS);
+#endif
+          }
+          else {
+            Handle(Prs3d_LineAspect) aLineAspect = myHighlightLineAspect;
+            aLineAspect->SetColor(aSelectionColor);
+            aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect());
+          }
+        }
+      }
+      mySelectedParts.Append(aPart);
+    }
   }
+  SynchronizeAspects();
 }
 
 //=======================================================================
-//function : Compute
-//purpose  : 
+//function : ClearSelected
+//purpose  :
 //=======================================================================
-
-void AIS_Trihedron::Compute(const Handle(Prs3d_Projector)& aProjector,
-                            const Handle(Geom_Transformation)& aTransformation,
-                            const Handle(Prs3d_Presentation)& aPresentation)
+void AIS_Trihedron::ClearSelected()
 {
-// Standard_NotImplemented::Raise("AIS_Trihedron::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
- PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
+  NCollection_List<Prs3d_DatumParts>::Iterator anIterator(mySelectedParts);
+  Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect();
+  bool isShadingMode = DatumDisplayMode() == Prs3d_DM_Shaded;
+  for (; anIterator.More(); anIterator.Next())
+  {
+    Prs3d_DatumParts aPart = anIterator.Value();
+    Handle(Graphic3d_Group) aGroup = myPartToGroup.Find(aPart);
+    if (aPart >= Prs3d_DP_XOYAxis && aPart <= Prs3d_DP_XOZAxis) {
+      aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect(aPart)->Aspect());
+    }
+    if (isShadingMode)
+      aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect());
+    else {
+      if (aPart == Prs3d_DP_Origin) {
+#ifndef POINT_SELECTION_MODE
+#ifdef PATCH_TO_OCCT_710
+        myPointAspect->SetTypeOfMarker(Aspect_TOM_POINT);
+        aGroup->SetGroupPrimitivesAspect(myPointAspect->Aspect());
+#else
+        aGroup->SetGroupPrimitivesAspect (anAspect->PointAspect()->Aspect());
+#endif
+#else
+        anAspect->PointAspect()->SetTypeOfMarker(Aspect_TOM_EMPTY);
+        SynchronizeAspects();
+#endif
+      }
+      else
+        aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect(aPart)->Aspect());
+    }
+  }
+  mySelectedParts.Clear();
 }
 
 //=======================================================================
-//function : ComputeSelection
-//purpose  : 
+//function : ComputePresentation
+//purpose  :
 //=======================================================================
-
-void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-                                     const Standard_Integer aMode)
+void AIS_Trihedron::ComputePresentation (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/,
+                                         const Handle(Prs3d_Presentation)& thePrs)
 {
-  // retrieve the tops of the trihedron.
-  Standard_Integer Prior, anIdx;
-  Handle(SelectMgr_EntityOwner) eown;
-  TColgp_Array1OfPnt PP(1,4),PO(1,4);
-  ExtremityPoints(PP);
+  myPartToGroup.Clear();
+  Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect();
+  bool isShadingMode = DatumDisplayMode() == Prs3d_DM_Shaded;
+  // display origin
+  {
+    // Origin is visualized only in shading mode
+    Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
+    Prs3d_DatumParts aPart = Prs3d_DP_Origin;
+#ifdef PATCH_TO_OCCT_710
+      // Origin is visualized only in shading mode
+      //Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
+      //Prs3d_DatumParts aPart = Prs3d_DP_Origin;
+      myPartToGroup.Bind(aPart, aGroup);
+      if (isShadingMode)
+        aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect());
+      else
+        aGroup->SetGroupPrimitivesAspect(myPointAspect->Aspect());
+      aGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart));
+#else
+    if (anAspect->DrawDatumPart(aPart)) {
+      myPartToGroup.Bind(aPart, aGroup);
+      if (isShadingMode)
+        aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect());
+      else {
+        aGroup->SetGroupPrimitivesAspect (anAspect->PointAspect()->Aspect());
+      }
+      aGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart));
+    }
+#endif
+  }
 
-  // remove shapes from active selections
-  Handle(AIS_InteractiveContext) anAISContext = GetContext();
-  if (!anAISContext.IsNull())
-    for (anIdx = 0; anIdx < 7; anIdx++)
+  // display axes
+  {
+    for (Standard_Integer anAxisIter = Prs3d_DP_XAxis; anAxisIter <= Prs3d_DP_ZAxis; ++anAxisIter)
     {
-      // Deselect object
-      if (anAISContext->IsSelected (myShapes[anIdx]))
-        anAISContext->AddOrRemoveSelected (myShapes[anIdx], Standard_False);
-
-      anAISContext->Remove (myShapes[anIdx], Standard_False);
-    }
-  
-  switch (aMode) {
-  case 0:
-    {   // complete triedron only 1 owner : this... priority 5 (same as faces)
-      Prior = 5;
-      eown = new SelectMgr_EntityOwner(this,Prior);
-      for (Standard_Integer i=1; i<=3;i++)
-       aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1)));
-      break;
+      Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
+      if (!anAspect->DrawDatumPart(aPart))
+        continue;
+      {
+        Handle(Graphic3d_Group) anAxisGroup = Prs3d_Root::NewGroup (thePrs);
+        myPartToGroup.Bind(aPart, anAxisGroup);
+        if (isShadingMode)
+          anAxisGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect());
+        else
+          anAxisGroup->SetGroupPrimitivesAspect (anAspect->LineAspect(aPart)->Aspect());
+        anAxisGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart));
+
+        // draw arrow
+        Handle(Graphic3d_Group) anArrowGroup = Prs3d_Root::NewGroup (thePrs);
+        anArrowGroup->SetPrimitivesAspect(anAspect->ArrowAspect()->Aspect());
+
+        Prs3d_DatumParts anArrowPart = anAspect->ArrowPartForAxis(aPart);
+        if (!anAspect->DrawDatumPart(anArrowPart))
+          continue;
+        anArrowGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(anArrowPart));
+      }
     }
-  case 1:
-    {  //origin : 
-      Prior = 8;
-      const Handle(SelectMgr_SelectableObject)& anObj = myShapes[0]; // to avoid ambiguity
-      eown= new SelectMgr_EntityOwner(anObj,Prior);
-      
-      aSelection->Add(new Select3D_SensitivePoint (eown,myComponent->Location()));
-      // If the trihedron's shapes display and selection modes are the same
-      // the shapes are still displayed after selection, so we need to
-      // use different presentation and hide it by nullifying
-      if (!anAISContext.IsNull())
+  }
+  // display labels
+  if (anAspect->ToDrawLabels())
+  {
+    Handle(Geom_Axis2Placement) aComponent = myComponent;
+    gp_Pnt anOrigin = aComponent->Location();
+    for (Standard_Integer anAxisIter = Prs3d_DP_XAxis; anAxisIter <= Prs3d_DP_ZAxis; ++anAxisIter)
+    {
+      Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
+      if (!anAspect->DrawDatumPart(aPart))
+        continue;
+      Standard_Real anAxisLength = anAspect->AxisLength(aPart);
+      TCollection_ExtendedString aLabel = myLabel.Find(aPart);
+      gp_Dir aDir;
+      switch (aPart)
       {
-        anAISContext->Display (myShapes[0], 1, 0, Standard_False);
-        anAISContext->ClearPrs (myShapes[0], 1, Standard_False);
+        case Prs3d_DP_XAxis: aDir = aComponent->XDirection(); break;
+        case Prs3d_DP_YAxis: aDir = aComponent->YDirection(); break;
+        case Prs3d_DP_ZAxis: aDir = aComponent->Direction(); break;
+        default: break;
       }
-      
-      break;
+      Handle(Graphic3d_Group) aLabelGroup = Prs3d_Root::NewGroup (thePrs);
+      gp_Pnt aPoint = anOrigin.XYZ() + aDir.XYZ()*anAxisLength;
+      Prs3d_Text::Draw (aLabelGroup, anAspect->TextAspect(), aLabel, aPoint);
     }
-  case 2:
-    {  //axes ... priority 7
-      Prior = 7;
-      for (Standard_Integer i=1; i<=3;i++){
-        const Handle(SelectMgr_SelectableObject)& anObj = myShapes[i]; // to avoid ambiguity
-       eown= new SelectMgr_EntityOwner(anObj,Prior);
-       aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1)));
+  }
+  // planes invisible group for planes selection
+  /// plane selection mode is available only in wireframe mode
+#ifndef PATCH_TO_OCCT_710
+  for (Standard_Integer anAxisIter = Prs3d_DP_XOYAxis; anAxisIter <= Prs3d_DP_XOZAxis; ++anAxisIter)
+  {
+    Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
+    if (!anAspect->DrawDatumPart(aPart))
+      continue;
+    {
+      Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
+      myPartToGroup.Bind(aPart, aGroup);
 
-      }
+      const Handle(Graphic3d_AspectLine3d)& aLineAspect = anAspect->LineAspect(aPart)->Aspect();
+      aLineAspect->SetType(Aspect_TOL_EMPTY);
 
-      // If the trihedron's shapes display and selection modes are the same
-      // the shapes are still displayed after selection, so we need to
-      // use different presentation and hide it by nullifying
-      AIS_TypeOfAxis anAxisType;
-      if (!anAISContext.IsNull())
-        for (anIdx = 1; anIdx <= 3; anIdx++)
-        {
-          // update AIS_Axis for selection
-          Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[anIdx]);
-          Handle(Prs3d_Drawer) aDrawer = anAxis->Attributes();
-          Handle(Prs3d_DatumAspect) aDatum = myDrawer->DatumAspect();
-          aDrawer->SetDatumAspect (aDatum);
-          anAxisType = anAxis->TypeOfAxis();
-          anAxis->SetAxis2Placement (myComponent, anAxisType);
-
-          // display
-          anAISContext->Display (myShapes[anIdx], 1, 0, Standard_False);
-          anAISContext->ClearPrs (myShapes[anIdx], 1, Standard_False);
-        }
-      
-      break;
-    }
-    
-  case 3:
-    {  // main planes priority 6
-//      PO(1) = PP(1);
-//      PO(4) = PP(1);
-      Prior =5;
-      
-      
-      const Handle(SelectMgr_SelectableObject)& anObj4 = myShapes[4]; // to avoid ambiguity
-      eown= new SelectMgr_EntityOwner(anObj4,Prior);
-//      PO(2) = PP(2);PO(3) = PP(3);
-      aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(2),PP(3)));
-
-      const Handle(SelectMgr_SelectableObject)& anObj5 = myShapes[5]; // to avoid ambiguity
-      eown= new SelectMgr_EntityOwner(anObj5,Prior);
-//      PO(2) = PP(3);PO(3) = PP(4);
-      aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(2),PP(4)));
-
-      const Handle(SelectMgr_SelectableObject)& anObj6 = myShapes[6]; // to avoid ambiguity
-      eown= new SelectMgr_EntityOwner(anObj6,Prior);
-//      PO(2) = PP(4);PO(3) = PP(2);
-      aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(3),PP(4)));
-      
-      // If the trihedron's shapes display and selection modes are the same
-      // the shapes are still displayed after selection, so we need to
-      // use different presentation and hide it by nullifying
-      if (!anAISContext.IsNull())
-        for (anIdx = 4; anIdx < 7; anIdx++)
-       {
-          anAISContext->Display (myShapes[anIdx], 1, 0, Standard_False);
-          anAISContext->ClearPrs (myShapes[anIdx], 1, Standard_False);
-        }
+      aGroup->AddPrimitiveArray (anAspect->ArrayOfPrimitives(aPart));
+      aGroup->SetGroupPrimitivesAspect (aLineAspect);
     }
   }
-  
+#endif
 }
 
 //=======================================================================
-//function : SetColor
+//function : LoadRecomputable
 //purpose  : 
 //=======================================================================
 
-void AIS_Trihedron::SetColor(const Quantity_NameOfColor aCol)
+void AIS_Trihedron::LoadRecomputable(const Standard_Integer TheMode)
 {
-  SetColor(Quantity_Color(aCol));
+  myRecomputeEveryPrs = Standard_False;
+  if(!IsInList(myToRecomputeModes,TheMode))
+    myToRecomputeModes.Append(TheMode);
 }
 
-void AIS_Trihedron::SetColor(const Quantity_Color &aCol)
+//=======================================================================
+//function : SetColor
+//purpose  :
+//=======================================================================
+
+void AIS_Trihedron::SetColor (const Prs3d_DatumParts& thePart,
+                              const Quantity_Color& theColor)
 {
-  hasOwnColor=Standard_True;
-  myOwnColor = aCol;
-  
-  if(!myDrawer->HasOwnDatumAspect()){
-    Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
-    
-    DA->SetAxisLength(myDrawer->DatumAspect()->FirstAxisLength(),
-                     myDrawer->DatumAspect()->SecondAxisLength(),
-                     myDrawer->DatumAspect()->ThirdAxisLength());
-    myDrawer->SetDatumAspect(DA);
-  }
-  myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(aCol);
-  myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(aCol);
-  myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(aCol);
+  myDrawer->DatumAspect()->ShadingAspect(thePart)->SetColor(theColor);
+  if (thePart != Prs3d_DP_Origin)
+    myDrawer->DatumAspect()->LineAspect(thePart)->SetColor(theColor);
+}
+
+//=======================================================================
+//function : SetTextColor
+//purpose  :
+//=======================================================================
 
+void AIS_Trihedron::SetTextColor (const Quantity_NameOfColor theColor)
+{
+  SetTextColor(Quantity_Color(theColor));
 }
 
 //=======================================================================
 //function : SetTextColor
-//purpose  : 
+//purpose  :
 //=======================================================================
 
-void AIS_Trihedron::SetTextColor(const Quantity_NameOfColor aCol)
+void AIS_Trihedron::SetTextColor (const Quantity_Color& theColor)
 {
-  myHasOwnTextColor = Standard_True;
-  myOwnTextColor = aCol;
-  
-  if(!myDrawer->HasOwnDatumAspect()){
-    Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
-    
-    DA->SetAxisLength(myDrawer->DatumAspect()->FirstAxisLength(),
-                     myDrawer->DatumAspect()->SecondAxisLength(),
-                     myDrawer->DatumAspect()->ThirdAxisLength());
-    myDrawer->SetDatumAspect(DA);
-  }
-  Handle(Prs3d_TextAspect) aspect = myDrawer->TextAspect();
-  aspect->SetColor(aCol);
-  myDrawer->SetTextAspect(aspect);
+  myDrawer->DatumAspect()->TextAspect()->SetColor(theColor);
 }
 
-void AIS_Trihedron::SetArrowColor(const Quantity_NameOfColor aCol)
+Quantity_Color AIS_Trihedron::Color (const Prs3d_DatumParts& thePart)
 {
-  myHasOwnArrowColor = Standard_True;
-  myOwnArrowColor = aCol;
-  
-  if(!myDrawer->HasOwnDatumAspect()){
-    Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
-    
-    DA->SetAxisLength(myDrawer->DatumAspect()->FirstAxisLength(),
-                     myDrawer->DatumAspect()->SecondAxisLength(),
-                     myDrawer->DatumAspect()->ThirdAxisLength());
-    myDrawer->SetDatumAspect(DA);
+  Quantity_Color aColor;
+  if (DatumDisplayMode() == Prs3d_DM_Shaded)
+  {
+    aColor = myDrawer->DatumAspect()->ShadingAspect(thePart)->Color();
+  }
+  else
+  {
+    aColor = myDrawer->DatumAspect()->LineAspect(thePart)->Aspect()->Color();
   }
-  Handle(Prs3d_ArrowAspect) aspect = myDrawer->ArrowAspect();
-  aspect->SetColor(aCol);
-  myDrawer->SetArrowAspect(aspect);
+  return aColor;
 }
 
 //=======================================================================
-Standard_Boolean AIS_Trihedron::HasTextColor() const {
+//function : SetOriginColor
+//purpose  :
+//=======================================================================
+void AIS_Trihedron::SetOriginColor (const Quantity_Color& theColor)
+{
+  if (DatumDisplayMode() == Prs3d_DM_Shaded)
+  {
+    SetColor(Prs3d_DP_Origin, theColor);
+  }
+}
 
-  return myHasOwnTextColor;
+//=======================================================================
+//function : SetXAxisColor
+//purpose  :
+//=======================================================================
+void AIS_Trihedron::SetXAxisColor (const Quantity_Color& theColor)
+{
+  SetColor(Prs3d_DP_XAxis, theColor);
 }
 
 //=======================================================================
-Quantity_NameOfColor AIS_Trihedron::TextColor() const {
+//function : SetYAxisColor
+//purpose  :
+//=======================================================================
+void AIS_Trihedron::SetYAxisColor (const Quantity_Color& theColor)
+{
+  SetColor(Prs3d_DP_YAxis, theColor);
+}
 
-  return myOwnTextColor;
+//=======================================================================
+//function : SetAxisColor
+//purpose  :
+//=======================================================================
+void AIS_Trihedron::SetAxisColor (const Quantity_Color& theColor)
+{
+  SetColor(Prs3d_DP_ZAxis, theColor);
 }
 
 //=======================================================================
-Standard_Boolean AIS_Trihedron::HasArrowColor() const {
+//function : SetColor
+//purpose  : 
+//=======================================================================
+void AIS_Trihedron::SetColor (const Quantity_NameOfColor theColor)
+{
+  SetColor(Quantity_Color(theColor));
+}
 
-  return myHasOwnArrowColor;
+void AIS_Trihedron::SetColor (const Quantity_Color& theColor)
+{
+  hasOwnColor = Standard_True;
+#ifndef PATCH_TO_OCCT_710
+  myDrawer->SetColor(theColor);
+#endif
+  SetColor(Prs3d_DP_Origin, theColor);
+  SetColor(Prs3d_DP_XAxis, theColor);
+  SetColor(Prs3d_DP_YAxis, theColor);
+  SetColor(Prs3d_DP_ZAxis, theColor);
 }
 
-//=======================================================================
-Quantity_NameOfColor AIS_Trihedron::ArrowColor() const {
+void AIS_Trihedron::SetArrowColor (const Quantity_NameOfColor theColor)
+{
+  SetArrowColor(Quantity_Color(theColor));
+}
 
-  return myOwnArrowColor;
+void AIS_Trihedron::SetArrowColor (const Quantity_Color& theColor)
+{
+  myHasOwnArrowColor = Standard_True;
+  myDrawer->DatumAspect()->ArrowAspect()->SetColor(theColor);
 }
 
+//=======================================================================
+Standard_Boolean AIS_Trihedron::HasTextColor() const
+{
+  return myHasOwnTextColor;
+}
 
 //=======================================================================
-//function : Compute
-//purpose  : to avoid warning
+Quantity_Color AIS_Trihedron::TextColor() const
+{
+  return myDrawer->DatumAspect()->TextAspect()->Aspect()->Color();
+}
+
 //=======================================================================
-void AIS_Trihedron::Compute(const Handle(Prs3d_Projector)&, 
-                              const Handle(Prs3d_Presentation)&)
+Standard_Boolean AIS_Trihedron::HasArrowColor () const
 {
+  return myHasOwnArrowColor;
 }
+
+//=======================================================================
+Quantity_Color AIS_Trihedron::ArrowColor () const
+{
+  return myDrawer->DatumAspect()->ArrowAspect()->Aspect()->Color();
+}
+
 //=======================================================================
 //function : Type
 //purpose  : 
 //=======================================================================
-
-AIS_KindOfInteractive AIS_Trihedron::Type() const 
-{return AIS_KOI_Datum;}
+AIS_KindOfInteractive AIS_Trihedron::Type () const 
+{
+  return AIS_KOI_Datum;
+}
 
 
 //=======================================================================
 //function : Signature
 //purpose  : 
 //=======================================================================
-
- Standard_Integer AIS_Trihedron::Signature() const 
-{return 3;}
-
-//=======================================================================
-//function : ExtremityPoints
-//purpose  : to avoid warning
-//=======================================================================
-void  AIS_Trihedron::ExtremityPoints(TColgp_Array1OfPnt& PP) const 
+ Standard_Integer AIS_Trihedron::Signature () const 
 {
-  gp_Ax2 theax(myComponent->Ax2());
-  PP(1) = theax.Location();
-
-  Standard_Real len = myDrawer->DatumAspect()->FirstAxisLength();
-  gp_Vec vec = theax.XDirection();
-  vec *= len;
-  PP(2) = PP(1).Translated(vec);
-  
-  len = myDrawer->DatumAspect()->SecondAxisLength();
-  vec = theax.YDirection();
-  vec *= len;
-  PP(3) = PP(1).Translated(vec);
-
-  len = myDrawer->DatumAspect()->ThirdAxisLength();
-  vec = theax.Direction();
-  vec *= len;
-  PP(4) = PP(1).Translated(vec);
-}
+  return 3;
+ }
 
 //=======================================================================
 //function : AcceptDisplayMode
 //purpose  : 
 //=======================================================================
-
- Standard_Boolean  AIS_Trihedron::
-AcceptDisplayMode(const Standard_Integer aMode) const
-{return aMode == 0;}
-
-
+Standard_Boolean AIS_Trihedron::AcceptDisplayMode (const Standard_Integer theMode) const
+{
+  return theMode == AIS_WireFrame || theMode == AIS_Shaded;
+}
 
 //=======================================================================
 //function : UnsetColor
 //purpose  : 
 //=======================================================================
-
 void AIS_Trihedron::UnsetColor()
 {
   hasOwnColor=Standard_False;
-  myOwnColor = Quantity_NOC_LIGHTSTEELBLUE4;
-  myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(myOwnColor);
-  myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(myOwnColor);
-  myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(myOwnColor);
-  if( HasTextColor() ) {
-    SetTextColor(myOwnColor.Name());
+  Quantity_Color aDefaultColor = Quantity_NOC_LIGHTSTEELBLUE4;
+  SetColor(aDefaultColor);
+  if( HasTextColor() )
+  {
+    SetTextColor(aDefaultColor.Name());
     myHasOwnTextColor = Standard_False;
   }
-  if( HasArrowColor() ) {
-    SetArrowColor(myOwnColor.Name());
+  if( HasArrowColor() )
+  {
+    SetArrowColor(aDefaultColor.Name());
     myHasOwnArrowColor = Standard_False;
   }
-  
-}
-
-//=======================================================================
-//function : UnsetWitdth
-//purpose  : 
-//=======================================================================
-
-void AIS_Trihedron::UnsetWidth()
-{
-  myOwnWidth =0.0;
-  myDrawer->DatumAspect()->FirstAxisAspect()->SetWidth(1.);
-  myDrawer->DatumAspect()->SecondAxisAspect()->SetWidth(1.);
-  myDrawer->DatumAspect()->ThirdAxisAspect()->SetWidth(1.);
-
-}
-void AIS_Trihedron::LoadSubObjects()
-{
-  myShapes[0] = Position();
-  myShapes[1] = XAxis();
-  myShapes[2] = YAxis();
-  myShapes[3] = Axis();
-  myShapes[4] = XYPlane();
-  myShapes[5] = XZPlane();
-  myShapes[6] = YZPlane();
 }
 
-//=======================================================================
-//function : SetContext
-//purpose  : 
-//=======================================================================
-
-void AIS_Trihedron::SetContext(const Handle(AIS_InteractiveContext)& Ctx)
+Handle(SelectBasics_SensitiveEntity) AIS_Trihedron::CreateSensitiveEntity(
+                                       const Prs3d_DatumParts& thePart,
+                                       const Handle(SelectBasics_EntityOwner)& theOwner) const
 {
-//  Standard_Boolean same_DA = myDrawer->Link() == Ctx->DefaultDrawer();
-   
-   if( Ctx.IsNull())
-   {
-      Standard_Integer anIdx;
-      for (anIdx = 0; anIdx < 7; anIdx++)
-      {
-        myShapes[anIdx]->SetContext(Ctx);
-      }
-     AIS_InteractiveObject::SetContext (Ctx);
-     return;
-   }
-  // Remove subobjects from current context
-  Handle(AIS_InteractiveContext) anAISContext = GetContext();
-  
-  Standard_Boolean hasContext = (anAISContext.IsNull() == Standard_False);
-  Standard_Integer anIdx;
-  for (anIdx = 0; anIdx < 7; anIdx++)
+  Handle(SelectBasics_SensitiveEntity) aSelectEntity;
+
+  Handle(Prs3d_DatumAspect) anAspect = Attributes()->DatumAspect();
+  Handle(Graphic3d_ArrayOfPrimitives) aPrimitives = anAspect->ArrayOfPrimitives(thePart);
+  if (aPrimitives.IsNull())
+    return aSelectEntity;
+
+#ifndef PATCH_TO_OCCT_710
+  if (thePart >= Prs3d_DP_XOYAxis && thePart <= Prs3d_DP_XOZAxis)
+  { // plane
+    Standard_Real aX1, anY1, aZ1, aX2, anY2, aZ2, aX3, anY3, aZ3;
+    aPrimitives->Vertice(1, aX1, anY1, aZ1);
+    aPrimitives->Vertice(2, aX2, anY2, aZ2);
+    aPrimitives->Vertice(3, aX3, anY3, aZ3);
+    aSelectEntity = new Select3D_SensitiveTriangle(theOwner, gp_Pnt(aX1, anY1, aZ1),
+                                      gp_Pnt(aX2, anY2, aZ2), gp_Pnt(aX3, anY3, aZ3));
+  }
+  else if (DatumDisplayMode() == Prs3d_DM_Shaded)
+#else
+  if (DatumDisplayMode() == Prs3d_DM_Shaded)
+#endif
+  {
+    Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray
+                                                                                  (theOwner);
+    aSelArray->InitTriangulation (aPrimitives->Attributes(), aPrimitives->Indices(),
+                                  TopLoc_Location());
+    aSelectEntity = aSelArray;
+  }
+  else {
+    if (!Handle(Graphic3d_ArrayOfPoints)::DownCast(aPrimitives).IsNull())
+    {
+      Standard_Real aX, anY, aZ;
+      aPrimitives->Vertice(1, aX, anY, aZ);
+      aSelectEntity = new Select3D_SensitivePoint(theOwner, gp_Pnt(aX, anY, aZ));
+    }
+    else if (!Handle(Graphic3d_ArrayOfSegments)::DownCast(aPrimitives).IsNull())
     {
-      // Deselect object
-      if (hasContext)
-       {
-         if (anAISContext->IsSelected (myShapes[anIdx]))
-           anAISContext->AddOrRemoveSelected (myShapes[anIdx]);
-         
-         anAISContext->Remove (myShapes[anIdx], Standard_False);
-       }
-      myShapes[anIdx].Nullify();
+      Standard_Real aX1, anY1, aZ1, aX2, anY2, aZ2;
+      aPrimitives->Vertice(1, aX1, anY1, aZ1);
+      aPrimitives->Vertice(2, aX2, anY2, aZ2);
+      aSelectEntity = new Select3D_SensitiveSegment(theOwner, gp_Pnt(aX1, anY1, aZ1),
+                                                    gp_Pnt(aX2, anY2, aZ2));
     }
-  AIS_InteractiveObject::SetContext (Ctx);
-  LoadSubObjects();
-  for(Standard_Integer i= 0;i<=6;i++)
-    myShapes[i]->SetContext (Ctx);
+  }
+  return aSelectEntity;
 }
index 980b3e93710cbb7324775e13b8c82830b59e7aec..0a691940dd4d023e0589d0a3513a6c63eec98d19 100644 (file)
 #ifndef _AIS_Trihedron_HeaderFile
 #define _AIS_Trihedron_HeaderFile
 
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_KindOfInteractive.hxx>
+
+#include <Graphic3d_ArrayOfTriangles.hxx>
+
+#include <PrsMgr_PresentationManager3d.hxx>
+
+#include <Prs3d_DatumAspect.hxx>
+#include <Prs3d_DatumMode.hxx>
+#include <Prs3d_DatumParts.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_PointAspect.hxx>
 
-#include <Standard_Boolean.hxx>
 #include <Quantity_NameOfColor.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <Standard_Real.hxx>
+
+#include <Standard.hxx>
+#include <Standard_Boolean.hxx>
 #include <Standard_Integer.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
+#include <Standard_Real.hxx>
+#include <Standard_Type.hxx>
 #include <SelectMgr_Selection.hxx>
-#include <AIS_KindOfInteractive.hxx>
+
 #include <TColgp_Array1OfPnt.hxx>
+
 class Geom_Axis2Placement;
 class AIS_InteractiveObject;
 class AIS_Axis;
@@ -46,26 +59,24 @@ class AIS_Trihedron;
 DEFINE_STANDARD_HANDLE(AIS_Trihedron, AIS_InteractiveObject)
 
 //! Create a selectable trihedron
-//! there are 4 modes of selection :
-//! mode = 0 to select trihedron   ,priority = 1
-//! mode = 1 to select its origin  ,priority = 5
-//! mode = 2 to select its axis    ,priority = 3
-//! mode = 3 to select its planes  ,priority = 2
-//! a trihedron has 1 origin, 3 axes and 3 planes.
+//! The trihedron includes 1 origin, 3 axes and 3 labels.
+//! Default text of labels are "X", "Y", "Z".
+//! Color of origin and any axis, color of arrows and labels may be changed.
+//! Visual presentation might be shown in two, shading and wireframe modes(wireframe by default)
+//! There are 4 modes of selection :
+//! mode = 0 to select trihedron,  priority = 1
+//! mode = 1 to select its origin, priority = 5
+//! mode = 2 to select its axis,   priority = 3
+//! mode = 3 to select its planes, priority = 2
 //! Warning
-//! For the presentation of trihedra, the default unit of
-//! length is the millimeter, and the default value for the
-//! representation of axes is 10. To modify these
+//! For the presentation of trihedron, the default unit of
+//! length is the millimetre, and the default value for the
+//! representation of the axes is 100. If you modify these
 //! dimensions, you must temporarily recover the Drawer.
 //! From inside it, you take the aspect in which the values
-//! for length are stocked. For trihedra, this is FirstAxisLength from 
-//! Prs3d_DatumAspect(). Change the
+//! for length are stocked. For trihedron, this is
+//! Prs3d_Drawer_LineAspect. You change the
 //! values inside this Aspect and recalculate the presentation.
-//! If you want to use extended selection modes, different than 0,
-//! you should take care of removing of the shapes from the interactive
-//! context that has been computed for selection; it might be necessary
-//! when you change selection mode. You can use methods Axis, Point,
-//! Plane to retrieve the shapes.
 class AIS_Trihedron : public AIS_InteractiveObject
 {
   DEFINE_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
@@ -75,18 +86,24 @@ public:
   //! Initializes a trihedron entity.
   Standard_EXPORT AIS_Trihedron(const Handle(Geom_Axis2Placement)& aComponent);
   
+  //! Sets Shading or Wireframe display mode, triangle or segment graphic group is used relatively.
+  Standard_EXPORT void SetDatumDisplayMode(const Prs3d_DatumMode& theMode) { myDisplayMode = theMode; }
+
+  //! Returns datum display mode.
+  Standard_EXPORT Prs3d_DatumMode DatumDisplayMode() const { return myDisplayMode; }
+
   //! Returns the right-handed coordinate system set in SetComponent.
-    const Handle(Geom_Axis2Placement)& Component() const;
-  
+  Standard_EXPORT const Handle(Geom_Axis2Placement)& Component() const { return myComponent; }
+
   //! Constructs the right-handed coordinate system aComponent.
-  Standard_EXPORT void SetComponent (const Handle(Geom_Axis2Placement)& aComponent);
-  
+  Standard_EXPORT void SetComponent (const Handle(Geom_Axis2Placement)& theComponent);
+
   //! Returns true if the trihedron object has a size other
-  //! than the default size of 10 mm. along each axis.
-    Standard_Boolean HasOwnSize() const;
-  
+  //! than the default size of 100 mm. along each axis.
+  Standard_Boolean HasOwnSize() const;
+
   //! Sets the size aValue for the trihedron object.
-  //! The default value is 10 mm.
+  //! The default value is 100 mm.
   Standard_EXPORT void SetSize (const Standard_Real aValue);
   
   //! Removes any non-default settings for size of this
@@ -95,43 +112,9 @@ public:
   
   Standard_EXPORT Standard_Real Size() const;
   
-  //! Returns the "XAxis".
-  Standard_EXPORT Handle(AIS_Axis) XAxis() const;
-  
-  //! Returns the "YAxis".
-  Standard_EXPORT Handle(AIS_Axis) YAxis() const;
-  
-  //! Returns the main Axis.
-  Standard_EXPORT Handle(AIS_Axis) Axis() const;
-  
-  //! Returns the origine.
-  Standard_EXPORT Handle(AIS_Point) Position() const;
-  
-  //! Returns the "XYPlane".
-  Standard_EXPORT Handle(AIS_Plane) XYPlane() const;
-  
-  //! Returns the "XZPlane".
-  Standard_EXPORT Handle(AIS_Plane) XZPlane() const;
-  
-  //! Returns the "YZPlane".
-  Standard_EXPORT Handle(AIS_Plane) YZPlane() const;
-  
-  //! connection to <aCtx> default drawer implies a recomputation
-  //! of SubObjects values.
-  Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx) Standard_OVERRIDE;
-  
   //! Returns true if the display mode selected, aMode, is
   //! valid for trihedron datums.
   Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
-  
-  //! Computes the presentation according to a point of view
-  //! given by <aProjector>.
-  //! To be Used when the associated degenerated Presentations
-  //! have been transformed by <aTrsf> which is not a Pure
-  //! Translation. The HLR Prs can't be deducted automatically
-  //! WARNING :<aTrsf> must be applied
-  //! to the object to display before computation  !!!
-  Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
 
   //! Returns index 3, selection of the planes XOY, YOZ, XOZ.
   Standard_EXPORT virtual Standard_Integer Signature() const Standard_OVERRIDE;
@@ -139,63 +122,154 @@ public:
   //! Indicates that the type of Interactive Object is datum.
   Standard_EXPORT virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE;
   
-  Standard_EXPORT void SetColor (const Quantity_NameOfColor aColor) Standard_OVERRIDE;
-  
-  //! Sets the color aColor for this trihedron object.
-  Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE;
-  
-  Standard_EXPORT void SetTextColor (const Quantity_NameOfColor aColor);
+  //! Sets the color theColor for this trihedron object, it changes color of axes.
+  Standard_EXPORT void SetColor (const Quantity_NameOfColor theColor) Standard_OVERRIDE;
+
+  //! Sets the color theColor for this trihedron object, it changes color of axes.
+  Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
   
+  //! Sets color of label of trihedron axes.
+  Standard_EXPORT void SetTextColor (const Quantity_NameOfColor theColor);
+
+  //! Sets color of label of trihedron axes.
+  Standard_EXPORT void SetTextColor (const Quantity_Color& theColor);
+
+  //! Returns true if trihedron has own text color
   Standard_EXPORT Standard_Boolean HasTextColor() const;
   
-  Standard_EXPORT Quantity_NameOfColor TextColor() const;
-  
-  Standard_EXPORT void SetArrowColor (const Quantity_NameOfColor aColor);
+  //! Returns trihedron text color
+  Standard_EXPORT Quantity_Color TextColor() const;
+
+  //! Sets color of arrow of trihedron axes. Used only in wireframe mode
+  Standard_EXPORT void SetArrowColor (const Quantity_NameOfColor theColor);
   
+  //! Sets color of arrow of trihedron axes. Used only in wireframe mode
+  Standard_EXPORT void SetArrowColor (const Quantity_Color& theColor);
+
+  //! Returns true if trihedron has own arrow color
   Standard_EXPORT Standard_Boolean HasArrowColor() const;
   
-  Standard_EXPORT Quantity_NameOfColor ArrowColor() const;
-  
-  //! Returns the four extremities of the trihedron from the
-  //! array of points, TheExtrem.
-  Standard_EXPORT void ExtremityPoints (TColgp_Array1OfPnt& TheExtrem) const;
+  //! Returns trihedron arrow color
+  Standard_EXPORT Quantity_Color ArrowColor() const;
   
   //! Removes the settings for color.
   Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
   
-  //! Removes the non-default settings for width set in SetWidth.
-  Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
+  //! Sets color of datum part: origin or some of trihedron axes.
+  //! If presentation is shading mode, this color is set for both sides of facing model
+  Standard_EXPORT void SetColor (const Prs3d_DatumParts& thePart,
+                                 const Quantity_Color& theColor);
+
+  //! Returns color of datum part: origin or some of trihedron axes.
+  Standard_EXPORT Quantity_Color Color (const Prs3d_DatumParts& thePart);
+
+  //! Sets color of origin.
+  //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
+  Standard_EXPORT void SetOriginColor (const Quantity_Color& theColor);
+
+  //! Sets color of x-axis.
+  //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
+  Standard_EXPORT void SetXAxisColor (const Quantity_Color& theColor);
+
+  //! Sets color of y-axis.
+  //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
+  Standard_EXPORT void SetYAxisColor (const Quantity_Color& theColor);
+
+  //! Sets color of z-axis.
+  //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
+  Standard_EXPORT void SetAxisColor (const Quantity_Color& theColor);
+
+  //! Sets priority of selection for owner of the given type
+  Standard_EXPORT void SetSelectionPriority(const Prs3d_DatumParts& thePart, const Standard_Integer thePriority)
+  {
+    mySelectionPriority.Bind(thePart, thePriority);
+  }
+
+  //! Sets priority of selection for owner of the given type
+  Standard_EXPORT Standard_Integer SelectionPriority(const Prs3d_DatumParts& thePart)
+  {
+    return mySelectionPriority.Find(thePart);
+  }
+
+  //! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis
+  Standard_EXPORT void SetLabel(const Prs3d_DatumParts& thePart, const TCollection_ExtendedString& thePriority)
+  {
+    myLabel.Bind(thePart, thePriority);
+  }
+
+  //! Returns text of axis. Parameter thePart should be XAxis, YAxis or ZAxis
+  Standard_EXPORT const TCollection_ExtendedString& Label(const Prs3d_DatumParts& thePart)
+  {
+    return myLabel.Find(thePart);
+  }
+
+public:
+
+  //! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
+  Standard_EXPORT virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE;
+
+  //! Method which clear all selected owners belonging
+  //! to this selectable object ( for fast presentation draw ).
+  Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
+
+  //! Method which draws selected owners ( for fast presentation draw ).
+  Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
+                                    const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE;
+
+  //! Method which hilight an owner belonging to
+  //! this selectable object  ( for fast presentation draw ).
+  Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
+                                                      const Handle(Graphic3d_HighlightStyle)& theStyle,
+                                                      const Handle(SelectMgr_EntityOwner)& theOwner);
 
 protected:
 
-  Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE;
+  //! Compute trihedron presentation.
+  Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+                                const Handle(Prs3d_Presentation)& thePrs,
+                                const Standard_Integer theMode) Standard_OVERRIDE;
 
-private:
+  //! This compute is unavailable for trihedron presentation.
+  void Compute (const Handle(Prs3d_Projector)& , const Handle(Prs3d_Presentation)& ) Standard_OVERRIDE {}
   
-  Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
-  
-  Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE;
-  
-  Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
-  
-  Standard_EXPORT void LoadSubObjects();
+  //! This compute is unavailable for trihedron presentation.
+  Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector,
+                                        const Handle(Geom_Transformation)& theTrsf,
+                                        const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE;
 
-protected:
+  //! Compute selection.
+  Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
+                                         const Standard_Integer theMode) Standard_OVERRIDE;
 
-  Handle(Geom_Axis2Placement) myComponent;
-  Handle(AIS_InteractiveObject) myShapes[7];
+  //! Computes presentation for display mode equal 1.
+  Standard_EXPORT void ComputePresentation (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+                                            const Handle(Prs3d_Presentation)& thePrs);
+
+  Standard_EXPORT void LoadRecomputable (const Standard_Integer TheMode);
+
+  //! Created a sensitive entity for the datum part that will be used in selection owner creation
+  Handle(SelectBasics_SensitiveEntity) CreateSensitiveEntity(const Prs3d_DatumParts& thePart,
+                                        const Handle(SelectBasics_EntityOwner)& theOwner) const;
+
+protected:
   Standard_Boolean myHasOwnSize;
   Standard_Boolean myHasOwnTextColor;
-  Quantity_NameOfColor myOwnTextColor;
   Standard_Boolean myHasOwnArrowColor;
-  Quantity_NameOfColor myOwnArrowColor;
-};
-
 
-#include <AIS_Trihedron.lxx>
+  Prs3d_DatumMode myDisplayMode;
+  Handle(Geom_Axis2Placement) myComponent;
 
+  NCollection_DataMap<Prs3d_DatumParts, Standard_Integer> mySelectionPriority;
+  NCollection_DataMap<Prs3d_DatumParts, TCollection_ExtendedString> myLabel;
 
+  NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_Group)> myPartToGroup;
+  NCollection_List<Prs3d_DatumParts> mySelectedParts;
 
+  Handle(Prs3d_PointAspect) myPointAspect;
 
+  Handle(Prs3d_ShadingAspect) myHighlightAspect; // internal container to set group selected
+  Handle(Prs3d_LineAspect) myHighlightLineAspect; // internal container to set group selected
+  Handle(Prs3d_PointAspect) myHighlightPointAspect; // internal container to set group selected
+};
 
 #endif // _AIS_Trihedron_HeaderFile
diff --git a/src/AIS/AIS_TrihedronOwner.cxx b/src/AIS/AIS_TrihedronOwner.cxx
new file mode 100644 (file)
index 0000000..5a60f0f
--- /dev/null
@@ -0,0 +1,66 @@
+// Created by: Ilya SEVRIKOV
+// Copyright (c) 2016 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 <AIS_TrihedronOwner.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT (AIS_TrihedronOwner, SelectMgr_EntityOwner)
+
+AIS_TrihedronOwner::AIS_TrihedronOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
+                                        const Prs3d_DatumParts thePart,
+                                        const Standard_Integer thePriority)
+: SelectMgr_EntityOwner (theSelObject, thePriority),
+  myDatumPart (thePart)
+{
+}
+
+//=======================================================================
+//function : HilightWithColor
+//purpose  :
+//=======================================================================
+void AIS_TrihedronOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
+                                           const Handle(Graphic3d_HighlightStyle)& theStyle,
+                                           const Standard_Integer /*theMode*/)
+{
+  Selectable()->HilightOwnerWithColor (thePM, theStyle, this);
+}
+
+//=======================================================================
+//function : IsHilighted
+//purpose  :
+//=======================================================================
+Standard_Boolean AIS_TrihedronOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
+                                                  const Standard_Integer theMode) const
+{
+  if (!HasSelectable())
+  {
+    return Standard_False;
+  }
+
+  return thePM->IsHighlighted (Selectable(), theMode);
+}
+
+//=======================================================================
+//function : Unhilight
+//purpose  :
+//=======================================================================
+void AIS_TrihedronOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
+                                    const Standard_Integer theMode)
+{
+  if (!HasSelectable())
+  {
+    return;
+  }
+
+  thePM->Unhighlight (Selectable());
+}
diff --git a/src/AIS/AIS_TrihedronOwner.hxx b/src/AIS/AIS_TrihedronOwner.hxx
new file mode 100644 (file)
index 0000000..7d452ce
--- /dev/null
@@ -0,0 +1,56 @@
+// Created by: Ilya SEVRIKOV
+// Copyright (c) 2016 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 _AIS_TrihedronOwner_HeaderFile
+#define _AIS_TrihedronOwner_HeaderFile
+
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_SelectableObject.hxx>
+#include <Prs3d_DatumParts.hxx>
+
+//! Entity owner for selection management of AIS_Trihedron object.
+class AIS_TrihedronOwner : public SelectMgr_EntityOwner
+{
+  DEFINE_STANDARD_RTTIEXT(AIS_TrihedronOwner, SelectMgr_EntityOwner)
+public:
+
+  //! Creates an owner of AIS_Trihedron object.
+  Standard_EXPORT AIS_TrihedronOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
+                                      const Prs3d_DatumParts theDatumPart,
+                                      const Standard_Integer thePriority);
+
+  Standard_EXPORT const Prs3d_DatumParts& DatumPart() const { return myDatumPart; }
+
+  //! Highlights selectable object's presentation.
+  Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
+                                                 const Handle(Graphic3d_HighlightStyle)& theStyle,
+                                                 const Standard_Integer theMode = 0);
+
+  //! Returns true if the presentation manager thePM
+  //! highlights selections corresponding to the selection mode aMode.
+  Standard_EXPORT Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
+                                                const Standard_Integer theMode) const Standard_OVERRIDE;
+
+  //! Removes highlighting from the owner of a detected
+  //! selectable object in the presentation manager thePM.
+  Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
+                                          const Standard_Integer theMode) Standard_OVERRIDE;
+
+protected:
+  Prs3d_DatumParts myDatumPart; //! Part of datum selected
+};
+
+DEFINE_STANDARD_HANDLE (AIS_TrihedronOwner, SelectMgr_EntityOwner)
+
+#endif // _AIS_TrihedronOwner_HeaderFile
index 4c878ef9ff08553225c4618c675b808505662bd0..90168284084ac8f53a65211b41281a9275081a08 100644 (file)
@@ -179,6 +179,8 @@ AIS_Triangulation.hxx
 AIS_Trihedron.cxx
 AIS_Trihedron.hxx
 AIS_Trihedron.lxx
+AIS_TrihedronOwner.cxx
+AIS_TrihedronOwner.hxx
 AIS_TypeFilter.cxx
 AIS_TypeFilter.hxx
 AIS_TypeOfAngle.hxx
index a982836f3d97ef1e06f9625e4cc53174be365e7f..7fc0bd1ebb34d7a3ed3bd04b86ab2098b6a0871e 100755 (executable)
@@ -8,6 +8,10 @@ Prs3d_BasicAspect.cxx
 Prs3d_BasicAspect.hxx
 Prs3d_DatumAspect.cxx
 Prs3d_DatumAspect.hxx
+Prs3d_DatumAttribute.hxx
+Prs3d_DatumAxes.hxx
+Prs3d_DatumMode.hxx
+Prs3d_DatumParts.hxx
 Prs3d_DimensionArrowOrientation.hxx
 Prs3d_DimensionAspect.cxx
 Prs3d_DimensionAspect.hxx
index 3c9d12bbc3d9508ea7177cb94e2075dbaefec493..b502e1a34a6f39f68001507e63bc504111778553 100644 (file)
 //purpose  : 
 //=======================================================================
 void Prs3d_Arrow::Draw(const Handle(Graphic3d_Group)& theGroup,
-                       const gp_Pnt& aLocation,
-                       const gp_Dir& aDirection,
-                       const Quantity_PlaneAngle anAngle,
-                       const Quantity_Length aLength)
+                       const gp_Pnt& theLocation,
+                       const gp_Dir& theDirection,
+                       const Quantity_PlaneAngle theAngle,
+                       const Quantity_Length theLength)
 {
-  Quantity_Length dx,dy,dz;  aDirection.Coord(dx,dy,dz);
+  Handle(Graphic3d_ArrayOfSegments) aPrimitives = Prs3d_Arrow::DrawSegments(theLocation,
+                                                  theDirection, theAngle, theLength, 15);
+  theGroup->AddPrimitiveArray (aPrimitives);
+}
+
+//=======================================================================
+//function : DrawSegments
+//purpose  : 
+//=======================================================================
+Handle(Graphic3d_ArrayOfSegments) Prs3d_Arrow::DrawSegments (const gp_Pnt& theLocation,
+                                                             const gp_Dir& theDirection,
+                                                             const Quantity_PlaneAngle theAngle,
+                                                             const Quantity_Length theLength,
+                                                             const int theNumberOfSegments)
+{
+  Handle(Graphic3d_ArrayOfSegments) aSegments = new Graphic3d_ArrayOfSegments(theNumberOfSegments+1,
+                                                                              2*(2*theNumberOfSegments));
+
+  Quantity_Length dx,dy,dz;  theDirection.Coord(dx,dy,dz);
 //
 // Point of the arrow:
-  Quantity_Length xo,yo,zo;  aLocation.Coord(xo,yo,zo);
+  Quantity_Length xo,yo,zo;  theLocation.Coord(xo,yo,zo);
 
 // Center of the base circle of the arrow:
-  Quantity_Length xc = xo - dx * aLength;
-  Quantity_Length yc = yo - dy * aLength;
-  Quantity_Length zc = zo - dz * aLength;
+  Quantity_Length xc = xo - dx * theLength;
+  Quantity_Length yc = yo - dy * theLength;
+  Quantity_Length zc = zo - dz * theLength;
 
 // Construction of i,j mark for the circle:
   Quantity_Length xn=0., yn=0., zn=0.;
@@ -63,32 +81,43 @@ void Prs3d_Arrow::Draw(const Handle(Graphic3d_Group)& theGroup,
   const Quantity_Length  yj = dz * xi - dx * zi;
   const Quantity_Length  zj = dx * yi - dy * xi;
 
-  const Standard_Integer NbPoints = 15;
+  const Standard_Integer NbPoints = theNumberOfSegments;
 
-  Handle(Graphic3d_ArrayOfSegments) aPrims1 = new Graphic3d_ArrayOfSegments(2*NbPoints);
-  Handle(Graphic3d_ArrayOfPolylines) aPrims2 = new Graphic3d_ArrayOfPolylines(NbPoints+1);
+  aSegments->AddVertex(theLocation);
 
   gp_Pnt p1;
-  const Standard_Real Tg=tan(anAngle);
+  const Standard_Real Tg=tan(theAngle);
 
   for (Standard_Integer i = 1; i <= NbPoints ; i++)
   {
-    const Standard_Real cosinus = cos ( 2 * M_PI / NbPoints * (i-1) );   
+    const Standard_Real cosinus = cos ( 2 * M_PI / NbPoints * (i-1) );
     const Standard_Real sinus   = sin ( 2 * M_PI / NbPoints * (i-1) );
 
-    const gp_Pnt pp(xc + (cosinus * xi + sinus * xj) * aLength * Tg,
-                    yc + (cosinus * yi + sinus * yj) * aLength * Tg,
-                    zc + (cosinus * zi + sinus * zj) * aLength * Tg);
+    const gp_Pnt pp(xc + (cosinus * xi + sinus * xj) * theLength * Tg,
+                    yc + (cosinus * yi + sinus * yj) * theLength * Tg,
+                    zc + (cosinus * zi + sinus * zj) * theLength * Tg);
 
-    aPrims1->AddVertex(aLocation);
-    aPrims1->AddVertex(pp);
-    if(i==1) p1 = pp;
-    aPrims2->AddVertex(pp);
+    aSegments->AddVertex(pp);
   }
-  aPrims2->AddVertex(p1);
 
-  theGroup->AddPrimitiveArray (aPrims1);
-  theGroup->AddPrimitiveArray (aPrims2);
+  int aNbVertices = NbPoints + 1;
+  int aFirstContourVertex = 2;
+  int anEdgeCount = 0;
+  for (Standard_Integer i = aFirstContourVertex; i <= aNbVertices ; i++) {
+    aSegments->AddEdge(1); // location vertex
+    aSegments->AddEdge(i);
+    anEdgeCount++;
+  }
+  aSegments->AddEdge(aNbVertices);
+  aSegments->AddEdge(aFirstContourVertex);
+  anEdgeCount++;
+
+  for (Standard_Integer i = aFirstContourVertex; i <= aNbVertices-1 ; i++) {
+    aSegments->AddEdge(i);
+    aSegments->AddEdge(i+1);
+    anEdgeCount++;
+  }
+  return aSegments;
 }
 
 // ============================================================================
index 21917b7203cfcab6451cd469df19b83e1a411302..b16c5f870f33d002f14b720f82b109fafec6c185 100644 (file)
@@ -20,6 +20,7 @@
 #include <Prs3d_Root.hxx>
 
 #include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
 #include <Quantity_PlaneAngle.hxx>
 #include <Quantity_Length.hxx>
 
@@ -46,6 +47,18 @@ public:
                                                                         const Standard_Real    theConeLength,
                                                                         const Standard_Integer theNbFacettes);
 
+  //! Defines the representation of the arrow as a container of segments.
+  //! @param theLocation  location of the arrow tip
+  //! @param theDirection direction of the arrow
+  //! @param theAngle     angle of opening of the arrow head
+  //! @param theLength    length of the arrow (from the tip)
+  //! @param theNumberOfSegments count of points on polyline where location is connected
+  Standard_EXPORT static Handle(Graphic3d_ArrayOfSegments) DrawSegments (const gp_Pnt& theLocation,
+                                                                const gp_Dir& theDirection,
+                                                                const Quantity_PlaneAngle theAngle,
+                                                                const Quantity_Length theLength,
+                                                                const int theNumberOfSegments);
+
   //! Defines the representation of the arrow.
   //! Note that this method does NOT assign any presentation aspects to the primitives group!
   //! @param theGroup     presentation group to add primitives
index 4736cf515b487d0acbf55d0f4e2121f1f0299fc8..5a1859b4967b1d586a79329985546c14cd7f5455 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
 
 #include <Prs3d_DatumAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Standard_Type.hxx>
+#include <Prs3d_ToolSphere.hxx>
+#include <Prs3d_Arrow.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect,Prs3d_BasicAspect)
+IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect)
 
+#define PATCH_TO_OCCT_710
+
+// =======================================================================
+// function : Prs3d_DatumAspect
+// purpose  :
+// =======================================================================
 Prs3d_DatumAspect::Prs3d_DatumAspect()
-: myDrawFirstAndSecondAxis (Standard_True),
-  myDrawThirdAxis (Standard_True),
-  myToDrawLabels (Standard_True),
-  myFirstAxisLength (10.0),
-  mySecondAxisLength (10.0),
-  myThirdAxisLength (10.0)
+: myAxes (Prs3d_DA_XYZAxis),
+  myToDrawLabels (Standard_True)
 {
-  myFirstAxisAspect = new Prs3d_LineAspect (Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID, 1.0);
-  mySecondAxisAspect = new Prs3d_LineAspect (Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID, 1.0);
-  myThirdAxisAspect = new Prs3d_LineAspect (Quantity_NOC_PEACHPUFF,Aspect_TOL_SOLID, 1.0);
-}
-
-Handle(Prs3d_LineAspect) Prs3d_DatumAspect::FirstAxisAspect() const {
-
-  return myFirstAxisAspect;
-}
-
-Handle(Prs3d_LineAspect) Prs3d_DatumAspect::SecondAxisAspect()  const {
-
-  return mySecondAxisAspect;
-}
-
-Handle(Prs3d_LineAspect) Prs3d_DatumAspect::ThirdAxisAspect()  const {
-
-  return myThirdAxisAspect;
-
-}
-Standard_Boolean Prs3d_DatumAspect::DrawFirstAndSecondAxis () const {
-
-  return myDrawFirstAndSecondAxis;
-
+  myAttributes.Bind(Prs3d_DA_XAxisLength, 10.0);
+  myAttributes.Bind(Prs3d_DA_YAxisLength, 10.0);
+  myAttributes.Bind(Prs3d_DA_ZAxisLength, 10.0);
+  myAttributes.Bind(Prs3d_DP_ShadingTubeRadiusPercent, 0.02);
+  myAttributes.Bind(Prs3d_DP_ShadingConeRadiusPercent, 0.04);
+  myAttributes.Bind(Prs3d_DP_ShadingConeLengthPercent, 0.1);
+  myAttributes.Bind(Prs3d_DP_ShadingOriginRadiusPercent, 0.015);
+  myAttributes.Bind(Prs3d_DP_ShadingNumberOfFacettes, 12.);
+
+  myDefaultColors.Bind(Prs3d_DP_Origin, Quantity_Color(Quantity_NOC_BLUE1));
+  myDefaultColors.Bind(Prs3d_DP_XAxis,  Quantity_Color(Quantity_NOC_RED));
+  myDefaultColors.Bind(Prs3d_DP_YAxis,  Quantity_Color(Quantity_NOC_GREEN));
+  myDefaultColors.Bind(Prs3d_DP_ZAxis,  Quantity_Color(Quantity_NOC_BLUE1));
+
+  Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
+  Standard_Real aWidth = 1.0;
+  for (int i = Prs3d_DP_Origin; i <= Prs3d_DP_XOZAxis; i++)
+  {
+    Prs3d_DatumParts aPart = (Prs3d_DatumParts)i;
+    Quantity_Color aDefaultColor;
+    if (!myDefaultColors.Find(aPart, aDefaultColor))
+      aDefaultColor = Quantity_NOC_PEACHPUFF;
+    if (aPart != Prs3d_DP_Origin) // origin point is used only in shading mode
+      myLineAspects.Bind(aPart, new Prs3d_LineAspect (aDefaultColor, aLineType, aWidth));
+    Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
+    aShadingAspect->SetColor(aDefaultColor);
+    myShadedAspects.Bind(aPart, aShadingAspect);
+  }
+  myTextAspect = new Prs3d_TextAspect ();
+#ifdef PATCH_TO_OCCT_710
+  myPointAspect = new Prs3d_PointAspect(Aspect_TOM_POINT/*Aspect_TOM_EMPTY*/,
+#else
+  myPointAspect = new Prs3d_PointAspect(Aspect_TOM_EMPTY,
+#endif
+                                        myDefaultColors.Find(Prs3d_DP_Origin), 1.0);
+  myArrowAspect = new Prs3d_ArrowAspect();
 }
 
-void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (const Standard_Boolean draw)
+Handle(Graphic3d_ArrayOfPrimitives) Prs3d_DatumAspect::ArrayOfPrimitives(
+                                                        const Prs3d_DatumParts& theDatumPart) const
 {
-  myDrawFirstAndSecondAxis = draw;
+  Handle(Graphic3d_ArrayOfPrimitives) anArray;
+  myPrimitives.Find(theDatumPart, anArray);
+  return anArray;
 }
 
-Standard_Boolean Prs3d_DatumAspect::DrawThirdAxis () const {
-
-  return myDrawThirdAxis;
-
-}
-
-void Prs3d_DatumAspect::SetDrawThirdAxis (const Standard_Boolean draw)
+void Prs3d_DatumAspect::UpdatePrimitives(const Prs3d_DatumMode& theMode, const gp_Pnt& theOrigin,
+                                         const gp_Dir& theXDirection,
+                                         const gp_Dir& theYDirection, const gp_Dir& theZDirection)
 {
-  myDrawThirdAxis = draw;
-}
-
-void Prs3d_DatumAspect::SetAxisLength (const Quantity_Length L1,
-                                      const Quantity_Length L2,
-                                      const Quantity_Length L3) {
-
-  myFirstAxisLength = L1;
-  mySecondAxisLength = L2;
-  myThirdAxisLength = L3;
+  myPrimitives.Clear();
+
+  NCollection_DataMap<Prs3d_DatumParts, gp_Dir> anAxisDirs;
+  anAxisDirs.Bind(Prs3d_DP_XAxis, theXDirection);
+  anAxisDirs.Bind(Prs3d_DP_YAxis, theYDirection);
+  anAxisDirs.Bind(Prs3d_DP_ZAxis, theZDirection);
+
+  NCollection_DataMap<Prs3d_DatumParts, gp_Pnt> anAxisPoints;
+  gp_XYZ anXYZOrigin = theOrigin.XYZ();
+  for (int i = Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++)
+  {
+    Prs3d_DatumParts aPart = (Prs3d_DatumParts)i;
+    anAxisPoints.Bind(aPart, gp_Pnt(anXYZOrigin + anAxisDirs.Find(aPart).XYZ()*AxisLength(aPart)));
+  }
+
+  if (theMode == Prs3d_DM_WireFrame)
+  {
+    // origin
+    Prs3d_DatumParts aPart = Prs3d_DP_Origin;
+    if (DrawDatumPart(aPart))
+    {
+      Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPoints(1);
+      aPrims->AddVertex(theOrigin);
+      myPrimitives.Bind(aPart, aPrims);
+    }
+    // axes
+    for (int i = Prs3d_DP_XAxis; i <= Prs3d_DP_ZAxis; i++)
+    {
+      Prs3d_DatumParts aPart = (Prs3d_DatumParts)i;
+      if (DrawDatumPart(aPart))
+      {
+        Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(2);
+        aPrims->AddVertex(theOrigin);
+        aPrims->AddVertex(anAxisPoints.Find(aPart));
+        myPrimitives.Bind(aPart, aPrims);
+      }
+
+      Prs3d_DatumParts anArrowPart = ArrowPartForAxis(aPart);
+      if (DrawDatumPart(anArrowPart))
+      {
+        myPrimitives.Bind(anArrowPart,
+          Prs3d_Arrow::DrawSegments(anAxisPoints.Find(aPart), anAxisDirs.Find(aPart),
+                          ArrowAspect()->Angle(),
+                          AxisLength(aPart)*Attribute(Prs3d_DP_ShadingConeLengthPercent),
+                          (Standard_Integer)Attribute(Prs3d_DP_ShadingNumberOfFacettes)));
+      }
+    }
+  }
+  else { // shading mode
+    // origin
+    Prs3d_DatumParts aPart = Prs3d_DP_Origin;
+    if (DrawDatumPart(aPart))
+    {
+      Standard_Real aSphereRadius = AxisLength(Prs3d_DP_XAxis)*
+                                    Attribute(Prs3d_DP_ShadingOriginRadiusPercent);
+      Standard_Integer aNbOfFacettes = (Standard_Integer)Attribute(Prs3d_DP_ShadingNumberOfFacettes);
+      gp_Trsf aSphereTransform;
+      aSphereTransform.SetTranslationPart(gp_Vec(gp_Pnt(0.0, 0.0, 0.0), theOrigin));
+      myPrimitives.Bind(aPart, Prs3d_ToolSphere::Create(aSphereRadius, aNbOfFacettes,
+                                                        aNbOfFacettes, aSphereTransform));
+    }
+    // axes
+    {
+      Standard_Integer aNbOfFacettes =
+                        (Standard_Integer)Attribute(Prs3d_DP_ShadingNumberOfFacettes);
+      Standard_Real aTubeRadiusPercent = Attribute(Prs3d_DP_ShadingTubeRadiusPercent);
+      Standard_Real aConeLengthPercent = Attribute(Prs3d_DP_ShadingConeLengthPercent);
+      Standard_Real aConeRadiusPercent = Attribute(Prs3d_DP_ShadingConeRadiusPercent);
+      for (Standard_Integer anAxisIter = Prs3d_DP_XAxis; anAxisIter <= Prs3d_DP_ZAxis;
+           ++anAxisIter)
+      {
+        Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
+        Prs3d_DatumParts anArrowPart = ArrowPartForAxis(aPart);
+        bool aDrawArrow = DrawDatumPart(anArrowPart);
+        Standard_Real anAxisLength = AxisLength(aPart);
+        gp_Ax1 anAxis (theOrigin, anAxisDirs.Find(aPart));
+
+        if (DrawDatumPart(aPart))
+          // draw cylinder
+          myPrimitives.Bind(aPart, Prs3d_Arrow::DrawShaded (anAxis, anAxisLength*aTubeRadiusPercent,
+                          aDrawArrow ? anAxisLength - anAxisLength*aConeLengthPercent: anAxisLength,
+                          0.0, 0.0, aNbOfFacettes));
+
+        // draw arrow
+        if (aDrawArrow)
+          myPrimitives.Bind(anArrowPart, Prs3d_Arrow::DrawShaded (anAxis,
+                            0.0, anAxisLength, anAxisLength*aConeRadiusPercent,
+                            anAxisLength*aConeLengthPercent, aNbOfFacettes));
+      }
+    }
+  }
+  // planes
+  for (Standard_Integer aPlaneIter = Prs3d_DP_XOYAxis; aPlaneIter <= Prs3d_DP_XOZAxis;
+       ++aPlaneIter)
+  {
+    Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPlaneIter;
+    if (!DrawDatumPart(aPart))
+      continue;
+
+    Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(4);
+    aPrims->AddVertex(theOrigin);
+
+    Prs3d_DatumParts aPart1, aPart2;
+    switch (aPart) {
+      case Prs3d_DP_XOYAxis: { aPart1 = Prs3d_DP_XAxis;     aPart2 = Prs3d_DP_YAxis; } break;
+      case Prs3d_DP_YOZAxis: { aPart1 = Prs3d_DP_YAxis;     aPart2 = Prs3d_DP_ZAxis; } break;
+      case Prs3d_DP_XOZAxis: { aPart1 = Prs3d_DP_XAxis;     aPart2 = Prs3d_DP_ZAxis; } break;
+      default: break;
+    }
+    aPrims->AddVertex(anAxisPoints.Find(aPart1));
+    aPrims->AddVertex(anAxisPoints.Find(aPart2));
+
+    aPrims->AddVertex(theOrigin);
+    myPrimitives.Bind(aPart, aPrims);
+  }
 }
 
-
-Quantity_Length Prs3d_DatumAspect::FirstAxisLength () const {
-
-  return myFirstAxisLength;
-
+void Prs3d_DatumAspect::SetDrawFirstAndSecondAxis (const Standard_Boolean theToDraw)
+{
+  if (theToDraw)
+    myAxes = Prs3d_DatumAxes(myAxes | Prs3d_DA_XAxis | Prs3d_DA_YAxis);
+  else
+    myAxes = Prs3d_DatumAxes(myAxes & !Prs3d_DA_XAxis & !Prs3d_DA_YAxis);
 }
 
-Quantity_Length Prs3d_DatumAspect::SecondAxisLength () const {
-
-  return mySecondAxisLength;
-
+void Prs3d_DatumAspect::SetDrawThirdAxis (const Standard_Boolean theToDraw)
+{
+  if (theToDraw)
+    myAxes = Prs3d_DatumAxes(myAxes | Prs3d_DA_ZAxis);
+  else
+    myAxes = Prs3d_DatumAxes(myAxes & !Prs3d_DA_ZAxis);
 }
 
-Quantity_Length Prs3d_DatumAspect::ThirdAxisLength () const {
-
-  return myThirdAxisLength;
-
+bool Prs3d_DatumAspect::DrawDatumPart(const Prs3d_DatumParts& thePart) const
+{
+  switch (thePart)
+  {
+    case Prs3d_DP_Origin:  return true;
+    case Prs3d_DP_XAxis:
+    case Prs3d_DP_XArrow:  return (myAxes & Prs3d_DA_XAxis) != 0;
+    case Prs3d_DP_YAxis:
+    case Prs3d_DP_YArrow:  return (myAxes & Prs3d_DA_YAxis) != 0;
+    case Prs3d_DP_ZAxis:
+    case Prs3d_DP_ZArrow:  return (myAxes & Prs3d_DA_ZAxis) != 0;
+    case Prs3d_DP_XOYAxis: return DrawDatumPart(Prs3d_DP_XAxis) && DrawDatumPart(Prs3d_DP_YAxis);
+    case Prs3d_DP_YOZAxis: return DrawDatumPart(Prs3d_DP_YAxis) && DrawDatumPart(Prs3d_DP_ZAxis);
+    case Prs3d_DP_XOZAxis: return DrawDatumPart(Prs3d_DP_XAxis) && DrawDatumPart(Prs3d_DP_ZAxis);
+    default: break;
+  }
+  return false;
 }
 
-//=======================================================================
-//function : SetToDrawLabels
-//purpose  : 
-//=======================================================================
-void Prs3d_DatumAspect::SetToDrawLabels (const Standard_Boolean theToDraw)
+Quantity_Length Prs3d_DatumAspect::AxisLength(const Prs3d_DatumParts& thePart) const
 {
-  myToDrawLabels = theToDraw;
+  switch (thePart)
+  {
+    case Prs3d_DP_XAxis: return (Quantity_Length)myAttributes.Find(Prs3d_DA_XAxisLength);
+    case Prs3d_DP_YAxis: return (Quantity_Length)myAttributes.Find(Prs3d_DA_YAxisLength);
+    case Prs3d_DP_ZAxis: return (Quantity_Length)myAttributes.Find(Prs3d_DA_ZAxisLength);
+    default: break;
+  }
+  return Quantity_Length(0);
 }
 
-//=======================================================================
-//function : ToDrawLabels
-//purpose  : 
-//=======================================================================
-Standard_Boolean Prs3d_DatumAspect::ToDrawLabels() const
+Prs3d_DatumParts Prs3d_DatumAspect::ArrowPartForAxis(const Prs3d_DatumParts& thePart) const
 {
-  return myToDrawLabels;
+  switch (thePart)
+  {
+    case Prs3d_DP_XAxis: return Prs3d_DP_XArrow;
+    case Prs3d_DP_YAxis: return Prs3d_DP_YArrow;
+    case Prs3d_DP_ZAxis: return Prs3d_DP_ZArrow;
+    default: break;
+  }
+  return Prs3d_DP_None;
 }
index 50f0b25f6574bf5bc5d9753809ac52f636bc5ea4..cf8bf2481692fa0e387cb0d3bb5c86d661600234 100644 (file)
 #ifndef _Prs3d_DatumAspect_HeaderFile
 #define _Prs3d_DatumAspect_HeaderFile
 
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
+#include <NCollection_DataMap.hxx>
+
+#include <Graphic3d_ArrayOfPrimitives.hxx>
 
-#include <Standard_Boolean.hxx>
-#include <Quantity_Length.hxx>
 #include <Prs3d_BasicAspect.hxx>
-#include <Standard_Real.hxx>
-class Prs3d_LineAspect;
+#include <Prs3d_DatumAttribute.hxx>
+#include <Prs3d_DatumParts.hxx>
+#include <Prs3d_DatumMode.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DatumAxes.hxx>
 
+#include <Quantity_Length.hxx>
 
-class Prs3d_DatumAspect;
-DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect)
+#include <Standard.hxx>
+#include <Standard_Boolean.hxx>
+#include <Standard_Real.hxx>
+#include <Standard_Type.hxx>
 
 //! A framework to define the display of datums.
 class Prs3d_DatumAspect : public Prs3d_BasicAspect
 {
-
+  DEFINE_STANDARD_RTTIEXT(Prs3d_DatumAspect, Prs3d_BasicAspect)
 public:
 
   //! An empty framework to define the display of datums.
   Standard_EXPORT Prs3d_DatumAspect();
-  
+
+  //! Returns the right-handed coordinate system set in SetComponent.
+  Standard_EXPORT const Handle(Prs3d_LineAspect)& LineAspect(const Prs3d_DatumParts& thePart) const
+  {
+    return myLineAspects.Find(thePart);
+  }
+
+  //! Returns the right-handed coordinate system set in SetComponent.
+  Standard_EXPORT const Handle(Prs3d_ShadingAspect)& ShadingAspect(const Prs3d_DatumParts& thePart) const
+  {
+    return myShadedAspects.Find(thePart);
+  }
+
+  //! Returns the right-handed coordinate system set in SetComponent.
+  Standard_EXPORT const Handle(Prs3d_TextAspect)& TextAspect() const
+  {
+    return myTextAspect;
+  }
+
+  //! Returns the point aspect of origin wireframe presentation
+  Standard_EXPORT const Handle(Prs3d_PointAspect)& PointAspect() const
+  {
+    return myPointAspect;
+  }
+
+  //! Returns the arrow aspect of presentation
+  Standard_EXPORT const Handle(Prs3d_ArrowAspect)& ArrowAspect() const
+  {
+    return myArrowAspect;
+  }
+
+  //! Returns primitives.
+  Handle(Graphic3d_ArrayOfPrimitives) ArrayOfPrimitives(const Prs3d_DatumParts& thePart) const;
+
+  //! Updates graphic groups for the current datum mode
+  //! Parameters of datum position and orientation
+  Standard_EXPORT void UpdatePrimitives(const Prs3d_DatumMode& theMode, const gp_Pnt& theOrigin,
+                                        const gp_Dir& theXDirection, const gp_Dir& theYDirection,
+                                        const gp_Dir& theZDirection);
+
   //! Returns the attributes for display of the first axis.
-  Standard_EXPORT Handle(Prs3d_LineAspect) FirstAxisAspect() const;
+  Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
+  const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects.Find(Prs3d_DP_XAxis); }
   
   //! Returns the attributes for display of the second axis.
-  Standard_EXPORT Handle(Prs3d_LineAspect) SecondAxisAspect() const;
+  Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
+  const Handle(Prs3d_LineAspect)& SecondAxisAspect() const { return myLineAspects.Find(Prs3d_DP_YAxis); }
   
   //! Returns the attributes for display of the third axis.
-  Standard_EXPORT Handle(Prs3d_LineAspect) ThirdAxisAspect() const;
+  Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
+  const Handle(Prs3d_LineAspect)& ThirdAxisAspect() const { return myLineAspects.Find(Prs3d_DP_ZAxis); }
   
   //! Sets the DrawFirstAndSecondAxis attributes to active.
-  Standard_EXPORT void SetDrawFirstAndSecondAxis (const Standard_Boolean draw);
+  Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
+  Standard_EXPORT void SetDrawFirstAndSecondAxis (const Standard_Boolean theToDraw);
   
   //! Returns true if the first and second axes can be drawn.
-  Standard_EXPORT Standard_Boolean DrawFirstAndSecondAxis() const;
-  
+  Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
+  Standard_Boolean DrawFirstAndSecondAxis() const { return (myAxes & Prs3d_DA_XAxis & Prs3d_DA_YAxis) != 0; }
+
   //! Sets the DrawThirdAxis attributes to active.
-  Standard_EXPORT void SetDrawThirdAxis (const Standard_Boolean draw);
+  Standard_DEPRECATED("This method is deprecated - SetDrawDatumAxes() should be called instead")
+  Standard_EXPORT void SetDrawThirdAxis (const Standard_Boolean theToDraw);
   
   //! Returns true if the third axis can be drawn.
-  Standard_EXPORT Standard_Boolean DrawThirdAxis() const;
-  
-  //! Sets the lengths L1, L2 and L3 of the three axes.
-  Standard_EXPORT void SetAxisLength (const Standard_Real L1, const Standard_Real L2, const Standard_Real L3);
-  
+  Standard_DEPRECATED("This method is deprecated - DatumAxes() should be called instead")
+  Standard_Boolean DrawThirdAxis() const { return (myAxes & Prs3d_DA_ZAxis) != 0; }
+
+  //! Returns true if the given part is used in axes of aspect
+  Standard_EXPORT Standard_Boolean DrawDatumPart(const Prs3d_DatumParts& thePart) const;
+
+  //! Sets the axes used in the datum aspect
+  void SetDrawDatumAxes(const Prs3d_DatumAxes& theType) { myAxes = theType; }
+
+  //! Returns axes used in the datum aspect
+  Prs3d_DatumAxes DatumAxes() const { return myAxes; }
+
+  //! Sets the attribute of the datum type
+  void SetAttribute(const Prs3d_DatumAttribute& theType, const Standard_Real& theValue)
+  {
+    myAttributes.Bind(theType, theValue);
+  }
+
+  //! Returns the attribute of the datum type
+  Standard_Real Attribute(const Prs3d_DatumAttribute& theType) const
+  {
+    return myAttributes.Find(theType);
+  }
+
+  //! Sets the lengths of the three axes.
+  void SetAxisLength (const Standard_Real theL1, const Standard_Real theL2, const Standard_Real theL3)
+  {
+    myAttributes.Bind(Prs3d_DA_XAxisLength, theL1);
+    myAttributes.Bind(Prs3d_DA_YAxisLength, theL2);
+    myAttributes.Bind(Prs3d_DA_ZAxisLength, theL3);
+  }
+
   //! Returns the length of the displayed first axis.
-  Standard_EXPORT Quantity_Length FirstAxisLength() const;
-  
+  Quantity_Length AxisLength(const Prs3d_DatumParts& thePart) const;
+
+  //! Returns the length of the displayed first axis.
+  Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
+  Quantity_Length FirstAxisLength() const { return (Quantity_Length)myAttributes.Find(Prs3d_DA_XAxisLength); }
+
   //! Returns the length of the displayed second axis.
-  Standard_EXPORT Quantity_Length SecondAxisLength() const;
+  Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
+  Quantity_Length SecondAxisLength() const { return (Quantity_Length)myAttributes.Find(Prs3d_DA_YAxisLength); }
   
   //! Returns the length of the displayed third axis.
-  Standard_EXPORT Quantity_Length ThirdAxisLength() const;
+  Standard_DEPRECATED("This method is deprecated - AxisLength() should be called instead")
+  Quantity_Length ThirdAxisLength() const { return (Quantity_Length)myAttributes.Find(Prs3d_DA_ZAxisLength); }
 
   //! Sets option to draw or not to draw text labels for axes
-  Standard_EXPORT void SetToDrawLabels (const Standard_Boolean theToDraw);
+  void SetToDrawLabels (const Standard_Boolean theToDraw) { myToDrawLabels = theToDraw; }
 
   //! @return true if axes labels are drawn
-  Standard_EXPORT Standard_Boolean ToDrawLabels() const;
+  Standard_Boolean ToDrawLabels() const { return myToDrawLabels; }
 
-  DEFINE_STANDARD_RTTIEXT(Prs3d_DatumAspect,Prs3d_BasicAspect)
+  //! Returns type of arrow for a type of axis
+  Prs3d_DatumParts ArrowPartForAxis(const Prs3d_DatumParts& thePart) const;
 
 private:
-
-  Handle(Prs3d_LineAspect) myFirstAxisAspect;
-  Handle(Prs3d_LineAspect) mySecondAxisAspect;
-  Handle(Prs3d_LineAspect) myThirdAxisAspect;
-  Standard_Boolean myDrawFirstAndSecondAxis;
-  Standard_Boolean myDrawThirdAxis;
+  Prs3d_DatumAxes myAxes;
   Standard_Boolean myToDrawLabels;
-  Quantity_Length myFirstAxisLength;
-  Quantity_Length mySecondAxisLength;
-  Quantity_Length myThirdAxisLength;
-
-};
-
-
+  NCollection_DataMap<Prs3d_DatumAttribute, Standard_Real> myAttributes;
 
+  NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_ArrayOfPrimitives)> myPrimitives;
+  NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_ShadingAspect)> myShadedAspects;
+  NCollection_DataMap<Prs3d_DatumParts, Handle(Prs3d_LineAspect)> myLineAspects;
 
+  NCollection_DataMap<Prs3d_DatumParts, Quantity_Color> myDefaultColors;
 
+  Handle(Prs3d_TextAspect) myTextAspect;
+  Handle(Prs3d_PointAspect) myPointAspect;
+  Handle(Prs3d_ArrowAspect) myArrowAspect;
+};
 
+DEFINE_STANDARD_HANDLE(Prs3d_DatumAspect, Prs3d_BasicAspect)
 
 #endif // _Prs3d_DatumAspect_HeaderFile
diff --git a/src/Prs3d/Prs3d_DatumAttribute.hxx b/src/Prs3d/Prs3d_DatumAttribute.hxx
new file mode 100644 (file)
index 0000000..d76e2ea
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (c) 2016 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 _Prs3d_DatumAttribute_HeaderFile
+#define _Prs3d_DatumAttribute_HeaderFile
+
+//! Enumeration defining a part of datum aspect, see Prs3d_Datum.
+enum Prs3d_DatumAttribute
+{
+  Prs3d_DA_XAxisLength = 0,
+  Prs3d_DA_YAxisLength,
+  Prs3d_DA_ZAxisLength,
+  Prs3d_DP_ShadingTubeRadiusPercent,
+  Prs3d_DP_ShadingConeRadiusPercent,
+  Prs3d_DP_ShadingConeLengthPercent,
+  Prs3d_DP_ShadingOriginRadiusPercent,
+  Prs3d_DP_ShadingNumberOfFacettes
+};
+
+#endif // _Prs3d_DatumAttribute_HeaderFile
diff --git a/src/Prs3d/Prs3d_DatumAxes.hxx b/src/Prs3d/Prs3d_DatumAxes.hxx
new file mode 100644 (file)
index 0000000..0266551
--- /dev/null
@@ -0,0 +1,34 @@
+// Copyright (c) 2016 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 _Prs3d_DatumAxes_HeaderFile
+#define _Prs3d_DatumAxes_HeaderFile
+
+//! Enumeration defining an axes used in datum aspect, see Prs3d_Datum.
+enum Prs3d_DatumAxes
+{
+  Prs3d_DA_XAxis      = 0x00000001,      //!< X axis of the datum
+  Prs3d_DA_YAxis      = 0x00000002,      //!< Y axis of the datum
+  Prs3d_DA_ZAxis      = 0x00000004,      //!< Z axis of the datum
+  Prs3d_DA_XYAxis     = Prs3d_DA_XAxis
+                      | Prs3d_DA_YAxis, //!< XOY 2D axes
+  Prs3d_DA_YZAxis     = Prs3d_DA_YAxis
+                      | Prs3d_DA_ZAxis, //!< YOZ 2D axes
+  Prs3d_DA_XZAxis     = Prs3d_DA_XAxis
+                      | Prs3d_DA_ZAxis, //!< XOZ 2D axes
+  Prs3d_DA_XYZAxis    = Prs3d_DA_XAxis
+                      | Prs3d_DA_YAxis
+                      | Prs3d_DA_ZAxis  //!< XYZ 3D axes
+};
+
+#endif // _Prs3d_DatumParts_HeaderFile
diff --git a/src/Prs3d/Prs3d_DatumMode.hxx b/src/Prs3d/Prs3d_DatumMode.hxx
new file mode 100644 (file)
index 0000000..45d40ca
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (c) 2016 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 _Prs3d_DatumMode_HeaderFile
+#define _Prs3d_DatumMode_HeaderFile
+
+//! Enumeration defining a mode of datum graphic presentation, see Prs3d_Datum.
+enum Prs3d_DatumMode
+{
+  Prs3d_DM_WireFrame = 0,
+  Prs3d_DM_Shaded
+};
+
+#endif // _Prs3d_DatumMode_HeaderFile
diff --git a/src/Prs3d/Prs3d_DatumParts.hxx b/src/Prs3d/Prs3d_DatumParts.hxx
new file mode 100644 (file)
index 0000000..e784a37
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (c) 2016 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 _Prs3d_DatumParts_HeaderFile
+#define _Prs3d_DatumParts_HeaderFile
+
+//! Enumeration defining a part of datum aspect, see Prs3d_Datum.
+enum Prs3d_DatumParts
+{
+  Prs3d_DP_Origin = 0,
+  Prs3d_DP_XAxis,
+  Prs3d_DP_YAxis,
+  Prs3d_DP_ZAxis,
+  Prs3d_DP_XArrow,
+  Prs3d_DP_YArrow,
+  Prs3d_DP_ZArrow,
+  Prs3d_DP_XOYAxis,
+  Prs3d_DP_YOZAxis,
+  Prs3d_DP_XOZAxis,
+  Prs3d_DP_None
+};
+
+#endif // _Prs3d_DatumParts_HeaderFile
index d4cd82be3551a001dd384836205d4a5796e2f3a5..61aa7bbf16cc6b3632ec8041ea6165b22c5dadff 100644 (file)
@@ -85,7 +85,7 @@ static int VTrihedronOrigins(Draw_Interpretor& di,
   }
 
   //get axis
-  Handle(AIS_Axis) XAxis = aTrih->XAxis();
+  /*Handle(AIS_Axis) XAxis = aTrih->XAxis();
   Handle(AIS_Axis) YAxis = aTrih->YAxis();
   Handle(AIS_Axis) ZAxis = aTrih->Axis();
 
@@ -110,7 +110,7 @@ static int VTrihedronOrigins(Draw_Interpretor& di,
   TheAISContext()->Display(XLine);
   TheAISContext()->Display(YLine);
   TheAISContext()->Display(ZLine);
-
+  */
   return 0;
 }