vtkSlicerApplicationLogic.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Slicer3 Application Logic
00004   Module:    $HeadURL: http://svn.slicer.org/Slicer3/trunk/Base/Logic/vtkSlicerApplicationLogic.h $
00005   Language:  C++
00006   Date:      $Date: 2011-01-30 12:51:01 -0500 (Sun, 30 Jan 2011) $
00007   Version:   $Revision: 15856 $
00008 
00009   Copyright (c) Brigham and Women's Hospital (BWH) All Rights Reserved.
00010 
00011   See License.txt or http://www.slicer.org/copyright/copyright.txt for details.
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 //BTX
00040 class ProcessingTaskQueue;
00041 class ModifiedQueue;
00042 class ReadDataQueue;
00043 class ReadDataRequest;
00044 class WriteDataQueue;
00045 class WriteDataRequest;
00046 class vtkSlicerTask;
00047 //ETX
00048 
00049 //BTX
00050 class SliceLogicMap;
00051 //ETX
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   //vtkSetObjectMacro (Views,vtkCollection);
00117   vtkGetObjectMacro (Views,vtkCollection);
00118 
00121   //vtkSetObjectMacro (ActiveView,vtkSlicerViewLogic);
00122   //vtkGetObjectMacro (ActiveView,vtkSlicerViewLogic);
00123 
00128   //vtkSetObjectMacro (Slices,vtkCollection);
00129   //vtkGetObjectMacro (Slices,vtkCollection);
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   //vtkSetObjectMacro (Modules,vtkCollection);
00166   vtkGetObjectMacro (Modules,vtkCollection);
00167 
00170   //vtkSetObjectMacro (ActiveModule,vtkSlicerModule);
00171   //vtkGetObjectMacro (ActiveModule,vtkSlicerModule);
00172 
00175   virtual void ProcessMRMLEvents ( vtkObject * /*caller*/, 
00176                                   unsigned long /*event*/, 
00177                                   void * /*callData*/ );
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   //BTX
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   //ETX
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   //BTX
00328   void ProcessReadNodeData( ReadDataRequest &req );
00329   void ProcessWriteNodeData( WriteDataRequest &req );
00330   //EXT
00331   
00332 
00338   //BTX
00339   void ProcessReadSceneData( ReadDataRequest &req );
00340   void ProcessWriteSceneData( WriteDataRequest &req );
00341   //EXT
00342   
00343 private:
00349   //BTX
00350   SliceLogicMap *InternalSliceLogicMap;
00351   //ETX
00352   
00355   vtkCollection *Views;
00356   //vtkCollection *Slices;
00357   vtkCollection *Modules;
00358 
00359   //vtkSlicerViewLogic *ActiveView;
00360   vtkSlicerSliceLogic *ActiveSlice;
00361   vtkMRMLSelectionNode *SelectionNode;
00362   vtkMRMLInteractionNode *InteractionNode;
00363   //vtkSlicerModuleLogic *ActiveModule;
00364 
00365   //BTX
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   //ETX
00376   int ProcessingThreadId;
00377   //BTX
00378   std::vector<int> NetworkingThreadIDs;
00379   //ETX
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 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1