From: azv Date: Mon, 26 May 2014 07:01:01 +0000 (+0400) Subject: Sketch's arcs and circles were added. Constraints for parallel/perpendicular lines... X-Git-Tag: V_0.2~8^2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=78be47ffdc50846de6c88b94fb8c933c7c21b5a1;p=modules%2Fshaper.git Sketch's arcs and circles were added. Constraints for parallel/perpendicular lines and for diameter of a circle were implemented --- diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index ee4d7da0a..a1ee7a362 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -7,9 +7,14 @@ SET(PROJECT_HEADERS SketchPlugin_Sketch.h SketchPlugin_Line.h SketchPlugin_Point.h + SketchPlugin_Circle.h + SketchPlugin_Arc.h SketchPlugin_Constraint.h SketchPlugin_ConstraintCoincidence.h SketchPlugin_ConstraintDistance.h + SketchPlugin_ConstraintDiameter.h + SketchPlugin_ConstraintParallel.h + SketchPlugin_ConstraintPerpendicular.h ) SET(PROJECT_SOURCES @@ -18,8 +23,13 @@ SET(PROJECT_SOURCES SketchPlugin_Sketch.cpp SketchPlugin_Line.cpp SketchPlugin_Point.cpp + SketchPlugin_Circle.cpp + SketchPlugin_Arc.cpp SketchPlugin_ConstraintCoincidence.cpp SketchPlugin_ConstraintDistance.cpp + SketchPlugin_ConstraintDiameter.cpp + SketchPlugin_ConstraintParallel.cpp + SketchPlugin_ConstraintPerpendicular.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp new file mode 100644 index 000000000..ed5275b00 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -0,0 +1,30 @@ +// File: SketchPlugin_Arc.cpp +// Created: 26 Apr 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_Arc.h" +#include "SketchPlugin_Sketch.h" +#include +#include + +SketchPlugin_Arc::SketchPlugin_Arc() + : SketchPlugin_Feature() +{ +} + +void SketchPlugin_Arc::initAttributes() +{ + data()->addAttribute(ARC_ATTR_CENTER, GeomDataAPI_Point2D::type()); + data()->addAttribute(ARC_ATTR_START, GeomDataAPI_Point2D::type()); + data()->addAttribute(ARC_ATTR_END, GeomDataAPI_Point2D::type()); +} + +void SketchPlugin_Arc::execute() +{ +} + +const boost::shared_ptr& SketchPlugin_Arc::preview() +{ + /// \todo Implement preview for arc of circle + return getPreview(); +} diff --git a/src/SketchPlugin/SketchPlugin_Arc.h b/src/SketchPlugin/SketchPlugin_Arc.h new file mode 100644 index 000000000..f22e92b4c --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_Arc.h @@ -0,0 +1,51 @@ +// File: SketchPlugin_Arc.h +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#ifndef SketchPlugin_Arc_HeaderFile +#define SketchPlugin_Arc_HeaderFile + +#include "SketchPlugin.h" +#include + +/// Central 2D point of the circle which contains the arc +const std::string ARC_ATTR_CENTER("ArcCenter"); +/// Start 2D point of the arc +const std::string ARC_ATTR_START("ArcStartPoint"); +/// End 2D point of the arc +const std::string ARC_ATTR_END("ArcEndPoint"); + +/**\class SketchPlugin_Arc + * \ingroup DataModel + * \brief Feature for creation of the new arc of circle in PartSet. + */ +class SketchPlugin_Arc: public SketchPlugin_Feature +{ +public: + /// Returns the kind of a feature + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + {static std::string MY_KIND = "SketchArc"; return MY_KIND;} + + /// 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;} + + /// Creates a new part document if needed + SKETCHPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + SKETCHPLUGIN_EXPORT virtual void initAttributes(); + + /// Returns the sketch preview + SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); + + /// Adds sub-feature of the higher level feature (sub-element of the sketch) + /// \param theFeature sub-feature + SKETCHPLUGIN_EXPORT virtual const void addSub( + const boost::shared_ptr& theFeature) {}; + + /// Use plugin manager for features creation + SketchPlugin_Arc(); +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp new file mode 100644 index 000000000..a083b1845 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -0,0 +1,30 @@ +// File: SketchPlugin_Circle.cpp +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_Circle.h" +#include "SketchPlugin_Sketch.h" +#include +#include +#include + +SketchPlugin_Circle::SketchPlugin_Circle() + : SketchPlugin_Feature() +{ +} + +void SketchPlugin_Circle::initAttributes() +{ + data()->addAttribute(CIRCLE_ATTR_CENTER, GeomDataAPI_Point2D::type()); + data()->addAttribute(CIRCLE_ATTR_RADIUS, ModelAPI_AttributeDouble::type()); +} + +void SketchPlugin_Circle::execute() +{ +} + +const boost::shared_ptr& SketchPlugin_Circle::preview() +{ + /// \todo Implement preview for the circle + return getPreview(); +} diff --git a/src/SketchPlugin/SketchPlugin_Circle.h b/src/SketchPlugin/SketchPlugin_Circle.h new file mode 100644 index 000000000..18fa1e71f --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_Circle.h @@ -0,0 +1,49 @@ +// File: SketchPlugin_Circle.h +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#ifndef SketchPlugin_Circle_HeaderFile +#define SketchPlugin_Circle_HeaderFile + +#include "SketchPlugin.h" +#include + +/// 2D point - center of the circle +const std::string CIRCLE_ATTR_CENTER("CircleCenter"); +/// Radius of the circle +const std::string CIRCLE_ATTR_RADIUS("CircleRadius"); + +/**\class SketchPlugin_Circle + * \ingroup DataModel + * \brief Feature for creation of the new circle in PartSet. + */ +class SketchPlugin_Circle: public SketchPlugin_Feature +{ +public: + /// Returns the kind of a feature + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + {static std::string MY_KIND = "SketchCircle"; return MY_KIND;} + + /// 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;} + + /// Creates a new part document if needed + SKETCHPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + SKETCHPLUGIN_EXPORT virtual void initAttributes(); + + /// Returns the sketch preview + SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); + + /// Adds sub-feature of the higher level feature (sub-element of the sketch) + /// \param theFeature sub-feature + SKETCHPLUGIN_EXPORT virtual const void addSub( + const boost::shared_ptr& theFeature) {}; + + /// Use plugin manager for features creation + SketchPlugin_Circle(); +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDiameter.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDiameter.cpp new file mode 100644 index 000000000..179cce935 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintDiameter.cpp @@ -0,0 +1,30 @@ +// File: SketchPlugin_ConstraintDiameter.cpp +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_ConstraintDiameter.h" + +#include +#include +#include + +SketchPlugin_ConstraintDiameter::SketchPlugin_ConstraintDiameter() +{ +} + +void SketchPlugin_ConstraintDiameter::initAttributes() +{ + data()->addAttribute(CONSTRAINT_ATTR_VALUE, ModelAPI_AttributeDouble::type()); + data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type()); +} + +void SketchPlugin_ConstraintDiameter::execute() +{ +} + +const boost::shared_ptr& SketchPlugin_ConstraintDiameter::preview() +{ + /// \todo Preview for diameter constraint + return getPreview(); +} + diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDiameter.h b/src/SketchPlugin/SketchPlugin_ConstraintDiameter.h new file mode 100644 index 000000000..1ac7a324a --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintDiameter.h @@ -0,0 +1,43 @@ +// File: SketchPlugin_ConstraintDiameter.h +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#ifndef SketchPlugin_ConstraintDiameter_HeaderFile +#define SketchPlugin_ConstraintDiameter_HeaderFile + +#include "SketchPlugin.h" +#include "SketchPlugin_Constraint.h" + + +/** \class SketchPlugin_ConstraintDiameter + * \ingroup DataModel + * \brief Feature for creation of a new constraint which defines a diameter of a circle + * + * These constraint has two attributes: + * CONSTRAINT_ATTR_VALUE (diameter), CONSTRAINT_ATTR_ENTITY_A (a circle) + */ +class SketchPlugin_ConstraintDiameter: public SketchPlugin_Constraint +{ +public: + /// \brief Returns the kind of a feature + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + {static std::string MY_KIND = "SketchConstraintDiameter"; 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_ConstraintDiameter(); +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp new file mode 100644 index 000000000..91e6c4ca5 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@ -0,0 +1,30 @@ +// File: SketchPlugin_ConstraintParallel.cpp +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_ConstraintParallel.h" + +#include +#include +#include + +SketchPlugin_ConstraintParallel::SketchPlugin_ConstraintParallel() +{ +} + +void SketchPlugin_ConstraintParallel::initAttributes() +{ + data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type()); + data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type()); +} + +void SketchPlugin_ConstraintParallel::execute() +{ +} + +const boost::shared_ptr& SketchPlugin_ConstraintParallel::preview() +{ + /// \todo Preview for parallel constraint + return getPreview(); +} + diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h new file mode 100644 index 000000000..dfc894d36 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h @@ -0,0 +1,43 @@ +// File: SketchPlugin_ConstraintParallel.h +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#ifndef SketchPlugin_ConstraintParallel_HeaderFile +#define SketchPlugin_ConstraintParallel_HeaderFile + +#include "SketchPlugin.h" +#include "SketchPlugin_Constraint.h" + + +/** \class SketchPlugin_ConstraintParallel + * \ingroup DataModel + * \brief Feature for creation of a new constraint parallelism of two lines + * + * These constraint has two attributes: + * CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B + */ +class SketchPlugin_ConstraintParallel: public SketchPlugin_Constraint +{ +public: + /// \brief Returns the kind of a feature + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + {static std::string MY_KIND = "SketchConstraintParallel"; 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_ConstraintParallel(); +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp new file mode 100644 index 000000000..85c543f2b --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp @@ -0,0 +1,30 @@ +// File: SketchPlugin_ConstraintPerpendicular.cpp +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_ConstraintPerpendicular.h" + +#include +#include +#include + +SketchPlugin_ConstraintPerpendicular::SketchPlugin_ConstraintPerpendicular() +{ +} + +void SketchPlugin_ConstraintPerpendicular::initAttributes() +{ + data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type()); + data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type()); +} + +void SketchPlugin_ConstraintPerpendicular::execute() +{ +} + +const boost::shared_ptr& SketchPlugin_ConstraintPerpendicular::preview() +{ + /// \todo Preview for perpendicular constraint + return getPreview(); +} + diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h new file mode 100644 index 000000000..6c5074a90 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h @@ -0,0 +1,43 @@ +// File: SketchPlugin_ConstraintPerpendicular.h +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#ifndef SketchPlugin_ConstraintPerpendicular_HeaderFile +#define SketchPlugin_ConstraintPerpendicular_HeaderFile + +#include "SketchPlugin.h" +#include "SketchPlugin_Constraint.h" + + +/** \class SketchPlugin_ConstraintPerpendicular + * \ingroup DataModel + * \brief Feature for creation of a new constraint for perpendicularity of two lines + * + * These constraint has two attributes: + * CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B + */ +class SketchPlugin_ConstraintPerpendicular: public SketchPlugin_Constraint +{ +public: + /// \brief Returns the kind of a feature + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + {static std::string MY_KIND = "SketchConstraintPerpendicular"; 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_ConstraintPerpendicular(); +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_Line.h b/src/SketchPlugin/SketchPlugin_Line.h index 7877a7191..62dc6cfa9 100644 --- a/src/SketchPlugin/SketchPlugin_Line.h +++ b/src/SketchPlugin/SketchPlugin_Line.h @@ -22,18 +22,18 @@ class SketchPlugin_Line: public SketchPlugin_Feature { public: /// Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = "SketchLine"; return MY_KIND;} /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() + SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() {static std::string MY_GROUP = "Sketch"; return MY_GROUP;} /// Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(); /// Request for initialization of data model of the feature: adding all attributes - SKETCHPLUGIN_EXPORT virtual void initAttributes(); + SKETCHPLUGIN_EXPORT virtual void initAttributes(); /// Returns the sketch preview SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); diff --git a/src/SketchPlugin/SketchPlugin_Point.h b/src/SketchPlugin/SketchPlugin_Point.h index f4ecc4936..b18bffb08 100644 --- a/src/SketchPlugin/SketchPlugin_Point.h +++ b/src/SketchPlugin/SketchPlugin_Point.h @@ -20,18 +20,18 @@ class SketchPlugin_Point: public SketchPlugin_Feature { public: /// Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = "SketchPoint"; return MY_KIND;} /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() + SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() {static std::string MY_GROUP = "Sketch"; return MY_GROUP;} /// Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(); /// Request for initialization of data model of the feature: adding all attributes - SKETCHPLUGIN_EXPORT virtual void initAttributes(); + SKETCHPLUGIN_EXPORT virtual void initAttributes(); /// Returns the sketch preview SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 371943ec5..ecdf0ee3a 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -29,18 +29,18 @@ class SketchPlugin_Sketch: public SketchPlugin_Feature { public: /// Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() {static std::string MY_KIND = "Sketch"; return MY_KIND;} /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() + SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() {static std::string MY_GROUP = "Construction"; return MY_GROUP;} /// Creates a new part document if needed - SKETCHPLUGIN_EXPORT virtual void execute(); + SKETCHPLUGIN_EXPORT virtual void execute(); /// Request for initialization of data model of the feature: adding all attributes - SKETCHPLUGIN_EXPORT virtual void initAttributes(); + SKETCHPLUGIN_EXPORT virtual void initAttributes(); /// Returns the sketch preview SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 443ad5327..ca3ced477 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -10,8 +10,19 @@ + + + + + + + + + + +