From: azv Date: Mon, 13 Oct 2014 06:44:57 +0000 (+0400) Subject: New constraint "Rigid" was added X-Git-Tag: V_0.5~101 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bc46759639a0f56128a9ebbdaa586eda46c00fd4;p=modules%2Fshaper.git New constraint "Rigid" was added --- diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index 2be41c483..8f4a6930a 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -63,7 +64,8 @@ bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId) || theId == SketchPlugin_ConstraintRadius::ID() || theId == SketchPlugin_ConstraintParallel::ID() || theId == SketchPlugin_ConstraintPerpendicular::ID() - || theId == SketchPlugin_ConstraintCoincidence::ID(); + || theId == SketchPlugin_ConstraintCoincidence::ID() + || theId == SketchPlugin_ConstraintRigid::ID(); } bool PartSet_OperationFeatureCreate::canBeCommitted() const diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index a52a43453..ea47cde21 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -341,5 +342,6 @@ bool PartSet_Tools::isConstraintFeature(const std::string& theKind) { return theKind == SketchPlugin_ConstraintDistance::ID() || theKind == SketchPlugin_ConstraintLength::ID() - || theKind == SketchPlugin_ConstraintRadius::ID(); + || theKind == SketchPlugin_ConstraintRadius::ID() + || theKind == SketchPlugin_ConstraintRigid::ID(); } diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index d9b7328c2..4d4097d12 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -18,6 +18,7 @@ SET(PROJECT_HEADERS SketchPlugin_ConstraintParallel.h SketchPlugin_ConstraintPerpendicular.h SketchPlugin_ConstraintRadius.h + SketchPlugin_ConstraintRigid.h SketchPlugin_Validators.h SketchPlugin_ResultValidators.h ) @@ -37,6 +38,7 @@ SET(PROJECT_SOURCES SketchPlugin_ConstraintParallel.cpp SketchPlugin_ConstraintPerpendicular.cpp SketchPlugin_ConstraintRadius.cpp + SketchPlugin_ConstraintRigid.cpp SketchPlugin_Validators.cpp SketchPlugin_ResultValidators.cpp ) diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h index 78c580426..d14a4b6de 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h @@ -14,7 +14,7 @@ * \ingroup DataModel * \brief Feature for creation of a new constraint which defines equivalence of two points * - * These constraint has two attributes: + * This constraint has two attributes: * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() */ class SketchPlugin_ConstraintCoincidence : public SketchPlugin_ConstraintBase diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h index 69ff19762..4f4fedc62 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -22,7 +22,7 @@ class GeomDataAPI_Point2D; * \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: + * This constraint has three attributes: * SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() */ class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.h b/src/SketchPlugin/SketchPlugin_ConstraintLength.h index 456c0c27c..5f3ae9aae 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.h @@ -16,7 +16,7 @@ * \ingroup DataModel * \brief Feature for creation of a new constraint which defines a length of a line segment * - * These constraint has two attributes: + * This constraint has two attributes: * SketchPlugin_Constraint::VALUE() (length) and SketchPlugin_Constraint::ENTITY_A() (segment), * SketchPlugin_Constraint::FLYOUT_VALUE_PNT() (distance of a constraints handle) */ diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h index 053fe5f36..370ff6336 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h @@ -15,7 +15,7 @@ * \ingroup DataModel * \brief Feature for creation of a new constraint parallelism of two lines * - * These constraint has two attributes: + * This constraint has two attributes: * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() */ class SketchPlugin_ConstraintParallel : public SketchPlugin_ConstraintBase diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h index 9b304c8d4..7847bf4d6 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h @@ -15,7 +15,7 @@ * \ingroup DataModel * \brief Feature for creation of a new constraint for perpendicularity of two lines * - * These constraint has two attributes: + * This constraint has two attributes: * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() */ class SketchPlugin_ConstraintPerpendicular : public SketchPlugin_ConstraintBase diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h index eb96ef93d..96e295e1b 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h @@ -16,7 +16,7 @@ * \brief Feature for creation of a new constraint which defines * a radius of a circle or an arc of circle * - * These constraint has two attributes: + * This constraint has two attributes: * SketchPlugin_Constraint::VALUE() (radius), SketchPlugin_Constraint::ENTITY_A() (a circle) */ class SketchPlugin_ConstraintRadius : public SketchPlugin_ConstraintBase diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp new file mode 100644 index 000000000..b1cd1708b --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp @@ -0,0 +1,18 @@ +// File: SketchPlugin_ConstraintRigid.cpp +// Created: 13 Oct 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_ConstraintRigid.h" + +SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid() +{ +} + +void SketchPlugin_ConstraintRigid::initAttributes() +{ + data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type()); +} + +void SketchPlugin_ConstraintRigid::execute() +{ +} diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.h b/src/SketchPlugin/SketchPlugin_ConstraintRigid.h new file mode 100644 index 000000000..dd66a6f63 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.h @@ -0,0 +1,46 @@ +// File: SketchPlugin_ConstraintRigid.h +// Created: 13 Oct 2014 +// Author: Artem ZHIDKOV + +#ifndef SketchPlugin_ConstraintRigid_H_ +#define SketchPlugin_ConstraintRigid_H_ + +#include "SketchPlugin.h" +#include "SketchPlugin_ConstraintBase.h" +#include +#include + +/** \class SketchPlugin_ConstraintRigid + * \ingroup DataModel + * \brief Feature for creation of a new constraint which defines immovable object + * + * This constraint has one attribute: + * SketchPlugin_Constraint::ENTITY_A() (any object, i.e. point, line, circle, arc) + */ +class SketchPlugin_ConstraintRigid : public SketchPlugin_ConstraintBase +{ + public: + /// Length constraint kind + inline static const std::string& ID() + { + static const std::string MY_CONSTRAINT_RIGID_ID("SketchConstraintRigid"); + return MY_CONSTRAINT_RIGID_ID; + } + /// \brief Returns the kind of a feature + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_ConstraintRigid::ID(); + return MY_KIND; + } + + /// \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 Use plugin manager for features creation + SketchPlugin_ConstraintRigid(); +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index ba178fe65..e3a324300 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -10,6 +10,7 @@ #include "SketchPlugin_ConstraintParallel.h" #include "SketchPlugin_ConstraintPerpendicular.h" #include "SketchPlugin_ConstraintRadius.h" +#include "SketchPlugin_ConstraintRigid.h" #include "SketchPlugin_Validators.h" #include "SketchPlugin_ResultValidators.h" #include @@ -83,6 +84,8 @@ FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID) return FeaturePtr(new SketchPlugin_ConstraintPerpendicular); } else if (theFeatureID == SketchPlugin_ConstraintRadius::ID()) { return FeaturePtr(new SketchPlugin_ConstraintRadius); + } else if (theFeatureID == SketchPlugin_ConstraintRigid::ID()) { + return FeaturePtr(new SketchPlugin_ConstraintRigid); } // feature of such kind is not found return FeaturePtr(); diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index e002f0108..9bcc261fd 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -1,7 +1,7 @@ - + @@ -92,6 +92,14 @@ + + + + + + + +