#include "FeaturesPlugin_Union.h"
+#include <Events_InfoMessage.h>
+
#include <ModelAPI_Attribute.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeSelectionList.h>
//==================================================================================================
bool FeaturesPlugin_ValidatorPipePath::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
AttributeSelectionPtr aPathAttrSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
if(!aPathAttrSelection.get()) {
//==================================================================================================
bool FeaturesPlugin_ValidatorPipeLocations::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
static const std::string aCreationMethodID = "creation_method";
static const std::string aBaseObjectsID = "base_objects";
static const std::string aLocationsID = "locations_objects";
if(theFeature->getKind() != "Pipe") {
- theError = "Error: Feature \"" + theFeature->getKind() + "\" does not supported by this validator.";
+ theError = "Error: Feature \"%1\" does not supported by this validator.";
+ theError.arg(theFeature->getKind());
return false;
}
AttributeStringPtr aCreationMethodAttr = theFeature->string(aCreationMethodID);
if(!aCreationMethodAttr.get()) {
- theError = "Error: Could not get \"" + aCreationMethodID + "\" attribute.";
+ theError = "Error: Could not get \"%1\" attribute.";
+ theError.arg(aCreationMethodID);
return false;
}
AttributeSelectionListPtr aBaseObjectsSelectionList = theFeature->selectionList(aBaseObjectsID);
if(!aBaseObjectsSelectionList.get()) {
- theError = "Error: Could not get \"" + aBaseObjectsID + "\" attribute.";
+ theError = "Error: Could not get \"%1\" attribute.";
+ theError.arg(aBaseObjectsID);
return false;
}
AttributeSelectionListPtr aLocationsSelectionList = theFeature->selectionList(aLocationsID);
if(!aLocationsSelectionList.get()) {
- theError = "Error: Could not get \"" + aBaseObjectsID + "\" attribute.";
+ theError = "Error: Could not get \"%1\" attribute.";
+ theError.arg(aBaseObjectsID);
return false;
}
//==================================================================================================
bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
if(theArguments.empty()) {
theError = "Error: Validator parameters is empty.";
//==================================================================================================
bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
if(!theAttribute.get()) {
theError = "Error: Empty attribute.";
// Check that object is a shape with allowed type.
GeomValidators_ShapeType aShapeTypeValidator;
if(!aShapeTypeValidator.isValid(anAttr, theArguments, theError)) {
- theError = "Error: Selected shape has unacceptable type. Acceptable types are: faces or wires on sketch, "
- "whole sketch(if it has at least one face), and whole objects with shape types: ";
- std::list<std::string>::const_iterator anIt = theArguments.cbegin();
- theError += *anIt;
- for(++anIt; anIt != theArguments.cend(); ++anIt) {
- theError += ", " + *anIt;
+ theError = "Error: Selected shape has unacceptable type. Acceptable types are: faces or wires on sketch, whole sketch(if it has at least one face), and whole objects with shape types: %1";
+ std::string anArgumentString;
+ for(auto anIt = theArguments.cbegin(); anIt != theArguments.cend(); ++anIt) {
+ if (!anArgumentString.empty())
+ anArgumentString += ", ";
+ anArgumentString += *anIt;
}
+ theError.arg(anArgumentString);
return false;
}
} else {
- theError = "Error: Attribute \"" + anAttributeType + "\" does not supported by this validator.";
+ theError = "Error: Attribute \"%1\" does not supported by this validator.";
+ theError.arg(anAttributeType);
return false;
}
//==================================================================================================
bool FeaturesPlugin_ValidatorCompositeLauncher::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
if (theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) {
- theError = "Error: The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ theError = "Error: The attribute with the %1 type is not processed";
+ theError.arg(theAttribute->attributeType());
return false;
}
if (theArguments.size() != 2) {
- theError = "Error: Wrong parameters in XML definition for " + theAttribute->attributeType() + " type";
+ theError = "Error: Wrong parameters in XML definition for %1 type";
+ theError.arg(theAttribute->attributeType());
return false;
}
// first argument is for the base attribute, second - for skipping feature kind
FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
AttributePtr aBaseAttribute = aFeature->attribute(aBaseAttributeId);
if (!aBaseAttribute.get()) {
- theError = "Wrong parameters in XML definition for " + theAttribute->attributeType() + " type";
+ theError = "Wrong parameters in XML definition for %1 type";
+ theError.arg(theAttribute->attributeType());
return false;
}
if (aBaseAttribute->isInitialized()) // when base list of composite feature is already filled,
//==================================================================================================
bool FeaturesPlugin_ValidatorExtrusionDir::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
if(theArguments.size() != 2) {
theError = "Error: Validator should be used with 2 parameters for extrusion.";
if(!aDirShape.get()) {
// Check that dir can be empty.
if(!isShapesCanBeEmpty(aCheckAttribute, theError)) {
- theError = "Error: Base objects list contains vertex or edge, so attribute \"" + *anArgsIt
- + "\" can not be used with default value. Select direction for extrusion.";
+ theError = "Error: Base objects list contains vertex or edge, so attribute \"%1\" can not be used with default value. Select direction for extrusion.";
+ theError.arg(*anArgsIt);
return false;
} else {
return true;
//==================================================================================================
bool FeaturesPlugin_ValidatorExtrusionDir::isShapesCanBeEmpty(const AttributePtr& theAttribute,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
if(!theAttribute.get()) {
return true;
//==================================================================================================
bool FeaturesPlugin_ValidatorBooleanSelection::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
AttributeSelectionListPtr anAttrSelectionList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if(!anAttrSelectionList.get()) {
return false;
}
std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
+ GeomShapePtr aContextShape = aContext->shape();
if(!aShape.get()) {
- aShape = aContext->shape();
+ aShape = aContextShape;
}
if(!aShape.get()) {
theError = "Error: Empty shape.";
return false;
}
+ if(!aShape->isEqual(aContextShape)) {
+ theError = "Error: Local selection not allowed.";
+ return false;
+ }
+
int aShapeType = aShape->shapeType();
if(anOperationType == 1) {
// Fuse operation. Allow to select edges, faces and solids.
//==================================================================================================
bool FeaturesPlugin_ValidatorPartitionSelection::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
AttributeSelectionListPtr anAttrSelectionList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if(!anAttrSelectionList.get()) {
//==================================================================================================
bool FeaturesPlugin_ValidatorRemoveSubShapesSelection::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
AttributeSelectionListPtr aSubShapesAttrList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if(!aSubShapesAttrList.get()) {
AttributeSelectionPtr aShapeAttrSelection = aFeature->selection(aBaseShapeID);
if(!aShapeAttrSelection.get()) {
- theError = "Error: Could not get \"" + aBaseShapeID + "\" attribute.";
+ theError = "Error: Could not get \"%1\" attribute.";
+ theError.arg(aBaseShapeID);
return false;
}
//==================================================================================================
bool FeaturesPlugin_ValidatorRemoveSubShapesResult::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
static const std::string aBaseShapeID = "base_shape";
static const std::string aSubShapesID = "subshapes";
if(theFeature->getKind() != "Remove_SubShapes") {
- theError = "Error: Feature \"" + theFeature->getKind() + "\" does not supported by this validator.";
+ theError = "Error: Feature \"%1\" does not supported by this validator.";
+ theError.arg(theFeature->getKind());
return false;
}
AttributeSelectionPtr aShapeAttrSelection = theFeature->selection(aBaseShapeID);
if(!aShapeAttrSelection.get()) {
- theError = "Error: Could not get \"" + aBaseShapeID + "\" attribute.";
+ theError = "Error: Could not get \"%1\" attribute.";
+ theError.arg(aBaseShapeID);
return false;
}
AttributeSelectionListPtr aSubShapesAttrList = theFeature->selectionList(aSubShapesID);
if(!aSubShapesAttrList.get()) {
- theError = "Error: Could not get \"" + aSubShapesID + "\" attribute.";
+ theError = "Error: Could not get \"%1\" attribute.";
+ theError.arg(aSubShapesID);
return false;
}
//==================================================================================================
bool FeaturesPlugin_ValidatorUnionSelection::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
AttributeSelectionListPtr aBaseObjectsAttrList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if(!aBaseObjectsAttrList.get()) {
- theError = "Error: This validator can only work with selection list in \"" + FeaturesPlugin_Union::ID() + "\" feature.";
+ theError = "Error: This validator can only work with selection list in \"%1\" feature.";
+ theError.arg(FeaturesPlugin_Union::ID());
return false;
}
//==================================================================================================
bool FeaturesPlugin_ValidatorUnionArguments::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
- std::string& theError) const
+ Events_InfoMessage& theError) const
{
// Check feature kind.
if(theFeature->getKind() != FeaturesPlugin_Union::ID()) {
- theError = "Error: This validator supports only \"" + FeaturesPlugin_Union::ID() + "\" feature.";
+ theError = "Error: This validator supports only \"%1\" feature.";
+ theError.arg(FeaturesPlugin_Union::ID());
return false;
}
// Get base objects attribute list.
AttributeSelectionListPtr aBaseObejctsAttrList = theFeature->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID());
if(!aBaseObejctsAttrList.get()) {
- theError = "Error: Could not get \"" + FeaturesPlugin_Union::BASE_OBJECTS_ID() + "\" attribute.";
+ theError = "Error: Could not get \"%1\" attribute.";
+ theError.arg(FeaturesPlugin_Union::BASE_OBJECTS_ID());
return false;
}