Salome HOME
The selection problem with an object deactivate:
authornds <natalia.donis@opencascade.com>
Wed, 29 Apr 2015 19:55:34 +0000 (22:55 +0300)
committernds <natalia.donis@opencascade.com>
Wed, 29 Apr 2015 19:55:34 +0000 (22:55 +0300)
Scenario: select a line, start distance constraint operation, activate a point widget, the object is not selected in the viewer, but click 'Esc', the first control is filled by this object.

src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_Workshop.cpp

index 7ba5cfe1e09693d931618d6f73c189f268fdc02e..65a5c5a5a8b66b5b4541c54693604c673f24e928 100644 (file)
@@ -120,6 +120,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \returns true if the action is processed\r
   virtual bool deleteObjects() { return false; };\r
 \r
+  /// Returns a list of modes, where the AIS objects should be activated\r
+  /// \param theModes a list of modes\r
+  virtual void activeSelectionModes(QIntList& theModes) {};\r
+\r
 public slots:\r
   /// Called on call of command corresponded to a feature\r
   void onFeatureTriggered();\r
index 684d940715c9131a473a9219a4620dbca23ba301..662e3d1bcaaf23c675f86a30b026ce7b0f934d3f 100644 (file)
@@ -285,6 +285,13 @@ bool PartSet_Module::addViewerItems(QMenu* theMenu, const QMap<QString, QAction*
   return myMenuMgr->addViewerItems(theMenu, theStdActions);
 }
 
+void PartSet_Module::activeSelectionModes(QIntList& theModes)
+{
+  theModes.clear();
+  if (mySketchMgr->activeSketch().get())
+    PartSet_SketcherMgr::sketchSelectionModes(theModes);
+}
+
 bool PartSet_Module::isMouseOverWindow()
 {
   return mySketchMgr->isMouseOverWindow();
index 3120798c6c598a82c67686bb6d17e1085477da01..9ba109a65eb3cf28b060765cdf98c4920f1c9fda 100644 (file)
@@ -103,6 +103,10 @@ public:
   /// \return true if items are added and there is no necessity to provide standard menu
   virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
 
+  /// Returns a list of modes, where the AIS objects should be activated
+  /// \param theModes a list of modes
+  virtual void activeSelectionModes(QIntList& theModes);
+
   /// Returns whether the mouse enter the viewer's window
   /// \return true if items are added and there is no necessity to provide standard menu
   bool isMouseOverWindow();
index 5e527a8816cdac4e871b98d32bca0d487a3344b5..7b942563a5195394d8cf443491cc1d8e7ac2b512 100644 (file)
@@ -628,6 +628,16 @@ const QStringList& PartSet_SketcherMgr::constraintsIdList()
   return aIds;
 }
 
+void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
+{
+  theModes.clear();
+
+  theModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
+  theModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
+  theModes.append(SketcherPrs_Tools::Sel_Constraint);
+  theModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
+  theModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
+}
 
 bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
 {
@@ -1079,13 +1089,8 @@ void PartSet_SketcherMgr::activateObjectsInSketchMode(const bool isActive)
   XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
 
   QIntList aModes;
-  if (isActive) {
-    aModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
-    aModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
-    aModes.append(SketcherPrs_Tools::Sel_Constraint);
-    aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
-    aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
-  }
+  if (isActive)
+    sketchSelectionModes(aModes);
   aDisplayer->activateObjects(aModes);
 }
 
index f302a589e77685ea4a831a212623d8721b248f04..f82f450f5a16270fd21229e04b53a7566aaa0bf1 100644 (file)
@@ -162,6 +162,10 @@ public:
   /// Returns list of strings which contains id's of constraints operations
   static const QStringList& constraintsIdList();
 
+  /// Returns a list of modes, where the AIS objects should be activated
+  /// \param theModes a list of modes
+  static void sketchSelectionModes(QIntList& theModes);
+
 public slots:
   /// Process sketch plane selected event
   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
index dd564aba08280ce8f647e08a38eadbda7f37a1d4..486f23a50f038a6acf2e503d56758b2a212a0912 100644 (file)
@@ -47,6 +47,7 @@ const int MOUSE_SENSITIVITY_IN_PIXEL = 10;  ///< defines the local context mouse
 //#define DEBUG_ACTIVATE
 //#define DEBUG_FEATURE_REDISPLAY
 //#define DEBUG_SELECTION_FILTERS
+//#define DEBUG_USE_CLEAR_OUTDATED_SELECTION
 
 // Workaround for bug #25637
 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
@@ -272,6 +273,10 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject)
     AISObjectPtr anObj = myResult2AISObjectMap[theObject];
     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
     aContext->Deactivate(anAIS);
+#ifdef DEBUG_USE_CLEAR_OUTDATED_SELECTION
+    aContext->LocalContext()->ClearOutdatedSelection(anAIS, true);
+    updateViewer();
+#endif
   }
 }
 
@@ -388,6 +393,10 @@ void XGUI_Displayer::deactivateObjects()
   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
     anAISIO = aLIt.Value();
     aContext->Deactivate(anAISIO);
+#ifdef DEBUG_USE_CLEAR_OUTDATED_SELECTION
+    aContext->LocalContext()->ClearOutdatedSelection(anAISIO, true);
+    updateViewer();
+#endif
   }
 }
 
@@ -588,7 +597,7 @@ bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
   return aWasEnabled;
 }
 
-void XGUI_Displayer::updateViewer()
+void XGUI_Displayer::updateViewer() const
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (!aContext.IsNull() && myEnableUpdateViewer)
@@ -788,6 +797,7 @@ void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
   aContext->ActivatedModes(theIO, aTColModes);
   TColStd_ListIteratorOfListOfInteger itr( aTColModes );
   QIntList aModesActivatedForIO;
+  //bool isDeactivated = false;
   for (; itr.More(); itr.Next() ) {
     Standard_Integer aMode = itr.Value();
     if (!theModes.contains(aMode)) {
@@ -795,6 +805,7 @@ void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
       qDebug(QString("deactivate: %1").arg(aMode).toStdString().c_str());
 #endif
       aContext->Deactivate(theIO, aMode);
+      //isDeactivated = true;
     }
     else {
       aModesActivatedForIO.append(aMode);
@@ -803,6 +814,12 @@ void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
 #endif
     }
   }
+#ifdef DEBUG_USE_CLEAR_OUTDATED_SELECTION
+  if (isDeactivated) {
+    aContext->LocalContext()->ClearOutdatedSelection(theIO, true);
+    updateViewer();
+  }
+#endif
   // loading the interactive object allowing the decomposition
   if (aTColModes.IsEmpty())
     aContext->Load(theIO, -1, true);
index 89f693d522c1c58bd8fa21dc955326260fea6498..5ea7f07137efdb6dcf924512711dc4fab1fbe59f 100644 (file)
@@ -126,7 +126,7 @@ class XGUI_EXPORT XGUI_Displayer: public QObject
   bool enableUpdateViewer(const bool isEnabled);
 
   /// Updates the viewer
-  void updateViewer();
+  void updateViewer() const;
 
   /// Searches the interactive object by feature
   /// \param theObject the object or presentable feature
index d3a057beb5111d865a7f09285d809bc1d5460c20..b83edb4c8d158e4233a4368875f232d6234ee576 100644 (file)
@@ -13,6 +13,8 @@
 #include "XGUI_Displayer.h"
 #include "XGUI_PropertyPanel.h"
 
+#include <ModuleBase_IModule.h>
+
 #include <AIS_Shape.hxx>
 
 
@@ -83,6 +85,14 @@ void XGUI_ModuleConnector::deactivateSubShapesSelection()
   XGUI_Displayer* aDisp = myWorkshop->displayer();
   // Clear selection modes
   QIntList aModes;
+  // TODO: check on OCC6.9.0
+  // the module current active modes should not be deactivated in order to save the objects selected
+  // the deactivate object in the mode of selection leads to the object is deselected in the viewer.
+  // But, in OCC6.8.0 this deselection does not happened automatically. It is necessary to call
+  // ClearOutdatedSelection, but this method has an error in the realization, which should be fixed in
+  // the OCC6.9.0 release. Moreother, it is possible that ClearOutdatedSelection will be called inside
+  // Deactivate method of AIS_InteractiveContext. In this case, we need not call it.
+  module()->activeSelectionModes(aModes);
   aDisp->activateObjects(aModes);
   // The document limitation selection has to be only during operation
   //aDisp->removeSelectionFilter(myDocumentShapeFilter);
index b32a80bbc0e064937b76d170d54d2a7348681c0e..387594ec062f8d5e3c8642b4417c489a2f6a3883 100644 (file)
@@ -675,11 +675,20 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   //myDisplayer->activateObjects(aModes);
   myModule->operationStopped(theOperation);
 
-  if (myOperationMgr->operationsCount() == 0) {
+  // if the operation is nested, do not deactivate objects
+  //if (myOperationMgr->operationsCount() == 0) {
     // Activate selection mode for all objects
-    QIntList aModes;
-    myDisplayer->activateObjects(aModes);
-  }
+  QIntList aModes;
+  // TODO: check on OCC_6.9.0
+  // the module current active modes should not be deactivated in order to save the objects selected
+  // the deactivate object in the mode of selection leads to the object is deselected in the viewer.
+  // But, in OCC_6.8.0 this deselection does not happened automatically. It is necessary to call
+  // ClearOutdatedSelection, but this method has an error in the realization, which should be fixed in
+  // the OCC_6.9.0 release. Moreother, it is possible that ClearOutdatedSelection will be called inside
+  // Deactivate method of AIS_InteractiveContext. In this case, we need not call it.
+  module()->activeSelectionModes(aModes);
+  myDisplayer->activateObjects(aModes);
+  //}
 }