From: azv Date: Fri, 23 May 2014 12:29:31 +0000 (+0400) Subject: Constraint for distance between two features is added X-Git-Tag: V_0.2~8^2^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=17173fd09790446e33485e38c3d241cd023e07de;p=modules%2Fshaper.git Constraint for distance between two features is added --- diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 60fb882c0..ee4d7da0a 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -9,6 +9,7 @@ SET(PROJECT_HEADERS SketchPlugin_Point.h SketchPlugin_Constraint.h SketchPlugin_ConstraintCoincidence.h + SketchPlugin_ConstraintDistance.h ) SET(PROJECT_SOURCES @@ -18,6 +19,7 @@ SET(PROJECT_SOURCES SketchPlugin_Line.cpp SketchPlugin_Point.cpp SketchPlugin_ConstraintCoincidence.cpp + SketchPlugin_ConstraintDistance.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h index 57e95f5ba..1c5f2adf3 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h @@ -14,7 +14,8 @@ * \ingroup DataModel * \brief Feature for creation of a new constraint which defines equivalence of two points * - * These constraint has two attributes: CONSTRAINT_ATTR_POINT_A and CONSTRAINT_ATTR_POINT_B + * These constraint has two attributes: + * CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B */ class SketchPlugin_ConstraintCoincidence: public SketchPlugin_Constraint { diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp new file mode 100644 index 000000000..57f7b627d --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -0,0 +1,31 @@ +// File: SketchPlugin_ConstraintDistance.cpp +// Created: 23 May 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_ConstraintDistance.h" + +#include +#include +#include + +SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance() +{ +} + +void SketchPlugin_ConstraintDistance::initAttributes() +{ + data()->addAttribute(CONSTRAINT_ATTR_VALUE, ModelAPI_AttributeDouble::type()); + data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type()); + data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type()); +} + +void SketchPlugin_ConstraintDistance::execute() +{ +} + +const boost::shared_ptr& SketchPlugin_ConstraintDistance::preview() +{ + /// \todo Preview for distance constraint + return getPreview(); +} + diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h new file mode 100644 index 000000000..4295e8c2d --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -0,0 +1,45 @@ +// File: SketchPlugin_ConstraintDistance.h +// Created: 23 May 2014 +// Author: Artem ZHIDKOV + +#ifndef SketchPlugin_ConstraintDistance_HeaderFile +#define SketchPlugin_ConstraintDistance_HeaderFile + +#include "SketchPlugin.h" +#include "SketchPlugin_Constraint.h" +#include + + +/** \class SketchPlugin_ConstraintDistance + * \ingroup DataModel + * \brief Feature for creation of a new constraint which defines a distance + * between a point and another feature (point, line, plane or face) + * + * These constraint has three attributes: + * CONSTRAINT_ATTR_VALUE, CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B + */ +class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint +{ +public: + /// \brief Returns the kind of a feature + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + {static std::string MY_KIND = "SketchConstraintDistance"; return MY_KIND;} + + /// \brief Returns to which group in the document must be added feature + SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() + {static std::string MY_GROUP = "Sketch"; return MY_GROUP;} + + /// \brief Creates a new part document if needed + SKETCHPLUGIN_EXPORT virtual void execute(); + + /// \brief Request for initialization of data model of the feature: adding all attributes + SKETCHPLUGIN_EXPORT virtual void initAttributes(); + + /// \brief Returns the sketch preview + SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); + + /// \brief Use plugin manager for features creation + SketchPlugin_ConstraintDistance(); +}; + +#endif diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 706d85f3b..443ad5327 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -11,6 +11,7 @@ +