Salome HOME
Issue #2998: Add help description for automatic creation of constraints
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
index 30f94ef70929ad744c19856f8bc2b01c9a579453..ccad93e0e2325f4d0a776c4c8a9044ebb5b3af85 100644 (file)
@@ -38,7 +38,6 @@
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_ResultField.h>
 
 #include <ModuleBase_BRepOwner.h>
 #include <ModuleBase_IModule.h>
@@ -158,24 +157,23 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
       }
       anAIS = aPrs->getAISObject(anAIS);
     } else {
-      ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-      if (aResult.get() != NULL) {
-        anAIS = createPresentation(aResult);
-        isShading = true;
-      }
-      else {
-        FieldStepPtr aStep =
-          std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(theObject);
-        if (aStep) {
-          GeomShapePtr aShapePtr = aStep->field()->shape();
+      Handle(AIS_InteractiveObject) anAISPrs =
+        myWorkshop->module()->createPresentation(theObject);
+      if (anAISPrs.IsNull()) {
+        ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+        if (aResult.get() != NULL) {
+          std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
           if (aShapePtr.get() != NULL) {
-            Handle(AIS_InteractiveObject) anAISPrs = new ModuleBase_ResultPrs(aStep);
-            anAIS = AISObjectPtr(new GeomAPI_AISObject());
-            anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
-            isShading = true;
+             anAISPrs = new ModuleBase_ResultPrs(aResult);
           }
         }
       }
+      Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
+      if (!aShapePrs.IsNull())
+        ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*)aShapePrs.get());
+      anAIS = AISObjectPtr(new GeomAPI_AISObject());
+      anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
+      isShading = true;
     }
     if (anAIS)
       aDisplayed = display(theObject, anAIS, isShading, theUpdateViewer);
@@ -184,30 +182,6 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
 }
 
 
-//**************************************************************
-AISObjectPtr XGUI_Displayer::createPresentation(const ResultPtr& theResult) const
-{
-  AISObjectPtr anAIS;
-  if (theResult.get() != NULL) {
-    std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
-    if (aShapePtr.get() != NULL) {
-      anAIS = AISObjectPtr(new GeomAPI_AISObject());
-      Handle(AIS_InteractiveObject) anAISPrs =
-        myWorkshop->module()->createPresentation(theResult);
-      if (anAISPrs.IsNull())
-        anAISPrs = new ModuleBase_ResultPrs(theResult);
-      else {
-        Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISPrs);
-        if (!aShapePrs.IsNull())
-          ModuleBase_Tools::setPointBallHighlighting((AIS_Shape*)aShapePrs.get());
-      }
-      anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
-    }
-  }
-  return anAIS;
-}
-
-
 //**************************************************************
 bool canBeShaded(Handle(AIS_InteractiveObject) theAIS, ModuleBase_IModule* theModule)
 {
@@ -396,11 +370,16 @@ void XGUI_Displayer::redisplayObjects()
   // redisplay objects visualized in the viewer
   static Events_ID EVENT_DISP = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
   static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
-  QObjectPtrList aDisplayed = myWorkshop->displayer()->displayedObjects();
+  QObjectPtrList aDisplayed = displayedObjects();
   QObjectPtrList::const_iterator anIt = aDisplayed.begin(), aLast = aDisplayed.end();
   for (; anIt != aLast; anIt++) {
     aECreator->sendUpdated(*anIt, EVENT_DISP);
   }
+  XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
+  if (aViewer->isColorScaleVisible()) {
+    aViewer->setupColorScale();
+    aViewer->setColorScaleShown(true);
+  }
   Events_Loop::loop()->flush(EVENT_DISP);
 }
 
@@ -639,12 +618,6 @@ bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
   return aWasEnabled;
 }
 
-//**************************************************************
-bool XGUI_Displayer::isUpdateEnabled() const
-{
-  return myViewerBlockedRecursiveCount == 0;
-}
-
 //**************************************************************
 void XGUI_Displayer::updateViewer() const
 {
@@ -1082,8 +1055,6 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const
     if (getCallBack()) getCallBack()->Remove(aTrihedron);
     #endif
   }
-
-  updateViewer();
 }
 
 //**************************************************************
@@ -1123,17 +1094,21 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th
                                              ::Iterator aShapeIt(theShapesToBeSelected);
       for (; aShapeIt.More(); aShapeIt.Next()) {
         const TopoDS_Shape& aParameterShape = aShapeIt.Key();
-        // isSame should be used here as it does not check orientation of shapes
-        // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is
-        // different for Edges shapes in model shape and owner even if this is the same shape
-        if (aParameterShape.IsSame(aShape)) {
+        // In case of compound we cannot rely on simple comparison method.
+        // If the compound is generated by Group feature then this compound is alwais new.
+        // So, we have to compare content of these compounds
+
+          // isSame should be used here as it does not check orientation of shapes
+          // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is
+          // different for Edges shapes in model shape and owner even if this is the same shape
+        if (ModuleBase_Tools::isSameShape(aParameterShape, aShape)) {
           Handle(AIS_InteractiveObject) anOwnerPresentation =
-                            Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
+            Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
           NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations =
-                                      theShapesToBeSelected.Find(aParameterShape);
+            theShapesToBeSelected.Find(aParameterShape);
           if (aPresentations.Contains(anOwnerPresentation)) {
             theContext->AddOrRemoveSelected(anOwner, Standard_False);
-            anOwner->SetSelected (Standard_True);
+            anOwner->SetSelected(Standard_True);
             // collect selected presentations to do not select them if compsolid is selected
             if (!aSelectedPresentations.Contains(anOwnerPresentation))
               aSelectedPresentations.Add(anOwnerPresentation);