1 // Copyright (C) 2014-2022 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";
122 /// Event ID that 1D-fillet failed (comes with ModelAPI_ShapesFailedMessage)
123 MAYBE_UNUSED static const char * EVENT_OPERATION_SHAPES_FAILED = "OperationShapesFailed";
125 MAYBE_UNUSED static const char * EVENT_CHECK_CONSTRAINTS = "CheckConstrains";
127 MAYBE_UNUSED static const char * EVENT_REMOVE_CONSTRAINTS = "RemoveConstrains";
129 /// Event ID that license of specified features is checked and valid
130 MAYBE_UNUSED static const char * EVENT_FEATURE_LICENSE_VALID = "FeaturesLicenseValid";
132 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
133 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
136 /// Creates an empty message
137 ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0);
138 /// The virtual destructor
139 virtual ~ModelAPI_ObjectUpdatedMessage();
142 /// Returns the feature that has been updated
143 virtual const std::set<ObjectPtr>& objects() const = 0;
145 //! Creates a new empty group (to store it in the loop before flush)
146 virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
148 //! Allows to join the given message with the current one
149 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
152 /// Message that feature was deleted (used for Object Browser update)
153 class MODELAPI_EXPORT ModelAPI_ObjectDeletedMessage : public Events_MessageGroup
156 /// Creates an empty message
157 ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0);
158 /// The virtual destructor
159 virtual ~ModelAPI_ObjectDeletedMessage();
162 /// Returns the groups where the objects were deleted
163 virtual const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> >&
166 /// Creates the new empty message of this kind
167 virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
169 /// Returns the identifier of the kind of a message
170 virtual const Events_ID messageId() = 0;
172 /// Appends to this message the given one.
173 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
176 /// Message that order changed (used for Object Browser update)
177 class MODELAPI_EXPORT ModelAPI_OrderUpdatedMessage : public Events_Message
180 /// Creates a message:
181 ModelAPI_OrderUpdatedMessage(const Events_ID theID, const void* theSender = 0);
182 /// The virtual destructor
183 virtual ~ModelAPI_OrderUpdatedMessage();
186 /// Returns the document that has been updated
187 virtual std::shared_ptr<ModelAPI_Feature> reordered() = 0;
189 /// Returns the identifier of the kind of a message
190 virtual const Events_ID messageId() = 0;
193 /// Allows to create ModelAPI messages
194 class MODELAPI_EXPORT ModelAPI_EventCreator
197 virtual ~ModelAPI_EventCreator() {}
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;
211 /// returns the creator instance
212 static const ModelAPI_EventCreator* get();
214 /// sets the creator instance
215 static void set(const ModelAPI_EventCreator* theCreator);
218 /// Contains the state information about the feature: is it enabled or disabled.
219 class ModelAPI_FeatureStateMessage : public Events_Message
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();
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);
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;
243 std::shared_ptr<ModelAPI_Feature> myCurrentFeature;
245 std::map<std::string, bool> myFeatureState;
248 /// Message that document (Part, PartSet) was created
249 class ModelAPI_DocumentCreatedMessage : public Events_Message
251 DocumentPtr myDocument;
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()
261 static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated");
262 return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID);
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);
271 /// Message that attribute text should be evaluated in the attribute value
272 class ModelAPI_AttributeEvalMessage : public Events_Message
274 AttributePtr myAttribute;
277 /// Static. Returns EventID of the message.
278 MODELAPI_EXPORT static Events_ID& eventId()
280 static const char * MY_ATTRIBUTE_EVALUATION_EVENT_ID("AttributeEvaluationRequest");
281 static Events_ID anId = Events_Loop::eventByName(MY_ATTRIBUTE_EVALUATION_EVENT_ID);
285 /// Useful method that creates and sends the AttributeEvalMessage event
286 MODELAPI_EXPORT static void send(AttributePtr theAttribute, const void* theSender)
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);
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();
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);
306 /// Message that parameter feature expression should be evaluated: value and error producing
307 class ModelAPI_ParameterEvalMessage : public Events_Message
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
317 /// Static. Returns EventID of the message.
318 MODELAPI_EXPORT static Events_ID& eventId()
320 static const char * MY_PARAMETER_EVALUATION_EVENT_ID("ParameterEvaluationRequest");
321 static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
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)
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);
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();
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;
361 class ModelAPI_ImportParametersMessage : public Events_Message
363 std::string myFilename; ///< filename where where parameters are stored
364 std::string myError; ///< error of processing, empty if there is no error
367 /// Static. Returns EventID of the message.
368 MODELAPI_EXPORT static Events_ID& eventId()
370 static const char* MY_PARAMETER_EVALUATION_EVENT_ID("ImportParametersMessage");
371 static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
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)
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);
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();
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);
400 class ModelAPI_BuildEvalMessage : public Events_Message
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;
409 /// Static. Returns EventID of the message.
410 MODELAPI_EXPORT static Events_ID& eventId()
412 static const char * MY_BUILD_EVALUATION_EVENT_ID("BuildEvaluationRequest");
413 static Events_ID anId = Events_Loop::eventByName(MY_BUILD_EVALUATION_EVENT_ID);
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)
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);
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();
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();
448 /// Returns the interpreter error (empty if no error)
449 MODELAPI_EXPORT const std::string& error() const;
452 /// Message to ask compute the positions of parameters in the expression
453 class ModelAPI_ComputePositionsMessage : public Events_Message
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
460 /// Static. Returns EventID of the message.
461 MODELAPI_EXPORT static Events_ID& eventId()
463 static const char * MY_COMPUTE_POSITIOND_EVENT_ID("ComputePositionsRequest");
464 static Events_ID anId = Events_Loop::eventByName(MY_COMPUTE_POSITIOND_EVENT_ID);
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)
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);
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();
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;
499 /// Message that the object is renamed
500 class ModelAPI_ObjectRenamedMessage : public Events_Message
503 std::wstring myOldName;
504 std::wstring myNewName;
507 /// Static. Returns EventID of the message.
508 MODELAPI_EXPORT static Events_ID& eventId()
510 static const char * MY_OBJECT_RENAMED_EVENT_ID("ObjectRenamed");
511 static Events_ID anId = Events_Loop::eventByName(MY_OBJECT_RENAMED_EVENT_ID);
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);
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();
526 /// Returns an object
527 MODELAPI_EXPORT ObjectPtr object() const;
529 MODELAPI_EXPORT void setObject(ObjectPtr theObject);
530 /// Returns an old name
531 MODELAPI_EXPORT std::wstring oldName() const;
533 MODELAPI_EXPORT void setOldName(const std::wstring& theOldName);
534 /// Returns a new name
535 MODELAPI_EXPORT std::wstring newName() const;
537 MODELAPI_EXPORT void setNewName(const std::wstring& theNewName);
540 /// Message that the parameter should be replaced with its value
541 class ModelAPI_ReplaceParameterMessage : public Events_Message
546 /// Static. Returns EventID of the message.
547 MODELAPI_EXPORT static Events_ID& eventId()
549 static const char * MY_EVENT_ID("ReplaceParameter");
550 static Events_ID anId = Events_Loop::eventByName(MY_EVENT_ID);
554 /// Useful method that creates and sends the AttributeEvalMessage event
555 MODELAPI_EXPORT static void send(ObjectPtr theObject,
556 const void* theSender);
558 /// Creates an empty message
560 ModelAPI_ReplaceParameterMessage(const Events_ID theID, const void* theSender = 0);
561 /// The virtual destructor
562 MODELAPI_EXPORT virtual ~ModelAPI_ReplaceParameterMessage();
564 /// Returns an object
565 MODELAPI_EXPORT ObjectPtr object() const;
567 MODELAPI_EXPORT void setObject(ObjectPtr theObject);
570 /// Message that sends the sketch solver and sketcher GUI processes to show in the property panel
571 class ModelAPI_SolverFailedMessage : public Events_Message
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();
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;
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; }
590 std::set<ObjectPtr> myObjects;
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
598 ObjectPtr myMovedObject;
599 AttributePtr myMovedAttribute;
600 int myMovedPointIndex;
602 std::shared_ptr<GeomAPI_Pnt2d> myOriginalPosition;
603 std::shared_ptr<GeomAPI_Pnt2d> myCurrentPosition;
606 MODELAPI_EXPORT ModelAPI_ObjectMovedMessage(const void* theSender = 0);
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);
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; }
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; }
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; }
643 /// Message that sends the failed vertices of 1D-fillet to highlight them in 3D viewer
644 class ModelAPI_ShapesFailedMessage : public Events_Message
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()
654 return Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED);
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;
663 std::list< std::shared_ptr<GeomAPI_Shape> > myShapes;
666 ///Message that sends the constraints to check or remove
667 class ModelAPI_CheckConstraintsMessage : public Events_Message
670 /// Creates an empty message
671 MODELAPI_EXPORT ModelAPI_CheckConstraintsMessage(const Events_ID theID, const void* theSender = 0);
672 /// The virtual destructor
673 MODELAPI_EXPORT virtual ~ModelAPI_CheckConstraintsMessage();
675 ///Get list of constrains
676 MODELAPI_EXPORT const std::set<ObjectPtr>& constraints() const;
678 ///Set list of constrains
679 MODELAPI_EXPORT void setConstraints(const std::set<ObjectPtr>& theConstraints);
682 std::set<ObjectPtr> myConstraints;
686 /// Message that sends the features which license is checked and valid
687 class ModelAPI_FeaturesLicenseValidMessage : public Events_Message
690 /// Creates an message
692 ModelAPI_FeaturesLicenseValidMessage(const Events_ID theID, const void* theSender = 0);
693 /// Default destructor
694 MODELAPI_EXPORT virtual ~ModelAPI_FeaturesLicenseValidMessage();
695 /// Static. Returns EventID of the message.
696 MODELAPI_EXPORT static Events_ID eventId()
698 return Events_Loop::eventByName(EVENT_FEATURE_LICENSE_VALID);
701 /// Sets list of features with valid license
702 MODELAPI_EXPORT void setFeatures(const std::set<std::string>& theFeatures);
703 /// Returns list of features with valid license
704 MODELAPI_EXPORT const std::set<std::string>& features() const;
707 std::set<std::string> myFeatures;