#include "SketchPlugin_ConstraintDistance.h"
#include <ModelAPI_Data.h>
#include <ModelAPI_Validator.h>
-#include <ModelAPI_ResultValidator.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_Session.h>
+
+#include <GeomValidators_Edge.h>
+
#include <GeomDataAPI_Point2D.h>
bool SketchPlugin_DistanceAttrValidator::isValid(
const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+//bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
+// const std::list<std::string>& theArguments,
+// const ObjectPtr& theObject,
+// const GeomShapePtr& theShape) const
+// ======= end of todo master
{
// there is a check whether the feature contains a point and a linear edge or two point values
std::string aParamA = theArguments.front();
} else {
// 1. check whether the references object is a linear
ObjectPtr anObject = aRefAttr->object();
- const ModelAPI_ResultValidator* anArcValidator =
- dynamic_cast<const ModelAPI_ResultValidator*>(aFactory->validator("SketchPlugin_ResultArc"));
- bool anArcValid = anArcValidator->isValid(anObject);
- if (anArcValid)
- return false;
- // If the object is not a line then it is accepted. It can be a point feature selected
- const ModelAPI_ResultValidator* aLineValidator =
- dynamic_cast<const ModelAPI_ResultValidator*>(aFactory->validator("SketchPlugin_ResultLine"));
- bool aLineValid = aLineValidator->isValid(anObject);
- if (!aLineValid)
+ const ModelAPI_AttributeValidator* anEdgeValidator =
+ dynamic_cast<const GeomValidators_Edge*>(aFactory->validator("GeomValidators_Edge"));
+ std::list<std::string> anArguments;
+ anArguments.push_back("circle");
+ bool anEdgeValid = anEdgeValidator->isValid(aRefAttr, anArguments);
+ // the circle line is not a valid case
+ if (anEdgeValid)
+ return false;
+
+ anArguments.clear();
+ anArguments.push_back("line");
+ anEdgeValid = anEdgeValidator->isValid(aRefAttr, anArguments);
+ // if the attribute value is not a line, that means it is a vertex. A vertex is always valid
+ if (!anEdgeValid)
return true;
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ 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<GeomDataAPI_Point2D> aPoint = getFeaturePoint(aFeature->data(), aParamA);
if (aPoint)
}
return false;
}
+// TODO(nds) v1.0.2, master
+// return false;
+//}
+
+//bool SketchPlugin_DistanceAttrValidator::isValid(
+// const AttributePtr& theAttribute, const std::list<std::string>& theArguments ) const
+//{
+// // any point attribute is acceptable for the distance operation
+// return true;
+//}
+//
+//bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
+// const std::list<std::string>& theArguments,
+// const AttributePtr& theAttribute) const
+//{
+// return isValid(theAttribute, theArguments);
+//}
+// commented in v1.0.2, master:
//bool SketchPlugin_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature,
// const std::list<std::string>& theArguments,
// const ObjectPtr& theObject) const
//{
// std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs =
-// theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+// theFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
// std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
// for(; anAttr != anAttrs.end(); anAttr++) {
// if (*anAttr) {
// const FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObj);
//
// std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs =
-// aFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+// aFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
// std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
// for(; anAttr != anAttrs.end(); anAttr++) {
// if (*anAttr && *anAttr != theAttribute) {
// const std::list<std::string>& theArguments, const AttributePtr& theAttribute) const
//{
// std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs =
-// theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+// theFeature->data()->attributes(ModelAPI_AttributeRefAttr::typeId());
// std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
// for(; anAttr != anAttrs.end(); anAttr++) {
// if (*anAttr) {
// }
// return true;
//}
+// =========== end of todo