Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
40class vtkPersonInformation;
41class vtkSlicerTask;
42class ModifiedQueue;
43class ProcessingTaskQueue;
44class ReadDataQueue;
45class ReadDataRequest;
46class WriteDataQueue;
47class WriteDataRequest;
48
49class VTK_SLICER_BASE_LOGIC_EXPORT vtkSlicerApplicationLogic : public vtkMRMLApplicationLogic
50{
51public:
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
64 void SetMRMLSceneDataIO(vtkMRMLScene* scene, vtkMRMLRemoteIOLogic* remoteIOLogic, vtkDataIOManagerLogic* dataIOManagerLogic);
65
68
83
88
98 vtkMTimeType RequestModified(vtkObject*);
99
108 vtkMTimeType RequestReadFile(const char* refNode, const char* filename, int displayData = false, int deleteFile = false);
109
116 vtkMTimeType RequestUpdateParentTransform(const std::string& updatedNode, const std::string& parentTransformNode);
117
124 vtkMTimeType RequestUpdateSubjectHierarchyLocation(const std::string& updatedNode, const std::string& siblingNode);
125
132 vtkMTimeType RequestAddNodeReference(const std::string& referencingNode, const std::string& referencedNode, const std::string& role);
133
137 unsigned int GetReadDataQueueSize();
138
144 vtkMTimeType RequestWriteData(const char* refNode, const char* filename);
145
156 vtkMTimeType RequestReadScene(const std::string& filename,
157 std::vector<std::string>& targetIDs,
158 std::vector<std::string>& sourceIDs,
159 int displayData = false,
160 int deleteFile = false);
161
167
173
176
180 void SetTracingOn() { this->Tracing = 1; }
181 void SetTracingOff() { this->Tracing = 0; }
182
188 static bool IsEmbeddedModule(const std::string& filePath, const std::string& applicationHomeDir, const std::string& slicerRevision);
189
194 static bool IsPluginInstalled(const std::string& filePath, const std::string& applicationHomeDir);
195
197 static bool IsPluginBuiltIn(const std::string& filePath, const std::string& applicationHomeDir, const std::string& slicerRevision);
198
200 static std::string GetModuleShareDirectory(const std::string& moduleName, const std::string& filePath);
201
203 static std::string GetModuleSlicerXYShareDirectory(const std::string& filePath);
204
206 static std::string GetModuleSlicerXYLibDirectory(const std::string& filePath);
207
210 vtkPersonInformation* GetUserInformation();
211
214 static void RequestModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
215
234
235protected:
238
241
244
247
250
255 void ProcessReadSceneData(ReadDataRequest& req);
256 void ProcessWriteSceneData(WriteDataRequest& req);
257
263
264private:
266 void operator=(const vtkSlicerApplicationLogic&);
267
268 std::mutex ProcessingThreadActiveLock;
269 std::mutex ProcessingTaskQueueLock;
270 std::mutex ModifiedQueueActiveLock;
271 std::mutex ModifiedQueueLock;
272 std::mutex ReadDataQueueActiveLock;
273 std::mutex ReadDataQueueLock;
274 std::mutex WriteDataQueueActiveLock;
275 std::mutex WriteDataQueueLock;
276 vtkTimeStamp RequestTimeStamp;
277 std::thread ProcessingThread;
278 std::vector<std::thread> NetworkingThreads;
279 int ProcessingThreadActive;
280 int ModifiedQueueActive;
281 int ReadDataQueueActive;
282 int WriteDataQueueActive;
283
284 ProcessingTaskQueue* InternalTaskQueue;
285 ModifiedQueue* InternalModifiedQueue;
286 ReadDataQueue* InternalReadDataQueue;
287 WriteDataQueue* InternalWriteDataQueue;
288
289 vtkPersonInformation* UserInformation;
290
292 int Tracing;
293};
294
295#endif
Superclass for displayable manager classes.
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D,...
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)
vtkMRMLAbstractDisplayableManager * GetViewDisplayableManagerByClassName(vtkMRMLAbstractViewNode *viewNode, const char *className) const
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)