From: nds Date: Fri, 30 Oct 2015 15:27:08 +0000 (+0300) Subject: Sketch->circle creation, move to PP, input valid value, Enter ->nothing is visualized. X-Git-Tag: V_2.0.0_alfa1~43 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=694c3ff1a0449659db85d40303428e6add7cc2c1;p=modules%2Fshaper.git Sketch->circle creation, move to PP, input valid value, Enter ->nothing is visualized. --- diff --git a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp index 94387b2ec..114a27d6c 100644 --- a/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_DoubleSpinBox.cpp @@ -219,9 +219,9 @@ void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent) bool ModuleBase_DoubleSpinBox::focusNextPrevChild(bool theIsNext) { - myIsModified = false; + //myIsModified = false; - emit valueStored(); + //emit valueStored(); emit focusNextPrev(); return QDoubleSpinBox::focusNextPrevChild(theIsNext); } diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index ed5ad0456..f4d547d43 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -196,6 +196,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param isToConnect a boolean value whether connect or disconnect virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect) {}; + /// Validates the operation to change the "Apply" button state. + /// \param thePreviousState the previous state of the widget + virtual void widgetStateChanged(int thePreviousState) {}; + signals: /// Signal which is emitted when operation is launched void operationLaunched(); diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index db4a41f66..f0d330553 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -187,12 +187,12 @@ bool ModuleBase_ModelWidget::storeValue() return isDone; } -ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState(const ValueState& theState) +ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState(const ModuleBase_ModelWidget::ValueState& theState) { ValueState aState = myState; if (myState != theState && !myIsValueStateBlocked) { myState = theState; - emit valueStateChanged(); + emit valueStateChanged(aState); } return aState; } @@ -213,14 +213,6 @@ bool ModuleBase_ModelWidget::restoreValue() return isDone; } -void ModuleBase_ModelWidget::storeValueByApply() -{ - // do not emit signal about update the currenty feature object - // in order to do not perform additional redisplay in the viewer. - // It should happens by finish operation of the apply action - storeValueCustom(); -} - void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) { blockUpdateViewer(true); @@ -259,6 +251,17 @@ bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent) emit focusInWidget(this); } } + else if (theEvent->type() == QEvent::FocusOut) { + QFocusEvent* aFocusEvent = dynamic_cast(theEvent); + + Qt::FocusReason aReason = aFocusEvent->reason(); + bool aMouseOrKey = aReason == Qt::MouseFocusReason || + aReason == Qt::TabFocusReason || + aReason == Qt::BacktabFocusReason || + aReason == Qt::OtherFocusReason; // to process widget->setFocus() + if (aMouseOrKey && getControls().contains(aWidget) && getValueState() == ModifiedInPP) + storeValue(); + } // pass the event on to the parent class return QObject::eventFilter(theObject, theEvent); diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index f85549673..0942fcce7 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -102,10 +102,6 @@ Q_OBJECT /// \return True in success bool restoreValue(); - /// Saves the internal parameters to the given feature. Emits signals before and after store - /// \return True in success - void storeValueByApply(); - /// Set focus to the first control of the current widget. The focus policy of the control is checked. /// If the widget has the NonFocus focus policy, it is skipped. /// \return the state whether the widget can accept the focus @@ -206,7 +202,7 @@ signals: void focusOutWidget(ModuleBase_ModelWidget* theWidget); /// The signal about value state modification - void valueStateChanged(); + void valueStateChanged(int theState); void focusNextPrev(); void valueStored(); diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp index 3e040c4d3..624e04744 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp @@ -214,8 +214,8 @@ void ExpressionEditor::paintEvent( QPaintEvent* theEvent ) bool ExpressionEditor::focusNextPrevChild(bool theIsNext) { - emit valueStored(); - emit focusNextPrev(); + //emit valueStored(); + //emit focusNextPrev(); return QPlainTextEdit::focusNextPrevChild(theIsNext); } @@ -248,8 +248,8 @@ ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent, this->setLayout(aMainLay); connect(myEditor, SIGNAL(valueModified()), this, SIGNAL(valuesModified())); - connect(myEditor, SIGNAL(valueStored()), this, SLOT(onTextChanged())); - connect(myEditor, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); + //connect(myEditor, SIGNAL(valueStored()), this, SLOT(onTextChanged())); + //connect(myEditor, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev())); connect(myEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); /// The signal about key release on the control, that corresponds to the attribute diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.h b/src/ModuleBase/ModuleBase_WidgetExprEditor.h index 67d6453d6..0e81242bb 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.h +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.h @@ -66,8 +66,8 @@ class ExpressionEditor: public QPlainTextEdit signals: void valueModified(); /// A signal that is emitted by the "Tab" key event. It is emitted before the key is processed. - void valueStored(); - void focusNextPrev(); + //void valueStored(); + //void focusNextPrev(); /// The signal about key release on the control, that corresponds to the attribute /// \param theEvent key release event diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index c7623e387..4dba40553 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1104,3 +1104,9 @@ void PartSet_Module::onViewCreated(ModuleBase_IViewWindow*) } } } + +//****************************************************** +void PartSet_Module::widgetStateChanged(int thePreviousState) +{ + mySketchMgr->widgetStateChanged(thePreviousState); +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h old mode 100644 new mode 100755 index 06241521f..f879712a5 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -203,6 +203,10 @@ public: /// Returns list of granted operation indices virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const; + /// Validates the current operation and send the state change to sketch manager + /// \thePrevState the previous widget value state + virtual void widgetStateChanged(int thePreviousState); + public slots: /// SLOT, that is called by no more widget signal emitted by property panel /// Set a specific flag to restart the sketcher operation @@ -247,7 +251,7 @@ protected slots: /// A slot called on view window creation void onViewCreated(ModuleBase_IViewWindow*); - protected: +protected: /// Register validators for this module virtual void registerValidators(); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 03d2cb298..97a5ce43c 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -296,22 +296,6 @@ void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel() aDisplayer->updateViewer(); } -void PartSet_SketcherMgr::onValuesChangedInPropertyPanel() -{ - if (!isNestedCreateOperation(getCurrentOperation())) - return; - - operationMgr()->onValidateOperation(); - // the feature is to be erased here, but it is correct to call canDisplayObject because - // there can be additional check (e.g. editor widget in distance constraint) - ModuleBase_OperationFeature* aFOperation = dynamic_cast - (getCurrentOperation()); - if (aFOperation) { - FeaturePtr aFeature = aFOperation->feature(); - visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature)); - } -} - void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { get2dPoint(theWnd, theEvent, myClickedPoint); @@ -1200,19 +1184,31 @@ void PartSet_SketcherMgr::connectToPropertyPanel(ModuleBase_ModelWidget* theWidg 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())); - disconnect(theWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel())); disconnect(theWidget, SIGNAL(afterValuesChanged()), this, SLOT(onAfterValuesChangedInPropertyPanel())); } } +void PartSet_SketcherMgr::widgetStateChanged(int thePreviousState) +{ + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (getCurrentOperation()); + if (aFOperation) { + if (PartSet_SketcherMgr::isSketchOperation(aFOperation) || + PartSet_SketcherMgr::isNestedSketchOperation(aFOperation) && + thePreviousState == ModuleBase_ModelWidget::ModifiedInPP) { + FeaturePtr aFeature = aFOperation->feature(); + visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature)); + } + } +} + ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const { return myModule->workshop()->currentOperation(); diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 3ea2f1fbf..577f9601d 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -196,6 +197,10 @@ public: /// \param isToConnect a boolean value whether connect or disconnect void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect); + /// Visualize the operation feature if the previous state is modified value in property panel + /// \thePrevState the previous widget value state + void widgetStateChanged(int thePreviousState); + public slots: /// Process sketch plane selected event void onPlaneSelected(const std::shared_ptr& thePln); @@ -212,8 +217,6 @@ private slots: void onLeaveViewPort(); /// 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 - void onValuesChangedInPropertyPanel(); /// Listens to the signal about the modification of the values have been done in the property panel void onAfterValuesChangedInPropertyPanel(); @@ -288,6 +291,7 @@ private: /// \param isToDisplay a flag about the display or erase the feature void visualizeFeature(const FeaturePtr& theFeature, const bool isEditOperation, const bool isToDisplay, const bool isFlushRedisplay = true); + private: XGUI_OperationMgr* operationMgr() const; diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index b5749c7ae..097d9145d 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -118,8 +118,8 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t this, SLOT(activateNextWidget(ModuleBase_ModelWidget*))); connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*))); - connect(aWidget, SIGNAL(focusNextPrev()), - this, SLOT(onFocusNextPrev())); + //connect(aWidget, SIGNAL(focusNextPrev()), + // this, SLOT(onFocusNextPrev())); } } @@ -331,4 +331,4 @@ void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent) theEvent->ignore(); } else ModuleBase_IPropertyPanel::closeEvent(theEvent); -} \ No newline at end of file +} diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index ceb3f817d..cb519a969 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -617,10 +617,10 @@ void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect) foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { myModule->connectToPropertyPanel(aWidget, isToConnect); if (isToConnect) { - connect(aWidget, SIGNAL(valueStateChanged()), this, SLOT(onValueStateChanged())); + connect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int))); } else { - disconnect(aWidget, SIGNAL(valueStateChanged()), this, SLOT(onValueStateChanged())); + disconnect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int))); } } } @@ -865,7 +865,7 @@ void XGUI_Workshop::onRebuild() } //****************************************************** -void XGUI_Workshop::onValueStateChanged() +void XGUI_Workshop::onWidgetStateChanged(int thePreviousState) { ModuleBase_ModelWidget* anActiveWidget = 0; ModuleBase_Operation* anOperation = myOperationMgr->currentOperation(); @@ -876,6 +876,8 @@ void XGUI_Workshop::onValueStateChanged() } if (anActiveWidget) operationMgr()->onValidateOperation(); + + myModule->widgetStateChanged(thePreviousState); 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 index 25a71105f..5aa9e7802 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -299,8 +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(); + /// Validates the operation to change the "Apply" button state. + /// \param thePreviousState the previous state of the widget + void onWidgetStateChanged(int thePreviousState); /// Show property panel void showPropertyPanel();