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";
63 /// All documents closed
64 MAYBE_UNUSED static const char * EVENT_DOCUMENTS_CLOSED = "AllDocumentsClosed";
66 /// Event ID that order of objects in group is changed,
67 /// so, tree must be fully recreated (movement of feature)
68 MAYBE_UNUSED static const char * EVENT_ORDER_UPDATED = "OrderUpdated";
69 /// Event ID that the sketch is prepared and all grouped messages for the solver may be flushed
70 MAYBE_UNUSED static const char * EVENT_UPDATE_SELECTION = "UpdateSelection";
72 /// Request for the enabled/disabled actions behavior for some specific features
73 MAYBE_UNUSED static const char * EVENT_FEATURE_STATE_REQUEST = "FeatureStateRequest";
74 /// Reply for the enabled/disabled actions behavior for some specific features
75 MAYBE_UNUSED static const char * EVENT_FEATURE_STATE_RESPONSE = "FeatureStateResponse";
77 /// To block the viewer updates
78 MAYBE_UNUSED static const char * EVENT_UPDATE_VIEWER_BLOCKED = "UpdateViewerBlocked";
79 /// To unblock the viewer updates
80 MAYBE_UNUSED static const char * EVENT_UPDATE_VIEWER_UNBLOCKED = "UpdateViewerUnblocked";
82 /// To inform that there is an empty presentation in the viewer
83 MAYBE_UNUSED static const char * EVENT_EMPTY_AIS_PRESENTATION = "EmptyAISPresentation";
84 /// To inform that there is an empty operation for presentation in the viewer
85 MAYBE_UNUSED static const char * EVENT_EMPTY_OPERATION_PRESENTATION = "EmptyOperationPresentation";
87 MAYBE_UNUSED static const char * EVENT_PREVIEW_BLOCKED = "PreviewBlocked";
88 /// To preview the current feature in the viewer (to compute the result)
89 MAYBE_UNUSED static const char * EVENT_PREVIEW_REQUESTED = "PreviewRequested";
90 /// To block automatic recomputation of any feature (by the GUI button press)
91 MAYBE_UNUSED static const char * EVENT_AUTOMATIC_RECOMPUTATION_DISABLE
92 = "DisableAutomaticRecomputation";
93 /// To unblock block automatic recomputation (default state: the GUI button unpressed)
94 MAYBE_UNUSED static const char * EVENT_AUTOMATIC_RECOMPUTATION_ENABLE
95 = "EnableAutomaticRecomputation";
97 /// Event ID that solver has conflicting constraints (comes with ModelAPI_SolverFailedMessage)
98 MAYBE_UNUSED static const char * EVENT_SOLVER_FAILED = "SolverFailed";
99 /// Event ID that the problem in solver disappeared
100 MAYBE_UNUSED static const char * EVENT_SOLVER_REPAIRED = "SolverRepaired";
102 /// Event Id that sketch has DoF = 0
103 MAYBE_UNUSED static const char * EVENT_SKETCH_FULLY_CONSTRAINED = "SketchFullyConstrainted";
104 /// Event Id that sketch has DoF > 0
105 MAYBE_UNUSED static const char * EVENT_SKETCH_UNDER_CONSTRAINED = "SketchUnderConstrainted";
106 /// Event Id that sketch has DoF < 0
107 MAYBE_UNUSED static const char * EVENT_SKETCH_OVER_CONSTRAINED = "SketchOverConstrainted";
109 /// Event ID that informs that some object has changed the stability
110 MAYBE_UNUSED static const char * EVENT_STABILITY_CHANGED = "StabilityChanged";
112 /// Event ID that the sketch is prepared and all grouped messages for the solver may be flushed
113 MAYBE_UNUSED static const char * EVENT_SKETCH_PREPARED = "SketchPrepared";
115 /// Event ID that provides a request for list of non-fixed objects necessary for DoF = 0
116 MAYBE_UNUSED static const char * EVENT_GET_DOF_OBJECTS = "GetDoFObjects";
118 /// Event ID that provides a request for list of non-fixed objects necessary for DoF = 0
119 MAYBE_UNUSED static const char * EVENT_DOF_OBJECTS = "DoFObjects";
121 /// Event ID that requests updates visual attributes for presentations
122 MAYBE_UNUSED static const char * EVENT_VISUAL_ATTRIBUTES = "UpdateVisualAttributes";
124 /// Event ID that 1D-fillet failed (comes with ModelAPI_ShapesFailedMessage)
125 MAYBE_UNUSED static const char * EVENT_OPERATION_SHAPES_FAILED = "OperationShapesFailed";
127 MAYBE_UNUSED static const char * EVENT_CHECK_CONSTRAINTS = "CheckConstrains";
129 MAYBE_UNUSED static const char * EVENT_REMOVE_CONSTRAINTS = "RemoveConstrains";
131 /// Event ID that license of specified features is checked and valid
132 MAYBE_UNUSED static const char * EVENT_FEATURE_LICENSE_VALID = "FeaturesLicenseValid";
134 /// To send preferences information: create part on init or not
135 MAYBE_UNUSED static const char * EVENT_CREATE_PART_ON_START = "CreatePartOnStart";
138 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
139 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
142 /// Creates an empty message
143 ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0);
144 /// The virtual destructor
145 virtual ~ModelAPI_ObjectUpdatedMessage();
148 /// Returns the feature that has been updated
149 virtual const std::set<ObjectPtr>& objects() const = 0;
151 //! Creates a new empty group (to store it in the loop before flush)
152 virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
154 //! Allows to join the given message with the current one
155 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
158 /// Message that feature was deleted (used for Object Browser update)
159 class MODELAPI_EXPORT ModelAPI_ObjectDeletedMessage : public Events_MessageGroup
162 /// Creates an empty message
163 ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0);
164 /// The virtual destructor
165 virtual ~ModelAPI_ObjectDeletedMessage();
168 /// Returns the groups where the objects were deleted
169 virtual const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string> >&
172 /// Creates the new empty message of this kind
173 virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
175 /// Returns the identifier of the kind of a message
176 virtual const Events_ID messageId() = 0;
178 /// Appends to this message the given one.
179 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
182 /// Message that order changed (used for Object Browser update)
183 class MODELAPI_EXPORT ModelAPI_OrderUpdatedMessage : public Events_Message
186 /// Creates a message:
187 ModelAPI_OrderUpdatedMessage(const Events_ID theID, const void* theSender = 0);
188 /// The virtual destructor
189 virtual ~ModelAPI_OrderUpdatedMessage();
192 /// Returns the document that has been updated
193 virtual std::shared_ptr<ModelAPI_Feature> reordered() = 0;
195 /// Returns the identifier of the kind of a message
196 virtual const Events_ID messageId() = 0;
199 /// Allows to create ModelAPI messages
200 class MODELAPI_EXPORT ModelAPI_EventCreator
203 virtual ~ModelAPI_EventCreator() {}
205 /// creates created, updated or moved messages and sends to the loop
206 virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
207 const bool isGroupped = true) const = 0;
208 /// creates created, updated or moved messages with the objects collection and sends to the loop
209 virtual void sendUpdated(const std::list<ObjectPtr>& theObjects, const Events_ID& theEvent,
210 const bool isGroupped = true) const = 0;
211 /// creates deleted message and sends to the loop
212 virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
213 const std::string& theGroup) const = 0;
214 /// creates reordered message and sends to the loop
215 virtual void sendReordered(const std::shared_ptr<ModelAPI_Feature>& theReordered) const = 0;
217 /// returns the creator instance
218 static const ModelAPI_EventCreator* get();
220 /// sets the creator instance
221 static void set(const ModelAPI_EventCreator* theCreator);
224 /// Contains the state information about the feature: is it enabled or disabled.
225 class ModelAPI_FeatureStateMessage : public Events_Message
228 /// Creates an empty message
229 MODELAPI_EXPORT ModelAPI_FeatureStateMessage(const Events_ID theID, const void* theSender = 0);
230 /// The virtual destructor
231 MODELAPI_EXPORT virtual ~ModelAPI_FeatureStateMessage();
233 /// Returns the feature this message is related to
234 MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> feature() const;
235 /// Stores the feature this message is related to
236 MODELAPI_EXPORT void setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature);
238 /// Returns true if feature has specific state
239 MODELAPI_EXPORT bool hasState(const std::string& theFeatureId) const;
240 /// Returns true if feature is enabled
241 MODELAPI_EXPORT bool state(const std::string& theFeatureId, bool theDefault = false) const;
242 /// Stores the feature state
243 MODELAPI_EXPORT void setState(const std::string& theFeatureId, bool theValue);
244 /// Returns all feature IDs with states
245 MODELAPI_EXPORT std::list<std::string> features() const;
249 std::shared_ptr<ModelAPI_Feature> myCurrentFeature;
251 std::map<std::string, bool> myFeatureState;
254 /// Message that document (Part, PartSet) was created
255 class ModelAPI_DocumentCreatedMessage : public Events_Message
257 DocumentPtr myDocument;
260 /// Creates an empty message
261 MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0);
262 /// The virtual destructor
263 MODELAPI_EXPORT virtual ~ModelAPI_DocumentCreatedMessage();
264 /// Static. Returns EventID of the message.
265 MODELAPI_EXPORT static Events_ID eventId()
267 static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated");
268 return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID);
271 /// Returns a document stored in the message
272 MODELAPI_EXPORT DocumentPtr document() const;
273 /// Sets a document to the message
274 MODELAPI_EXPORT void setDocument(DocumentPtr theDocument);
277 /// Message that attribute text should be evaluated in the attribute value
278 class ModelAPI_AttributeEvalMessage : public Events_Message
280 AttributePtr myAttribute;
283 /// Static. Returns EventID of the message.
284 MODELAPI_EXPORT static Events_ID& eventId()
286 static const char * MY_ATTRIBUTE_EVALUATION_EVENT_ID("AttributeEvaluationRequest");
287 static Events_ID anId = Events_Loop::eventByName(MY_ATTRIBUTE_EVALUATION_EVENT_ID);
291 /// Useful method that creates and sends the AttributeEvalMessage event
292 MODELAPI_EXPORT static void send(AttributePtr theAttribute, const void* theSender)
294 std::shared_ptr<ModelAPI_AttributeEvalMessage> aMessage =
295 std::shared_ptr<ModelAPI_AttributeEvalMessage>(
296 new ModelAPI_AttributeEvalMessage(eventId(), theSender));
297 aMessage->setAttribute(theAttribute);
298 Events_Loop::loop()->send(aMessage);
301 /// Creates an empty message
302 MODELAPI_EXPORT ModelAPI_AttributeEvalMessage(const Events_ID theID, const void* theSender = 0);
303 /// The virtual destructor
304 MODELAPI_EXPORT virtual ~ModelAPI_AttributeEvalMessage();
306 /// Returns a document stored in the message
307 MODELAPI_EXPORT AttributePtr attribute() const;
308 /// Sets an attribute to the message
309 MODELAPI_EXPORT void setAttribute(AttributePtr theAttribute);
312 /// Message that parameter feature expression should be evaluated: value and error producing
313 class ModelAPI_ParameterEvalMessage : public Events_Message
315 FeaturePtr myParam; ///< parameters that should be evaluated
316 bool myIsProcessed; ///< true if results were set
317 /// result of processing, list of parameters in expression found
318 std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
319 double myResult; ///< result of processing, the computed value of the expression
320 std::string myError; ///< error of processing, empty if there is no error
323 /// Static. Returns EventID of the message.
324 MODELAPI_EXPORT static Events_ID& eventId()
326 static const char * MY_PARAMETER_EVALUATION_EVENT_ID("ParameterEvaluationRequest");
327 static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
331 /// Useful method that creates and sends the event.
332 /// Returns the message, processed, with the resulting fields filled.
333 MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ParameterEvalMessage>
334 send(FeaturePtr theParameter, const void* theSender)
336 std::shared_ptr<ModelAPI_ParameterEvalMessage> aMessage =
337 std::shared_ptr<ModelAPI_ParameterEvalMessage>(
338 new ModelAPI_ParameterEvalMessage(eventId(), theSender));
339 aMessage->setParameter(theParameter);
340 Events_Loop::loop()->send(aMessage);
344 /// Creates an empty message
345 MODELAPI_EXPORT ModelAPI_ParameterEvalMessage(const Events_ID theID, const void* theSender = 0);
346 /// The virtual destructor
347 MODELAPI_EXPORT virtual ~ModelAPI_ParameterEvalMessage();
349 /// Returns a parameter stored in the message
350 MODELAPI_EXPORT FeaturePtr parameter() const;
351 /// Sets a parameter to the message
352 MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
353 /// Sets the results of processing
354 MODELAPI_EXPORT void setResults(
355 const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
356 const double theResult, const std::string& theError);
357 /// Returns true if the expression is processed
358 MODELAPI_EXPORT bool isProcessed();
359 /// Returns the results of processing: list of parameters found in the expression
360 MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
361 /// Returns the expression result
362 MODELAPI_EXPORT const double& result() const;
363 /// Returns the interpreter error (empty if no error)
364 MODELAPI_EXPORT const std::string& error() const;
367 class ModelAPI_ImportParametersMessage : public Events_Message
369 std::string myFilename; ///< filename where where parameters are stored
370 std::string myError; ///< error of processing, empty if there is no error
373 /// Static. Returns EventID of the message.
374 MODELAPI_EXPORT static Events_ID& eventId()
376 static const char* MY_PARAMETER_EVALUATION_EVENT_ID("ImportParametersMessage");
377 static Events_ID anId = Events_Loop::eventByName(MY_PARAMETER_EVALUATION_EVENT_ID);
381 /// Useful method that creates and sends the event.
382 /// Returns the message, processed, with the resulting fields filled.
383 MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ImportParametersMessage>
384 send(std::string theParameter, const void* theSender)
386 std::shared_ptr<ModelAPI_ImportParametersMessage> aMessage =
387 std::shared_ptr<ModelAPI_ImportParametersMessage>(
388 new ModelAPI_ImportParametersMessage(eventId(), theSender));
389 aMessage->setFilename(theParameter);
390 Events_Loop::loop()->send(aMessage);
394 /// Creates an empty message
395 MODELAPI_EXPORT ModelAPI_ImportParametersMessage(const Events_ID theID,
396 const void* theSender = 0);
397 /// The virtual destructor
398 MODELAPI_EXPORT virtual ~ModelAPI_ImportParametersMessage();
400 /// Returns a filename stored in the message
401 MODELAPI_EXPORT std::string filename() const;
402 /// Sets a filename to the message
403 MODELAPI_EXPORT void setFilename(std::string theFilename);
406 class ModelAPI_BuildEvalMessage : public Events_Message
408 FeaturePtr myParam; ///< parameters that should be evaluated
409 bool myIsProcessed; ///< true if results were set
410 std::string myError; ///< error of processing, empty if there is no error
411 /// result of processing, list of parameters in expression found
412 std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
415 /// Static. Returns EventID of the message.
416 MODELAPI_EXPORT static Events_ID& eventId()
418 static const char * MY_BUILD_EVALUATION_EVENT_ID("BuildEvaluationRequest");
419 static Events_ID anId = Events_Loop::eventByName(MY_BUILD_EVALUATION_EVENT_ID);
423 /// Useful method that creates and sends the event.
424 /// Returns the message, processed, with the resulting fields filled.
425 MODELAPI_EXPORT static std::shared_ptr<ModelAPI_BuildEvalMessage>
426 send(FeaturePtr theParameter, const void* theSender)
428 std::shared_ptr<ModelAPI_BuildEvalMessage> aMessage =
429 std::shared_ptr<ModelAPI_BuildEvalMessage>(
430 new ModelAPI_BuildEvalMessage(eventId(), theSender));
431 aMessage->setParameter(theParameter);
432 Events_Loop::loop()->send(aMessage);
436 /// Creates an empty message
437 MODELAPI_EXPORT ModelAPI_BuildEvalMessage(const Events_ID theID, const void* theSender = 0);
438 /// The virtual destructor
439 MODELAPI_EXPORT virtual ~ModelAPI_BuildEvalMessage();
441 /// Returns a parameter stored in the message
442 MODELAPI_EXPORT FeaturePtr parameter() const;
443 /// Sets a parameter to the message
444 MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
445 /// Sets the results of processing
446 MODELAPI_EXPORT void setResults(
447 const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
448 const std::string& theError);
449 /// Returns the results of processing: list of parameters found in the expression
450 MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
451 /// Returns true if the expression is processed
452 MODELAPI_EXPORT bool isProcessed();
454 /// Returns the interpreter error (empty if no error)
455 MODELAPI_EXPORT const std::string& error() const;
458 /// Message to ask compute the positions of parameters in the expression
459 class ModelAPI_ComputePositionsMessage : public Events_Message
461 std::wstring myExpression; ///< the expression string
462 std::wstring myParamName; ///< name of the parameter to be searched
463 std::list<std::pair<int, int> > myPositions; ///< computation result: start-end position indices
466 /// Static. Returns EventID of the message.
467 MODELAPI_EXPORT static Events_ID& eventId()
469 static const char * MY_COMPUTE_POSITIOND_EVENT_ID("ComputePositionsRequest");
470 static Events_ID anId = Events_Loop::eventByName(MY_COMPUTE_POSITIOND_EVENT_ID);
474 /// Useful method that creates and sends the AttributeEvalMessage event
475 /// Returns the message, processed, with the resulting fields filled
476 MODELAPI_EXPORT static std::shared_ptr<ModelAPI_ComputePositionsMessage>
477 send(const std::wstring& theExpression, const std::wstring& theParameter, const void* theSender)
479 std::shared_ptr<ModelAPI_ComputePositionsMessage> aMessage =
480 std::shared_ptr<ModelAPI_ComputePositionsMessage>(
481 new ModelAPI_ComputePositionsMessage(eventId(), theSender));
482 aMessage->set(theExpression, theParameter);
483 Events_Loop::loop()->send(aMessage);
487 /// Creates an empty message
488 MODELAPI_EXPORT ModelAPI_ComputePositionsMessage(
489 const Events_ID theID, const void* theSender = 0);
490 /// The virtual destructor
491 MODELAPI_EXPORT virtual ~ModelAPI_ComputePositionsMessage();
493 /// Returns an expression stored in the message
494 MODELAPI_EXPORT const std::wstring& expression() const;
495 /// Returns a parameter name stored in the message
496 MODELAPI_EXPORT const std::wstring& parameter() const;
497 /// Sets an expression and parameter needed for computation
498 MODELAPI_EXPORT void set(const std::wstring& theExpression, const std::wstring& theParameter);
499 /// Sets the results of processing
500 MODELAPI_EXPORT void setPositions(const std::list<std::pair<int, int> >& thePositions);
501 /// Returns the results of processing: position start and end indices
502 MODELAPI_EXPORT const std::list<std::pair<int, int> >& positions() const;
505 /// Message that the object is renamed
506 class ModelAPI_ObjectRenamedMessage : public Events_Message
509 std::wstring myOldName;
510 std::wstring myNewName;
513 /// Static. Returns EventID of the message.
514 MODELAPI_EXPORT static Events_ID& eventId()
516 static const char * MY_OBJECT_RENAMED_EVENT_ID("ObjectRenamed");
517 static Events_ID anId = Events_Loop::eventByName(MY_OBJECT_RENAMED_EVENT_ID);
521 /// Useful method that creates and sends the AttributeEvalMessage event
522 MODELAPI_EXPORT static void send(ObjectPtr theObject,
523 const std::wstring& theOldName,
524 const std::wstring& theNewName,
525 const void* theSender);
527 /// Creates an empty message
528 MODELAPI_EXPORT ModelAPI_ObjectRenamedMessage(const Events_ID theID, const void* theSender = 0);
529 /// The virtual destructor
530 MODELAPI_EXPORT virtual ~ModelAPI_ObjectRenamedMessage();
532 /// Returns an object
533 MODELAPI_EXPORT ObjectPtr object() const;
535 MODELAPI_EXPORT void setObject(ObjectPtr theObject);
536 /// Returns an old name
537 MODELAPI_EXPORT std::wstring oldName() const;
539 MODELAPI_EXPORT void setOldName(const std::wstring& theOldName);
540 /// Returns a new name
541 MODELAPI_EXPORT std::wstring newName() const;
543 MODELAPI_EXPORT void setNewName(const std::wstring& theNewName);
546 /// Message that the parameter should be replaced with its value
547 class ModelAPI_ReplaceParameterMessage : public Events_Message
552 /// Static. Returns EventID of the message.
553 MODELAPI_EXPORT static Events_ID& eventId()
555 static const char * MY_EVENT_ID("ReplaceParameter");
556 static Events_ID anId = Events_Loop::eventByName(MY_EVENT_ID);
560 /// Useful method that creates and sends the AttributeEvalMessage event
561 MODELAPI_EXPORT static void send(ObjectPtr theObject,
562 const void* theSender);
564 /// Creates an empty message
566 ModelAPI_ReplaceParameterMessage(const Events_ID theID, const void* theSender = 0);
567 /// The virtual destructor
568 MODELAPI_EXPORT virtual ~ModelAPI_ReplaceParameterMessage();
570 /// Returns an object
571 MODELAPI_EXPORT ObjectPtr object() const;
573 MODELAPI_EXPORT void setObject(ObjectPtr theObject);
576 /// Message that sends the sketch solver and sketcher GUI processes to show in the property panel
577 class ModelAPI_SolverFailedMessage : public Events_Message
580 /// Creates an message
581 MODELAPI_EXPORT ModelAPI_SolverFailedMessage(const Events_ID theID, const void* theSender = 0);
582 /// Default destructor
583 MODELAPI_EXPORT virtual ~ModelAPI_SolverFailedMessage();
585 /// Sets list of conflicting constraints
586 MODELAPI_EXPORT void setObjects(const std::set<ObjectPtr>& theObjects);
587 /// Returns list of conflicting constraints
588 MODELAPI_EXPORT const std::set<ObjectPtr>& objects() const;
590 /// Sets degrees of freedom
591 void dof(const int theDOF) { myDOF = theDOF; }
592 /// Returns degrees of freedom
593 const int& dof() const { return myDOF; }
596 std::set<ObjectPtr> myObjects;
600 /// Message sent when feature or attribute has been moved.
601 /// Stores the moving object/attribute, original and new positions of mouse.
602 class ModelAPI_ObjectMovedMessage : public Events_Message
604 ObjectPtr myMovedObject;
605 AttributePtr myMovedAttribute;
606 int myMovedPointIndex;
608 std::shared_ptr<GeomAPI_Pnt2d> myOriginalPosition;
609 std::shared_ptr<GeomAPI_Pnt2d> myCurrentPosition;
612 MODELAPI_EXPORT ModelAPI_ObjectMovedMessage(const void* theSender = 0);
614 /// Set object which is being moved (if the message already contains attribute it will be cleared)
615 MODELAPI_EXPORT void setMovedObject(const ObjectPtr& theMovedObject);
616 /// Set attribute which is being moved (if the message already contains object it will be cleared)
617 /// \param[in] theMovedAttribute moved attribute
618 /// \param[in] thePointIndex index of the point if the moved attribute is an array of points
619 MODELAPI_EXPORT void setMovedAttribute(const AttributePtr& theMovedAttribute,
620 const int thePointIndex = -1);
622 /// Return moved object
623 ObjectPtr movedObject() const
624 { return myMovedObject; }
625 /// Return moved attribute
626 AttributePtr movedAttribute() const
627 { return myMovedAttribute; }
628 /// Return index of the moved point
629 int movedPointIndex() const
630 { return myMovedPointIndex; }
632 /// Set original mouse position
633 MODELAPI_EXPORT void setOriginalPosition(double theX, double theY);
634 /// Set original mouse position
635 MODELAPI_EXPORT void setOriginalPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
636 /// Return original mouse position
637 const std::shared_ptr<GeomAPI_Pnt2d>& originalPosition() const
638 { return myOriginalPosition; }
640 /// Set current mouse position
641 MODELAPI_EXPORT void setCurrentPosition(double theX, double theY);
642 /// Set current mouse position
643 MODELAPI_EXPORT void setCurrentPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
644 /// Return current mouse position
645 const std::shared_ptr<GeomAPI_Pnt2d>& currentPosition() const
646 { return myCurrentPosition; }
649 /// Message that sends the failed vertices of 1D-fillet to highlight them in 3D viewer
650 class ModelAPI_ShapesFailedMessage : public Events_Message
653 /// Creates an message
654 MODELAPI_EXPORT ModelAPI_ShapesFailedMessage(const Events_ID theID, const void* theSender = 0);
655 /// Default destructor
656 MODELAPI_EXPORT virtual ~ModelAPI_ShapesFailedMessage();
657 /// Static. Returns EventID of the message.
658 MODELAPI_EXPORT static Events_ID eventId()
660 return Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED);
663 /// Sets list of failed vertices
664 MODELAPI_EXPORT void setShapes(const std::list< std::shared_ptr<GeomAPI_Shape> >& theVertices);
665 /// Returns list of failed vertices
666 MODELAPI_EXPORT const std::list< std::shared_ptr<GeomAPI_Shape> >& shapes() const;
669 std::list< std::shared_ptr<GeomAPI_Shape> > myShapes;
672 ///Message that sends the constraints to check or remove
673 class ModelAPI_CheckConstraintsMessage : public Events_Message
676 /// Creates an empty message
677 MODELAPI_EXPORT ModelAPI_CheckConstraintsMessage(
678 const Events_ID theID, const void* theSender = 0);
679 /// The virtual destructor
680 MODELAPI_EXPORT virtual ~ModelAPI_CheckConstraintsMessage();
682 ///Get list of constrains
683 MODELAPI_EXPORT const std::set<ObjectPtr>& constraints() const;
685 ///Set list of constrains
686 MODELAPI_EXPORT void setConstraints(const std::set<ObjectPtr>& theConstraints);
689 std::set<ObjectPtr> myConstraints;
693 /// Message that sends the features which license is checked and valid
694 class ModelAPI_FeaturesLicenseValidMessage : public Events_Message
697 /// Creates an message
699 ModelAPI_FeaturesLicenseValidMessage(const Events_ID theID, const void* theSender = 0);
700 /// Default destructor
701 MODELAPI_EXPORT virtual ~ModelAPI_FeaturesLicenseValidMessage();
702 /// Static. Returns EventID of the message.
703 MODELAPI_EXPORT static Events_ID eventId()
705 return Events_Loop::eventByName(EVENT_FEATURE_LICENSE_VALID);
708 /// Sets list of features with valid license
709 MODELAPI_EXPORT void setFeatures(const std::set<std::string>& theFeatures);
710 /// Returns list of features with valid license
711 MODELAPI_EXPORT const std::set<std::string>& features() const;
714 std::set<std::string> myFeatures;