]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Validators.h
Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / PartSet / PartSet_Validators.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef PartSet_Validators_H
22 #define PartSet_Validators_H
23
24 #include "PartSet.h"
25
26 #include <ModuleBase_SelectionValidator.h>
27 #include <ModuleBase_ISelection.h>
28 #include <ModelAPI_AttributeValidator.h>
29
30 /*
31  * Selector validators
32  */
33
34
35 //! \ingroup Validators
36 //! A class to validate a selection for Distance constraint operation
37 class PartSet_DistanceSelection : public ModuleBase_SelectionValidator
38 {
39 public:
40   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
41                                       ModuleBase_Operation* theOperation) const;
42 };
43
44 //! \ingroup Validators
45 //! A class to validate a selection for Length constraint operation
46 class PartSet_LengthSelection : public ModuleBase_SelectionValidator
47 {
48 public:
49   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
50                                       ModuleBase_Operation* theOperation) const;
51 };
52
53 //! \ingroup Validators
54 //! A class to validate a selection for Perpendicular constraint operation
55 class PartSet_PerpendicularSelection : public ModuleBase_SelectionValidator
56 {
57 public:
58   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
59                                       ModuleBase_Operation* theOperation) const;
60 };
61
62 //! \ingroup Validators
63 //! A class to validate a selection for Parallel constraint operation
64 class PartSet_ParallelSelection : public ModuleBase_SelectionValidator
65 {
66 public:
67   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
68                                       ModuleBase_Operation* theOperation) const;
69 };
70
71 //! \ingroup Validators
72 //! A class to validate a selection for Radius constraint operation
73 class PartSet_RadiusSelection : public ModuleBase_SelectionValidator
74 {
75 public:
76   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
77                                       ModuleBase_Operation* theOperation) const;
78 };
79
80 //! \ingroup Validators
81 //! A class to validate a selection for Rigid constraint operation
82 class PartSet_RigidSelection : public ModuleBase_SelectionValidator
83 {
84 public:
85   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
86                                       ModuleBase_Operation* theOperation) const;
87 };
88
89
90 //! \ingroup Validators
91 //! A class to validate a selection for coincedence constraint operation
92 class PartSet_CoincidentSelection : public ModuleBase_SelectionValidator
93 {
94 public:
95   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
96                                       ModuleBase_Operation* theOperation) const;
97 };
98
99 //! \ingroup Validators
100 //! A class to validate a selection for Horizontal and Vertical constraints operation
101 class PartSet_HVDirSelection : public ModuleBase_SelectionValidator
102 {
103 public:
104   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
105                                       ModuleBase_Operation* theOperation) const;
106 };
107
108 //! \ingroup Validators
109 //! A class to validate a selection for Tangential constraints operation
110 class PartSet_TangentSelection : public ModuleBase_SelectionValidator
111 {
112 public:
113   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
114                                       ModuleBase_Operation* theOperation) const;
115 };
116
117 //! \ingroup Validators
118 //! A class to validate a selection for Fillet constraints operation
119 class PartSet_FilletSelection : public ModuleBase_SelectionValidator
120 {
121 public:
122   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
123                                       ModuleBase_Operation* theOperation) const;
124 };
125
126 //! \ingroup Validators
127 //! A class to validate a selection for Angle constraints operation
128 class PartSet_AngleSelection : public ModuleBase_SelectionValidator
129 {
130 public:
131   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
132                                       ModuleBase_Operation* theOperation) const;
133 };
134
135 //! \ingroup Validators
136 //! A class to validate a selection for Equal constraints operation
137 class PartSet_EqualSelection : public ModuleBase_SelectionValidator
138 {
139 public:
140   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
141                                       ModuleBase_Operation* theOperation) const;
142 };
143
144 //! \ingroup Validators
145 //! A class to validate a selection for Collinear constraints operation
146 class PartSet_CollinearSelection : public ModuleBase_SelectionValidator
147 {
148 public:
149   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
150                                       ModuleBase_Operation* theOperation) const;
151 };
152
153 //! \ingroup Validators
154 //! A class to validate a selection for Middle point constraints operation
155 class PartSet_MiddlePointSelection : public ModuleBase_SelectionValidator
156 {
157 public:
158   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
159                                       ModuleBase_Operation* theOperation) const;
160 };
161
162 //! \ingroup Validators
163 //! A class to validate a selection for Middle point constraints operation
164 class PartSet_MultyTranslationSelection : public ModuleBase_SelectionValidator
165 {
166 public:
167   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
168                                       ModuleBase_Operation* theOperation) const;
169 };
170
171 //! \ingroup Validators
172 //! A class to validate a selection for Middle point constraints operation
173 class PartSet_SplitSelection : public ModuleBase_SelectionValidator
174 {
175 public:
176   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
177                                       ModuleBase_Operation* theOperation) const;
178 };
179
180 //! \ingroup Validators
181 //! A class to validate a selection for Middle point constraints operation
182 class PartSet_ProjectionSelection : public ModuleBase_SelectionValidator
183 {
184 public:
185   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
186                                       ModuleBase_Operation* theOperation) const;
187 };
188
189 ////////////// Attribute validators ////////////////
190
191
192 /**
193 * \ingroup Validators
194 * A validator which checks that objects selected for feature attributes are different (not the same)
195 */
196 class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
197 {
198   //! Validator possible error types
199   enum ErrorType {
200     EqualObjects,
201     EqualAttributes,
202     EqualShapes,
203     EmptyShapes
204   };
205  public:
206   //! Returns true if the attribute is good for the feature attribute
207   //! \param theAttribute an attribute
208   //! \param theArguments a list of arguments (names of attributes to check)
209   //! \param theError an output error string
210   virtual bool isValid(const AttributePtr& theAttribute,
211                        const std::list<std::string>& theArguments,
212                        Events_InfoMessage& theError) const;
213 private:
214   //! Returns error message for the error type
215   //! \param theType a type of error
216   //! \param thEqualObjectInfo an
217   std::string errorMessage(const PartSet_DifferentObjectsValidator::ErrorType& theType,
218                            const std::string& thEqualObject, const std::string& theFirstAttribute,
219                            const std::string& theSecondAttribute) const;
220
221 };
222
223 /**\class PartSet_CoincidentAttr
224  * \ingroup Validators
225  * \brief Validator to check whether there is a coincident constraint between
226  * the attribute and attribute of argument.
227  */
228 class PartSet_CoincidentAttr : public ModelAPI_AttributeValidator
229 {
230  public:
231   //! returns true if attribute is valid
232   //! \param theAttribute the checked attribute
233   //! \param theArguments arguments of the attribute
234   //! \param theError an output error string
235   virtual bool isValid(const AttributePtr& theAttribute,
236                        const std::list<std::string>& theArguments,
237                        Events_InfoMessage& theError) const;
238 };
239
240
241 #endif