-
-FeaturePtr ModuleBase_WidgetDoubleValue::createParameter(const QString& theText) const
-{
- FeaturePtr aParameter;
- QStringList aList = theText.split("=");
- QString aParamName = aList.at(0).trimmed();
-
- if (isNameExist(aParamName)) {
- return aParameter;
- }
-
- if (!ModelAPI_Expression::isVariable(aParamName.toStdString())) {
- return aParameter;
- }
-
- QString aExpression = aList.at(1).trimmed();
- if (aExpression.isEmpty()) {
- return aParameter;
- }
-
- SessionPtr aMgr = ModelAPI_Session::get();
- std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
-
- aParameter = aDoc->addFeature("Parameter");
- if (aParameter.get()) {
- AttributeStringPtr aNameAttr = aParameter->string("variable");
- aNameAttr->setValue(aParamName.toStdString());
-
- AttributeStringPtr aExprAttr = aParameter->string("expression");
- aExprAttr->setValue(aExpression.toStdString());
- aParameter->execute();
-
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- }
- return aParameter;
-}
-
-bool ModuleBase_WidgetDoubleValue::isNameExist(const QString& theName) const
-{
- SessionPtr aMgr = ModelAPI_Session::get();
- std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
- FeaturePtr aParamFeature;
- int aNbFeatures = aDoc->numInternalFeatures();
- std::string aName = theName.toStdString();
- for (int i = 0; i < aNbFeatures; i++) {
- aParamFeature = aDoc->internalFeature(i);
- if (aParamFeature && aParamFeature->getKind() == "Parameter") {
- if ((myParameter != aParamFeature) && (aParamFeature->name() == aName))
- return true;
- }
- }
- return false;
-}
-
-void ModuleBase_WidgetDoubleValue::editParameter(const QString& theText)