Implement special keyword "main_argument" to mark concealed attribute as granting its name in case of several concealed attributes in the feature when the main attribute is not first.
{
myCases = theCases;
}
+
+bool Config_AttributeMessage::isMainArgument() const
+{
+ return myIsMainArgument;
+}
+
+void Config_AttributeMessage::setMainArgument(bool isMainArg)
+{
+ myIsMainArgument = isMainArg;
+}
std::string myFeatureId; ///< Attribute's feature's unique id
bool myIsObligatory; ///< Required to be set by user, else it's feature is invalid.
bool myIsConcealment; ///< If true, conceals features used as input
+ bool myIsMainArgument; ///< Mark attribute as a main argument of the feature
///< a list of pairs, if the attribute is placed inside paged containers: (case, switch)
std::list<std::pair<std::string, std::string> > myCases;
CONFIG_EXPORT bool isObligatory() const;
/// Returns true if attribute should conceal input features
CONFIG_EXPORT bool isConcealment() const;
+ /// Returns true if attribute is a main argument of the feature
+ CONFIG_EXPORT bool isMainArgument() const;
/// Returns container of ids of pair of a case and switches
CONFIG_EXPORT const std::list<std::pair<std::string, std::string> >& getCases() const;
/// Sets ids of pair of a case and switches
CONFIG_EXPORT void setConcealment(bool isConcealment);
/// Set attribute's obligatory state
CONFIG_EXPORT void setObligatory(bool isObligatory);
+ /// Set a state that the attribute is a main argument of the feature
+ CONFIG_EXPORT void setMainArgument(bool isMainArg);
};
#endif // ATTRIBUTE_MESSAGE_H
if (!anAttributeID.empty()) {
aMessage->setAttributeId(anAttributeID);
aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true));
- aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false));
+ bool isConcealment = getBooleanAttribute(theNode, ATTR_CONCEALMENT, false);
+ aMessage->setConcealment(isConcealment);
+ bool isMainArg = isConcealment && getBooleanAttribute(theNode, ATTR_MAIN_ARG, false);
+ aMessage->setMainArgument(isMainArg);
std::list<std::pair<std::string, std::string> > aCases;
xmlNodePtr aCaseNode =
const static char* ATTR_USE_RESET = "use_reset";
const static char* ATTR_GREED = "greed";
const static char* ATTR_MODIFIED_IN_EDIT = "modified_in_edit";
+const static char* ATTR_MAIN_ARG = "main_argument";
// WDG_INFO properties
const static char* INFO_WDG_TEXT = FEATURE_TEXT;
if(aMsgAttr->isConcealment()) {
validators()->registerConcealment(aMsgAttr->featureId(), aMsgAttr->attributeId());
}
+ if(aMsgAttr->isMainArgument()) {
+ validators()->registerMainArgument(aMsgAttr->featureId(), aMsgAttr->attributeId());
+ }
const std::list<std::pair<std::string, std::string> >& aCases = aMsgAttr->getCases();
if (!aCases.empty()) {
validators()->registerCase(aMsgAttr->featureId(), aMsgAttr->attributeId(), aCases);
}
return anInCase; // if no additional conditions, this attribute is the case to be validated
}
+
+void Model_ValidatorsFactory::registerMainArgument(std::string theFeature,
+ std::string theAttribute)
+{
+ std::map<std::string, std::string>::iterator aFound = myMainArgument.find(theFeature);
+ if (aFound == myMainArgument.end())
+ myMainArgument[theFeature] = theAttribute;
+}
+
+bool Model_ValidatorsFactory::isMainArgument(std::string theFeature, std::string theAttribute)
+{
+ std::map<std::string, std::string>::iterator aFound = myMainArgument.find(theFeature);
+ return aFound != myMainArgument.end() && aFound->second == theAttribute;
+}
// (switchId (ID of the attribute) and case Ids (possible values of the switch attribute))
std::map<std::string, std::map<std::string,
std::map<std::string, std::set<std::string> > > > myCases;
+ /// Stores main attribute for each feature
+ std::map<std::string, std::string> myMainArgument;
public:
/// Registers the instance of the validator by the ID
/// Returns true if the attribute must be checked (the case is selected)
virtual bool isCase(FeaturePtr theFeature, std::string theAttribute);
+ /// Register the attribute as a main argument of the feature
+ virtual void registerMainArgument(std::string theFeature, std::string theAttribute);
+
+ /// Returns true is the attribute is a main argument of the feature
+ virtual bool isMainArgument(std::string theFeature, std::string theAttribute);
+
protected:
/// Adds the defualt validators that are usefull for all features.
ListOfReferences::const_iterator aFoundRef = aReferences.end();
for (ListOfReferences::const_iterator aRefIt = aReferences.begin();
aRefIt != aReferences.end(); ++aRefIt) {
- if (aSession->validators()->isConcealed(anOwner->getKind(), aRefIt->first)) {
+ bool isConcealed = aSession->validators()->isConcealed(anOwner->getKind(), aRefIt->first);
+ bool isMainArg = isConcealed &&
+ aSession->validators()->isMainArgument(anOwner->getKind(), aRefIt->first);
+ if (isConcealed) {
// check the referred object is a Body
// (for example, ExtrusionCut has a sketch as a first attribute which is concealing)
bool isBody = aRefIt->second.size() > 1 || (aRefIt->second.size() == 1 &&
aRefIt->second.front()->groupName() == ModelAPI_ResultBody::group());
- if (isBody && (aFoundRef == aReferences.end() ||
+ if (isBody && (isMainArg || aFoundRef == aReferences.end() ||
aData->isPrecedingAttribute(aRefIt->first, aFoundRef->first)))
aFoundRef = aRefIt;
+
+ if (isMainArg)
+ break;
}
}
/// Returns true that it was registered that attribute conceals the referenced result
virtual bool isConcealed(std::string theFeature, std::string theAttribute) = 0;
+ /// Register the attribute as a main argument of the feature
+ virtual void registerMainArgument(std::string theFeature, std::string theAttribute) = 0;
+
+ /// Returns true is the attribute is a main argument of the feature
+ virtual bool isMainArgument(std::string theFeature, std::string theAttribute) = 0;
+
/// Register the case-attribute: this attribute is checked only if its case is selected
virtual void registerCase(std::string theFeature, std::string theAttribute,
const std::list<std::pair<std::string, std::string> >& theCases) = 0;