Slicer 5.13
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
110 vtkMTimeType RequestReadFile(const char* refNode, const char* filename, int displayData = false, int deleteFile = false, const char* cliNode = nullptr);
111
118 vtkMTimeType RequestUpdateParentTransform(const std::string& updatedNode, const std::string& parentTransformNode);
119
126 vtkMTimeType RequestUpdateSubjectHierarchyLocation(const std::string& updatedNode, const std::string& siblingNode);
127
134 vtkMTimeType RequestAddNodeReference(const std::string& referencingNode, const std::string& referencedNode, const std::string& role);
135
139 unsigned int GetReadDataQueueSize();
140
146 vtkMTimeType RequestWriteData(const char* refNode, const char* filename);
147
158 vtkMTimeType RequestReadScene(const std::string& filename,
159 std::vector<std::string>& targetIDs,
160 std::vector<std::string>& sourceIDs,
161 int displayData = false,
162 int deleteFile = false);
163
169
175
178
182 void SetTracingOn() { this->Tracing = 1; }
183 void SetTracingOff() { this->Tracing = 0; }
184
194 static bool IsEmbeddedModule(const std::string& filePath, const std::string& applicationHomeDir, const std::string& slicerRevision, const std::string& extensionsDirBase = "");
195
204 static bool IsPluginInstalled(const std::string& filePath,
205 const std::string& applicationHomeDir,
206 const std::string& organizationDomain = "",
207 const std::string& organizationName = "",
208 const std::string& extensionsDirBase = "");
209
213 static bool IsPluginBuiltIn(const std::string& filePath, const std::string& applicationHomeDir, const std::string& slicerRevision, const std::string& extensionsDirBase = "");
214
216 static std::string GetModuleShareDirectory(const std::string& moduleName, const std::string& filePath);
217
219 static std::string GetModuleSlicerXYShareDirectory(const std::string& filePath);
220
222 static std::string GetModuleSlicerXYLibDirectory(const std::string& filePath);
223
226 vtkPersonInformation* GetUserInformation();
227
230 static void RequestModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
231
250
251protected:
254
257
260
263
266
271 void ProcessReadSceneData(ReadDataRequest& req);
272 void ProcessWriteSceneData(WriteDataRequest& req);
273
279
280private:
282 void operator=(const vtkSlicerApplicationLogic&);
283
284 std::mutex ProcessingThreadActiveLock;
285 std::mutex ProcessingTaskQueueLock;
286 std::mutex ModifiedQueueActiveLock;
287 std::mutex ModifiedQueueLock;
288 std::mutex ReadDataQueueActiveLock;
289 std::mutex ReadDataQueueLock;
290 std::mutex WriteDataQueueActiveLock;
291 std::mutex WriteDataQueueLock;
292 vtkTimeStamp RequestTimeStamp;
293 std::thread ProcessingThread;
294 std::vector<std::thread> NetworkingThreads;
295 int ProcessingThreadActive;
296 int ModifiedQueueActive;
297 int ReadDataQueueActive;
298 int WriteDataQueueActive;
299
300 ProcessingTaskQueue* InternalTaskQueue;
301 ModifiedQueue* InternalModifiedQueue;
302 ReadDataQueue* InternalReadDataQueue;
303 WriteDataQueue* InternalWriteDataQueue;
304
305 vtkPersonInformation* UserInformation;
306
308 int Tracing;
309};
310
311#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 IsPluginInstalled(const std::string &filePath, const std::string &applicationHomeDir, const std::string &organizationDomain="", const std::string &organizationName="", const std::string &extensionsDirBase="")
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.
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)
vtkMTimeType RequestReadFile(const char *refNode, const char *filename, int displayData=false, int deleteFile=false, const char *cliNode=nullptr)
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.
static bool IsEmbeddedModule(const std::string &filePath, const std::string &applicationHomeDir, const std::string &slicerRevision, const std::string &extensionsDirBase="")
vtkMTimeType RequestModified(vtkObject *)
void PrintSelf(ostream &os, vtkIndent indent) override
static bool IsPluginBuiltIn(const std::string &filePath, const std::string &applicationHomeDir, const std::string &slicerRevision, const std::string &extensionsDirBase="")
void ProcessWriteData()
Process a request to write data from a referenced node.
static std::string GetModuleShareDirectory(const std::string &moduleName, const std::string &filePath)
Get share directory associated with moduleName located in filePath.
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)