Slicer  4.11
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 
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 
73  void PropagateFiducialListSelection();
74 
76  void CreateProcessingThread();
77 
79  void TerminateProcessingThread();
82  {
83  RequestModifiedEvent = vtkMRMLApplicationLogic::RequestInvokeEvent + 1,
90  RequestProcessedEvent
91  };
92 
96  int ScheduleTask( vtkSlicerTask* );
97 
107  vtkMTimeType RequestModified(vtkObject *);
108 
117  vtkMTimeType RequestReadFile(const char *refNode, const char *filename,
118  int displayData = false, int deleteFile = false);
119 
126  vtkMTimeType RequestUpdateParentTransform(const std::string &updatedNode, const std::string& parentTransformNode);
127 
134  vtkMTimeType RequestUpdateSubjectHierarchyLocation(const std::string &updatedNode, const std::string& siblingNode);
135 
142  vtkMTimeType RequestAddNodeReference(const std::string &referencingNode, const std::string& referencedNode, const std::string& role);
143 
147  unsigned int GetReadDataQueueSize();
148 
149 
155  vtkMTimeType RequestWriteData(const char *refNode, const char *filename);
156 
167  vtkMTimeType RequestReadScene(const std::string& filename,
168  std::vector<std::string> &targetIDs,
169  std::vector<std::string> &sourceIDs,
170  int displayData = false,
171  int deleteFile = false);
172 
177  void ProcessModified();
178 
183  void ProcessReadData();
184 
186  void ProcessWriteData();
187 
191  void SetTracingOn () { this->Tracing = 1; }
192  void SetTracingOff () { this->Tracing = 0; }
193 
199  static bool IsEmbeddedModule(const std::string& filePath, const std::string& applicationHomeDir,
200  const std::string& slicerRevision);
201 
206  static bool IsPluginInstalled(const std::string& filePath, const std::string& applicationHomeDir);
207 
209  static bool IsPluginBuiltIn(const std::string& filePath, const std::string& applicationHomeDir);
210 
212  static std::string GetModuleShareDirectory(const std::string& moduleName, const std::string& filePath);
213 
215  static std::string GetModuleSlicerXYShareDirectory(const std::string& filePath);
216 
218  static std::string GetModuleSlicerXYLibDirectory(const std::string& filePath);
219 
222  vtkPersonInformation* GetUserInformation();
223 
224 protected:
225 
227  ~vtkSlicerApplicationLogic() override;
228 
230  static itk::ITK_THREAD_RETURN_TYPE ProcessingThreaderCallback( void * );
231 
233  static itk::ITK_THREAD_RETURN_TYPE NetworkingThreaderCallback( void * );
234 
236  void ProcessProcessingTasks();
237 
239  void ProcessNetworkingTasks();
240 
245  void ProcessReadSceneData( ReadDataRequest &req );
246  void ProcessWriteSceneData( WriteDataRequest &req );
247 
248 private:
250  void operator=(const vtkSlicerApplicationLogic&);
251 
252  itk::PlatformMultiThreader::Pointer ProcessingThreader;
253  std::mutex ProcessingThreadActiveLock;
254  std::mutex ProcessingTaskQueueLock;
255  std::mutex ModifiedQueueActiveLock;
256  std::mutex ModifiedQueueLock;
257  std::mutex ReadDataQueueActiveLock;
258  std::mutex ReadDataQueueLock;
259  std::mutex WriteDataQueueActiveLock;
260  std::mutex WriteDataQueueLock;
261  vtkTimeStamp RequestTimeStamp;
262  int ProcessingThreadId;
263  std::vector<int> NetworkingThreadIDs;
264  int ProcessingThreadActive;
265  int ModifiedQueueActive;
266  int ReadDataQueueActive;
267  int WriteDataQueueActive;
268 
269  ProcessingTaskQueue* InternalTaskQueue;
270  ModifiedQueue* InternalModifiedQueue;
271  ReadDataQueue* InternalReadDataQueue;
272  WriteDataQueue* InternalWriteDataQueue;
273 
274  vtkPersonInformation* UserInformation;
275 
277  int Tracing;
278 };
279 
280 #endif
static vtkMRMLApplicationLogic * New()
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:56
RequestEvents
List of events potentially fired by the application logic.
vtkPersonInformation - specify name and other information to identify a person.
MRML node for storing information about the active nodes in the scene.
void PrintSelf(ostream &os, vtkIndent indent) override