Using the valueChanged() signal of the model widget to update the sketch feature visibility on creation.
myIsValueDefault = !theData->getProperty(ATTR_DEFAULT).empty();
myIsComputedDefault = false;
myAttributeID = theData ? theData->widgetId() : "";
+
+ connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
}
bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
}
}
+void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool theToStoreValue)
+{
+ myFeature = theFeature;
+ if (theToStoreValue)
+ storeValue();
+}
+
bool ModuleBase_ModelWidget::focusTo()
{
QList<QWidget*> aControls = getControls();
return QObject::eventFilter(theObject, theEvent);
}
+
+//**************************************************************
+void ModuleBase_ModelWidget::onWidgetValuesChanged()
+{
+ storeValue();
+}
return false;
}
- /// Saves the internal parameters to the given feature
- virtual bool storeValue() const = 0;
-
/// Restore value from attribute data to the widget's control
virtual bool restoreValue() = 0;
}
/// Set feature which is processing by active operation
- void setFeature(const FeaturePtr& theFeature)
- {
- myFeature = theFeature;
- }
+ /// \param theToStoreValue a value about necessity to store the widget value to the feature
+ void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false);
/// Editing mode depends on mode of current operation. This value is defined by it.
void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
/// The signal about widget values changed
void valuesChanged();
- /// The signal about widget values changed
- void controlValuesChanged();
-
/// The signal about key release on the control, that corresponds to the attribute
/// \param theEvent key release event
void keyReleased(QKeyEvent* theEvent);
void focusOutWidget(ModuleBase_ModelWidget* theWidget);
protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const = 0;
+
/// \brief Set the attribute name
/// \param theAttribute the string value with attribute name
void setAttributeID(const std::string& theAttribute)
/// \param theObj is object for moving
void moveObject(ObjectPtr theObj) const;
+protected slots:
+ /// Processing of values changed in model widget by store the current value to the feature
+ void onWidgetValuesChanged();
+
protected:
/// The attribute name of the model feature
virtual ~ModuleBase_WidgetBoolValue();
- virtual bool storeValue() const;
-
virtual bool restoreValue();
virtual QList<QWidget*> getControls() const;
QWidget* getControl() const;
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
private:
/// The check box
QCheckBox* myCheckBox;
virtual ~ModuleBase_WidgetChoice();
- virtual bool storeValue() const;
-
virtual bool restoreValue();
virtual bool focusTo();
/// \return a controls list
virtual QList<QWidget*> getControls() const;
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
private slots:
/// Slot called on combo box index change
void onCurrentIndexChanged(int theIndex);
aControlLay->setStretch(1, 1);
connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
- connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(controlValuesChanged()));
}
ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
virtual ~ModuleBase_WidgetDoubleValue();
- //! Saves the internal parameters to the given feature
- // \return True in success
- virtual bool storeValue() const;
-
//! Read value of corresponded attribute from data model to the input control
// \return True in success
virtual bool restoreValue();
// it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
// void onValueChanged();
- protected:
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
+protected:
/// Container for thw widget controls
QWidget* myContainer;
const std::string& theParentId);
virtual ~ModuleBase_WidgetFileSelector();
- virtual bool storeValue() const;
-
virtual bool restoreValue();
QWidget* getControl() const;
/// Processing of path changing
void onPathChanged();
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
protected:
/// Returns string containing formats
QString formatsString() const;
/// It returns false because this is an info widget
virtual bool canSetValue() const { return false; };
- virtual bool storeValue() const
- {
- return true;
- }
-
virtual bool restoreValue()
{
return true;
/// This control doesn't accept focus
virtual bool focusTo() { return false; }
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const
+ {
+ return true;
+ }
+
private:
/// A label control
QLabel* myLabel;
const std::string& theParentId);
virtual ~ModuleBase_WidgetLineEdit();
- virtual bool storeValue() const;
-
virtual bool restoreValue();
QWidget* getControl() const;
/// A slot for processing text changed event
void onTextChanged();
- private:
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
+private:
/// A line edit control
QLineEdit* myLineEdit;
const std::string& theParentId);
virtual ~ModuleBase_WidgetMultiSelector();
- /// Saves the internal parameters to the given feature
- virtual bool storeValue() const;
-
virtual bool restoreValue();
/// Returns the internal parent wiget control, that can be shown anywhere
void onListSelection();
protected:
- /// Provide filtering of selected shapes
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
+ /// Provide filtering of selected shapes
/// \param theShapesToFilter source list of shapes
/// \param theResult result list of shapes
void filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
virtual ~ModuleBase_WidgetShapeSelector();
- /// Saves the internal parameters to the given feature
- virtual bool storeValue() const;
-
virtual bool restoreValue();
/// Defines if it is supposed that the widget should interact with the viewer.
void onSelectionChanged();
protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
/// The methiod called when widget is activated
virtual void activateCustom();
void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
{
- if (PartSet_SketcherMgr::isSketchOperation(theOperation) ||
- PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
mySketchMgr->stopSketch(theOperation);
}
else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
if (isToConnect)
- connect(aWidget, SIGNAL(controlValuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+ connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
else
- disconnect(aWidget, SIGNAL(controlValuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+ disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
}
}
}
aGroupLay->addWidget(myXSpin, 0, 1);
connect(myXSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
- connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(controlValuesChanged()));
}
{
QLabel* aLabel = new QLabel(myGroupBox);
aGroupLay->addWidget(myYSpin, 1, 1);
connect(myYSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
- connect(myYSpin, SIGNAL(valueChanged(double)), this, SIGNAL(controlValuesChanged()));
}
}
myYSpin->blockSignals(false);
this->blockSignals(isBlocked);
- emit valuesChanged();
+ storeValue();
return true;
}
/// \param theValue the wrapped widget value
virtual bool setSelection(ModuleBase_ViewerPrs theValue);
- virtual bool storeValue() const;
-
virtual bool restoreValue();
/// Returns the internal parent wiget control, that can be shown anywhere
void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
/// The methiod called when widget is activated
virtual void activateCustom();
// Reconnect to local slot
disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
- connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(controlValuesChanged()));
}
PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance()
mySpinBox->blockSignals(true);
mySpinBox->setValue(aRadius);
mySpinBox->blockSignals(false);
- emit valuesChanged();
+ storeValue();
}
}
virtual ~PartSet_WidgetShapeSelector() {}
- virtual bool storeValue() const;
-
/// Set sketcher
/// \param theSketch a sketcher object
void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
CompositeFeaturePtr sketch() const { return mySketch; }
protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
/// Check the selected with validators if installed
virtual bool isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape);
virtual ~PartSet_WidgetConstraintShapeSelector() {}
- /// Saves the internal parameters to the given feature
- virtual bool storeValue() const;
-
/// Set sketcher
/// \param theSketch a sketcher object
void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
/// Retrurns installed sketcher
CompositeFeaturePtr sketch() const { return mySketch; }
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
private:
/// Pointer to a sketch
CompositeFeaturePtr mySketch;
virtual ~PartSet_WidgetSketchLabel();
- virtual bool storeValue() const
- {
- return true;
- }
-
virtual bool restoreValue()
{
return true;
void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const
+ {
+ return true;
+ }
+
/// The methiod called when widget is activated
virtual void activateCustom();
QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
- aWidget->setFeature(theOperation->feature());
+ bool isStoreValue = !theOperation->isEditOperation() &&
+ aWidget->isValueDefault() && !aWidget->isComputedDefault();
+ aWidget->setFeature(theOperation->feature(), isStoreValue);
aWidget->enableFocusProcessing();
- QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
- // Init default values
- if (!theOperation->isEditOperation() && aWidget->isValueDefault() && !aWidget->isComputedDefault()) {
- aWidget->storeValue();
- }
}
myPropertyPanel->setModelWidgets(aWidgets);
}
}
-//**************************************************************
-void XGUI_Workshop::onWidgetValuesChanged()
-{
- ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
- FeaturePtr aFeature = anOperation->feature();
-
- ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
-
- const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
- for (; anIt != aLast; anIt++) {
- ModuleBase_ModelWidget* aCustom = *anIt;
- if (aCustom && (aCustom == aSenderWidget)) {
- aCustom->storeValue();
- }
- }
-}
-
//**************************************************************
void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
{
/// \param isChecked a state of toggle if the action is checkable
void onContextMenuCommand(const QString& theId, bool isChecked);
- /// Processing of values changed in model widget
- void onWidgetValuesChanged();
-
/// Set waiting cursor
void onStartWaiting();