Salome HOME
Issue #2117: Problem when creating an arc by 3 points ending on the same circle
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Validators.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_Validators.h
4 // Created:     01 Aug 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef SketchPlugin_Validators_H
8 #define SketchPlugin_Validators_H
9
10 #include "SketchPlugin.h"
11 #include <ModelAPI_AttributeValidator.h>
12 #include <ModelAPI_FeatureValidator.h>
13
14 /**\class SketchPlugin_DistanceAttrValidator
15  * \ingroup Validators
16  * \brief Validator for the distance input.
17  *
18  * It just checks that distance is greater than zero.
19  */
20 class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator
21 {
22  public:
23   //! returns true if attribute is valid
24   //! \param theAttribute the checked attribute
25   //! \param theArguments arguments of the attribute
26   //! \param theError error message
27   virtual bool isValid(const AttributePtr& theAttribute,
28                        const std::list<std::string>& theArguments,
29                        Events_InfoMessage& theError) const;
30 };
31
32 /**\class SketchPlugin_TangentAttrValidator
33  * \ingroup Validators
34  * \brief Validator for the tangent constraint input.
35  *
36  * It just checks that distance is greater than zero.
37  */
38 class SketchPlugin_TangentAttrValidator : public ModelAPI_AttributeValidator
39 {
40  public:
41   //! returns true if attribute is valid
42   //! \param theAttribute the checked attribute
43   //! \param theArguments arguments of the attribute
44   //! \param theError error message
45   virtual bool isValid(const AttributePtr& theAttribute,
46                        const std::list<std::string>& theArguments,
47                        Events_InfoMessage& theError) const;
48 };
49
50
51 /**\class SketchPlugin_NotFixedValidator
52  * \ingroup Validators
53  * \brief Validator for the rigid constraint input.
54  *
55  * It just checks there is no rigid constraint for the current feature.
56  */
57 class SketchPlugin_NotFixedValidator : public ModelAPI_AttributeValidator
58 {
59  public:
60   //! returns true if attribute is not used in another rigid constraint
61   //! \param theAttribute the checked attribute
62   //! \param theArguments arguments of the attribute
63   //! \param theError error message
64   virtual bool isValid(const AttributePtr& theAttribute,
65                        const std::list<std::string>& theArguments,
66                        Events_InfoMessage& theError) const;
67 };
68
69 /**\class SketchPlugin_EqualAttrValidator
70  * \ingroup Validators
71  * \brief Validator for the equal constraint input.
72  *
73  * It checks that attributes of the Equal constraint are correct.
74  */
75 class SketchPlugin_EqualAttrValidator : public ModelAPI_AttributeValidator
76 {
77  public:
78   //! returns true if attribute is valid
79   //! \param theAttribute the checked attribute
80   //! \param theArguments arguments of the attribute
81   //! \param theError error message
82   virtual bool isValid(const AttributePtr& theAttribute,
83                        const std::list<std::string>& theArguments,
84                        Events_InfoMessage& theError) const;
85 };
86
87 /**\class SketchPlugin_MirrorAttrValidator
88  * \ingroup Validators
89  * \brief Validator for the mirror constraint input.
90  *
91  * It checks that attributes of the Mirror constraint are correct.
92  */
93 class SketchPlugin_MirrorAttrValidator : public ModelAPI_AttributeValidator
94 {
95  public:
96   //! returns true if attribute is valid
97   //! \param theAttribute the checked attribute
98   //! \param theArguments arguments of the attribute (not used)
99   //! \param theError error message
100   virtual bool isValid(const AttributePtr& theAttribute,
101                        const std::list<std::string>& theArguments,
102                        Events_InfoMessage& theError) const;
103 };
104
105
106 /**\class SketchPlugin_CoincidenceAttrValidator
107  * \ingroup Validators
108  * \brief Validator for the coincidence constraint input.
109  *
110  * It checks that attributes of the Coincidence constraint are correct.
111  */
112 class SketchPlugin_CoincidenceAttrValidator : public ModelAPI_AttributeValidator
113 {
114  public:
115   //! returns true if attribute is valid
116   //! \param theAttribute the checked attribute
117   //! \param theArguments arguments of the attribute (not used)
118   //! \param theError error message
119   virtual bool isValid(const AttributePtr& theAttribute,
120                        const std::list<std::string>& theArguments,
121                        Events_InfoMessage& theError) const;
122 };
123
124
125 /**\class SketchPlugin_CopyValidator
126  * \ingroup Validators
127  * \brief Validator for the constraints which create features.
128  *
129  * Applicable only for features, which creates another features. It verifies the produced
130  * features of current constraint don't become into the list of initial features
131  */
132 class SketchPlugin_CopyValidator : public ModelAPI_AttributeValidator
133 {
134  public:
135   //! returns true if attribute is valid
136   //! \param theAttribute the checked attribute
137   //! \param theArguments arguments of the attribute (not used)
138   //! \param theError error message
139   virtual bool isValid(const AttributePtr& theAttribute,
140                        const std::list<std::string>& theArguments,
141                        Events_InfoMessage& theError) const;
142 };
143
144 /**\class SketchPlugin_SolverErrorValidator
145  * \ingroup Validators
146  * \brief Validator for the solver error.
147  *
148  * Simply checks that solver error attribute is empty. Returns the attribute value as an error.
149  */
150 class SketchPlugin_SolverErrorValidator : public ModelAPI_FeatureValidator
151 {
152  public:
153   //! returns true if there are no solver errors
154   //! \param theFeature the checked feature
155   //! \param theArguments arguments of the feature (not used)
156   //! \param theError error message
157   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
158                        const std::list<std::string>& theArguments,
159                        Events_InfoMessage& theError) const;
160
161   /// Returns true if the attribute in feature is not obligatory for the feature execution
162   virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
163 };
164
165 /**\class SketchPlugin_FilletVertexValidator
166  * \ingroup Validators
167  * \brief Validator for the point for fillet creation.
168  *
169  * Checks that selected point have exactly two coincident lines.
170  */
171 class SketchPlugin_FilletVertexValidator : public ModelAPI_AttributeValidator
172 {
173 public:
174   //! returns true if attribute is valid
175   //! \param theAttribute the checked attribute
176   //! \param theArguments arguments of the attribute (not used)
177   //! \param theError error message
178   virtual bool isValid(const AttributePtr& theAttribute,
179                        const std::list<std::string>& theArguments,
180                        Events_InfoMessage& theError) const;
181 };
182
183
184 /**\class SketchPlugin_MiddlePointAttrValidator
185  * \ingroup Validators
186  * \brief Validator for the middle point constraint input.
187  *
188  * It checks that attributes of the Middle point constraint are correct.
189  */
190 class SketchPlugin_MiddlePointAttrValidator : public ModelAPI_AttributeValidator
191 {
192  public:
193   //! returns true if attribute is valid
194   //! \param theAttribute the checked attribute
195   //! \param theArguments arguments of the attribute (not used)
196   //! \param theError error message
197   virtual bool isValid(const AttributePtr& theAttribute,
198                        const std::list<std::string>& theArguments,
199                        Events_InfoMessage& theError) const;
200 };
201
202
203 /**\class SketchPlugin_ArcTangentPointValidator
204  * \ingroup Validators
205  * \brief Validator for the point where the tangent arc is building.
206  *
207  * Checks that the point is a start or end point just on line or arc.
208  */
209 class SketchPlugin_ArcTangentPointValidator : public ModelAPI_AttributeValidator
210 {
211  public:
212   //! returns true if attribute is valid
213   //! \param theAttribute the checked attribute
214   //! \param theArguments arguments of the attribute
215   //! \param theError error message
216   virtual bool isValid(const AttributePtr& theAttribute,
217                        const std::list<std::string>& theArguments,
218                        Events_InfoMessage& theError) const;
219 };
220
221 /**\class SketchPlugin_SplitValidator
222  * \ingroup Validators
223  * \brief Validator for the entity of the following type:
224  * - Linear segment with point(s) coinident to this line
225  * - Arc with point(s) coincident to the arc
226  * - Circle with at least 2 split-points on this circle
227  *
228  * Checks that there are coincident point on selected feature.
229  */
230 class SketchPlugin_SplitValidator : public ModelAPI_AttributeValidator
231 {
232  public:
233   //! returns true if attribute is valid
234   //! \param theAttribute the checked attribute
235   //! \param theArguments arguments of the attribute
236   //! \param theError error message
237   virtual bool isValid(const AttributePtr& theAttribute,
238                        const std::list<std::string>& theArguments,
239                        Events_InfoMessage& theError) const;
240 };
241
242 /**\class SketchPlugin_TrimValidator
243  * \ingroup Validators
244  * \brief Validator for the entity of the following type:
245  * - Linear segment with point(s) coinident to this line or intersected it
246  * - Arc with point(s) coincident to the arc or intersected it
247  * - Circle with at least 2 split-points on this circle or intersected it
248  *
249  * Checks that there are coincident point on selected feature.
250  */
251 class SketchPlugin_TrimValidator : public ModelAPI_AttributeValidator
252 {
253  public:
254   //! returns true if attribute is valid
255   //! \param theAttribute the checked attribute
256   //! \param theArguments arguments of the attribute
257   //! \param theError error message
258   virtual bool isValid(const AttributePtr& theAttribute,
259                        const std::list<std::string>& theArguments,
260                        Events_InfoMessage& theError) const;
261 };
262
263 /**\class SketchPlugin_IntersectionValidator
264  * \ingroup Validators
265  * \brief Validator for the attribute to be intersected with the sketch plane.
266  */
267 class SketchPlugin_IntersectionValidator : public ModelAPI_AttributeValidator
268 {
269  public:
270   //! returns true if attribute is valid
271   //! \param theAttribute the checked attribute
272   //! \param theArguments arguments of the attribute
273   //! \param theError error message
274   virtual bool isValid(const AttributePtr& theAttribute,
275                        const std::list<std::string>& theArguments,
276                        Events_InfoMessage& theError) const;
277 };
278
279 /**\class SketchPlugin_ProjectionValidator
280  * \ingroup Validators
281  * \brief Validator for the attribute to be projected onto the sketch plane.
282  */
283 class SketchPlugin_ProjectionValidator : public ModelAPI_AttributeValidator
284 {
285  public:
286   //! returns true if attribute is valid
287   //! \param theAttribute the checked attribute
288   //! \param theArguments arguments of the attribute
289   //! \param theError error message
290   virtual bool isValid(const AttributePtr& theAttribute,
291                        const std::list<std::string>& theArguments,
292                        Events_InfoMessage& theError) const;
293 };
294
295 /**\class SketchPlugin_DifferentReferenceValidator
296  * \ingroup Validators
297  * \brief Validator for attributes of a sketch feature.
298  *
299  * It checks that at least one of specified attributes
300  * refers to another feature in respect to each other.
301  */
302 class SketchPlugin_DifferentReferenceValidator : public ModelAPI_AttributeValidator
303 {
304  public:
305   //! returns true if attribute is valid
306   //! \param theAttribute the checked attribute
307   //! \param theArguments arguments of the attribute
308   //! \param theError error message
309   virtual bool isValid(const AttributePtr& theAttribute,
310                        const std::list<std::string>& theArguments,
311                        Events_InfoMessage& theError) const;
312 };
313
314 /**\class SketchPlugin_DifferentPointReferenceValidator
315  * \ingroup Validators
316  * \brief Validator for attributes of a sketch feature.
317  *
318  * It checks that at least two of specified attributes refer to different points.
319  */
320 class SketchPlugin_DifferentPointReferenceValidator : public ModelAPI_AttributeValidator
321 {
322  public:
323   //! returns true if attribute is valid
324   //! \param theAttribute the checked attribute
325   //! \param theArguments arguments of the attribute
326   //! \param theError error message
327   virtual bool isValid(const AttributePtr& theAttribute,
328                        const std::list<std::string>& theArguments,
329                        Events_InfoMessage& theError) const;
330 };
331
332 /**\class SketchPlugin_CirclePassedPointValidator
333  * \ingroup Validators
334  * \brief Validator for passed point of MacroCircle feature.
335  *
336  * Checks that passed point does not refer to the feature, the center is coincident to.
337  */
338 class SketchPlugin_CirclePassedPointValidator : public ModelAPI_AttributeValidator
339 {
340  public:
341   //! returns true if attribute is valid
342   //! \param theAttribute the checked attribute
343   //! \param theArguments arguments of the attribute
344   //! \param theError error message
345   virtual bool isValid(const AttributePtr& theAttribute,
346                        const std::list<std::string>&,
347                        Events_InfoMessage& theError) const;
348 };
349
350 /**\class SketchPlugin_ThirdPointValidator
351  * \ingroup Validators
352  * \brief Validator for the third point of MacroCircle feature.
353  *
354  * Checks that third point does not lie on a line passed through the first two points.
355  * Checks that third point does not refer to feature lying between the first two points.
356  */
357 class SketchPlugin_ThirdPointValidator : public ModelAPI_AttributeValidator
358 {
359  public:
360   //! returns true if attribute is valid
361   //! \param theAttribute the checked attribute
362   //! \param theArguments arguments of the attribute
363   //! \param theError error message
364   virtual bool isValid(const AttributePtr& theAttribute,
365                        const std::list<std::string>& theArguments,
366                        Events_InfoMessage& theError) const;
367
368 private:
369   //! returns true if three points have not been placed on the same line
370   bool arePointsNotOnLine(const FeaturePtr& theMacroFeature,
371                           Events_InfoMessage& theError) const;
372
373   //! returns true if the first two points have not been separated
374   //! by a feature referred by thrid point
375   bool arePointsNotSeparated(const FeaturePtr& theMacroFeature,
376                              const std::list<std::string>& theArguments,
377                              Events_InfoMessage& theError) const;
378 };
379
380 /**\class SketchPlugin_ArcEndPointValidator
381  * \ingroup Validators
382  * \brief Validator for the end point of MacroArc feature.
383  *
384  * Checks that third point does not lie on a point.
385  */
386 class SketchPlugin_ArcEndPointValidator: public ModelAPI_AttributeValidator
387 {
388  public:
389   //! returns true if attribute is valid
390   //! \param theAttribute the checked attribute
391   //! \param theArguments arguments of the attribute
392   //! \param theError error message
393   virtual bool isValid(const AttributePtr& theAttribute,
394                        const std::list<std::string>& theArguments,
395                        Events_InfoMessage& theError) const;
396 };
397
398 /**\class SketchPlugin_ArcEndPointIntersectionValidator
399  * \ingroup Validators
400  * \brief Validator for the end point of MacroArc feature.
401  *
402  * Checks that third point does lie on edge which intersects arc.
403  */
404 class SketchPlugin_ArcEndPointIntersectionValidator: public ModelAPI_AttributeValidator
405 {
406  public:
407   //! returns true if attribute is valid
408   //! \param theAttribute the checked attribute
409   //! \param theArguments arguments of the attribute
410   //! \param theError error message
411   virtual bool isValid(const AttributePtr& theAttribute,
412                        const std::list<std::string>& theArguments,
413                        Events_InfoMessage& theError) const;
414 };
415
416 #endif