1 // Copyright (C) 2014-2021 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef MODELAPI_EVENTS_H_
21 #define MODELAPI_EVENTS_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>
36 class ModelAPI_Document;
37 class ModelAPI_ResultParameter;
41 #if defined __GNUC__ || defined __clang__
42 #define MAYBE_UNUSED __attribute__((unused))
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";
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";
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";
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";
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";
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";
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";
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";
107 /// Event ID that informs that some object has changed the stability
108 MAYBE_UNUSED static const char * EVENT_STABILITY_CHANGED = "StabilityChanged";
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";
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";
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";
119 /// Event ID that requests updates visual attributes for presentations
120 MAYBE_UNUSED static const char * EVENT_VISUAL_ATTRIBUTES = "UpdateVisualAttributes";
123 /// Event ID that 1D-fillet failed (comes with ModelAPI_ShapesFailedMessage)
124 MAYBE_UNUSED static const char * EVENT_OPERATION_SHAPES_FAILED = "OperationShapesFailed";
126 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
127 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
130 /// Creates an empty message
131 ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0);
132 /// The virtual destructor
133 virtual ~ModelAPI_ObjectUpdatedMessage();
136 /// Returns the feature that has been updated
137 virtual const std::set<ObjectPtr>& objects() const = 0;
139 //! Creates a new empty group (to store it in the loop before flush)
140 virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
142 //! Allows to join the given message with the current one
143 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
146 /// Message that feature was deleted (used for Object Browser update)
147 class MODELAPI_EXPORT ModelAPI_ObjectDeletedMessage : public Events_MessageGroup
150 /// Creates an empty message
151 ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0);
152 /// The virtual destructor
153 virtual ~ModelAPI_ObjectDeletedMessage();
156 /// Returns the groups where the objects were deleted
157 virtual const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> >&
160 /// Creates the new empty message of this kind
161 virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
163 /// Returns the identifier of the kind of a message
164 virtual const Events_ID messageId() = 0;
166 /// Appends to this message the given one.
167 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
170 /// Message that order changed (used for Object Browser update)
171 class MODELAPI_EXPORT ModelAPI_OrderUpdatedMessage : public Events_Message
174 /// Creates a message:
175 ModelAPI_OrderUpdatedMessage(const Events_ID theID, const void* theSender = 0);
176 /// The virtual destructor
177 virtual ~ModelAPI_OrderUpdatedMessage();
180 /// Returns the document that has been updated
181 virtual std::shared_ptr<ModelAPI_Feature> reordered() = 0;
183 /// Returns the identifier of the kind of a message
184 virtual const Events_ID messageId() = 0;
187 /// Allows to create ModelAPI messages
188 class MODELAPI_EXPORT ModelAPI_EventCreator
191 virtual ~ModelAPI_EventCreator() {}
193 /// creates created, updated or moved messages and sends to the loop
194 virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
195 const bool isGroupped = true) const = 0;
196 /// creates created, updated or moved messages with the objects collection and sends to the loop
197 virtual void sendUpdated(const std::list<ObjectPtr>& theObjects, const Events_ID& theEvent,
198 const bool isGroupped = true) const = 0;
199 /// creates deleted message and sends to the loop
200 virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
201 const std::string& theGroup) const = 0;
202 /// creates reordered message and sends to the loop
203 virtual void sendReordered(const std::shared_ptr<ModelAPI_Feature>& theReordered) const = 0;
205 /// returns the creator instance
206 static const ModelAPI_EventCreator* get();
208 /// sets the creator instance
209 static void set(const ModelAPI_EventCreator* theCreator);
212 /// Contains the state information about the feature: is it enabled or disabled.
213 class ModelAPI_FeatureStateMessage : public Events_Message
216 /// Creates an empty message
217 MODELAPI_EXPORT ModelAPI_FeatureStateMessage(const Events_ID theID, const void* theSender = 0);
218 /// The virtual destructor
219 MODELAPI_EXPORT virtual ~ModelAPI_FeatureStateMessage();
221 /// Returns the feature this message is related to
222 MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> feature() const;
223 /// Stores the feature this message is related to
224 MODELAPI_EXPORT void setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature);
226 /// Returns true if feature has specific state
227 MODELAPI_EXPORT bool hasState(const std::string& theFeatureId) const;
228 /// Returns true if feature is enabled
229 MODELAPI_EXPORT bool state(const std::string& theFeatureId, bool theDefault = false) const;
230 /// Stores the feature state
231 MODELAPI_EXPORT void setState(const std::string& theFeatureId, bool theValue);
232 /// Returns all feature IDs with states
233 MODELAPI_EXPORT std::list<std::string> features() const;
237 std::shared_ptr<ModelAPI_Feature> myCurrentFeature;
239 std::map<std::string, bool> myFeatureState;
242 /// Message that document (Part, PartSet) was created
243 class ModelAPI_DocumentCreatedMessage : public Events_Message
245 DocumentPtr myDocument;
248 /// Creates an empty message
249 MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0);
250 /// The virtual destructor
251 MODELAPI_EXPORT virtual ~ModelAPI_DocumentCreatedMessage();
252 /// Static. Returns EventID of the message.
253 MODELAPI_EXPORT static Events_ID eventId()
255 static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated");
256 return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID);
259 /// Returns a document stored in the message
260 MODELAPI_EXPORT DocumentPtr document() const;
261 /// Sets a document to the message
262 MODELAPI_EXPORT void setDocument(DocumentPtr theDocument);
265 /// Message that attribute text should be evaluated in the attribute value
266 class ModelAPI_AttributeEvalMessage : public Events_Message
268 AttributePtr myAttribute;
271 /// Static. Returns EventID of the message.
272 MODELAPI_EXPORT static Events_ID& eventId()
274 static const char * MY_ATTRIBUTE_EVALUATION_EVENT_ID("AttributeEvaluationRequest");
275 static Events_ID anId = Events_Loop::eventByName(MY_ATTRIBUTE_EVALUATION_EVENT_ID);
279 /// Useful method that creates and sends the AttributeEvalMessage event
280 MODELAPI_EXPORT static void send(AttributePtr theAttribute, const void* theSender)
282 std::shared_ptr<ModelAPI_AttributeEvalMessage> aMessage =
283 std::shared_ptr<ModelAPI_AttributeEvalMessage>(
284 new ModelAPI_AttributeEvalMessage(eventId(), theSender));
285 aMessage->setAttribute(theAttribute);
286 Events_Loop::loop()->send(aMessage);
289 /// Creates an empty message
290 MODELAPI_EXPORT ModelAPI_AttributeEvalMessage(const Events_ID theID, const void* theSender = 0);
291 /// The virtual destructor
292 MODELAPI_EXPORT virtual ~ModelAPI_AttributeEvalMessage();
294 /// Returns a document stored in the message
295 MODELAPI_EXPORT AttributePtr attribute() const;
296 /// Sets an attribute to the message
297 MODELAPI_EXPORT void setAttribute(AttributePtr theAttribute);
300 /// Message that parameter feature expression should be evaluated: value and error producing
301 class ModelAPI_ParameterEvalMessage : public Events_Message
303 FeaturePtr myParam; ///< parameters that should be evaluated
304 bool myIsProcessed; ///< true if results were set
305 /// result of processing, list of parameters in expression found
306 std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
307 double myResult; ///< result of processing, the computed value of the expression
308 std::string myError; ///< error of processing, empty if there is no error
311 /// Static. Returns EventID of the message.
312 MODELAPI_EXPORT static Events_ID& eventId()
314 static const char * MY_PARAMETER_EVALUATION_EVENT_ID("ParameterEvaluationRequest");
315 static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
319 /// Useful method that creates and sends the event.
320 /// Returns the message, processed, with the resulting fields filled.
321 MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ParameterEvalMessage>
322 send(FeaturePtr theParameter, const void* theSender)
324 std::shared_ptr<ModelAPI_ParameterEvalMessage> aMessage =
325 std::shared_ptr<ModelAPI_ParameterEvalMessage>(
326 new ModelAPI_ParameterEvalMessage(eventId(), theSender));
327 aMessage->setParameter(theParameter);
328 Events_Loop::loop()->send(aMessage);
332 /// Creates an empty message
333 MODELAPI_EXPORT ModelAPI_ParameterEvalMessage(const Events_ID theID, const void* theSender = 0);
334 /// The virtual destructor
335 MODELAPI_EXPORT virtual ~ModelAPI_ParameterEvalMessage();
337 /// Returns a parameter stored in the message
338 MODELAPI_EXPORT FeaturePtr parameter() const;
339 /// Sets a parameter to the message
340 MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
341 /// Sets the results of processing
342 MODELAPI_EXPORT void setResults(
343 const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
344 const double theResult, const std::string& theError);
345 /// Returns true if the expression is processed
346 MODELAPI_EXPORT bool isProcessed();
347 /// Returns the results of processing: list of parameters found in the expression
348 MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
349 /// Returns the expression result
350 MODELAPI_EXPORT const double& result() const;
351 /// Returns the interpreter error (empty if no error)
352 MODELAPI_EXPORT const std::string& error() const;
355 class ModelAPI_ImportParametersMessage : public Events_Message
357 std::string myFilename; ///< filename where where parameters are stored
358 std::string myError; ///< error of processing, empty if there is no error
361 /// Static. Returns EventID of the message.
362 MODELAPI_EXPORT static Events_ID& eventId()
364 static const char* MY_PARAMETER_EVALUATION_EVENT_ID("ImportParametersMessage");
365 static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
369 /// Useful method that creates and sends the event.
370 /// Returns the message, processed, with the resulting fields filled.
371 MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ImportParametersMessage>
372 send(std::string theParameter, const void* theSender)
374 std::shared_ptr<ModelAPI_ImportParametersMessage> aMessage =
375 std::shared_ptr<ModelAPI_ImportParametersMessage>(
376 new ModelAPI_ImportParametersMessage(eventId(), theSender));
377 aMessage->setFilename(theParameter);
378 Events_Loop::loop()->send(aMessage);
382 /// Creates an empty message
383 MODELAPI_EXPORT ModelAPI_ImportParametersMessage(const Events_ID theID, const void* theSender = 0);
384 /// The virtual destructor
385 MODELAPI_EXPORT virtual ~ModelAPI_ImportParametersMessage();
387 /// Returns a filename stored in the message
388 MODELAPI_EXPORT std::string filename() const;
389 /// Sets a filename to the message
390 MODELAPI_EXPORT void setFilename(std::string theFilename);
393 class ModelAPI_BuildEvalMessage : public Events_Message
395 FeaturePtr myParam; ///< parameters that should be evaluated
396 bool myIsProcessed; ///< true if results were set
397 std::string myError; ///< error of processing, empty if there is no error
398 /// result of processing, list of parameters in expression found
399 std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
402 /// Static. Returns EventID of the message.
403 MODELAPI_EXPORT static Events_ID& eventId()
405 static const char * MY_BUILD_EVALUATION_EVENT_ID("BuildEvaluationRequest");
406 static Events_ID anId = Events_Loop::eventByName(MY_BUILD_EVALUATION_EVENT_ID);
410 /// Useful method that creates and sends the event.
411 /// Returns the message, processed, with the resulting fields filled.
412 MODELAPI_EXPORT static std::shared_ptr<ModelAPI_BuildEvalMessage>
413 send(FeaturePtr theParameter, const void* theSender)
415 std::shared_ptr<ModelAPI_BuildEvalMessage> aMessage =
416 std::shared_ptr<ModelAPI_BuildEvalMessage>(
417 new ModelAPI_BuildEvalMessage(eventId(), theSender));
418 aMessage->setParameter(theParameter);
419 Events_Loop::loop()->send(aMessage);
423 /// Creates an empty message
424 MODELAPI_EXPORT ModelAPI_BuildEvalMessage(const Events_ID theID, const void* theSender = 0);
425 /// The virtual destructor
426 MODELAPI_EXPORT virtual ~ModelAPI_BuildEvalMessage();
428 /// Returns a parameter stored in the message
429 MODELAPI_EXPORT FeaturePtr parameter() const;
430 /// Sets a parameter to the message
431 MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
432 /// Sets the results of processing
433 MODELAPI_EXPORT void setResults(
434 const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
435 const std::string& theError);
436 /// Returns the results of processing: list of parameters found in the expression
437 MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
438 /// Returns true if the expression is processed
439 MODELAPI_EXPORT bool isProcessed();
441 /// Returns the interpreter error (empty if no error)
442 MODELAPI_EXPORT const std::string& error() const;
445 /// Message to ask compute the positions of parameters in the expression
446 class ModelAPI_ComputePositionsMessage : public Events_Message
448 std::wstring myExpression; ///< the expression string
449 std::wstring myParamName; ///< name of the parameter to be searched
450 std::list<std::pair<int, int> > myPositions; ///< computation result: start-end position indices
453 /// Static. Returns EventID of the message.
454 MODELAPI_EXPORT static Events_ID& eventId()
456 static const char * MY_COMPUTE_POSITIOND_EVENT_ID("ComputePositionsRequest");
457 static Events_ID anId = Events_Loop::eventByName(MY_COMPUTE_POSITIOND_EVENT_ID);
461 /// Useful method that creates and sends the AttributeEvalMessage event
462 /// Returns the message, processed, with the resulting fields filled
463 MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ComputePositionsMessage>
464 send(const std::wstring& theExpression, const std::wstring& theParameter, const void* theSender)
466 std::shared_ptr<ModelAPI_ComputePositionsMessage> aMessage =
467 std::shared_ptr<ModelAPI_ComputePositionsMessage>(
468 new ModelAPI_ComputePositionsMessage(eventId(), theSender));
469 aMessage->set(theExpression, theParameter);
470 Events_Loop::loop()->send(aMessage);
474 /// Creates an empty message
475 MODELAPI_EXPORT ModelAPI_ComputePositionsMessage(
476 const Events_ID theID, const void* theSender = 0);
477 /// The virtual destructor
478 MODELAPI_EXPORT virtual ~ModelAPI_ComputePositionsMessage();
480 /// Returns an expression stored in the message
481 MODELAPI_EXPORT const std::wstring& expression() const;
482 /// Returns a parameter name stored in the message
483 MODELAPI_EXPORT const std::wstring& parameter() const;
484 /// Sets an expression and parameter needed for computation
485 MODELAPI_EXPORT void set(const std::wstring& theExpression, const std::wstring& theParameter);
486 /// Sets the results of processing
487 MODELAPI_EXPORT void setPositions(const std::list<std::pair<int, int> >& thePositions);
488 /// Returns the results of processing: position start and end indices
489 MODELAPI_EXPORT const std::list<std::pair<int, int> >& positions() const;
492 /// Message that the object is renamed
493 class ModelAPI_ObjectRenamedMessage : public Events_Message
496 std::wstring myOldName;
497 std::wstring myNewName;
500 /// Static. Returns EventID of the message.
501 MODELAPI_EXPORT static Events_ID& eventId()
503 static const char * MY_OBJECT_RENAMED_EVENT_ID("ObjectRenamed");
504 static Events_ID anId = Events_Loop::eventByName(MY_OBJECT_RENAMED_EVENT_ID);
508 /// Useful method that creates and sends the AttributeEvalMessage event
509 MODELAPI_EXPORT static void send(ObjectPtr theObject,
510 const std::wstring& theOldName,
511 const std::wstring& theNewName,
512 const void* theSender);
514 /// Creates an empty message
515 MODELAPI_EXPORT ModelAPI_ObjectRenamedMessage(const Events_ID theID, const void* theSender = 0);
516 /// The virtual destructor
517 MODELAPI_EXPORT virtual ~ModelAPI_ObjectRenamedMessage();
519 /// Returns an object
520 MODELAPI_EXPORT ObjectPtr object() const;
522 MODELAPI_EXPORT void setObject(ObjectPtr theObject);
523 /// Returns an old name
524 MODELAPI_EXPORT std::wstring oldName() const;
526 MODELAPI_EXPORT void setOldName(const std::wstring& theOldName);
527 /// Returns a new name
528 MODELAPI_EXPORT std::wstring newName() const;
530 MODELAPI_EXPORT void setNewName(const std::wstring& theNewName);
533 /// Message that the parameter should be replaced with its value
534 class ModelAPI_ReplaceParameterMessage : public Events_Message
539 /// Static. Returns EventID of the message.
540 MODELAPI_EXPORT static Events_ID& eventId()
542 static const char * MY_EVENT_ID("ReplaceParameter");
543 static Events_ID anId = Events_Loop::eventByName(MY_EVENT_ID);
547 /// Useful method that creates and sends the AttributeEvalMessage event
548 MODELAPI_EXPORT static void send(ObjectPtr theObject,
549 const void* theSender);
551 /// Creates an empty message
553 ModelAPI_ReplaceParameterMessage(const Events_ID theID, const void* theSender = 0);
554 /// The virtual destructor
555 MODELAPI_EXPORT virtual ~ModelAPI_ReplaceParameterMessage();
557 /// Returns an object
558 MODELAPI_EXPORT ObjectPtr object() const;
560 MODELAPI_EXPORT void setObject(ObjectPtr theObject);
563 /// Message that sends the sketch solver and sketcher GUI processes to show in the property panel
564 class ModelAPI_SolverFailedMessage : public Events_Message
567 /// Creates an message
568 MODELAPI_EXPORT ModelAPI_SolverFailedMessage(const Events_ID theID, const void* theSender = 0);
569 /// Default destructor
570 MODELAPI_EXPORT virtual ~ModelAPI_SolverFailedMessage();
572 /// Sets list of conflicting constraints
573 MODELAPI_EXPORT void setObjects(const std::set<ObjectPtr>& theObjects);
574 /// Returns list of conflicting constraints
575 MODELAPI_EXPORT const std::set<ObjectPtr>& objects() const;
577 /// Sets degrees of freedom
578 void dof(const int theDOF) { myDOF = theDOF; }
579 /// Returns degrees of freedom
580 const int& dof() const { return myDOF; }
583 std::set<ObjectPtr> myObjects;
587 /// Message sent when feature or attribute has been moved.
588 /// Stores the moving object/attribute, original and new positions of mouse.
589 class ModelAPI_ObjectMovedMessage : public Events_Message
591 ObjectPtr myMovedObject;
592 AttributePtr myMovedAttribute;
593 int myMovedPointIndex;
595 std::shared_ptr<GeomAPI_Pnt2d> myOriginalPosition;
596 std::shared_ptr<GeomAPI_Pnt2d> myCurrentPosition;
599 MODELAPI_EXPORT ModelAPI_ObjectMovedMessage(const void* theSender = 0);
601 /// Set object which is being moved (if the message already contains attribute it will be cleared)
602 MODELAPI_EXPORT void setMovedObject(const ObjectPtr& theMovedObject);
603 /// Set attribute which is being moved (if the message already contains object it will be cleared)
604 /// \param[in] theMovedAttribute moved attribute
605 /// \param[in] thePointIndex index of the point if the moved attribute is an array of points
606 MODELAPI_EXPORT void setMovedAttribute(const AttributePtr& theMovedAttribute,
607 const int thePointIndex = -1);
609 /// Return moved object
610 ObjectPtr movedObject() const
611 { return myMovedObject; }
612 /// Return moved attribute
613 AttributePtr movedAttribute() const
614 { return myMovedAttribute; }
615 /// Return index of the moved point
616 int movedPointIndex() const
617 { return myMovedPointIndex; }
619 /// Set original mouse position
620 MODELAPI_EXPORT void setOriginalPosition(double theX, double theY);
621 /// Set original mouse position
622 MODELAPI_EXPORT void setOriginalPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
623 /// Return original mouse position
624 const std::shared_ptr<GeomAPI_Pnt2d>& originalPosition() const
625 { return myOriginalPosition; }
627 /// Set current mouse position
628 MODELAPI_EXPORT void setCurrentPosition(double theX, double theY);
629 /// Set current mouse position
630 MODELAPI_EXPORT void setCurrentPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
631 /// Return current mouse position
632 const std::shared_ptr<GeomAPI_Pnt2d>& currentPosition() const
633 { return myCurrentPosition; }
636 /// Message that sends the failed vertices of 1D-fillet to highlight them in 3D viewer
637 class ModelAPI_ShapesFailedMessage : public Events_Message
640 /// Creates an message
641 MODELAPI_EXPORT ModelAPI_ShapesFailedMessage(const Events_ID theID, const void* theSender = 0);
642 /// Default destructor
643 MODELAPI_EXPORT virtual ~ModelAPI_ShapesFailedMessage();
644 /// Static. Returns EventID of the message.
645 MODELAPI_EXPORT static Events_ID eventId()
647 return Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED);
650 /// Sets list of failed vertices
651 MODELAPI_EXPORT void setShapes(const std::list< std::shared_ptr<GeomAPI_Shape> >& theVertices);
652 /// Returns list of failed vertices
653 MODELAPI_EXPORT const std::list< std::shared_ptr<GeomAPI_Shape> >& shapes() const;
656 std::list< std::shared_ptr<GeomAPI_Shape> > myShapes;