shape_types="vertex">
<validator id="GeomValidators_ConstructionComposite"/>
<validator id="GeomValidators_ShapeType" parameters="vertex"/>
- <validator id="PartSet_DifferentShapes"/>
+ <validator id="GeomValidators_DifferentShapes"/>
</shape_selector>
</box>
<box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face" icon=":icons/circle.png">
GeomValidators.h
GeomValidators_BooleanArguments.h
GeomValidators_ConstructionComposite.h
+ GeomValidators_DifferentShapes.h
GeomValidators_Face.h
GeomValidators_Finite.h
GeomValidators_Positive.h
SET(PROJECT_SOURCES
GeomValidators_BooleanArguments.cpp
GeomValidators_ConstructionComposite.cpp
+ GeomValidators_DifferentShapes.cpp
GeomValidators_Face.cpp
GeomValidators_Finite.cpp
GeomValidators_Positive.cpp
const std::list<std::string>& theArguments,
std::string& theError) const
{
- bool aValid = false;
- AttributeSelectionPtr aSelectionAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
- (theAttribute);
- if (aSelectionAttr.get() == NULL) {
- theError = "Is not a selection attribute.";
+ bool aValid = true;
+ if (theAttribute->attributeType() != ModelAPI_AttributeSelection::typeId()) {
+ aValid = false;
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
return aValid;
}
+ AttributeSelectionPtr aSelectionAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+ (theAttribute);
ResultPtr aResult = aSelectionAttr->context();
- GeomShapePtr aShape = aSelectionAttr->value();
// global selection should be ignored, the filter processes only selected sub-shapes
// that means, that the shape of the context result is equal to the shape value
///*ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
- if (aResult.get() != NULL) {
+ if (!aResult.get()) {
+ aValid = false;
+ theError = "The result is empty";
+ }
+ else {
+ GeomShapePtr aShape = aSelectionAttr->value();
GeomShapePtr aShapePtr = aResult->shape();
// it is important to call isEqual of the shape of result.
// It is a GeomAPI_Vertex shape for the point. The shape of the parameter is
// GeomAPI_Shape. It is important to use the realization of the isEqual method from
// GeomAPI_Vertex class
- if (aShape.get()) {
- aValid = aShapePtr.get() != NULL && aShapePtr->isEqual(aShape);
- }
- else {
+ if (!aShape.get()) {
// an empty shape is used in attribute selection if the shape of the result is equal to
// the selected shape, so according to the upper condition, the result is true
aValid = true;
}
- }
- if (!aValid) {
- ResultConstructionPtr aConstr =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
- if (aConstr != NULL) {
- // it provides selection only on composite features, construction without composite
- // feature is not selectable
- FeaturePtr aFeature = ModelAPI_Feature::feature(aConstr);
- CompositeFeaturePtr aComposite =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
- aValid = aComposite && aComposite->numberOfSubs() > 0;
- }
else {
- // non-construction results should be accepted by this filter, e.g. body results
- aValid = true;
+ if (aShapePtr->isEqual(aShape)) {
+ aValid = true;
+ }
+ else {
+ ResultConstructionPtr aConstr =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
+ if (!aConstr.get()) {
+ // non-construction results should be accepted by this filter, e.g. body results
+ aValid = true;
+ }
+ else {
+ // it provides selection only on composite features, construction without composite
+ // feature is not selectable.
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aConstr);
+ CompositeFeaturePtr aComposite =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
+ aValid = aComposite && aComposite->numberOfSubs() > 0;
+ if (!aValid)
+ theError = "Uses composite construction feature without sub-features.";
+ }
+ }
}
}
return aValid;
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_DifferentShapes.cpp
+// Created: 2 Feb 2015
+// Author: Natalia ERMOLAEVA
+
+#include "GeomValidators_DifferentShapes.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include "ModelAPI_Object.h"
+
+bool GeomValidators_DifferentShapes::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ AttributeSelectionPtr aSelectionAttribute =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ GeomShapePtr aShape = aSelectionAttribute->value();
+ if (!aShape.get()) {
+ ResultPtr aResult = aSelectionAttribute->context();
+ if (aResult.get())
+ aShape = aResult->shape();
+ }
+
+ std::string aCurrentAttributeId = theAttribute->id();
+ // get all feature attributes
+ std::list<AttributePtr> anAttrs =
+ aFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
+ if (anAttrs.size() > 0 && aShape.get() != NULL) {
+ std::list<AttributePtr>::iterator anAttr = anAttrs.begin();
+ for(; anAttr != anAttrs.end(); anAttr++) {
+ AttributePtr anAttribute = *anAttr;
+ // take into concideration only other attributes
+ if (anAttribute.get() != NULL && anAttribute->id() != aCurrentAttributeId) {
+ aSelectionAttribute =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
+ // the shape of the attribute should be not the same
+ if (aSelectionAttribute.get() != NULL) {
+ GeomShapePtr anAttrShape = aSelectionAttribute->value();
+ if (!anAttrShape.get()) {
+ ResultPtr aResult = aSelectionAttribute->context();
+ if (aResult.get())
+ anAttrShape = aResult->shape();
+ }
+ if (aShape->isEqual(anAttrShape)) {
+ theError = "The feature uses equal shapes.";
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomValidators_DifferentShapes.h
+// Created: 2 Feb 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef GeomValidators_DifferentShapes_H
+#define GeomValidators_DifferentShapes_H
+
+#include <ModelAPI.h>
+
+#include <ModelAPI_AttributeValidator.h>
+#include <ModelAPI_Attribute.h>
+
+/**
+ * Generic validator for any attribute of a feature.
+ */
+class GeomValidators_DifferentShapes : public ModelAPI_AttributeValidator
+{
+public:
+ /// returns True if the attribute is valid. It checks whether the feature of the attribute
+ /// does not contain a selection attribute filled with the same shape
+ /// \param theAttribute an attribute to check
+ /// \param theArguments a filter parameters
+ MODELAPI_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+};
+
+#endif
const std::list<std::string>& theArguments,
std::string& theError) const
{
- bool aValid = false;
-
- GeomAbs_SurfaceType aFaceType = GeomAbs_Plane;
- if (theArguments.size() == 1) {
- std::string anArgument = theArguments.front();
- aFaceType = faceType(anArgument);
+ std::string anAttributeType = theAttribute->attributeType();
+ if (anAttributeType != ModelAPI_AttributeSelection::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ return false;
}
+ bool aValid = true;
ObjectPtr anObject = GeomValidators_Tools::getObject(theAttribute);
- if (anObject.get() != NULL) {
+ if (!anObject.get()) {
+ aValid = true; // an empty face selected is valid.
+ }
+ else {
AttributeSelectionPtr aSelectionAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
- if (aSelectionAttr.get() == NULL) {
- theError = "Is not a selection attribute.";
- return aValid;
- }
-
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
std::shared_ptr<GeomAPI_Shape> aGeomShape = aSelectionAttr->value();
if (!aGeomShape.get()) {
// if the shape is empty, apply the validator to the shape of result
// it is necessary to check whether the shape is face in order to set in selection a value
// with any type and check the type in this validator
// It is realized to select any object in OB and filter it in this validator (sketch plane)
- if (aGeomShape->isFace()) {
+ if (!aGeomShape->isFace()) {
+ aValid = false;
+ theError = "The shape is not a face.";
+ }
+ else {
std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face(aGeomShape));
- if (aGeomFace.get() != NULL) {
- switch(aFaceType) {
- case GeomAbs_Plane:
- aValid = aGeomFace->isPlanar();
- if (!aValid)
- theError = "The shape is not a plane.";
- break;
- case GeomAbs_Cylinder:
- aValid = aGeomFace->isCylindrical();
- if (!aValid)
- theError = "The shape is not a cylinder.";
- break;
- default:
- theError = "The shape is not an available face.";
- break;
+ if (!aGeomFace.get()) {
+ aValid = false;
+ theError = "The shape is not a face.";
+ }
+ else {
+ GeomAbs_SurfaceType aFaceType = GeomAbs_Plane;
+ if (theArguments.size() == 1)
+ aFaceType = faceType(theArguments.front());
+
+ switch (aFaceType) {
+ case GeomAbs_Plane: {
+ aValid = aGeomFace->isPlanar();
+ if (!aValid)
+ theError = "The shape is not a plane.";
+ }
+ break;
+ case GeomAbs_Cylinder:{
+ aValid = aGeomFace->isCylindrical();
+ if (!aValid)
+ theError = "The shape is not a cylinder.";
+ }
+ break;
+ default: {
+ aValid = false;
+ theError = "The shape is not an available face.";
+ break;
+ }
}
}
- } else
- theError = "The shape is not a face.";
+ }
}
- else
- aValid = true; // an empty face selected is valid.
return aValid;
}
ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
if (aConstruction.get() && aConstruction->isInfinite()) {
aValid = false;
+ theError = "Infinite result is selected.";
}
}
}
typedef std::map<std::string, GeomValidators_ShapeType::TypeOfShape> EdgeTypes;
+static EdgeTypes MyShapeTypes;
GeomValidators_ShapeType::TypeOfShape GeomValidators_ShapeType::shapeType(const std::string& theType)
{
- static EdgeTypes MyShapeTypes;
-
if (MyShapeTypes.size() == 0) {
MyShapeTypes["empty"] = Empty;
MyShapeTypes["vertex"] = Vertex;
return AnyShape;
}
+std::string getShapeTypeDescription(const GeomValidators_ShapeType::TypeOfShape& theType)
+{
+ std::string aValue = "";
+
+ if (MyShapeTypes.size() != 0) {
+ std::map<std::string, GeomValidators_ShapeType::TypeOfShape>::const_iterator anIt = MyShapeTypes.begin(),
+ aLast = MyShapeTypes.end();
+ for (; anIt != aLast; anIt++) {
+ if (anIt->second == theType)
+ aValue = anIt->first;
+ break;
+ }
+ }
+ return aValue;
+}
+
bool GeomValidators_ShapeType::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const
bool aValid = false;
std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
- for (; anIt != aLast && !aValid; anIt++) {
- aValid = isValidArgument(theAttribute, *anIt);
- }
-
- return aValid;
-}
-
-bool GeomValidators_ShapeType::isValidArgument(const AttributePtr& theAttribute,
- const std::string& theArgument) const
-{
- bool aValid = false;
- TypeOfShape aShapeType = shapeType(theArgument);
- if (aShapeType == AnyShape)
- return true;
-
- AttributeSelectionListPtr aListAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
- if (aListAttr.get()) {
- if(aListAttr->size() == 0 && shapeType(theArgument) == Empty) {
- return true;
+ // returns true if the attribute satisfies at least one of given arguments
+ for (; anIt != aLast; anIt++) {
+ TypeOfShape aShapeType = shapeType(*anIt);
+ // if arguments contain any shape type value, the validator returns true
+ if (aShapeType == AnyShape) {
+ aValid = true;
+ break;
}
- for (int i = 0; i < aListAttr->size(); i++) {
- aValid = isValidAttribute(aListAttr->value(i), aShapeType);
- if (!aValid) // if at least one attribute is invalid, the result is false
- break;
+ if (isValidAttribute(theAttribute, aShapeType, theError)) {
+ aValid = true;
+ break;
}
}
- else {
- aValid = isValidAttribute(theAttribute, aShapeType);
+ if (!aValid && theError.empty()) {
+ std::string aTypes;
+ std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
+ // returns true if the attribute satisfies at least one of given arguments
+ for (; anIt != aLast; anIt++) {
+ if (!aTypes.empty())
+ aTypes += ", ";
+ }
+ theError = "It does not contain element with acceptable shape type. The type should be one of the next: "
+ + aTypes;
}
+
return aValid;
}
bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute,
- const TypeOfShape theShapeType) const
+ const TypeOfShape theShapeType,
+ std::string& theError) const
{
- bool aValid = false;
+ bool aValid = true;
std::string anAttributeType = theAttribute->attributeType();
-
if (anAttributeType == ModelAPI_AttributeSelection::typeId()) {
AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
GeomShapePtr aShape = anAttr->value();
if (aShape.get())
- aValid = isValidShape(aShape, theShapeType);
+ aValid = isValidShape(aShape, theShapeType, theError);
else
- aValid = isValidObject(anAttr->context(), theShapeType);
+ aValid = isValidObject(anAttr->context(), theShapeType, theError);
}
else if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (anAttr.get() != NULL) {
- if (anAttr->isObject()) {
- aValid = isValidObject(anAttr->object(), theShapeType);
+ if (anAttr->isObject()) {
+ aValid = isValidObject(anAttr->object(), theShapeType, theError);
+ }
+ else if (theShapeType == Vertex) {
+ AttributePtr aRefAttr = anAttr->attr();
+ if (!aRefAttr.get()){
+ aValid = false;
+ theError = "It has reference to an empty attribute";
}
- else if (theShapeType == Vertex) {
- AttributePtr aRefAttr = anAttr->attr();
- aValid = aRefAttr.get() != NULL && aRefAttr->attributeType() == GeomDataAPI_Point2D::typeId();
+ else {
+ std::string anAttributeType = aRefAttr->attributeType();
+ aValid = anAttributeType == GeomDataAPI_Point2D::typeId();
+ if (!aValid)
+ theError = "Shape type is \"" + anAttributeType +
+ "\", it should be \"" + getShapeTypeDescription(theShapeType) + "\"";
}
}
}
else if (anAttributeType == ModelAPI_AttributeReference::typeId()) {
- AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
- if (anAttr.get() != NULL)
- aValid = isValidObject(anAttr->value(), theShapeType);
+ AttributeReferencePtr anAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+ aValid = isValidObject(anAttr->value(), theShapeType, theError);
+ }
+ else if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ // the Empty value means that the attribute selection list is valid if it is empty
+ if (aListAttr->size() == 0 && theShapeType == Empty) {
+ return true;
+ }
+ aValid = false; // the list should have elements if the shape type is not Empty
+ for (int i = 0; i < aListAttr->size(); i++) {
+ aValid = isValidAttribute(aListAttr->value(i), theShapeType, theError);
+ if (!aValid) // if at least one attribute is invalid, the result is false
+ break;
+ }
+ }
+ else {
+ aValid = false;
+ theError = "The attribute with the " + anAttributeType + " type is not processed";
}
return aValid;
}
bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject,
- const TypeOfShape theShapeType) const
+ const TypeOfShape theShapeType,
+ std::string& theError) const
{
- bool aValid = false;
- if (theObject.get() != NULL) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ bool aValid = true;
+ if (!theObject.get()) {
+ aValid = false;
+ theError = "The object is empty";
+ }
+ else {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if( theShapeType==Plane )
{
ResultConstructionPtr aResultConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theObject);
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
const std::string& aKind = aFeature->getKind();
return aResult.get() != NULL && aKind == "Plane";
}
-
- if (aResult.get() != NULL) {
- GeomShapePtr aShape = aResult->shape();
- aValid = isValidShape(aShape, theShapeType);
+ if (!aResult.get()) {
+ aValid = false;
+ theError = "The result is empty";
+ }
+ else {
+ aValid = isValidShape(aResult->shape(), theShapeType, theError);
}
}
return aValid;
}
bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape,
- const TypeOfShape theShapeType) const
+ const TypeOfShape theShapeType,
+ std::string& theError) const
{
- bool aValid = false;
+ bool aValid = true;
- if (theShape.get() != NULL) {
+ if (!theShape.get()) {
+ aValid = false;
+ theError = "The shape is empty";
+ }
+ else {
switch (theShapeType) {
- case Edge:
- aValid = theShape->isEdge();
+ case Edge:
+ aValid = theShape->isEdge();
break;
case Line:
aValid = theShape->isEdge() && !GeomAPI_Curve(theShape).isCircle();
case Compound:
aValid = theShape->isCompound();
break;
- default: break;
+ default:
+ aValid = false;
+ break;
}
}
return aValid;
public:
GEOMVALIDATORS_EXPORT GeomValidators_ShapeType() {}
- //! returns true if attribute is valid
+ //! Returns true if attribute has shape type listed in the parameter arguments
//! \param theAttribute the checked attribute
//! \param theArguments arguments of the attribute
GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
/// \param theType a string value
static TypeOfShape shapeType(const std::string& theType);
- bool isValidArgument(const AttributePtr& theAttribute,
- const std::string& theArgument) const;
-
/// Returns true if the attibute's object type satisfies the argument value
/// \param theAttribute a checked attribute
/// \param theArgument a parameter
bool isValidAttribute(const AttributePtr& theAttribute,
- const TypeOfShape theShapeType) const;
+ const TypeOfShape theShapeType,
+ std::string& theError) const;
/// Returns true if the attibute's object type satisfies the argument value
/// \param theAttribute a checked object
/// \param theShapeType a shape type
bool isValidObject(const ObjectPtr& theObject,
- const TypeOfShape theShapeType) const;
+ const TypeOfShape theShapeType,
+ std::string& theError) const;
/// Returns true if the attibute's object type satisfies the argument value
/// \param theShape a checked shape
/// \param theShapeType a shape type
bool isValidShape(const GeomShapePtr theShape,
- const TypeOfShape theShapeType) const;
+ const TypeOfShape theShapeType,
+ std::string& theError) const;
};
ModelAPI_ResultPart.h
ModelAPI_Session.h
ModelAPI_Tools.h
- ModelAPI_ShapeValidator.h
ModelAPI_Validator.h
ModelAPI_Entity.h
)
ModelAPI_ResultPart.cpp
ModelAPI_ResultParameter.cpp
ModelAPI_Session.cpp
- ModelAPI_ShapeValidator.cpp
ModelAPI_Tools.cpp
ModelAPI_AttributeValidator.cpp
)
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: ModelAPI_ShapeValidator.cpp
-// Created: 2 Feb 2015
-// Author: Natalia ERMOLAEVA
-
-#include "ModelAPI_ShapeValidator.h"
-
-#include <ModelAPI_AttributeSelection.h>
-#include "ModelAPI_Object.h"
-
-bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute,
- const std::list<std::string>& theArguments,
- std::string& theError) const
-{
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
- AttributeSelectionPtr aSelectionAttribute =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
- GeomShapePtr aShape = aSelectionAttribute->value();
- if (!aShape.get()) {
- ResultPtr aResult = aSelectionAttribute->context();
- if (aResult.get())
- aShape = aResult->shape();
- }
-
- std::string aCurrentAttributeId = theAttribute->id();
- // get all feature attributes
- std::list<AttributePtr> anAttrs =
- aFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
- if (anAttrs.size() > 0 && aShape.get() != NULL) {
- std::list<AttributePtr>::iterator anAttr = anAttrs.begin();
- for(; anAttr != anAttrs.end(); anAttr++) {
- AttributePtr anAttribute = *anAttr;
- // take into concideration only other attributes
- if (anAttribute.get() != NULL && anAttribute->id() != aCurrentAttributeId) {
- aSelectionAttribute =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
- // the shape of the attribute should be not the same
- if (aSelectionAttribute.get() != NULL) {
- GeomShapePtr anAttrShape = aSelectionAttribute->value();
- if (!anAttrShape.get()) {
- ResultPtr aResult = aSelectionAttribute->context();
- if (aResult.get())
- anAttrShape = aResult->shape();
- }
- if (aShape->isEqual(anAttrShape)) {
- return false;
- }
- }
- }
- }
- }
- return true;
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: ModelAPI_ShapeValidator.h
-// Created: 2 Feb 2015
-// Author: Natalia ERMOLAEVA
-
-#ifndef ModelAPI_ShapeValidator_H
-#define ModelAPI_ShapeValidator_H
-
-#include <ModelAPI.h>
-
-#include <ModelAPI_AttributeValidator.h>
-#include <ModelAPI_Attribute.h>
-
-/**
- * Generic validator for any attribute of a feature.
- */
-class ModelAPI_ShapeValidator : public ModelAPI_AttributeValidator
-{
-public:
- /// returns True if the attribute is valid. It checks whether the feature of the attribute
- /// does not contain a selection attribute filled with the same shape
- /// \param theAttribute an attribute to check
- /// \param theArguments a filter parameters
- MODELAPI_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
- const std::list<std::string>& theArguments,
- std::string& theError) const;
-};
-
-#endif
#include <GeomDataAPI_Point2D.h>
#include <Events_Error.h>
+#include <Config_PropManager.h>
+
#include <QWidget>
#include <QLayout>
#include <QPainter>
theDrawer->SetDeviationCoefficient(1.e-4);
}
+Quantity_Color color(const std::string& theSection,
+ const std::string& theName,
+ const std::string& theDefault)
+{
+ std::vector<int> aColor = Config_PropManager::color(theSection, theName, theDefault);
+ return Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB);
+}
+
}
#include <TopoDS_Shape.hxx>
#include <Prs3d_Drawer.hxx>
+#include <Quantity_Color.hxx>
+
#include <QPixmap>
class QWidget;
*/
MODULEBASE_EXPORT void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer);
+
+/*! Obtains the color from the property manager and converts it to the OCCT color
+\param theSection a property section
+\param theName a property item name
+\param theDefault a default color value
+\return quantity color
+*/
+MODULEBASE_EXPORT Quantity_Color color(const std::string& theSection,
+ const std::string& theName,
+ const std::string& theDefault);
}
#endif
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_AttributeValidator.h>
-#include <ModelAPI_ShapeValidator.h>
#include <Config_WidgetAPI.h>
#include <Events_Error.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Session.h>
-#include <ModelAPI_ShapeValidator.h>
+#include <GeomValidators_DifferentShapes.h>
#include <ModelAPI_ResultBody.h>
#include <GeomDataAPI_Point2D.h>
aFactory->registerValidator("PartSet_TangentSelection", new PartSet_TangentSelection);
aFactory->registerValidator("PartSet_FilletSelection", new PartSet_FilletSelection);
aFactory->registerValidator("PartSet_AngleSelection", new PartSet_AngleSelection);
-
aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
- aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
-
aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr);
+ aFactory->registerValidator("GeomValidators_DifferentShapes", new GeomValidators_DifferentShapes);
aFactory->registerValidator("GeomValidators_ShapeType", new GeomValidators_ShapeType);
aFactory->registerValidator("GeomValidators_Face", new GeomValidators_Face);
-
aFactory->registerValidator("GeomValidators_Finite", new GeomValidators_Finite);
aFactory->registerValidator("GeomValidators_ConstructionComposite",
aFactory->registerValidator("PartSet_SketchEntityValidator",
new PartSet_SketchEntityValidator);
- aFactory->registerValidator("PartSet_SameTypeAttr",
- new PartSet_SameTypeAttrValidator);
-
aFactory->registerValidator("GeomValidators_Different",
new GeomValidators_Different);
}
PartSet_OperationPrs::PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop)
: ViewerData_AISShape(TopoDS_Shape()), myFeature(FeaturePtr()), myWorkshop(theWorkshop)
{
+ myShapeColor = ModuleBase_Tools::color("Visualization", "construction_plane_color", "1,1,0");
+ myResultColor = ModuleBase_Tools::color("Visualization", "construction_plane_color", "0,1,0");
}
bool PartSet_OperationPrs::canActivate(const FeaturePtr& theFeature)
#include <ViewerData_AISShape.hxx>
#include <Standard_DefineHandle.hxx>
+#include <Quantity_Color.hxx>
+
#include <QMap>
#include <QList>
FeaturePtr myFeature; /// Reference to a feature object
QMap<ObjectPtr, QList<GeomShapePtr> > myFeatureShapes; /// visualized shapes
std::list<ResultPtr> myFeatureResults; /// visualized feature results
+
+ Quantity_Color myShapeColor; /// color of feature depended shapes
+ Quantity_Color myResultColor; /// color of feature result
};
return (aCount > 0) && (aCount < 3);
}
+std::string PartSet_DifferentObjectsValidator::errorMessage(
+ const PartSet_DifferentObjectsValidator::ErrorType& theType,
+ const std::string& thEqualObject, const std::string& theFirstAttribute,
+ const std::string& theSecondAttribute) const
+{
+ std::string anError;
+ switch (theType) {
+ case EqualObjects:
+ anError = "The feature uses one " + thEqualObject + " object in " +
+ theFirstAttribute + " and " + theSecondAttribute + " attributes.";
+ break;
+ case EqualAttributes:
+ anError = "The feature uses reference to one " + thEqualObject + " attribute in " +
+ theFirstAttribute + " and " + theSecondAttribute + " attributes.";
+ break;
+ case EqualShapes:
+ anError = "The feature uses one shape in " +
+ theFirstAttribute + " and " + theSecondAttribute + " attributes.";
+ break;
+ case EmptyShapes:
+ anError = "The feature uses empty shapes in " +
+ theFirstAttribute + " and " + theSecondAttribute + " attributes.";
+ break;
+ break;
+ default:
+ break;
+ }
+ return anError;
+}
bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
if (aRef->isObject() != isObject)
continue;
if (isObject) {
- if (aRef->object() == anObject)
+ if (aRef->object() == anObject) {
+ theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "",
+ theAttribute->id(), aRef->id());
return false;
+ }
}
else { // the attribute reference
- if (aRef->attr() == anAttributeAttr)
+ if (aRef->attr() == anAttributeAttr) {
+ theError = errorMessage(EqualAttributes,
+ anAttributeAttr.get() ? anAttributeAttr->id() : "",
+ theAttribute->id(), aRef->id());
return false;
+ }
}
}
}
// check the object is already presented
if (aRef->context() == aContext) {
bool aHasShape = aShape.get() != NULL;
- if (!aHasShape || aRef->value()->isEqual(aShape))
+ if (!aHasShape || aRef->value()->isEqual(aShape)) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(), aRef->id());
return false;
+ }
}
}
}
std::shared_ptr<ModelAPI_AttributeReference> aRef =
std::dynamic_pointer_cast<ModelAPI_AttributeReference>(*anAttr);
// check the object is already presented
- if (aRef->value() == anObject)
+ if (aRef->value() == anObject) {
+ theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "",
+ theAttribute->id(), aRef->id());
return false;
+ }
}
return true;
}
if(aRefSelCompSolidPtr.get()) {
aRefSelCompSolid = aRefSelCompSolidPtr->shape();
}
- if((aCurSelCompSolid.get() && aCurSelCompSolid->isEqual(aRefSel->value()))
+ if ((aCurSelCompSolid.get() && aCurSelCompSolid->isEqual(aRefSel->value()))
|| (aRefSelCompSolid.get() && aRefSelCompSolid->isEqual(aCurSel->value()))) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(),
+ aRefSel->id());
return false;
}
if(aCurSelContext == aRefSelContext) {
- if(aCurSel->value().get() == NULL || aRefSel->value().get() == NULL
- || aCurSel->value()->isEqual(aRefSel->value())) {
- return false;
+ if (aCurSel->value().get() == NULL || aRefSel->value().get() == NULL) {
+ theError = errorMessage(EmptyShapes, "", theAttribute->id(),
+ aRefSel->id());
+ return false;
+ }
+ if (aCurSel->value()->isEqual(aRefSel->value())) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(),
+ aRefSel->id());
+ return false;
}
}
}
ObjectPtr aCurSelObject = aCurSelList->object(i);
for (int j = 0; j < aRefSelList->size(); j++) {
if (aCurSelObject == aRefSelList->object(j)) {
+ theError = errorMessage(EqualObjects,
+ aCurSelObject.get() ? aCurSelObject->data()->name() : "",
+ theAttribute->id(), aCurSelList->id());
return false;
}
}
{
bool isSketchEntities = true;
std::set<std::string> anEntityKinds;
+ std::string anEntityKindsStr;
std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
for (; anIt != aLast; anIt++) {
anEntityKinds.insert(*anIt);
+ if (!anEntityKindsStr.empty())
+ anEntityKindsStr += ", ";
+ anEntityKindsStr += *anIt;
}
std::string anAttributeType = theAttribute->attributeType();
}
}
}
+ if (!isSketchEntities) {
+ theError = "It refers to feature, which kind is not in the list: " + anEntityKindsStr;
+ }
return isSketchEntities;
}
-
-
-bool PartSet_SameTypeAttrValidator::isValid(const AttributePtr& theAttribute,
- const std::list<std::string>& theArguments,
- std::string& theError ) const
-{
- // there is a check whether the feature contains a point and a linear edge or two point values
- std::string aParamA = theArguments.front();
- SessionPtr aMgr = ModelAPI_Session::get();
- ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
- AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (!aRefAttr)
- return false;
-
- bool isObject = aRefAttr->isObject();
- ObjectPtr anObject = aRefAttr->object();
- if (isObject && anObject) {
- FeaturePtr aRefFea = ModelAPI_Feature::feature(anObject);
-
- AttributeRefAttrPtr aOtherAttr = aFeature->data()->refattr(aParamA);
- ObjectPtr aOtherObject = aOtherAttr->object();
- FeaturePtr aOtherFea = ModelAPI_Feature::feature(aOtherObject);
- return aRefFea->getKind() == aOtherFea->getKind();
- }
- return false;
-}
-
bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const
{
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ return false;
+ }
+
// there is a check whether the feature contains a point and a linear edge or two point values
std::string aParamA = theArguments.front();
SessionPtr aMgr = ModelAPI_Session::get();
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (!aRefAttr)
- return false;
-
QList<FeaturePtr> aCoinsideLines;
bool isObject = aRefAttr->isObject();
}
}
// if there is no coincidence then it is not valid
- if (aCoinList.size() == 0)
- return false;
-
- QList<FeaturePtr>::const_iterator anIt = aCoinsideLines.begin(), aLast = aCoinsideLines.end();
- bool aValid = false;
- for (; anIt != aLast && !aValid; anIt++) {
- aValid = *anIt == aOtherFea;
+ if (aCoinList.size() > 0) {
+ QList<FeaturePtr>::const_iterator anIt = aCoinsideLines.begin(), aLast = aCoinsideLines.end();
+ bool aValid = false;
+ for (; anIt != aLast && !aValid; anIt++) {
+ aValid = *anIt == aOtherFea;
+ }
+ if (aValid)
+ return true;
}
- if (aValid)
- return true;
}
+ theError = "There is no a common coincident point.";
return false;
}
*/
class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
{
+ //! Validator possible error types
+ enum ErrorType {
+ EqualObjects,
+ EqualAttributes,
+ EqualShapes,
+ EmptyShapes
+ };
public:
//! Returns true if the attribute is good for the feature attribute
//! \param theAttribute an attribute
virtual bool isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const;
+private:
+ //! Returns error message for the error type
+ //! \param theType a type of error
+ //! \param thEqualObjectInfo an
+ std::string errorMessage(const PartSet_DifferentObjectsValidator::ErrorType& theType,
+ const std::string& thEqualObject, const std::string& theFirstAttribute,
+ const std::string& theSecondAttribute) const;
+
};
/**
std::string& theError) const;
};
-/**\class PartSet_SameTypeAttrValidator
- * \ingroup Validators
- * \brief Validator for the tangent constraint input.
- *
- * It just checks that distance is greater than zero.
- */
-class PartSet_SameTypeAttrValidator : public ModelAPI_AttributeValidator
-{
- public:
- //! returns true if attribute is valid
- //! \param theAttribute the checked attribute
- //! \param theArguments arguments of the attribute
- virtual bool isValid(const AttributePtr& theAttribute,
- const std::list<std::string>& theArguments,
- std::string& theError) const;
-};
-
/**\class PartSet_CoincidentAttr
* \ingroup Validators
* \brief Validator to check whether there is a coincident constraint between
const std::list<std::string>& theArguments,
std::string& theError) const
{
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ return false;
+ }
+
// there is a check whether the feature contains a point and a linear edge or two point values
std::string aParamA = theArguments.front();
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (!aRefAttr)
- return false;
-
bool isObject = aRefAttr->isObject();
if (!isObject) {
// an attribute is a point. A point value is valid always for the distance
std::string aCircleError;
bool aShapeValid = aShapeValidator->isValid(aRefAttr, anArguments, aCircleError);
// the circle line is not a valid case
- if (aShapeValid)
+ if (aShapeValid) {
+ theError = "Circle can not be used in distance constraint";
return false;
+ }
anArguments.clear();
anArguments.push_back("line");
std::string aLineError;
aShapeValid = aShapeValidator->isValid(aRefAttr, anArguments, aLineError);
// if the attribute value is not a line, that means it is a vertex. A vertex is always valid
- if (!aShapeValid)
- return true;
-
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
- // If it is a line then we have to check that first attribute id not a line
- std::shared_ptr<SketchPlugin_Feature> aSFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
- SketchPlugin_Sketch* aSketch = aSFeature->sketch();
- std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(aSketch);
- std::shared_ptr<GeomDataAPI_Point2D> aPoint = SketcherPrs_Tools::getFeaturePoint(
- aFeature->data(), aParamA, aPlane);
- if (aPoint)
- return true;
+ if (aShapeValid) {
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ // If it is a line then we have to check that first attribute id not a line
+ std::shared_ptr<SketchPlugin_Feature> aSFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
+ SketchPlugin_Sketch* aSketch = aSFeature->sketch();
+ std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(aSketch);
+ std::shared_ptr<GeomDataAPI_Point2D> aPoint = SketcherPrs_Tools::getFeaturePoint(
+ aFeature->data(), aParamA, aPlane);
+ if (!aPoint.get()) {
+ theError = "One of parameters of distance constraint should be a point";
+ return false;
+ }
+ }
}
- return false;
+ return true;
}
bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const
{
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ return false;
+ }
+
// there is a check whether the feature contains a point and a linear edge or two point values
std::string aParamA = theArguments.front();
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ FeaturePtr anAttributeFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (!aRefAttr)
- return false;
bool isObject = aRefAttr->isObject();
ObjectPtr anObject = aRefAttr->object();
- if (isObject && anObject) {
+ if (isObject && anObject.get()) {
FeaturePtr aRefFea = ModelAPI_Feature::feature(anObject);
- AttributeRefAttrPtr aOtherAttr = aFeature->data()->refattr(aParamA);
+ AttributeRefAttrPtr aOtherAttr = anAttributeFeature->data()->refattr(aParamA);
ObjectPtr aOtherObject = aOtherAttr->object();
FeaturePtr aOtherFea = ModelAPI_Feature::feature(aOtherObject);
if (aRefFea->getKind() == SketchPlugin_Line::ID()) {
- if (aOtherFea->getKind() != SketchPlugin_Arc::ID())
+ if (aOtherFea->getKind() != SketchPlugin_Arc::ID()) {
+ theError = "It refers to a " + SketchPlugin_Line::ID() + ", but " + aParamA + " is not an "
+ + SketchPlugin_Arc::ID();
return false;
- } else if (aRefFea->getKind() == SketchPlugin_Arc::ID()) {
+ }
+ }
+ else if (aRefFea->getKind() == SketchPlugin_Arc::ID()) {
if (aOtherFea->getKind() != SketchPlugin_Line::ID() &&
- aOtherFea->getKind() != SketchPlugin_Arc::ID())
+ aOtherFea->getKind() != SketchPlugin_Arc::ID()) {
+ theError = "It refers to an " + SketchPlugin_Arc::ID() + ", but " + aParamA + " is not a "
+ + SketchPlugin_Line::ID() + " or an " + SketchPlugin_Arc::ID();
return false;
- } else
+ }
+ }
+ else {
+ theError = "It refers to " + aRefFea->getKind() + "but should refer to " + SketchPlugin_Line::ID()
+ + " or " + SketchPlugin_Arc::ID();
return false;
-
+ }
return true;
}
- return false;
+ else {
+ theError = "It uses an empty object";
+ return false;
+ }
+
+ return true;
}
bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string& theError) const
{
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ return false;
+ }
+
std::shared_ptr<SketchPlugin_Feature> aFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(theAttribute->owner());
if (!aFeature)
return true;
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (!aRefAttr)
- return false;
SketchPlugin_Sketch* aSketch = aFeature->sketch();
int aNbFeatures = aSketch->numberOfSubs();
AttributeRefAttrPtr aRAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
aSubFeature->attribute(SketchPlugin_ConstraintRigid::ENTITY_A()));
if (aRefAttr->isObject()) {
- if (aRefAttr->object() == aRAttr->object())
+ if (aRefAttr->object() == aRAttr->object()) {
+ ObjectPtr anObject = aRefAttr->object();
+ std::string aName = anObject.get() ? anObject->data()->name() : "";
+ theError = "The object " + aName + " has been already fixed.";
return false;
- } else if (aRefAttr->attr() == aRAttr->attr())
+ }
+ }
+ else if (aRefAttr->attr() == aRAttr->attr()) {
+ AttributePtr anAttribute = aRefAttr->attr();
+ std::string aName = anAttribute.get() ? anAttribute->id() : "";
+ theError = "The attribute " + aName + " has been already fixed.";
return false;
+ }
}
return true;
}
const std::list<std::string>& theArguments,
std::string& theError) const
{
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ return false;
+ }
+
std::string aParamA = theArguments.front();
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
AttributeRefAttrPtr aRefAttr[2];
aRefAttr[0] = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (!aRefAttr)
- return false;
aRefAttr[1] = aFeature->data()->refattr(aParamA);
- if (!aRefAttr[0]->isObject() || !aRefAttr[1]->isObject())
+ if (!aRefAttr[0]->isObject() || !aRefAttr[1]->isObject()) {
+ theError = "Attributes can not be used in equal constraint";
return false;
+ }
int aType[2] = {0, 0}; // types of attributes: 0 - incorrect, 1 - line, 2 - circle, 3 - arc
std::list<std::string> anArguments;
for (int i = 0; i < 2; i++) {
ObjectPtr anObject = aRefAttr[i]->object();
+ if (!anObject.get()) {
+ theError = "An empty object is used.";
+ return false;
+ }
+
aFeature = ModelAPI_Feature::feature(anObject);
- if (!aFeature)
+ if (!aFeature.get()) {
+ theError = "An empty feature is used.";
return false;
+ }
if (aFeature->getKind() == SketchPlugin_Line::ID()) {
aType[i] = 1;
aType[i] = 3;
continue;
}
+ theError = "The " + aFeature->getKind() + " feature kind of attribute is wrong. It should be " +
+ SketchPlugin_Line::ID() + " or " + SketchPlugin_Circle::ID() + " or " +
+ SketchPlugin_Arc::ID();
// wrong type of attribute
return false;
}
if ((aType[0] == 1 && aType[1] == 2) ||
- (aType[0] == 2 && aType[1] == 1))
+ (aType[0] == 2 && aType[1] == 1)) {
+ theError = "Feature with kinds " + SketchPlugin_Line::ID() + " and " +
+ SketchPlugin_Circle::ID() + "can not be equal.";
return false;
+ }
return true;
}
const std::list<std::string>& theArguments,
std::string& theError) const
{
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
- AttributeRefListPtr aSelAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
- if (!aSelAttr)
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefList::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
return false;
+ }
+
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ AttributeRefListPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
AttributeRefListPtr aRefListOfMirrored = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
aFeature->attribute(SketchPlugin_Constraint::ENTITY_C()));
for(int anInd = 0; anInd < aSelAttr->size(); anInd++) {
ObjectPtr aSelObject = aSelAttr->object(anInd);
+ std::string aName = aSelObject.get() ? aSelObject->data()->name() : "";
std::list<ObjectPtr>::iterator aMirIter = aMirroredObjects.begin();
for (; aMirIter != aMirroredObjects.end(); aMirIter++)
- if (aSelObject == *aMirIter)
+ if (aSelObject == *aMirIter) {
+ theError = "The object " + aName + " is a result of mirror";
return false;
+ }
}
return true;
}
const std::list<std::string>& theArguments,
std::string& theError) const
{
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ return false;
+ }
+
// there is a check whether the feature contains a point and a linear edge or two point values
std::string aParamA = theArguments.front();
SessionPtr aMgr = ModelAPI_Session::get();
FeaturePtr aConstraint = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
AttributeRefAttrPtr aRefAttrA = aConstraint->data()->refattr(aParamA);
- if (!aRefAttrA)
+ if (!aRefAttrA) {
+ theError = "The " + aParamA + " attribute " + " should be " + ModelAPI_AttributeRefAttr::typeId();
return false;
+ }
AttributeRefAttrPtr aRefAttrB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (!aRefAttrB)
- return false;
// first attribute is a point, it may coincide with any object
if (!aRefAttrA->isObject())
return true;
else {
+ ObjectPtr anObject = aRefAttrA->object();
+ if (!anObject.get()) {
+ theError = aParamA + " attribute has an empty object";
+ return false;
+ }
FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttrA->object());
- if (!aFeature)
+ if (!aFeature.get()) {
+ theError = aParamA + " attribute has an empty feature";
return false;
+ }
+
if (aFeature->getKind() == SketchPlugin_Point::ID())
return true;
}
return true;
else {
FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttrB->object());
- if (!aFeature)
+ if (!aFeature) {
+ theError = theAttribute->id() + " attribute has an empty object";
return false;
+ }
if (aFeature->getKind() == SketchPlugin_Point::ID())
return true;
}
-
+ theError = "There is no an attribute filled by a point";
return false;
}
const std::list<std::string>& theArguments,
std::string& theError) const
{
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefList::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ return false;
+ }
+
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
AttributeRefListPtr aSelAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
- if (!aSelAttr)
- return false;
AttributeRefListPtr aRefListOfInitial = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
aFeature->attribute(SketchPlugin_Constraint::ENTITY_A()));
continue;
anObjIter = aCopiedObjects.begin();
for (; anObjIter != aCopiedObjects.end(); anObjIter++)
- if (aSelObject == *anObjIter)
+ if (aSelObject == *anObjIter) {
+ std::string aName = aSelObject.get() ? aSelObject->data()->name() : "";
+ theError = "The object " + aName + " is a result of copy";
return false;
+ }
}
return true;
}