//=================================================================================================
bool BuildPlugin_ValidatorBaseForBuild::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
// Get base objects list.
if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
- std::string aMsg = "Error: BuildPlugin_ValidatorBaseForBuild does not support attribute type '%1'\nOnly '%2' is supported.";
+ std::string aMsg = "Error: BuildPlugin_ValidatorBaseForBuild does "
+ "not support attribute type '%1'\nOnly '%2' is supported.";
Events_InfoMessage("BuildPlugin_Validators", aMsg).
arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();
return false;
}
// Check that it is shape on sketch.
- ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+ ResultConstructionPtr aConstruction =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
if(aConstruction.get()) {
if(aConstruction->isInfinite()) {
theError = "Inifinte objects not acceptable.";
return false;
}
- std::shared_ptr<GeomAPI_PlanarEdges> anEdges = std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aContextShape);
+ std::shared_ptr<GeomAPI_PlanarEdges> anEdges =
+ std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aContextShape);
if(anEdges.get()) {
if(aShape->isEqual(aContextShape)) {
// It is whole sketch.
//=================================================================================================
bool BuildPlugin_ValidatorBaseForWire::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
// Get attribute.
if(theArguments.size() != 1) {
- std::string aMsg = "Error: BuildPlugin_ValidatorBaseForWire should be used only with 1 parameter (ID of base objects list).";
+ std::string aMsg = "Error: BuildPlugin_ValidatorBaseForWire should be used only "
+ "with 1 parameter (ID of base objects list).";
Events_InfoMessage("BuildPlugin_Validators", aMsg).send();
return false;
}
AttributeSelectionListPtr aSelectionList = theFeature->selectionList(theArguments.front());
if(!aSelectionList.get()) {
- theError = "Empty attribute \"" + theArguments.front() + "\".";
+ theError = "Empty attribute \"%1\".";
+ theError.arg(theArguments.front());
return false;
}
AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
GeomShapePtr aShape = aSelection->value();
if(!aShape.get()) {
- aShape = aSelection->context()->shape();
+ if (aSelection->context().get())
+ aShape = aSelection->context()->shape();
}
- aListOfShapes.push_back(aShape);
+ if (aShape.get())
+ aListOfShapes.push_back(aShape);
}
// Create wire.
}
//=================================================================================================
-bool BuildPlugin_ValidatorBaseForWire::isNotObligatory(std::string theFeature, std::string theAttribute)
+bool BuildPlugin_ValidatorBaseForWire::isNotObligatory(std::string theFeature,
+ std::string theAttribute)
{
return false;
}
//=================================================================================================
bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
// Get attribute.
if(theArguments.size() != 1) {
}
AttributeSelectionListPtr aSelectionList = theFeature->selectionList(theArguments.front());
if(!aSelectionList.get()) {
- theError = "Empty attribute \"" + theArguments.front() + "\".";
+ theError = "Empty attribute \"%1\".";
+ theError.arg(theArguments.front());
return false;
}
}
}
+ if(anEdges.empty()) {
+ theError = "Objects not selected.";
+ return false;
+ }
+
// Check that edges does not have intersections.
if(anEdges.size() > 1) {
GeomAlgoAPI_PaveFiller aPaveFiller(anEdges, false);
GeomShapePtr aSectedEdges = aPaveFiller.shape();
int anEdgesNum = 0;
- for(GeomAPI_ShapeExplorer anExp(aSectedEdges, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
+ for(GeomAPI_ShapeExplorer
+ anExp(aSectedEdges, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
anEdgesNum++;
}
if(anEdgesNum != anEdges.size()) {
// Check that they are planar.
std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_ShapeTools::findPlane(anEdges);
if(!aPln.get()) {
- theError = "Selected objects are not planar.";
+ theError = "Selected object(s) should belong to only one plane.";
return false;
}
// Check that selected objects have closed contours.
ListOfShape aFaces;
- GeomAlgoAPI_SketchBuilder::createFaces(aPln->location(), aPln->xDirection(), aPln->direction(), anEdges, aFaces);
+ GeomAlgoAPI_SketchBuilder::createFaces(aPln->location(), aPln->xDirection(),
+ aPln->direction(), anEdges, aFaces);
if(aFaces.empty()) {
- theError = "Selected objects does not have closed contours.";
+ theError = "Selected objects do not generate closed contour.";
return false;
}
}
//=================================================================================================
-bool BuildPlugin_ValidatorBaseForFace::isNotObligatory(std::string theFeature, std::string theAttribute)
+bool BuildPlugin_ValidatorBaseForFace::isNotObligatory(std::string theFeature,
+ std::string theAttribute)
{
return false;
}
//=================================================================================================
bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
if(theArguments.size() != 1) {
std::string aMsg = "Error: BuildPlugin_ValidatorSubShapesSelection should be used only with "
// Get base objects list.
if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
- std::string aMsg = "Error: BuildPlugin_ValidatorSubShapesSelection does not support attribute type \""
+ std::string aMsg =
+ "Error: BuildPlugin_ValidatorSubShapesSelection does not support attribute type \""
"%1\"\n Only \"%2\" supported.";
Events_InfoMessage("BuildPlugin_Validators", aMsg).
arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();