Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef mitkToolManager_h_Included
00019 #define mitkToolManager_h_Included
00020
00021 #include "mitkTool.h"
00022 #include "MitkExtExports.h"
00023 #include "mitkDataNode.h"
00024 #include "mitkDataStorage.h"
00025 #include "mitkWeakPointer.h"
00026
00027 #include <itkEventObject.h>
00028
00029 #include <vector>
00030 #include <map>
00031
00032 namespace mitk
00033 {
00034
00035 class Image;
00036 class PlaneGeometry;
00037
00085 class MitkExt_EXPORT ToolManager : public itk::Object
00086 {
00087 public:
00088
00089 typedef std::vector<Tool::Pointer> ToolVectorType;
00090 typedef std::vector<Tool::ConstPointer> ToolVectorTypeConst;
00091 typedef std::vector<DataNode*> DataVectorType;
00092 typedef std::map<DataNode*, unsigned long> NodeTagMapType;
00093
00094 Message<> NodePropertiesChanged;
00095 Message<> NewNodesGenerated;
00096 Message1<DataVectorType*> NewNodeObjectsGenerated;
00097
00098 Message<> ActiveToolChanged;
00099 Message<> ReferenceDataChanged;
00100 Message<> WorkingDataChanged;
00101 Message<> RoiDataChanged;
00102
00103 Message1<std::string> ToolErrorMessage;
00104 Message1<std::string> GeneralToolMessage;
00105
00106 mitkClassMacro(ToolManager, itk::Object);
00107 mitkNewMacro1Param(ToolManager, DataStorage*);
00108
00113 const ToolVectorTypeConst GetTools();
00114
00115 int GetToolID( const Tool* tool );
00116
00117
00118
00119
00120
00121 Tool* GetToolById(int id);
00122
00127 bool ActivateTool(int id);
00128
00129 template <class T>
00130 int GetToolIdByToolType()
00131 {
00132 int id = 0;
00133 for ( ToolVectorType::iterator iter = m_Tools.begin();
00134 iter != m_Tools.end();
00135 ++iter, ++id )
00136 {
00137 if ( dynamic_cast<T*>(iter->GetPointer()) )
00138 {
00139 return id;
00140 }
00141 }
00142 return -1;
00143 }
00144
00148 int GetActiveToolID();
00149
00153 Tool* GetActiveTool();
00154
00155
00156
00157
00158 void SetReferenceData(DataVectorType);
00159
00160
00161
00162
00163 void SetReferenceData(DataNode*);
00164
00165
00166
00167
00168 void SetWorkingData(DataVectorType);
00169
00170
00171
00172
00173 void SetWorkingData(DataNode*);
00174
00175
00176
00177
00178 void SetRoiData(DataVectorType);
00179
00180
00181
00182
00183 void SetRoiData(DataNode*);
00184
00185
00186
00187
00188 DataVectorType GetReferenceData();
00189
00190
00191
00192
00193
00194 DataNode* GetReferenceData(int);
00195
00196
00197
00198
00199 DataVectorType GetWorkingData();
00200
00201
00202
00203
00204
00205 DataNode* GetWorkingData(int);
00206
00207
00208
00209
00210 DataVectorType GetRoiData();
00211
00212
00213
00214
00215 DataNode* GetRoiData(int idx);
00216
00217 DataStorage* GetDataStorage();
00218 void SetDataStorage(DataStorage& storage);
00219
00220
00221
00222
00223
00224
00225
00226 void RegisterClient();
00227
00228
00229
00230
00231
00232
00233
00234 void UnregisterClient();
00235
00236 void OnOneOfTheReferenceDataDeletedConst(const itk::Object* caller, const itk::EventObject& e);
00237 void OnOneOfTheReferenceDataDeleted (itk::Object* caller, const itk::EventObject& e);
00238
00239 void OnOneOfTheWorkingDataDeletedConst(const itk::Object* caller, const itk::EventObject& e);
00240 void OnOneOfTheWorkingDataDeleted (itk::Object* caller, const itk::EventObject& e);
00241
00242 void OnOneOfTheRoiDataDeletedConst(const itk::Object* caller, const itk::EventObject& e);
00243 void OnOneOfTheRoiDataDeleted (itk::Object* caller, const itk::EventObject& e);
00244
00245
00246
00247
00248
00249
00250 void OnToolErrorMessage(std::string s);
00251 void OnGeneralToolMessage(std::string s);
00252
00253 protected:
00254
00260 ToolManager(DataStorage* storage);
00261 virtual ~ToolManager();
00262
00263 ToolVectorType m_Tools;
00264
00265 Tool* m_ActiveTool;
00266 int m_ActiveToolID;
00267
00268 DataVectorType m_ReferenceData;
00269 NodeTagMapType m_ReferenceDataObserverTags;
00270
00271 DataVectorType m_WorkingData;
00272 NodeTagMapType m_WorkingDataObserverTags;
00273
00274 DataVectorType m_RoiData;
00275 NodeTagMapType m_RoiDataObserverTags;
00276
00277 int m_RegisteredClients;
00278
00279 WeakPointer<DataStorage> m_DataStorage;
00280 };
00281
00282 }
00283
00284 #endif
00285