Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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// STL includes
31#include <mutex>
32#include <thread>
33
38class vtkPersonInformation;
39class vtkSlicerTask;
40class ModifiedQueue;
41class ProcessingTaskQueue;
42class ReadDataQueue;
43class ReadDataRequest;
44class WriteDataQueue;
45class WriteDataRequest;
46
47class VTK_SLICER_BASE_LOGIC_EXPORT vtkSlicerApplicationLogic
49{
50 public:
51
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
65 vtkMRMLRemoteIOLogic *remoteIOLogic,
66 vtkDataIOManagerLogic *dataIOManagerLogic);
67
68
71
86
91
101 vtkMTimeType RequestModified(vtkObject *);
102
111 vtkMTimeType RequestReadFile(const char *refNode, const char *filename,
112 int displayData = false, int deleteFile = false);
113
120 vtkMTimeType RequestUpdateParentTransform(const std::string &updatedNode, const std::string& parentTransformNode);
121
128 vtkMTimeType RequestUpdateSubjectHierarchyLocation(const std::string &updatedNode, const std::string& siblingNode);
129
136 vtkMTimeType RequestAddNodeReference(const std::string &referencingNode, const std::string& referencedNode, const std::string& role);
137
141 unsigned int GetReadDataQueueSize();
142
143
149 vtkMTimeType RequestWriteData(const char *refNode, const char *filename);
150
161 vtkMTimeType RequestReadScene(const std::string& filename,
162 std::vector<std::string> &targetIDs,
163 std::vector<std::string> &sourceIDs,
164 int displayData = false,
165 int deleteFile = false);
166
172
178
181
185 void SetTracingOn () { this->Tracing = 1; }
186 void SetTracingOff () { this->Tracing = 0; }
187
193 static bool IsEmbeddedModule(const std::string& filePath, const std::string& applicationHomeDir,
194 const std::string& slicerRevision);
195
200 static bool IsPluginInstalled(const std::string& filePath, const std::string& applicationHomeDir);
201
203 static bool IsPluginBuiltIn(const std::string& filePath, const std::string& applicationHomeDir,
204 const std::string& slicerRevision);
205
207 static std::string GetModuleShareDirectory(const std::string& moduleName, const std::string& filePath);
208
210 static std::string GetModuleSlicerXYShareDirectory(const std::string& filePath);
211
213 static std::string GetModuleSlicerXYLibDirectory(const std::string& filePath);
214
217 vtkPersonInformation* GetUserInformation();
218
221 static void RequestModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
222
223protected:
224
227
230
233
236
239
244 void ProcessReadSceneData( ReadDataRequest &req );
245 void ProcessWriteSceneData( WriteDataRequest &req );
246
252
253private:
255 void operator=(const vtkSlicerApplicationLogic&);
256
257 std::mutex ProcessingThreadActiveLock;
258 std::mutex ProcessingTaskQueueLock;
259 std::mutex ModifiedQueueActiveLock;
260 std::mutex ModifiedQueueLock;
261 std::mutex ReadDataQueueActiveLock;
262 std::mutex ReadDataQueueLock;
263 std::mutex WriteDataQueueActiveLock;
264 std::mutex WriteDataQueueLock;
265 vtkTimeStamp RequestTimeStamp;
266 std::thread ProcessingThread;
267 std::vector<std::thread> NetworkingThreads;
268 int ProcessingThreadActive;
269 int ModifiedQueueActive;
270 int ReadDataQueueActive;
271 int WriteDataQueueActive;
272
273 ProcessingTaskQueue* InternalTaskQueue;
274 ModifiedQueue* InternalModifiedQueue;
275 ReadDataQueue* InternalReadDataQueue;
276 WriteDataQueue* InternalWriteDataQueue;
277
278 vtkPersonInformation* UserInformation;
279
281 int Tracing;
282};
283
284#endif
A set of MRML Nodes that supports serialization and undo/redo.
MRML node for storing information about the active nodes in the scene.
vtkMTimeType RequestAddNodeReference(const std::string &referencingNode, const std::string &referencedNode, const std::string &role)
static bool IsEmbeddedModule(const std::string &filePath, const std::string &applicationHomeDir, const std::string &slicerRevision)
unsigned int GetReadDataQueueSize()
static void RequestModifiedCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
static void ProcessingThreaderCallback(vtkSlicerApplicationLogic *appLogic)
Callback used by a std::thread to start a processing thread.
void CreateProcessingThread()
Create a thread for processing.
vtkMTimeType RequestReadScene(const std::string &filename, std::vector< std::string > &targetIDs, std::vector< std::string > &sourceIDs, int displayData=false, int deleteFile=false)
RequestEvents
List of events potentially fired by the application logic.
static bool IsPluginBuiltIn(const std::string &filePath, const std::string &applicationHomeDir, const std::string &slicerRevision)
Return true if the plugin identified with its filePath is a built-in Slicer module.
void TerminateProcessingThread()
Shutdown the processing thread.
static vtkSlicerApplicationLogic * New()
The Usual vtk class functions.
void SetMRMLSceneDataIO(vtkMRMLScene *scene, vtkMRMLRemoteIOLogic *remoteIOLogic, vtkDataIOManagerLogic *dataIOManagerLogic)
vtkMTimeType RequestWriteData(const char *refNode, const char *filename)
static std::string GetModuleSlicerXYShareDirectory(const std::string &filePath)
Get Slicer-X.Y share directory associated with module located in filePath.
vtkPersonInformation * GetUserInformation()
int ScheduleTask(vtkSlicerTask *)
vtkMTimeType RequestUpdateSubjectHierarchyLocation(const std::string &updatedNode, const std::string &siblingNode)
void ProcessProcessingTasks()
Task processing loop that is run in the processing thread.
~vtkSlicerApplicationLogic() override
static std::string GetModuleSlicerXYLibDirectory(const std::string &filePath)
Get Slicer-X.Y lib directory associated with module located in filePath.
static void NetworkingThreaderCallback(vtkSlicerApplicationLogic *appLogic)
Callback used by a std::thread to start a networking thread.
vtkMTimeType RequestModified(vtkObject *)
void PrintSelf(ostream &os, vtkIndent indent) override
void ProcessWriteData()
Process a request to write data from a referenced node.
static bool IsPluginInstalled(const std::string &filePath, const std::string &applicationHomeDir)
static std::string GetModuleShareDirectory(const std::string &moduleName, const std::string &filePath)
Get share directory associated with moduleName located in filePath.
vtkMTimeType RequestReadFile(const char *refNode, const char *filename, int displayData=false, int deleteFile=false)
void ProcessNetworkingTasks()
Networking Task processing loop that is run in a networking thread.
vtkMTimeType RequestUpdateParentTransform(const std::string &updatedNode, const std::string &parentTransformNode)
void ProcessWriteSceneData(WriteDataRequest &req)
virtual void SetCurrentThreadPriorityToBackground()
void ProcessReadSceneData(ReadDataRequest &req)