return false;
}
- std::set<ResultConstructionPtr> aSelectedSketches;
- std::set<ResultConstructionPtr> aSelectedSketchesFromObjects;
GeomAPI_DataMapOfShapeShape aSelectedWiresFromObjects;
std::string anAttributeType = theAttribute->attributeType();
if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
GeomShapePtr aShape = aSelectionAttr->value();
GeomShapePtr aContextShape = aResultConstruction->shape();
if(!aShape.get()) {
- // For possibility to select whole sketch from ObjectBrowser when
- // Extrusion already has sub-element of this sketch, the next check
- // is commented
// Whole sketch selected.
- /*if(aSelectedSketchesFromObjects.find(aResultConstruction) !=
- aSelectedSketchesFromObjects.cend()) {
- theError = "Error: Object from this sketch is already selected. "
- "Sketch is not allowed for selection.";
- return false;
- }*/
-
- aSelectedSketches.insert(aResultConstruction);
+ continue;
} else {
// Object from sketch selected.
- if(aSelectedSketches.find(aResultConstruction) != aSelectedSketches.cend()) {
- theError = "Error: Whole sketch with this object is already selected. "
- "Don't allow to select this object.";
- return false;
- }
-
for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::WIRE); anExp.more(); anExp.next()) {
GeomShapePtr aWire = anExp.current();
if(aWire->orientation() != GeomAPI_Shape::FORWARD) {
}
aSelectedWiresFromObjects.bind(aWire, aWire);
- aSelectedSketchesFromObjects.insert(aResultConstruction);
}
}
}
return true;
}
+//==================================================================================================
+bool FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects::isValid(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ const std::string aBaseObjectsID = theArguments.front();
+
+ AttributeSelectionListPtr aListAttr = theFeature->selectionList(aBaseObjectsID);
+ if(!aListAttr.get()) {
+ theError = "Error: Could not get \"%1\" attribute.";
+ theError.arg(aBaseObjectsID);
+ return false;
+ }
+
+ std::set<ResultConstructionPtr> aSelectedSketches;
+ std::set<ResultConstructionPtr> aSelectedSketchesFromObjects;
+
+ for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
+ AttributeSelectionPtr aSelectionAttr = aListAttr->value(anIndex);
+ ResultPtr aContext = aSelectionAttr->context();
+ if(!aContext.get()) {
+ theError = "Error: Empty context.";
+ return false;
+ }
+
+ ResultConstructionPtr aResultConstruction =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+ if(!aResultConstruction.get()) {
+ // It is not a result construction.
+ continue;
+ }
+
+ GeomShapePtr aShape = aSelectionAttr->value();
+ GeomShapePtr aContextShape = aResultConstruction->shape();
+ if(!aShape.get()) {
+ // Whole sketch selected.
+ aSelectedSketches.insert(aResultConstruction);
+ } else {
+ // Object from sketch selected.
+ aSelectedSketchesFromObjects.insert(aResultConstruction);
+ }
+ }
+
+
+ for(std::set<ResultConstructionPtr>::const_iterator anIt = aSelectedSketches.cbegin();
+ anIt != aSelectedSketches.cend();
+ ++anIt) {
+ ResultConstructionPtr aResultConstruction = *anIt;
+ if(aSelectedSketchesFromObjects.find(aResultConstruction) !=
+ aSelectedSketchesFromObjects.cend()) {
+ theError = "Sketch and objects from it can not be selected at the same time.";
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//==================================================================================================
+bool FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects::isNotObligatory(
+ std::string theFeature,
+ std::string theAttribute)
+{
+ return false;
+}
+
//==================================================================================================
bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,