Salome HOME
Fix for registering parameters in command line mode
[modules/shaper.git] / src / ModuleBase / ModuleBase_ResultPrs.cpp
index 49e1dc691715737cf3f9029d4bb33e92c3f03358..d08ccb44dfa7f6d09443c529ce2bb28014ef1569 100755 (executable)
@@ -25,7 +25,7 @@
 #include <SelectMgr_SequenceOfOwner.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <SelectMgr_SelectionManager.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
+#include <StdPrs_WFShape.hxx>
 #include <StdSelect_BRepSelectionTool.hxx>
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_Selection.hxx>
 #include <Graphic3d_AspectMarker3d.hxx>
 #include <TopExp_Explorer.hxx>
 
-IMPLEMENT_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner);
 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner);
 
 //*******************************************************************************************
 
-IMPLEMENT_STANDARD_HANDLE(ModuleBase_ResultPrs, ViewerData_AISShape);
 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape);
 
 
 
-
-
 ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
   : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult), myAdditionalSelectionPriority(0)
 {
@@ -52,7 +48,7 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
   TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
   Set(aShape);
   Handle(Prs3d_Drawer) aDrawer = Attributes();
-  if (aDrawer->HasOwnPointAspect()) 
+  if (aDrawer->HasOwnPointAspect())
     aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS);
   else
     aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.));
@@ -69,9 +65,10 @@ void ModuleBase_ResultPrs::setAdditionalSelectionPriority(const int thePriority)
   myAdditionalSelectionPriority = thePriority;
 }
 
-void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
-                                   const Handle(Prs3d_Presentation)& thePresentation, 
-                                   const Standard_Integer theMode)
+void ModuleBase_ResultPrs::Compute(
+          const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+          const Handle(Prs3d_Presentation)& thePresentation,
+          const Standard_Integer theMode)
 {
   std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
   bool aReadyToDisplay = aShapePtr.get();
@@ -85,7 +82,8 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
 
   if (!aReadyToDisplay) {
-    Events_InfoMessage("ModuleBase_ResultPrs", "An empty AIS presentation: ModuleBase_ResultPrs").send();
+    Events_InfoMessage("ModuleBase_ResultPrs",
+                       "An empty AIS presentation: ModuleBase_ResultPrs").send();
     static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
     ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
   }
@@ -121,29 +119,32 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
         TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
         int aPriority = StdSelect_BRepSelectionTool::GetStandardPriority(aShape, TopAbs_COMPSOLID);
         /// It is important to have priority for the shape of comp solid result less than priority
-        /// for the presentation shape which is a sub-result. Reason is to select the sub-objects before: #1592
+        /// for the presentation shape which is a sub-result.
+        /// Reason is to select the sub-objects before: #1592
         aPriority = aPriority - 1;
         double aDeflection = Prs3d::GetDeflection(aShape, myDrawer);
 
         Handle(ModuleBase_BRepOwner) aOwner = new ModuleBase_BRepOwner(aShape, aPriority);
-        StdSelect_BRepSelectionTool::ComputeSensitive(aShape, aOwner, aSelection, 
+        StdSelect_BRepSelectionTool::ComputeSensitive(aShape, aOwner, aSelection,
           aDeflection, myDrawer->HLRAngle(), 9, 500);
 
         for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
           Handle(SelectMgr_EntityOwner) anOwner =
-            Handle(SelectMgr_EntityOwner)::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId());
+            Handle(SelectMgr_EntityOwner)
+            ::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId());
           anOwner->Set(this);
         }
         return;
       }
     }
     //AIS_Shape::ComputeSelection(aSelection, 0);
-  } 
+  }
   AIS_Shape::ComputeSelection(aSelection, aMode);
 
   if (myAdditionalSelectionPriority > 0) {
     for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
-      Handle(SelectBasics_EntityOwner) aBasicsOwner = aSelection->Sensitive()->BaseSensitive()->OwnerId();
+      Handle(SelectBasics_EntityOwner) aBasicsOwner =
+        aSelection->Sensitive()->BaseSensitive()->OwnerId();
       if (!aBasicsOwner.IsNull())
         aBasicsOwner->Set(aBasicsOwner->Priority() + myAdditionalSelectionPriority);
     }
@@ -169,7 +170,7 @@ void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection
   }
 }
 
-void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
+void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
                                            const SelectMgr_SequenceOfOwner& theOwners)
 {
   Handle(SelectMgr_EntityOwner) anOwner;
@@ -177,25 +178,26 @@ void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManag
   for (int i = 1; i <= theOwners.Length(); i++) {
     anOwner = theOwners.Value(i);
     aCompOwner = Handle(ModuleBase_BRepOwner)::DownCast(anOwner);
-    if (aCompOwner.IsNull())
-      anOwner->Hilight(thePM);
+    if (aCompOwner.IsNull()) {
+      thePM->Color(anOwner->Selectable(), GetContext()->SelectionStyle());
+    }
     else {
       TopoDS_Shape aShape = aCompOwner->Shape();
       Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM );
       aSelectionPrs->Clear();
 
-      StdPrs_WFDeflectionShape::Add(aSelectionPrs, aShape, myDrawer);
+      StdPrs_WFShape::Add(aSelectionPrs, aShape, myDrawer);
 
       aSelectionPrs->SetDisplayPriority(9);
-      aSelectionPrs->Highlight(Aspect_TOHM_COLOR, aSelectionPrs->HighlightColor());
+      aSelectionPrs->Highlight(GetContext()->SelectionStyle());
       aSelectionPrs->Display();
-      thePM->Highlight(this);
+      thePM->Color(this, GetContext()->SelectionStyle());
     }
   }
 }
-  
-void ModuleBase_ResultPrs::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
-                                                 const Quantity_NameOfColor theColor, 
+
+void ModuleBase_ResultPrs::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
+                                                 const Handle(Graphic3d_HighlightStyle)& theStyle,
                                                  const Handle(SelectMgr_EntityOwner)& theOwner)
 {
   Handle(StdSelect_BRepOwner) aOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
@@ -204,13 +206,13 @@ void ModuleBase_ResultPrs::HilightOwnerWithColor(const Handle(PrsMgr_Presentatio
 
   TopoDS_Shape aShape = aOwner->Shape();
   if (!aShape.IsNull()) {
-    thePM->Color(this, theColor);
+    thePM->Color(this, theStyle);
 
     Handle( Prs3d_Presentation ) aHilightPrs = GetHilightPresentation( thePM );
     aHilightPrs->Clear();
 
-    StdPrs_WFDeflectionShape::Add(aHilightPrs, aShape, myDrawer);
-    aHilightPrs->Highlight(Aspect_TOHM_COLOR, theColor);
+    StdPrs_WFShape::Add(aHilightPrs, aShape, myDrawer);
+    aHilightPrs->Highlight(theStyle);
 
     if (thePM->IsImmediateModeOn())
       thePM->AddToImmediateList(aHilightPrs);