]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2123: Unexpected Sketcher behavior when creating Coincidence
authornds <nds@opencascade.com>
Tue, 11 Apr 2017 10:10:15 +0000 (13:10 +0300)
committernds <nds@opencascade.com>
Tue, 11 Apr 2017 10:10:34 +0000 (13:10 +0300)
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/SketchPlugin/SketchPlugin_Sketch.cpp

index fe5bff496eceae0bfe665b358a8a558a6590a0d7..ca6c1b1bc234dec3a25fd0bdcfc333319b33c24e 100644 (file)
@@ -86,6 +86,11 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId,
   QList<ModuleBase_ViewerPrsPtr> aPreSelected =
     aSelection->getSelected(ModuleBase_ISelection::AllControls);
 
+  ModuleBase_OperationFeature* aCurOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                         (myWorkshop->currentOperation());
+  QString anOperationKind = aCurOperation ? aCurOperation->getDescription()->operationId() : "";
+
+
   bool isCommitted;
   if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
     return;
@@ -101,7 +106,7 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId,
     if (aMessage.get()) {
       setReentrantPreSelection(aMessage);
     }
-    else
+    else if (anOperationKind == theCmdId) // restore of selection only if the kind is the same
       aFOperation->initSelection(aPreSelected);
 
     workshop()->processLaunchOperation(aFOperation);
index f0be4ae9e58002dba8ddb0082c929506c0d2b1a0..10042d488110d7d6187be6958fd8d3ee765b9c95 100644 (file)
@@ -386,7 +386,15 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
 #ifdef DEBUG_WIDGET_INSTANCE
     qDebug("ModuleBase_ModelWidget::updateObject");
 #endif
-    ModuleBase_Tools::flushUpdated(theObject);
+    ModuleBase_Tools::blockUpdateViewer(true);
+    // Fix the problem of not previewed results of constraints applied. Flush Create/Delete
+    // (for the sketch result) to start processing of the sketch in the solver.
+    // TODO: these flushes should be moved in a separate method provided by Model
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+
+    ModuleBase_Tools::blockUpdateViewer(false);
     emit objectUpdated();
   }
 }
index 963b53c6277340cb7dfe12bca8885b1f639c712e..2b14c2506f8da83192a8b6872d3fbe5887087039 100755 (executable)
@@ -207,7 +207,7 @@ void PartSet_Module::storeSelection()
   // cash is used only to restore selection, so it should be filled in storeSelection and
   // after applying immediatelly cleared in restoreSelection
   myCurrentSelection.clear();
-  sketchMgr()->storeSelection(false, myCurrentSelection);
+  sketchMgr()->storeSelection(PartSet_SketcherMgr::ST_SelectType, myCurrentSelection);
 }
 
 void PartSet_Module::restoreSelection()
index 774fc1fcbe014e098bdfb13977457cec375d5fe8..2a5ed0d372cb0ff46d3d80f2a414f910b57e4c3a 100755 (executable)
@@ -276,7 +276,7 @@ void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
       myModule->sketchReentranceMgr()->isInternalEditActive())
     return;
   // it is necessary to save current selection in order to restore it after the values are modifed
-  storeSelection(false);
+  storeSelection(ST_SelectAndHighlightType);
 
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
@@ -358,7 +358,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
     ModuleBase_ISelection* aSelect = aWorkshop->selection();
 
     bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-    storeSelection(!aHasShift, myCurrentSelection);
+    storeSelection(aHasShift ? ST_SelectAndHighlightType : ST_HighlightType, myCurrentSelection);
 
     if (myCurrentSelection.empty()) {
       if (isSketchOpe && (!isSketcher))
@@ -1529,7 +1529,7 @@ void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
   if (aResults.size() > 0) {
     ResultPtr aFirstResult = theFeature->firstResult();
     if (aFirstResult.get() && aFirstResult->shape().get()) {
-      const TopoDS_Shape& aFirstShape = aFirstResult->shape()->impl<TopoDS_Shape>();
+      TopoDS_Shape aFirstShape = aFirstResult->shape()->impl<TopoDS_Shape>();
       isSameShape = aFirstShape.IsEqual(anInfo.myFirstResultShape);
     }
   }
@@ -1700,7 +1700,7 @@ void PartSet_SketcherMgr::visualizeFeature(const FeaturePtr& theFeature,
     Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
 }
 
-void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly,
+void PartSet_SketcherMgr::storeSelection(const SelectionType theType,
                         PartSet_SketcherMgr::FeatureToSelectionMap& theCurrentSelection)
 {
   if (!myCurrentSketch.get())
@@ -1708,10 +1708,13 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly,
 
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   ModuleBase_ISelection* aSelect = aWorkshop->selection();
-  QList<ModuleBase_ViewerPrsPtr> aStoredPrs = aSelect->getHighlighted();
+  QList<ModuleBase_ViewerPrsPtr> aStoredPrs;
+
+  if (theType == ST_HighlightType || theType == ST_SelectAndHighlightType)
+    aStoredPrs = aSelect->getHighlighted();
 
   QList<FeaturePtr> aFeatureList;
-  if (!theHighlightedOnly) {
+  if (theType == ST_SelectAndHighlightType || theType == ST_SelectType) {
     QList<ModuleBase_ViewerPrsPtr> aSelected = aSelect->getSelected(
                                                               ModuleBase_ISelection::AllControls);
     aStoredPrs.append(aSelected);
index 5fb1931fdddd1906234e344882fdb88262c90ccc..648ed988b7acbba533f3fa8b6598a25ad07ec602 100644 (file)
@@ -231,12 +231,19 @@ public:
   /// \return boolean value
   bool isObjectOfSketch(const ObjectPtr& theObject) const;
 
+  /// Enumeration for selection mode used
+  enum SelectionType {
+    ST_HighlightType, /// Only highlighted objects
+    ST_SelectType, /// Only selected objects
+    ST_SelectAndHighlightType /// Both, highlighted and selected objects
+  };
+
   /// Saves the current selection in the viewer into an internal container
   /// It obtains the selected attributes.
   /// The highlighted objects can be processes as the selected ones
   /// \param theHighlightedOnly a boolean flag
   /// \param theCurrentSelection a container filled by the current selection
-  void storeSelection(const bool theHighlightedOnly, FeatureToSelectionMap& theCurrentSelection);
+  void storeSelection(const SelectionType theType, FeatureToSelectionMap& theCurrentSelection);
 
   /// Restores previously saved selection state
   /// \param theCurrentSelection a container filled by the current selection
index 91fddccd708bade99ca94b5ec1bc8b51653dec3c..d1deff5364ac1e1f9369a33889243ee28db68c1b 100755 (executable)
@@ -140,10 +140,6 @@ std::shared_ptr<ModelAPI_Feature> SketchPlugin_Sketch::addFeature(std::string th
    // set as current also after it becomes sub to set correctly enabled for other sketch subs
   document()->setCurrentFeature(aNew, false);
 
-  static Events_Loop* aLoop = Events_Loop::loop();
-  static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED);
-  aLoop->flush(aDeleteEvent);
-
   return aNew;
 }