Salome HOME
Issue #1412: Activate selection mode FACES for sketcher only in operations with selector:
authornds <nds@opencascade.com>
Fri, 27 May 2016 08:00:25 +0000 (11:00 +0300)
committernds <nds@opencascade.com>
Fri, 27 May 2016 08:01:19 +0000 (11:01 +0300)
correction for wrong case in Extrusion operation.
New custom selection modes(Face, Wire) are implemented in Sketch presentation which is switched on by module when corresponded standard modes are mentioned in XML. It is switched on/off when the Property panel widget control is activated.

src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_ResultSketchPrs.cpp
src/PartSet/PartSet_ResultSketchPrs.h
src/SketcherPrs/SketcherPrs_Tools.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_ModuleConnector.cpp

index f65b1d313dbad4bb4e689d3712aaf4b8a83ddf35..f12b751f318881db81973b8bf7069978549bd9c7 100755 (executable)
@@ -183,16 +183,6 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param theObject a model object\r
   virtual bool canActivateSelection(const ObjectPtr& theObject) const;\r
 \r
-  /// Returns true if the given selection mode can be activated for the given presentgation\r
-  /// \param theIO an object presentation\r
-  /// \param theMode selection mode\r
-  virtual bool canActivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const { return true; }\r
-\r
-  /// Returns true if the given selection mode must be deactivated for the given presentgation in any case\r
-  /// \param theIO an object presentation\r
-  /// \param theMode selection mode\r
-  virtual bool needDeactivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const { return false; }\r
-\r
   /// Reacts to the delete action in module\r
   /// \returns true if the action is processed\r
   virtual bool deleteObjects() { return false; };\r
@@ -207,6 +197,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param theModes a list of modes\r
   virtual void activeSelectionModes(QIntList& theModes) {}\r
 \r
+  /// Appends specific selection modes for the module to the list of types\r
+  /// \param theTypes a selection modes to be extended\r
+  virtual void customSubShapesSelectionModes(QIntList& theTypes) {}\r
+\r
   /// Activate custom presentation for the object. Default realization is empty.\r
   /// \param theFeature a feature instance\r
   /// \param theFlag a flag of level of customization, which means that only part of sub-elements\r
index b8b46fb90555be4072ae17092e1e5d3c6fd0e798..29948541da0becfe38e48255609b863be276c0ee 100755 (executable)
@@ -526,6 +526,14 @@ void PartSet_Module::activeSelectionModes(QIntList& theModes)
     PartSet_SketcherMgr::sketchSelectionModes(theModes);
 }
 
+void PartSet_Module::customSubShapesSelectionModes(QIntList& theTypes)
+{
+  if (theTypes.contains(TopAbs_FACE))
+    theTypes.append(SketcherPrs_Tools::Sel_Sketch_Face);
+  if (theTypes.contains(TopAbs_WIRE))
+    theTypes.append(SketcherPrs_Tools::Sel_Sketch_Wire);
+}
+
 bool PartSet_Module::isMouseOverWindow()
 {
   return mySketchMgr->isMouseOverWindow();
@@ -1322,38 +1330,3 @@ void PartSet_Module::setDefaultConstraintShown()
   myHasConstraintShown[PartSet_Tools::Dimensional] = true;
   myHasConstraintShown[PartSet_Tools::Expressions] = false;
 }
-
-//******************************************************
-bool PartSet_Module::canActivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const
-{
-  /*if (theMode == TopAbs_FACE) {
-    Handle(PartSet_ResultSketchPrs) aSketchPrs = Handle(PartSet_ResultSketchPrs)::DownCast(theIO);
-    if (!aSketchPrs.IsNull()) {
-        ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-        if (anOperation) {
-          ModuleBase_IPropertyPanel* aPropPanel = anOperation->propertyPanel();
-          if (aPropPanel) {
-            ModuleBase_ModelWidget* aModelWgt = aPropPanel->activeWidget();
-            ModuleBase_WidgetSelector* aWgtSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aModelWgt);
-            if (aWgtSelector) {
-              return aWgtSelector->isFilterActivated();
-            } else
-              return true;
-          } else
-            return false;
-        } else
-          return false;
-    }
-  }*/
-  return true; 
-}
-
-//******************************************************
-bool PartSet_Module::needDeactivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const
-{
-  if (theMode == TopAbs_FACE) {
-   // Handle(PartSet_ResultSketchPrs) aSketchPrs = Handle(PartSet_ResultSketchPrs)::DownCast(theIO);
-   // return !aSketchPrs.IsNull();
-  }
-  return false;
-}
index 0c03bede41507900529d9a2cf4f46a27efdb95ad..237fd817bfb249e6c98cf1ca72f03c1102eee529 100755 (executable)
@@ -189,6 +189,10 @@ public:
   /// \param theModes a list of modes
   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);
+
   /// Returns whether the mouse enter the viewer's window
   /// \return true if items are added and there is no necessity to provide standard menu
   bool isMouseOverWindow();
@@ -307,16 +311,6 @@ public:
   /// \return theAttribute
   virtual AttributePtr findAttribute(const ObjectPtr& theObject, const GeomShapePtr& theGeomShape);
 
-  /// Returns true if the given selection mode can be activated for the given presentgation
-  /// \param theIO an object presentation
-  /// \param theMode selection mode
-  virtual bool canActivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const;
-
-  /// Returns true if the given selection mode must be deactivated for the given presentgation in any case
-  /// \param theIO an object presentation
-  /// \param theMode selection mode
-  virtual bool needDeactivateSelectionMode(const Handle(AIS_InteractiveObject)& theIO, int theMode) const;
-
 public slots:
   /// Redefines the parent method in order to customize the next case:
   /// If the sketch nested operation is active and the presentation is not visualized in the viewer,
index 384741cedf30442e8fa09f3275dde8409bc2beee..a07cfd490431463dc915434438af59fcac49583c 100755 (executable)
@@ -18,6 +18,8 @@
 
 #include <SketchPlugin_SketchEntity.h>
 
+#include <SketcherPrs_Tools.h>
+
 #include <Config_PropManager.h>
 
 #include <BRep_Builder.hxx>
@@ -120,15 +122,21 @@ void debugInfo(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType)
 #endif
 
 void PartSet_ResultSketchPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-                                            const Standard_Integer aMode)
+                                            const Standard_Integer theMode)
 {
-  if (aMode > 8)
+  int aMode = theMode;
+
+  if (aMode > 8 &&
+      aMode != SketcherPrs_Tools::Sel_Sketch_Face &&
+      aMode != SketcherPrs_Tools::Sel_Sketch_Wire)
     // In order to avoid using custom selection modes
     return;
 
   bool aShapeIsChanged = false;
-  if (aMode == AIS_Shape::SelectionMode(TopAbs_FACE) ||
-      aMode == AIS_Shape::SelectionMode(TopAbs_WIRE)) {
+  if (aMode == SketcherPrs_Tools::Sel_Sketch_Face ||
+      aMode == SketcherPrs_Tools::Sel_Sketch_Wire) {
+    aMode = (aMode == SketcherPrs_Tools::Sel_Sketch_Face) ? AIS_Shape::SelectionMode(TopAbs_FACE)
+                                                          : AIS_Shape::SelectionMode(TopAbs_WIRE);
 #ifdef DEBUG_WIRE
     const TopoDS_Shape& aShape = Shape();
     debugInfo(aShape, TopAbs_VERTEX); // 24
index ddf21d1ecd72d143e2a0bd0be691425b1daf6325..f303adec9999dcfec9b41c35a4335a3b5ee2370c 100755 (executable)
@@ -37,7 +37,7 @@ protected:
 
   /// Redefinition of virtual function
   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-    const Standard_Integer aMode) ;
+    const Standard_Integer theMode) ;
 
 private:
   /// Appens sensitive and owners for wires of the given shape into selection
index a17dc49371c44205dedb472f2a19b7f6b403164b..cfc15dbfc6c06cb1dcc2c4cc9be00870963739e6 100644 (file)
@@ -72,8 +72,14 @@ namespace SketcherPrs_Tools {
     /// Selection mode for line of dimension
     Sel_Dimension_Line,
 
-    /// Selection mode foe text of dimension
-    Sel_Dimension_Text
+    /// Selection mode for text of dimension
+    Sel_Dimension_Text,
+
+    /// Selectiom mode for faces selection on sketch
+    Sel_Sketch_Face,
+
+    /// Selectiom mode for wires selection on sketch
+    Sel_Sketch_Wire
   };
 
   /// Type of angle
index 4c41e5243c7a7f1dbe4f765ee0f72997a5cd4580..2b3b043e43e6ea506b533149e2a585c6befcd0ec 100644 (file)
@@ -887,8 +887,7 @@ void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO,
   if (!aContext.IsNull()) {
     if (myWorkshop->module()) {
       int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode);
-      if (myWorkshop->module()->canActivateSelectionMode(theIO, aMode))
-        aContext->Activate(theIO, theMode, false);
+      aContext->Activate(theIO, theMode, false);
     } else
       aContext->Activate(theIO, theMode, false);
 
@@ -1160,7 +1159,7 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
   for (; itr.More(); itr.Next() ) {
     Standard_Integer aMode = itr.Value();
     int aShapeMode = (aMode > 8)? aMode : AIS_Shape::SelectionType(aMode);
-    if (!theModes.contains(aMode) || (myWorkshop->module()->needDeactivateSelectionMode(theIO, aShapeMode))) {
+    if (!theModes.contains(aMode)) {
       deactivateAIS(theIO, aMode);
       isDeactivated = true;
     }
index 8fd52e598bfc06d6568a75d85aea966398421a86..4163952e319710d777fcd7b81f62fc5893dbd2e6 100644 (file)
@@ -79,8 +79,11 @@ QObjectPtrList XGUI_ModuleConnector::activeObjects(const QObjectPtrList& theObjL
 
 void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
 {
+  QIntList aTypes = theTypes;
+
   XGUI_Displayer* aDisp = myWorkshop->displayer();
-  aDisp->activateObjects(theTypes, activeObjects(aDisp->displayedObjects()));
+  myWorkshop->module()->customSubShapesSelectionModes(aTypes);
+  aDisp->activateObjects(aTypes, activeObjects(aDisp->displayedObjects()));
 }
 
 void XGUI_ModuleConnector::deactivateSubShapesSelection()