]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Apply button to be disabled during value modification for any operation, not only...
authornds <nds@opencascade.com>
Fri, 16 Oct 2015 06:12:05 +0000 (09:12 +0300)
committernds <nds@opencascade.com>
Fri, 16 Oct 2015 06:12:05 +0000 (09:12 +0300)
src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 27e71bfc89fa62ea2e036f475b3e2c0fbc657abe..859b43fa6b6a441529c004fc12e729a15a37db52 100644 (file)
@@ -188,6 +188,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   //! \return string value\r
   virtual QString getFeatureError(const FeaturePtr& theFeature);\r
 \r
+  /// Connects or disconnects to the value changed signal of the property panel widgets\r
+  /// \param theWidget a property contol widget\r
+  /// \param isToConnect a boolean value whether connect or disconnect\r
+  virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect) {};\r
+\r
 signals:\r
   /// Signal which is emitted when operation is launched\r
   void operationLaunched();\r
index b60fe129bb329a3270e2c06e0be4b7d2c2a816a4..dd096b6a4a095a85fbcb0e8ba3499d0ea7a39a0b 100755 (executable)
@@ -244,6 +244,11 @@ void PartSet_Module::registerProperties()
                                    Config_Prop::Integer, SKETCH_WIDTH);
 }
 
+void PartSet_Module::connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect)
+{
+  mySketchMgr->connectToPropertyPanel(theWidget, isToConnect);
+}
+
 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) 
 {
   if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
index d28cae00f24f5bb2dfcf88283b969d0414478340..79445f445da0913b4e189b083de1ec1a849bb26a 100644 (file)
@@ -254,6 +254,11 @@ protected slots:
   /// Register properties of this module
   virtual void registerProperties();
 
+  /// Connects or disconnects to the value changed signal of the property panel widgets
+  /// \param theWidget a property contol widget
+  /// \param isToConnect a boolean value whether connect or disconnect
+  virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect);
+
  private slots:
    /// Processing of vertex selected
    void onVertexSelected();
index d26b9dde718b47d1f0c13b6628df0cbae83a8d36..6c94099d987ac067eb11a9dbc795cafc868c6af4 100644 (file)
@@ -265,13 +265,6 @@ void PartSet_SketcherMgr::onLeaveViewPort()
   }
 }
 
-void PartSet_SketcherMgr::onValueStateChanged()
-{
-  ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
-  if (anActiveWidget && anActiveWidget->getValueState() != ModuleBase_ModelWidget::Stored)
-    operationMgr()->onValidateOperation();
-}
-
 void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
 {
   if (isNestedCreateOperation(getCurrentOperation()))
@@ -911,14 +904,12 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
 
 void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
 {
-  connectToPropertyPanel(true);
   if (isNestedCreateOperation(theOperation) && myIsMouseOverWindow)
     QApplication::setOverrideCursor(QCursor(Qt::CrossCursor));//QIcon(":pictures/button_plus.png").pixmap(20,20)));
 }
 
 void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp)
 {
-  connectToPropertyPanel(false);
   myIsMouseOverViewProcessed = true;
   operationMgr()->onValidateOperation();
   if (isNestedCreateOperation(theOp))
@@ -1193,32 +1184,21 @@ void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
   }
 }
 
-void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
+void PartSet_SketcherMgr::connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect)
 {
-  ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
-  XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
-  if (aPropertyPanel) {
-    const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
-    foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
-      if (isToConnect) {
-        connect(aWidget, SIGNAL(beforeValuesChanged()),
+  if (isToConnect) {
+    connect(theWidget, SIGNAL(beforeValuesChanged()),
+            this, SLOT(onBeforeValuesChangedInPropertyPanel()));
+    connect(theWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+    connect(theWidget, SIGNAL(afterValuesChanged()),
+            this, SLOT(onAfterValuesChangedInPropertyPanel()));
+  }
+  else {
+    disconnect(theWidget, SIGNAL(beforeValuesChanged()),
                 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
-        connect(aWidget, SIGNAL(valueStateChanged()),
-                this, SLOT(onValueStateChanged()));
-        connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
-        connect(aWidget, SIGNAL(afterValuesChanged()),
+    disconnect(theWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+    disconnect(theWidget, SIGNAL(afterValuesChanged()),
                 this, SLOT(onAfterValuesChangedInPropertyPanel()));
-      }
-      else {
-        disconnect(aWidget, SIGNAL(beforeValuesChanged()),
-                   this, SLOT(onBeforeValuesChangedInPropertyPanel()));
-        disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
-        disconnect(aWidget, SIGNAL(afterValuesChanged()),
-                   this, SLOT(onAfterValuesChangedInPropertyPanel()));
-      }
-    }
   }
 }
 
index f5f38555dfd8980117ee168cdd1338cc407c2930..66666c1901228ae5da9b2f47ada0f004945522b0 100644 (file)
@@ -191,6 +191,11 @@ public:
   /// \param theModes a list of modes
   static void sketchSelectionModes(QIntList& theModes);
 
+  /// Connects or disconnects to the value changed signal of the property panel widgets
+  /// \param theWidget a property contol widget
+  /// \param isToConnect a boolean value whether connect or disconnect
+  void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect);
+
 public slots:
   /// Process sketch plane selected event
   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
@@ -205,9 +210,6 @@ private slots:
   /// Process the leave mouse of the view port. If the current operation is a create of
   /// a nested sketch feature, it hides the feature in the viewer
   void onLeaveViewPort();
-
-  /// Validates the operation. Apply button is disabled if the widget value is in Modified state
-  void onValueStateChanged();
   /// Listens to the value changed signal and display the current operation feature
   void onBeforeValuesChangedInPropertyPanel();
   /// Listens to the signal about values are to be changed in the property panel
@@ -269,10 +271,6 @@ private:
                                   const FeatureToSelectionMap& theSelection,
                                   SelectMgr_IndexedMapOfOwner& anOwnersToSelect);
 
-  /// Connects or disconnects to the value changed signal of the property panel widgets
-  /// \param isToConnect a boolean value whether connect or disconnect
-  void connectToPropertyPanel(const bool isToConnect);
-
   /// Returns true if the created feature is visible
   /// \param 
   bool isVisibleCreatedFeature() const;
index 343e3a6fb30d261b4e90d8d7051d2e9e54c0e289..56228ab22b1b27868d59c78d5a38f3a81be80226 100644 (file)
@@ -459,6 +459,7 @@ void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation)
   }
   updateCommandStatus();
 
+  connectToPropertyPanel(true);
   myModule->operationStarted(aFOperation);
 
   // the objects of the current operation should be deactivated
@@ -507,6 +508,7 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   hidePropertyPanel();
   myPropertyPanel->cleanContent();
 
+  connectToPropertyPanel(false);
   myModule->operationStopped(aFOperation);
 
   // the deactivated objects of the current operation should be activated back.
@@ -602,6 +604,23 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
   myErrorMgr->setPropertyPanel(myPropertyPanel);
 }
 
+void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect)
+{
+  XGUI_PropertyPanel* aPropertyPanel = propertyPanel();
+  if (aPropertyPanel) {
+    const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+    foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+       myModule->connectToPropertyPanel(aWidget, isToConnect);
+      if (isToConnect) {
+        connect(aWidget, SIGNAL(valueStateChanged()), this, SLOT(onValueStateChanged()));
+      }
+      else {
+        disconnect(aWidget, SIGNAL(valueStateChanged()), this, SLOT(onValueStateChanged()));
+      }
+    }
+  }
+}
+
 /*
  * Saves document with given name.
  */
@@ -836,6 +855,20 @@ void XGUI_Workshop::onPreferences()
   }
 }
 
+//******************************************************
+void XGUI_Workshop::onValueStateChanged()
+{
+  ModuleBase_ModelWidget* anActiveWidget = 0;
+  ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
+  if (anOperation) {
+    ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
+    if (aPanel)
+      anActiveWidget = aPanel->activeWidget();
+  }
+  if (anActiveWidget && anActiveWidget->getValueState() != ModuleBase_ModelWidget::Stored)
+    operationMgr()->onValidateOperation();
+}
+
 //******************************************************
 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
 {
index 628e721ce5bcd756319cc8ce474801f882d82226..6a72b02d5821db8c79f2780cac28df4cbdf40aa6 100644 (file)
@@ -304,6 +304,9 @@ signals:
   /// Rebuild data tree
   void onRebuild();
 
+  /// Validates the operation. Apply button is disabled if the widget value is in Modified state
+  void onValueStateChanged();
+
   /// Open preferences dialog box
   void onPreferences();
 
@@ -333,6 +336,10 @@ signals:
   /// \param theOperation an operation
   void setPropertyPanel(ModuleBase_Operation* theOperation);
 
+  /// Connects or disconnects to the value changed signal of the property panel widgets
+  /// \param isToConnect a boolean value whether connect or disconnect
+  void connectToPropertyPanel(const bool isToConnect);
+
 private:
   /// Display all results
   //void displayAllResults();