Salome HOME
Issue #2998: Add help description for automatic creation of constraints
[modules/shaper.git] / src / XGUI / XGUI_SelectionActivate.cpp
index 9b8d2a5d579a5b7dcb8e5df8bd9c32738b4ae317..10b1d84e5711f80688e74293a18063176e00669a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "XGUI_SelectionActivate.h"
 //#define DEBUG_ACTIVATE_AIS
 //#define DEBUG_DEACTIVATE_AIS
 
+#ifdef TINSPECTOR
+#include <inspector/VInspectorAPI_CallBack.hxx>
+#endif
+
 #define CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
 
 //**************************************************************
@@ -89,7 +92,7 @@ void XGUI_SelectionActivate::updateSelectionModes()
     break;
     case FacesPanel: {
       XGUI_Tools::workshop(myWorkshop)->facesPanel()->selectionModes(aModes);
-      myWorkshop->module()->customSubShapesSelectionModes(aModes); // avoid wire selection
+      myWorkshop->module()->moduleSelectionModes(-1/*all modes*/, aModes);
     }
     break;
     default: break;
@@ -102,17 +105,24 @@ void XGUI_SelectionActivate::updateSelectionFilters()
 {
   SelectMgr_ListOfFilter aSelectionFilters;
   switch (activeSelectionPlace()) {
-  case Workshop:
-    XGUI_Tools::workshop(myWorkshop)->selectionFilters(aSelectionFilters);
+    case Workshop: {
+      QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters();
+      myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters);
+    }
     break;
     case PropertyPanel: {
+      QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters();
+
       ModuleBase_ModelWidget* anActiveWidget = myWorkshop->module()->activeWidget();
-      getSelectionFilters(anActiveWidget, aSelectionFilters);
+      if (anActiveWidget)
+        anActiveWidget->selectionFilters(aModuleSelectionFilters, aSelectionFilters);
+      myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters);
     }
     break;
     case FacesPanel: {
-      //XGUI_Tools::workshop(myWorkshop)->selectionFilters(aSelectionFilters);
       XGUI_Tools::workshop(myWorkshop)->facesPanel()->selectionFilters(aSelectionFilters);
+      //QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters();
+      //myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters);
     }
     break;
     default: break;
@@ -136,20 +146,6 @@ void XGUI_SelectionActivate::activateSelectionFilters
   }
 }
 
-//**************************************************************
-void XGUI_SelectionActivate::activateSelectionAndFilters(ModuleBase_ModelWidget* theWidget)
-{
-  // activate selection modes
-  QIntList aModes;
-  getSelectionModes(theWidget, aModes);
-  activateObjects(aModes, getDisplayer()->displayedObjects(), true);
-
-  // activate selection filters
-  SelectMgr_ListOfFilter aSelectionFilters;
-  getSelectionFilters(theWidget, aSelectionFilters);
-  activateSelectionFilters(aSelectionFilters);
-}
-
 //**************************************************************
 void XGUI_SelectionActivate::getSelectionModes(ModuleBase_ModelWidget* theWidget,
                                                QIntList& theModes)
@@ -157,23 +153,9 @@ void XGUI_SelectionActivate::getSelectionModes(ModuleBase_ModelWidget* theWidget
   if (!theWidget)
     return;
 
-  bool isAdditional = false;
-  theWidget->selectionModes(theModes, isAdditional);
-  if (isAdditional) {
-    myWorkshop->module()->customSubShapesSelectionModes(theModes);
-    //theModes.append(XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes());
-    //myWorkshop->module()->activeSelectionModes(theModes);
-  }
-}
-
-//**************************************************************
-void XGUI_SelectionActivate::getSelectionFilters(ModuleBase_ModelWidget* theWidget,
-                                                 SelectMgr_ListOfFilter& theSelectionFilters)
-{
-  XGUI_Tools::workshop(myWorkshop)->selectionFilters(theSelectionFilters);
-
-  if (theWidget)
-    theWidget->selectionFilters(theSelectionFilters);
+  int aModuleSelectionModes = -1;
+  theWidget->selectionModes(aModuleSelectionModes, theModes);
+  myWorkshop->module()->moduleSelectionModes(aModuleSelectionModes, theModes);
 }
 
 //**************************************************************
@@ -354,11 +336,19 @@ void XGUI_SelectionActivate::activateAIS(const Handle(AIS_InteractiveObject)& th
   }
   if (!aContext.IsNull()) {
     if (myWorkshop->module()) {
-      int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode);
+      // the code is obsolete, used in additional check before activate, it was removed
+      //int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode);
       aContext->Activate(theIO, theMode, false);
-    } else
+#ifdef TINSPECTOR
+      if (getDisplayer()->getCallBack()) getDisplayer()->getCallBack()->Activate(theIO, theMode);
+#endif
+    }
+    else {
       aContext->Activate(theIO, theMode, false);
-
+#ifdef TINSPECTOR
+      if (getDisplayer()->getCallBack()) getDisplayer()->getCallBack()->Activate(theIO, theMode);
+#endif
+    }
     // the fix from VPA for more suitable selection of sketcher lines
     if (theIO->Width() > 1) {
       double aPrecision = theIO->Width() + 2;
@@ -559,14 +549,16 @@ void XGUI_SelectionActivate::deactivateTrihedron(const bool theUpdateViewer) con
 void XGUI_SelectionActivate::deactivateTrihedronInSelectionModes()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
-  Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(getTrihedron());
-  /// deactivate trihedron in selection modes
-  TColStd_ListOfInteger aTColModes;
-  aContext->ActivatedModes(aTrihedron, aTColModes);
-  TColStd_ListIteratorOfListOfInteger itr( aTColModes );
-  for (; itr.More(); itr.Next() ) {
-    Standard_Integer aMode = itr.Value();
-    aContext->Deactivate(aTrihedron, aMode);
+  if (!aContext.IsNull()) {
+    Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(getTrihedron());
+    /// deactivate trihedron in selection modes
+    TColStd_ListOfInteger aTColModes;
+    aContext->ActivatedModes(aTrihedron, aTColModes);
+    TColStd_ListIteratorOfListOfInteger itr(aTColModes);
+    for (; itr.More(); itr.Next()) {
+      Standard_Integer aMode = itr.Value();
+      aContext->Deactivate(aTrihedron, aMode);
+    }
   }
 }