SketchPlugin_Line.h
SketchPlugin_Point.h
SketchPlugin_Constraint.h
- SketchPlugin_ConstraintPointsCoincident.h
+ SketchPlugin_ConstraintCoincidence.h
)
SET(PROJECT_SOURCES
SketchPlugin_Sketch.cpp
SketchPlugin_Line.cpp
SketchPlugin_Point.cpp
- SketchPlugin_ConstraintPointsCoincident.cpp
+ SketchPlugin_ConstraintCoincidence.cpp
)
SET(PROJECT_LIBRARIES
* The "entityA" and "entityB" represents any other object (and a point too).
* And the "valA" represents a real value.
*
- * The attributes below are named corresponding to the SolveSpace,
- * some of them may be unused. The list of used attributes is defined
- * inside the certain constraint.
+ * The attributes below are named independent of the SolveSpace.
+ * Some of them may be unused.
+ *
+ * Also the list of possible attributes is provided to simplify assignment.
*/
/// The value parameter for the constraint
-const std::string CONSTRAINT_ATTR_VALUE("ConstraintValueA");
-/// First point for the constraint
-const std::string CONSTRAINT_ATTR_POINT_A("ConstraintPointA");
-/// Second point for the constraint
-const std::string CONSTRAINT_ATTR_POINT_B("ConstraintPointB");
+const std::string CONSTRAINT_ATTR_VALUE("ConstraintValue");
/// First entity for the constraint
const std::string CONSTRAINT_ATTR_ENTITY_A("ConstraintEntityA");
/// Second entity for the constraint
const std::string CONSTRAINT_ATTR_ENTITY_B("ConstraintEntityB");
+/// Third entity for the constraint
+const std::string CONSTRAINT_ATTR_ENTITY_C("ConstraintEntityC");
+/// Fourth entity for the constraint
+const std::string CONSTRAINT_ATTR_ENTITY_D("ConstraintEntityD");
+/// List of constraint attributes
+const std::string CONSTRAINT_ATTRIBUTES[4] =
+ {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B,
+ CONSTRAINT_ATTR_ENTITY_C, CONSTRAINT_ATTR_ENTITY_D};
/** \class SketchPlugin_Constraint
--- /dev/null
+// File: SketchPlugin_ConstraintCoincidence.cpp
+// Created: 08 May 2014
+// Author: Artem ZHIDKOV
+
+#include "SketchPlugin_ConstraintCoincidence.h"
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Data.h>
+#include <SketchPlugin_Point.h>
+
+SketchPlugin_ConstraintCoincidence::SketchPlugin_ConstraintCoincidence()
+{
+}
+
+void SketchPlugin_ConstraintCoincidence::initAttributes()
+{
+ data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
+ data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
+}
+
+void SketchPlugin_ConstraintCoincidence::execute()
+{
+}
+
+const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_ConstraintCoincidence::preview()
+{
+ /// \todo Preview for point coincidence
+ return getPreview();
+}
+
--- /dev/null
+// File: SketchPlugin_ConstraintCoincidence.h
+// Created: 08 May 2014
+// Author: Artem ZHIDKOV
+
+#ifndef SketchPlugin_ConstraintCoincidence_HeaderFile
+#define SketchPlugin_ConstraintCoincidence_HeaderFile
+
+#include "SketchPlugin.h"
+#include "SketchPlugin_Constraint.h"
+#include <list>
+
+
+/** \class SketchPlugin_ConstraintCoincidence
+ * \ingroup DataModel
+ * \brief Feature for creation of a new constraint which defines equvalence of two points
+ *
+ * These constraint has two attributes: CONSTRAINT_ATTR_POINT_A and CONSTRAINT_ATTR_POINT_B
+ */
+class SketchPlugin_ConstraintCoincidence: public SketchPlugin_Constraint
+{
+public:
+ /// \brief Returns the kind of a feature
+ SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
+ {static std::string MY_KIND = "SketchConstraintCoincidence"; 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<GeomAPI_Shape>& preview();
+
+ /// \brief Use plugin manager for features creation
+ SketchPlugin_ConstraintCoincidence();
+};
+
+#endif
+++ /dev/null
-// File: SketchPlugin_ConstraintPointsCoincident.cpp
-// Created: 08 May 2014
-// Author: Artem ZHIDKOV
-
-#include "SketchPlugin_ConstraintPointsCoincident.h"
-
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_Data.h>
-#include <SketchPlugin_Point.h>
-
-SketchPlugin_ConstraintPointsCoincident::SketchPlugin_ConstraintPointsCoincident()
-{
-}
-
-void SketchPlugin_ConstraintPointsCoincident::initAttributes()
-{
- data()->addAttribute(CONSTRAINT_ATTR_POINT_A, ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(CONSTRAINT_ATTR_POINT_B, ModelAPI_AttributeRefAttr::type());
-}
-
-void SketchPlugin_ConstraintPointsCoincident::execute()
-{
-}
-
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_ConstraintPointsCoincident::preview()
-{
- /// \todo Preview for point coincidence
- return getPreview();
-}
-
+++ /dev/null
-// File: SketchPlugin_ConstraintPointsCoincident.h
-// Created: 08 May 2014
-// Author: Artem ZHIDKOV
-
-#ifndef SketchPlugin_ConstraintPointsCoincident_HeaderFile
-#define SketchPlugin_ConstraintPointsCoincident_HeaderFile
-
-#include "SketchPlugin.h"
-#include "SketchPlugin_Constraint.h"
-#include <list>
-
-
-/** \class SketchPlugin_ConstraintPointsCoincident
- * \ingroup DataModel
- * \brief Feature for creation of a new constraint which defines equvalence of two points
- *
- * These constraint has two attributes: CONSTRAINT_ATTR_POINT_A and CONSTRAINT_ATTR_POINT_B
- */
-class SketchPlugin_ConstraintPointsCoincident: public SketchPlugin_Constraint
-{
-public:
- /// \brief Returns the kind of a feature
- SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
- {static std::string MY_KIND = "SketchConstraintPointsCoincident"; 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<GeomAPI_Shape>& preview();
-
- /// \brief Use plugin manager for features creation
- SketchPlugin_ConstraintPointsCoincident();
-};
-
-#endif
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Data.h>
#include <SketchPlugin_Constraint.h>
-#include <SketchPlugin_ConstraintPointsCoincident.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
#include <SketchPlugin_Line.h>
if (aDistAttr.get())
aDistance = aDistAttr->value();
+ /// \todo Specify the entities
Slvs_hEntity aPtA, aPtB, aEntityA, aEntityB; // parameters of the constraint
- boost::shared_ptr<ModelAPI_Attribute> aEntAttr = theConstraint->data()->attribute(CONSTRAINT_ATTR_POINT_A);
+ boost::shared_ptr<ModelAPI_Attribute> aEntAttr = theConstraint->data()->attribute(CONSTRAINT_ATTR_ENTITY_A);
aPtA = addEntity(aEntAttr);
if (aPtA == 0) return false;
- aEntAttr = theConstraint->data()->attribute(CONSTRAINT_ATTR_POINT_B);
+ aEntAttr = theConstraint->data()->attribute(CONSTRAINT_ATTR_ENTITY_B);
aPtB = addEntity(aEntAttr);
if (aPtB == 0) return false;
- aEntAttr = theConstraint->data()->attribute(CONSTRAINT_ATTR_ENTITY_A);
+ aEntAttr = theConstraint->data()->attribute(CONSTRAINT_ATTR_ENTITY_C);
aEntityA = addEntity(aEntAttr);
if (aEntityA == 0) return false;
- aEntAttr = theConstraint->data()->attribute(CONSTRAINT_ATTR_ENTITY_B);
+ aEntAttr = theConstraint->data()->attribute(CONSTRAINT_ATTR_ENTITY_D);
aEntityB = addEntity(aEntAttr);
if (aEntityB == 0) return false;