* Returns True if the property succesfully registered
*/
CONFIG_EXPORT static bool registerProp(const std::string& theSection, const std::string& theName,
- const std::string& theTitle, Config_Prop::PropType theType,
- const std::string& theValue);
+ const std::string& theTitle, Config_Prop::PropType theType, const std::string& theValue);
- CONFIG_EXPORT static Config_Prop* findProp(const std::string& theSection, const std::string& theName);
+ CONFIG_EXPORT static Config_Prop* findProp(
+ const std::string& theSection, const std::string& theName);
CONFIG_EXPORT static Config_Properties getProperties();
CONFIG_EXPORT static Config_Properties getProperties(const std::string& theSection);
//! Returns value of the property by its owner, section, and name
- CONFIG_EXPORT static std::string string(const std::string& theSection, const std::string& theName,
- const std::string& theDefault);
- CONFIG_EXPORT static std::vector<int> color(const std::string& theSection, const std::string& theName,
- const std::string& theDefault);
- CONFIG_EXPORT static int integer(const std::string& theSection, const std::string& theName,
- const std::string& theDefault);
- CONFIG_EXPORT static double real(const std::string& theSection, const std::string& theName,
- const std::string& theDefault);
+ CONFIG_EXPORT static std::string string(
+ const std::string& theSection, const std::string& theName, const std::string& theDefault);
+
+ CONFIG_EXPORT static std::vector<int> color(
+ const std::string& theSection, const std::string& theName, const std::string& theDefault);
+
+ CONFIG_EXPORT static int integer(
+ const std::string& theSection, const std::string& theName, const std::string& theDefault);
+
+ CONFIG_EXPORT static double real(
+ const std::string& theSection, const std::string& theName, const std::string& theDefault);
private:
CONFIG_EXPORT static Config_Properties myProps;
GeomAPI_Edge.h
GeomAPI_AISObject.h
GeomAPI_IPresentable.h
+ GeomAPI_Curve.h
)
SET(PROJECT_SOURCES
GeomAPI_Shape.cpp
GeomAPI_Edge.cpp
GeomAPI_AISObject.cpp
+ GeomAPI_Curve.cpp
)
ADD_DEFINITIONS(-DGEOMAPI_EXPORTS ${CAS_DEFINITIONS})
--- /dev/null
+// File: GeomAPI_Curve.cpp
+// Created: 04 Sep 2014
+// Author: Mikhail PONIKAROV
+
+#include<GeomAPI_Curve.h>
+
+#include <TopoDS_Shape.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Circle.hxx>
+#include <BRep_Tool.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+
+#define MY_CURVE (*(static_cast<Handle_Geom_Curve*>(myImpl)))
+
+GeomAPI_Curve::GeomAPI_Curve()
+ : GeomAPI_Interface(new Handle_Geom_Curve())
+{
+}
+
+GeomAPI_Curve::GeomAPI_Curve(const boost::shared_ptr<GeomAPI_Shape>& theShape)
+ : GeomAPI_Interface(new Handle_Geom_Curve()) // initially it is null
+{
+ const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
+ TopoDS_Edge anEdge = TopoDS::Edge(aShape);
+ if (!anEdge.IsNull()) {
+ Standard_Real aStart, anEnd;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aStart, anEnd);
+ if (!aCurve.IsNull()) {
+ setImpl(&aCurve);
+ }
+ }
+}
+
+bool GeomAPI_Curve::isNull() const
+{
+ return MY_CURVE.IsNull() == Standard_True;
+}
+
+bool GeomAPI_Curve::isLine() const
+{
+ return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Line);
+}
+
+bool GeomAPI_Curve::isCircle() const
+{
+ return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Circle);
+}
--- /dev/null
+// File: GeomAPI_Curve.hxx
+// Created: 04 Sep 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomAPI_Curve_H_
+#define GeomAPI_Curve_H_
+
+#include <GeomAPI_Shape.h>
+#include <boost/shared_ptr.hpp>
+
+/**\class GeomAPI_Curve
+ * \ingroup DataModel
+ * \brief Interface to the generic curve object
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Curve : public GeomAPI_Interface
+{
+ public:
+ /// Creation of empty (null) shape
+ GeomAPI_Curve();
+
+ /// Creates a curve from the shape (edge)
+ GeomAPI_Curve(const boost::shared_ptr<GeomAPI_Shape>& theShape);
+
+ /// Returns true if curve is not initialized
+ bool isNull() const;
+
+ /// Returns whether the curve is linear
+ virtual bool isLine() const;
+
+ /// Returns whether the curve is circular
+ virtual bool isCircle() const;
+
+};
+
+#endif
#include <TopoDS_Shape.hxx>
-#define MY_PNT static_cast<gp_Pnt*>(myImpl)
+#define MY_SHAPE static_cast<TopoDS_Shape*>(myImpl)
GeomAPI_Shape::GeomAPI_Shape()
: GeomAPI_Interface(new TopoDS_Shape())
bool GeomAPI_Shape::isNull()
{
- return MY_SHAPE->IsNull();
+ return MY_SHAPE->IsNull() == Standard_True;
}
bool GeomAPI_Shape::isVertex() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
- return aShape.TShape()->ShapeType() == TopAbs_VERTEX;
+ return !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX;
}
bool GeomAPI_Shape::isEdge() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
- return aShape.TShape()->ShapeType() == TopAbs_EDGE;
+ return aShape.ShapeType() == TopAbs_EDGE;
}
* \ingroup DataModel
* \brief Interface to the topological shape object
*/
-class TopoDS_Shape;
-
-#define MY_SHAPE static_cast<TopoDS_Shape*>(myImpl)
-
class GEOMAPI_EXPORT GeomAPI_Shape : public GeomAPI_Interface
{
public:
Model_ResultBody.h
Model_ResultConstruction.h
Model_ResultPart.h
- Model_ResultValidators.h
- Model_FeatureValidator.h
+ Model_FeatureValidator.h
)
SET(PROJECT_SOURCES
Model_ResultBody.cpp
Model_ResultConstruction.cpp
Model_ResultPart.cpp
- Model_ResultValidators.cpp
- Model_FeatureValidator.cpp
+ Model_FeatureValidator.cpp
)
SET(PROJECT_LIBRARIES
const Config_ValidatorMessage* aMsg = dynamic_cast<const Config_ValidatorMessage*>(theMessage);
if (aMsg) {
if (aMsg->attributeId().empty()) { // feature validator
- validators()->assignValidator(aMsg->validatorId(), aMsg->featureId());
+ validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), aMsg->parameters());
} else { // attribute validator
validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), aMsg->attributeId(),
aMsg->parameters());
+++ /dev/null
-// File: Model_ResultValidators.cpp
-// Created: 23 July 2014
-// Author: Vitaly SMETANNIKOV
-
-#include "Model_ResultValidators.h"
-
-#include <ModelAPI_Result.h>
-#include <ModelAPI_Tools.h>
-#include <GeomAPI_Shape.h>
-
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS.hxx>
-#include <BRep_Tool.hxx>
-#include <GeomAdaptor_Curve.hxx>
-
-ResultPtr result(const ObjectPtr theObject)
-{
- return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-}
-
-TopoDS_Shape shape(ResultPtr theResult)
-{
- boost::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(theResult);
- if (aShape)
- return aShape->impl<TopoDS_Shape>();
- return TopoDS_Shape();
-}
-
-bool Model_ResultPointValidator::isValid(const ObjectPtr theObject) const
-{
- ResultPtr aResult = result(theObject);
- if (!aResult)
- return false;
- TopoDS_Shape aShape = shape(aResult);
- if (aShape.IsNull())
- return false;
-
- return aShape.ShapeType() == TopAbs_VERTEX;
-}
-
-bool Model_ResultLineValidator::isValid(const ObjectPtr theObject) const
-{
- ResultPtr aResult = result(theObject);
- if (!aResult)
- return false;
- TopoDS_Shape aShape = shape(aResult);
- if (aShape.IsNull())
- return false;
-
- if (aShape.ShapeType() == TopAbs_EDGE) {
- TopoDS_Edge aEdge = TopoDS::Edge(aShape);
- Standard_Real aStart, aEnd;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
- GeomAdaptor_Curve aAdaptor(aCurve);
- return aAdaptor.GetType() == GeomAbs_Line;
- }
- return false;
-}
-
-bool Model_ResultArcValidator::isValid(const ObjectPtr theObject) const
-{
- ResultPtr aResult = result(theObject);
- if (!aResult)
- return false;
- TopoDS_Shape aShape = shape(aResult);
- if (aShape.IsNull())
- return false;
-
- TopAbs_ShapeEnum aa = aShape.ShapeType();
- if (aShape.ShapeType() == TopAbs_EDGE) {
- TopoDS_Edge aEdge = TopoDS::Edge(aShape);
- Standard_Real aStart, aEnd;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
- GeomAdaptor_Curve aAdaptor(aCurve);
- return aAdaptor.GetType() == GeomAbs_Circle;
- }
- return false;
-}
-
+++ /dev/null
-// File: Model_ResultValidators.h
-// Created: 23 July 2014
-// Author: Vitaly SMETANNIKOV
-
-#ifndef Model_ResultValidators_H
-#define Model_ResultValidators_H
-
-#include "Model.h"
-#include <ModelAPI_ResultValidator.h>
-#include <ModelAPI_Object.h>
-
-class Model_ResultPointValidator : public ModelAPI_ResultValidator
-{
- public:
- MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
-};
-
-class Model_ResultLineValidator : public ModelAPI_ResultValidator
-{
- public:
- MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
-};
-
-class Model_ResultArcValidator : public ModelAPI_ResultValidator
-{
- public:
- MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
-};
-
-#endif
// Author: Mikhail PONIKAROV
#include <Model_Validator.h>
-#include <Model_ResultValidators.h>
#include <Model_FeatureValidator.h>
#include <ModelAPI_Feature.h>
#include <Events_Error.h>
const std::string& theFeatureID)
{
if (myFeatures.find(theFeatureID) == myFeatures.end()) {
- myFeatures[theFeatureID] = std::set<std::string>();
+ myFeatures[theFeatureID] = AttrValidators();
+ }
+ if (myFeatures[theFeatureID].find(theID) != myFeatures[theFeatureID].end()) {
+ //Events_Error::send(std::string("Validator ") + theID +
+ // " for feature " + theFeatureID + "is already registered");
+ } else {
+ myFeatures[theFeatureID][theID] = std::list<std::string>();
+ }
+}
+
+void Model_ValidatorsFactory::assignValidator(const std::string& theID,
+ const std::string& theFeatureID,
+ const std::list<std::string>& theArguments)
+{
+ if (myFeatures.find(theFeatureID) == myFeatures.end()) {
+ myFeatures[theFeatureID] = AttrValidators();
+ }
+
+ if (myFeatures[theFeatureID].find(theID) != myFeatures[theFeatureID].end()) {
+ //Events_Error::send(std::string("Validator ") + theID +
+ // " for feature " + theFeatureID + "is already registered");
+ } else {
+ myFeatures[theFeatureID][theID] = theArguments;
}
- myFeatures[theFeatureID].insert(theID);
}
void Model_ValidatorsFactory::assignValidator(const std::string& theID,
if (anAttr == aFeature->second.end()) {
aFeature->second[theAttrID] = AttrValidators();
}
- aFeature->second[theAttrID].insert(
- std::pair<std::string, std::list<std::string> >(theID, theArguments));
+ aFeature->second[theAttrID][theID] = theArguments;
}
void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
- std::list<ModelAPI_Validator*>& theResult) const
+ std::list<ModelAPI_Validator*>& theResult,
+ std::list<std::list<std::string> >& theArguments) const
{
- std::map<std::string, std::set<std::string> >::const_iterator aFeature = myFeatures.find(
- theFeatureID);
+ std::map<std::string, AttrValidators>::const_iterator aFeature = myFeatures.find(theFeatureID);
if (aFeature != myFeatures.cend()) {
- std::set<std::string>::const_iterator aValIter = aFeature->second.cbegin();
+ AttrValidators::const_iterator aValIter = aFeature->second.cbegin();
for (; aValIter != aFeature->second.cend(); aValIter++) {
- std::map<std::string, ModelAPI_Validator*>::const_iterator aFound = myIDs.find(*aValIter);
+ std::map<std::string, ModelAPI_Validator*>::const_iterator aFound =
+ myIDs.find(aValIter->first);
if (aFound == myIDs.end()) {
- Events_Error::send(std::string("Validator ") + *aValIter + " was not registered");
+ Events_Error::send(std::string("Validator ") + aValIter->first + " was not registered");
} else {
theResult.push_back(aFound->second);
+ theArguments.push_back(aValIter->second);
}
}
}
Model_ValidatorsFactory::Model_ValidatorsFactory()
: ModelAPI_ValidatorsFactory()
{
- registerValidator("Model_ResultPointValidator", new Model_ResultPointValidator);
- registerValidator("Model_ResultLineValidator", new Model_ResultLineValidator);
- registerValidator("Model_ResultArcValidator", new Model_ResultArcValidator);
registerValidator("Model_FeatureValidator", new Model_FeatureValidator);
}
{
private:
std::map<std::string, ModelAPI_Validator*> myIDs; ///< map from ID to registered validator
+ /// validators IDs to list of arguments
+ typedef std::map<std::string, std::list<std::string> > AttrValidators;
/// validators IDs by feature ID
- std::map<std::string, std::set<std::string> > myFeatures;
- /// set of pairs: validators IDs, list of arguments
- typedef std::set<std::pair<std::string, std::list<std::string> > > AttrValidators;
+ std::map<std::string, AttrValidators> myFeatures;
/// validators IDs and arguments by feature and attribute IDs
std::map<std::string, std::map<std::string, AttrValidators> > myAttrs;
public:
MODEL_EXPORT virtual void assignValidator(const std::string& theID,
const std::string& theFeatureID);
+ /// Assigns validator to the feature with arguments of the validator
+ MODEL_EXPORT virtual void assignValidator(const std::string& theID,
+ const std::string& theFeatureID,
+ const std::list<std::string>& theArguments);
+
/// Assigns validator to the attribute of the feature
MODEL_EXPORT virtual void assignValidator(const std::string& theID,
const std::string& theFeatureID,
/// Provides a validator for the feature, returns NULL if no validator
MODEL_EXPORT virtual void validators(const std::string& theFeatureID,
- std::list<ModelAPI_Validator*>& theResult) const;
+ std::list<ModelAPI_Validator*>& theResult,
+ std::list<std::list<std::string> >& theArguments) const;
/// Provides a validator for the attribute, returns NULL if no validator
MODEL_EXPORT virtual void validators(const std::string& theFeatureID,
const std::string& theAttrID,
/// Assigns validator to the feature
virtual void assignValidator(const std::string& theID, const std::string& theFeatureID) = 0;
+ /// Assigns validator to the feature with arguments of the validator
+ virtual void assignValidator(const std::string& theID,
+ const std::string& theFeatureID,
+ const std::list<std::string>& theArguments) = 0;
+
/// Assigns validator to the attribute of the feature
virtual void assignValidator(const std::string& theID, const std::string& theFeatureID,
const std::string& theAttrID,
/// Provides a validator for the feature, returns NULL if no validator
virtual void validators(const std::string& theFeatureID,
- std::list<ModelAPI_Validator*>& theResult) const = 0;
+ std::list<ModelAPI_Validator*>& theResult,
+ std::list<std::list<std::string> >& theArguments) const = 0;
/// Provides a validator for the attribute, returns NULL if no validator
virtual void validators(const std::string& theFeatureID, const std::string& theAttrID,
std::list<ModelAPI_Validator*>& theValidators,
+++ /dev/null
-// File: ModuleBase_ResultValidators.cpp
-// Created: 23 July 2014
-// Author: Vitaly SMETANNIKOV
-
-#include "ModuleBase_ResultValidators.h"
-#include "ModuleBase_Tools.h"
-
-#include <ModelAPI_Result.h>
-#include <GeomAPI_Shape.h>
-
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS.hxx>
-#include <BRep_Tool.hxx>
-#include <GeomAdaptor_Curve.hxx>
-
-ResultPtr result(const ObjectPtr theObject)
-{
- return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-}
-
-TopoDS_Shape shape(ResultPtr theResult)
-{
- boost::shared_ptr<GeomAPI_Shape> aShape = ModuleBase_Tools::shape(theResult);
- if (aShape)
- return aShape->impl<TopoDS_Shape>();
- return TopoDS_Shape();
-}
-
-bool ModuleBase_ResultPointValidator::isValid(const ObjectPtr theObject) const
-{
- ResultPtr aResult = result(theObject);
- if (!aResult)
- return false;
- TopoDS_Shape aShape = shape(aResult);
- if (aShape.IsNull())
- return false;
-
- return aShape.ShapeType() == TopAbs_VERTEX;
-}
-
-bool ModuleBase_ResultLineValidator::isValid(const ObjectPtr theObject) const
-{
- ResultPtr aResult = result(theObject);
- if (!aResult)
- return false;
- TopoDS_Shape aShape = shape(aResult);
- if (aShape.IsNull())
- return false;
-
- if (aShape.ShapeType() == TopAbs_EDGE) {
- TopoDS_Edge aEdge = TopoDS::Edge(aShape);
- Standard_Real aStart, aEnd;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
- GeomAdaptor_Curve aAdaptor(aCurve);
- return aAdaptor.GetType() == GeomAbs_Line;
- }
- return false;
-}
-
-bool ModuleBase_ResultArcValidator::isValid(const ObjectPtr theObject) const
-{
- ResultPtr aResult = result(theObject);
- if (!aResult)
- return false;
- TopoDS_Shape aShape = shape(aResult);
- if (aShape.IsNull())
- return false;
-
- TopAbs_ShapeEnum aa = aShape.ShapeType();
- if (aShape.ShapeType() == TopAbs_EDGE) {
- TopoDS_Edge aEdge = TopoDS::Edge(aShape);
- Standard_Real aStart, aEnd;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
- GeomAdaptor_Curve aAdaptor(aCurve);
- return aAdaptor.GetType() == GeomAbs_Circle;
- }
- return false;
-}
-
+++ /dev/null
-// File: ModuleBase_ResultValidators.h
-// Created: 23 July 2014
-// Author: Vitaly SMETANNIKOV
-
-#ifndef ModuleBase_ResultValidators_H
-#define ModuleBase_ResultValidators_H
-
-#include "ModuleBase.h"
-#include <ModelAPI_Validator.h>
-#include <ModelAPI_Object.h>
-
-class ModuleBase_ResultValidator : public ModelAPI_Validator
-{
- public:
- virtual bool isValid(const ObjectPtr theObject) const = 0;
-};
-
-class ModuleBase_ResultPointValidator : public ModuleBase_ResultValidator
-{
- public:
- MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
-};
-
-class ModuleBase_ResultLineValidator : public ModuleBase_ResultValidator
-{
- public:
- MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
-};
-
-class ModuleBase_ResultArcValidator : public ModuleBase_ResultValidator
-{
- public:
- MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
-};
-
-#endif
SketchPlugin_ConstraintParallel.h
SketchPlugin_ConstraintPerpendicular.h
SketchPlugin_ConstraintRadius.h
- SketchPlugin_Validators.h
+ SketchPlugin_Validators.h
+ SketchPlugin_ResultValidators.h
)
SET(PROJECT_SOURCES
SketchPlugin_ConstraintParallel.cpp
SketchPlugin_ConstraintPerpendicular.cpp
SketchPlugin_ConstraintRadius.cpp
- SketchPlugin_Validators.cpp
+ SketchPlugin_Validators.cpp
+ SketchPlugin_ResultValidators.cpp
)
SET(PROJECT_LIBRARIES
#include "SketchPlugin_ConstraintPerpendicular.h"
#include "SketchPlugin_ConstraintRadius.h"
#include "SketchPlugin_Validators.h"
+#include "SketchPlugin_ResultValidators.h"
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Validator.h>
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
aFactory->registerValidator("SketchPlugin_DistanceAttrValidator",
new SketchPlugin_DistanceAttrValidator);
+ aFactory->registerValidator("Sketch_ResultPointValidator", new SketchPlugin_ResultPointValidator);
+ aFactory->registerValidator("Sketch_ResultLineValidator", new SketchPlugin_ResultLineValidator);
+ aFactory->registerValidator("Sketch_ResultArcValidator", new SketchPlugin_ResultArcValidator);
// register this plugin
ModelAPI_PluginManager::get()->registerPlugin(this);
--- /dev/null
+// File: Model_ResultValidators.cpp
+// Created: 23 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#include "SketchPlugin_ResultValidators.h"
+
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Tools.h>
+#include <GeomAPI_Curve.h>
+
+ResultPtr result(const ObjectPtr theObject)
+{
+ return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+}
+
+bool SketchPlugin_ResultPointValidator::isValid(const ObjectPtr theObject) const
+{
+ ResultPtr aResult = result(theObject);
+ if (!aResult)
+ return false;
+ boost::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
+ return aShape && aShape->isVertex();
+}
+
+bool SketchPlugin_ResultLineValidator::isValid(const ObjectPtr theObject) const
+{
+ ResultPtr aResult = result(theObject);
+ if (!aResult)
+ return false;
+ boost::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
+ return aShape && aShape->isEdge() && GeomAPI_Curve(aShape).isLine();
+
+ /*
+ if (aShape.ShapeType() == TopAbs_EDGE) {
+ TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+ Standard_Real aStart, aEnd;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
+ GeomAdaptor_Curve aAdaptor(aCurve);
+ return aAdaptor.GetType() == GeomAbs_Line;
+ }
+ return false;
+ */
+}
+
+bool SketchPlugin_ResultArcValidator::isValid(const ObjectPtr theObject) const
+{
+ ResultPtr aResult = result(theObject);
+ if (!aResult)
+ return false;
+ boost::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
+ return aShape && aShape->isEdge() && GeomAPI_Curve(aShape).isCircle();
+}
+
--- /dev/null
+// File: Model_ResultValidators.h
+// Created: 23 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef Model_ResultValidators_H
+#define Model_ResultValidators_H
+
+#include <SketchPlugin.h>
+#include <ModelAPI_ResultValidator.h>
+#include <ModelAPI_Object.h>
+
+class SketchPlugin_ResultPointValidator : public ModelAPI_ResultValidator
+{
+ public:
+ SKETCHPLUGIN_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class SketchPlugin_ResultLineValidator : public ModelAPI_ResultValidator
+{
+ public:
+ SKETCHPLUGIN_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class SketchPlugin_ResultArcValidator : public ModelAPI_ResultValidator
+{
+ public:
+ SKETCHPLUGIN_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+#endif
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
std::list<ModelAPI_Validator*> aValidators;
- aFactory->validators(anOperationId.toStdString(), aValidators);
+ std::list<std::list<std::string> > anArguments;
+ aFactory->validators(anOperationId.toStdString(), aValidators, anArguments);
//
std::list<ModelAPI_Validator*>::iterator it = aValidators.begin();
bool isValid = true;
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_SelectionValidator.h>
-#include <ModuleBase_ResultValidators.h>
#include "ModuleBase_WidgetFactory.h"
#include <Config_Common.h>
{
QString aId = aAction->data().toString();
std::list<ModelAPI_Validator*> aValidators;
- aFactory->validators(aId.toStdString(), aValidators);
+ std::list<std::list<std::string> > anArguments;
+ aFactory->validators(aId.toStdString(), aValidators, anArguments);
std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
for (; aValidator != aValidators.end(); aValidator++) {
if (*aValidator) {