Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkSlicerApplicationLogic.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Copyright (c) Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See License.txt or http://www.slicer.org/copyright/copyright.txt for details.
6 
7 ==========================================================================*/
16 //
17 
18 #ifndef __vtkSlicerApplicationLogic_h
19 #define __vtkSlicerApplicationLogic_h
20 
21 // Slicer includes
22 #include "vtkSlicerBaseLogic.h"
23 
24 // MRMLLogic includes
26 
27 // VTK includes
28 #include <vtkCollection.h>
29 
30 // ITK includes
31 #include <itkPlatformMultiThreader.h>
32 
33 // STL includes
34 #include <mutex>
35 
40 class vtkPersonInformation;
41 class vtkSlicerTask;
42 class ModifiedQueue;
43 class ProcessingTaskQueue;
44 class ReadDataQueue;
45 class ReadDataRequest;
46 class WriteDataQueue;
47 class WriteDataRequest;
48 
49 class VTK_SLICER_BASE_LOGIC_EXPORT vtkSlicerApplicationLogic
51 {
52  public:
53 
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
66  void SetMRMLSceneDataIO(vtkMRMLScene *scene,
67  vtkMRMLRemoteIOLogic *remoteIOLogic,
68  vtkDataIOManagerLogic *dataIOManagerLogic);
69 
70 
72  void CreateProcessingThread();
73 
75  void TerminateProcessingThread();
78  {
79  RequestModifiedEvent = vtkMRMLApplicationLogic::RequestInvokeEvent + 1,
86  RequestProcessedEvent
87  };
88 
92  int ScheduleTask( vtkSlicerTask* );
93 
103  vtkMTimeType RequestModified(vtkObject *);
104 
113  vtkMTimeType RequestReadFile(const char *refNode, const char *filename,
114  int displayData = false, int deleteFile = false);
115 
122  vtkMTimeType RequestUpdateParentTransform(const std::string &updatedNode, const std::string& parentTransformNode);
123 
130  vtkMTimeType RequestUpdateSubjectHierarchyLocation(const std::string &updatedNode, const std::string& siblingNode);
131 
138  vtkMTimeType RequestAddNodeReference(const std::string &referencingNode, const std::string& referencedNode, const std::string& role);
139 
143  unsigned int GetReadDataQueueSize();
144 
145 
151  vtkMTimeType RequestWriteData(const char *refNode, const char *filename);
152 
163  vtkMTimeType RequestReadScene(const std::string& filename,
164  std::vector<std::string> &targetIDs,
165  std::vector<std::string> &sourceIDs,
166  int displayData = false,
167  int deleteFile = false);
168 
173  void ProcessModified();
174 
179  void ProcessReadData();
180 
182  void ProcessWriteData();
183 
187  void SetTracingOn () { this->Tracing = 1; }
188  void SetTracingOff () { this->Tracing = 0; }
189 
195  static bool IsEmbeddedModule(const std::string& filePath, const std::string& applicationHomeDir,
196  const std::string& slicerRevision);
197 
202  static bool IsPluginInstalled(const std::string& filePath, const std::string& applicationHomeDir);
203 
205  static bool IsPluginBuiltIn(const std::string& filePath, const std::string& applicationHomeDir,
206  const std::string& slicerRevision);
207 
209  static std::string GetModuleShareDirectory(const std::string& moduleName, const std::string& filePath);
210 
212  static std::string GetModuleSlicerXYShareDirectory(const std::string& filePath);
213 
215  static std::string GetModuleSlicerXYLibDirectory(const std::string& filePath);
216 
219  vtkPersonInformation* GetUserInformation();
220 
223  static void RequestModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
224 
225 protected:
226 
228  ~vtkSlicerApplicationLogic() override;
229 
231  static itk::ITK_THREAD_RETURN_TYPE ProcessingThreaderCallback( void * );
232 
234  static itk::ITK_THREAD_RETURN_TYPE NetworkingThreaderCallback( void * );
235 
237  void ProcessProcessingTasks();
238 
240  void ProcessNetworkingTasks();
241 
246  void ProcessReadSceneData( ReadDataRequest &req );
247  void ProcessWriteSceneData( WriteDataRequest &req );
248 
253  virtual void SetCurrentThreadPriorityToBackground();
254 
255 private:
257  void operator=(const vtkSlicerApplicationLogic&);
258 
259  itk::PlatformMultiThreader::Pointer ProcessingThreader;
260  std::mutex ProcessingThreadActiveLock;
261  std::mutex ProcessingTaskQueueLock;
262  std::mutex ModifiedQueueActiveLock;
263  std::mutex ModifiedQueueLock;
264  std::mutex ReadDataQueueActiveLock;
265  std::mutex ReadDataQueueLock;
266  std::mutex WriteDataQueueActiveLock;
267  std::mutex WriteDataQueueLock;
268  vtkTimeStamp RequestTimeStamp;
269  int ProcessingThreadId;
270  std::vector<int> NetworkingThreadIDs;
271  int ProcessingThreadActive;
272  int ModifiedQueueActive;
273  int ReadDataQueueActive;
274  int WriteDataQueueActive;
275 
276  ProcessingTaskQueue* InternalTaskQueue;
277  ModifiedQueue* InternalModifiedQueue;
278  ReadDataQueue* InternalReadDataQueue;
279  WriteDataQueue* InternalWriteDataQueue;
280 
281  vtkPersonInformation* UserInformation;
282 
284  int Tracing;
285 };
286 
287 #endif
static vtkMRMLApplicationLogic * New()
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
RequestEvents
List of events potentially fired by the application logic.
MRML node for storing information about the active nodes in the scene.
void PrintSelf(ostream &os, vtkIndent indent) override