From: nds Date: Fri, 16 Oct 2015 06:12:05 +0000 (+0300) Subject: Apply button to be disabled during value modification for any operation, not only... X-Git-Tag: V_2.0.0_alfa1~53 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bf2f4cb0bc279c743be57c30ac9feb8b829fef3a;p=modules%2Fshaper.git Apply button to be disabled during value modification for any operation, not only Sketch. Checked on Extrusion and on Edit operation. --- diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h old mode 100644 new mode 100755 index 78e68b550..ed5ad0456 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -191,6 +191,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// Returns list of granted operation indices virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const; + /// 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) {}; + signals: /// Signal which is emitted when operation is launched void operationLaunched(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ce68a0c8d..3ff904eab 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -246,6 +246,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)) { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 3ff88e6c6..06241521f 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -257,6 +257,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(); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 60e578113..9ea9e0596 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -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())) @@ -918,14 +911,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)) @@ -1200,32 +1191,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(anIWorkshop); - XGUI_Workshop* aWorkshop = aConnector->workshop(); - XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel(); - if (aPropertyPanel) { - const QList& 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())); - } - } } } diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index d2a5226ed..3ea2f1fbf 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -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& 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; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp old mode 100644 new mode 100755 index e484aa493..a36332730 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -460,6 +460,7 @@ void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation) } updateCommandStatus(); + connectToPropertyPanel(true); myModule->operationStarted(aFOperation); // the objects of the current operation should be deactivated @@ -508,6 +509,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. @@ -607,6 +609,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& 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. */ @@ -843,6 +862,20 @@ void XGUI_Workshop::onRebuild() } //****************************************************** +} + +//****************************************************** +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) { QString libName = QString::fromStdString(library(theModule.toStdString())); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h old mode 100644 new mode 100755 index 5d03eefe5..25a71105f --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -299,6 +299,9 @@ signals: /// Rebuild data tree void onRebuild(); + /// Validates the operation. Apply button is disabled if the widget value is in Modified state + void onValueStateChanged(); + /// Show property panel void showPropertyPanel(); @@ -339,6 +342,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();