Salome HOME
#1042 Sometimes when setting distance constraints, the input field is not displayed...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Constraint.h
index 98680830ae87b92b2152e7d2cb45b0ad72d4fd29..dc4a228cbc80aa1dbe7f5917ced4dd3c9a0fee4d 100644 (file)
@@ -1,70 +1,87 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_Constraint.h
 // Created: 08 May 2014
 // Author:  Artem ZHIDKOV
 
-#ifndef SketchPlugin_Constraint_HeaderFile
-#define SketchPlugin_Constraint_HeaderFile
+#ifndef SketchPlugin_Constraint_H_
+#define SketchPlugin_Constraint_H_
 
-#include "SketchPlugin.h"
-#include "SketchPlugin_Feature.h"
-#include <ModelAPI_AttributeReference.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <list>
+#include <SketchPlugin_Feature.h>
 
-/*  Description: 
- *    Each constraint uses a set of parameters. In the SolveSpace library 
- *    these parameters are named "valA", "ptA", "ptB", "entityA", "entityB". 
- *    The "ptA" and "ptB" parameters represents a point in the constraint.
- *    The "entityA" and "entityB" represents any other object (and a point too).
- *    And the "valA" represents a real value.
- *
- *    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("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 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};
+#include <string>
 
+/// Size of the list of constraint attributes
+const unsigned int CONSTRAINT_ATTR_SIZE = 4;
 
 /** \class SketchPlugin_Constraint
- *  \ingroup DataModel
- *  \brief Feature for creation of a new constraint between other features.
- *         Base class for all constraints.
+ *  \brief Abstract interface to the SketchPlugin_ConstraintBase
+ *         For more info see: SketchPlugin_ConstraintBase.h
  */
-class SketchPlugin_Constraint: public SketchPlugin_Feature
+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;}
+ public:
+  /// The value parameter for the constraint
+  inline static const std::string& VALUE()
+  {
+    static const std::string MY_CONSTRAINT_VALUE("ConstraintValue");
+    return MY_CONSTRAINT_VALUE;
+  }
+  /// The 2D value parameter for the constraint
+  inline static const std::string& FLYOUT_VALUE_PNT()
+  {
+    static const std::string MY_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
+    return MY_FLYOUT_VALUE_PNT;
+  }
+  /// First entity for the constraint
+  inline static const std::string& ENTITY_A()
+  {
+    static const std::string MY_ENTITY_A("ConstraintEntityA");
+    return MY_ENTITY_A;
+  }
+  /// Second entity for the constraint
+  inline static const std::string& ENTITY_B()
+  {
+    static const std::string MY_ENTITY_B("ConstraintEntityB");
+    return MY_ENTITY_B;
+  }
+  /// Third entity for the constraint
+  inline static const std::string& ENTITY_C()
+  {
+    static const std::string MY_ENTITY_C("ConstraintEntityC");
+    return MY_ENTITY_C;
+  }
+  /// Fourth entity for the constraint
+  inline static const std::string& ENTITY_D()
+  {
+    static const std::string MY_ENTITY_D("ConstraintEntityD");
+    return MY_ENTITY_D;
+  }
 
-  /** \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<ModelAPI_Feature>& theFeature) {}
+  /// List of constraint attributes
+  inline static const std::string& ATTRIBUTE(const int theNumber)
+  {
+    switch (theNumber) {
+      case 0:
+        return ENTITY_A();
+      case 1:
+        return ENTITY_B();
+      case 2:
+        return ENTITY_C();
+      case 3:
+        return ENTITY_D();
+      default:
+        break;
+    }
+    static const std::string EMPTY_STRING("");
+    return EMPTY_STRING;
+  }
 
-protected:
+ protected:
   /// \brief Use plugin manager for features creation
-  SketchPlugin_Constraint() {}
+  SketchPlugin_Constraint();
 };
 
+typedef std::shared_ptr<SketchPlugin_Constraint> ConstraintPtr;
+
 #endif