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 
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 
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 
226  static void RequestModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
227 
228 protected:
229 
231  ~vtkSlicerApplicationLogic() override;
232 
234  static itk::ITK_THREAD_RETURN_TYPE ProcessingThreaderCallback( void * );
235 
237  static itk::ITK_THREAD_RETURN_TYPE NetworkingThreaderCallback( void * );
238 
240  void ProcessProcessingTasks();
241 
243  void ProcessNetworkingTasks();
244 
249  void ProcessReadSceneData( ReadDataRequest &req );
250  void ProcessWriteSceneData( WriteDataRequest &req );
251 
256  virtual void SetCurrentThreadPriorityToBackground();
257 
258 private:
260  void operator=(const vtkSlicerApplicationLogic&);
261 
262  itk::PlatformMultiThreader::Pointer ProcessingThreader;
263  std::mutex ProcessingThreadActiveLock;
264  std::mutex ProcessingTaskQueueLock;
265  std::mutex ModifiedQueueActiveLock;
266  std::mutex ModifiedQueueLock;
267  std::mutex ReadDataQueueActiveLock;
268  std::mutex ReadDataQueueLock;
269  std::mutex WriteDataQueueActiveLock;
270  std::mutex WriteDataQueueLock;
271  vtkTimeStamp RequestTimeStamp;
272  int ProcessingThreadId;
273  std::vector<int> NetworkingThreadIDs;
274  int ProcessingThreadActive;
275  int ModifiedQueueActive;
276  int ReadDataQueueActive;
277  int WriteDataQueueActive;
278 
279  ProcessingTaskQueue* InternalTaskQueue;
280  ModifiedQueue* InternalModifiedQueue;
281  ReadDataQueue* InternalReadDataQueue;
282  WriteDataQueue* InternalWriteDataQueue;
283 
284  vtkPersonInformation* UserInformation;
285 
287  int Tracing;
288 };
289 
290 #endif
static vtkMRMLApplicationLogic * New()
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
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