Salome HOME
Merge branch 'Dev_1.2.0' of newgeom:newgeom into Dev_1.2.0
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 26 May 2015 15:01:22 +0000 (18:01 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 26 May 2015 15:01:22 +0000 (18:01 +0300)
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_Workshop.cpp

index 1f759feb5b70a88fd16ccb21f74633a50c27ca23..28f25fd2940d9caf5e67685732cd637830a7b2e4 100644 (file)
@@ -148,3 +148,9 @@ void ModuleBase_IModule::editFeature(FeaturePtr theFeature)
   anOperation->setFeature(theFeature);
   sendOperation(anOperation);
 }
+
+bool ModuleBase_IModule::canActivateSelection(const ObjectPtr& theObject) const
+{
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  return !(aOperation && (!aOperation->isEditOperation()) && aOperation->hasObject(theObject));
+}
\ No newline at end of file
index 1b3081dd976012fba8772e83870c09b9500b76f7..6ae486f6c72c7d8c8170be9716eb25773d2ef48e 100644 (file)
@@ -117,6 +117,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param theObject a model object\r
   virtual bool canDisplayObject(const ObjectPtr& theObject) const;\r
 \r
+  /// Returns true if selection for the object can be activate.\r
+  /// By default a result or feature of the current operation can not be activated\r
+  /// \param theObject a model object\r
+  virtual bool canActivateSelection(const ObjectPtr& theObject) const;\r
+\r
   /// Reacts to the delete action in module\r
   /// \returns true if the action is processed\r
   virtual bool deleteObjects() { return false; };\r
index fd7e7707991bcdb668d8d9bf98bba9c5f5d7139a..1fef7d318df56218a33259c935498e3c42dcbea8 100644 (file)
@@ -331,7 +331,7 @@ void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theMode
   }
 }
 
-void XGUI_Displayer::activateObjects(const QIntList& theModes)
+void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList)
 {
 #ifdef DEBUG_ACTIVATE
   qDebug(QString("activate all features: theModes: %2, myActiveSelectionModes: %3").
@@ -356,15 +356,24 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes)
   //aContext->UseDisplayedObjects();
   //myUseExternalObjects = true;
 
+  Handle(AIS_InteractiveObject) anAISIO;
   AIS_ListOfInteractive aPrsList;
-  ::displayedObjects(aContext, aPrsList);
+  if (theObjList.isEmpty())
+    ::displayedObjects(aContext, aPrsList);
+  else {
+    foreach(ObjectPtr aObj, theObjList) {
+      if (myResult2AISObjectMap.contains(aObj))
+        aPrsList.Append(myResult2AISObjectMap[aObj]->impl<Handle(AIS_InteractiveObject)>());
+    }
+  }
 
   Handle(AIS_Trihedron) aTrihedron;
   AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
-  Handle(AIS_InteractiveObject) anAISIO;
   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
     anAISIO = aLIt.Value();
-    activate(anAISIO, myActiveSelectionModes);
+    aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
+    if (aTrihedron.IsNull())
+      activate(anAISIO, myActiveSelectionModes);
   }
 }
 
@@ -833,26 +842,22 @@ void XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
   if (aTColModes.IsEmpty())
     aContext->Load(theIO, -1, true);
 
-  Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
-  //Deactivate trihedron which can be activated in local selector
-  if (aTrihedron.IsNull()) {
     //aContext->Load(anAISIO, -1, true);
     // In order to clear active modes list
-    if (theModes.size() == 0) {
-      //aContext->Load(anAISIO, 0, true);
-      aContext->Activate(theIO);
+  if (theModes.size() == 0) {
+    //aContext->Load(anAISIO, 0, true);
+    aContext->Activate(theIO);
 #ifdef DEBUG_ACTIVATE
-      qDebug("activate in all modes");
+    qDebug("activate in all modes");
 #endif
-    } else {
-      foreach(int aMode, theModes) {
-        //aContext->Load(anAISIO, aMode, true);
-        if (!aModesActivatedForIO.contains(aMode)) {
-          aContext->Activate(theIO, aMode);
+  } else {
+    foreach(int aMode, theModes) {
+      //aContext->Load(anAISIO, aMode, true);
+      if (!aModesActivatedForIO.contains(aMode)) {
+        aContext->Activate(theIO, aMode);
 #ifdef DEBUG_ACTIVATE
-          qDebug(QString("activate: %1").arg(aMode).toStdString().c_str());
+        qDebug(QString("activate: %1").arg(aMode).toStdString().c_str());
 #endif
-        }
       }
     }
   }
index cf35c008302d2284daa9baae23e467d37da95e93..29cf7482a91e49acb0ab4160a0b496d8adf64b49 100644 (file)
@@ -169,7 +169,8 @@ class XGUI_EXPORT XGUI_Displayer: public QObject
 
   /// Activates in local context displayed outside of the context.
   /// \param theModes - modes on which it has to be activated (can be empty)
-  void activateObjects(const QIntList& theModes);
+  /// \param theObjList - list of objects which has to be activated. Can be empty. In this case all displayed objects will be used.
+  void activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList = QObjectPtrList());
 
   /// Activates in local context displayed outside of the context.
   void deactivateObjects();
index 1405ba5d620fb6d7da7997fa9a59a24b169597aa..e92c772c6ac88a81ed27aa25daa382791d3721ba 100644 (file)
@@ -61,6 +61,18 @@ ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
 }
 
 
+QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjList) const
+{
+  QObjectPtrList aActiveOPbjects;
+  ModuleBase_IModule* aModule = myWorkshop->module();
+  // Activate objects only which can be activated
+  foreach (ObjectPtr aObj, theObjList) {
+    if (aModule->canActivateSelection(aObj))
+      aActiveOPbjects.append(aObj);
+  }
+  return aActiveOPbjects;
+}
+
 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
 {
   XGUI_Displayer* aDisp = myWorkshop->displayer();
@@ -75,7 +87,7 @@ void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
     else
       aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
   }
-  aDisp->activateObjects(aModes);
+  aDisp->activateObjects(aModes, activeObjects(aDisp->displayedObjects()));
   //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
   //aDisp->addSelectionFilter(myDocumentShapeFilter);
 }
@@ -93,7 +105,7 @@ void XGUI_ModuleConnector::deactivateSubShapesSelection()
   // 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);
+  aDisp->activateObjects(aModes, activeObjects(aDisp->displayedObjects()));
   // The document limitation selection has to be only during operation
   //aDisp->removeSelectionFilter(myDocumentShapeFilter);
   //aDisp->closeLocalContexts(false);
index d2348e101018e6672460988ccb5113075127ae02..23398a0f9192bc00e7f92aab6f8df0afe5b278db 100644 (file)
@@ -69,6 +69,8 @@ Q_OBJECT
   XGUI_Workshop* workshop() const { return myWorkshop; }
 
 private:
+  QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;
+
   /// Reference to workshop
   XGUI_Workshop* myWorkshop;
 
index dfa21b5da8fd497137d746a0f453fa2ff352b00c..646a41bfa8c070f70a6f183e566d8db0c59b2cb1 100644 (file)
@@ -468,17 +468,19 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectU
         // of redisplay is called. This modification is made in order to have the line is updated
         // by creation of a horizontal constraint on the line by preselection
         myDisplayer->redisplay(aObj, false);
-        if (myOperationMgr->hasOperation()) {
-          ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-          if (!aOperation->isEditOperation() &&
-              aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+        //if (myOperationMgr->hasOperation()) {
+        //  ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+        //  if (!aOperation->isEditOperation() &&
+        //      aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+        if (!myModule->canActivateSelection(aObj)) {
+          if (myDisplayer->isActive(aObj))
             myDisplayer->deactivate(aObj);
         }
       } else { // display object if the current operation has it
         if (displayObject(aObj)) {
-          ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-          if (aOperation && aOperation->hasObject(aObj)) {
-            ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+          //ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+          //if (aOperation && aOperation->hasObject(aObj)) {
+          if (!myModule->canActivateSelection(aObj)) {
             #ifdef DEBUG_FEATURE_REDISPLAY
               QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
               qDebug(QString("  display object = %1").arg(anObjInfo).toStdString().c_str());