Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkSlicerCLIModuleLogic.h
Go to the documentation of this file.
1/*=auto=========================================================================
2
3 Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH)
4 All Rights Reserved.
5
6 See COPYRIGHT.txt
7 or http://www.slicer.org/copyright/copyright.txt for details.
8
9 Program: 3D Slicer
10
11=========================================================================auto=*/
12
13#ifndef __vtkSlicerCLIModuleLogic_h
14#define __vtkSlicerCLIModuleLogic_h
15
16// Slicer includes
18
19// MRMLCLI includes
21class ModuleDescription;
22class ModuleParameter;
23
24// MRML include
25#include "vtkMRMLScene.h"
27class MRMLIDMap;
28
29// STL includes
30#include <string>
31
32#include "qSlicerBaseQTCLIExport.h"
33
40class Q_SLICER_BASE_QTCLI_EXPORT vtkSlicerCLIModuleLogic :
42{
43public:
50
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
57 void SetDefaultModuleDescription(const ModuleDescription& moduleDescription);
58 const ModuleDescription& GetDefaultModuleDescription()const;
59
64 bool SetDefaultParameterValue(const std::string& name, const std::string& value);
65
69 std::string GetDefaultParameterValue(const std::string& name) const;
70
77
83
84 // TODO: do we need to observe MRML here?
85 virtual void ProcessMrmlEvents(vtkObject * vtkNotUsed(caller),
86 unsigned long vtkNotUsed(event),
87 void * vtkNotUsed(callData)){}
88
90 virtual void DeleteTemporaryFilesOn();
92 void SetDeleteTemporaryFiles(int value);
94
95 // Control use of in-memory data transfer by this specific CLI.
96 void SetAllowInMemoryTransfer(int value);
98
104
111 void Apply( vtkMRMLCommandLineModuleNode* node, bool updateDisplay = true );
112
119 void ApplyAndWait ( vtkMRMLCommandLineModuleNode* node, bool updateDisplay = true);
120
122
123// void LazyEvaluateModuleTarget(ModuleDescription& moduleDescriptionObject);
124// void LazyEvaluateModuleTarget(vtkMRMLCommandLineModuleNode* node)
125// { this->LazyEvaluateModuleTarget(node->GetModuleDescription()); }
126
129
130protected:
132 void SetMRMLSceneInternal(vtkMRMLScene * newScene) override;
134 void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
136 void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event,
137 void *callData) override;
139 void ProcessMRMLLogicsEvents(vtkObject*, long unsigned int, void*) override;
140
141
142 std::string ConstructTemporaryFileName(const std::string& tag,
143 const std::string& type,
144 const std::string& name,
145 const std::vector<std::string>& extensions,
146 CommandLineModuleType commandType);
148 std::string FindHiddenNodeID(const ModuleDescription& d,
149 const ModuleParameter& p);
150
151 // The method that runs the command line module
152 void ApplyTask(void *clientdata);
153
154 // Communicate progress back to the node
155 static void ProgressCallback(void *);
156
159 static void RemoveProgressInfoFromProcessOutput(std::string& text);
160
164 vtkMRMLCommandLineModuleNode* commandLineModuleNode)const;
165
168
171 {
172 RequestHierarchyEditEvent = vtkCommand::UserEvent + 1
173 };
174
175 // Add a model hierarchy node and all its descendants to a scene (miniscene to sent to a CLI).
176 // The mapping of ids from the original scene to the mini scene is put in (added to) sceneToMiniSceneMap.
177 // Any files that will be created by writing out the miniscene are added to filesToDelete (i.e. models)
178 void AddCompleteModelHierarchyToMiniScene(vtkMRMLScene*, vtkMRMLModelHierarchyNode*, MRMLIDMap* sceneToMiniSceneMap, std::set<std::string> &filesToDelete);
179
180 int GetCoordinateSystemFromString(const char* coordinateSystemStr)const;
181
182private:
184 ~vtkSlicerCLIModuleLogic() override;
186 void operator=(const vtkSlicerCLIModuleLogic&) = delete;
187
188 class vtkInternal;
189 vtkInternal * Internal;
190};
191
192#endif
193
MRML node for representing the parameters allowing to run a command line interface module (CLI)....
MRML node to represent a hierarchy of models.
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
vtkMRMLCommandLineModuleNode * CreateNode()
virtual void DeleteTemporaryFilesOff()
const ModuleDescription & GetDefaultModuleDescription() const
void ApplyTask(void *clientdata)
virtual void RedirectModuleStreamsOn()
For debugging, control redirection of cout and cerr.
void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) override
Reimplemented to observe CLI node.
std::string ConstructTemporarySceneFileName(vtkMRMLScene *scene)
void AddCompleteModelHierarchyToMiniScene(vtkMRMLScene *, vtkMRMLModelHierarchyNode *, MRMLIDMap *sceneToMiniSceneMap, std::set< std::string > &filesToDelete)
virtual void ProcessMrmlEvents(vtkObject *vtkNotUsed(caller), unsigned long vtkNotUsed(event), void *vtkNotUsed(callData))
void SetAllowInMemoryTransfer(int value)
void SetMRMLApplicationLogic(vtkMRMLApplicationLogic *logic) override
Set the application logic.
std::string ConstructTemporaryFileName(const std::string &tag, const std::string &type, const std::string &name, const std::vector< std::string > &extensions, CommandLineModuleType commandType)
std::string GetDefaultParameterValue(const std::string &name) const
static void ProgressCallback(void *)
int GetCoordinateSystemFromString(const char *coordinateSystemStr) const
static vtkSlicerCLIModuleLogic * New()
void SetMRMLSceneInternal(vtkMRMLScene *newScene) override
Reimplemented to observe NodeAddedEvent.
bool SetDefaultParameterValue(const std::string &name, const std::string &value)
void AutoRun(vtkMRMLCommandLineModuleNode *cliNode)
Call apply because the node requests it.
int GetDeleteTemporaryFiles() const
void Apply(vtkMRMLCommandLineModuleNode *node, bool updateDisplay=true)
void SetRedirectModuleStreams(int value)
void OnMRMLSceneNodeAdded(vtkMRMLNode *node) override
Reimplemented for AutoRun mode.
vtkMRMLCommandLineModuleNode * CreateNodeInScene()
virtual void DeleteTemporaryFilesOn()
For debugging, control deletion of temp files.
int GetRedirectModuleStreams() const
void ApplyAndWait(vtkMRMLCommandLineModuleNode *node, bool updateDisplay=true)
virtual void RedirectModuleStreamsOff()
bool IsCommandLineModuleNodeUpdatingDisplay(vtkMRMLCommandLineModuleNode *commandLineModuleNode) const
static void RemoveProgressInfoFromProcessOutput(std::string &text)
void SetDeleteTemporaryFiles(int value)
Events
List of custom events fired by the class.
void PrintSelf(ostream &os, vtkIndent indent) override
void SetDefaultModuleDescription(const ModuleDescription &moduleDescription)
int GetAllowInMemoryTransfer() const
void ProcessMRMLLogicsEvents(vtkObject *, long unsigned int, void *) override
Reimplemented to observe vtkSlicerApplicationLogic.
std::string FindHiddenNodeID(const ModuleDescription &d, const ModuleParameter &p)