From 8731443233c00aa76fb5f5d65b273ab1d7dedd04 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 13 May 2014 12:42:42 +0400 Subject: [PATCH] The class for the points coincidence was renamed --- src/SketchPlugin/CMakeLists.txt | 4 +-- src/SketchPlugin/SketchPlugin_Constraint.h | 21 ++++++++----- .../SketchPlugin_ConstraintCoincidence.cpp | 30 +++++++++++++++++++ ...h => SketchPlugin_ConstraintCoincidence.h} | 14 ++++----- ...ketchPlugin_ConstraintPointsCoincident.cpp | 30 ------------------- .../SketchSolver_ConstraintManager.cpp | 11 +++---- 6 files changed, 58 insertions(+), 52 deletions(-) create mode 100644 src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp rename src/SketchPlugin/{SketchPlugin_ConstraintPointsCoincident.h => SketchPlugin_ConstraintCoincidence.h} (71%) delete mode 100644 src/SketchPlugin/SketchPlugin_ConstraintPointsCoincident.cpp diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 33cce5392..eb5956ec2 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -8,7 +8,7 @@ SET(PROJECT_HEADERS SketchPlugin_Line.h SketchPlugin_Point.h SketchPlugin_Constraint.h - SketchPlugin_ConstraintPointsCoincident.h + SketchPlugin_ConstraintCoincidence.h ) SET(PROJECT_SOURCES @@ -17,7 +17,7 @@ SET(PROJECT_SOURCES SketchPlugin_Sketch.cpp SketchPlugin_Line.cpp SketchPlugin_Point.cpp - SketchPlugin_ConstraintPointsCoincident.cpp + SketchPlugin_ConstraintCoincidence.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/SketchPlugin/SketchPlugin_Constraint.h b/src/SketchPlugin/SketchPlugin_Constraint.h index 8c5e6dadb..e69a316cc 100644 --- a/src/SketchPlugin/SketchPlugin_Constraint.h +++ b/src/SketchPlugin/SketchPlugin_Constraint.h @@ -18,20 +18,25 @@ * 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 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp new file mode 100644 index 000000000..6cd5c1b58 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp @@ -0,0 +1,30 @@ +// File: SketchPlugin_ConstraintCoincidence.cpp +// Created: 08 May 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_ConstraintCoincidence.h" + +#include +#include +#include + +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& SketchPlugin_ConstraintCoincidence::preview() +{ + /// \todo Preview for point coincidence + return getPreview(); +} + diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPointsCoincident.h b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h similarity index 71% rename from src/SketchPlugin/SketchPlugin_ConstraintPointsCoincident.h rename to src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h index 8130a43b9..fe75115e9 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPointsCoincident.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h @@ -1,27 +1,27 @@ -// File: SketchPlugin_ConstraintPointsCoincident.h +// File: SketchPlugin_ConstraintCoincidence.h // Created: 08 May 2014 // Author: Artem ZHIDKOV -#ifndef SketchPlugin_ConstraintPointsCoincident_HeaderFile -#define SketchPlugin_ConstraintPointsCoincident_HeaderFile +#ifndef SketchPlugin_ConstraintCoincidence_HeaderFile +#define SketchPlugin_ConstraintCoincidence_HeaderFile #include "SketchPlugin.h" #include "SketchPlugin_Constraint.h" #include -/** \class SketchPlugin_ConstraintPointsCoincident +/** \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_ConstraintPointsCoincident: public SketchPlugin_Constraint +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 = "SketchConstraintPointsCoincident"; return MY_KIND;} + {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() @@ -37,7 +37,7 @@ public: SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); /// \brief Use plugin manager for features creation - SketchPlugin_ConstraintPointsCoincident(); + SketchPlugin_ConstraintCoincidence(); }; #endif diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPointsCoincident.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPointsCoincident.cpp deleted file mode 100644 index ebbb76373..000000000 --- a/src/SketchPlugin/SketchPlugin_ConstraintPointsCoincident.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// File: SketchPlugin_ConstraintPointsCoincident.cpp -// Created: 08 May 2014 -// Author: Artem ZHIDKOV - -#include "SketchPlugin_ConstraintPointsCoincident.h" - -#include -#include -#include - -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& SketchPlugin_ConstraintPointsCoincident::preview() -{ - /// \todo Preview for point coincidence - return getPreview(); -} - diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 6872c82f6..7984b031c 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include @@ -106,17 +106,18 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::addConstraint if (aDistAttr.get()) aDistance = aDistAttr->value(); + /// \todo Specify the entities Slvs_hEntity aPtA, aPtB, aEntityA, aEntityB; // parameters of the constraint - boost::shared_ptr aEntAttr = theConstraint->data()->attribute(CONSTRAINT_ATTR_POINT_A); + boost::shared_ptr 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; -- 2.39.2