]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_Events.h
Salome HOME
Merge branch 'cadbld'
[modules/shaper.git] / src / ModelAPI / ModelAPI_Events.h
1 // Copyright (C) 2014-2021  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 /// Event ID that license of specified features is checked and valid
126 MAYBE_UNUSED static const char * EVENT_FEATURE_LICENSE_VALID = "FeaturesLicenseValid";
127
128 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
129 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
130 {
131  protected:
132   /// Creates an empty message
133   ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0);
134   /// The virtual destructor
135   virtual ~ModelAPI_ObjectUpdatedMessage();
136
137  public:
138   /// Returns the feature that has been updated
139   virtual const std::set<ObjectPtr>& objects() const = 0;
140
141   //! Creates a new empty group (to store it in the loop before flush)
142   virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
143
144   //! Allows to join the given message with the current one
145   virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
146 };
147
148 /// Message that feature was deleted (used for Object Browser update)
149 class MODELAPI_EXPORT ModelAPI_ObjectDeletedMessage : public Events_MessageGroup
150 {
151 protected:
152   /// Creates an empty message
153   ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0);
154   /// The virtual destructor
155   virtual ~ModelAPI_ObjectDeletedMessage();
156
157 public:
158   /// Returns the groups where the objects were deleted
159   virtual const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> >&
160     groups() const = 0;
161
162   /// Creates the new empty message of this kind
163   virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
164
165   /// Returns the identifier of the kind of a message
166   virtual const Events_ID messageId() = 0;
167
168   /// Appends to this message the given one.
169   virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
170 };
171
172 /// Message that order changed (used for Object Browser update)
173 class MODELAPI_EXPORT ModelAPI_OrderUpdatedMessage : public Events_Message
174 {
175 protected:
176   /// Creates a message:
177   ModelAPI_OrderUpdatedMessage(const Events_ID theID, const void* theSender = 0);
178   /// The virtual destructor
179   virtual ~ModelAPI_OrderUpdatedMessage();
180
181 public:
182   /// Returns the document that has been updated
183   virtual std::shared_ptr<ModelAPI_Feature> reordered() = 0;
184
185   /// Returns the identifier of the kind of a message
186   virtual const Events_ID messageId() = 0;
187 };
188
189 /// Allows to create ModelAPI messages
190 class MODELAPI_EXPORT ModelAPI_EventCreator
191 {
192 public:
193   virtual ~ModelAPI_EventCreator() {}
194
195   /// creates created, updated or moved messages and sends to the loop
196   virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
197                            const bool isGroupped = true) const = 0;
198   /// creates created, updated or moved messages with the objects collection and sends to the loop
199   virtual void sendUpdated(const std::list<ObjectPtr>& theObjects, const Events_ID& theEvent,
200     const bool isGroupped = true) const = 0;
201   /// creates deleted message and sends to the loop
202   virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
203                            const std::string& theGroup) const = 0;
204   /// creates reordered message and sends to the loop
205   virtual void sendReordered(const std::shared_ptr<ModelAPI_Feature>& theReordered) const = 0;
206
207   /// returns the creator instance
208   static const ModelAPI_EventCreator* get();
209
210   /// sets the creator instance
211   static void set(const ModelAPI_EventCreator* theCreator);
212 };
213
214 /// Contains the state information about the feature: is it enabled or disabled.
215 class ModelAPI_FeatureStateMessage : public Events_Message
216 {
217 public:
218   /// Creates an empty message
219   MODELAPI_EXPORT ModelAPI_FeatureStateMessage(const Events_ID theID, const void* theSender = 0);
220   /// The virtual destructor
221   MODELAPI_EXPORT virtual ~ModelAPI_FeatureStateMessage();
222
223   /// Returns the feature this message is related to
224   MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> feature() const;
225   /// Stores the feature this message is related to
226   MODELAPI_EXPORT void setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature);
227   // For response
228   /// Returns true if feature has specific state
229   MODELAPI_EXPORT bool hasState(const std::string& theFeatureId) const;
230   /// Returns true if feature is enabled
231   MODELAPI_EXPORT bool state(const  std::string& theFeatureId, bool theDefault = false) const;
232   /// Stores the feature state
233   MODELAPI_EXPORT void setState(const std::string& theFeatureId, bool theValue);
234   /// Returns all feature IDs with states
235   MODELAPI_EXPORT std::list<std::string> features() const;
236
237  private:
238   /// For Request
239   std::shared_ptr<ModelAPI_Feature> myCurrentFeature;
240   /// For response
241   std::map<std::string, bool> myFeatureState;
242 };
243
244 /// Message that document (Part, PartSet) was created
245 class ModelAPI_DocumentCreatedMessage : public Events_Message
246 {
247   DocumentPtr myDocument;
248
249  public:
250   /// Creates an empty message
251   MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0);
252   /// The virtual destructor
253   MODELAPI_EXPORT virtual ~ModelAPI_DocumentCreatedMessage();
254   /// Static. Returns EventID of the message.
255   MODELAPI_EXPORT static Events_ID eventId()
256   {
257     static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated");
258     return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID);
259   }
260
261   /// Returns a document stored in the message
262   MODELAPI_EXPORT DocumentPtr document() const;
263   /// Sets a document to the message
264   MODELAPI_EXPORT void setDocument(DocumentPtr theDocument);
265 };
266
267 /// Message that attribute text should be evaluated in the attribute value
268 class ModelAPI_AttributeEvalMessage : public Events_Message
269 {
270   AttributePtr myAttribute;
271
272  public:
273   /// Static. Returns EventID of the message.
274   MODELAPI_EXPORT static Events_ID& eventId()
275   {
276     static const char * MY_ATTRIBUTE_EVALUATION_EVENT_ID("AttributeEvaluationRequest");
277     static Events_ID anId = Events_Loop::eventByName(MY_ATTRIBUTE_EVALUATION_EVENT_ID);
278     return anId;
279   }
280
281   /// Useful method that creates and sends the AttributeEvalMessage event
282   MODELAPI_EXPORT static void send(AttributePtr theAttribute, const void* theSender)
283   {
284     std::shared_ptr<ModelAPI_AttributeEvalMessage> aMessage =
285       std::shared_ptr<ModelAPI_AttributeEvalMessage>(
286       new ModelAPI_AttributeEvalMessage(eventId(), theSender));
287     aMessage->setAttribute(theAttribute);
288     Events_Loop::loop()->send(aMessage);
289   }
290
291   /// Creates an empty message
292   MODELAPI_EXPORT ModelAPI_AttributeEvalMessage(const Events_ID theID, const void* theSender = 0);
293   /// The virtual destructor
294   MODELAPI_EXPORT virtual ~ModelAPI_AttributeEvalMessage();
295
296   /// Returns a document stored in the message
297   MODELAPI_EXPORT AttributePtr attribute() const;
298   /// Sets an attribute to the message
299   MODELAPI_EXPORT void setAttribute(AttributePtr theAttribute);
300 };
301
302 /// Message that parameter feature expression should be evaluated: value and error producing
303 class ModelAPI_ParameterEvalMessage : public Events_Message
304 {
305   FeaturePtr myParam; ///< parameters that should be evaluated
306   bool myIsProcessed; ///< true if results were set
307   /// result of processing, list of parameters in expression found
308   std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
309   double myResult; ///< result of processing, the computed value of the expression
310   std::string myError; ///< error of processing, empty if there is no error
311
312  public:
313   /// Static. Returns EventID of the message.
314   MODELAPI_EXPORT static Events_ID& eventId()
315   {
316     static const char * MY_PARAMETER_EVALUATION_EVENT_ID("ParameterEvaluationRequest");
317     static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
318     return anId;
319   }
320
321   /// Useful method that creates and sends the event.
322   /// Returns the message, processed, with the resulting fields filled.
323   MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ParameterEvalMessage>
324     send(FeaturePtr theParameter, const void* theSender)
325   {
326     std::shared_ptr<ModelAPI_ParameterEvalMessage> aMessage =
327       std::shared_ptr<ModelAPI_ParameterEvalMessage>(
328       new ModelAPI_ParameterEvalMessage(eventId(), theSender));
329     aMessage->setParameter(theParameter);
330     Events_Loop::loop()->send(aMessage);
331     return aMessage;
332   }
333
334   /// Creates an empty message
335   MODELAPI_EXPORT ModelAPI_ParameterEvalMessage(const Events_ID theID, const void* theSender = 0);
336   /// The virtual destructor
337   MODELAPI_EXPORT virtual ~ModelAPI_ParameterEvalMessage();
338
339   /// Returns a parameter stored in the message
340   MODELAPI_EXPORT FeaturePtr parameter() const;
341   /// Sets a parameter to the message
342   MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
343   /// Sets the results of processing
344   MODELAPI_EXPORT void setResults(
345     const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
346     const double theResult, const std::string& theError);
347   /// Returns true if the expression is processed
348   MODELAPI_EXPORT bool isProcessed();
349   /// Returns the results of processing: list of parameters found in the expression
350   MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
351   /// Returns the expression result
352   MODELAPI_EXPORT const double& result() const;
353   /// Returns the interpreter error (empty if no error)
354   MODELAPI_EXPORT const std::string& error() const;
355 };
356
357 class ModelAPI_ImportParametersMessage : public Events_Message
358 {
359   std::string myFilename; ///< filename where where parameters are stored
360   std::string myError; ///< error of processing, empty if there is no error
361
362 public:
363   /// Static. Returns EventID of the message.
364   MODELAPI_EXPORT static Events_ID& eventId()
365   {
366     static const char* MY_PARAMETER_EVALUATION_EVENT_ID("ImportParametersMessage");
367     static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
368     return anId;
369   }
370
371   /// Useful method that creates and sends the event.
372   /// Returns the message, processed, with the resulting fields filled.
373   MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ImportParametersMessage>
374     send(std::string theParameter, const void* theSender)
375   {
376     std::shared_ptr<ModelAPI_ImportParametersMessage> aMessage =
377       std::shared_ptr<ModelAPI_ImportParametersMessage>(
378         new ModelAPI_ImportParametersMessage(eventId(), theSender));
379     aMessage->setFilename(theParameter);
380     Events_Loop::loop()->send(aMessage);
381     return aMessage;
382   }
383
384   /// Creates an empty message
385   MODELAPI_EXPORT ModelAPI_ImportParametersMessage(const Events_ID theID,
386                                                    const void* theSender = 0);
387   /// The virtual destructor
388   MODELAPI_EXPORT virtual ~ModelAPI_ImportParametersMessage();
389
390   /// Returns a filename stored in the message
391   MODELAPI_EXPORT std::string filename() const;
392   /// Sets a filename to the message
393   MODELAPI_EXPORT void setFilename(std::string theFilename);
394 };
395
396 class ModelAPI_BuildEvalMessage : public Events_Message
397 {
398   FeaturePtr myParam; ///< parameters that should be evaluated
399   bool myIsProcessed; ///< true if results were set
400   std::string myError; ///< error of processing, empty if there is no error
401   /// result of processing, list of parameters in expression found
402   std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
403
404  public:
405   /// Static. Returns EventID of the message.
406   MODELAPI_EXPORT static Events_ID& eventId()
407   {
408     static const char * MY_BUILD_EVALUATION_EVENT_ID("BuildEvaluationRequest");
409     static Events_ID anId = Events_Loop::eventByName(MY_BUILD_EVALUATION_EVENT_ID);
410     return anId;
411   }
412
413   /// Useful method that creates and sends the event.
414   /// Returns the message, processed, with the resulting fields filled.
415   MODELAPI_EXPORT static std::shared_ptr<ModelAPI_BuildEvalMessage>
416     send(FeaturePtr theParameter, const void* theSender)
417   {
418     std::shared_ptr<ModelAPI_BuildEvalMessage> aMessage =
419           std::shared_ptr<ModelAPI_BuildEvalMessage>(
420                 new ModelAPI_BuildEvalMessage(eventId(), theSender));
421     aMessage->setParameter(theParameter);
422     Events_Loop::loop()->send(aMessage);
423     return aMessage;
424   }
425
426   /// Creates an empty message
427   MODELAPI_EXPORT ModelAPI_BuildEvalMessage(const Events_ID theID, const void* theSender = 0);
428   /// The virtual destructor
429   MODELAPI_EXPORT virtual ~ModelAPI_BuildEvalMessage();
430
431   /// Returns a parameter stored in the message
432   MODELAPI_EXPORT FeaturePtr parameter() const;
433   /// Sets a parameter to the message
434   MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
435   /// Sets the results of processing
436   MODELAPI_EXPORT void setResults(
437                        const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
438                        const std::string& theError);
439   /// Returns the results of processing: list of parameters found in the expression
440   MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
441   /// Returns true if the expression is processed
442   MODELAPI_EXPORT bool isProcessed();
443
444   /// Returns the interpreter error (empty if no error)
445   MODELAPI_EXPORT const std::string& error() const;
446 };
447
448 /// Message to ask compute the positions of parameters in the expression
449 class ModelAPI_ComputePositionsMessage : public Events_Message
450 {
451   std::wstring myExpression; ///< the expression string
452   std::wstring myParamName; ///< name of the parameter to be searched
453   std::list<std::pair<int, int> > myPositions; ///< computation result: start-end position indices
454
455 public:
456   /// Static. Returns EventID of the message.
457   MODELAPI_EXPORT static Events_ID& eventId()
458   {
459     static const char * MY_COMPUTE_POSITIOND_EVENT_ID("ComputePositionsRequest");
460     static Events_ID anId = Events_Loop::eventByName(MY_COMPUTE_POSITIOND_EVENT_ID);
461     return anId;
462   }
463
464   /// Useful method that creates and sends the AttributeEvalMessage event
465   /// Returns the message, processed, with the resulting fields filled
466   MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ComputePositionsMessage>
467     send(const std::wstring& theExpression, const std::wstring& theParameter, const void* theSender)
468   {
469     std::shared_ptr<ModelAPI_ComputePositionsMessage> aMessage =
470       std::shared_ptr<ModelAPI_ComputePositionsMessage>(
471       new ModelAPI_ComputePositionsMessage(eventId(), theSender));
472     aMessage->set(theExpression, theParameter);
473     Events_Loop::loop()->send(aMessage);
474     return aMessage;
475   }
476
477   /// Creates an empty message
478   MODELAPI_EXPORT ModelAPI_ComputePositionsMessage(
479     const Events_ID theID, const void* theSender = 0);
480   /// The virtual destructor
481   MODELAPI_EXPORT virtual ~ModelAPI_ComputePositionsMessage();
482
483   /// Returns an expression stored in the message
484   MODELAPI_EXPORT const std::wstring& expression() const;
485   /// Returns a parameter name stored in the message
486   MODELAPI_EXPORT const std::wstring& parameter() const;
487   /// Sets an expression and parameter needed for computation
488   MODELAPI_EXPORT void set(const std::wstring& theExpression, const std::wstring& theParameter);
489   /// Sets the results of processing
490   MODELAPI_EXPORT void setPositions(const std::list<std::pair<int, int> >& thePositions);
491   /// Returns the results of processing: position start and end indices
492   MODELAPI_EXPORT const std::list<std::pair<int, int> >& positions() const;
493 };
494
495 /// Message that the object is renamed
496 class ModelAPI_ObjectRenamedMessage : public Events_Message
497 {
498   ObjectPtr myObject;
499   std::wstring myOldName;
500   std::wstring myNewName;
501
502  public:
503   /// Static. Returns EventID of the message.
504   MODELAPI_EXPORT static Events_ID& eventId()
505   {
506     static const char * MY_OBJECT_RENAMED_EVENT_ID("ObjectRenamed");
507     static Events_ID anId = Events_Loop::eventByName(MY_OBJECT_RENAMED_EVENT_ID);
508     return anId;
509   }
510
511   /// Useful method that creates and sends the AttributeEvalMessage event
512   MODELAPI_EXPORT static void send(ObjectPtr theObject,
513                                    const std::wstring& theOldName,
514                                    const std::wstring& theNewName,
515                                    const void* theSender);
516
517   /// Creates an empty message
518   MODELAPI_EXPORT ModelAPI_ObjectRenamedMessage(const Events_ID theID, const void* theSender = 0);
519   /// The virtual destructor
520   MODELAPI_EXPORT virtual ~ModelAPI_ObjectRenamedMessage();
521
522   /// Returns an object
523   MODELAPI_EXPORT ObjectPtr object() const;
524   /// Sets an object
525   MODELAPI_EXPORT void setObject(ObjectPtr theObject);
526   /// Returns an old name
527   MODELAPI_EXPORT std::wstring oldName() const;
528   /// Sets an old name
529   MODELAPI_EXPORT void setOldName(const std::wstring& theOldName);
530   /// Returns a new name
531   MODELAPI_EXPORT std::wstring newName() const;
532   /// Sets a new name
533   MODELAPI_EXPORT void setNewName(const std::wstring& theNewName);
534 };
535
536 /// Message that the parameter should be replaced with its value
537 class ModelAPI_ReplaceParameterMessage : public Events_Message
538 {
539   ObjectPtr myObject;
540
541  public:
542   /// Static. Returns EventID of the message.
543   MODELAPI_EXPORT static Events_ID& eventId()
544   {
545     static const char * MY_EVENT_ID("ReplaceParameter");
546     static Events_ID anId = Events_Loop::eventByName(MY_EVENT_ID);
547     return anId;
548   }
549
550   /// Useful method that creates and sends the AttributeEvalMessage event
551   MODELAPI_EXPORT static void send(ObjectPtr theObject,
552                                    const void* theSender);
553
554   /// Creates an empty message
555   MODELAPI_EXPORT
556     ModelAPI_ReplaceParameterMessage(const Events_ID theID, const void* theSender = 0);
557   /// The virtual destructor
558   MODELAPI_EXPORT virtual ~ModelAPI_ReplaceParameterMessage();
559
560   /// Returns an object
561   MODELAPI_EXPORT ObjectPtr object() const;
562   /// Sets an object
563   MODELAPI_EXPORT void setObject(ObjectPtr theObject);
564 };
565
566 /// Message that sends the sketch solver and sketcher GUI processes to show in the property panel
567 class ModelAPI_SolverFailedMessage : public Events_Message
568 {
569 public:
570   /// Creates an message
571   MODELAPI_EXPORT ModelAPI_SolverFailedMessage(const Events_ID theID, const void* theSender = 0);
572   /// Default destructor
573   MODELAPI_EXPORT virtual ~ModelAPI_SolverFailedMessage();
574
575   /// Sets list of conflicting constraints
576   MODELAPI_EXPORT void setObjects(const std::set<ObjectPtr>& theObjects);
577   /// Returns list of conflicting constraints
578   MODELAPI_EXPORT const std::set<ObjectPtr>& objects() const;
579
580   /// Sets degrees of freedom
581   void dof(const int theDOF) { myDOF = theDOF; }
582   /// Returns degrees of freedom
583   const int& dof() const { return myDOF; }
584
585 private:
586   std::set<ObjectPtr> myObjects;
587   int myDOF;
588 };
589
590 /// Message sent when feature or attribute has been moved.
591 /// Stores the moving object/attribute, original and new positions of mouse.
592 class ModelAPI_ObjectMovedMessage : public Events_Message
593 {
594   ObjectPtr myMovedObject;
595   AttributePtr myMovedAttribute;
596   int myMovedPointIndex;
597
598   std::shared_ptr<GeomAPI_Pnt2d> myOriginalPosition;
599   std::shared_ptr<GeomAPI_Pnt2d> myCurrentPosition;
600
601 public:
602   MODELAPI_EXPORT ModelAPI_ObjectMovedMessage(const void* theSender = 0);
603
604   /// Set object which is being moved (if the message already contains attribute it will be cleared)
605   MODELAPI_EXPORT void setMovedObject(const ObjectPtr& theMovedObject);
606   /// Set attribute which is being moved (if the message already contains object it will be cleared)
607   /// \param[in] theMovedAttribute moved attribute
608   /// \param[in] thePointIndex     index of the point if the moved attribute is an array of points
609   MODELAPI_EXPORT void setMovedAttribute(const AttributePtr& theMovedAttribute,
610                                          const int thePointIndex = -1);
611
612   /// Return moved object
613   ObjectPtr movedObject() const
614   { return myMovedObject; }
615   /// Return moved attribute
616   AttributePtr movedAttribute() const
617   { return myMovedAttribute; }
618   /// Return index of the moved point
619   int movedPointIndex() const
620   { return myMovedPointIndex; }
621
622   /// Set original mouse position
623   MODELAPI_EXPORT void setOriginalPosition(double theX, double theY);
624   /// Set original mouse position
625   MODELAPI_EXPORT void setOriginalPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
626   /// Return original mouse position
627   const std::shared_ptr<GeomAPI_Pnt2d>& originalPosition() const
628   { return myOriginalPosition; }
629
630   /// Set current mouse position
631   MODELAPI_EXPORT void setCurrentPosition(double theX, double theY);
632   /// Set current mouse position
633   MODELAPI_EXPORT void setCurrentPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
634   /// Return current mouse position
635   const std::shared_ptr<GeomAPI_Pnt2d>& currentPosition() const
636   { return myCurrentPosition; }
637 };
638
639 /// Message that sends the failed vertices of 1D-fillet to highlight them in 3D viewer
640 class ModelAPI_ShapesFailedMessage : public Events_Message
641 {
642 public:
643   /// Creates an message
644   MODELAPI_EXPORT ModelAPI_ShapesFailedMessage(const Events_ID theID, const void* theSender = 0);
645   /// Default destructor
646   MODELAPI_EXPORT virtual ~ModelAPI_ShapesFailedMessage();
647   /// Static. Returns EventID of the message.
648   MODELAPI_EXPORT static Events_ID eventId()
649   {
650     return Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED);
651   }
652
653   /// Sets list of failed vertices
654   MODELAPI_EXPORT void setShapes(const std::list< std::shared_ptr<GeomAPI_Shape> >& theVertices);
655   /// Returns list of failed vertices
656   MODELAPI_EXPORT const std::list< std::shared_ptr<GeomAPI_Shape> >& shapes() const;
657
658 private:
659   std::list< std::shared_ptr<GeomAPI_Shape> > myShapes;
660 };
661
662 /// Message that sends the features which license is checked and valid
663 class ModelAPI_FeaturesLicenseValidMessage : public Events_Message
664 {
665 public:
666   /// Creates an message
667   MODELAPI_EXPORT
668   ModelAPI_FeaturesLicenseValidMessage(const Events_ID theID, const void* theSender = 0);
669   /// Default destructor
670   MODELAPI_EXPORT virtual ~ModelAPI_FeaturesLicenseValidMessage();
671   /// Static. Returns EventID of the message.
672   MODELAPI_EXPORT static Events_ID eventId()
673   {
674     return Events_Loop::eventByName(EVENT_FEATURE_LICENSE_VALID);
675   }
676
677   /// Sets list of features with valid license
678   MODELAPI_EXPORT void setFeatures(const std::set<std::string>& theFeatures);
679   /// Returns list of features with valid license
680   MODELAPI_EXPORT const std::set<std::string>& features() const;
681
682 private:
683   std::set<std::string> myFeatures;
684 };
685
686 #endif