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-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5844079e74d55a2525dc15ca5de4b63095a8daae;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 859b43fa6..3219da1fb 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -193,6 +193,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_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index 81c53126d..734edb19b 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -268,8 +268,6 @@ bool ModuleBase_OperationFeature::commit() ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel(); if (aPropertyPanel) { ModuleBase_ModelWidget* aWidget = aPropertyPanel->activeWidget(); - if (aWidget) - aWidget->storeValueByApply(); aPropertyPanel->cleanContent(); } SessionPtr aMgr = ModelAPI_Session::get(); 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 100b7ea3e..3b19b6b2e 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1067,3 +1067,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 index 79445f445..2a5cb017f 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -200,6 +200,10 @@ public: //! \return string value virtual QString getFeatureError(const FeaturePtr& theFeature); + /// 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 @@ -244,7 +248,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 167fad759..ac623b3c9 100644 --- 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); @@ -1193,19 +1177,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 66666c190..b82f5a871 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 5a4dda830..e75b44130 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -116,8 +116,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())); } } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index c09f7d584..61d6b5021 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -612,10 +612,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))); } } } @@ -856,7 +856,7 @@ void XGUI_Workshop::onPreferences() } //****************************************************** -void XGUI_Workshop::onValueStateChanged() +void XGUI_Workshop::onWidgetStateChanged(int thePreviousState) { ModuleBase_ModelWidget* anActiveWidget = 0; ModuleBase_Operation* anOperation = myOperationMgr->currentOperation(); @@ -867,6 +867,8 @@ void XGUI_Workshop::onValueStateChanged() } if (anActiveWidget) operationMgr()->onValidateOperation(); + + myModule->widgetStateChanged(thePreviousState); } //****************************************************** diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 6a72b02d5..281a61f9f 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -304,8 +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(); + /// Validates the operation to change the "Apply" button state. + /// \param thePreviousState the previous state of the widget + void onWidgetStateChanged(int thePreviousState); /// Open preferences dialog box void onPreferences();