#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
+#include <TDataStd_UAttribute.hxx>
using namespace std;
{
return TCollection_AsciiString(myText->Get()).ToCString();
}
+
+Standard_GUID kInvalidGUID("caee5ce4-34b1-4b29-abcb-685287d18096");
+
+void Model_AttributeDouble::setExpressionInvalid(const bool theFlag)
+{
+ if (theFlag) {
+ TDataStd_UAttribute::Set(myReal->Label(), kInvalidGUID);
+ } else {
+ myReal->Label().ForgetAttribute(kInvalidGUID);
+ }
+}
+
+bool Model_AttributeDouble::expressionInvalid()
+{
+ return myReal->Label().IsAttribute(kInvalidGUID);
+}
/// Returns the double value
MODEL_EXPORT virtual std::string text();
+ /// Allows to set expression (text) as invalid (by the parameters listener)
+ MODEL_EXPORT virtual void setExpressionInvalid(const bool theFlag);
+
+ /// Returns true if text is invalid
+ MODEL_EXPORT virtual bool expressionInvalid();
+
protected:
/// Initializes attibutes
Model_AttributeDouble(TDF_Label& theLabel);
if (anIter == theCurrent) aPassed = true;
bool aDisabledFlag = !aPassed;
- if (aMain.get() && aMain->isSub(anIter))
+ if (aMain.get() && aMain->isSub(anIter)) // sub-elements of not-disabled feature are not disabled
+ aDisabledFlag = false;
+ if (anIter->getKind() == "Parameter") // parameters are always out of the history
aDisabledFlag = false;
if (anIter->setDisabled(aDisabledFlag)) {
// state of feature is changed => so feature become updated
ModelAPI_ExecState aState = theFeature->data()->execState();
if (aState == ModelAPI_StateInvalidArgument) // a chance to be corrected
aState = ModelAPI_StateMustBeUpdated;
- // check the parameters: values can be changed
- /* parameters evaluator now does this
+ // check the parameters state
std::list<AttributePtr> aDoubles =
theFeature->data()->attributes(ModelAPI_AttributeDouble::typeId());
std::list<AttributePtr>::iterator aDoubleIter = aDoubles.begin();
for(; aDoubleIter != aDoubles.end(); aDoubleIter++) {
AttributeDoublePtr aDouble =
std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(*aDoubleIter);
- if (aDouble.get() && !aDouble->text().empty()) {
- double aNewVal;
- if (ModelAPI_Tools::findVariable(aDouble->text(), aNewVal)) {
- if (aNewVal != aDouble->value()) {
- aDouble->setValue(aNewVal);
- aJustUpdated = true;
- }
- } else {
- aState = ModelAPI_StateInvalidArgument;
- }
+ if (aDouble.get() && aDouble->expressionInvalid()) {
+ aState = ModelAPI_StateInvalidArgument;
}
}
- */
//if (aState == ModelAPI_StateDone) {// all referenced objects are ready to be used
//std::cout<<"Execute feature "<<theFeature->getKind()<<std::endl;
/// Returns the double value
MODELAPI_EXPORT virtual std::string text() = 0;
+ /// Allows to set expression (text) as invalid (by the parameters listener)
+ MODELAPI_EXPORT virtual void setExpressionInvalid(const bool theFlag) = 0;
+
+ /// Returns true if text is invalid
+ MODELAPI_EXPORT virtual bool expressionInvalid() = 0;
+
/// Returns the type of this class of attributes
MODELAPI_EXPORT static std::string typeId()
{
double aValue = evaluate(aDoubleAttribute->text(), anError);
if (anError.empty()) {
aDoubleAttribute->setValue(aValue);
+ aDoubleAttribute->setExpressionInvalid(false);
+ } else { // set feature as invalid-parameter arguments
+ aDoubleAttribute->setExpressionInvalid(true);
}
}
} else {