]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
The local selection restore for a feature vertex (it is checked on the line feature)
authornds <natalia.donis@opencascade.com>
Sat, 27 Dec 2014 07:59:51 +0000 (10:59 +0300)
committernds <natalia.donis@opencascade.com>
Sat, 27 Dec 2014 07:59:51 +0000 (10:59 +0300)
It blocks updateViewer() during move feature. The block, selection save, move, selection restore, unblock, updateViewer.
Also it corrects the XGUI_Workshop to do not deactivate current object if the current operation is edit.

src/PartSet/PartSet_SketcherMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_SelectionMgr.h
src/XGUI/XGUI_Workshop.cpp

index a2303017c011a052de5755bd21540c5a0e3e3dae..b4a44f8b3d7e7685e8c316fe925f647d0cf24417 100644 (file)
@@ -240,6 +240,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
       return; // No edit operation activated
 
     static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
+
     Handle(V3d_View) aView = theWnd->v3dView();
     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
     double aX, aY;
@@ -266,52 +267,51 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
         }
       }
     } else {
+      ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+      XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+      XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+      bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
+
       foreach(FeaturePtr aFeature, myEditingFeatures) {
         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
         if (aSketchFeature) { 
           // save the previous selection
-          /*ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
-          XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
-          XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
           QIntList anActivatedModes;
-
           ResultPtr aResult = aSketchFeature->firstResult();
 
           aDisplayer->getModesOfActivation(aResult, anActivatedModes);
-
+          
           std::list<AttributePtr> aSelectedAttributes;
-          getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes);*/
+          getCurrentSelection(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes);
           // save the previous selection: end
 
-
           aSketchFeature->move(dX, dY);
-          ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent);
-          /*
+
           // TODO: the selection restore should be after the AIS presentation is rebuilt
           Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
           Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-
           // restore the previous selection
-          aResult = aSketchFeature->firstResult();
-            aDisplayer->activate(aResult, anActivatedModes);
+          //aResult = aSketchFeature->firstResult();
+          //  aDisplayer->activate(aResult, anActivatedModes);
 
           SelectMgr_IndexedMapOfOwner anOwnersToSelect;
           getSelectionOwners(aSketchFeature, myCurrentSketch, aWorkshop, aSelectedAttributes,
                              anOwnersToSelect);
           
-          ModuleBase_IViewer* aViewer = aWorkshop->viewer();
-          Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
-          for (Standard_Integer i = 1, n = anOwnersToSelect.Extent(); i <= n; i++)
-            aContext->AddOrRemoveSelected(anOwnersToSelect(i), false); // SetSelected()
-
-          aContext->UpdateCurrentViewer();
-          // restore the previous selection*/
+          aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
+          // restore the previous selection
         }
+        ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent, true);
+        Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
       }
       // TODO: set here
-      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
-      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+      //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
+      //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+
+      //Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+      aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
+      aDisplayer->updateViewer();
     }
     myDragDone = true;
     myCurX = aX;
index bf5a0516545685504f0a484595aa68553c742673..56b16f90797e29f76273646b3cf18a8294fc0512 100644 (file)
@@ -68,6 +68,7 @@ void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfIn
 XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
   : myWorkshop(theWorkshop)
 {
+  enableUpdateViewer(true);
 }
 
 XGUI_Displayer::~XGUI_Displayer()
@@ -152,7 +153,7 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
     if (aCanBeShaded) {
       openLocalContext();
       activateObjects(myActiveSelectionModes);
-      myWorkshop->selector()->setSelectedOwners(aSelectedOwners);
+      myWorkshop->selector()->setSelectedOwners(aSelectedOwners, false);
     }
   }
   if (isUpdateViewer)
@@ -206,7 +207,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
     aContext->Redisplay(aAISIO, false);
     // Restore selection state after redisplay
     if (aToSelect) 
-      aContext->SetSelected(aAISIO);
+      aContext->SetSelected(aAISIO, false);
     if (isUpdateViewer)
       updateViewer();
   }
@@ -541,10 +542,19 @@ ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO)
   return aFeature;
 }
 
+bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
+{
+  bool aWasEnabled = myEnableUpdateViewer;
+
+  myEnableUpdateViewer = isEnabled;
+
+  return aWasEnabled;
+}
+
 void XGUI_Displayer::updateViewer()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull())
+  if (!aContext.IsNull() && myEnableUpdateViewer)
     aContext->UpdateCurrentViewer();
 }
 
index 176f52bc4ee7feda4b1cb925b983068ae9d2871a..154e4b0206178a826d45e694302ab64662820f94 100644 (file)
@@ -89,6 +89,13 @@ class XGUI_EXPORT XGUI_Displayer
 
   void removeFilters();
 
+  /**
+   * Sets a flag to the displayer whether the internal viewer can be updated by 
+   * the updateViewer method call. If it is not enabled, this method do nothing
+   * \param isEnabled a boolean value
+   */
+  bool enableUpdateViewer(const bool isEnabled);
+
   /// Updates the viewer
   void updateViewer();
 
@@ -188,6 +195,8 @@ class XGUI_EXPORT XGUI_Displayer
   //bool myUseExternalObjects;
   // Selection modes installed for external objects in local context
   QIntList myActiveSelectionModes;
+
+  bool myEnableUpdateViewer;  /// the enable update viewer flag
 };
 
 #endif
index 0cdaecf9ba94fdd830f7faefff3d03f0855f22c4..94c8462678eb96a170794f0b2afc83cf2dc4606c 100644 (file)
@@ -41,11 +41,12 @@ void XGUI_SelectionMgr::connectViewers()
 }
 
 //**************************************************************
-void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners)
+void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners,
+                                          bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   for  (Standard_Integer i = 1, n = theSelectedOwners.Extent(); i <= n; i++)  {
-    aContext->AddOrRemoveSelected(theSelectedOwners(i), false);
+    aContext->AddOrRemoveSelected(theSelectedOwners(i), isUpdateViewer);
   }
 }
 
index 8d74e0990a9357d1d05985cd3fb8f1b876a5e809..f1665a7465203a6e0670d7d3c19df7272e7810d3 100644 (file)
@@ -39,7 +39,9 @@ Q_OBJECT
 
   //! Selects the owners in the context.
   //! \param theSelectedOwners a container of owners
-  void setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners);
+  /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+  void setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners,
+                         bool isUpdateViewer);
 
 signals:
   //! Emited when selection in a one of viewers was changed
index d892ccf706b3d094dc831519622279f7b8e91d52..87d424125c0db2b5c4397f4760e73a6b5da6f351 100644 (file)
@@ -502,7 +502,8 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectU
         displayObject(aObj);  // In order to update presentation
         if (myOperationMgr->hasOperation()) {
           ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-          if (aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+          if (!aOperation->isEditOperation() &&
+              aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
             myDisplayer->deactivate(aObj);
         }
       } else {