<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
<source>
- <multi_selector id="group_list"
- tooltip="Select a set of objects"
- type_choice="Vertices Edges Faces Solids" />
+ <multi_selector id="group_list"
+ tooltip="Select a set of objects"
+ type_choice="Vertices Edges Faces Solids">
+ <validator id="GeomValidators_BodyShapes" parameters="Sketch"/>
+ </multi_selector>
</source>
\ No newline at end of file
SET(PROJECT_HEADERS
GeomValidators.h
+ GeomValidators_BodyShapes.h
GeomValidators_BooleanArguments.h
GeomValidators_ConstructionComposite.h
GeomValidators_DifferentShapes.h
)
SET(PROJECT_SOURCES
+ GeomValidators_BodyShapes.cpp
GeomValidators_BooleanArguments.cpp
GeomValidators_ConstructionComposite.cpp
GeomValidators_DifferentShapes.cpp
)
SET(PROJECT_LIBRARIES
- ModelAPI
+ ModelAPI
Events
GeomAPI
)
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_BodyShapes.cpp
+// Created: 21 December 2015
+// Author: Dmitry Bobylev
+
+#include "GeomValidators_BodyShapes.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Object.h>
+
+bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ std::string anAttributeType = theAttribute->attributeType();
+ if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ // all context objects should not be sketch entities
+ for(int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) {
+ AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
+ ObjectPtr anObject = aSelectAttr->context();
+ if (!anObject.get())
+ return false;
+ else {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ std::string aFeatureKind = aFeature->getKind();
+ if(aFeatureKind == "Sketch") {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_BodyShapes.h
+// Created: 21 December 2015
+// Author: Dmitry Bobylev
+
+#ifndef GeomValidators_BodyShapes_H
+#define GeomValidators_BodyShapes_H
+
+#include <ModelAPI.h>
+
+#include <ModelAPI_AttributeValidator.h>
+#include <ModelAPI_Attribute.h>
+
+/**
+ * Generic validator for any attribute of a feature.
+ */
+class GeomValidators_BodyShapes : public ModelAPI_AttributeValidator
+{
+public:
+ /// \return True if the attribute is valid. It checks whether the shape is a
+ /// body subshape. Does not allow select construction shapes.
+ /// \param[in] theAttribute an attribute to check
+ /// \param[in] theArguments a filter parameters
+ /// \param[out] theError error message.
+ MODELAPI_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+};
+
+#endif
#include <GeomValidators_Plugin.h>
+#include <GeomValidators_BodyShapes.h>
#include <GeomValidators_BooleanArguments.h>
#include <GeomValidators_ConstructionComposite.h>
#include <GeomValidators_Different.h>
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+ aFactory->registerValidator("GeomValidators_BodyShapes", new GeomValidators_BodyShapes);
aFactory->registerValidator("GeomValidators_BooleanArguments", new GeomValidators_BooleanArguments);
aFactory->registerValidator("GeomValidators_ConstructionComposite", new GeomValidators_ConstructionComposite);
aFactory->registerValidator("GeomValidators_Different", new GeomValidators_Different);