]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #171: Deactivate selection of object of current operation
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 29 Sep 2014 13:55:10 +0000 (17:55 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 29 Sep 2014 13:55:10 +0000 (17:55 +0400)
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Workshop.cpp

index 68e8b68bdf16e7720c362e0da0c88edb7d904462..6ac7aca9a875a3d77fe8e5e1aaac85302ec4e01e 100644 (file)
@@ -204,6 +204,22 @@ void XGUI_Displayer::activate(ObjectPtr theObject)
   }
 }
 
+bool XGUI_Displayer::isActive(ObjectPtr theObject) const
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (aContext.IsNull())
+    return false;
+  if (!isVisible(theObject))
+    return false;
+    
+  boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap.at(theObject);
+  Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+
+  TColStd_ListOfInteger aModes;
+  aContext->ActivatedModes(anAIS, aModes);
+  return aModes.Extent() > 0;
+}
+
 void XGUI_Displayer::stopSelection(const QList<ObjectPtr>& theResults, const bool isStop,
                                    const bool isUpdateViewer)
 {
index 6337a4096857145b008f1d419057e251d438db97..9552fd6d365460379d36709319878e0b83dd3716 100644 (file)
@@ -124,10 +124,15 @@ class XGUI_EXPORT XGUI_Displayer
   /// \return feature the feature or NULL if it not visualized
   ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const;
 
+  /// Deactivates the given object (not allow selection)
   void deactivate(ObjectPtr theFeature);
 
+  /// Activates the given object (it can be selected)
   void activate(ObjectPtr theFeature);
 
+  /// Returns true if the given object can be selected
+  bool isActive(ObjectPtr theObject) const;
+
   /// Activates in local context displayed outside of the context.
   /// \param theModes - selection modes to activate
   /// \param theFilter - filter for selection
index def3e45ace97b9d180c94a64c64582f8daa74d9a..d36f3f6de5e4f35ced929d47535c22390da8f60e 100644 (file)
@@ -414,14 +414,24 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const boost::shared_ptr<ModelAPI_Objec
     if (!aObj->data() || !aObj->data()->isValid() || aObj->document()->isConcealed(aObj))
       myDisplayer->erase(aObj, false);
     else {
-      if (myDisplayer->isVisible(aObj))  // TODO VSV: Correction sketch drawing
+      if (myDisplayer->isVisible(aObj))  {
         myDisplayer->display(aObj, false);  // In order to update presentation
-      else {
+        if (myOperationMgr->hasOperation()) {
+          ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+          if (!aOperation->hasObject(aObj))
+            if (!myDisplayer->isActive(aObj))
+              myDisplayer->activate(aObj);
+        }
+      } else {
         if (myOperationMgr->hasOperation()) {
           ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
           // Display only current operation results if operation has preview
-          if (aOperation->hasObject(aObj) && aOperation->hasPreview())
+          if (aOperation->hasObject(aObj) && aOperation->hasPreview()) {
             myDisplayer->display(aObj, false);
+            // Deactivate object of current operation from selection
+            if (myDisplayer->isActive(aObj))
+              myDisplayer->deactivate(aObj);
+          }
         }
       }
     }