SHAPER  9.15.0
SketchPlugin_Constraint.h
1 // Copyright (C) 2014-2025 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef SketchPlugin_Constraint_H_
21 #define SketchPlugin_Constraint_H_
22 
23 #include <SketchPlugin_Feature.h>
24 #include <ModelAPI_AttributeDouble.h>
25 
26 #include <string>
27 #include <limits>
28 
30 const int CONSTRAINT_ATTR_SIZE = 4;
31 
37 {
38  public:
40  inline static const std::string& VALUE()
41  {
42  static const std::string MY_CONSTRAINT_VALUE("ConstraintValue");
43  return MY_CONSTRAINT_VALUE;
44  }
46  inline static const std::string& FLYOUT_VALUE_PNT()
47  {
48  static const std::string MY_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
49  return MY_FLYOUT_VALUE_PNT;
50  }
52  inline static const std::string& CONSTRAINT_ACTIVE()
53  {
54  static const std::string MY_STATE("ConstraintState");
55  return MY_STATE;
56  }
58  inline static const std::string& ENTITY_A()
59  {
60  static const std::string MY_ENTITY_A("ConstraintEntityA");
61  return MY_ENTITY_A;
62  }
64  inline static const std::string& ENTITY_B()
65  {
66  static const std::string MY_ENTITY_B("ConstraintEntityB");
67  return MY_ENTITY_B;
68  }
70  inline static const std::string& ENTITY_C()
71  {
72  static const std::string MY_ENTITY_C("ConstraintEntityC");
73  return MY_ENTITY_C;
74  }
76  inline static const std::string& ENTITY_D()
77  {
78  static const std::string MY_ENTITY_D("ConstraintEntityD");
79  return MY_ENTITY_D;
80  }
81 
83  inline static const std::string& ATTRIBUTE(const int theNumber)
84  {
85  switch (theNumber) {
86  case 0:
87  return ENTITY_A();
88  case 1:
89  return ENTITY_B();
90  case 2:
91  return ENTITY_C();
92  case 3:
93  return ENTITY_D();
94  default:
95  break;
96  }
97  static const std::string EMPTY_STRING("");
98  return EMPTY_STRING;
99  }
100 
102  virtual inline bool isZeroValueAllowed()
103  {
104  return true;
105  }
106 
109  virtual inline void setNumericValue(const double theValue)
110  {
111  real(VALUE())->setValue(theValue);
112  }
113 
115  virtual inline double getNumericValue()
116  {
117  return real(VALUE())? real(VALUE())->value(): std::numeric_limits<double>::lowest();
118  }
119 
120  protected:
123 };
124 
125 typedef std::shared_ptr<SketchPlugin_Constraint> ConstraintPtr;
126 
127 #endif
std::shared_ptr< ModelAPI_AttributeDouble > real(const std::string &theID)
Returns the real attribute by the identifier.
Definition: ModelAPI_Feature.h:211
Abstract interface to the SketchPlugin_ConstraintBase For more info see: SketchPlugin_ConstraintBase....
Definition: SketchPlugin_Constraint.h:37
static const std::string & CONSTRAINT_ACTIVE()
State of constraint - Active - true, Suppressed - false.
Definition: SketchPlugin_Constraint.h:52
virtual double getNumericValue()
Get numeric value of attribute VALUE()
Definition: SketchPlugin_Constraint.h:115
SketchPlugin_Constraint()
Use plugin manager for features creation.
Definition: SketchPlugin_Constraint.cpp:22
virtual bool isZeroValueAllowed()
Get if a constraint is able to have a zero numeric value.
Definition: SketchPlugin_Constraint.h:102
static const std::string & FLYOUT_VALUE_PNT()
The 2D value parameter for the constraint.
Definition: SketchPlugin_Constraint.h:46
static const std::string & ENTITY_A()
First entity for the constraint.
Definition: SketchPlugin_Constraint.h:58
virtual void setNumericValue(const double theValue)
Set numeric value to attribute VALUE()
Definition: SketchPlugin_Constraint.h:109
static const std::string & ENTITY_D()
Fourth entity for the constraint.
Definition: SketchPlugin_Constraint.h:76
static const std::string & VALUE()
The value parameter for the constraint.
Definition: SketchPlugin_Constraint.h:40
static const std::string & ENTITY_B()
Second entity for the constraint.
Definition: SketchPlugin_Constraint.h:64
static const std::string & ENTITY_C()
Third entity for the constraint.
Definition: SketchPlugin_Constraint.h:70
static const std::string & ATTRIBUTE(const int theNumber)
List of constraint attributes.
Definition: SketchPlugin_Constraint.h:83
Feature for creation of the new feature in PartSet.
Definition: SketchPlugin_Feature.h:40