bool ModuleBase_DoubleSpinBox::focusNextPrevChild(bool theIsNext)
{
- myIsModified = false;
+ //myIsModified = false;
- emit valueStored();
+ //emit valueStored();
emit focusNextPrev();
return QDoubleSpinBox::focusNextPrevChild(theIsNext);
}
/// \param isToConnect a boolean value whether connect or disconnect\r
virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect) {};\r
\r
+ /// Validates the operation to change the "Apply" button state.\r
+ /// \param thePreviousState the previous state of the widget\r
+ virtual void widgetStateChanged(int thePreviousState) {};\r
+\r
signals:\r
/// Signal which is emitted when operation is launched\r
void operationLaunched();\r
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;
}
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);
emit focusInWidget(this);
}
}
+ else if (theEvent->type() == QEvent::FocusOut) {
+ QFocusEvent* aFocusEvent = dynamic_cast<QFocusEvent*>(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);
/// \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
void focusOutWidget(ModuleBase_ModelWidget* theWidget);
/// The signal about value state modification
- void valueStateChanged();
+ void valueStateChanged(int theState);
void focusNextPrev();
void valueStored();
ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel();
if (aPropertyPanel) {
ModuleBase_ModelWidget* aWidget = aPropertyPanel->activeWidget();
- if (aWidget)
- aWidget->storeValueByApply();
aPropertyPanel->cleanContent();
}
SessionPtr aMgr = ModelAPI_Session::get();
bool ExpressionEditor::focusNextPrevChild(bool theIsNext)
{
- emit valueStored();
- emit focusNextPrev();
+ //emit valueStored();
+ //emit focusNextPrev();
return QPlainTextEdit::focusNextPrevChild(theIsNext);
}
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
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
}
}
}
+
+//******************************************************
+void PartSet_Module::widgetStateChanged(int thePreviousState)
+{
+ mySketchMgr->widgetStateChanged(thePreviousState);
+}
//! \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
/// A slot called on view window creation
void onViewCreated(ModuleBase_IViewWindow*);
- protected:
+protected:
/// Register validators for this module
virtual void registerValidators();
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<ModuleBase_OperationFeature*>
- (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);
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<ModuleBase_OperationFeature*>
+ (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();
#include <ModuleBase_ViewerFilters.h>
#include <ModuleBase_Definitions.h>
+#include <ModuleBase_ModelWidget.h>
#include <GeomAPI_Pln.h>
#include <SelectMgr_IndexedMapOfOwner.hxx>
/// \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<GeomAPI_Pln>& thePln);
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();
/// \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;
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()));
}
}
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)));
}
}
}
}
//******************************************************
-void XGUI_Workshop::onValueStateChanged()
+void XGUI_Workshop::onWidgetStateChanged(int thePreviousState)
{
ModuleBase_ModelWidget* anActiveWidget = 0;
ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
}
if (anActiveWidget)
operationMgr()->onValidateOperation();
+
+ myModule->widgetStateChanged(thePreviousState);
}
//******************************************************
/// 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();