Salome HOME
Remove unnecessary variable
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
index 344704de0f915a8595b2ded14b51530768a5c8c6..ef89e2bcef6ca0e804b0e0b2e8383f5400f3e689 100644 (file)
@@ -96,7 +96,7 @@ QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QS
 }
 
 XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
-  : myWorkshop(theWorkshop)
+  : myWorkshop(theWorkshop), myEnableUpdateViewer(true), myNeedUpdate(false)
 {
   enableUpdateViewer(true);
   myCustomPrs = std::shared_ptr<GeomAPI_ICustomPrs>(new XGUI_CustomPrs());
@@ -363,8 +363,9 @@ void XGUI_Displayer::deactivateObjects(const QObjectPtrList& theObjList,
   for (; anIt != aLast; anIt++) {
     deactivate(*anIt, false);
   }
-  if (theUpdateViewer)
-    updateViewer();
+  //VSV It seems that there is no necessity to update viewer on deactivation
+  //if (theUpdateViewer)
+  //  updateViewer();
 }
 
 void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theModes)
@@ -439,12 +440,15 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrL
   }
 
   AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
+  bool isActivationChanged = false;
   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
     anAISIO = aLIt.Value();
-    activate(anAISIO, myActiveSelectionModes, false);
+    if (activate(anAISIO, myActiveSelectionModes, false))
+      isActivationChanged = true;
   }
-  if (theUpdateViewer)
-    updateViewer();
+  // VSV It seems that there is no necessity to update viewer on activation
+  //if (theUpdateViewer && isActivationChanged)
+  //  updateViewer();
 }
 
 bool XGUI_Displayer::isActive(ObjectPtr theObject) const
@@ -685,7 +689,10 @@ bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
   bool aWasEnabled = myEnableUpdateViewer;
 
   myEnableUpdateViewer = isEnabled;
-
+  if (myNeedUpdate && myEnableUpdateViewer) {
+    updateViewer();
+    myNeedUpdate = false;
+  }
   return aWasEnabled;
 }
 
@@ -695,6 +702,8 @@ void XGUI_Displayer::updateViewer() const
   if (!aContext.IsNull() && myEnableUpdateViewer) {
     myWorkshop->viewer()->Zfitall();
     aContext->UpdateCurrentViewer();
+  } else {
+    myNeedUpdate = true;
   }
 }
 
@@ -830,18 +839,19 @@ XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) con
 void XGUI_Displayer::deactivateSelectionFilters()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull() && !myAndFilter.IsNull()) {
+  if (!myAndFilter.IsNull()) {
     bool aFound = false;
-    const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
-    SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
-    for (; anIt.More() && !aFound; anIt.Next()) {
-      Handle(SelectMgr_Filter) aFilter = anIt.Value();
-      aFound = aFilter == myAndFilter;
-    }
-    if (aFound) {
-      aContext->RemoveFilter(myAndFilter);
-      myAndFilter.Nullify();
+    if (!aContext.IsNull()) {
+      const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
+      SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
+      for (; anIt.More() && !aFound; anIt.Next()) {
+        Handle(SelectMgr_Filter) aFilter = anIt.Value();
+        aFound = aFilter == myAndFilter;
+      }
+      if (aFound)
+        aContext->RemoveFilter(myAndFilter);
     }
+    myAndFilter.Nullify();
   }
 }
 
@@ -939,14 +949,15 @@ bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
   return ::canBeShaded(anAIS);
 }
 
-void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
+bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
                               const QIntList& theModes,
                               const bool theUpdateViewer) const
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (aContext.IsNull() || theIO.IsNull())
-    return;
-
+    return false;
+  
+  bool isActivationChanged = false;
   // deactivate object in all modes, which are not in the list of activation
   // It seems that after the IO deactivation the selected state of the IO's owners
   // is modified in OCC(version: 6.8.0) and the selection of the object later is lost.
@@ -973,9 +984,12 @@ void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
   }
   if (isDeactivated) {
     // the selection from the previous activation modes should be cleared manually (#26172)
+    theIO->ClearSelected();
     aContext->LocalContext()->ClearOutdatedSelection(theIO, true);
-    if (theUpdateViewer)
-      updateViewer();
+    // For performance issues
+    //if (theUpdateViewer)
+    //  updateViewer();
+    isActivationChanged = true;
   }
 
   // loading the interactive object allowing the decomposition
@@ -997,10 +1011,12 @@ void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
         //aContext->Load(anAISIO, aMode, true);
         if (!aModesActivatedForIO.contains(aMode)) {
           activateAIS(theIO, aMode, theUpdateViewer);
+          isActivationChanged = true;
         }
       }
     }
   }
+  return isActivationChanged;
 }
 
 bool XGUI_Displayer::customizeObject(ObjectPtr theObject)