const static char* DOUBLE_WDG_MIN = "min";
const static char* DOUBLE_WDG_MAX = "max";
const static char* DOUBLE_WDG_STEP = "step";
-const static char* DOUBLE_WDG_DFLT = "default";
+const static char* DOUBLE_WDG_DEFAULT = "default";
+const static char* DOUBLE_WDG_DEFAULT_COMPUTED = "computed";
//toolbox/switch properties
const static char* CONTAINER_PAGE_NAME = "title";
class CONFIG_EXPORT Config_WidgetAPI
{
public:
- Config_WidgetAPI(std::string theRawXml);
virtual ~Config_WidgetAPI();
- //TODO(sbh): Make these fields protected, accessible only for WidgetFactory
- bool toNextWidget();
- bool toChildWidget();
- bool toParentWidget();
-
std::string widgetType() const;
bool isContainerWidget() const;
bool isPagedWidget() const;
std::string getProperty(const char* thePropName) const;
+ bool isComputedDefault() const;
+
+ protected:
+ /// These fields are accessible for ModuleBase_WidgetFactory only
+ Config_WidgetAPI(std::string theRawXml);
+ bool toNextWidget();
+ bool toChildWidget();
+ bool toParentWidget();
+
private:
xmlDocPtr myDoc;
xmlNodePtr myCurrentNode;
+ friend class ModuleBase_WidgetFactory;
};
#endif /* CONFIG_WIDGETAPI_H_ */
protected:
// accessible from the attributes
bool myIsInitialized;
+ bool myIsComputedDefault;
bool myIsArgument;
public:
myIsInitialized = true;
}
+ /// Returns true if attribute's default value was computed
+ MODELAPI_EXPORT bool isComputedDefault()
+ {
+ return myIsComputedDefault;
+ }
+
+ /// Tells that attribute's default value was computed
+ MODELAPI_EXPORT void setComputedDefault()
+ {
+ myIsComputedDefault = true;
+ myIsInitialized = false;
+ }
+
/// Set this attribute is argument for result (change of this attribute requires update of result).
/// By default it is true.
MODELAPI_EXPORT void setIsArgument(const bool theFlag)
ModelAPI_Attribute()
{
myIsInitialized = false;
+ myIsComputedDefault = false;
myIsArgument = true;
}
: QObject(theParent),
myParentId(theParentId)
{
+ myIsComputedDefault = false;
myAttributeID = theData ? theData->widgetId() : "";
}
return theObject->data()->attribute(attributeID())->isInitialized();
}
+void ModuleBase_ModelWidget::setAttributeComputedState(ObjectPtr theObject) const
+{
+ if(myIsComputedDefault)
+ theObject->data()->attribute(attributeID())->setComputedDefault();
+}
+
bool ModuleBase_ModelWidget::focusTo()
{
QList<QWidget*> aControls = getControls();
/// \return the boolean result
bool isInitialized(ObjectPtr theObject) const;
+ void setAttributeComputedState(ObjectPtr theObject) const;
+
+ bool isComputedDefault()
+ {
+ return myIsComputedDefault;
+ }
+
/// Saves the internal parameters to the given feature
/// \param theObject a model feature to be changed
virtual bool storeValue() const = 0;
void setFeature(const FeaturePtr& theFeature)
{
myFeature = theFeature;
+ if(theFeature)
+ setAttributeComputedState(theFeature);
}
signals:
std::string myAttributeID; /// the attribute name of the model feature
std::string myParentId; /// name of parent
FeaturePtr myFeature;
+
+ bool myIsComputedDefault;
};
#endif
mySpinBox->setSingleStep(aStepVal);
}
- aProp = theData->getProperty(DOUBLE_WDG_DFLT);
+ aProp = theData->getProperty(DOUBLE_WDG_DEFAULT);
double aDefVal = QString::fromStdString(aProp).toDouble(&isOk);
if (isOk) {
mySpinBox->setValue(aDefVal);
+ } else if (aProp == DOUBLE_WDG_DEFAULT_COMPUTED){
+ myIsComputedDefault = true;
}
QString aTTip = QString::fromStdString(theData->widgetTooltip());
{
}
-ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
- const std::string& theAttribute)
- : ModuleBase_WidgetDoubleValue(theParent, 0, "")
-{
- setAttributeID(theAttribute);
-}
-
ModuleBase_WidgetEditor::~ModuleBase_WidgetEditor()
{
}
} else if (theType == WDG_DOUBLEVALUE_EDITOR) {
result = doubleValueEditor(theParent);
- } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
- result = doubleValueEditor(theParent);
-
} else if (theType == WDG_POINT2D_DISTANCE) {
result = point2dDistanceControl(theParent);
<validator id="SketchPlugin_ResultArcValidator"/>
</feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
- <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
+ <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue" default="computed"/>
<validator id="PartSet_RadiusValidator"/>
</feature>
for (; anIt != aLast; anIt++) {
aWidget = *anIt;
aWidget->setFeature(aOperation->feature());
- //QObject::connect(aWidget, SIGNAL(valuesChanged()), aOperation, SLOT(storeCustomValue()));
QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
// Init default values
- if (!aOperation->isEditOperation()) {
- //aWidget->storeValue(aOperation->feature());
-
+ if (!aOperation->isEditOperation() && !aWidget->isComputedDefault()) {
aWidget->storeValue();
}
}