Salome HOME
Merge remote-tracking branch 'remotes/origin/occ/compounds_processing'
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
index 68549f2b2674fabf33d7421c29081dc9fd89e618..00360a96defc2743b9c8edb97c976c1f76507aaa 100644 (file)
@@ -105,7 +105,11 @@ const int MOUSE_SENSITIVITY_IN_PIXEL = 10;
 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
 {
   // Get from null point
-  theAIS->DisplayedObjects(theList, true);
+#if OCC_VERSION_HEX < 0x070400
+       theAIS->DisplayedObjects(theList, true);
+#else
+       theAIS->DisplayedObjects(theList);
+#endif
 }
 
 QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QString(", "))
@@ -200,8 +204,6 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
     //bool isCustomized = customizeObject(theObject);
 
     int aDispMode = isShading? Shading : Wireframe;
-    if (isShading)
-      anAISIO->Attributes()->SetFaceBoundaryDraw( Standard_True );
     anAISIO->SetDisplayMode(aDispMode);
     aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed);
     #ifdef TINSPECTOR
@@ -293,45 +295,37 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
   }
 
   if (!aAISIO.IsNull()) {
-    // Check that the visualized shape is the same and the redisplay is not necessary
-    // Redisplay of AIS object leads to this object selection compute and the selection
-    // in the browser is lost
-    // this check is not necessary anymore because the selection store/restore is realized
-    // before and after the values modification.
-    // Moreother, this check avoids customize and redisplay presentation if the presentable
-    // parameter is changed.
-    //bool isEqualShapes = false;
-    //ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-    //if (aResult.get() != NULL) {
-    //  Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(aAISIO);
-    //  if (!aShapePrs.IsNull()) {
-    //    std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
-    //    if (aShapePtr.get()) {
-    //      const TopoDS_Shape& aOldShape = aShapePrs->Shape();
-    //      if (!aOldShape.IsNull())
-    //        isEqualShapes = aOldShape.IsEqual(aShapePtr->impl<TopoDS_Shape>());
-    //    }
-    //  }
-    //}
-    // Customization of presentation
-    //bool isCustomized = customizeObject(theObject);
-    #ifdef DEBUG_FEATURE_REDISPLAY
-      qDebug(QString("Redisplay: %1, isEqualShapes=%2").
-        arg(!isEqualShapes/* || isCustomized*/).arg(isEqualShapes)
-        .toStdString().c_str());
-    #endif
-    //if (!isEqualShapes/* || isCustomized*/) {
-    //  /// if shapes are equal and presentation are customized, selection should be restored
-    //  bool aNeedToRestoreSelection = isEqualShapes/* && isCustomized*/;
-    //  if (aNeedToRestoreSelection)
-      if (aAISObj.get() && myWorkshop->facesPanel())
-        myWorkshop->facesPanel()->customizeObject(theObject, aAISObj);
-
+    ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult.get()) {
+      // Set color
+      std::vector<int> aColor;
+      ModelAPI_Tools::getColor(aResult, aColor);
+      if (aColor.size() > 0) {
+        Quantity_Color
+          aCol(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB);
+        aAISIO->SetColor(aCol);
+      }
+      // Set deflection
+      double aDeflection = ModelAPI_Tools::getDeflection(aResult);
+      if ((aDeflection >= 0) && (aDeflection != aAISObj->getDeflection()))
+        aAISObj->setDeflection(aDeflection);
+
+      // Set transparency
+      double aTransparency = ModelAPI_Tools::getTransparency(aResult);
+      if ((aTransparency >= 0) && (aTransparency != aAISObj->getTransparency()))
+        aAISObj->setTransparency(aTransparency);
+
+      // Set Iso-Lines
+      Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO);
+      if (!aResPrs.IsNull())
+        aResPrs->updateIsoLines();
+    }
     myWorkshop->module()->storeSelection();
 
 #ifdef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
     myWorkshop->selector()->deselectPresentation(aAISIO);
 #endif
+
     if (aContext->IsDisplayed(aAISIO))
       aContext->Redisplay(aAISIO, false);
     else {
@@ -634,15 +628,16 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
     myContextId = aContext.get();
     if (!myWorkshop->selectionActivate()->isTrihedronActive())
       selectionActivate()->deactivateTrihedron(true);
-    aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0);
-    aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0);
+    // Do not modify default drawer. The same is done in ModuleBase_ResultPrs
+    //aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0);
+    //aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0);
 
     //Handle(AIS_Trihedron) aTrihedron = myWorkshop->viewer()->trihedron();
     //aTrihedron->getHighlightPointAspect()->SetScale(2.0);
     //aTrihedron->getHighlightPointAspect()->SetTypeOfMarker(Aspect_TOM_O_STAR);
 
     // Commented out according to discussion in bug #2825
-    //ModuleBase_IViewer::DefaultHighlightDrawer = aContext->HighlightStyle();
+    ModuleBase_IViewer::DefaultHighlightDrawer = aContext->HighlightStyle();
     //Handle(Prs3d_Drawer) aSelStyle = aContext->SelectionStyle();
     //double aDeflection =
     //  QString(ModelAPI_ResultConstruction::DEFAULT_DEFLECTION().c_str()).toDouble();
@@ -665,6 +660,8 @@ void XGUI_Displayer::setSelectionColor(const std::vector<int>& theColor)
                            theColor[1] / 255.,
                            theColor[2] / 255., Quantity_TOC_RGB);
     aContext->SelectionStyle()->SetColor(aQColor);
+    aContext->SelectionStyle()->PointAspect()->SetColor(aQColor);
+    aContext->SelectionStyle()->LineAspect()->SetColor(aQColor);
     aContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor(aQColor);
   }
 }