Salome HOME
Activation objects redesign.
authornds <nds@opencascade.com>
Wed, 13 Dec 2017 04:21:39 +0000 (07:21 +0300)
committernds <nds@opencascade.com>
Wed, 13 Dec 2017 04:22:18 +0000 (07:22 +0300)
52 files changed:
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_ISelectionActivate.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetFeatureSelector.cpp
src/ModuleBase/ModuleBase_WidgetFeatureSelector.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/ModuleBase/ModuleBase_WidgetValidated.cpp
src/ModuleBase/ModuleBase_WidgetValidated.h
src/ModuleBase/ModuleBase_WidgetValidator.cpp
src/ModuleBase/ModuleBase_WidgetValidator.h
src/PartSet/PartSet_ExternalPointsMgr.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_SketcherReentrantMgr.cpp
src/PartSet/PartSet_WidgetFeaturePointSelector.cpp
src/PartSet/PartSet_WidgetFeaturePointSelector.h
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/PartSet/PartSet_WidgetShapeSelector.h
src/PartSet/PartSet_WidgetSketchCreator.cpp
src/PartSet/PartSet_WidgetSketchCreator.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h
src/SHAPERGUI/SHAPERGUI.cpp
src/SamplePanelPlugin/CMakeLists.txt
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_ActiveControlMgr.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_FacesPanel.cpp
src/XGUI/XGUI_FacesPanel.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_PropertyPanelSelector.cpp
src/XGUI/XGUI_SelectionActivate.cpp [new file with mode: 0644]
src/XGUI/XGUI_SelectionActivate.h [new file with mode: 0644]
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_SelectionMgr.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 585bcb4e6c110cfde2fbfbc849cea0dd1188c78b..a9ad6af4db94df5696357cd77897506d818fc9e5 100644 (file)
@@ -45,6 +45,7 @@ SET(PROJECT_HEADERS
   ModuleBase_IPrefMgr.h
   ModuleBase_IPropertyPanel.h
   ModuleBase_ISelection.h
+  ModuleBase_ISelectionActivate.h
   ModuleBase_IViewWindow.h
   ModuleBase_IViewer.h
   ModuleBase_IWidgetCreator.h
index 4290fc3cdee0c93303e9aa60341f4faf16d48bf0..0a2b14991f580d6746f38df6a770ab01cdab56f1 100755 (executable)
@@ -32,6 +32,8 @@
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_ICustomPrs.h>
 
+#include <SelectMgr_ListOfFilter.hxx>
+
 #include <QString>
 #include <QObject>
 #include <QMap>
@@ -77,14 +79,13 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
 
   virtual ~ModuleBase_IModule() {}
 
-  /// Add default selection filters of the module to the current viewer
-  virtual void activateSelectionFilters() {}
-
-  /// Remove default selection filters of the module from the current viewer
-  virtual void deactivateSelectionFilters() {}
+  /// Appends into container of workshop selection filters
+  /// \param [out] selection filters
+  virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const {}
 
-  /// Update selection filters depending on the module active controls
-  virtual void updateActiveSelectionFilters() {}
+  /// Returns current selection modes that should be used in 3D viewer
+  /// \param theModes container of modes
+  virtual void selectionModes(QIntList& theModes) const {}
 
   /// Stores the current selection
   virtual void storeSelection() {}
@@ -238,8 +239,8 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   virtual void activeSelectionModes(QIntList& theModes) {}
 
   /// Appends specific selection modes for the module to the list of types
-  /// \param theTypes a selection modes to be extended
-  virtual void customSubShapesSelectionModes(QIntList& theTypes) {}
+  /// \param theModes a selection modes to be extended
+  virtual void customSubShapesSelectionModes(QIntList& theModes) {}
 
   /// Return true if the custom presentation is activated
   /// \param theFlag a flag of level of customization, which means that only part of sub-elements
diff --git a/src/ModuleBase/ModuleBase_ISelectionActivate.h b/src/ModuleBase/ModuleBase_ISelectionActivate.h
new file mode 100644 (file)
index 0000000..4e79670
--- /dev/null
@@ -0,0 +1,65 @@
+// Copyright (C) 2014-2017  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef ModuleBase_ISelectionActivate_H
+#define ModuleBase_ISelectionActivate_H
+
+#include "ModuleBase.h"
+
+#include "ModuleBase_IWorkshop.h"
+
+#include <SelectMgr_ListOfFilter.hxx>
+
+class ModuleBase_ModelWidget;
+
+
+/// \ingroup GUI
+/// A class which provides interface of activation/deactivate selection modes
+/// and using selection filters.
+class ModuleBase_ISelectionActivate
+{
+public:
+  /// Constructor
+  ModuleBase_ISelectionActivate(ModuleBase_IWorkshop* theWorkshop) : myWorkshop(theWorkshop) {}
+
+  /// Destructor
+  ~ModuleBase_ISelectionActivate() {}
+
+  /// Updates active selection modes in the viewer depending on the application state
+  MODULEBASE_EXPORT virtual void updateSelectionModes() = 0;
+
+  /// Updates active selection filters in the viewer depending on the application state
+  MODULEBASE_EXPORT virtual void updateSelectionFilters() = 0;
+
+  /// Activates parameter filters in the workshop, deactivate active out of the container
+  /// Please find a possibility to use updateSelectionFilters instead of direct call this method.
+  /// \param theSelectionFilters a filtes
+  MODULEBASE_EXPORT virtual void activateSelectionFilters
+    (const SelectMgr_ListOfFilter& theSelectionFilters) = 0;
+
+  /// Activate or deactivate selection and selection filters like the widget is active
+  /// \param theWidget a source widget of selection modes/filters
+  MODULEBASE_EXPORT virtual void activateSelectionAndFilters(ModuleBase_ModelWidget* theWidget) = 0;
+
+protected:
+  ModuleBase_IWorkshop* myWorkshop; ///< active workshop
+};
+
+#endif
index 77d9314d74d6b7d1d6d10096153bbdb97d82186b..e9a4d2c350b788ee8249c6cc19500ec370f2bba4 100644 (file)
@@ -37,6 +37,7 @@ class ModuleBase_IViewer;
 class ModuleBase_IPropertyPanel;
 class ModuleBase_IErrorMgr;
 class ModuleBase_Operation;
+class ModuleBase_ISelectionActivate;
 class ModuleBase_ViewerPrs;
 class QMainWindow;
 
@@ -58,16 +59,6 @@ Q_OBJECT
   /// Return current selection instance
   virtual ModuleBase_ISelection* selection() const = 0;
 
-  /// Activate sub-shapes selection (opens local context)
-  /// Types has to be defined according to TopAbs_ShapeEnum
-  virtual void activateSubShapesSelection(const QIntList& theTypes) = 0;
-
-  /// Activate objects in the module selection modes(opens local context)
-  virtual void activateModuleSelectionModes() = 0;
-
-  /// Deactivate sub-shapes selection (closes local context)
-  virtual void deactivateSubShapesSelection() = 0;
-
   //! Returns instance of loaded module
   virtual ModuleBase_IModule* module() const = 0;
 
@@ -84,6 +75,9 @@ Q_OBJECT
   /// \return a filter
   Handle(ModuleBase_FilterValidated) validatorFilter();
 
+  /// A selection activate in 3D View handler
+  virtual ModuleBase_ISelectionActivate* selectionActivate() const = 0;
+
   //! Returns currently active operation
   virtual ModuleBase_Operation* currentOperation() const = 0;
 
index 54a2511cb368613e33eef4c5d16eb77e842f1957..904d28ab1b932b96dfa51165f41d7d10e25c65e7 100644 (file)
@@ -49,6 +49,7 @@
 //#define DEBUG_WIDGET_INSTANCE
 //#define DEBUG_ENABLE_SKETCH_INPUT_FIELDS
 
+//**************************************************************
 ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
                                                const Config_WidgetAPI* theData)
     : QWidget(theParent),
@@ -85,6 +86,7 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
   connect(this, SIGNAL(valuesModified()), this, SLOT(onWidgetValuesModified()));
 }
 
+//**************************************************************
 ModuleBase_ModelWidget::~ModuleBase_ModelWidget()
 {
 #ifdef DEBUG_WIDGET_INSTANCE
@@ -92,6 +94,7 @@ ModuleBase_ModelWidget::~ModuleBase_ModelWidget()
 #endif
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::reset()
 {
   bool aResult = resetCustom();
@@ -101,11 +104,28 @@ bool ModuleBase_ModelWidget::reset()
   return aResult;
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
 {
   return theObject->data()->attribute(attributeID())->isInitialized();
 }
 
+//**************************************************************
+void ModuleBase_ModelWidget::selectionModes(QIntList& theModes, bool& isAdditional)
+{
+  isAdditional = true;
+  if (myWidgetValidator)
+    myWidgetValidator->selectionModes(theModes, isAdditional);
+}
+
+//**************************************************************
+void ModuleBase_ModelWidget::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
+{
+  if (myWidgetValidator)
+    myWidgetValidator->selectionFilters(theSelectionFilters);
+}
+
+//**************************************************************
 bool ModuleBase_ModelWidget::isValueEnabled() const
 {
   bool anEnabled = true;
@@ -124,12 +144,14 @@ bool ModuleBase_ModelWidget::isValueEnabled() const
   return anEnabled;
 }
 
+//**************************************************************
 void ModuleBase_ModelWidget::processValueState()
 {
   if (myState == ModifiedInPP || myState == ModifiedInViewer)
     storeValue();
 }
 
+//**************************************************************
 Events_InfoMessage ModuleBase_ModelWidget::getValueStateError() const
 {
   Events_InfoMessage aMessage;
@@ -157,6 +179,7 @@ Events_InfoMessage ModuleBase_ModelWidget::getValueStateError() const
   return aMessage;
 }
 
+//**************************************************************
 QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const
 {
   QString anError;
@@ -194,6 +217,7 @@ QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) const
   return anError;
 }
 
+//**************************************************************
 void ModuleBase_ModelWidget::enableFocusProcessing()
 {
   QList<QWidget*> aMyControls = getControls();
@@ -203,6 +227,7 @@ void ModuleBase_ModelWidget::enableFocusProcessing()
   }
 }
 
+//**************************************************************
 void ModuleBase_ModelWidget::setHighlighted(bool isHighlighted)
 {
   QList<QWidget*> aWidgetList = getControls();
@@ -217,6 +242,7 @@ void ModuleBase_ModelWidget::setHighlighted(bool isHighlighted)
   }
 }
 
+//**************************************************************
 void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool theToStoreValue,
                                         const bool isUpdateFlushed)
 {
@@ -234,6 +260,7 @@ void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool
   myFlushUpdateBlocked = false;
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::focusTo()
 {
 #ifdef DEBUG_WIDGET_INSTANCE
@@ -252,6 +279,7 @@ bool ModuleBase_ModelWidget::focusTo()
   return isFocusAccepted;
 }
 
+//**************************************************************
 void ModuleBase_ModelWidget::activate()
 {
 #ifdef DEBUG_WIDGET_INSTANCE
@@ -265,13 +293,10 @@ void ModuleBase_ModelWidget::activate()
     if (anAttribute.get() != NULL && !anAttribute->isInitialized())
       initializeValueByActivate();
   }
-
-  if (myWidgetValidator)
-    myWidgetValidator->activateFilters(true);
-
   activateCustom();
 }
 
+//**************************************************************
 void ModuleBase_ModelWidget::deactivate()
 {
 #ifdef DEBUG_WIDGET_INSTANCE
@@ -280,9 +305,10 @@ void ModuleBase_ModelWidget::deactivate()
   myIsValueStateBlocked = false;
   myState = Stored;
   if (myWidgetValidator)
-    myWidgetValidator->activateFilters(false);
+    myWidgetValidator->clearValidatedCash();
 }
 
+//**************************************************************
 void ModuleBase_ModelWidget::initializeValueByActivate()
 {
   if (isComputedDefault()) {
@@ -295,6 +321,7 @@ void ModuleBase_ModelWidget::initializeValueByActivate()
   }
 }
 
+//**************************************************************
 QWidget* ModuleBase_ModelWidget::getControlAcceptingFocus(const bool isFirst)
 {
   QWidget* aControl = 0;
@@ -317,11 +344,13 @@ QWidget* ModuleBase_ModelWidget::getControlAcceptingFocus(const bool isFirst)
   return aControl;
 }
 
+//**************************************************************
 void ModuleBase_ModelWidget::setDefaultValue(const std::string& theValue)
 {
   myDefaultValue = theValue;
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::storeValue()
 {
   setValueState(Stored);
@@ -348,6 +377,8 @@ bool ModuleBase_ModelWidget::storeValue()
   return isDone;
 }
 #ifdef DEBUG_VALUE_STATE
+
+//**************************************************************
 std::string getDebugInfo(const ModuleBase_ModelWidget::ValueState& theState)
 {
   std::string anInfo;
@@ -360,8 +391,9 @@ std::string getDebugInfo(const ModuleBase_ModelWidget::ValueState& theState)
   }
   return anInfo;
 }
-
 #endif
+
+//**************************************************************
 ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState
                                          (const ModuleBase_ModelWidget::ValueState& theState)
 {
@@ -379,6 +411,7 @@ ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState
   return aState;
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::blockValueState(const bool theBlocked)
 {
   bool isBlocked = myIsValueStateBlocked;
@@ -386,6 +419,7 @@ bool ModuleBase_ModelWidget::blockValueState(const bool theBlocked)
   return isBlocked;
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::restoreValue()
 {
   emit beforeValuesRestored();
@@ -395,6 +429,7 @@ bool ModuleBase_ModelWidget::restoreValue()
   return isDone;
 }
 
+//**************************************************************
 void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
 {
   if (!myFlushUpdateBlocked) {
@@ -406,6 +441,7 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
   }
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::canProcessAction(ModuleBase_ActionType theActionType,
                                               bool& isActionEnabled)
 {
@@ -414,6 +450,7 @@ bool ModuleBase_ModelWidget::canProcessAction(ModuleBase_ActionType theActionTyp
     case ActionEnter: return false;
     case ActionEscape: return false;
     case ActionDelete: return true;
+    case ActionSelection: return true;
     case ActionUndo:
     case ActionRedo:
     default:
@@ -421,6 +458,7 @@ bool ModuleBase_ModelWidget::canProcessAction(ModuleBase_ActionType theActionTyp
   }
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::processAction(ModuleBase_ActionType theActionType,
                                            const ActionParamPtr& theParam)
 {
@@ -431,6 +469,8 @@ bool ModuleBase_ModelWidget::processAction(ModuleBase_ActionType theActionType,
       return processEscape();
     case ActionDelete:
       return processDelete();
+    case ActionSelection:
+      processSelection();
     case ActionUndo:
     case ActionRedo:
     default:
@@ -438,16 +478,19 @@ bool ModuleBase_ModelWidget::processAction(ModuleBase_ActionType theActionType,
   }
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::processEnter()
 {
   return false;
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::processEscape()
 {
   return false;
 }
 
+//**************************************************************
 bool ModuleBase_ModelWidget::processDelete()
 {
   // we consider that model objects eats delete key in order to
@@ -455,6 +498,13 @@ bool ModuleBase_ModelWidget::processDelete()
   return true;
 }
 
+//**************************************************************
+bool ModuleBase_ModelWidget::processSelection()
+{
+  return false;
+}
+
+//**************************************************************
 bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
 {
   QWidget* aWidget = qobject_cast<QWidget*>(theObject);
index c6a475889282c57fcc4addc0681c4eb519c2a6d9..306f8eb12e8faf1da02c04ee630c469d9416152c 100644 (file)
 
 #include <ModuleBase.h>
 #include <ModuleBase_ActionType.h>
+#include <ModuleBase_Definitions.h>
 #include <ModuleBase_OperationFeature.h>
 #include <ModuleBase_ActionInfo.h>
 #include <ModuleBase_ActionParameter.h>
 #include <ModelAPI_Feature.h>
 
+#include <SelectMgr_ListOfFilter.hxx>
+
 #include <QWidget>
 
 #include <memory>
@@ -83,6 +86,15 @@ Q_OBJECT
   /// \return the boolean result
   bool isInitialized(ObjectPtr theObject) const;
 
+  /// Fills given container with selection modes if the widget has it
+  /// \param theModes [out] a container of modes
+  /// \param isAdditional if true, the modes are combinated with the module ones
+  virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
+  /// Appends into container of workshop selection filters
+  /// \param [out] selection filters
+  virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
   /// Returns true, if default value of the widget should be computed
   /// on operation's execute, like radius for circle's constraint (can not be zero)
   bool isComputedDefault() const { return myIsComputedDefault; }
@@ -363,7 +375,10 @@ protected:
   //// Returns true if the event is processed. The default implementation is empty, returns false.
   virtual bool processDelete();
 
-protected slots:
+  /// Returns true if envent is processed. It applyes workshop selection for the widget attribute.
+  virtual bool processSelection();
+
+  protected slots:
   /// Processing of values changed in model widget by store the current value to the feature
   void onWidgetValuesChanged();
 
index 88e482ada1f75badab4c0da6b9e7de1afd484447..7872179a302e1e27775b721d1c303d1a93ac9dc6 100644 (file)
@@ -110,34 +110,15 @@ bool ModuleBase_WidgetFeatureSelector::setSelectionCustom(const ModuleBase_Viewe
 }
 
 //********************************************************************
-void ModuleBase_WidgetFeatureSelector::deactivate()
+void ModuleBase_WidgetFeatureSelector::selectionModes(QIntList& theModes, bool& isAdditional)
 {
-  ModuleBase_ModelWidget::deactivate();
-  activateFilters(false);
-  myWorkshop->deactivateSubShapesSelection();
-}
-
-//********************************************************************
-bool ModuleBase_WidgetFeatureSelector::processAction(ModuleBase_ActionType theActionType,
-                                                     const ActionParamPtr& theParam)
-{
-  if (theActionType == ActionSelection)
-    onSelectionChanged();
-  else
-    return ModuleBase_WidgetValidated::processAction(theActionType, theParam);
-
-  return true;
+  theModes.push_back(ModuleBase_ResultPrs::Sel_Result);
+  isAdditional = true;
 }
 
 //********************************************************************
 void ModuleBase_WidgetFeatureSelector::activateCustom()
 {
-  activateFilters(true);
-
-  QIntList aShapeTypes;
-  aShapeTypes.push_back(ModuleBase_ResultPrs::Sel_Result);
-  myWorkshop->activateSubShapesSelection(aShapeTypes);
-
   // Restore selection in the viewer by the attribute selection list
   // it should be postponed to have current widget as active to validate restored selection
   //static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
@@ -227,13 +208,15 @@ bool ModuleBase_WidgetFeatureSelector::isValidInFilters(const ModuleBase_ViewerP
 }
 
 //********************************************************************
-void ModuleBase_WidgetFeatureSelector::onSelectionChanged()
+bool ModuleBase_WidgetFeatureSelector::processSelection()
 {
   QList<ModuleBase_ViewerPrsPtr> aSelected = myWorkshop->selection()->getSelected(
                                                               ModuleBase_ISelection::AllControls);
 
   bool isDone = setSelection(aSelected, true/*false*/);
   updateOnSelectionChanged(isDone);
+
+  return isDone;
 }
 
 //********************************************************************
index 39014f247fb8b33510fe6cffaed3eeab44ff2e3e..5261f53f7285dc0dddc8eab24fe456bf6ecc43f3 100644 (file)
@@ -68,6 +68,11 @@ Q_OBJECT
   virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
                             const bool theToValidate);
 
+  /// Fills given container with selection modes if the widget has it
+  /// \param theModes [out] a container of modes
+  /// \param isAdditional if true, the modes are combinated with the module ones
+  virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
   /// Returns list of widget controls
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
@@ -76,13 +81,6 @@ Q_OBJECT
   /// \param thePrs a selected owner
   virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
 
-  /// The method called when widget is deactivated
-  virtual void deactivate();
-
-  /// Processes Selection action.
-  virtual bool processAction(ModuleBase_ActionType theActionType,
-                             const ActionParamPtr& theParam = ActionParamPtr());
-
 protected:
   /// The method called when widget is activated
   virtual void activateCustom();
@@ -109,8 +107,8 @@ protected:
   virtual void updateOnSelectionChanged(const bool theDone);
 
 protected:
-  /// Called on selection changed event
-  virtual void onSelectionChanged();
+  /// Returns true if envent is processed.
+  virtual bool processSelection();
 
   //----------- Class members -------------
 protected:
index 56565ef5587a4d9a1cdd54638fa52391e148f2dc..c7b42d7ee41069bb5b6c04d1b849337306507ee2 100755 (executable)
 
 #include <ModuleBase_WidgetMultiSelector.h>
 
+#include <ModuleBase_ActionIntParameter.h>
 #include <ModuleBase_Definitions.h>
 #include <ModuleBase_Events.h>
 #include <ModuleBase_IconFactory.h>
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_ISelection.h>
+#include <ModuleBase_ISelectionActivate.h>
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_ListView.h>
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_ViewerPrs.h>
 #include <ModuleBase_WidgetShapeSelector.h>
-#include <ModuleBase_ActionIntParameter.h>
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
@@ -291,6 +292,7 @@ bool ModuleBase_WidgetMultiSelector::canProcessAction(ModuleBase_ActionType theA
     }
     break;
     default:
+      aCanProcess = ModuleBase_WidgetSelector::canProcessAction(theActionType, isActionEnabled);
     break;
   }
   return aCanProcess;
@@ -330,10 +332,10 @@ bool ModuleBase_WidgetMultiSelector::processAction(ModuleBase_ActionType theActi
 }
 
 //********************************************************************
-bool ModuleBase_WidgetMultiSelector::activateSelectionAndFilters(bool toActivate)
+void ModuleBase_WidgetMultiSelector::activateSelectionAndFilters(bool toActivate)
 {
   myWorkshop->updateCommandStatus(); // update enable state of Undo/Redo application actions
-  return ModuleBase_WidgetSelector::activateSelectionAndFilters(toActivate);
+  ModuleBase_WidgetSelector::activateSelectionAndFilters(toActivate);
 }
 
 //********************************************************************
@@ -429,6 +431,7 @@ QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
 void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
 {
   activateSelectionAndFilters(true);
+  myWorkshop->selectionActivate()->updateSelectionModes();
 
   if (!myFeature)
     return;
@@ -469,7 +472,7 @@ void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
 }
 
 //********************************************************************
-void ModuleBase_WidgetMultiSelector::onSelectionChanged()
+bool ModuleBase_WidgetMultiSelector::processSelection()
 {
   if (!myIsNeutralPointClear) {
     QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
@@ -481,13 +484,14 @@ void ModuleBase_WidgetMultiSelector::onSelectionChanged()
         static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
         ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
         Events_Loop::loop()->flush(anEvent);
-        return;
+        return true;
       }
     }
   }
   appendFirstSelectionInHistory();
-  ModuleBase_WidgetSelector::onSelectionChanged();
+  bool aDone = ModuleBase_WidgetSelector::processSelection();
   appendSelectionInHistory();
+  return aDone;
 }
 
 void ModuleBase_WidgetMultiSelector::appendFirstSelectionInHistory()
@@ -588,12 +592,11 @@ void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const int theShapeType)
     aShapeTypeName = myTypeCombo->itemText(idx);
     int aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
     if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
-      bool aWasActivated = activateSelectionAndFilters(false);
+      activateSelectionAndFilters(false);
       bool isBlocked = myTypeCombo->blockSignals(true);
       myTypeCombo->setCurrentIndex(idx);
       myTypeCombo->blockSignals(isBlocked);
-      if (aWasActivated)
-        activateSelectionAndFilters(true);
+      activateSelectionAndFilters(true);
       break;
     }
   }
index 1faf7fdd978bdcb621a9a7775a1dc3504d153f71..50742a71145b654cd5f26f0d7d325ede22cba636 100755 (executable)
@@ -96,8 +96,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge
                              const ActionParamPtr& theParam = ActionParamPtr());
 
   /// Activate or deactivate selection and selection filters
-  /// \return true if the selection filter of the widget is activated in viewer context
-  virtual bool activateSelectionAndFilters(bool toActivate);
+  virtual void activateSelectionAndFilters(bool toActivate);
 
   /// Checks the widget validity. By default, it returns true.
   /// \param thePrs a selected presentation in the view
@@ -112,9 +111,10 @@ public slots:
   /// Slot is called on selection type changed
   void onSelectionTypeChanged();
 
-  /// Slot which is called on selection event. Redefined to process XML state about
-  /// clear selection in neutral point
-  virtual void onSelectionChanged();
+protected:
+  /// Returns true if envent is processed.
+  /// Redefined to process XML state about clear selection in neutral point
+  virtual bool processSelection();
 
 protected slots:
   /// Slot for delete command in a list pop-up menu
index bb4bbc4a110d0ce01d5f04feb28cb47c018878c3..6f4a021d8686d1a24a442dd9bbf1aee29ce051c2 100755 (executable)
 
 #include <ModuleBase_WidgetSelector.h>
 
+#include <ModuleBase_Events.h>
+#include <ModuleBase_IModule.h>
 #include <ModuleBase_ISelection.h>
+#include <ModuleBase_ISelectionActivate.h>
 #include <ModuleBase_IWorkshop.h>
-#include <ModuleBase_Tools.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetFactory.h>
-#include <ModuleBase_IModule.h>
 #include <ModuleBase_ResultPrs.h>
+#include <ModuleBase_Tools.h>
 #include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_Events.h>
+#include <ModuleBase_WidgetFactory.h>
 
-#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_Events.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Events.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <TopoDS_Iterator.hxx>
 
@@ -61,7 +62,7 @@ void ModuleBase_WidgetSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr&
 }
 
 //********************************************************************
-void ModuleBase_WidgetSelector::onSelectionChanged()
+bool ModuleBase_WidgetSelector::processSelection()
 {
   QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
   // equal vertices should not be used here
@@ -69,6 +70,8 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
 
   bool isDone = setSelection(aSelected, true/*false*/);
   updateOnSelectionChanged(isDone);
+
+  return isDone;
 }
 
 //********************************************************************
@@ -162,26 +165,27 @@ bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape,
 }
 
 //********************************************************************
-bool ModuleBase_WidgetSelector::activateSelectionAndFilters(bool toActivate)
+void ModuleBase_WidgetSelector::selectionModes(QIntList& theModes, bool& isAdditional)
+{
+  theModes.append(getShapeTypes());
+  isAdditional = true;
+}
+
+//********************************************************************
+void ModuleBase_WidgetSelector::activateSelectionAndFilters(bool toActivate)
 {
   updateSelectionName();
 
-  if (toActivate) {
-    myWorkshop->activateSubShapesSelection(getShapeTypes());
-  } else {
-    myWorkshop->deactivateSubShapesSelection();
-  }
-  return activateFilters(toActivate);
+  myWorkshop->selectionActivate()->updateSelectionFilters();
+  myWorkshop->selectionActivate()->updateSelectionModes();
+
+  if (!toActivate)
+    clearValidatedCash();
 }
 
 //********************************************************************
 void ModuleBase_WidgetSelector::activateCustom()
 {
-  connect(myWorkshop, SIGNAL(selectionChanged()), this,
-          SLOT(onSelectionChanged()), Qt::UniqueConnection);
-
-  activateSelectionAndFilters(true);
-
   // Restore selection in the viewer by the attribute selection list
   // it should be postponed to have current widget as active to validate restored selection
   static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
@@ -219,10 +223,7 @@ bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrsPtr
 //********************************************************************
 void ModuleBase_WidgetSelector::deactivate()
 {
-  ModuleBase_ModelWidget::deactivate();
-  disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-  activateSelectionAndFilters(false);
-
+  ModuleBase_WidgetValidated::deactivate();
   /// clear temporary cash
   AttributePtr anAttribute = attribute();
   if (!anAttribute.get())
index f6d0275787382d43876bf895226f668721fd1452..86da4e12b37887600cce2df5b5bfbe8ce898e36b 100755 (executable)
@@ -54,12 +54,16 @@ Q_OBJECT
 
   virtual ~ModuleBase_WidgetSelector();
 
+  /// Fills given container with selection modes if the widget has it
+  /// \param theModes [out] a container of modes
+  /// \param isAdditional if true, the modes are combinated with the module ones
+  virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
   /// Defines if it is supposed that the widget should interact with the viewer.
   virtual bool isViewerSelector() { return true; }
 
   /// Activate or deactivate selection and selection filters
-  /// \return true if the selection filter of the widget is activated in viewer context
-  virtual bool activateSelectionAndFilters(bool toActivate);
+  virtual void activateSelectionAndFilters(bool toActivate);
 
   /// Checks the widget validity. By default, it returns true.
   /// \param thePrs a selected presentation in the view
@@ -78,11 +82,10 @@ Q_OBJECT
   /// a shape. If the attribute do not uses the shape, it is empty
   virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
 
-protected slots:
-  /// Slot which is called on selection event
-  virtual void onSelectionChanged();
-
 protected:
+  /// Returns true if envent is processed. The default implementation is empty, returns false.
+  virtual bool processSelection();
+
   /// Emits model changed info, updates the current control by selection change
   /// \param theDone a state whether the selection is set
   virtual void updateOnSelectionChanged(const bool theDone);
index 11ce866e315a1f4041b013b53f520b9ee4b7211a..7d88e7afcccc67b685a99b6114f17379200be2c4 100644 (file)
@@ -22,6 +22,7 @@
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_ISelection.h>
+#include <ModuleBase_ISelectionActivate.h>
 #include <ModuleBase_WidgetSelectorStore.h>
 #include <ModuleBase_ViewerPrs.h>
 
@@ -64,6 +65,12 @@ ObjectPtr ModuleBase_WidgetValidated::findPresentedObject(const AISObjectPtr& th
   return myPresentedObject;
 }
 
+//********************************************************************
+void ModuleBase_WidgetValidated::deactivate()
+{
+  clearValidatedCash();
+}
+
 //********************************************************************
 void ModuleBase_WidgetValidated::clearValidatedCash()
 {
@@ -115,8 +122,12 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr&
     // the widget validator filter should be active, but during check by preselection
     // it is not yet activated, so we need to activate/deactivate it manually
     bool isActivated = isFilterActivated();
-    if (!isActivated)
-      activateFilters(true);
+    if (!isActivated) {
+      SelectMgr_ListOfFilter aSelectionFilters;
+      selectionFilters(aSelectionFilters);
+      /// after validation, the selection filters should be restored
+      myWorkshop->selectionActivate()->activateSelectionFilters(aSelectionFilters);
+    }
 
     Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
     if (!aContext.IsNull()) {
@@ -128,7 +139,10 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr&
       }
     }
     if (!isActivated)
-      activateFilters(false);
+    {
+      myWorkshop->selectionActivate()->updateSelectionFilters();
+      clearValidatedCash();
+    }
   }
 
   // removes created owner
@@ -218,6 +232,7 @@ bool ModuleBase_WidgetValidated::isValidAttribute(const AttributePtr& theAttribu
   return aFactory->validate(theAttribute, aValidatorID, anError);
 }
 
+//********************************************************************
 bool ModuleBase_WidgetValidated::isFilterActivated() const
 {
   bool isActivated = false;
@@ -228,21 +243,10 @@ bool ModuleBase_WidgetValidated::isFilterActivated() const
   return aViewer->hasSelectionFilter(aSelFilter);
 }
 
-bool ModuleBase_WidgetValidated::activateFilters(const bool toActivate)
+//********************************************************************
+void ModuleBase_WidgetValidated::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
 {
-  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-
-  Handle(SelectMgr_Filter) aSelFilter = myWorkshop->validatorFilter();
-  bool aHasSelectionFilter = aViewer->hasSelectionFilter(aSelFilter);
-
-  if (toActivate)
-    aViewer->addSelectionFilter(aSelFilter);
-  else {
-    aViewer->removeSelectionFilter(aSelFilter);
-    clearValidatedCash();
-  }
-
-  return aHasSelectionFilter;
+  theSelectionFilters.Append(myWorkshop->validatorFilter());
 }
 
 //********************************************************************
index bd01429ed0b05ccc5e2facfefe3318aac088cba0..d47b71f14305bcbad4d3c5f0ff9435e29617ba66 100644 (file)
@@ -73,6 +73,9 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg
   //! Returns data object by AIS
   ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
 
+  /// The method called when widget is deactivated
+  virtual void deactivate();
+
   //! Clear all validated cash in the widget
   void clearValidatedCash();
 
@@ -80,6 +83,10 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg
   /// \return boolean value
   bool isFilterActivated() const;
 
+  /// Appends into container of workshop selection filters
+  /// \param [out] selection filters
+  virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
   /// Block the model flush of update and intialization of attribute
   /// \param theAttribute an attribute of blocking
   /// \param theFeature a feature
@@ -148,11 +155,6 @@ protected:
   /// \return a list of presentations
   QList<std::shared_ptr<ModuleBase_ViewerPrs>> getFilteredSelected();
 
-  /// It obtains selection filters from the workshop and activates them in the active viewer
-  /// \param toActivate a flag about activation or deactivation the filters
-  /// \return true if the selection filter of the widget is activated in viewer context
-  bool activateFilters(const bool toActivate);
-
   /// Block the model flush of update and intialization of attribute
   /// \param theAttribute an attribute of blocking
   /// \param theToBlock flag whether the model is blocked or unblocked
index 874a0f4859e9da22262477ebea03d2389265a3a1..8f6113c44054e819dd3607f3edd0ca752fea7b70 100755 (executable)
@@ -39,6 +39,12 @@ ModuleBase_WidgetValidator::~ModuleBase_WidgetValidator()
   delete myAttributeStore;
 }
 
+//********************************************************************
+void ModuleBase_WidgetValidator::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
+{
+  theSelectionFilters.Append(myWorkshop->validatorFilter());
+}
+
 //********************************************************************
 bool ModuleBase_WidgetValidator::isValidSelection(const ModuleBase_ViewerPrsPtr& theValue)
 {
@@ -52,23 +58,6 @@ bool ModuleBase_WidgetValidator::isValidSelection(const ModuleBase_ViewerPrsPtr&
   return aValid;
 }
 
-bool ModuleBase_WidgetValidator::activateFilters(const bool toActivate)
-{
-  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-
-  Handle(SelectMgr_Filter) aSelFilter = myWorkshop->validatorFilter();
-  bool aHasSelectionFilter = aViewer->hasSelectionFilter(aSelFilter);
-
-  if (toActivate)
-    aViewer->addSelectionFilter(aSelFilter);
-  else {
-    aViewer->removeSelectionFilter(aSelFilter);
-    clearValidatedCash();
-  }
-
-  return aHasSelectionFilter;
-}
-
 void ModuleBase_WidgetValidator::storeAttributeValue(const AttributePtr& theAttribute)
 {
   myIsInValidate = true;
index cb62c1167c7c56d4f73664a79a3299ed70357ba4..f6c84426430e05229631e1faf7047320cbd078b8 100755 (executable)
 #ifndef ModuleBase_WidgetValidator_H_
 #define ModuleBase_WidgetValidator_H_
 
-#include <ModuleBase.h>
+#include "ModuleBase.h"
+
+#include "ModuleBase_Definitions.h"
+
+#include <SelectMgr_ListOfFilter.hxx>
 
 #include <QList>
 #include <memory>
@@ -47,6 +51,15 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidator
                              ModuleBase_IWorkshop* theWorkshop);
   virtual ~ModuleBase_WidgetValidator();
 
+  /// Fills given container with selection modes if the widget has it
+  /// \param theModes [out] a container of modes
+  /// \param isAdditional if true, the modes are combinated with the module ones
+  virtual void selectionModes(QIntList& theModes, bool& isAdditional) {}
+
+  /// Appends into container of workshop selection filters
+  /// \param [out] selection filters
+  virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
   /// Returns true if the validation is activated
   bool isInValidate() const { return myIsInValidate; }
 
@@ -58,11 +71,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidator
   /// \return a boolean value
   virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
 
-  /// It obtains selection filters from the workshop and activates them in the active viewer
-  /// \param toActivate a flag about activation or deactivation the filters
-  /// \return true if the selection filter of the widget is activated in viewer context
-  bool activateFilters(const bool toActivate);
-
     /// Creates a backup of the current values of the attribute
   /// It should be realized in the specific widget because of different
   /// parameters of the current attribute
@@ -82,14 +90,14 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidator
   /// \return true if all validators return that the attribute is valid
   bool isValidAttribute(const std::shared_ptr<ModelAPI_Attribute>& theAttribute) const;
 
+  //! Clear all validated cash in the widget
+  void clearValidatedCash();
+
 private:
   /// Returns true if the workshop validator filter has been already activated
   /// \return boolean value
   bool isFilterActivated() const;
 
-  //! Clear all validated cash in the widget
-  void clearValidatedCash();
-
   /// Gets the validity state of the presentation in an internal map.
   /// Returns true if the valid state of value is stored
   /// \param theValue a viewer presentation
index 0f9babdae75ef5377962558fc8b69dc8076b16a0..3de84434e2dd3942e87e923eca84b6aa602c5bf9 100644 (file)
@@ -40,6 +40,7 @@
 #include <XGUI_Tools.h>
 #include <XGUI_Displayer.h>
 #include <XGUI_Workshop.h>
+#include <XGUI_SelectionActivate.h>
 #include <XGUI_SelectionMgr.h>
 
 PartSet_ExternalPointsMgr::PartSet_ExternalPointsMgr(ModuleBase_IWorkshop* theWorkshop,
@@ -179,7 +180,8 @@ void PartSet_ExternalPointsMgr::updateCenterPresentations()
       myPresentations[aPrs->object()] = aList;
     foreach(AISObjectPtr anAIS, aList) {
       aDisplayer->displayAIS(anAIS, false);
-      aDisplayer->activateAIS(anAIS->impl<Handle(AIS_InteractiveObject)>(), TopAbs_VERTEX, false);
+      aWorkshop->selectionActivate()->activateAIS(anAIS->impl<Handle(AIS_InteractiveObject)>(),
+        TopAbs_VERTEX, false);
     }
   }
 }
index 1455f1ab08e55363ff68b2c20a1d1b38ac2e320f..91468737ea647e0f0fadefccfe1687aac67288ec 100755 (executable)
@@ -51,6 +51,7 @@
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_IViewWindow.h>
 #include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ISelectionActivate.h>
 #include <ModuleBase_WidgetChoice.h>
 #include <ModuleBase_WidgetEditor.h>
 #include <ModuleBase_WidgetValidated.h>
@@ -143,6 +144,7 @@ extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop*
   return new PartSet_Module(theWshop);
 }
 
+//******************************************************
 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
 : ModuleBase_IModule(theWshop),
   myVisualLayerId(0),
@@ -198,6 +200,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
                                    "0.8");
 }
 
+//******************************************************
 PartSet_Module::~PartSet_Module()
 {
   SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters);
@@ -210,37 +213,7 @@ PartSet_Module::~PartSet_Module()
   delete myOverconstraintListener;
 }
 
-void PartSet_Module::activateSelectionFilters()
-{
-  SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters);
-  for (; aIt.More(); aIt.Next()) {
-    Handle(SelectMgr_Filter) aFilter = aIt.Value();
-    if (!aFilter.IsNull())
-      myWorkshop->viewer()->addSelectionFilter(aFilter);
-  }
-}
-
-void PartSet_Module::deactivateSelectionFilters()
-{
-  SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters);
-  for (; aIt.More(); aIt.Next()) {
-    Handle(SelectMgr_Filter) aFilter = aIt.Value();
-    if (!aFilter.IsNull())
-      myWorkshop->viewer()->removeSelectionFilter(aFilter);
-  }
-}
-
-void PartSet_Module::updateActiveSelectionFilters()
-{
-  XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(workshop());
-  XGUI_ActiveControlSelector* anActiveSelector = aWorkshop->activeControlMgr()->activeSelector();
-
-  if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
-    sketchMgr()->deactivateSelectionFilters();
-  else
-    sketchMgr()->activateSelectionFilters();
-}
-
+//******************************************************
 void PartSet_Module::storeSelection()
 {
   // cash is used only to restore selection, so it should be filled in storeSelection and
@@ -249,6 +222,7 @@ void PartSet_Module::storeSelection()
   sketchMgr()->storeSelection(PartSet_SketcherMgr::ST_SelectType, myCurrentSelection);
 }
 
+//******************************************************
 void PartSet_Module::restoreSelection()
 {
   // cash is used only to restore selection, so it should be filled in storeSelection and
@@ -257,6 +231,7 @@ void PartSet_Module::restoreSelection()
   myCurrentSelection.clear();
 }
 
+//******************************************************
 void PartSet_Module::registerValidators()
 {
   //Registering of validators
@@ -285,12 +260,14 @@ void PartSet_Module::registerValidators()
   aFactory->registerValidator("PartSet_ProjectionSelection", new PartSet_ProjectionSelection);
 }
 
+//******************************************************
 void PartSet_Module::connectToPropertyPanel(ModuleBase_ModelWidget* theWidget,
                                             const bool isToConnect)
 {
   mySketchMgr->connectToPropertyPanel(theWidget, isToConnect);
 }
 
+//******************************************************
 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
 {
   if (sketchMgr()->isNestedSketchOperation(theOperation)) {
@@ -314,6 +291,7 @@ void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
   }
 }
 
+//******************************************************
 void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
 {
   /// Restart sketcher operations automatically
@@ -323,6 +301,7 @@ void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
     overconstraintListener()->setActive(false);
 }
 
+//******************************************************
 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
 {
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
@@ -410,6 +389,7 @@ void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
   }
 }
 
+//******************************************************
 void PartSet_Module::updateSketcherOnStart(ModuleBase_Operation* theOperation)
 {
   if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
@@ -420,6 +400,7 @@ void PartSet_Module::updateSketcherOnStart(ModuleBase_Operation* theOperation)
   }
 }
 
+//******************************************************
 void PartSet_Module::updatePresentationsOnStart(ModuleBase_Operation* theOperation)
 {
   ModuleBase_OperationFeature* aFOperation =
@@ -430,6 +411,7 @@ void PartSet_Module::updatePresentationsOnStart(ModuleBase_Operation* theOperati
   }
 }
 
+//******************************************************
 void PartSet_Module::operationResumed(ModuleBase_Operation* theOperation)
 {
   ModuleBase_IModule::operationResumed(theOperation);
@@ -442,6 +424,7 @@ void PartSet_Module::operationResumed(ModuleBase_Operation* theOperation)
   }
 }
 
+//******************************************************
 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
 {
   bool isModifiedArgs = myCustomPrs->deactivate(ModuleBase_IModule::CustomizeArguments, false);
@@ -468,6 +451,7 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
   }
 }
 
+//******************************************************
 ModuleBase_Operation* PartSet_Module::currentOperation() const
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
@@ -475,6 +459,7 @@ ModuleBase_Operation* PartSet_Module::currentOperation() const
   return anOpMgr->currentOperation();
 }
 
+//******************************************************
 bool PartSet_Module::canUndo() const
 {
   bool aCanUndo = false;
@@ -487,6 +472,7 @@ bool PartSet_Module::canUndo() const
   return aCanUndo;
 }
 
+//******************************************************
 bool PartSet_Module::canRedo() const
 {
   bool aCanRedo = false;
@@ -499,6 +485,7 @@ bool PartSet_Module::canRedo() const
   return aCanRedo;
 }
 
+//******************************************************
 bool PartSet_Module::canApplyAction(const ObjectPtr& theObject, const QString& theActionId) const
 {
   bool aValid = true;
@@ -514,18 +501,21 @@ bool PartSet_Module::canApplyAction(const ObjectPtr& theObject, const QString& t
   return aValid;
 }
 
+//******************************************************
 bool PartSet_Module::canEraseObject(const ObjectPtr& theObject) const
 {
   // the sketch manager put the restriction to the objects erase
   return mySketchMgr->canEraseObject(theObject);
 }
 
+//******************************************************
 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
 {
   // the sketch manager put the restriction to the objects display
   return mySketchMgr->canDisplayObject(theObject);
 }
 
+//******************************************************
 bool PartSet_Module::canUsePreselection(const QString& thePreviousOperationKind,
                                         const QString& theStartedOperationKind)
 {
@@ -540,6 +530,7 @@ bool PartSet_Module::canUsePreselection(const QString& thePreviousOperationKind,
   mySketchMgr->processHiddenObject(theObjects);
 }*/
 
+//******************************************************
 bool PartSet_Module::canActivateSelection(const ObjectPtr& theObject) const
 {
   bool aCanActivate = ModuleBase_IModule::canActivateSelection(theObject);
@@ -557,6 +548,18 @@ bool PartSet_Module::canActivateSelection(const ObjectPtr& theObject) const
   return aCanActivate;
 }
 
+//******************************************************
+void PartSet_Module::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const
+{
+  for (SelectMgr_ListOfFilter::Iterator aFiltersIt(mySelectionFilters); aFiltersIt.More();
+       aFiltersIt.Next())
+    theSelectionFilters.Append(aFiltersIt.Value());
+
+  if (mySketchMgr->activeSketch())
+    mySketchMgr->selectionFilters(theSelectionFilters);
+}
+
+//******************************************************
 bool PartSet_Module::addViewerMenu(const QMap<QString, QAction*>& theStdActions,
                                    QWidget* theParent,
                                    QMap<int, QAction*>& theMenuActions) const
@@ -564,11 +567,13 @@ bool PartSet_Module::addViewerMenu(const QMap<QString, QAction*>& theStdActions,
   return myMenuMgr->addViewerMenu(theStdActions, theParent, theMenuActions);
 }
 
+//******************************************************
 void PartSet_Module::updateViewerMenu(const QMap<QString, QAction*>& theStdActions)
 {
   myMenuMgr->updateViewerMenu(theStdActions);
 }
 
+//******************************************************
 bool PartSet_Module::isActionEnableStateFixed(const int theActionId) const
 {
   bool isEnabledFixed = false;
@@ -578,6 +583,7 @@ bool PartSet_Module::isActionEnableStateFixed(const int theActionId) const
   return isEnabledFixed;
 }
 
+//******************************************************
 QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature)
 {
   QString anError = ModuleBase_IModule::getFeatureError(theFeature);
@@ -587,6 +593,7 @@ QString PartSet_Module::getFeatureError(const FeaturePtr& theFeature)
   return anError;
 }
 
+//******************************************************
 void PartSet_Module::grantedOperationIds(ModuleBase_Operation* theOperation,
                                          QStringList& theIds) const
 {
@@ -598,21 +605,28 @@ void PartSet_Module::grantedOperationIds(ModuleBase_Operation* theOperation,
   }
 }
 
+//******************************************************
 void PartSet_Module::activeSelectionModes(QIntList& theModes)
 {
-  theModes.clear();
   if (mySketchMgr->activeSketch().get())
-    PartSet_SketcherMgr::sketchSelectionModes(theModes);
+    PartSet_SketcherMgr::sketchSelectionModes(mySketchMgr->activeSketch(), theModes);
+  else
+    theModes = XGUI_Tools::workshop(myWorkshop)->viewerSelectionModes();
 }
 
-void PartSet_Module::customSubShapesSelectionModes(QIntList& theTypes)
+//******************************************************
+void PartSet_Module::customSubShapesSelectionModes(QIntList& theModes)
 {
-  if (theTypes.contains(TopAbs_FACE))
-    theTypes.append(SketcherPrs_Tools::Sel_Sketch_Face);
-  if (theTypes.contains(TopAbs_WIRE))
-    theTypes.append(SketcherPrs_Tools::Sel_Sketch_Wire);
+  if (theModes.contains(TopAbs_FACE))
+    theModes.append(SketcherPrs_Tools::Sel_Sketch_Face);
+  if (theModes.contains(TopAbs_WIRE))
+    theModes.append(SketcherPrs_Tools::Sel_Sketch_Wire);
+
+  if (mySketchMgr->activeSketch().get())
+    PartSet_SketcherMgr::sketchSelectionModes(mySketchMgr->activeSketch(), theModes);
 }
 
+//******************************************************
 void PartSet_Module::getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelected,
                                       ObjectPtr& theObject, AttributePtr& theAttribute)
 {
@@ -624,11 +638,13 @@ void PartSet_Module::getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs
   theObject = anObject;
 }
 
+//******************************************************
 bool PartSet_Module::isMouseOverWindow()
 {
   return mySketchMgr->isMouseOverWindow();
 }
 
+//******************************************************
 bool PartSet_Module::isSketchNeutralPointActivated() const
 {
   bool isNeutralPoint = true;
@@ -640,20 +656,23 @@ bool PartSet_Module::isSketchNeutralPointActivated() const
   return isNeutralPoint;
 }
 
+//******************************************************
 void PartSet_Module::closeDocument()
 {
   myActivePartIndex = QModelIndex();
 }
 
+//******************************************************
 void PartSet_Module::clearViewer()
 {
   myCustomPrs->clearPrs();
 
   XGUI_Workshop* aWorkshop = getWorkshop();
   XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-  aDisplayer->deactivateSelectionFilters();
+  aDisplayer->deactivateSelectionFilters(false);
 }
 
+//******************************************************
 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
 {
   ModuleBase_OperationFeature* aFOperation =
@@ -667,6 +686,7 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
     aPanel->activateWidget(aPanel->modelWidgets().first());
 }
 
+//******************************************************
 bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation,
                                    QList<ModuleBase_ModelWidget*>& theWidgets) const
 {
@@ -719,6 +739,7 @@ bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation,
   return aProcessed;
 }
 
+//******************************************************
 void PartSet_Module::onSelectionChanged()
 {
   ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
@@ -752,6 +773,7 @@ void PartSet_Module::onSelectionChanged()
   }
 }
 
+//******************************************************
 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
@@ -759,6 +781,7 @@ void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* the
   anOpMgr->onKeyReleased(theWnd->viewPort(), theEvent);
 }
 
+//******************************************************
 ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType,
                                                            QWidget* theParent,
                                                            Config_WidgetAPI* theWidgetApi)
@@ -817,6 +840,7 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
   return aWgt;
 }
 
+//******************************************************
 ModuleBase_ModelWidget* PartSet_Module::activeWidget() const
 {
   ModuleBase_ModelWidget* anActiveWidget = 0;
@@ -832,6 +856,7 @@ ModuleBase_ModelWidget* PartSet_Module::activeWidget() const
   return anActiveWidget;
 }
 
+//******************************************************
 bool PartSet_Module::deleteObjects()
 {
   bool isProcessed = false;
@@ -905,17 +930,20 @@ bool PartSet_Module::deleteObjects()
   return isProcessed;
 }
 
+//******************************************************
 void PartSet_Module::editFeature(FeaturePtr theFeature)
 {
   storeConstraintsState(theFeature->getKind());
   ModuleBase_IModule::editFeature(theFeature);
 }
 
+//******************************************************
 bool PartSet_Module::canCommitOperation() const
 {
   return true;
 }
 
+//******************************************************
 void PartSet_Module::launchOperation(const QString& theCmdId, const bool& isStartAfterCommitOnly)
 {
   myIsOperationIsLaunched = true;
@@ -927,6 +955,7 @@ void PartSet_Module::launchOperation(const QString& theCmdId, const bool& isStar
   myIsOperationIsLaunched = false;
 }
 
+//******************************************************
 void PartSet_Module::storeConstraintsState(const std::string& theFeatureKind)
 {
   if (myWorkshop->currentOperation() &&
@@ -937,6 +966,7 @@ void PartSet_Module::storeConstraintsState(const std::string& theFeatureKind)
   }
 }
 
+//******************************************************
 void PartSet_Module::updateConstraintsState(const std::string& theFeatureKind)
 {
   if (PartSet_SketcherMgr::constraintsIdList().contains(theFeatureKind.c_str()) ||
@@ -949,6 +979,7 @@ void PartSet_Module::updateConstraintsState(const std::string& theFeatureKind)
   }
 }
 
+//******************************************************
 void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
 {
   Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
@@ -971,6 +1002,7 @@ void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
   }
 }
 
+//******************************************************
 void PartSet_Module::onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS)
 {
   // this is obsolete
@@ -980,6 +1012,7 @@ void PartSet_Module::onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAI
   //  myCustomPrs->redisplay(theObject, false);
 }
 
+//******************************************************
 void PartSet_Module::onViewTransformed(int theTrsfType)
 {
   // Set length of arrows constant in pixel size
@@ -1039,11 +1072,13 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
   }
 }
 
+//******************************************************
 bool PartSet_Module::isCustomPrsActivated(const ModuleBase_CustomizeFlag& theFlag) const
 {
   return myCustomPrs->isActive(theFlag);
 }
 
+//******************************************************
 void PartSet_Module::activateCustomPrs(const FeaturePtr& theFeature,
                                        const ModuleBase_CustomizeFlag& theFlag,
                                        const bool theUpdateViewer)
@@ -1051,12 +1086,14 @@ void PartSet_Module::activateCustomPrs(const FeaturePtr& theFeature,
   myCustomPrs->activate(theFeature, theFlag, theUpdateViewer);
 }
 
+//******************************************************
 void PartSet_Module::deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag,
                                          const bool theUpdateViewer)
 {
   myCustomPrs->deactivate(theFlag, theUpdateViewer);
 }
 
+//******************************************************
 bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
                                            std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs)
 {
@@ -1081,6 +1118,7 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the
   return aCustomized;
 }
 
+//******************************************************
 bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
                                                 AISObjectPtr thePrs,
                                                 GeomCustomPrsPtr theCustomPrs)
@@ -1123,6 +1161,7 @@ bool PartSet_Module::afterCustomisePresentation(std::shared_ptr<ModelAPI_Result>
   return aCustomized;
 }
 
+//******************************************************
 bool PartSet_Module::customizeObject(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
                                      const bool theUpdateViewer)
 {
@@ -1133,6 +1172,7 @@ bool PartSet_Module::customizeObject(ObjectPtr theObject, const ModuleBase_Custo
   return isRedisplayed;
 }
 
+//******************************************************
 void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser)
 {
   XGUI_ObjectsBrowser* aOB = dynamic_cast<XGUI_ObjectsBrowser*>(theObjectBrowser);
@@ -1150,6 +1190,7 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser)
   }
 }
 
+//******************************************************
 void PartSet_Module::onActiveDocPopup(const QPoint& thePnt)
 {
   SessionPtr aMgr = ModelAPI_Session::get();
@@ -1165,12 +1206,13 @@ void PartSet_Module::onActiveDocPopup(const QPoint& thePnt)
   aMenu.exec(aHeader->mapToGlobal(thePnt));
 }
 
+//******************************************************
 Handle(AIS_InteractiveObject) PartSet_Module::createPresentation(const ResultPtr& theResult)
 {
   return mySketchMgr->createPresentation(theResult);
 }
 
-
+//******************************************************
 ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const
 {
   ObjectPtr anObject;
@@ -1193,6 +1235,7 @@ ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const
   return anObject;
 }
 
+//******************************************************
 bool PartSet_Module::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const
 {
   bool aCanBeShaged = true;
@@ -1204,6 +1247,7 @@ bool PartSet_Module::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const
   return aCanBeShaged;
 }
 
+//******************************************************
 void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const
 {
   QObjectPtrList aObjects = myWorkshop->selection()->selectedObjects();
@@ -1263,6 +1307,7 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const
   }
 }
 
+//******************************************************
 #define EXPAND_PARENT(OBJ) \
 QModelIndex aObjIndex = aDataModel->objectIndex(OBJ); \
 if (aObjIndex.isValid()) { \
@@ -1272,7 +1317,7 @@ if (aObjIndex.isValid()) { \
     aTreeView->setExpanded(aParent, true); \
 }
 
-
+//******************************************************
 void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMessage)
 {
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
@@ -1359,6 +1404,7 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
   }
 }
 
+//******************************************************
 void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
 {
   if (myWorkshop->currentOperation()) // Do not change activation of parts if an operation active
@@ -1395,7 +1441,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
   }
 }
 
-
+//******************************************************
 void PartSet_Module::onViewCreated(ModuleBase_IViewWindow*)
 {
   // z layer is created for all started operations in order to visualize operation AIS presentation
@@ -1423,16 +1469,8 @@ void PartSet_Module::onViewCreated(ModuleBase_IViewWindow*)
   }
   // if there is an active operation with validated widget,
   // the filters of this widget should be activated in the created view
-  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
-  if (aOperation) {
-    ModuleBase_ModelWidget* anActiveWidget = activeWidget();
-    if (anActiveWidget) {
-      ModuleBase_WidgetSelector* aWSelector =
-        dynamic_cast<ModuleBase_WidgetSelector*>(anActiveWidget);
-      if (aWSelector)
-        aWSelector->activateSelectionAndFilters(true);
-    }
-  }
+  myWorkshop->selectionActivate()->updateSelectionFilters();
+  myWorkshop->selectionActivate()->updateSelectionModes();
 }
 
 //******************************************************
@@ -1441,6 +1479,7 @@ void PartSet_Module::widgetStateChanged(int thePreviousState)
   mySketchMgr->widgetStateChanged(thePreviousState);
 }
 
+//******************************************************
 bool PartSet_Module::processEnter(const std::string& thePreviousAttributeID)
 {
   return mySketchReentrantMgr->processEnter(thePreviousAttributeID);
index a54c16660383a56d4311dfbd7656b9fa2351b100..850c52f5d7a400ac15d7414dee5056a7c9933470 100755 (executable)
@@ -84,13 +84,6 @@ public:
   PartSet_Module(ModuleBase_IWorkshop* theWshop);
   virtual ~PartSet_Module();
 
-  // Add default selection filters of the module to the current viewer
-  virtual void activateSelectionFilters();
-  // Remove default selection filters of the module from the current viewer
-  virtual void deactivateSelectionFilters();
-  /// Update selection filters depending on the module active controls
-  virtual void updateActiveSelectionFilters();
-
   // Stores the current selection
   virtual void storeSelection();
 
@@ -207,6 +200,10 @@ public:
   /// \param theObject a model object
   virtual bool canActivateSelection(const ObjectPtr& theObject) const;
 
+  /// Appends into container of workshop selection filters
+  /// \param [out] selection filters
+  virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const;
+
   /// Add menu atems for object browser into the given menu
   /// \param theMenu a popup menu to be shown in the object browser
   virtual void addObjectBrowserMenu(QMenu* theMenu) const;
@@ -225,8 +222,8 @@ public:
   virtual void activeSelectionModes(QIntList& theModes);
 
   /// Appends specific selection modes for the module to the list of types
-  /// \param theTypes a selection modes to be extended
-  virtual void customSubShapesSelectionModes(QIntList& theTypes);
+  /// \param theModes a selection modes to be extended
+  virtual void customSubShapesSelectionModes(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
index 27b0b64f67ef5d7f56d56c4337305593c639a452..01ec24d19aba31007f3996985eb26db022d1e0a6 100755 (executable)
@@ -34,6 +34,7 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_ContextMenuMgr.h>
 #include <XGUI_Selection.h>
+#include <XGUI_SelectionActivate.h>
 #include <XGUI_SelectionMgr.h>
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_PropertyPanel.h>
@@ -812,9 +813,11 @@ const QStringList& PartSet_SketcherMgr::constraintsIdList()
   return aConstraintIds;
 }
 
-void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
+void PartSet_SketcherMgr::sketchSelectionModes(const CompositeFeaturePtr& theSketch,
+                                               QIntList& theModes)
 {
-  theModes.clear();
+  if (!theSketch.get() || !PartSet_Tools::sketchPlane(theSketch).get())
+    return;
 
   theModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
   theModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
@@ -1022,13 +1025,10 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
   myPlaneFilter->setPlane(aPln);
 
-  activateSelectionFilters();
+  workshop()->selectionActivate()->updateSelectionFilters();
+  workshop()->selectionActivate()->updateSelectionModes();
 
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-  // all displayed objects should be activated in current selection modes according to switched
-  // plane filter
-  if (aPln.get())
-    aConnector->activateModuleSelectionModes();
 
   myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch);
 }
@@ -1097,10 +1097,8 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
 
     Events_Loop::loop()->flush(aDispEvent);
   }
-  deactivateSelectionFilters();
-
-  // restore the module selection modes, which were changed on startSketch
-  aConnector->activateModuleSelectionModes();
+  workshop()->selectionActivate()->updateSelectionFilters();
+  workshop()->selectionActivate()->updateSelectionModes();
 }
 
 void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
@@ -1160,16 +1158,10 @@ void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
   }
 }
 
-void PartSet_SketcherMgr::activateSelectionFilters()
-{
-  myModule->workshop()->viewer()->addSelectionFilter(myCirclePointFilter);
-  myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
-}
-
-void PartSet_SketcherMgr::deactivateSelectionFilters()
+void PartSet_SketcherMgr::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const
 {
-  myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter);
-  myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
+  theSelectionFilters.Append(myCirclePointFilter);
+  theSelectionFilters.Append(myPlaneFilter);
 }
 
 void PartSet_SketcherMgr::activatePlaneFilter(const bool& toActivate)
@@ -1483,6 +1475,7 @@ bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const
 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
 {
   myPlaneFilter->setPlane(thePln);
+  workshop()->selectionActivate()->updateSelectionModes();
 }
 
 bool PartSet_SketcherMgr::setDistanceValueByPreselection(ModuleBase_Operation* theOperation,
index 119764273f5168c1eb3a2b396c744aff27693eb6..849a6a1b821007777b1ae6eae6fa9b1186f67dbd 100644 (file)
 #include <ModuleBase_ModelWidget.h>
 
 #include <GeomAPI_Pln.h>
+
 #include <SelectMgr_IndexedMapOfOwner.hxx>
+#include <SelectMgr_ListOfFilter.hxx>
+
 #include <TopoDS_Shape.hxx>
 #include <TopTools_MapOfShape.hxx>
 
@@ -194,11 +197,9 @@ public:
   /// \param theOperation a committed operation
   void commitNestedSketch(ModuleBase_Operation* theOperation);
 
-  /// Append the sketch selection filters in 3D viewer (plane and circle pointer)
-  void activateSelectionFilters();
-
-  // Remove sketch selection filter from the current viewer
-  virtual void deactivateSelectionFilters();
+  /// Appends into container of workshop selection filters
+  /// \param [out] selection filters
+  virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const;
 
   /// Append the sketch plane filter into the current viewer
   /// \param toActivate state whether the filter should be activated/deactivated
@@ -302,8 +303,9 @@ public:
   static const QStringList& constraintsIdList();
 
   /// Returns a list of modes, where the AIS objects should be activated
+  /// \param theSketch a sketch object, modes are empty if sketch plane is not defined yet
   /// \param theModes a list of modes
-  static void sketchSelectionModes(QIntList& theModes);
+  static void sketchSelectionModes(const CompositeFeaturePtr& theSketch, QIntList& theModes);
 
   /// Create specific for the module presentation
   /// \param theResult an object for presentation
index 5c4e1025735e16677eea0035593e502550291822..95ca672cd15e04c0edbc247859c22990dca23828 100644 (file)
@@ -32,6 +32,7 @@
 #include "GeomDataAPI_Point2D.h"
 
 #include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ISelectionActivate.h>
 #include <ModuleBase_OperationFeature.h>
 #include <ModuleBase_ModelWidget.h>
 #include <ModuleBase_ViewerPrs.h>
@@ -42,6 +43,7 @@
 #include <ModuleBase_OperationDescription.h>
 #include "ModuleBase_ToolBox.h"
 #include "ModuleBase_ISelection.h"
+#include "ModuleBase_ISelectionActivate.h"
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Line.h>
@@ -332,8 +334,9 @@ void PartSet_SketcherReentrantMgr::onWidgetActivated()
   ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel();
   if (aFirstWidget != aPanel->activeWidget()) {
     ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aFirstWidget);
-    if (aWSelector)
-      aWSelector->activateSelectionAndFilters(true);
+    if (aWSelector) {
+      myWorkshop->selectionActivate()->activateSelectionAndFilters(aWSelector);
+    }
   }
 }
 
@@ -660,7 +663,7 @@ void PartSet_SketcherReentrantMgr::deleteInternalFeature()
     ModuleBase_WidgetSelector* aWSelector =
       dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
     if (aWSelector)
-      aWSelector->activateSelectionAndFilters(false);
+      myWorkshop->selectionActivate()->activateSelectionAndFilters(aWSelector);
     myInternalActiveWidget = 0;
   }
   delete myInternalWidget;
index 2ee93fbb4ffbde724f2a9ff624178ccf2b22f62f..c39cc3cdec0ede3f4b168ddcb93e30a213ab54de 100644 (file)
@@ -86,7 +86,7 @@ bool PartSet_WidgetFeaturePointSelector::isValidSelection(
 }
 
 //********************************************************************
-bool PartSet_WidgetFeaturePointSelector::activateSelectionAndFilters(bool toActivate)
+void PartSet_WidgetFeaturePointSelector::activateSelectionAndFilters(bool toActivate)
 {
 #ifdef HIGHLIGHT_STAYS_PROBLEM
   Handle(AIS_InteractiveContext) aContext =
@@ -113,7 +113,7 @@ bool PartSet_WidgetFeaturePointSelector::activateSelectionAndFilters(bool toActi
 
 #endif
 
-  return ModuleBase_WidgetShapeSelector::activateSelectionAndFilters(toActivate);
+  ModuleBase_WidgetShapeSelector::activateSelectionAndFilters(toActivate);
 }
 
 //********************************************************************
index 12d897c37e868a03bc7544313e026cbd4c484022..ab4160bc6378375478850f3ad4016099e2d444cd 100644 (file)
@@ -74,7 +74,7 @@ Q_OBJECT
 
   /// Activate or deactivate selection and selection filters
   /// \return true if the selection filter of the widget is activated in viewer context
-  virtual bool activateSelectionAndFilters(bool toActivate);
+  virtual void activateSelectionAndFilters(bool toActivate);
 
   /// Set sketcher
   /// \param theSketch a sketcher object
index dc799cef9cd57be39cc2b542faceb8af0ade6af0..a4ba3b237bc34bd067abfdcabf22230fe4163816 100644 (file)
@@ -442,14 +442,17 @@ QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
   return aControls;
 }
 
+//********************************************************************
+void PartSet_WidgetPoint2D::selectionModes(QIntList& theModes, bool& isAdditional)
+{
+  theModes << TopAbs_VERTEX;
+  theModes << TopAbs_EDGE;
+  isAdditional = true;
+}
 
+//********************************************************************
 void PartSet_WidgetPoint2D::activateCustom()
 {
-  QIntList aModes;
-  aModes << TopAbs_VERTEX;
-  aModes << TopAbs_EDGE;
-  myWorkshop->activateSubShapesSelection(aModes);
-
   if (!isEditingMode()) {
     FeaturePtr aFeature = feature();
     if (aFeature.get() && aFeature->getKind() == SketchPlugin_Point::ID())
@@ -472,7 +475,6 @@ void PartSet_WidgetPoint2D::deactivate()
     storeValue();
 
   ModuleBase_ModelWidget::deactivate();
-  myWorkshop->deactivateSubShapesSelection();
 }
 
 bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
index 314308723a7354388c29984fcfbc1ba28a63931f..bfc060b62ef8cc8fc5a38bdc575f159a1667a1e9 100755 (executable)
@@ -68,6 +68,11 @@ Q_OBJECT
   /// Destructor
   virtual ~PartSet_WidgetPoint2D();
 
+  /// Fills given container with selection modes if the widget has it
+  /// \param theModes [out] a container of modes
+  /// \param isAdditional if true, the modes are combinated with the module ones
+  virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
   /// Checks if the selection presentation is valid in widget
   /// \param theValue a selected presentation in the view
   /// \return a boolean value
index c983d74252247b1419c8b4b584623be430192582..15a2571a29274cc6e3013dcda1840cf3c0e113e5 100755 (executable)
@@ -60,17 +60,15 @@ PartSet_WidgetShapeSelector::~PartSet_WidgetShapeSelector()
 }
 
 //********************************************************************
-bool PartSet_WidgetShapeSelector::activateSelectionAndFilters(bool toActivate)
+void PartSet_WidgetShapeSelector::activateSelectionAndFilters(bool toActivate)
 {
-  bool aHasSelectionFilter = ModuleBase_WidgetShapeSelector::activateSelectionAndFilters
-                                                                           (toActivate);
+  ModuleBase_WidgetShapeSelector::activateSelectionAndFilters(toActivate);
   if (!myUseSketchPlane) {
     XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
     PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(aWorkshop->module());
     bool isUsePlaneFilterOnly = !toActivate;
     aModule->sketchMgr()->activatePlaneFilter(isUsePlaneFilterOnly);
   }
-  return aHasSelectionFilter;
 }
 
 //********************************************************************
index 5d531c4733fa415090be722d70d76ba7a79bdea5..90fe78baec9c7bb6dcbfa3df1c61b6a34b25a1e7 100644 (file)
@@ -56,7 +56,7 @@ Q_OBJECT
 
   /// Activate or deactivate selection and selection filters
   /// \param toActivate boolean state whether it should be activated/deactivated
-  virtual bool activateSelectionAndFilters(bool toActivate);
+  virtual void activateSelectionAndFilters(bool toActivate);
 
 protected:
   /// Checks the widget validity. By default, it returns true.
index f31198234f3d9be6d5d423019c3021f3522d811f..7f9fc5adae6c9a4a3725f0d91e36e1138b66b86a 100644 (file)
@@ -327,10 +327,12 @@ bool PartSet_WidgetSketchCreator::setSelection(QList<ModuleBase_ViewerPrsPtr>& t
 }
 
 //********************************************************************
-void PartSet_WidgetSketchCreator::onSelectionChanged()
+bool PartSet_WidgetSketchCreator::processSelection()
 {
   QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
   bool isDone = setSelection(aSelected, true/*false*/);
+
+  return isDone;
 }
 
 //********************************************************************
index 58f8922dc391d4d3513af94f950b55c32929c76d..a37ec0d1dc63257a6f8dbaf275a1d0d3bcbc8e1b 100644 (file)
@@ -121,9 +121,9 @@ protected:
   /// \param theDone a state whether the selection is set
   void updateOnSelectionChanged(const bool theDone);
 
-protected slots:
-  /// Slot which is called on selection event
-  virtual void onSelectionChanged();
+protected:
+  /// Returns true if envent is processed.
+  virtual bool processSelection();
 
 private:
   /// Returns true if the selection mode is active. This is when composition feature has no
index d91cb5c26c4471329b86c1edf68b520d25d71043..b5ad01f40834b2e303f51067e2e1befb7733431b 100644 (file)
 
 #include "SketchPlugin_SketchEntity.h"
 
-#include <XGUI_Workshop.h>
+#include <XGUI_ActionsMgr.h>
 #include <XGUI_Displayer.h>
-#include <XGUI_SelectionMgr.h>
+#include <XGUI_ModuleConnector.h>
+#include <XGUI_SelectionActivate.h>
 #include <XGUI_Selection.h>
-#include <XGUI_ViewerProxy.h>
-#include <XGUI_ActionsMgr.h>
+#include <XGUI_SelectionMgr.h>
 #include <XGUI_Tools.h>
-#include <XGUI_ModuleConnector.h>
+#include <XGUI_ViewerProxy.h>
+#include <XGUI_Workshop.h>
+
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_Tools.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_ViewerPrs.h>
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_IModule.h>
 
-#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_Tools.h>
-
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 #include <GeomDataAPI_Point.h>
@@ -193,22 +194,24 @@ QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
   return aResult;
 }
 
-void PartSet_WidgetSketchLabel::onSelectionChanged()
+bool PartSet_WidgetSketchLabel::processSelection()
 {
   std::shared_ptr<GeomAPI_Pln> aPlane = plane();
   if (aPlane.get())
-    return;
+    return false;
 
   QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
 
   if (aSelected.empty())
-    return;
+    return false;
   ModuleBase_ViewerPrsPtr aPrs = aSelected.first();
   bool aDone = setSelectionInternal(aSelected, false);
   if (aDone) {
     updateByPlaneSelected(aPrs);
     updateObject(myFeature);
   }
+
+  return aDone;
 }
 
 void PartSet_WidgetSketchLabel::onShowConstraint(bool theOn)
@@ -360,15 +363,14 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
   //myLabel->setText("");
   //myLabel->setToolTip("");
   XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-  // 4. deactivate face selection filter
-  activateFilters(false);
 
   // 5. Clear selection mode and define sketching mode
   emit planeSelected(plane());
   // after the plane is selected in the sketch, the sketch selection should be activated
   // it can not be performed in the sketch label widget because, we don't need to switch off
   // the selection by any label deactivation, but need to switch it off by stop the sketch
-  activateSelection(true);
+  myWorkshop->selectionActivate()->updateSelectionFilters();
+  myWorkshop->selectionActivate()->updateSelectionModes();
 
   // 6. Update sketcher actions
   XGUI_ActionsMgr* anActMgr = aWorkshop->actionsMgr();
@@ -451,18 +453,6 @@ bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrsPtr& the
   return aCanFillSketch;
 }
 
-//********************************************************************
-bool PartSet_WidgetSketchLabel::processAction(ModuleBase_ActionType theActionType,
-                                              const ActionParamPtr& theParam)
-{
-  if (theActionType == ActionSelection)
-    onSelectionChanged();
-  else
-    return ModuleBase_WidgetValidated::processAction(theActionType, theParam);
-
-  return true;
-}
-
 bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const ModuleBase_ViewerPrsPtr& thePrs)
 {
   bool isOwnerSet = false;
@@ -506,7 +496,6 @@ void PartSet_WidgetSketchLabel::activateCustom()
   std::shared_ptr<GeomAPI_Pln> aPlane = plane();
   if (aPlane.get()) {
     myStackWidget->setCurrentIndex(1);
-    activateSelection(true);
     return;
   }
 
@@ -516,7 +505,7 @@ void PartSet_WidgetSketchLabel::activateCustom()
   // Clear previous selection mode It is necessary for correct activation of preview planes
   XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
   XGUI_Displayer* aDisp = aWorkshop->displayer();
-  aDisp->activateObjects(QIntList(), aDisp->displayedObjects(), false);
+  aWorkshop->selectionActivate()->activateObjects(QIntList(), aDisp->displayedObjects(), false);
 
   if (!aBodyIsVisualized) {
     // We have to select a plane before any operation
@@ -525,40 +514,33 @@ void PartSet_WidgetSketchLabel::activateCustom()
   }
   else
     mySizeOfViewWidget->setVisible(false);
-
-  activateSelection(true);
-  activateFilters(true);
 }
 
 void PartSet_WidgetSketchLabel::deactivate()
 {
-  ModuleBase_ModelWidget::deactivate();
+  ModuleBase_WidgetValidated::deactivate();
   bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
   myPreviewPlanes->erasePreviewPlanes(myWorkshop);
-  activateSelection(false);
 
-  activateFilters(false);
   if (aHidePreview)
     myWorkshop->viewer()->update();
 }
 
-void PartSet_WidgetSketchLabel::activateSelection(bool toActivate)
+void PartSet_WidgetSketchLabel::selectionModes(QIntList& theModes, bool& isAdditional)
 {
-  if (toActivate) {
-    QIntList aModes;
-    std::shared_ptr<GeomAPI_Pln> aPlane = plane();
-    if (aPlane.get()) {
-      myWorkshop->module()->activeSelectionModes(aModes);
-    }
-    else {
-      aModes << TopAbs_FACE;
-    }
-    myWorkshop->activateSubShapesSelection(aModes);
-  } else {
-    myWorkshop->deactivateSubShapesSelection();
-  }
+  std::shared_ptr<GeomAPI_Pln> aPlane = plane();
+  if (!aPlane.get())
+    theModes << TopAbs_FACE;
+  isAdditional = true;
 }
 
+void PartSet_WidgetSketchLabel::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
+{
+  std::shared_ptr<GeomAPI_Pln> aPlane = plane();
+  if (aPlane.get())
+    return;
+  return ModuleBase_WidgetValidated::selectionFilters(theSelectionFilters);
+}
 
 std::shared_ptr<GeomAPI_Dir>
   PartSet_WidgetSketchLabel::setSketchPlane(const TopoDS_Shape& theShape)
index af0b81f841a6793d01eae0abf6978e3639364666..a9869882ce4606263f0b8706864dccb1c5ed45a7 100644 (file)
@@ -73,6 +73,15 @@ public:
   virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
                             const bool theToValidate);
 
+  /// Fills given container with selection modes if the widget has it
+  // \param theModes [out] a container of modes
+  /// \param isAdditional if true, the modes are combinated with the module ones
+  virtual void selectionModes(QIntList& theModes, bool& isAdditional);
+
+  /// Using widget selection filter only if plane is not defined.
+  /// \param [out] selection filters
+  virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
   /// Returns list of widget controls
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
@@ -95,10 +104,6 @@ public:
   /// \param thePrs a presentation
   static bool canFillSketch(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
 
-  /// Processes Selection action.
-  virtual bool processAction(ModuleBase_ActionType theActionType,
-                             const ActionParamPtr& theParam);
-
 signals:
   /// Signal on plane selection
   void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
@@ -157,6 +162,9 @@ protected:
                               bool& isAttributeSetInitializedBlocked,
                               bool& isAttributeSendUpdatedBlocked);
 
+  /// Returns true if envent is processed.
+  virtual bool processSelection();
+
   /// Set the given wrapped value to the current widget
   /// This value should be processed in the widget according to the needs
   /// The method is called by the current operation to process the operation preselection.
@@ -175,14 +183,6 @@ protected:
   /// \param thePrs a presentation
   bool fillSketchPlaneBySelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
 
- protected:
-  /// Activate or deactivate selection
-  void activateSelection(bool toActivate);
-
- private:
-   /// Slot on change selection
-  void onSelectionChanged();
-
 private slots:
   /// A slot called on set sketch plane view
   void onSetPlaneView();
@@ -191,7 +191,7 @@ private slots:
   /// \param theOn a flag show constraints or not
   void onShowConstraint(bool theOn);
 
- private:
+private:
   /// Set sketch plane by shape
   /// \param theShape a planar face
   std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
index 19aa0fc1c49a34493c4d75877bb1fa7b60f72424..20524c9030f8fa31d56b65aa199c8ec559f6b905 100644 (file)
@@ -31,6 +31,7 @@
 #include <XGUI_Displayer.h>
 #include <XGUI_MenuMgr.h>
 #include <XGUI_FacesPanel.h>
+#include <XGUI_SelectionActivate.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_Preferences.h>
@@ -353,7 +354,8 @@ void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr)
 {
   if (!mySelector) {
     mySelector = createSelector(theMgr);
-    myWorkshop->module()->activateSelectionFilters();
+    myWorkshop->selectionActivate()->updateSelectionFilters();
+    myWorkshop->selectionActivate()->updateSelectionModes();
     myWorkshop->synchronizeViewer();
   }
 }
index 2175e6a780c68cf81a80946eb96711d2cc4cec78..f9f5fb5bede2e9af4f36f7f87322dd57fdfe32a3 100755 (executable)
@@ -77,6 +77,7 @@ ADD_LIBRARY(SamplePanelPlugin MODULE
 TARGET_LINK_LIBRARIES(SamplePanelPlugin ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
+  ${CAS_INCLUDE_DIRS}
   ../Config
   ../Events
   ../ModelAPI
index 9380b2688f71640e1e1edffb1094a264036a10e6..3a62858820ff7f4de2c0215aa08da3ae184d6769 100644 (file)
@@ -54,6 +54,7 @@ SET(PROJECT_HEADERS
     XGUI_QtEvents.h
     XGUI_SalomeConnector.h
     XGUI_Selection.h
+    XGUI_SelectionActivate.h
     XGUI_SelectionMgr.h
     XGUI_Tools.h
     XGUI_TransparencyWidget.h
@@ -118,6 +119,7 @@ SET(PROJECT_SOURCES
     XGUI_QtEvents.cpp
     XGUI_SalomeConnector.cpp
     XGUI_Selection.cpp
+    XGUI_SelectionActivate.cpp
     XGUI_SelectionMgr.cpp
     XGUI_Tools.cpp
     XGUI_TransparencyWidget.cpp
index 7c2fc833b817d76264125a64cb432bcbb4070bef..13c789c25b5f457ed82620fe76b1fc59c0a2dca6 100644 (file)
 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
 //
 
-#include <XGUI_ActiveControlMgr.h>
-#include <XGUI_ActiveControlSelector.h>
+#include "XGUI_ActiveControlMgr.h"
+#include "XGUI_ActiveControlSelector.h"
+#include "XGUI_SelectionActivate.h"
+#include "XGUI_Tools.h"
+#include "XGUI_Workshop.h"
+
 
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_IWorkshop.h>
@@ -64,6 +68,8 @@ void XGUI_ActiveControlMgr::onSelectorActivated()
     myActiveSelector->setActive(false);
 
   activateSelector(aSelector);
+  XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionModes();
+  XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionFilters();
 }
 
 //********************************************************************
@@ -76,7 +82,6 @@ void XGUI_ActiveControlMgr::onSelectorDeactivated()
   myActiveSelector = NULL;
 
   aSelector->setActive(false);
-  myWorkshop->module()->updateActiveSelectionFilters();
 
   XGUI_ActiveControlSelector* aSelectorToBeActivated = 0;
   for (int i = 0, aCount = mySelectors.count(); i < aCount; i++)
@@ -88,6 +93,9 @@ void XGUI_ActiveControlMgr::onSelectorDeactivated()
   }
   if (aSelectorToBeActivated)
     activateSelector(aSelectorToBeActivated);
+
+  XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionModes();
+  XGUI_Tools::workshop(myWorkshop)->selectionActivate()->updateSelectionFilters();
 }
 
 //********************************************************************
@@ -104,6 +112,4 @@ void XGUI_ActiveControlMgr::activateSelector(XGUI_ActiveControlSelector* theSele
 {
   myActiveSelector = theSelector;
   theSelector->setActive(true);
-
-  myWorkshop->module()->updateActiveSelectionFilters();
 }
index 4d97e46d0dd67020cd2760875188e42cbb54a1b2..47aeb1ba75474d746223196e6d41080b7dbace26 100644 (file)
@@ -24,8 +24,9 @@
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_Displayer.h"
 #include "XGUI_ViewerProxy.h"
-#include "XGUI_Selection.h"
 #include "XGUI_SalomeConnector.h"
+#include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
 #include "XGUI_DataModel.h"
 #include "XGUI_OperationMgr.h"
 #include "XGUI_Tools.h"
@@ -541,7 +542,7 @@ void XGUI_ContextMenuMgr::updateViewerMenu()
 #endif
 
   // Update selection menu
-  QIntList aModes = aDisplayer->activeSelectionModes();
+  QIntList aModes = myWorkshop->selectionActivate()->activeSelectionModes();
   action("SELECT_VERTEX_CMD")->setEnabled(true);
   action("SELECT_EDGE_CMD")->setEnabled(true);
   action("SELECT_FACE_CMD")->setEnabled(true);
@@ -781,9 +782,8 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const
 
   // Create selection menu
   XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
-  QIntList aModes;
-  myWorkshop->module()->activeSelectionModes(aModes);
-  if ((!aOpMgr->hasOperation()) && aModes.isEmpty()) {
+  if (!aOpMgr->hasOperation() &&
+      myWorkshop->selectionActivate()->activeSelectionPlace() == XGUI_SelectionActivate::Workshop) {
     QMenu* aSelMenu = new QMenu(tr("Selection mode"), theMenu);
     aSelMenu->addAction(action("SELECT_VERTEX_CMD"));
     aSelMenu->addAction(action("SELECT_EDGE_CMD"));
index 2652ae0ed1753caa9e7f863862942f59b2ba4247..7028e4a352baa2f520b64c54c63a6547a8d3dd7c 100644 (file)
 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
 //
 
-#include "XGUI_CustomPrs.h"
 #include "XGUI_Displayer.h"
+
+#include "XGUI_CustomPrs.h"
 #include "XGUI_FacesPanel.h"
 #include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_Workshop.h"
 #include <AIS_Point.hxx>
 #endif
 #include <AIS_Selection.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <SelectMgr_ListOfFilter.hxx>
-#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_IsoAspect.hxx>
+#include <SelectMgr_ListOfFilter.hxx>
+#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 #include <SelectMgr_SelectionManager.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
 
 #include <StdSelect_ViewerSelector3d.hxx>
 
 /// defines the local context mouse selection sensitivity
 const int MOUSE_SENSITIVITY_IN_PIXEL = 10;
 
-//#define DEBUG_ACTIVATE_OBJECTS
-//#define DEBUG_DEACTIVATE
-//#define DEBUG_ACTIVATE_AIS
-//#define DEBUG_DEACTIVATE_AIS
-
 //#define DEBUG_DISPLAY
 //#define DEBUG_FEATURE_REDISPLAY
 //#define DEBUG_SELECTION_FILTERS
@@ -102,6 +99,7 @@ const int MOUSE_SENSITIVITY_IN_PIXEL = 10;
 
 #define CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
 
+//**************************************************************
 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
 {
   // Get from null point
@@ -118,44 +116,26 @@ QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QS
   return anInfo.join(theSeparator);
 }
 
-void deselectPresentation(const Handle(AIS_InteractiveObject) theObject,
-                          const Handle(AIS_InteractiveContext)& theContext)
-{
-  NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
-
-  for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected()) {
-    Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
-    if (anOwner.IsNull()) // TODO: check why it is possible
-      continue;
-    if (anOwner->Selectable() == theObject && anOwner->IsSelected())
-      aResultOwners.Append(anOwner);
-  }
-  NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (aResultOwners);
-  Handle(SelectMgr_EntityOwner) anOwner;
-  for (; anOwnersIt.More(); anOwnersIt.Next()) {
-    anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
-    if (!anOwner.IsNull())
-      theContext->AddOrRemoveSelected(anOwner, false);
-  }
-}
-
+//**************************************************************
 XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
-  : myWorkshop(theWorkshop), myNeedUpdate(false),
-  myIsTrihedronActive(true), myViewerBlockedRecursiveCount(0),
-  myIsFirstAISContextUse(true)
+: myWorkshop(theWorkshop), myNeedUpdate(false),
+  myViewerBlockedRecursiveCount(0), myIsFirstAISContextUse(true)
 {
   myCustomPrs = std::shared_ptr<GeomAPI_ICustomPrs>(new XGUI_CustomPrs(theWorkshop));
 }
 
+//**************************************************************
 XGUI_Displayer::~XGUI_Displayer()
 {
 }
 
+//**************************************************************
 bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
 {
   return myResult2AISObjectMap.contains(theObject);
 }
 
+//**************************************************************
 bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
 {
   bool aDisplayed = false;
@@ -237,6 +217,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
   return aDisplayed;
 }
 
+//**************************************************************
 bool canBeShaded(Handle(AIS_InteractiveObject) theAIS, ModuleBase_IModule* theModule)
 {
   Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(theAIS);
@@ -255,6 +236,7 @@ bool canBeShaded(Handle(AIS_InteractiveObject) theAIS, ModuleBase_IModule* theMo
   return false;
 }
 
+//**************************************************************
 bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
                              bool isShading, bool theUpdateViewer)
 {
@@ -281,7 +263,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
     aDisplayed = true;
 
     emit objectDisplayed(theObject, theAIS);
-    activate(anAISIO, myActiveSelectionModes, theUpdateViewer);
+    selectionActivate()->activate(anAISIO, theUpdateViewer);
   }
   if (theUpdateViewer)
     updateViewer();
@@ -289,6 +271,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
   return aDisplayed;
 }
 
+//**************************************************************
 bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer)
 {
   bool aErased = false;
@@ -326,6 +309,7 @@ bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer)
   return aErased;
 }
 
+//**************************************************************
 bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
 {
   bool aRedisplayed = false;
@@ -384,7 +368,7 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
         myWorkshop->module()->storeSelection();
 
 #ifdef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
-      deselectPresentation(aAISIO, aContext);
+      myWorkshop->selector()->deselectPresentation(aAISIO);
 #endif
       aContext->Redisplay(aAISIO, false);
 
@@ -406,6 +390,7 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
   return aRedisplayed;
 }
 
+//**************************************************************
 void XGUI_Displayer::redisplayObjects()
 {
   // redisplay objects visualized in the viewer
@@ -419,30 +404,7 @@ void XGUI_Displayer::redisplayObjects()
   Events_Loop::loop()->flush(EVENT_DISP);
 }
 
-void XGUI_Displayer::deactivate(ObjectPtr theObject, const bool theUpdateViewer)
-{
-#ifdef DEBUG_DEACTIVATE
-  QString anInfoStr = ModuleBase_Tools::objectInfo(theObject);
-  qDebug(QString("deactivate: myActiveSelectionModes[%1]: %2, objects = ").
-    arg(myActiveSelectionModes.size()).arg(qIntListInfo(myActiveSelectionModes)).
-    arg(anInfoStr).
-    toStdString().c_str());
-#endif
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull() && isVisible(theObject)) {
-    AISObjectPtr anObj = myResult2AISObjectMap[theObject];
-    Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
-
-    deactivateAIS(anAIS);
-    // the selection from the previous activation modes should be cleared manually (#26172)
-#ifndef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
-    deselectPresentation(anAIS, aContext);
-#endif
-    if (theUpdateViewer)
-      updateViewer();
-  }
-}
-
+//**************************************************************
 void XGUI_Displayer::deactivateObjects(const QObjectPtrList& theObjList,
                                        const bool theUpdateViewer)
 {
@@ -452,38 +414,14 @@ void XGUI_Displayer::deactivateObjects(const QObjectPtrList& theObjList,
 
   QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end();
   for (; anIt != aLast; anIt++) {
-    deactivate(*anIt, false);
+    selectionActivate()->deactivate(*anIt, false);
   }
   //VSV It seems that there is no necessity to update viewer on deactivation
   //if (theUpdateViewer)
   //  updateViewer();
 }
 
-void XGUI_Displayer::getModesOfActivation(ObjectPtr theObject, QIntList& theModes)
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (aContext.IsNull() || !isVisible(theObject))
-    return;
-
-  AISObjectPtr aAISObj = getAISObject(theObject);
-
-  if (aAISObj.get() != NULL) {
-    Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
-    TColStd_ListOfInteger aTColModes;
-    aContext->ActivatedModes(anAISIO, aTColModes);
-    TColStd_ListIteratorOfListOfInteger itr( aTColModes );
-    for (; itr.More(); itr.Next() ) {
-      theModes.append(itr.Value());
-    }
-  }
-}
-
-int XGUI_Displayer::getSelectionMode(int theShapeType)
-{
-  return (theShapeType > TopAbs_SHAPE) ? theShapeType :
-                                         AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theShapeType);
-}
-
+//**************************************************************
 bool XGUI_Displayer::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject)
 {
   bool aVisible = false;
@@ -522,127 +460,7 @@ bool XGUI_Displayer::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& th
   return aVisible;
 }
 
-#ifdef DEBUG_ACTIVATE_OBJECTS
-QString getModeInfo(const int theMode)
-{
-  QString anInfo = "Undefined";
-  switch(theMode) {
-    case 0: anInfo = "SHAPE(0)"; break;
-    case 1: anInfo = "VERTEX(1)"; break;
-    case 2: anInfo = "EDGE(2)"; break;
-    case 3: anInfo = "WIRE(3)"; break;
-    case 4: anInfo = "FACE(4)"; break;
-    case 5: anInfo = "SHELL(5)"; break;
-    case 6: anInfo = "SOLID(6)"; break;
-    case 7: anInfo = "COMPSOLID(7)"; break;
-    case 8: anInfo = "COMPOUND(8)"; break;
-    case 100: anInfo = "Sel_Mode_First(100)"; break; //SketcherPrs_Tools
-    case 101: anInfo = "Sel_Constraint(101)"; break;
-    case 102: anInfo = "Sel_Dimension_All(102)"; break;
-    case 103: anInfo = "Sel_Dimension_Line(103)"; break;
-    case 104: anInfo = "Sel_Dimension_Text(104)"; break;
-    default: break;
-  }
-  return anInfo;
-}
-
-QString getModesInfo(const QIntList& theModes)
-{
-  QStringList aModesInfo;
-  for (int i = 0, aSize = theModes.size(); i < aSize; i++)
-    aModesInfo.append(getModeInfo(theModes[i]));
-  return QString("[%1] = %2").arg(aModesInfo.size()).arg(aModesInfo.join(", "));
-}
-#endif
-
-void XGUI_Displayer::activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
-                                     const bool theUpdateViewer)
-{
-  // Convert shape types to selection types
-  QIntList aModes;
-  foreach(int aType, theModes) {
-    aModes.append(getSelectionMode(aType));
-  }
-
-#ifdef DEBUG_ACTIVATE_OBJECTS
-  QStringList anInfo;
-  QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end();
-  for (; anIt != aLast; ++anIt) {
-    anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
-  }
-  QString anInfoStr = anInfo.join(", ");
-
-  qDebug(QString("activateObjects: new modes%1, active modes%2, objects[%3] = %4").
-    arg(getModesInfo(aModes)).
-    arg(getModesInfo(myActiveSelectionModes)).
-    arg(theObjList.size()).
-    arg(anInfoStr).
-    toStdString().c_str());
-#endif
-  // In order to avoid doblications of selection modes
-  QIntList aNewModes;
-  foreach (int aMode, aModes) {
-    if (!aNewModes.contains(aMode))
-      aNewModes.append(aMode);
-  }
-  myActiveSelectionModes = aNewModes;
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  // Open local context if there is no one
-  if (aContext.IsNull())
-    return;
-
-  //aContext->UseDisplayedObjects();
-  //myUseExternalObjects = true;
-
-  Handle(AIS_InteractiveObject) anAISIO;
-  AIS_ListOfInteractive aPrsList;
-  //if (aObjList.isEmpty())
-  //  return;
-  //else {
-  foreach(ObjectPtr aObj, theObjList) {
-    if (myResult2AISObjectMap.contains(aObj))
-      aPrsList.Append(myResult2AISObjectMap[aObj]->impl<Handle(AIS_InteractiveObject)>());
-  }
-  //}
-
-  // Add trihedron because it has to partisipate in selection
-  Handle(AIS_InteractiveObject) aTrihedron;
-  if (isTrihedronActive()) {
-    aTrihedron = getTrihedron();
-    if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron))
-      aPrsList.Append(aTrihedron);
-  }
-  if (aPrsList.Extent() == 0)
-    return;
-
-  AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
-  bool isActivationChanged = false;
-  for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
-    anAISIO = aLIt.Value();
-    if (activate(anAISIO, myActiveSelectionModes, false))
-      isActivationChanged = true;
-  }
-}
-
-bool XGUI_Displayer::isActive(ObjectPtr theObject) const
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (aContext.IsNull() || !isVisible(theObject))
-    return false;
-
-  AISObjectPtr anObj = myResult2AISObjectMap[theObject];
-  Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
-
-  TColStd_ListOfInteger aModes;
-  aContext->ActivatedModes(anAIS, aModes);
-  #ifdef TINSPECTOR
-  if (getCallBack()) getCallBack()->ActivatedModes(anAIS, aModes);
-  #endif
-
-  return aModes.Extent() > 0;
-}
-
-
+//**************************************************************
 void XGUI_Displayer::setSelected(const  QList<ModuleBase_ViewerPrsPtr>& theValues,
                                  bool theUpdateViewer)
 {
@@ -705,6 +523,7 @@ void XGUI_Displayer::setSelected(const  QList<ModuleBase_ViewerPrsPtr>& theValue
     updateViewer();
 }
 
+//**************************************************************
 void XGUI_Displayer::clearSelected(const bool theUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -717,6 +536,7 @@ void XGUI_Displayer::clearSelected(const bool theUpdateViewer)
   }
 }
 
+//**************************************************************
 bool XGUI_Displayer::eraseAll(const bool theUpdateViewer)
 {
   bool aErased = false;
@@ -746,169 +566,8 @@ bool XGUI_Displayer::eraseAll(const bool theUpdateViewer)
   return aErased;
 }
 
-void deactivateObject(Handle(AIS_InteractiveContext) theContext,
-                      Handle(AIS_InteractiveObject) theObject
-#ifdef TINSPECTOR
-                      , Handle(VInspectorAPI_CallBack) theCallBack
-#endif
-                      )
-{
-  if (!theObject.IsNull()) {
-    theContext->Deactivate(theObject);
-    #ifdef TINSPECTOR
-    if (theCallBack) theCallBack->Deactivate(theObject);
-    #endif
-  }
-}
-
-void XGUI_Displayer::deactivateTrihedron(const bool theUpdateViewer) const
-{
-  Handle(AIS_InteractiveObject) aTrihedron = getTrihedron();
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron)) {
-    Handle(AIS_Trihedron) aTrie = Handle(AIS_Trihedron)::DownCast(aTrihedron);
-    deactivateObject(aContext, aTrie
-    #ifdef TINSPECTOR
-      , getCallBack()
-    #endif
-      );
-
-    /// #1136 hidden axis are selected in sketch
-#ifdef BEFORE_TRIHEDRON_PATCH
-    deactivateObject(aContext, aTrie->XAxis()
-    #ifdef TINSPECTOR
-      , getCallBack()
-    #endif
-    );
-    deactivateObject(aContext, aTrie->YAxis()
-    #ifdef TINSPECTOR
-      , getCallBack()
-    #endif
-    );
-    deactivateObject(aContext, aTrie->Axis()
-    #ifdef TINSPECTOR
-      , getCallBack()
-    #endif
-    );
-    deactivateObject(aContext, aTrie->Position()
-    #ifdef TINSPECTOR
-      , getCallBack()
-    #endif
-    );
-
-    deactivateObject(aContext, aTrie->XYPlane()
-    #ifdef TINSPECTOR
-      , getCallBack()
-    #endif
-    );
-    deactivateObject(aContext, aTrie->XZPlane()
-    #ifdef TINSPECTOR
-      , getCallBack()
-    #endif
-    );
-    deactivateObject(aContext, aTrie->YZPlane()
-    #ifdef TINSPECTOR
-      , getCallBack()
-    #endif
-    );
-#endif
-    if (theUpdateViewer)
-      updateViewer();
-  }
-}
-
-Handle(AIS_InteractiveObject) XGUI_Displayer::getTrihedron() const
-{
-  return myWorkshop->viewer()->trihedron();
-}
-
-/*void XGUI_Displayer::openLocalContext()
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  // Open local context if there is no one
-  if (!aContext.IsNull() && !aContext->HasOpenedContext()) {
-    // Preserve selected objects
-    //AIS_ListOfInteractive aAisList;
-    //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
-    //  aAisList.Append(aContext->Current());
-
-    // get the filters from the global context and append them to the local context
-    // a list of filters in the global context is not cleared and should be cleared here
-    SelectMgr_ListOfFilter aFilters;
-    aFilters.Assign(aContext->Filters());
-    // it is important to remove the filters in the global context, because there is a code
-    // in the closeLocalContex, which restore the global context filters
-    aContext->RemoveFilters();
-
-    //aContext->ClearCurrents();
-    aContext->OpenLocalContext();
-    //deactivateTrihedron();
-    //aContext->NotUseDisplayedObjects();
-
-    //myUseExternalObjects = false;
-
-    SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
-    for (;aIt.More(); aIt.Next()) {
-      aContext->AddFilter(aIt.Value());
-    }
-    // Restore selection
-    //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
-    //for(; aIt2.More(); aIt2.Next()) {
-    //  aContext->SetSelected(aIt2.Value(), false);
-    //}
-  }
-}*/
-
-/*void XGUI_Displayer::closeLocalContexts(const bool theUpdateViewer)
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull() && aContext->HasOpenedContext()) {
-    // Preserve selected objects
-    //AIS_ListOfInteractive aAisList;
-    //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
-    //  aAisList.Append(aContext->SelectedInteractive());
-
-    // get the filters from the local context and append them to the global context
-    // a list of filters in the local context is cleared
-    SelectMgr_ListOfFilter aFilters;
-    aFilters.Assign(aContext->Filters());
-
-    //aContext->ClearSelected();
-    aContext->CloseAllContexts(false);
-
-    // From the moment when the AIS_DS_Displayed flag is used in the Display of AIS object,
-    // this code is obsolete. It is temporaty commented and should be removed after
-    // the test campaign.
-    // Redisplay all object if they were displayed in localContext
-    /*Handle(AIS_InteractiveObject) aAISIO;
-    foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
-      aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
-      if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
-        aContext->Display(aAISIO, false);
-        aContext->SetDisplayMode(aAISIO, Shading, false);
-      }
-    }*+/
-
-    // Append the filters from the local selection in the global selection context
-    SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
-    for (;aIt.More(); aIt.Next()) {
-      Handle(SelectMgr_Filter) aFilter = aIt.Value();
-      aContext->AddFilter(aFilter);
-    }
-
-    if (theUpdateViewer)
-      updateViewer();
-    //myUseExternalObjects = false;
-
-    // Restore selection
-    //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
-    //for(; aIt2.More(); aIt2.Next()) {
-    //  if (aContext->IsDisplayed(aIt2.Value()))
-    //    aContext->SetCurrentObject(aIt2.Value(), false);
-    //}
-  }
-}*/
 
+//**************************************************************
 AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
 {
   AISObjectPtr anIO;
@@ -917,12 +576,14 @@ AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
   return anIO;
 }
 
+//**************************************************************
 ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
 {
   Handle(AIS_InteractiveObject) aRefAIS = theIO->impl<Handle(AIS_InteractiveObject)>();
   return getObject(aRefAIS);
 }
 
+//**************************************************************
 ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
 {
   ObjectPtr anObject;
@@ -944,6 +605,7 @@ ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO)
   return anObject;
 }
 
+//**************************************************************
 bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
 {
   bool aWasEnabled = isUpdateEnabled();
@@ -959,11 +621,13 @@ bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled)
   return aWasEnabled;
 }
 
+//**************************************************************
 bool XGUI_Displayer::isUpdateEnabled() const
 {
   return myViewerBlockedRecursiveCount == 0;
 }
 
+//**************************************************************
 void XGUI_Displayer::updateViewer() const
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -975,93 +639,22 @@ void XGUI_Displayer::updateViewer() const
   }
 }
 
-void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO,
-                                 const int theMode, const bool theUpdateViewer) const
-{
-  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  if (!theIO.IsNull() && theIO == getTrihedron()) {
-    if (theMode != AIS_Shape::SelectionType(TopAbs_EDGE) &&
-        theMode != AIS_Shape::SelectionType(TopAbs_VERTEX))
-      return;
-  }
-  if (!aContext.IsNull()) {
-    if (myWorkshop->module()) {
-      int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode);
-      aContext->Activate(theIO, theMode, false);
-    } else
-      aContext->Activate(theIO, theMode, false);
-    #ifdef TINSPECTOR
-    if (getCallBack()) 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;
-      if (theMode == getSelectionMode(TopAbs_VERTEX))
-        aPrecision = ModuleBase_Preferences::resourceMgr()->doubleValue("Viewer",
-                                                                    "point-selection-sensitivity",
-                                                                        12);
-      else if ((theMode == getSelectionMode(TopAbs_EDGE)) ||
-               (theMode == getSelectionMode(TopAbs_WIRE)))
-        aPrecision = theIO->Width() +
-           ModuleBase_Preferences::resourceMgr()->doubleValue("Viewer",
-                                                              "edge-selection-sensitivity", 2);
-      aContext->SetSelectionSensitivity(theIO, theMode, aPrecision);
-    }
-
-#ifdef DEBUG_ACTIVATE_AIS
-    ObjectPtr anObject = getObject(theIO);
-    anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
-    qDebug(QString("activateAIS: theMode = %1, object = %2").arg(theMode)
-      .arg(anInfo).toStdString().c_str());
-#endif
-    if (theUpdateViewer)
-      updateViewer();
-  }
-}
-
-void XGUI_Displayer::deactivateAIS(const Handle(AIS_InteractiveObject)& theIO,
-                                   const int theMode) const
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull()) {
-    if (theMode == -1) {
-      aContext->Deactivate(theIO);
-      #ifdef TINSPECTOR
-      if (getCallBack()) getCallBack()->Deactivate(theIO);
-      #endif
-    }
-    else {
-      aContext->Deactivate(theIO, theMode);
-      #ifdef TINSPECTOR
-      if (getCallBack()) getCallBack()->Deactivate(theIO, theMode);
-      #endif
-    }
-
-#ifdef DEBUG_DEACTIVATE_AIS
-    ObjectPtr anObject = getObject(theIO);
-    anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
-    qDebug(QString("deactivateAIS: theMode = %1, object = %2").arg(theMode)
-      .arg(anInfo).toStdString().c_str());
-#endif
-  }
-}
-
+//**************************************************************
 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
 {
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if (!aContext.IsNull() && myIsFirstAISContextUse/*&& !aContext->HasOpenedContext()*/) {
     XGUI_Displayer* aDisplayer = (XGUI_Displayer*)this;
     aDisplayer->myIsFirstAISContextUse = false;
-    //aContext->OpenLocalContext();
-    if (!isTrihedronActive())
-      deactivateTrihedron(true);
+    if (!myWorkshop->selectionActivate()->isTrihedronActive())
+      selectionActivate()->deactivateTrihedron(true);
     aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0);
     aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0);
   }
   return aContext;
 }
 
+//**************************************************************
 Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -1072,6 +665,7 @@ Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
   return myAndFilter;
 }
 
+//**************************************************************
 bool XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSelectionModes,
                                 const Standard_Integer theDisplayMode, bool theUpdateViewer)
 {
@@ -1092,21 +686,16 @@ bool XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSele
     #ifdef TINSPECTOR
     if (getCallBack()) getCallBack()->Load(anAISIO);
     #endif
-    if (toActivateInSelectionModes) {
-      if (myActiveSelectionModes.size() == 0)
-        activateAIS(anAISIO, 0, theUpdateViewer);
-      else {
-        foreach(int aMode, myActiveSelectionModes) {
-          activateAIS(anAISIO, aMode, theUpdateViewer);
-        }
-      }
-    }
+    if (toActivateInSelectionModes)
+      myWorkshop->selectionActivate()->activateOnDisplay(anAISIO, theUpdateViewer);
+
     if (theUpdateViewer)
       updateViewer();
   }
   return aDisplayed;
 }
 
+//**************************************************************
 bool XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool theUpdateViewer)
 {
   bool aErased = false;
@@ -1126,7 +715,7 @@ bool XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool theUpdateViewer)
   return aErased;
 }
 
-
+//**************************************************************
 void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool theUpdateViewer)
 {
   if (theMode == NoMode)
@@ -1147,6 +736,7 @@ void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bo
     updateViewer();
 }
 
+//**************************************************************
 XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -1161,7 +751,8 @@ XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) con
   return (XGUI_Displayer::DisplayMode) aAISIO->DisplayMode();
 }
 
-void XGUI_Displayer::deactivateSelectionFilters()
+//**************************************************************
+void XGUI_Displayer::deactivateSelectionFilters(const bool theAddFilterOnly)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (!myAndFilter.IsNull()) {
@@ -1180,6 +771,7 @@ void XGUI_Displayer::deactivateSelectionFilters()
   }
 }
 
+//**************************************************************
 void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -1196,6 +788,7 @@ void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilte
   }
 }
 
+//**************************************************************
 void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -1213,6 +806,7 @@ void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFi
   }
 }
 
+//**************************************************************
 bool XGUI_Displayer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
 {
   bool aFilterFound = false;
@@ -1237,6 +831,7 @@ bool XGUI_Displayer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilte
   return aFilterFound;
 }
 
+//**************************************************************
 void XGUI_Displayer::removeFilters()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -1248,6 +843,7 @@ void XGUI_Displayer::removeFilters()
     aCompositeFilter->Clear();
 }
 
+//**************************************************************
 void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
 {
   QObjectPtrList aDispList = myResult2AISObjectMap.keys();
@@ -1262,6 +858,7 @@ void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
   updateViewer();
 }
 
+//**************************************************************
 bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
 {
   if (!isVisible(theObject))
@@ -1275,98 +872,7 @@ bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
   return ::canBeShaded(anAIS, myWorkshop->module());
 }
 
-bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
-                              const QIntList& theModes,
-                              const bool theUpdateViewer) const
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (aContext.IsNull() || theIO.IsNull())
-    return false;
-
-  bool isActivationChanged = false;
-  // deactivate object in all modes, which are not in the list of activation
-  // It seems that after the IO deactivation the selected state of the IO's owners
-  // is modified in OCC(version: 6.8.0) and the selection of the object later is lost.
-  // By this reason, the number of the IO deactivate is decreased and the object is deactivated
-  // only if there is a difference in the current modes and the parameters modes.
-  // If the selection problem happens again, it is possible to write a test scenario and create
-  // a bug. The bug steps are the following:
-  // Create two IO, activate them in 5 modes, select the first IO, deactivate 3 modes for both,
-  // with clicked SHIFT select the second object.
-  // The result is the selection of the first IO is lost.
-  TColStd_ListOfInteger aTColModes;
-  aContext->ActivatedModes(theIO, aTColModes);
-  #ifdef TINSPECTOR
-  if (getCallBack()) getCallBack()->ActivatedModes(theIO, aTColModes);
-  #endif
-  TColStd_ListIteratorOfListOfInteger itr( aTColModes );
-  QIntList aModesActivatedForIO;
-  bool isDeactivated = false;
-  bool aHasValidMode = false;
-  for (; itr.More(); itr.Next() ) {
-    Standard_Integer aMode = itr.Value();
-    aHasValidMode = aHasValidMode || aMode != -1;
-    int aShapeMode = (aMode > 8)? aMode : AIS_Shape::SelectionType(aMode);
-    if (!theModes.contains(aMode)) {
-      deactivateAIS(theIO, aMode);
-      isDeactivated = true;
-    }
-    else {
-      aModesActivatedForIO.append(aMode);
-    }
-  }
-  if (isDeactivated) {
-    // the selection from the previous activation modes should be cleared manually (#26172)
-    //theIO->ClearSelected();
-    //#ifdef TINSPECTOR
-    //if (getCallBack()) getCallBack()->ClearSelected(theIO);
-    //#endif
-#ifndef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
-    deselectPresentation(theIO, aContext);
-#endif
-    // For performance issues
-    //if (theUpdateViewer)
-    //  updateViewer();
-    isActivationChanged = true;
-  }
-
-  // loading the interactive object allowing the decomposition
-  if (aTColModes.IsEmpty() || !aHasValidMode) {
-    aContext->Load(theIO, -1, true);
-    Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
-    if (!aTrihedron.IsNull()) {
-      // Workaround for Trihedron. It should be loaded using the next Load method to
-      // add this object to myGlobal map of selection manager
-      // it is important to activate trihedron in two selection modes: edges and vertices
-      aContext->SelectionManager()->Load(theIO);
-    }
-
-    #ifdef TINSPECTOR
-    if (getCallBack()) getCallBack()->Load(theIO);
-    #endif
-  }
-
-  // trihedron AIS check should be after the AIS loading.
-  // If it is not loaded, it is steel selectable in the viewer.
-  Handle(AIS_Trihedron) aTrihedron;
-  if (!isTrihedronActive())
-    aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
-  if (aTrihedron.IsNull()) {
-      // In order to clear active modes list
-    if (theModes.size() == 0) {
-      activateAIS(theIO, 0, theUpdateViewer);
-    } else {
-      foreach(int aMode, theModes) {
-        if (!aModesActivatedForIO.contains(aMode)) {
-          activateAIS(theIO, aMode, theUpdateViewer);
-          isActivationChanged = true;
-        }
-      }
-    }
-  }
-  return isActivationChanged;
-}
-
+//**************************************************************
 bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
 {
   AISObjectPtr anAISObj = getAISObject(theObject);
@@ -1399,7 +905,7 @@ bool XGUI_Displayer::customizeObject(ObjectPtr theObject)
   return isCustomized;
 }
 
-
+//**************************************************************
 QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject,
                                       const QColor& theColor,
                                       bool theUpdateViewer)
@@ -1416,6 +922,7 @@ QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject,
   return QColor(aR, aG, aB);
 }
 
+//**************************************************************
 void XGUI_Displayer::appendResultObject(ObjectPtr theObject, AISObjectPtr theAIS)
 {
   myResult2AISObjectMap[theObject] = theAIS;
@@ -1429,6 +936,7 @@ void XGUI_Displayer::appendResultObject(ObjectPtr theObject, AISObjectPtr theAIS
 }
 
 #ifdef _DEBUG
+//**************************************************************
 std::string XGUI_Displayer::getResult2AISObjectMapInfo() const
 {
   QStringList aContent;
@@ -1446,6 +954,7 @@ std::string XGUI_Displayer::getResult2AISObjectMapInfo() const
 }
 #endif
 
+//**************************************************************
 void XGUI_Displayer::getPresentations(const ObjectPtr& theObject,
                                   NCollection_Map<Handle(AIS_InteractiveObject)>& thePresentations)
 {
@@ -1490,14 +999,7 @@ void XGUI_Displayer::getPresentations(const ObjectPtr& theObject,
   }
 }
 
-void XGUI_Displayer::activateTrihedron(bool theIsActive)
-{
-  myIsTrihedronActive = theIsActive;
-  if (!myIsTrihedronActive) {
-    deactivateTrihedron(true);
-  }
-}
-
+//**************************************************************
 void XGUI_Displayer::displayTrihedron(bool theToDisplay) const
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -1506,6 +1008,7 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const
 
   Handle(AIS_Trihedron) aTrihedron = myWorkshop->viewer()->trihedron();
 
+  XGUI_SelectionActivate* aSelectionActive = selectionActivate();
   if (theToDisplay) {
     if (!aContext->IsDisplayed(aTrihedron))
       aContext->Display(aTrihedron,
@@ -1518,12 +1021,12 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const
     if (getCallBack()) getCallBack()->Display(aTrihedron);
     #endif
 
-    if (!isTrihedronActive())
-      deactivateTrihedron(false);
+    if (!aSelectionActive->isTrihedronActive())
+      aSelectionActive->deactivateTrihedron(false);
     else
-      activate(aTrihedron, myActiveSelectionModes, false);
+      aSelectionActive->activate(aTrihedron, false);
   } else {
-    deactivateTrihedron(false);
+    aSelectionActive->deactivateTrihedron(false);
 
     aContext->Erase(aTrihedron, Standard_True);
     #ifdef TINSPECTOR
@@ -1534,16 +1037,7 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const
   updateViewer();
 }
 
-QIntList XGUI_Displayer::activeSelectionModes() const
-{
-  QIntList aModes;
-  foreach (int aMode, myActiveSelectionModes) {
-    // aMode < 9 is a Shape Enum values
-    aModes << ((aMode < 9)? AIS_Shape::SelectionType(aMode) : aMode);
-  }
-  return aModes;
-}
-
+//**************************************************************
 void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
                            const NCollection_DataMap<TopoDS_Shape,
                            NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected)
@@ -1617,3 +1111,9 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th
     theContext->AddOrRemoveSelected(anIt.Value(), Standard_False);
   }
 }
+
+//**************************************************************
+XGUI_SelectionActivate* XGUI_Displayer::selectionActivate() const
+{
+  return myWorkshop->selectionActivate();
+}
index 9b606dab3b55c0877694e1fe5033e150b8df9d77..50b4a79d5cd8f61606ffeed8e0fe42c9a7130c85 100644 (file)
 #include "XGUI.h"
 
 #include <GeomAPI_AISObject.h>
-#include <TopoDS_Shape.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <NCollection_Map.hxx>
-#include <NCollection_DataMap.hxx>
+#include <GeomAPI_ICustomPrs.h>
 
 #include <ModelAPI_Result.h>
 
 #include <ModuleBase_Definitions.h>
 
-#include <GeomAPI_ICustomPrs.h>
-
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <NCollection_Map.hxx>
+#include <NCollection_DataMap.hxx>
 #include <SelectMgr_AndFilter.hxx>
+#include <TopoDS_Shape.hxx>
 
-#include <QString>
+#include <QColor>
 #include <QMap>
 #include <QObject>
-#include <QColor>
+#include <QString>
 
 class ModuleBase_ViewerPrs;
 class ModelAPI_Feature;
+class XGUI_SelectionActivate;
 class XGUI_Workshop;
 
 #ifdef TINSPECTOR
@@ -61,12 +61,9 @@ class XGUI_EXPORT XGUI_Displayer: public QObject
  public:
    /// \enum DisplayMode display mode
    enum DisplayMode {
-     /// Mode is not defined
-     NoMode = -1,
-     /// Wireframe display mode
-     Wireframe,
-     /// Shading display mode
-     Shading
+     NoMode = -1, ///< Mode is not defined
+     Wireframe, ///< Wireframe display mode
+     Shading ///< Shading display mode
    };
 
   /// Constructor
@@ -138,12 +135,9 @@ class XGUI_EXPORT XGUI_Displayer: public QObject
   /// \return true if the object visibility state is changed
   bool eraseAll(const bool theUpdateViewer = true);
 
-  /// Deactivates selection of sub-shapes
-  /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
-  //void closeLocalContexts(const bool theUpdateViewer = true);
-
   /// Remove default selection filters of the module from the current viewer
-  void deactivateSelectionFilters();
+  /// \param theAddFilterOnly if is not 'true' it will deactivate all fiters in viewer
+  void deactivateSelectionFilters(const bool theAddFilterOnly = true);
 
   /// \brief Add selection filter
   /// \param theFilter a filter instance
@@ -174,19 +168,6 @@ class XGUI_EXPORT XGUI_Displayer: public QObject
   /// Updates the viewer
   void updateViewer() const;
 
-  /// Activate interactive context
-  /// \param theIO an interactive object
-  /// \param theMode activation mode
-  /// \param theUpdateViewer update viewer flag
-  void activateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode,
-                   const bool theUpdateViewer) const;
-
-  /// Activate interactive context. It is necessary to call ClearOutdatedSelection
-  /// after deactivation
-  /// \param theIO an interactive object
-  /// \param theMode a mode to deactivate. When theMode=-1 then all modes will be deactivated
-  void deactivateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode = -1) const;
-
   /// Searches the interactive object by feature
   /// \param theObject the object or presentable feature
   /// \return theIO an interactive object
@@ -208,22 +189,6 @@ class XGUI_EXPORT XGUI_Displayer: public QObject
   void deactivateObjects(const QObjectPtrList& theObjList,
                          const bool theUpdateViewer = true);
 
-  /// Returns the modes of activation
-  /// \param theObject the feature or NULL if it not visualized
-  /// \param theModes - modes on which it is activated (can be empty)
-  void getModesOfActivation(ObjectPtr theObject, QIntList& theModes);
-
-  /// Returns true if the given object can be selected
-  /// \param theObject object to check
-  bool isActive(ObjectPtr theObject) const;
-
-  /// Activates in local context displayed outside of the context.
-  /// \param theModes - modes on which it has to be activated (can be empty)
-  /// \param theObjList - list of objects which has to be activated.
-  /// \param theUpdateViewer an update viewer flag
-  void activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
-                       const bool theUpdateViewer = true);
-
   /// Sets display mode for the given object if this object is displayed
   void setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool theUpdateViewer = true);
 
@@ -256,31 +221,15 @@ class XGUI_EXPORT XGUI_Displayer: public QObject
   /// \return previously defined color on the object
   QColor setObjectColor(ObjectPtr theObject, const QColor& theColor, bool theUpdateViewer = true);
 
-  /// Returns Trihedron object if it is displayed
-  Handle(AIS_InteractiveObject) getTrihedron() const;
-
-  /// Set trihedron active (used in selection) or non active
-  void activateTrihedron(bool theIsActive);
-
   /// Displays/erases thrihedron in current modes. It will be activated or deactivated
   /// depending on the trihedron visible state and displayer active trihedron state
   void displayTrihedron(bool theToDisplay) const;
 
-  /// Returns true if the trihedron should be activated in current selection modes
-  bool isTrihedronActive() const { return myIsTrihedronActive; }
-
-  /// Returns list of currently active selection modes
-  /// Selection modes will be returned according to TopAbs_ShapeEnum
-  QIntList activeSelectionModes() const;
-
 #ifdef TINSPECTOR
   void setCallBack(const Handle(VInspectorAPI_CallBack)& theCallBack)
     { myVCallBack = theCallBack; }
   Handle(VInspectorAPI_CallBack) getCallBack() const { return myVCallBack; }
 #endif
-  /// Converts shape type (TopAbs_ShapeEnum) to selection mode
-  /// \param theShapeType a shape type from TopAbs_ShapeEnum
-  static int getSelectionMode(int theShapeType);
 
   /// Return true if the object is visible. If the object is feature, it returns true
   /// if all results of the feature are shown
@@ -318,21 +267,6 @@ signals:
                bool theUpdateViewer = true);
 
 private:
-  /// Activates the interactive object in the local context.
-  /// \param theIO an interactive object
-  /// \param theModes - modes on which it has to be activated (can be empty)
-  /// \return a flag is object activated or not
-  bool activate(const Handle(AIS_InteractiveObject)& theIO, const QIntList& theModes,
-                const bool theUpdateViewer) const;
-
-  /// Deactivates the given object (not allow selection)
-  /// \param theObject object to deactivate
-  void deactivate(ObjectPtr theObject, const bool theUpdateViewer);
-
-  /// Find a trihedron in a list of displayed presentations and deactivate it.
-  /// \param theUpdateViewer an update viewer flag
-  void deactivateTrihedron(const bool theUpdateViewer) const;
-
   /// Update the object presentable properties such as color, lines width and other
   /// If the object is result with the color attribute value set, it is used,
   /// otherwise the customize is applyed to the object's feature if it is a custom prs
@@ -366,17 +300,18 @@ private:
   /// owner is selected if it is found there.
   /// Only first owner is processed(according to OCCT logic)
   static void AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext,
-          const NCollection_DataMap<TopoDS_Shape,
-                          NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected);
+    const NCollection_DataMap<TopoDS_Shape,
+      NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected);
 
- protected:
-   /// Reference to workshop
-  XGUI_Workshop* myWorkshop;
+protected:
+  XGUI_SelectionActivate* selectionActivate() const;
+
+protected:
+  XGUI_Workshop* myWorkshop; ///< Reference to workshop
 #ifdef TINSPECTOR
   Handle(VInspectorAPI_CallBack) myVCallBack;
 #endif
-  /// A container for selection filters
-  Handle(SelectMgr_AndFilter) myAndFilter;
+  Handle(SelectMgr_AndFilter) myAndFilter; ///< A container for selection filters
 
   /// A default custom presentation, which is used if the displayed feature is not
   /// a custom presentation
@@ -384,24 +319,13 @@ private:
 
   /// Definition of a type of map which defines correspondance between objects and presentations
   typedef QMap<ObjectPtr, AISObjectPtr> ResultToAISMap;
+  ResultToAISMap myResult2AISObjectMap; ///< A map of displayed objects
 
-  /// A map of displayed objects
-  ResultToAISMap myResult2AISObjectMap;
-
-  /// Selection modes installed for external objects in local context
-  QIntList myActiveSelectionModes;
-
-  /// Number of blocking of the viewer update. The viewer is updated only if it equals zero
+  /// Number of blocking of the viewer update. The viewer is updated only if it is zero
   int myViewerBlockedRecursiveCount;
 
-  /// Flag: first asking of AIS context: trihedron activation
-  bool myIsFirstAISContextUse;
-
-  /// Flag: use trihedgon for selection or not
-  bool myIsTrihedronActive;
-
-  /// A flag that update was requested but not done
-  mutable bool myNeedUpdate;
+  bool myIsFirstAISContextUse; ///< Flag: first asking of AIS context: trihedron activation
+  mutable bool myNeedUpdate; ///< A flag that update was requested but not done
 };
 
 #endif
index 58571d2d24ddbdfe5aa230af04b16fd3d2067a8f..f8dde4f9a0661bd87e4d621f718d2ed7dab80458 100644 (file)
@@ -93,6 +93,12 @@ void XGUI_FacesPanel::reset(const bool isToFlushRedisplay)
   myLastItemIndex = 0; // it should be after redisplay as flag used in customize
 }
 
+//********************************************************************
+void XGUI_FacesPanel::selectionModes(QIntList& theModes)
+{
+  theModes.append(TopAbs_FACE);
+}
+
 //********************************************************************
 bool XGUI_FacesPanel::eventFilter(QObject* theObject, QEvent *theEvent)
 {
@@ -116,17 +122,9 @@ void XGUI_FacesPanel::setActivePanel(const bool theIsActive)
   myIsActive = theIsActive;
 
   if (myIsActive)
-  {
     emit activated();
-    // selection should be activated after emit signal, that deactivates current widget(selection)
-    activateSelection(theIsActive);
-  }
   else
-  {
-    // selection should be activated after emit signal, that deactivates current widget(selection)
-    activateSelection(theIsActive);
     emit deactivated();
-  }
 }
 
 //********************************************************************
@@ -369,23 +367,6 @@ void XGUI_FacesPanel::closeEvent(QCloseEvent* theEvent)
   emit closed();
 }
 
-//********************************************************************
-void XGUI_FacesPanel::activateSelection(bool toActivate)
-{
-  QIntList aShapeTypes;
-  aShapeTypes.append(TopAbs_FACE);
-
-  if (toActivate) {
-    myWorkshop->activateSubShapesSelection(aShapeTypes);
-  } else {
-    myWorkshop->deactivateSubShapesSelection();
-  }
-  if (toActivate)
-    activateSelectionFilters();
-  else
-    deactivateSelectionFilters();
-}
-
 //********************************************************************
 QString XGUI_FacesPanel::generateName(const ModuleBase_ViewerPrsPtr& thePrs)
 {
index 1dca0a9b0da8a064676c9c944a0d4d44b7b9d1ac..3f46acc5031abdb27f267d8e457c535a1b2fa804 100644 (file)
 #include <ModelAPI_Object.h>
 
 #include <ModuleBase_ActionType.h>
+#include <ModuleBase_Definitions.h>
 #include <ModuleBase_ViewerPrs.h>
 
+#include <SelectMgr_ListOfFilter.hxx>
+
 #include <QDockWidget>
 #include <QObject>
 #include <QMap>
@@ -74,6 +77,14 @@ public:
   /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
   virtual void reset(const bool isToFlushRedisplay);
 
+  /// Fills container with the panel selection mode: FACE
+  // \param theModes [out] a container of modes
+  void selectionModes(QIntList& theModes);
+
+  /// Appends into container of workshop selection filters
+  /// \param [out] selection filters
+  void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) {}
+
   /// Returns whether the panel is active or not
   bool isActivePanel() const { return myIsActive; }
 
@@ -121,13 +132,6 @@ public:
   bool customizeObject(const std::shared_ptr<ModelAPI_Object>& theObject,
     const std::shared_ptr<GeomAPI_AISObject>& thePresentation);
 
-protected:
-  /// Add panel selection filters to the current viewer
-  virtual void activateSelectionFilters() {}
-
-  /// Remove panel selection filters from the current viewer
-  virtual void deactivateSelectionFilters() {}
-
 protected:
   /// Reimplementation to emit a signal about the panel close
   virtual void closeEvent(QCloseEvent* theEvent);
@@ -141,9 +145,6 @@ signals:
   void closed();
 
 private:
-  /// Activate or deactivate selection and selection filters
-  void activateSelection(bool toActivate);
-
   /// Redisplay objects.
   /// \param theObjects container of objects
   /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
index b832fbb3071833f34b1eb610a7dcef366587b1c3..34b7d462c7c6c6a1a84d929c7873d2b386ae8cac 100644 (file)
@@ -21,8 +21,9 @@
 #include "XGUI_ModuleConnector.h"
 #include "XGUI_Workshop.h"
 #include "XGUI_ViewerProxy.h"
-#include "XGUI_SelectionMgr.h"
 #include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
+#include "XGUI_SelectionMgr.h"
 #include "XGUI_OperationMgr.h"
 #include "XGUI_Displayer.h"
 #include "XGUI_PropertyPanel.h"
@@ -78,6 +79,11 @@ ModuleBase_IErrorMgr* XGUI_ModuleConnector::errorMgr() const
   return myWorkshop->errorMgr();
 }
 
+ModuleBase_ISelectionActivate* XGUI_ModuleConnector::selectionActivate() const
+{
+  return myWorkshop->selectionActivate();
+}
+
 ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
 {
   return myWorkshop->operationMgr()->currentOperation();
@@ -96,27 +102,6 @@ QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjL
   return aActiveOPbjects;
 }
 
-void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
-{
-  QIntList aTypes = theTypes;
-
-  XGUI_Displayer* aDisp = myWorkshop->displayer();
-  myWorkshop->module()->customSubShapesSelectionModes(aTypes);
-  aDisp->activateObjects(aTypes, activeObjects(aDisp->displayedObjects()));
-}
-
-void XGUI_ModuleConnector::deactivateSubShapesSelection()
-{
-  // Clear selection modes
-  activateModuleSelectionModes();
-}
-
-void XGUI_ModuleConnector::activateModuleSelectionModes()
-{
-  XGUI_Displayer* aDisp = myWorkshop->displayer();
-  myWorkshop->activateObjectsSelection(activeObjects(aDisp->displayedObjects()));
-}
-
 AISObjectPtr XGUI_ModuleConnector::findPresentation(const ObjectPtr& theObject) const
 {
   XGUI_Displayer* aDisp = myWorkshop->displayer();
index 06536228efd826ec8b0abb1e7cee7310c6260328..6bf3914c29d3656eee583281953927fe99e97c4f 100644 (file)
@@ -45,16 +45,6 @@ Q_OBJECT
   //! Returns list of currently selected data objects
   virtual ModuleBase_ISelection* selection() const;
 
-  /// Activate sub-shapes selection (opens local context if it was not opened)
-  /// Types has to be dined according to TopAbs_ShapeEnum
-  virtual void activateSubShapesSelection(const QIntList& theTypes);
-
-  /// Activate objects in the module selection modes(opens local context)
-  virtual void activateModuleSelectionModes();
-
-  /// Deactivate sub-shapes selection (closes local context)
-  virtual void deactivateSubShapesSelection();
-
   //! Returns instance of loaded module
   virtual ModuleBase_IModule* module() const;
 
@@ -67,6 +57,9 @@ Q_OBJECT
   //! Returns error manager
   virtual ModuleBase_IErrorMgr* errorMgr() const;
 
+  /// A selection activate in 3D View handler
+  virtual ModuleBase_ISelectionActivate* selectionActivate() const;
+
   //! Returns currently active operation
   virtual ModuleBase_Operation* currentOperation() const;
 
index cb031c166c80e27d5d86f3ba4f386db686b17d15..bab01f75150cb882e6e00dec54d1790ee8ab7669 100755 (executable)
@@ -20,6 +20,7 @@
 
 #include <XGUI_ActionsMgr.h>
 #include <XGUI_ActiveControlMgr.h>
+#include <XGUI_SelectionActivate.h>
 #include <XGUI_ActiveControlSelector.h>
 #include <XGUI_PropertyPanel.h>
 #include <XGUI_PropertyPanelSelector.h>
@@ -151,6 +152,9 @@ void XGUI_PropertyPanel::cleanContent()
   myWidgets.clear();
   myPanelPage->clearPage();
   myActiveWidget = NULL;
+  emit propertyPanelDeactivated();
+  myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
+  myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
 #ifdef DEBUG_ACTIVE_WIDGET
   std::cout << "myActiveWidget = NULL" << std::endl;
 #endif
@@ -487,6 +491,9 @@ bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget)
     theWidget->activate();
   }
   myActiveWidget = theWidget;
+  myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
+  myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
+
 #ifdef DEBUG_ACTIVE_WIDGET
   std::cout << "myActiveWidget = " << (theWidget ? theWidget->context().c_str() : "") << std::endl;
 #endif
index 06dfda814035469dbcd770505a386548adb019be..d2b5b4966aa75ccc1ba7d35a5a52a4cb148fd661 100644 (file)
@@ -163,6 +163,9 @@ signals:
   /// \param theObject a sender of the event
   void enterClicked(QObject* theObject);
 
+  /// Emits on clear content
+  void propertyPanelDeactivated();
+
 protected:
   /// Makes the widget active, deactivate the previous, activate and hightlight the given one
   /// \param theWidget a widget
index f33e77c9139b43bc2b18b05c13e919b8fe17c9ea..5039168365c17c3278cc8f09a083f6b881cf36eb 100644 (file)
@@ -26,6 +26,7 @@ XGUI_PropertyPanelSelector::XGUI_PropertyPanelSelector(XGUI_PropertyPanel* thePa
 : myPanel(thePanel), myWidgetToBeActivated (NULL)
 {
   connect(myPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this, SIGNAL(activated()));
+  connect(myPanel, SIGNAL(propertyPanelDeactivated()), this, SIGNAL(deactivated()));
 }
 
 //********************************************************************
diff --git a/src/XGUI/XGUI_SelectionActivate.cpp b/src/XGUI/XGUI_SelectionActivate.cpp
new file mode 100644 (file)
index 0000000..13a6756
--- /dev/null
@@ -0,0 +1,602 @@
+// Copyright (C) 2014-2017  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "XGUI_SelectionActivate.h"
+
+#include "ModelAPI_Object.h"
+
+#include "ModuleBase_IModule.h"
+#include "ModuleBase_IViewer.h"
+#include "ModuleBase_ModelWidget.h"
+#include "ModuleBase_Preferences.h"
+
+#include "XGUI_ActiveControlMgr.h"
+#include "XGUI_ActiveControlSelector.h"
+#include "XGUI_Displayer.h"
+#include "XGUI_FacesPanel.h"
+#include "XGUI_FacesPanelSelector.h"
+#include "XGUI_SelectionMgr.h"
+#include "XGUI_Tools.h"
+#include "XGUI_Workshop.h"
+
+#include <SUIT_ResourceMgr.h>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_Shape.hxx>
+#include <AIS_Trihedron.hxx>
+
+#include <SelectMgr_SelectionManager.hxx>
+
+//#define DEBUG_ACTIVATE_OBJECTS
+//#define DEBUG_DEACTIVATE
+//#define DEBUG_ACTIVATE_AIS
+//#define DEBUG_DEACTIVATE_AIS
+
+#define CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
+
+//**************************************************************
+XGUI_SelectionActivate::XGUI_SelectionActivate(ModuleBase_IWorkshop* theWorkshop)
+ : ModuleBase_ISelectionActivate(theWorkshop), myIsTrihedronActive(true)
+{
+}
+
+//**************************************************************
+XGUI_SelectionActivate::SelectionPlace XGUI_SelectionActivate::activeSelectionPlace() const
+{
+  XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
+  XGUI_ActiveControlSelector* anActiveSelector = aWorkshop->activeControlMgr()->activeSelector();
+  if (!anActiveSelector)
+    return Workshop;
+
+  if (anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
+    return FacesPanel;
+  else
+    return PropertyPanel;
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::updateSelectionModes()
+{
+  QIntList aModes;
+  switch (activeSelectionPlace()) {
+  case Workshop:
+    myWorkshop->module()->activeSelectionModes(aModes);
+    break;
+    case PropertyPanel: {
+      ModuleBase_ModelWidget* anActiveWidget = myWorkshop->module()->activeWidget();
+      if (anActiveWidget)
+        getSelectionModes(anActiveWidget, aModes);
+      else
+        myWorkshop->module()->activeSelectionModes(aModes); //using module modes
+    }
+    break;
+    case FacesPanel: {
+      XGUI_Tools::workshop(myWorkshop)->facesPanel()->selectionModes(aModes);
+      myWorkshop->module()->customSubShapesSelectionModes(aModes); // avoid wire selection
+    }
+    break;
+    default: break;
+  }
+  activateObjects(aModes, getDisplayer()->displayedObjects(), true);
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::updateSelectionFilters()
+{
+  SelectMgr_ListOfFilter aSelectionFilters;
+  switch (activeSelectionPlace()) {
+  case Workshop:
+    XGUI_Tools::workshop(myWorkshop)->selectionFilters(aSelectionFilters);
+    break;
+    case PropertyPanel: {
+      ModuleBase_ModelWidget* anActiveWidget = myWorkshop->module()->activeWidget();
+      getSelectionFilters(anActiveWidget, aSelectionFilters);
+    }
+    break;
+    case FacesPanel: {
+      //XGUI_Tools::workshop(myWorkshop)->selectionFilters(aSelectionFilters);
+      XGUI_Tools::workshop(myWorkshop)->facesPanel()->selectionFilters(aSelectionFilters);
+    }
+    break;
+    default: break;
+  }
+  activateSelectionFilters(aSelectionFilters);
+}
+
+//**************************************************************
+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::activateSelectionFilters
+  (const SelectMgr_ListOfFilter& theSelectionFilters)
+{
+  XGUI_Displayer* aDisplayer = getDisplayer();
+  aDisplayer->deactivateSelectionFilters(false);
+
+  SelectMgr_ListIteratorOfListOfFilter aIt(theSelectionFilters);
+  for (; aIt.More(); aIt.Next()) {
+    Handle(SelectMgr_Filter) aFilter = aIt.Value();
+    if (aFilter.IsNull())
+      continue;
+    aDisplayer->addSelectionFilter(aFilter);
+  }
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::getSelectionModes(ModuleBase_ModelWidget* theWidget,
+                                               QIntList& theModes)
+{
+  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);
+}
+
+//**************************************************************
+QIntList XGUI_SelectionActivate::activeSelectionModes() const
+{
+  QIntList aModes;
+  foreach (int aMode, myActiveSelectionModes) {
+    // aMode < 9 is a Shape Enum values
+    aModes << ((aMode < 9)? AIS_Shape::SelectionType(aMode) : aMode);
+  }
+  return aModes;
+}
+
+//**************************************************************
+bool XGUI_SelectionActivate::isActive(ObjectPtr theObject) const
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (aContext.IsNull() || !getDisplayer()->isVisible(theObject))
+    return false;
+
+  AISObjectPtr anObj = getDisplayedAISObject(theObject);
+  Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+
+  TColStd_ListOfInteger aModes;
+  aContext->ActivatedModes(anAIS, aModes);
+
+  return aModes.Extent() > 0;
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::activateObjects(const QIntList& theModes,
+  const QObjectPtrList& theObjList, const bool theUpdateViewer)
+{
+  setSelectionModes(theModes);
+
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  // Open local context if there is no one
+  if (aContext.IsNull())
+    return;
+
+  //aContext->UseDisplayedObjects();
+  //myUseExternalObjects = true;
+
+  Handle(AIS_InteractiveObject) anAISIO;
+  AIS_ListOfInteractive aPrsList;
+  AIS_ListOfInteractive aPrsListToBeDeactivated;
+  //if (aObjList.isEmpty())
+  //  return;
+  //else {
+  foreach(ObjectPtr anObject, theObjList) {
+    AISObjectPtr anAISObject = getDisplayedAISObject(anObject);
+    if (!anAISObject.get())
+      continue;
+
+    Handle(AIS_InteractiveObject) aPrs = anAISObject->impl<Handle(AIS_InteractiveObject)>();
+    if (myWorkshop->module()->canActivateSelection(anObject))
+      aPrsList.Append(aPrs);
+    else
+      aPrsListToBeDeactivated.Append(aPrs);
+  }
+  //}
+
+  // Add trihedron because it has to partisipate in selection
+  Handle(AIS_InteractiveObject) aTrihedron;
+  if (isTrihedronActive()) {
+    aTrihedron = getTrihedron();
+    if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron))
+      aPrsList.Append(aTrihedron);
+  }
+  if (aPrsList.Extent() == 0 && aPrsListToBeDeactivated.Extent() == 0)
+    return;
+
+  AIS_ListIteratorOfListOfInteractive aLIt;
+  bool isActivationChanged = false;
+  for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()) {
+    anAISIO = aLIt.Value();
+    if (activate(anAISIO, false))
+      isActivationChanged = true;
+  }
+
+  for(aLIt.Initialize(aPrsListToBeDeactivated); aLIt.More(); aLIt.Next()) {
+    anAISIO = aLIt.Value();
+    deactivateAIS(anAISIO);
+    isActivationChanged = true;
+  }
+}
+
+#ifdef DEBUG_ACTIVATE_OBJECTS
+//**************************************************************
+QString getModeInfo(const int theMode)
+{
+  QString anInfo = "Undefined";
+  switch(theMode) {
+    case 0: anInfo = "SHAPE(0)"; break;
+    case 1: anInfo = "VERTEX(1)"; break;
+    case 2: anInfo = "EDGE(2)"; break;
+    case 3: anInfo = "WIRE(3)"; break;
+    case 4: anInfo = "FACE(4)"; break;
+    case 5: anInfo = "SHELL(5)"; break;
+    case 6: anInfo = "SOLID(6)"; break;
+    case 7: anInfo = "COMPSOLID(7)"; break;
+    case 8: anInfo = "COMPOUND(8)"; break;
+    case 100: anInfo = "Sel_Mode_First(100)"; break; //SketcherPrs_Tools
+    case 101: anInfo = "Sel_Constraint(101)"; break;
+    case 102: anInfo = "Sel_Dimension_All(102)"; break;
+    case 103: anInfo = "Sel_Dimension_Line(103)"; break;
+    case 104: anInfo = "Sel_Dimension_Text(104)"; break;
+    default: break;
+  }
+  return anInfo;
+}
+
+//**************************************************************
+QString getModesInfo(const QIntList& theModes)
+{
+  QStringList aModesInfo;
+  for (int i = 0, aSize = theModes.size(); i < aSize; i++)
+    aModesInfo.append(getModeInfo(theModes[i]));
+  return QString("[%1] = %2").arg(aModesInfo.size()).arg(aModesInfo.join(", "));
+}
+#endif
+
+//**************************************************************
+void XGUI_SelectionActivate::setSelectionModes(const QIntList& theModes)
+{
+  // Convert shape types to selection types
+  QIntList aModes;
+  foreach(int aType, theModes) {
+    aModes.append(getSelectionMode(aType));
+  }
+
+#ifdef DEBUG_ACTIVATE_OBJECTS
+  QStringList anInfo;
+  QObjectPtrList::const_iterator anIt = theObjList.begin(), aLast = theObjList.end();
+  for (; anIt != aLast; ++anIt) {
+    anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
+  }
+  QString anInfoStr = anInfo.join(", ");
+
+  qDebug(QString("activateObjects: new modes%1, active modes%2, objects[%3] = %4").
+    arg(getModesInfo(aModes)).
+    arg(getModesInfo(myActiveSelectionModes)).
+    arg(theObjList.size()).
+    arg(anInfoStr).
+    toStdString().c_str());
+#endif
+  // In order to avoid doblications of selection modes
+  QIntList aNewModes;
+  foreach (int aMode, aModes) {
+    if (!aNewModes.contains(aMode))
+      aNewModes.append(aMode);
+  }
+  myActiveSelectionModes = aNewModes;
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::activateOnDisplay(const Handle(AIS_InteractiveObject)& theIO,
+                                               const bool theUpdateViewer)
+{
+  if (myActiveSelectionModes.size() == 0)
+    activateAIS(theIO, 0, theUpdateViewer);
+  else {
+    foreach(int aMode, myActiveSelectionModes) {
+      activateAIS(theIO, aMode, theUpdateViewer);
+    }
+  }
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::activateAIS(const Handle(AIS_InteractiveObject)& theIO,
+                                         const int theMode, const bool theUpdateViewer) const
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (!theIO.IsNull() && theIO == getTrihedron()) {
+    if (theMode != AIS_Shape::SelectionType(TopAbs_EDGE) &&
+        theMode != AIS_Shape::SelectionType(TopAbs_VERTEX))
+      return;
+  }
+  if (!aContext.IsNull()) {
+    if (myWorkshop->module()) {
+      int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode);
+      aContext->Activate(theIO, theMode, false);
+    } else
+      aContext->Activate(theIO, theMode, false);
+
+    // the fix from VPA for more suitable selection of sketcher lines
+    if (theIO->Width() > 1) {
+      double aPrecision = theIO->Width() + 2;
+      if (theMode == getSelectionMode(TopAbs_VERTEX))
+        aPrecision = ModuleBase_Preferences::resourceMgr()->doubleValue("Viewer",
+        "point-selection-sensitivity", 12);
+      else if ((theMode == getSelectionMode(TopAbs_EDGE)) ||
+               (theMode == getSelectionMode(TopAbs_WIRE)))
+        aPrecision = theIO->Width() + ModuleBase_Preferences::resourceMgr()->doubleValue("Viewer",
+           "edge-selection-sensitivity", 2);
+      aContext->SetSelectionSensitivity(theIO, theMode, aPrecision);
+    }
+
+#ifdef DEBUG_ACTIVATE_AIS
+    ObjectPtr anObject = getObject(theIO);
+    anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
+    qDebug(QString("activateAIS: theMode = %1, object = %2").arg(theMode)
+      .arg(anInfo).toStdString().c_str());
+#endif
+    if (theUpdateViewer)
+      getDisplayer()->updateViewer();
+  }
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::deactivateAIS(const Handle(AIS_InteractiveObject)& theIO,
+                                           const int theMode) const
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (!aContext.IsNull()) {
+    if (theMode == -1)
+      aContext->Deactivate(theIO);
+    else
+      aContext->Deactivate(theIO, theMode);
+
+#ifdef DEBUG_DEACTIVATE_AIS
+    ObjectPtr anObject = getObject(theIO);
+    anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
+    qDebug(QString("deactivateAIS: theMode = %1, object = %2").arg(theMode)
+      .arg(anInfo).toStdString().c_str());
+#endif
+  }
+}
+
+//**************************************************************
+bool XGUI_SelectionActivate::activate(const Handle(AIS_InteractiveObject)& theIO,
+                                      const bool theUpdateViewer) const
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (aContext.IsNull() || theIO.IsNull())
+    return false;
+
+  bool isActivationChanged = false;
+  // deactivate object in all modes, which are not in the list of activation
+  // It seems that after the IO deactivation the selected state of the IO's owners
+  // is modified in OCC(version: 6.8.0) and the selection of the object later is lost.
+  // By this reason, the number of the IO deactivate is decreased and the object is deactivated
+  // only if there is a difference in the current modes and the parameters modes.
+  // If the selection problem happens again, it is possible to write a test scenario and create
+  // a bug. The bug steps are the following:
+  // Create two IO, activate them in 5 modes, select the first IO, deactivate 3 modes for both,
+  // with clicked SHIFT select the second object.
+  // The result is the selection of the first IO is lost.
+  TColStd_ListOfInteger aTColModes;
+  aContext->ActivatedModes(theIO, aTColModes);
+  TColStd_ListIteratorOfListOfInteger itr( aTColModes );
+  QIntList aModesActivatedForIO;
+  bool isDeactivated = false;
+  bool aHasValidMode = false;
+  for (; itr.More(); itr.Next() ) {
+    Standard_Integer aMode = itr.Value();
+    aHasValidMode = aHasValidMode || aMode != -1;
+    int aShapeMode = (aMode > 8)? aMode : AIS_Shape::SelectionType(aMode);
+    if (!myActiveSelectionModes.contains(aMode)) {
+      deactivateAIS(theIO, aMode);
+      isDeactivated = true;
+    }
+    else {
+      aModesActivatedForIO.append(aMode);
+    }
+  }
+  if (isDeactivated) {
+    // the selection from the previous activation modes should be cleared manually (#26172)
+    //theIO->ClearSelected();
+#ifndef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
+    XGUI_Tools::workshop(myWorkshop)->selector()->deselectPresentation(theIO);
+#endif
+    // For performance issues
+    //if (theUpdateViewer)
+    //  getDisplayer()->updateViewer();
+    isActivationChanged = true;
+  }
+
+  // loading the interactive object allowing the decomposition
+  if (aTColModes.IsEmpty() || !aHasValidMode) {
+    aContext->Load(theIO, -1, true);
+    Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
+    if (!aTrihedron.IsNull()) {
+      // Workaround for Trihedron. It should be loaded using the next Load method to
+      // add this object to myGlobal map of selection manager
+      // it is important to activate trihedron in two selection modes: edges and vertices
+      aContext->SelectionManager()->Load(theIO);
+    }
+  }
+
+  // trihedron AIS check should be after the AIS loading.
+  // If it is not loaded, it is steel selectable in the viewer.
+  Handle(AIS_Trihedron) aTrihedron;
+  if (!isTrihedronActive())
+    aTrihedron = Handle(AIS_Trihedron)::DownCast(theIO);
+  if (aTrihedron.IsNull()) {
+      // In order to clear active modes list
+    if (myActiveSelectionModes.size() == 0) {
+      activateAIS(theIO, 0, theUpdateViewer);
+    } else {
+      foreach(int aMode, myActiveSelectionModes) {
+        if (!aModesActivatedForIO.contains(aMode)) {
+          activateAIS(theIO, aMode, theUpdateViewer);
+          isActivationChanged = true;
+        }
+      }
+    }
+  }
+  return isActivationChanged;
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::deactivate(const ObjectPtr& theObject, const bool theUpdateViewer)
+{
+#ifdef DEBUG_DEACTIVATE
+  QString anInfoStr = ModuleBase_Tools::objectInfo(theObject);
+  qDebug(QString("deactivate: myActiveSelectionModes[%1]: %2, objects = ").
+    arg(myActiveSelectionModes.size()).arg(qIntListInfo(myActiveSelectionModes)).
+    arg(anInfoStr).
+    toStdString().c_str());
+#endif
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (!aContext.IsNull() && getDisplayer()->isVisible(theObject)) {
+    AISObjectPtr anObj = getDisplayedAISObject(theObject);
+    Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+
+    deactivateAIS(anAIS);
+    // the selection from the previous activation modes should be cleared manually (#26172)
+#ifndef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY
+    XGUI_Tools::workshop(myWorkshop)->selector()->deselectPresentation(anAIS);
+#endif
+    if (theUpdateViewer)
+      getDisplayer()->updateViewer();
+  }
+}
+
+/// #1136 hidden axis are selected in sketch
+#ifdef BEFORE_TRIHEDRON_PATCH
+//**************************************************************
+void deactivateObject(Handle(AIS_InteractiveContext) theContext,
+                      Handle(AIS_InteractiveObject) theObject)
+{
+  if (!theObject.IsNull())
+    theContext->Deactivate(theObject);
+}
+#endif
+
+//**************************************************************
+void XGUI_SelectionActivate::activateTrihedron(bool theIsActive)
+{
+  myIsTrihedronActive = theIsActive;
+  if (!myIsTrihedronActive)
+    deactivateTrihedron(true);
+}
+
+//**************************************************************
+void XGUI_SelectionActivate::deactivateTrihedron(const bool theUpdateViewer) const
+{
+  Handle(AIS_InteractiveObject) aTrihedron = getTrihedron();
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron)) {
+    Handle(AIS_Trihedron) aTrie = Handle(AIS_Trihedron)::DownCast(aTrihedron);
+    if (!aTrie.IsNull())
+      aContext->Deactivate(aTrie);
+
+    /// #1136 hidden axis are selected in sketch
+#ifdef BEFORE_TRIHEDRON_PATCH
+    deactivateObject(aContext, aTrie->XAxis());
+    deactivateObject(aContext, aTrie->YAxis());
+    deactivateObject(aContext, aTrie->Axis());
+    deactivateObject(aContext, aTrie->Position());
+
+    deactivateObject(aContext, aTrie->XYPlane());
+    deactivateObject(aContext, aTrie->XZPlane());
+    deactivateObject(aContext, aTrie->YZPlane());
+#endif
+    if (theUpdateViewer)
+      getDisplayer()->updateViewer();
+  }
+}
+
+//**************************************************************
+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);
+  }
+}
+
+//**************************************************************
+Handle(AIS_InteractiveContext) XGUI_SelectionActivate::AISContext() const
+{
+  return myWorkshop->viewer()->AISContext();
+}
+
+//**************************************************************
+XGUI_Displayer* XGUI_SelectionActivate::getDisplayer() const
+{
+  return XGUI_Tools::workshop(myWorkshop)->displayer();
+}
+
+//**************************************************************
+Handle(AIS_InteractiveObject) XGUI_SelectionActivate::getTrihedron() const
+{
+  return myWorkshop->viewer()->trihedron();
+}
+
+//**************************************************************
+AISObjectPtr XGUI_SelectionActivate::getDisplayedAISObject(ObjectPtr theObject) const
+{
+  return getDisplayer()->getAISObject(theObject);
+}
+
+//**************************************************************
+int XGUI_SelectionActivate::getSelectionMode(int theShapeType)
+{
+  return (theShapeType > TopAbs_SHAPE) ? theShapeType :
+                                         AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theShapeType);
+}
diff --git a/src/XGUI/XGUI_SelectionActivate.h b/src/XGUI/XGUI_SelectionActivate.h
new file mode 100644 (file)
index 0000000..1c149f8
--- /dev/null
@@ -0,0 +1,176 @@
+// Copyright (C) 2014-2017  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef XGUI_ISelectionActivate_H
+#define XGUI_ISelectionActivate_H
+
+#include "XGUI.h"
+
+#include "ModuleBase_Definitions.h"
+#include "ModuleBase_ISelectionActivate.h"
+
+#include "SelectMgr_ListOfFilter.hxx"
+
+#include <memory>
+
+class AIS_InteractiveContext;
+class AIS_InteractiveObject;
+class ModelAPI_Object;
+
+class XGUI_Displayer;
+
+/// \ingroup GUI
+/// A class which implements activation/deactivate selection modes and using selection filters.
+class XGUI_SelectionActivate : public ModuleBase_ISelectionActivate
+{
+public:
+  /// Types of the activation place
+  enum SelectionPlace { Workshop, PropertyPanel, FacesPanel };
+
+public:
+  /// Constructor
+  XGUI_EXPORT XGUI_SelectionActivate(ModuleBase_IWorkshop* theWorkshop);
+
+  /// Destructor
+  ~XGUI_SelectionActivate() {}
+
+  /// Returns place of activation modes that now is active
+  /// \return place
+  SelectionPlace activeSelectionPlace() const;
+
+  /// Updates active selection modes in the viewer depending on the application state
+  XGUI_EXPORT virtual void updateSelectionModes();
+
+  /// Updates active selection filters in the viewer depending on the application state
+  XGUI_EXPORT virtual void updateSelectionFilters();
+
+  /// Activates parameter filters in the workshop, deactivate active out of the container
+  /// Please find a possibility to use updateSelectionFilters instead of direct call this method.
+  /// \param theSelectionFilters a filtes
+  XGUI_EXPORT virtual void activateSelectionFilters
+    (const SelectMgr_ListOfFilter& theSelectionFilters);
+
+  /// Activate or deactivate selection and selection filters like the widget is active
+  /// \param theWidget a source widget of selection modes/filters
+  XGUI_EXPORT virtual void activateSelectionAndFilters(ModuleBase_ModelWidget* theWidget);
+
+  /// Returns list of currently active selection modes
+  /// Selection modes will be returned according to TopAbs_ShapeEnum
+  XGUI_EXPORT QIntList activeSelectionModes() const;
+
+  /// Returns true if the given object can be selected
+  /// \param theObject object to check
+  XGUI_EXPORT bool isActive(ObjectPtr theObject) const;
+
+  /// Activates in local context displayed outside of the context.
+  /// \param theModes - modes on which it has to be activated (can be empty)
+  /// \param theObjList - list of objects which has to be activated.
+  /// \param theUpdateViewer an update viewer flag
+  XGUI_EXPORT void activateObjects(const QIntList& theModes, const QObjectPtrList& theObjList,
+                                   const bool theUpdateViewer = true);
+
+  /// Fill container of current selection modes
+  /// \param theModes selection modes
+  XGUI_EXPORT void setSelectionModes(const QIntList& theModes);
+
+  /// Activate object in the selection modes
+  /// \param theIO an object
+  /// \param theUpdateViewer an update viewer flag
+  XGUI_EXPORT void activateOnDisplay(const Handle(AIS_InteractiveObject)& theIO,
+                                     const bool theUpdateViewer);
+
+  /// Activate interactive object
+  /// \param theIO an interactive object
+  /// \param theMode activation mode
+  /// \param theUpdateViewer update viewer flag
+  XGUI_EXPORT void activateAIS(const Handle(AIS_InteractiveObject)& theIO, const int theMode,
+                               const bool theUpdateViewer) const;
+
+  /// Activate interactive object. It is necessary to call ClearOutdatedSelection
+  /// after deactivation
+  /// \param theIO an interactive object
+  /// \param theMode a mode to deactivate. When theMode=-1 then all modes will be deactivated
+  XGUI_EXPORT void deactivateAIS(const Handle(AIS_InteractiveObject)& theIO,
+                                 const int theMode = -1) const;
+
+  /// Activates the interactive object in the local context.
+  /// \param theIO an interactive object
+  /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+  /// \return a flag is object activated or not
+  XGUI_EXPORT bool activate(const Handle(AIS_InteractiveObject)& theIO,
+                            const bool theUpdateViewer) const;
+
+  /// Deactivates the given object (not allow selection)
+  /// \param theObject object to deactivate
+  /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+  XGUI_EXPORT void deactivate(const std::shared_ptr<ModelAPI_Object>& theObject,
+                              const bool theUpdateViewer);
+
+  /// Returns true if the trihedron should be activated in current selection modes
+  bool isTrihedronActive() const { return myIsTrihedronActive; }
+
+  /// Set trihedron active (used in selection) or non active
+  XGUI_EXPORT void activateTrihedron(bool theIsActive);
+
+  /// Find a trihedron in a list of displayed presentations and deactivate it.
+  /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+  XGUI_EXPORT void deactivateTrihedron(const bool theUpdateViewer) const;
+
+  /// Get selection modes of trihedron and deactivate it in it.
+  XGUI_EXPORT void deactivateTrihedronInSelectionModes();
+
+protected:
+  /// Returns selection modes of the widget
+  /// \param theWidget model widget
+  /// \param theModes selection modes
+  void getSelectionModes(ModuleBase_ModelWidget* theWidget, QIntList& theModes);
+
+  /// Returns selection filters of the widget
+  /// \param theWidget model widget
+  /// \param theSelectionFilters selection filters
+  void getSelectionFilters(ModuleBase_ModelWidget* theWidget,
+                           SelectMgr_ListOfFilter& theSelectionFilters);
+
+  /// Returns Trihedron object if it is displayed
+  Handle(AIS_InteractiveObject) getTrihedron() const;
+
+  /// Returns context of the 3D viewer
+  /// \return context instance
+  Handle(AIS_InteractiveContext) AISContext() const;
+
+  /// Returns displayer
+  /// \return displayer
+  XGUI_Displayer* getDisplayer() const;
+
+  /// Returns AIS object displayed in 3D viewer for the given model object
+  /// \param theObject source object
+  /// \returns interactive object
+  AISObjectPtr getDisplayedAISObject(std::shared_ptr<ModelAPI_Object> theObject) const;
+
+  /// Converts shape type (TopAbs_ShapeEnum) to selection mode
+  /// \param theShapeType a shape type from TopAbs_ShapeEnum
+  static int getSelectionMode(int theShapeType);
+
+protected:
+  QIntList myActiveSelectionModes; ///< Current activated selection modes
+  bool myIsTrihedronActive; ///< Flag: use trihedgon for selection or not
+};
+
+#endif
index ed7e5e23330e21ab0925e668d5cb580c0f4a8e13..bece087dc5f4266476d175da5814030859875d1f 100755 (executable)
@@ -150,6 +150,28 @@ void XGUI_SelectionMgr::onViewerSelection()
   emit selectionChanged();
 }
 
+//**************************************************************
+void XGUI_SelectionMgr::deselectPresentation(const Handle(AIS_InteractiveObject) theObject)
+{
+  NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
+
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+    Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+    if (anOwner.IsNull()) // TODO: check why it is possible
+      continue;
+    if (anOwner->Selectable() == theObject && anOwner->IsSelected())
+      aResultOwners.Append(anOwner);
+  }
+  NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (aResultOwners);
+  Handle(SelectMgr_EntityOwner) anOwner;
+  for (; anOwnersIt.More(); anOwnersIt.Next()) {
+    anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
+    if (!anOwner.IsNull())
+      aContext->AddOrRemoveSelected(anOwner, false);
+  }
+}
+
 //**************************************************************
 void XGUI_SelectionMgr::updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace)
 {
index 06e6fe54e5d0f19274413f0a56504b9db9722940..da5d1cb9b602b9477c032d6d2175659f85da5e50 100644 (file)
@@ -28,6 +28,7 @@
 #include <QObject>
 #include <QModelIndexList>
 
+#include <AIS_InteractiveObject.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <NCollection_List.hxx>
 #include <TopoDS_Shape.hxx>
@@ -74,6 +75,10 @@ Q_OBJECT
   //! \param theValues a container of values to be selected.
   void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs> >& theValues);
 
+  //! Find all selected owners of the object and remove the owners from selection
+  //! \param theObject an interactive object
+  void deselectPresentation(const Handle(AIS_InteractiveObject) theObject);
+
   /// Updates selection, which are depend on the selection in the given place
   /// \param thePlace a widget where selection has happened.
   void updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace);
index 2e7c4e7702af76198a509735e1be301f0fe483db..bff02679288cdb7013a859d500930f6b0ebeedb9 100755 (executable)
@@ -41,6 +41,7 @@
 #include "XGUI_PropertyDialog.h"
 #include "XGUI_SalomeConnector.h"
 #include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_Tools.h"
 #include "XGUI_ViewerProxy.h"
@@ -184,6 +185,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   ModuleBase_IWorkshop* aWorkshop = moduleConnector();
   // Has to be defined first in order to get errors and messages from other components
   myEventsListener = new XGUI_WorkshopListener(aWorkshop);
+  mySelectionActivate = new XGUI_SelectionActivate(aWorkshop);
 
   SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
 #ifndef HAVE_SALOME
@@ -350,7 +352,7 @@ void XGUI_Workshop::startApplication()
 //******************************************************
 void XGUI_Workshop::activateModule()
 {
-  myModule->activateSelectionFilters();
+  selectionActivate()->updateSelectionFilters();
 
   connect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
     myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr)));
@@ -369,10 +371,8 @@ void XGUI_Workshop::activateModule()
 //******************************************************
 void XGUI_Workshop::deactivateModule()
 {
-  myModule->deactivateSelectionFilters();
-
   // remove internal displayer filter
-  displayer()->deactivateSelectionFilters();
+  displayer()->deactivateSelectionFilters(false);
 
   disconnect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
     myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr)));
@@ -382,17 +382,10 @@ void XGUI_Workshop::deactivateModule()
   XGUI_Displayer* aDisplayer = displayer();
   QObjectPtrList aDisplayed = aDisplayer->displayedObjects();
   aDisplayer->deactivateObjects(aDisplayed, true);
-  Handle(AIS_InteractiveContext) aContext = viewer()->AISContext();
-  Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aDisplayer->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);
-  }
+  selectionActivate()->deactivateTrihedronInSelectionModes();
+
 #ifdef BEFORE_TRIHEDRON_PATCH
+  //Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aDisplayer->getTrihedron());
   /// Trihedron problem: objects stayed in the viewer, should be removed manually
   /// otherwise in SALOME happens crash by HideAll in the viewer
   aContext->Remove(aTrihedron->Position(), true);
@@ -553,7 +546,7 @@ void XGUI_Workshop::onPreviewActionClicked()
 void XGUI_Workshop::deactivateActiveObject(const ObjectPtr& theObject, const bool theUpdateViewer)
 {
   if (!myModule->canActivateSelection(theObject)) {
-    if (myDisplayer->isActive(theObject)) {
+    if (selectionActivate()->isActive(theObject)) {
       QObjectPtrList anObjects;
       anObjects.append(theObject);
       myDisplayer->deactivateObjects(anObjects, theUpdateViewer);
@@ -693,6 +686,12 @@ void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect)
   }
 }
 
+//******************************************************
+void XGUI_Workshop::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters)
+{
+  module()->selectionFilters(theSelectionFilters);
+}
+
 //******************************************************
 void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
 {
@@ -707,7 +706,6 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
   myModule->operationResumed(theOperation);
 }
 
-
 //******************************************************
 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
 {
@@ -732,14 +730,14 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   QObjectPtrList anObjects;
   FeaturePtr aFeature = aFOperation->feature();
   if (aFeature.get()) { // feature may be not created (plugin load fail)
-    if (myDisplayer->isVisible(aFeature) && !myDisplayer->isActive(aFeature))
+    if (myDisplayer->isVisible(aFeature) && !selectionActivate()->isActive(aFeature))
       anObjects.append(aFeature);
     std::list<ResultPtr> aResults;
     ModelAPI_Tools::allResults(aFeature, aResults);
     std::list<ResultPtr>::const_iterator aIt;
     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
       ResultPtr anObject = *aIt;
-      if (myDisplayer->isVisible(anObject) && !myDisplayer->isActive(anObject)) {
+      if (myDisplayer->isVisible(anObject) && !selectionActivate()->isActive(anObject)) {
         anObjects.append(anObject);
       }
     }
@@ -1535,7 +1533,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 
 #ifdef DEBUG_WITH_MESSAGE_REPORT
         Handle(Message_Report) aContextReport = aContext->GetReport();
-        aContextReport->SetActive (Standard_True);
+        aContext->SetReportActive (Standard_True);
         aContextReport->SetLimit (1000);
         if (!aContextReport.IsNull())
           aParameters.Append(aContextReport);
@@ -1579,10 +1577,6 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 //**************************************************************
 void XGUI_Workshop::setViewerSelectionMode(int theMode)
 {
-  XGUI_ActiveControlSelector* anActiveSelector = activeControlMgr()->activeSelector();
-  if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
-    facesPanel()->setActivePanel(false);
-
   if (theMode == -1)
     myViewerSelMode.clear();
   else {
@@ -1591,7 +1585,7 @@ void XGUI_Workshop::setViewerSelectionMode(int theMode)
     else
       myViewerSelMode.append(theMode);
   }
-  activateObjectsSelection(myDisplayer->displayedObjects());
+  selectionActivate()->updateSelectionModes();
 }
 
 //**************************************************************
@@ -1601,7 +1595,7 @@ void XGUI_Workshop::activateObjectsSelection(const QObjectPtrList& theList)
   module()->activeSelectionModes(aModes);
   if (aModes.isEmpty() && (myViewerSelMode.length() > 0))
     aModes.append(myViewerSelMode);
-  myDisplayer->activateObjects(aModes, theList);
+  selectionActivate()->activateObjects(aModes, theList);
 }
 
 //**************************************************************
index 8267dff5a813cd7f160502354d3eebd85537d359..e8fc6c9908a141f7749711b81559577346050696 100755 (executable)
@@ -30,6 +30,8 @@
 #include <ModuleBase_ActionType.h>
 #include <ModuleBase_Definitions.h>
 
+#include <SelectMgr_ListOfFilter.hxx>
+
 #include <QIcon>
 #include <QObject>
 #include <QKeySequence>
@@ -57,6 +59,7 @@ class XGUI_OperationMgr;
 class XGUI_PropertyPanel;
 class XGUI_SalomeConnector;
 class XGUI_SalomeViewer;
+class XGUI_SelectionActivate;
 class XGUI_SelectionMgr;
 class XGUI_ViewerProxy;
 class XGUI_WorkshopListener;
@@ -103,6 +106,9 @@ Q_OBJECT
   /// Returns selection manager object
   XGUI_SelectionMgr* selector() const { return mySelector; }
 
+  /// Returns selection activating object
+  XGUI_SelectionActivate* selectionActivate() const { return mySelectionActivate; }
+
   /// Returns displayer
   XGUI_Displayer* displayer() const { return myDisplayer; }
 
@@ -290,6 +296,10 @@ Q_OBJECT
   /// Returns defailt selection mode in 3d viewer
   QIntList viewerSelectionModes() const { return myViewerSelMode; }
 
+  /// Appends into container of workshop selection filters
+  /// \param [out] selection filters
+  void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
   /// Highlights result objects in Object Browser according to
   /// features found in the given list
   void highlightResults(const QObjectPtrList& theObjects);
@@ -503,6 +513,7 @@ private:
   XGUI_PropertyPanel* myPropertyPanel; ///< container of feature attributes widgets
   XGUI_FacesPanel* myFacesPanel; ///< panel for hide object faces
   XGUI_SelectionMgr* mySelector; ///< handler of selection processing
+  XGUI_SelectionActivate* mySelectionActivate; /// manager of selection activating
   XGUI_Displayer* myDisplayer; ///< handler of objects display
   XGUI_OperationMgr* myOperationMgr;  ///< manager to manipulate through the operations
   XGUI_ActionsMgr* myActionsMgr; ///< manager of workshop actions