Salome HOME
bos #29482 Export of colors and names to STEP.
[modules/shaper.git] / src / ModelAPI / ModelAPI_Events.h
1 // Copyright (C) 2014-2022  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 email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef MODELAPI_EVENTS_H_
21 #define MODELAPI_EVENTS_H_
22
23 #include <ModelAPI.h>
24 #include <ModelAPI_Object.h>
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Attribute.h>
27 #include <Events_MessageGroup.h>
28 #include <Events_Loop.h>
29
30 #include <memory>
31 #include <string>
32 #include <set>
33 #include <map>
34
35
36 class ModelAPI_Document;
37 class ModelAPI_ResultParameter;
38 class GeomAPI_Pnt2d;
39 class GeomAPI_Shape;
40
41 #if defined __GNUC__ || defined __clang__
42 #define MAYBE_UNUSED __attribute__((unused))
43 #else
44 #define MAYBE_UNUSED
45 #endif
46
47 /// Event ID that feature is created (comes with ModelAPI_ObjectUpdatedMessage)
48 MAYBE_UNUSED static const char * EVENT_OBJECT_CREATED = "ObjectCreated";
49 /// Event ID that data of feature is updated (comes with Model_ObjectUpdatedMessage)
50 MAYBE_UNUSED static const char * EVENT_OBJECT_UPDATED = "ObjectUpdated";
51 /// Event ID that data of feature is deleted (comes with Model_ObjectDeletedMessage)
52 MAYBE_UNUSED static const char * EVENT_OBJECT_DELETED = "ObjectDeleted";
53 /// Event ID that name of feature is changed (comes with Model_ObjectRenamedMessage)
54 MAYBE_UNUSED static const char * EVENT_OBJECT_RENAMED = "ObjectRenamed";
55 /// Event ID that data of feature is updated (comes with ModelAPI_ObjectUpdatedMessage)
56 MAYBE_UNUSED static const char * EVENT_OBJECT_MOVED = "ObjectsMoved";
57 /// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage)
58 MAYBE_UNUSED static const char * EVENT_OBJECT_TO_REDISPLAY = "ObjectsToRedisplay";
59 /// Event ID that plugin is loaded (comes with ModelAPI_ObjectUpdatedMessage)
60 MAYBE_UNUSED static const char * EVENT_PLUGIN_LOADED = "PluginLoaded";
61 /// The active document becomes another one
62 MAYBE_UNUSED static const char * EVENT_DOCUMENT_CHANGED = "CurrentDocumentChanged";
63
64 /// Event ID that order of objects in group is changed,
65 /// so, tree must be fully recreated (movement of feature)
66 MAYBE_UNUSED static const char * EVENT_ORDER_UPDATED = "OrderUpdated";
67 /// Event ID that the sketch is prepared and all grouped messages for the solver may be flushed
68 MAYBE_UNUSED static const char * EVENT_UPDATE_SELECTION = "UpdateSelection";
69
70 /// Request for the enabled/disabled actions behavior for some specific features
71 MAYBE_UNUSED static const char * EVENT_FEATURE_STATE_REQUEST = "FeatureStateRequest";
72 /// Reply for the enabled/disabled actions behavior for some specific features
73 MAYBE_UNUSED static const char * EVENT_FEATURE_STATE_RESPONSE = "FeatureStateResponse";
74
75 /// To block the viewer updates
76 MAYBE_UNUSED static const char * EVENT_UPDATE_VIEWER_BLOCKED = "UpdateViewerBlocked";
77 /// To unblock the viewer updates
78 MAYBE_UNUSED static const char * EVENT_UPDATE_VIEWER_UNBLOCKED = "UpdateViewerUnblocked";
79
80 /// To inform that there is an empty presentation in the viewer
81 MAYBE_UNUSED static const char * EVENT_EMPTY_AIS_PRESENTATION = "EmptyAISPresentation";
82 /// To inform that there is an empty operation for presentation in the viewer
83 MAYBE_UNUSED static const char * EVENT_EMPTY_OPERATION_PRESENTATION = "EmptyOperationPresentation";
84 /// To block preview
85 MAYBE_UNUSED static const char * EVENT_PREVIEW_BLOCKED = "PreviewBlocked";
86 /// To preview the current feature in the viewer (to compute the result)
87 MAYBE_UNUSED static const char * EVENT_PREVIEW_REQUESTED = "PreviewRequested";
88 /// To block automatic recomputation of any feature (by the GUI button press)
89 MAYBE_UNUSED static const char * EVENT_AUTOMATIC_RECOMPUTATION_DISABLE
90                                                          = "DisableAutomaticRecomputation";
91 /// To unblock block automatic recomputation (default state: the GUI button unpressed)
92 MAYBE_UNUSED static const char * EVENT_AUTOMATIC_RECOMPUTATION_ENABLE
93                                                          = "EnableAutomaticRecomputation";
94
95 /// Event ID that solver has conflicting constraints (comes with ModelAPI_SolverFailedMessage)
96 MAYBE_UNUSED static const char * EVENT_SOLVER_FAILED = "SolverFailed";
97 /// Event ID that the problem in solver disappeared
98 MAYBE_UNUSED static const char * EVENT_SOLVER_REPAIRED = "SolverRepaired";
99
100 /// Event Id that sketch has DoF = 0
101 MAYBE_UNUSED static const char * EVENT_SKETCH_FULLY_CONSTRAINED = "SketchFullyConstrainted";
102 /// Event Id that sketch has DoF > 0
103 MAYBE_UNUSED static const char * EVENT_SKETCH_UNDER_CONSTRAINED = "SketchUnderConstrainted";
104 /// Event Id that sketch has DoF < 0
105 MAYBE_UNUSED static const char * EVENT_SKETCH_OVER_CONSTRAINED  = "SketchOverConstrainted";
106
107 /// Event ID that informs that some object has changed the stability
108 MAYBE_UNUSED static const char * EVENT_STABILITY_CHANGED = "StabilityChanged";
109
110 /// Event ID that the sketch is prepared and all grouped messages for the solver may be flushed
111 MAYBE_UNUSED static const char * EVENT_SKETCH_PREPARED = "SketchPrepared";
112
113 /// Event ID that provides a request for list of non-fixed objects necessary for DoF = 0
114 MAYBE_UNUSED static const char * EVENT_GET_DOF_OBJECTS = "GetDoFObjects";
115
116 /// Event ID that provides a request for list of non-fixed objects necessary for DoF = 0
117 MAYBE_UNUSED static const char * EVENT_DOF_OBJECTS = "DoFObjects";
118
119 /// Event ID that requests updates visual attributes for presentations
120 MAYBE_UNUSED static const char * EVENT_VISUAL_ATTRIBUTES = "UpdateVisualAttributes";
121
122 /// Event ID that 1D-fillet failed (comes with ModelAPI_ShapesFailedMessage)
123 MAYBE_UNUSED static const char * EVENT_OPERATION_SHAPES_FAILED = "OperationShapesFailed";
124
125 MAYBE_UNUSED static const char * EVENT_CHECK_CONSTRAINTS = "CheckConstrains";
126
127 MAYBE_UNUSED static const char * EVENT_REMOVE_CONSTRAINTS = "RemoveConstrains";
128
129 /// Event ID that license of specified features is checked and valid
130 MAYBE_UNUSED static const char * EVENT_FEATURE_LICENSE_VALID = "FeaturesLicenseValid";
131
132 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
133 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
134 {
135  protected:
136   /// Creates an empty message
137   ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0);
138   /// The virtual destructor
139   virtual ~ModelAPI_ObjectUpdatedMessage();
140
141  public:
142   /// Returns the feature that has been updated
143   virtual const std::set<ObjectPtr>& objects() const = 0;
144
145   //! Creates a new empty group (to store it in the loop before flush)
146   virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
147
148   //! Allows to join the given message with the current one
149   virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
150 };
151
152 /// Message that feature was deleted (used for Object Browser update)
153 class MODELAPI_EXPORT ModelAPI_ObjectDeletedMessage : public Events_MessageGroup
154 {
155 protected:
156   /// Creates an empty message
157   ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0);
158   /// The virtual destructor
159   virtual ~ModelAPI_ObjectDeletedMessage();
160
161 public:
162   /// Returns the groups where the objects were deleted
163   virtual const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> >&
164     groups() const = 0;
165
166   /// Creates the new empty message of this kind
167   virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
168
169   /// Returns the identifier of the kind of a message
170   virtual const Events_ID messageId() = 0;
171
172   /// Appends to this message the given one.
173   virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
174 };
175
176 /// Message that order changed (used for Object Browser update)
177 class MODELAPI_EXPORT ModelAPI_OrderUpdatedMessage : public Events_Message
178 {
179 protected:
180   /// Creates a message:
181   ModelAPI_OrderUpdatedMessage(const Events_ID theID, const void* theSender = 0);
182   /// The virtual destructor
183   virtual ~ModelAPI_OrderUpdatedMessage();
184
185 public:
186   /// Returns the document that has been updated
187   virtual std::shared_ptr<ModelAPI_Feature> reordered() = 0;
188
189   /// Returns the identifier of the kind of a message
190   virtual const Events_ID messageId() = 0;
191 };
192
193 /// Allows to create ModelAPI messages
194 class MODELAPI_EXPORT ModelAPI_EventCreator
195 {
196 public:
197   virtual ~ModelAPI_EventCreator() {}
198
199   /// creates created, updated or moved messages and sends to the loop
200   virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
201                            const bool isGroupped = true) const = 0;
202   /// creates created, updated or moved messages with the objects collection and sends to the loop
203   virtual void sendUpdated(const std::list<ObjectPtr>& theObjects, const Events_ID& theEvent,
204     const bool isGroupped = true) const = 0;
205   /// creates deleted message and sends to the loop
206   virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
207                            const std::string& theGroup) const = 0;
208   /// creates reordered message and sends to the loop
209   virtual void sendReordered(const std::shared_ptr<ModelAPI_Feature>& theReordered) const = 0;
210
211   /// returns the creator instance
212   static const ModelAPI_EventCreator* get();
213
214   /// sets the creator instance
215   static void set(const ModelAPI_EventCreator* theCreator);
216 };
217
218 /// Contains the state information about the feature: is it enabled or disabled.
219 class ModelAPI_FeatureStateMessage : public Events_Message
220 {
221 public:
222   /// Creates an empty message
223   MODELAPI_EXPORT ModelAPI_FeatureStateMessage(const Events_ID theID, const void* theSender = 0);
224   /// The virtual destructor
225   MODELAPI_EXPORT virtual ~ModelAPI_FeatureStateMessage();
226
227   /// Returns the feature this message is related to
228   MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> feature() const;
229   /// Stores the feature this message is related to
230   MODELAPI_EXPORT void setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature);
231   // For response
232   /// Returns true if feature has specific state
233   MODELAPI_EXPORT bool hasState(const std::string& theFeatureId) const;
234   /// Returns true if feature is enabled
235   MODELAPI_EXPORT bool state(const  std::string& theFeatureId, bool theDefault = false) const;
236   /// Stores the feature state
237   MODELAPI_EXPORT void setState(const std::string& theFeatureId, bool theValue);
238   /// Returns all feature IDs with states
239   MODELAPI_EXPORT std::list<std::string> features() const;
240
241  private:
242   /// For Request
243   std::shared_ptr<ModelAPI_Feature> myCurrentFeature;
244   /// For response
245   std::map<std::string, bool> myFeatureState;
246 };
247
248 /// Message that document (Part, PartSet) was created
249 class ModelAPI_DocumentCreatedMessage : public Events_Message
250 {
251   DocumentPtr myDocument;
252
253  public:
254   /// Creates an empty message
255   MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0);
256   /// The virtual destructor
257   MODELAPI_EXPORT virtual ~ModelAPI_DocumentCreatedMessage();
258   /// Static. Returns EventID of the message.
259   MODELAPI_EXPORT static Events_ID eventId()
260   {
261     static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated");
262     return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID);
263   }
264
265   /// Returns a document stored in the message
266   MODELAPI_EXPORT DocumentPtr document() const;
267   /// Sets a document to the message
268   MODELAPI_EXPORT void setDocument(DocumentPtr theDocument);
269 };
270
271 /// Message that attribute text should be evaluated in the attribute value
272 class ModelAPI_AttributeEvalMessage : public Events_Message
273 {
274   AttributePtr myAttribute;
275
276  public:
277   /// Static. Returns EventID of the message.
278   MODELAPI_EXPORT static Events_ID& eventId()
279   {
280     static const char * MY_ATTRIBUTE_EVALUATION_EVENT_ID("AttributeEvaluationRequest");
281     static Events_ID anId = Events_Loop::eventByName(MY_ATTRIBUTE_EVALUATION_EVENT_ID);
282     return anId;
283   }
284
285   /// Useful method that creates and sends the AttributeEvalMessage event
286   MODELAPI_EXPORT static void send(AttributePtr theAttribute, const void* theSender)
287   {
288     std::shared_ptr<ModelAPI_AttributeEvalMessage> aMessage =
289       std::shared_ptr<ModelAPI_AttributeEvalMessage>(
290       new ModelAPI_AttributeEvalMessage(eventId(), theSender));
291     aMessage->setAttribute(theAttribute);
292     Events_Loop::loop()->send(aMessage);
293   }
294
295   /// Creates an empty message
296   MODELAPI_EXPORT ModelAPI_AttributeEvalMessage(const Events_ID theID, const void* theSender = 0);
297   /// The virtual destructor
298   MODELAPI_EXPORT virtual ~ModelAPI_AttributeEvalMessage();
299
300   /// Returns a document stored in the message
301   MODELAPI_EXPORT AttributePtr attribute() const;
302   /// Sets an attribute to the message
303   MODELAPI_EXPORT void setAttribute(AttributePtr theAttribute);
304 };
305
306 /// Message that parameter feature expression should be evaluated: value and error producing
307 class ModelAPI_ParameterEvalMessage : public Events_Message
308 {
309   FeaturePtr myParam; ///< parameters that should be evaluated
310   bool myIsProcessed; ///< true if results were set
311   /// result of processing, list of parameters in expression found
312   std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
313   double myResult; ///< result of processing, the computed value of the expression
314   std::string myError; ///< error of processing, empty if there is no error
315
316  public:
317   /// Static. Returns EventID of the message.
318   MODELAPI_EXPORT static Events_ID& eventId()
319   {
320     static const char * MY_PARAMETER_EVALUATION_EVENT_ID("ParameterEvaluationRequest");
321     static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
322     return anId;
323   }
324
325   /// Useful method that creates and sends the event.
326   /// Returns the message, processed, with the resulting fields filled.
327   MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ParameterEvalMessage>
328     send(FeaturePtr theParameter, const void* theSender)
329   {
330     std::shared_ptr<ModelAPI_ParameterEvalMessage> aMessage =
331       std::shared_ptr<ModelAPI_ParameterEvalMessage>(
332       new ModelAPI_ParameterEvalMessage(eventId(), theSender));
333     aMessage->setParameter(theParameter);
334     Events_Loop::loop()->send(aMessage);
335     return aMessage;
336   }
337
338   /// Creates an empty message
339   MODELAPI_EXPORT ModelAPI_ParameterEvalMessage(const Events_ID theID, const void* theSender = 0);
340   /// The virtual destructor
341   MODELAPI_EXPORT virtual ~ModelAPI_ParameterEvalMessage();
342
343   /// Returns a parameter stored in the message
344   MODELAPI_EXPORT FeaturePtr parameter() const;
345   /// Sets a parameter to the message
346   MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
347   /// Sets the results of processing
348   MODELAPI_EXPORT void setResults(
349     const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
350     const double theResult, const std::string& theError);
351   /// Returns true if the expression is processed
352   MODELAPI_EXPORT bool isProcessed();
353   /// Returns the results of processing: list of parameters found in the expression
354   MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
355   /// Returns the expression result
356   MODELAPI_EXPORT const double& result() const;
357   /// Returns the interpreter error (empty if no error)
358   MODELAPI_EXPORT const std::string& error() const;
359 };
360
361 class ModelAPI_ImportParametersMessage : public Events_Message
362 {
363   std::string myFilename; ///< filename where where parameters are stored
364   std::string myError; ///< error of processing, empty if there is no error
365
366 public:
367   /// Static. Returns EventID of the message.
368   MODELAPI_EXPORT static Events_ID& eventId()
369   {
370     static const char* MY_PARAMETER_EVALUATION_EVENT_ID("ImportParametersMessage");
371     static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
372     return anId;
373   }
374
375   /// Useful method that creates and sends the event.
376   /// Returns the message, processed, with the resulting fields filled.
377   MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ImportParametersMessage>
378     send(std::string theParameter, const void* theSender)
379   {
380     std::shared_ptr<ModelAPI_ImportParametersMessage> aMessage =
381       std::shared_ptr<ModelAPI_ImportParametersMessage>(
382         new ModelAPI_ImportParametersMessage(eventId(), theSender));
383     aMessage->setFilename(theParameter);
384     Events_Loop::loop()->send(aMessage);
385     return aMessage;
386   }
387
388   /// Creates an empty message
389   MODELAPI_EXPORT ModelAPI_ImportParametersMessage(const Events_ID theID,
390                                                    const void* theSender = 0);
391   /// The virtual destructor
392   MODELAPI_EXPORT virtual ~ModelAPI_ImportParametersMessage();
393
394   /// Returns a filename stored in the message
395   MODELAPI_EXPORT std::string filename() const;
396   /// Sets a filename to the message
397   MODELAPI_EXPORT void setFilename(std::string theFilename);
398 };
399
400 class ModelAPI_BuildEvalMessage : public Events_Message
401 {
402   FeaturePtr myParam; ///< parameters that should be evaluated
403   bool myIsProcessed; ///< true if results were set
404   std::string myError; ///< error of processing, empty if there is no error
405   /// result of processing, list of parameters in expression found
406   std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
407
408  public:
409   /// Static. Returns EventID of the message.
410   MODELAPI_EXPORT static Events_ID& eventId()
411   {
412     static const char * MY_BUILD_EVALUATION_EVENT_ID("BuildEvaluationRequest");
413     static Events_ID anId = Events_Loop::eventByName(MY_BUILD_EVALUATION_EVENT_ID);
414     return anId;
415   }
416
417   /// Useful method that creates and sends the event.
418   /// Returns the message, processed, with the resulting fields filled.
419   MODELAPI_EXPORT static std::shared_ptr<ModelAPI_BuildEvalMessage>
420     send(FeaturePtr theParameter, const void* theSender)
421   {
422     std::shared_ptr<ModelAPI_BuildEvalMessage> aMessage =
423           std::shared_ptr<ModelAPI_BuildEvalMessage>(
424                 new ModelAPI_BuildEvalMessage(eventId(), theSender));
425     aMessage->setParameter(theParameter);
426     Events_Loop::loop()->send(aMessage);
427     return aMessage;
428   }
429
430   /// Creates an empty message
431   MODELAPI_EXPORT ModelAPI_BuildEvalMessage(const Events_ID theID, const void* theSender = 0);
432   /// The virtual destructor
433   MODELAPI_EXPORT virtual ~ModelAPI_BuildEvalMessage();
434
435   /// Returns a parameter stored in the message
436   MODELAPI_EXPORT FeaturePtr parameter() const;
437   /// Sets a parameter to the message
438   MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
439   /// Sets the results of processing
440   MODELAPI_EXPORT void setResults(
441                        const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
442                        const std::string& theError);
443   /// Returns the results of processing: list of parameters found in the expression
444   MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
445   /// Returns true if the expression is processed
446   MODELAPI_EXPORT bool isProcessed();
447
448   /// Returns the interpreter error (empty if no error)
449   MODELAPI_EXPORT const std::string& error() const;
450 };
451
452 /// Message to ask compute the positions of parameters in the expression
453 class ModelAPI_ComputePositionsMessage : public Events_Message
454 {
455   std::wstring myExpression; ///< the expression string
456   std::wstring myParamName; ///< name of the parameter to be searched
457   std::list<std::pair<int, int> > myPositions; ///< computation result: start-end position indices
458
459 public:
460   /// Static. Returns EventID of the message.
461   MODELAPI_EXPORT static Events_ID& eventId()
462   {
463     static const char * MY_COMPUTE_POSITIOND_EVENT_ID("ComputePositionsRequest");
464     static Events_ID anId = Events_Loop::eventByName(MY_COMPUTE_POSITIOND_EVENT_ID);
465     return anId;
466   }
467
468   /// Useful method that creates and sends the AttributeEvalMessage event
469   /// Returns the message, processed, with the resulting fields filled
470   MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ComputePositionsMessage>
471     send(const std::wstring& theExpression, const std::wstring& theParameter, const void* theSender)
472   {
473     std::shared_ptr<ModelAPI_ComputePositionsMessage> aMessage =
474       std::shared_ptr<ModelAPI_ComputePositionsMessage>(
475       new ModelAPI_ComputePositionsMessage(eventId(), theSender));
476     aMessage->set(theExpression, theParameter);
477     Events_Loop::loop()->send(aMessage);
478     return aMessage;
479   }
480
481   /// Creates an empty message
482   MODELAPI_EXPORT ModelAPI_ComputePositionsMessage(
483     const Events_ID theID, const void* theSender = 0);
484   /// The virtual destructor
485   MODELAPI_EXPORT virtual ~ModelAPI_ComputePositionsMessage();
486
487   /// Returns an expression stored in the message
488   MODELAPI_EXPORT const std::wstring& expression() const;
489   /// Returns a parameter name stored in the message
490   MODELAPI_EXPORT const std::wstring& parameter() const;
491   /// Sets an expression and parameter needed for computation
492   MODELAPI_EXPORT void set(const std::wstring& theExpression, const std::wstring& theParameter);
493   /// Sets the results of processing
494   MODELAPI_EXPORT void setPositions(const std::list<std::pair<int, int> >& thePositions);
495   /// Returns the results of processing: position start and end indices
496   MODELAPI_EXPORT const std::list<std::pair<int, int> >& positions() const;
497 };
498
499 /// Message that the object is renamed
500 class ModelAPI_ObjectRenamedMessage : public Events_Message
501 {
502   ObjectPtr myObject;
503   std::wstring myOldName;
504   std::wstring myNewName;
505
506  public:
507   /// Static. Returns EventID of the message.
508   MODELAPI_EXPORT static Events_ID& eventId()
509   {
510     static const char * MY_OBJECT_RENAMED_EVENT_ID("ObjectRenamed");
511     static Events_ID anId = Events_Loop::eventByName(MY_OBJECT_RENAMED_EVENT_ID);
512     return anId;
513   }
514
515   /// Useful method that creates and sends the AttributeEvalMessage event
516   MODELAPI_EXPORT static void send(ObjectPtr theObject,
517                                    const std::wstring& theOldName,
518                                    const std::wstring& theNewName,
519                                    const void* theSender);
520
521   /// Creates an empty message
522   MODELAPI_EXPORT ModelAPI_ObjectRenamedMessage(const Events_ID theID, const void* theSender = 0);
523   /// The virtual destructor
524   MODELAPI_EXPORT virtual ~ModelAPI_ObjectRenamedMessage();
525
526   /// Returns an object
527   MODELAPI_EXPORT ObjectPtr object() const;
528   /// Sets an object
529   MODELAPI_EXPORT void setObject(ObjectPtr theObject);
530   /// Returns an old name
531   MODELAPI_EXPORT std::wstring oldName() const;
532   /// Sets an old name
533   MODELAPI_EXPORT void setOldName(const std::wstring& theOldName);
534   /// Returns a new name
535   MODELAPI_EXPORT std::wstring newName() const;
536   /// Sets a new name
537   MODELAPI_EXPORT void setNewName(const std::wstring& theNewName);
538 };
539
540 /// Message that the parameter should be replaced with its value
541 class ModelAPI_ReplaceParameterMessage : public Events_Message
542 {
543   ObjectPtr myObject;
544
545  public:
546   /// Static. Returns EventID of the message.
547   MODELAPI_EXPORT static Events_ID& eventId()
548   {
549     static const char * MY_EVENT_ID("ReplaceParameter");
550     static Events_ID anId = Events_Loop::eventByName(MY_EVENT_ID);
551     return anId;
552   }
553
554   /// Useful method that creates and sends the AttributeEvalMessage event
555   MODELAPI_EXPORT static void send(ObjectPtr theObject,
556                                    const void* theSender);
557
558   /// Creates an empty message
559   MODELAPI_EXPORT
560     ModelAPI_ReplaceParameterMessage(const Events_ID theID, const void* theSender = 0);
561   /// The virtual destructor
562   MODELAPI_EXPORT virtual ~ModelAPI_ReplaceParameterMessage();
563
564   /// Returns an object
565   MODELAPI_EXPORT ObjectPtr object() const;
566   /// Sets an object
567   MODELAPI_EXPORT void setObject(ObjectPtr theObject);
568 };
569
570 /// Message that sends the sketch solver and sketcher GUI processes to show in the property panel
571 class ModelAPI_SolverFailedMessage : public Events_Message
572 {
573 public:
574   /// Creates an message
575   MODELAPI_EXPORT ModelAPI_SolverFailedMessage(const Events_ID theID, const void* theSender = 0);
576   /// Default destructor
577   MODELAPI_EXPORT virtual ~ModelAPI_SolverFailedMessage();
578
579   /// Sets list of conflicting constraints
580   MODELAPI_EXPORT void setObjects(const std::set<ObjectPtr>& theObjects);
581   /// Returns list of conflicting constraints
582   MODELAPI_EXPORT const std::set<ObjectPtr>& objects() const;
583
584   /// Sets degrees of freedom
585   void dof(const int theDOF) { myDOF = theDOF; }
586   /// Returns degrees of freedom
587   const int& dof() const { return myDOF; }
588
589 private:
590   std::set<ObjectPtr> myObjects;
591   int myDOF;
592 };
593
594 /// Message sent when feature or attribute has been moved.
595 /// Stores the moving object/attribute, original and new positions of mouse.
596 class ModelAPI_ObjectMovedMessage : public Events_Message
597 {
598   ObjectPtr myMovedObject;
599   AttributePtr myMovedAttribute;
600   int myMovedPointIndex;
601
602   std::shared_ptr<GeomAPI_Pnt2d> myOriginalPosition;
603   std::shared_ptr<GeomAPI_Pnt2d> myCurrentPosition;
604
605 public:
606   MODELAPI_EXPORT ModelAPI_ObjectMovedMessage(const void* theSender = 0);
607
608   /// Set object which is being moved (if the message already contains attribute it will be cleared)
609   MODELAPI_EXPORT void setMovedObject(const ObjectPtr& theMovedObject);
610   /// Set attribute which is being moved (if the message already contains object it will be cleared)
611   /// \param[in] theMovedAttribute moved attribute
612   /// \param[in] thePointIndex     index of the point if the moved attribute is an array of points
613   MODELAPI_EXPORT void setMovedAttribute(const AttributePtr& theMovedAttribute,
614                                          const int thePointIndex = -1);
615
616   /// Return moved object
617   ObjectPtr movedObject() const
618   { return myMovedObject; }
619   /// Return moved attribute
620   AttributePtr movedAttribute() const
621   { return myMovedAttribute; }
622   /// Return index of the moved point
623   int movedPointIndex() const
624   { return myMovedPointIndex; }
625
626   /// Set original mouse position
627   MODELAPI_EXPORT void setOriginalPosition(double theX, double theY);
628   /// Set original mouse position
629   MODELAPI_EXPORT void setOriginalPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
630   /// Return original mouse position
631   const std::shared_ptr<GeomAPI_Pnt2d>& originalPosition() const
632   { return myOriginalPosition; }
633
634   /// Set current mouse position
635   MODELAPI_EXPORT void setCurrentPosition(double theX, double theY);
636   /// Set current mouse position
637   MODELAPI_EXPORT void setCurrentPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
638   /// Return current mouse position
639   const std::shared_ptr<GeomAPI_Pnt2d>& currentPosition() const
640   { return myCurrentPosition; }
641 };
642
643 /// Message that sends the failed vertices of 1D-fillet to highlight them in 3D viewer
644 class ModelAPI_ShapesFailedMessage : public Events_Message
645 {
646 public:
647   /// Creates an message
648   MODELAPI_EXPORT ModelAPI_ShapesFailedMessage(const Events_ID theID, const void* theSender = 0);
649   /// Default destructor
650   MODELAPI_EXPORT virtual ~ModelAPI_ShapesFailedMessage();
651   /// Static. Returns EventID of the message.
652   MODELAPI_EXPORT static Events_ID eventId()
653   {
654     return Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED);
655   }
656
657   /// Sets list of failed vertices
658   MODELAPI_EXPORT void setShapes(const std::list< std::shared_ptr<GeomAPI_Shape> >& theVertices);
659   /// Returns list of failed vertices
660   MODELAPI_EXPORT const std::list< std::shared_ptr<GeomAPI_Shape> >& shapes() const;
661
662 private:
663   std::list< std::shared_ptr<GeomAPI_Shape> > myShapes;
664 };
665
666 ///Message that sends the constraints to check or remove
667 class ModelAPI_CheckConstraintsMessage : public Events_Message
668 {
669 public:
670   /// Creates an empty message
671   MODELAPI_EXPORT ModelAPI_CheckConstraintsMessage(
672     const Events_ID theID, const void* theSender = 0);
673   /// The virtual destructor
674   MODELAPI_EXPORT virtual ~ModelAPI_CheckConstraintsMessage();
675
676   ///Get list of constrains
677   MODELAPI_EXPORT const std::set<ObjectPtr>& constraints() const;
678
679   ///Set list of constrains
680   MODELAPI_EXPORT void setConstraints(const std::set<ObjectPtr>& theConstraints);
681
682 private:
683   std::set<ObjectPtr> myConstraints;
684 };
685
686
687 /// Message that sends the features which license is checked and valid
688 class ModelAPI_FeaturesLicenseValidMessage : public Events_Message
689 {
690 public:
691   /// Creates an message
692   MODELAPI_EXPORT
693   ModelAPI_FeaturesLicenseValidMessage(const Events_ID theID, const void* theSender = 0);
694   /// Default destructor
695   MODELAPI_EXPORT virtual ~ModelAPI_FeaturesLicenseValidMessage();
696   /// Static. Returns EventID of the message.
697   MODELAPI_EXPORT static Events_ID eventId()
698   {
699     return Events_Loop::eventByName(EVENT_FEATURE_LICENSE_VALID);
700   }
701
702   /// Sets list of features with valid license
703   MODELAPI_EXPORT void setFeatures(const std::set<std::string>& theFeatures);
704   /// Returns list of features with valid license
705   MODELAPI_EXPORT const std::set<std::string>& features() const;
706
707 private:
708   std::set<std::string> myFeatures;
709 };
710
711 #endif