void Model_AttributeReference::setValue(ObjectPtr theObject)
{
+ if(!theObject)
+ return;
if (!myIsInitialized || value() != theObject) {
boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(
theObject->data());
ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData,
const std::string& theParentId)
: QObject(theParent),
- myHasDefaultValue(false),
myParentId(theParentId)
{
myAttributeID = theData ? theData->widgetId() : "";
/// \return a control list
virtual QList<QWidget*> getControls() const = 0;
- /// Returns whether the control has a default value
- /// \return a boolean value
- bool hasDefaultValue() const
- {
- return myHasDefaultValue;
- }
-
/// Returns the attribute name
/// \returns the string value
std::string attributeID() const
void updateObject(ObjectPtr theObj) const;
- bool myHasDefaultValue; /// the boolean state whether the control has a default value
-
std::string myAttributeID; /// the attribute name of the model feature
std::string myParentId; /// name of parent
FeaturePtr myFeature;
{
DataPtr aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
-
- if (aBool->value() != myCheckBox->isChecked()) {
- aBool->setValue(myCheckBox->isChecked());
- updateObject(myFeature);
- }
+ aBool->setValue(myCheckBox->isChecked());
+ updateObject(myFeature);
return true;
}
aProp = theData->getProperty(DOUBLE_WDG_DFLT);
double aDefVal = QString::fromStdString(aProp).toDouble(&isOk);
- myHasDefaultValue = isOk;
if (isOk) {
mySpinBox->setValue(aDefVal);
}
{
DataPtr aData = myFeature->data();
AttributeDoublePtr aReal = aData->real(attributeID());
- if (aReal->value() != mySpinBox->value()) {
- aReal->setValue(mySpinBox->value());
- updateObject(myFeature);
- }
+ aReal->setValue(mySpinBox->value());
+ updateObject(myFeature);
return true;
}
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
- myHasDefaultValue = false;
-
myTitle = QString::fromStdString(theData->getProperty("title"));
//TODO(sbh): Get them from the feature
myFormats = getSupportedFormats(theData);
{
DataPtr aData = myFeature->data();
AttributeStringPtr aStringAttr = aData->string(attributeID());
- QString aModelValue = QString::fromStdString(aStringAttr->value());
QString aWidgetValue = myPathField->text();
- if(aModelValue != aWidgetValue) {
- aStringAttr->setValue(aWidgetValue.toStdString());
- updateObject(myFeature);
- }
+ aStringAttr->setValue(aWidgetValue.toStdString());
+ updateObject(myFeature);
return true;
}
//QObject::connect(aWidget, SIGNAL(valuesChanged()), aOperation, SLOT(storeCustomValue()));
QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
// Init default values
- if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) {
+ if (!aOperation->isEditOperation()) {
//aWidget->storeValue(aOperation->feature());
aWidget->storeValue();