MeVisLab Toolbox Reference
CSOEvent.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2012, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 
18 
19 #pragma once
20 
21 
22 #include "../MLCSOIncludes.h"
23 
24 
25 ML_START_NAMESPACE
26 
27 //---------------------------------------------------------------------------
28 
39 {
40 public:
41 
42  // NOTE: if you change the enum CSOEventType, you need to accommodate the list of event names
43  // in CSOManager.cpp :: baseEventCB
44 
45  // NOTE: also accommodate the CSOEventWrapper
46 
49  {
50  NONE = 0,
51 
53 
56 
61 
73 
83 
92 
102 
105 
106  NUM_CSO_EVENTS
107  };
108 
111  {
112  _isPostCommand = true;
113  _eventType = NONE;
114  _moduleEventGroupId = 0;
115  }
116 
118  CSOEvent(CSOEventType eventTypeArg, bool isPostCommandArg=true)
119  {
120  _eventType = eventTypeArg;
121  _isPostCommand = isPostCommandArg;
122  _moduleEventGroupId = 0;
123  }
124 
126  CSOEvent& operator = (const CSOEvent& event);
127 
129  bool hasCSOIds() const { return _csoIds.size() > 0; }
131  bool hasGroupIds() const { return _groupIds.size() > 0; }
132 
134  void addCSOId(unsigned int id);
136  void addGroupId(unsigned int id);
137 
139  void addCSOIds(const CSOIdVector& csoIds);
141  void addGroupIds(const CSOIdVector& groupIds);
142 
144  const CSOIdVector& csoIds() const { return _csoIds; }
146  const CSOIdVector& groupIds() const { return _groupIds; }
147 
149  CSOEventType eventType() const { return _eventType; }
150 
152  static std::string getEventTypeName(CSOEventType eventType);
153 
155  void setEventType(CSOEventType eventTypeArg) { _eventType = eventTypeArg; }
156 
158  bool isPostCommand() const { return _isPostCommand; }
160  bool isPreCommand() const { return !_isPostCommand; }
162  void setIsPostCommand(bool flag) { _isPostCommand = flag; }
163 
165  void setSenderType(const std::string& senderTypeArg) { _senderType = senderTypeArg; }
167  std::string senderType() const { return _senderType; }
168 
170  void setSenderName(const std::string& senderNameArg) { _senderName = senderNameArg; }
172  std::string senderName() const { return _senderName; }
173 
175  void setCustomMessage(const std::string& customMessageArg) { _customMessage = customMessageArg; }
177  std::string customMessage() const { return _customMessage; }
178 
180  void setModuleEventGroupId(MLuint64 id) { _moduleEventGroupId = id; }
182  MLuint64 moduleEventGroupId() const { return _moduleEventGroupId; }
183 
185 
186 protected:
187 
196 
197  // type of event sender
198  std::string _senderType;
199  // instance name of event sender
200  std::string _senderName;
201  // some custom message if events are generated by scripting
202  std::string _customMessage;
203  // a unique id to check whether opening/closing module events match
205 };
206 
207 //---------------------------------------------------------------------------
208 
209 ML_END_NAMESPACE
std::vector< unsigned int > CSOIdVector
Defines a vector to hold CSO and CSOGroup ids.
Definition: MLCSOIncludes.h:63
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition: MLCSOSystem.h:23
BaseEvent is the base class for all events emitted from EventSourceBase.
Definition: mlEventSource.h:86
Class for all CSO events.
Definition: CSOEvent.h:39
CSOEvent()
Standard constructor.
Definition: CSOEvent.h:110
std::string _senderName
Definition: CSOEvent.h:200
MLuint64 moduleEventGroupId() const
Returns a unique module group event id.
Definition: CSOEvent.h:182
bool isPreCommand() const
Returns whether the event is a pre command.
Definition: CSOEvent.h:160
void addCSOIds(const CSOIdVector &csoIds)
Adds all given CSO ids if an id is not INVALID_CSO_ID.
std::string customMessage() const
Returns the custom message string. This can be used to identify the method or the subroutine from whe...
Definition: CSOEvent.h:177
CSOEventType _eventType
The event type.
Definition: CSOEvent.h:193
CSOEventType
Enumeration for specifying the exact type of event.
Definition: CSOEvent.h:49
@ CSO_SHOW_STATE
Definition: CSOEvent.h:78
@ CSOLIST_CLONE
Definition: CSOEvent.h:58
@ CSO_VISUAL_ATTRIBUTE_CHANGE
Definition: CSOEvent.h:74
@ GROUP_SELECTION_CHANGE
Definition: CSOEvent.h:90
@ GROUP_VISUAL_ATTRIBUTE_CHANGE
Definition: CSOEvent.h:93
@ CSO_MODIFICATION
Definition: CSOEvent.h:64
@ CSO_EDITABLE_STATE
Definition: CSOEvent.h:79
@ GROUP_TIMEPOINT_INDEX
Definition: CSOEvent.h:96
@ CSO_SELECTION_CHANGE
Definition: CSOEvent.h:71
@ CSO_MOUSE_OVER_CHANGE
Definition: CSOEvent.h:70
@ GROUP_DESCRIPTION
Definition: CSOEvent.h:95
@ CSOLIST_CLEAR
Definition: CSOEvent.h:57
@ GROUP_REMOVE
Definition: CSOEvent.h:85
@ CSO_VOXEL_WRITE_VALUE
Definition: CSOEvent.h:82
@ CSO_TIMEPOINT_INDEX
Definition: CSOEvent.h:77
@ CSO_DESCRIPTION
Definition: CSOEvent.h:76
@ CSOLIST_EVENT_GROUP_CLOSE
Definition: CSOEvent.h:55
@ CSOLIST_MERGE
Definition: CSOEvent.h:59
@ GROUP_VOXEL_WRITE_VALUE
Definition: CSOEvent.h:101
@ GROUP_SHOW_STATE
Definition: CSOEvent.h:97
@ GROUP_EDITABLE_STATE
Definition: CSOEvent.h:98
@ CSO_ADD_TO_GROUP
Definition: CSOEvent.h:88
@ CSO_DELETE_SEEDPOINT
Definition: CSOEvent.h:69
@ MODULE_EVENT
Definition: CSOEvent.h:52
@ CSO_INTERACTION
Definition: CSOEvent.h:103
@ CSOLIST_LOAD
Definition: CSOEvent.h:60
@ CSOLIST_EVENT_GROUP_OPEN
Definition: CSOEvent.h:54
@ CSO_VOXELIZE_STATE
Definition: CSOEvent.h:80
@ CSO_USER_DATA_CHANGE
Definition: CSOEvent.h:72
@ CSO_GEOMETRY_CHANGE
Definition: CSOEvent.h:68
@ GROUP_USER_DATA_CHANGE
Definition: CSOEvent.h:91
@ CSO_REMOVE_FROM_GROUP
Definition: CSOEvent.h:89
@ CSO_VOXEL_WRITE_MODE
Definition: CSOEvent.h:81
@ GROUP_VOXELIZE_STATE
Definition: CSOEvent.h:99
@ GROUP_VOXEL_WRITE_MODE
Definition: CSOEvent.h:100
std::string senderName() const
Returns the sender name string. This is typically the module instance name from where the event is se...
Definition: CSOEvent.h:172
CSOIdVector _groupIds
Vector of CSOGroup ids.
Definition: CSOEvent.h:191
const CSOIdVector & csoIds() const
Returns the vector with CSO ids.
Definition: CSOEvent.h:144
void addCSOId(unsigned int id)
Adds a CSO id if id is not INVALID_CSO_ID.
CSOIdVector _csoIds
Vector of CSO ids.
Definition: CSOEvent.h:189
void addGroupId(unsigned int id)
Adds a CSOGroup id if id is not INVALID_CSO_ID.
static std::string getEventTypeName(CSOEventType eventType)
Maps event types to strings with their name.
void setSenderType(const std::string &senderTypeArg)
Sets the sender type string. This is typically the module type from where the event is sent.
Definition: CSOEvent.h:165
std::string _customMessage
Definition: CSOEvent.h:202
ML_CLASS_HEADER(CSOEvent)
void setModuleEventGroupId(MLuint64 id)
Sets a unique event id. This is done by the module group scope class. No need to temper with it.
Definition: CSOEvent.h:180
CSOEvent(CSOEventType eventTypeArg, bool isPostCommandArg=true)
Constructor taking an event type and whether it is a pre/post command.
Definition: CSOEvent.h:118
bool hasGroupIds() const
Returns whether CSOGroup ids are registered with this event.
Definition: CSOEvent.h:131
bool _isPostCommand
Whether it is a pre or post command.
Definition: CSOEvent.h:195
std::string _senderType
Definition: CSOEvent.h:198
CSOEventType eventType() const
Returns the event type.
Definition: CSOEvent.h:149
void setEventType(CSOEventType eventTypeArg)
Sets the event type.
Definition: CSOEvent.h:155
MLuint64 _moduleEventGroupId
Definition: CSOEvent.h:204
bool isPostCommand() const
Returns whether the event is a post command.
Definition: CSOEvent.h:158
void setCustomMessage(const std::string &customMessageArg)
Sets the custom message string. This can be used to identify the method or the subroutine from where ...
Definition: CSOEvent.h:175
void setIsPostCommand(bool flag)
Sets whether the event is a pre or post command.
Definition: CSOEvent.h:162
void setSenderName(const std::string &senderNameArg)
Sets the sender name string. This is typically the module instance name from where the event is sent.
Definition: CSOEvent.h:170
std::string senderType() const
Returns the sender type string. This is typically the module type from where the event is sent.
Definition: CSOEvent.h:167
const CSOIdVector & groupIds() const
Returns the vector with CSOGroup ids.
Definition: CSOEvent.h:146
bool hasCSOIds() const
Returns whether CSO ids are registered with this event.
Definition: CSOEvent.h:129
void addGroupIds(const CSOIdVector &groupIds)
Adds all given CSOGroup ids if an id is not INVALID_CSO_ID.
UINT64 MLuint64
Introduce platform independent 64 bit unsigned integer type.
Definition: mlTypeDefs.h:513