X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Constraint.h;h=632243ba608557cc11ea325f61724794fde566ce;hb=e6aea428c7da7751e753eac36b99e16b7e3166e4;hp=9a5e9e4803c01a14dc0700f84355ff59c2ff4404;hpb=507f658f34fc6c42f48fb83a8fa916c6f0e33fd3;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Constraint.h b/src/SketchPlugin/SketchPlugin_Constraint.h index 9a5e9e480..632243ba6 100644 --- a/src/SketchPlugin/SketchPlugin_Constraint.h +++ b/src/SketchPlugin/SketchPlugin_Constraint.h @@ -7,10 +7,15 @@ #include "SketchPlugin.h" #include "SketchPlugin_Feature.h" +#include #include #include #include +const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint +const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance + + /* Description: * Each constraint uses a set of parameters. In the SolveSpace library * these parameters are named "valA", "ptA", "ptB", "entityA", "entityB". @@ -18,78 +23,66 @@ * 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"); +/// The 2D value parameter for the constraint +const std::string CONSTRAINT_ATTR_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt"); /// 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 unsigned int CONSTRAINT_ATTR_SIZE = 4; +const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] = + {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B, + CONSTRAINT_ATTR_ENTITY_C, CONSTRAINT_ATTR_ENTITY_D}; /** \class SketchPlugin_Constraint * \ingroup DataModel * \brief Feature for creation of a new constraint between other features. + * Base class for all constraints. */ class SketchPlugin_Constraint: public SketchPlugin_Feature { public: - /// \brief Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "SketchConstraint"; 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;} - - /// Returns the sketch preview - /// \param theSketch the owner of this feature - /// \return the built preview - SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); + SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() + {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} /** \brief 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) {} + const FeaturePtr& theFeature) {} - /** \brief Adds an object of the constraint. The object added by the reference. - * \param[in] theAttrID identifier of the attribute - * \param[in] theReference reference to the feature, which will be constrained - */ - SKETCHPLUGIN_EXPORT virtual void addConstrainedObject( - const std::string& theAttrID, - const boost::shared_ptr& theReference); + /// \brief Returns the sketch preview + SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr& preview(); - /** \brief Adds an object of the constraint. The object added by the reference to its attribute. - * \param[in] theAttrID identifier of the attribute - * \param[in] theReference reference to the attribute feature, which will be constrained - */ - SKETCHPLUGIN_EXPORT virtual void addConstrainedObject( - const std::string& theAttrID, - const boost::shared_ptr& theReference); + /// Returns the AIS preview + SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious); - /** \brief Prepares list of attributes of current sketch workplane - * \param[out] theParams list of attributes - */ - SKETCHPLUGIN_EXPORT void getSketchParameters( - std::list< boost::shared_ptr >& theParams); + /// Moves the feature + /// \param theDeltaX the delta for X coordinate is moved + /// \param theDeltaY the delta for Y coordinate is moved + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {}; - /// \brief Use plugin manager for features creation - SketchPlugin_Constraint() {} + /// Return the distance between the feature and the point + /// \param thePoint the point + virtual double distanceToPoint(const boost::shared_ptr& thePoint) { return 0; }; protected: - /** \brief Returns the list of attributes for the certain type of constraint. - * \return names of attributes - */ - virtual const std::list& getAttributesList() const = 0; + /// \brief Use plugin manager for features creation + SketchPlugin_Constraint() {} }; #endif