const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
{
- AttributeSelectionPtr aPathAttrSelection =
+ AttributeSelectionPtr aPathAttrSelection =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
if(!aPathAttrSelection.get()) {
theError = "Error: This validator can only work with path selector in \"Pipe\" feature.";
return false;
}
GeomShapePtr aContextShape = aContext->shape();
- if(aPathShape.get() && aPathShape->shapeType() == GeomAPI_Shape::WIRE &&
+ if(aPathShape.get() && aPathShape->shapeType() == GeomAPI_Shape::WIRE &&
!aPathShape->isEqual(aContextShape)) {
theError = "Error: Local selection of wires not allowed.";
return false;
return false;
}
- if(aLocationsSelectionList->size() > 0 &&
+ if(aLocationsSelectionList->size() > 0 &&
aLocationsSelectionList->size() != aBaseObjectsSelectionList->size()) {
theError = "Error: Number of locations should be the same as base objects.";
return false;
}
//==================================================================================================
-bool FeaturesPlugin_ValidatorPipeLocations::isNotObligatory(std::string theFeature,
+bool FeaturesPlugin_ValidatorPipeLocations::isNotObligatory(std::string theFeature,
std::string theAttribute)
{
return false;
return false;
}
- std::set<ResultConstructionPtr> aSelectedSketches;
- std::set<ResultConstructionPtr> aSelectedSketchesFromObjects;
GeomAPI_DataMapOfShapeShape aSelectedWiresFromObjects;
std::string anAttributeType = theAttribute->attributeType();
if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
return false;
}
- ResultConstructionPtr aResultConstruction =
+ ResultConstructionPtr aResultConstruction =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
if(!aResultConstruction.get()) {
- // It is not a result construction.
+ // It is not a result construction.
// If shape is compound check that it contains only faces and edges.
GeomShapePtr aShape = aSelectionAttr->value();
if(!aShape.get()) {
GeomShapePtr aContextShape = aResultConstruction->shape();
if(!aShape.get()) {
// 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) {
}
if(aSelectedWiresFromObjects.isBound(aWire)) {
- theError =
+ theError =
"Error: Objects with such wire already selected. Don't allow to select this object.";
return false;
}
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,
std::string anAttributeType = theAttribute->attributeType();
if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
- AttributeSelectionListPtr aListAttr =
+ AttributeSelectionListPtr aListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
// If at least one attribute is invalid, the result is false.
}
} else if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
// Getting context.
- AttributeSelectionPtr anAttr =
+ AttributeSelectionPtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
ResultPtr aContext = anAttr->context();
if(!aContext.get()) {
return false;
}
- ResultConstructionPtr aConstruction =
+ ResultConstructionPtr aConstruction =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
if(aConstruction.get()) {
// Construciotn selected. Check that is is not infinite.
}
} else {
// Shape on construction selected. Check that it is a face or wire.
- if(aShape->shapeType() == GeomAPI_Shape::WIRE ||
+ if(aShape->shapeType() == GeomAPI_Shape::WIRE ||
aShape->shapeType() == GeomAPI_Shape::FACE) {
return true;
}
return false;
}
- std::list<std::string>::const_iterator
+ std::list<std::string>::const_iterator
anArgsIt = theArguments.begin(), aLast = theArguments.end();
AttributePtr aCheckAttribute = theFeature->attribute(*anArgsIt);
std::shared_ptr<GeomAPI_Edge> aDirEdge(new GeomAPI_Edge(aDirShape));
// If faces selected check that direction not parallel with them.
- AttributeSelectionListPtr aListAttr =
+ AttributeSelectionListPtr aListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aCheckAttribute);
for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
AttributeSelectionPtr anAttr = aListAttr->value(anIndex);
aShapeInList = anAttr->context()->shape();
}
bool isParallel = true;
- if(aShapeInList->shapeType() == GeomAPI_Shape::FACE ||
+ if(aShapeInList->shapeType() == GeomAPI_Shape::FACE ||
aShapeInList->shapeType() == GeomAPI_Shape::SHELL) {
- for(GeomAPI_ShapeExplorer
+ for(GeomAPI_ShapeExplorer
anExp(aShapeInList, GeomAPI_Shape::FACE); anExp.more(); anExp.next()) {
std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(anExp.current()));
isParallel = GeomAlgoAPI_ShapeTools::isParallel(aDirEdge, aFace);
}
}
} else if(aShapeInList->shapeType() == GeomAPI_Shape::COMPOUND) {
- std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges =
+ std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges =
std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapeInList);
if(aPlanarEdges.get()) {
std::shared_ptr<GeomAPI_Dir> aSketchDir = aPlanarEdges->norm();
isParallel = false;
}
if(isParallel) {
- theError =
+ theError =
"Error: Direction is parallel to one of the selected face or face on selected shell.";
return false;
}
}
//==================================================================================================
-bool FeaturesPlugin_ValidatorExtrusionDir::isNotObligatory(std::string theFeature,
+bool FeaturesPlugin_ValidatorExtrusionDir::isNotObligatory(std::string theFeature,
std::string theAttribute)
{
return false;
std::string anAttributeType = theAttribute->attributeType();
if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
- AttributeSelectionListPtr aListAttr =
+ AttributeSelectionListPtr aListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
// If at least one attribute is invalid, the result is false.
}
} else if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
// Getting context.
- AttributeSelectionPtr anAttr =
+ AttributeSelectionPtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
ResultPtr aContext = anAttr->context();
if(!aContext.get()) {
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
{
- AttributeSelectionListPtr anAttrSelectionList =
+ AttributeSelectionListPtr anAttrSelectionList =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if(!anAttrSelectionList.get()) {
- theError =
+ theError =
"Error: This validator can only work with selection list attributes in \"Boolean\" feature.";
return false;
}
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
{
- AttributeSelectionListPtr anAttrSelectionList =
+ AttributeSelectionListPtr anAttrSelectionList =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if(!anAttrSelectionList.get()) {
theError = "Error: This validator can only work with selection list in \"Partition\" feature.";
}
ResultPtr aContext = aSelectAttr->context();
- ResultConstructionPtr aResultConstruction =
+ ResultConstructionPtr aResultConstruction =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
if(aResultConstruction.get()) {
theError = "Error: Only body shapes and construction planes are allowed for selection.";
return false;
}
- ResultCompSolidPtr aResultCompsolid =
+ ResultCompSolidPtr aResultCompsolid =
std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aContext);
if(aResultCompsolid.get()) {
continue;
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
{
- AttributeSelectionListPtr aSubShapesAttrList =
+ AttributeSelectionListPtr aSubShapesAttrList =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if(!aSubShapesAttrList.get()) {
- theError =
+ theError =
"Error: This validator can only work with selection list in \"Remove Sub-Shapes\" feature.";
return false;
}
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
{
- AttributeSelectionListPtr aBaseObjectsAttrList =
+ AttributeSelectionListPtr aBaseObjectsAttrList =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if(!aBaseObjectsAttrList.get()) {
theError = "Error: This validator can only work with selection list in \"%1\" feature.";
for(int anIndex = 0; anIndex < aBaseObjectsAttrList->size(); ++anIndex) {
bool isSameFound = false;
AttributeSelectionPtr anAttrSelectionInList = aBaseObjectsAttrList->value(anIndex);
- ResultCompSolidPtr aResult =
+ ResultCompSolidPtr aResult =
std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anAttrSelectionInList->context());
if(!aResult.get()) {
continue;
}
// Get base objects attribute list.
- AttributeSelectionListPtr aBaseObejctsAttrList =
+ AttributeSelectionListPtr aBaseObejctsAttrList =
theFeature->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID());
if(!aBaseObejctsAttrList.get()) {
theError = "Error: Could not get \"%1\" attribute.";