vtkSlicerApplicationLogic.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00022
00023
00024 #ifndef __vtkSlicerApplicationLogic_h
00025 #define __vtkSlicerApplicationLogic_h
00026
00027 #include "vtkMRMLSelectionNode.h"
00028 #include "vtkMRMLInteractionNode.h"
00029
00030 #include "vtkSlicerBaseLogic.h"
00031 #include "vtkSlicerLogic.h"
00032 #include "vtkSlicerSliceLogic.h"
00033
00034 #include "vtkCollection.h"
00035
00036 #include "itkMultiThreader.h"
00037 #include "itkMutexLock.h"
00038
00039
00040 class ProcessingTaskQueue;
00041 class ModifiedQueue;
00042 class ReadDataQueue;
00043 class ReadDataRequest;
00044 class WriteDataQueue;
00045 class WriteDataRequest;
00046 class vtkSlicerTask;
00047
00048
00049
00050 class SliceLogicMap;
00051
00052
00053 class VTK_SLICER_BASE_LOGIC_EXPORT vtkSlicerApplicationLogic : public vtkSlicerLogic
00054 {
00055 public:
00056
00058 static vtkSlicerApplicationLogic *New();
00059 vtkTypeRevisionMacro(vtkSlicerApplicationLogic,vtkSlicerLogic);
00060 void PrintSelf(ostream& os, vtkIndent indent);
00061
00062
00069 void Connect (const char *URL) {
00070 if (this->MRMLScene)
00071 {
00072 this->MRMLScene->SetURL(URL);
00073 this->MRMLScene->Connect();
00074 }
00075 };
00076
00080 int Commit () {
00081 if (this->MRMLScene)
00082 {
00083 return (this->MRMLScene->Commit());
00084 }
00085 return (0);
00086 };
00090 int Commit (const char *URL) {
00091 if (this->MRMLScene)
00092 {
00093 return (this->MRMLScene->Commit(URL));
00094 }
00095 return (0);
00096 };
00097
00098
00101
00105
00106
00107
00111
00112
00116
00117 vtkGetObjectMacro (Views,vtkCollection);
00118
00121
00122
00123
00128
00129
00130
00133 vtkSetObjectMacro (ActiveSlice,vtkSlicerSliceLogic);
00134 vtkGetObjectMacro (ActiveSlice,vtkSlicerSliceLogic);
00135
00138 vtkSetObjectMacro (SelectionNode,vtkMRMLSelectionNode);
00139 vtkGetObjectMacro (SelectionNode,vtkMRMLSelectionNode);
00140
00143 vtkSetObjectMacro (InteractionNode,vtkMRMLInteractionNode);
00144 vtkGetObjectMacro (InteractionNode,vtkMRMLInteractionNode);
00145
00149 void PropagateVolumeSelection(int fit);
00150 void PropagateVolumeSelection() {this->PropagateVolumeSelection(1);};
00151
00154 void PropagateVolumeLayerSelection(int layer);
00155
00159 void PropagateFiducialListSelection();
00160
00165
00166 vtkGetObjectMacro (Modules,vtkCollection);
00167
00170
00171
00172
00175 virtual void ProcessMRMLEvents ( vtkObject * ,
00176 unsigned long ,
00177 void * );
00178 virtual void ProcessMRMLEvents () { this->ProcessMRMLEvents( NULL, vtkCommand::NoEvent, NULL ); };
00179
00182 void CreateProcessingThread();
00183
00186 void CreateSliceLogics();
00187 void DeleteSliceLogics();
00188
00191 void TerminateProcessingThread();
00192
00197 int ScheduleTask( vtkSlicerTask* );
00198
00205 int RequestModified( vtkObject * );
00206
00212 int RequestReadData(const char *refNode, const char *filename,
00213 int displayData = false,
00214 int deleteFile=false);
00215
00220 unsigned int GetReadDataQueueSize();
00221
00222
00225 int RequestWriteData(const char *refNode, const char *filename,
00226 int displayData = false,
00227 int deleteFile=false);
00235
00236
00237 int RequestReadScene(const std::string& filename,
00238 std::vector<std::string> &targetIDs,
00239 std::vector<std::string> &sourceIDs,
00240 int displayData = false,
00241 int deleteFile = false);
00242
00243
00249 void ProcessModified();
00250
00256 void ProcessReadData();
00259 void ProcessWriteData();
00260
00263 void AddSliceLogic(const char *layoutName, vtkSlicerSliceLogic *sliceLogic);
00264
00268 void AddSliceLogic(vtkSlicerSliceLogic *sliceLogic);
00269
00272 vtkSlicerSliceLogic* GetSliceLogic(const char *layoutName);
00273
00276 void RemoveSliceLogic(vtkSlicerSliceLogic *sliceLogic);
00277 void RemoveSliceLogic(char *layoutName);
00278
00279
00287
00288
00289 void ClearCollections ( );
00290
00291
00296 void SetTracingOn () { this->Tracing = 1; };
00297 void SetTracingOff () { this->Tracing = 0; };
00298
00299 protected:
00300
00301 vtkSlicerApplicationLogic();
00302 ~vtkSlicerApplicationLogic();
00303 vtkSlicerApplicationLogic(const vtkSlicerApplicationLogic&);
00304 void operator=(const vtkSlicerApplicationLogic&);
00305
00308 static ITK_THREAD_RETURN_TYPE ProcessingThreaderCallback( void * );
00309
00312 static ITK_THREAD_RETURN_TYPE NetworkingThreaderCallback( void * );
00313
00316 void ProcessProcessingTasks();
00317
00320 void ProcessNetworkingTasks();
00321
00327
00328 void ProcessReadNodeData( ReadDataRequest &req );
00329 void ProcessWriteNodeData( WriteDataRequest &req );
00330
00331
00332
00338
00339 void ProcessReadSceneData( ReadDataRequest &req );
00340 void ProcessWriteSceneData( WriteDataRequest &req );
00341
00342
00343 private:
00349
00350 SliceLogicMap *InternalSliceLogicMap;
00351
00352
00355 vtkCollection *Views;
00356
00357 vtkCollection *Modules;
00358
00359
00360 vtkSlicerSliceLogic *ActiveSlice;
00361 vtkMRMLSelectionNode *SelectionNode;
00362 vtkMRMLInteractionNode *InteractionNode;
00363
00364
00365
00366 itk::MultiThreader::Pointer ProcessingThreader;
00367 itk::MutexLock::Pointer ProcessingThreadActiveLock;
00368 itk::MutexLock::Pointer ProcessingTaskQueueLock;
00369 itk::MutexLock::Pointer ModifiedQueueActiveLock;
00370 itk::MutexLock::Pointer ModifiedQueueLock;
00371 itk::MutexLock::Pointer ReadDataQueueActiveLock;
00372 itk::MutexLock::Pointer ReadDataQueueLock;
00373 itk::MutexLock::Pointer WriteDataQueueActiveLock;
00374 itk::MutexLock::Pointer WriteDataQueueLock;
00375
00376 int ProcessingThreadId;
00377
00378 std::vector<int> NetworkingThreadIDs;
00379
00380 int ProcessingThreadActive;
00381 int ModifiedQueueActive;
00382 int ReadDataQueueActive;
00383 int WriteDataQueueActive;
00384
00385 ProcessingTaskQueue* InternalTaskQueue;
00386 ModifiedQueue* InternalModifiedQueue;
00387 ReadDataQueue* InternalReadDataQueue;
00388 WriteDataQueue* InternalWriteDataQueue;
00389
00391
00393 int Tracing;
00394 };
00395
00396 #endif
00397