]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1343 Improvement of Extrusion and Revolution operations: disable selection...
authornds <nds@opencascade.com>
Tue, 22 Mar 2016 06:24:56 +0000 (09:24 +0300)
committerdbv <dbv@opencascade.com>
Wed, 6 Apr 2016 10:21:38 +0000 (13:21 +0300)
src/ModuleBase/ModuleBase_ModelWidget.h
src/PartSet/PartSet_WidgetMultiSelectorComposite.cpp
src/PartSet/PartSet_WidgetMultiSelectorComposite.h
src/PartSet/PartSet_WidgetSketchCreator.cpp
src/PartSet/PartSet_WidgetSketchCreator.h

index 9162f46755355deba90d325f7c9c62f6ad10d1f8..279d1e77453e2894f4d00cfe3be094c14ce54dc2 100644 (file)
@@ -170,7 +170,7 @@ Q_OBJECT
   void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false);
 
   /// Editing mode depends on mode of current operation. This value is defined by it.
-  void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
+  virtual void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
 
   /// \return Current Editing mode
   bool isEditingMode() const { return myIsEditing; }
index 32bd055cc194a2680ca6392fb3267e1408f948ff..fb1238c3ab69e411a3f4d0e17fdf89f5cd14df1c 100755 (executable)
@@ -19,17 +19,32 @@ PartSet_WidgetMultiSelectorComposite::~PartSet_WidgetMultiSelectorComposite()
 
 bool PartSet_WidgetMultiSelectorComposite::focusTo()
 {
-  bool aCanSetFocus = true;
-  CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
-  if (aComposite.get())
-    aCanSetFocus = aComposite->numberOfSubs() == 0;
+  bool aHasSubObjects = hasSubObjects();
 
   // disable widget controls
-  if (!aCanSetFocus) {
+  if (aHasSubObjects)
     disableControls();
-  }
 
-  return aCanSetFocus;
+  return !aHasSubObjects;
+}
+
+void PartSet_WidgetMultiSelectorComposite::setEditingMode(bool isEditing)
+{
+  ModuleBase_ModelWidget::setEditingMode(isEditing);
+  bool aHasSubObjects = hasSubObjects();
+  if (aHasSubObjects)
+    disableControls();
+}
+
+bool PartSet_WidgetMultiSelectorComposite::hasSubObjects() const
+{
+  bool aHasSubObjects = false;
+
+  bool aCanSetFocus = true;
+  CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+  if (aComposite.get())
+    aHasSubObjects = aComposite->numberOfSubs() > 0;
+  return aHasSubObjects;
 }
 
 void PartSet_WidgetMultiSelectorComposite::disableControls()
index 62afac31c65e4eb5b3e94b1607a5391af1c46ae5..4cfd940a0cd4074f3a9bb57ccb83d73f6832dc03 100755 (executable)
@@ -36,7 +36,14 @@ Q_OBJECT
   /// \return the state whether the widget can accept the focus
   virtual bool focusTo();
 
+  /// Editing mode depends on mode of current operation. This value is defined by it.
+  virtual void setEditingMode(bool isEditing);
+
 private:
+  /// Returns true if the current composite feature contains at least one sub-object
+  /// \return boolean value
+  bool hasSubObjects() const;
+
   /// Disable controls by setting them focus policy NoFocus and disabling them
   void disableControls();
 };
index 972a0e7a894137502ae9bd3024c684c5e962c8dc..4e9ccb983cae8896a397e0d8772ba6a4c76663e4 100644 (file)
@@ -16,6 +16,7 @@
 #include <XGUI_SelectionMgr.h>
 #include <XGUI_OperationMgr.h>
 #include <XGUI_PropertyPanel.h>
+#include <XGUI_Tools.h>
 
 #include <GeomAPI_Face.h>
 
@@ -130,8 +131,7 @@ void PartSet_WidgetSketchCreator::activateCustom()
 void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelectionControl)
 {
   // hide current widget, activate the next widget
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
   XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
   const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
   foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
@@ -159,9 +159,15 @@ QIntList PartSet_WidgetSketchCreator::getShapeTypes() const
 
 void PartSet_WidgetSketchCreator::deactivate()
 {
-  if (isSelectionMode()) {
-    ModuleBase_WidgetSelector::activateCustom();
-  }
+  if (isSelectionMode())
+    ModuleBase_WidgetSelector::deactivate();
+}
+
+void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing)
+{
+  ModuleBase_ModelWidget::setEditingMode(isEditing);
+  if (isEditing)
+    setVisibleSelectionControl(false);
 }
 
 bool PartSet_WidgetSketchCreator::isSelectionMode() const
@@ -326,8 +332,10 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
   CompositeFeaturePtr aSketchFeature = 
     std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
   if (aSketchFeature->numberOfSubs() == 0) {
+    // do nothing, selection control should be shown
+
     // Abort operation
-    SessionPtr aMgr = ModelAPI_Session::get();
+    //SessionPtr aMgr = ModelAPI_Session::get();
     // Close transaction
     /*
     bool aIsOp = aMgr->isOperation();
@@ -336,8 +344,17 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
       aMgr->startOperation(aNestedOpID, true);
     }
     */
-    theOp->abort();
+    //theOp->abort();
   } else {
+    // Update value in attribute selection list
+    XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
+    XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
+    const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
+    foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
+      if (aWidget->attributeID() == myAttributeListID)
+        aWidget->restoreValue();
+    }
+
     // Hide sketcher result
     std::list<ResultPtr> aResults = aSketchFeature->results();
     std::list<ResultPtr>::const_iterator aIt;
@@ -346,22 +363,23 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
     }
     aSketchFeature->setDisplayed(false);
 
+    // restore value in the selection control
+
+
+    // Add Selected body were created the sketcher to list of selected objects
     if(myUseBody) {
-      // Add Selected body were created the sketcher to list of selected objects
-      DataPtr aData = aSketchFeature->data();
-      AttributeSelectionPtr aSelAttr = 
-        std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-        (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
-      if (aSelAttr.get()) {
-        ResultPtr aRes = aSelAttr->context();
-        GeomShapePtr aShape = aSelAttr->value();
+      std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID();
+      AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute);
+      if (aSelList.get()) {
+        DataPtr aData = aSketchFeature->data();
+        AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+                                      (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+        ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr();
         if (aRes.get()) {
-          std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID();
           SessionPtr aMgr = ModelAPI_Session::get();
           ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
           AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute);
           std::string aValidatorID, anError;
-          AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute);
           aSelList->append(aRes, GeomShapePtr());
           if (aFactory->validate(anAttribute, aValidatorID, anError))
             updateObject(aCompFeature);
index a03e7102136696e90305b7fd01ae53494f299518..f6f56f8a2b52484cf5a8154d87e03f84afd7fc55 100644 (file)
@@ -50,6 +50,9 @@ public:
   /// The methiod called when widget is deactivated
   virtual void deactivate();
 
+  /// Editing mode depends on mode of current operation. This value is defined by it.
+  virtual void setEditingMode(bool isEditing);
+
 protected:
   /// Saves the internal parameters to the given feature
   /// \return True in success