Slicer 5.9
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 "vtkSlicerBaseLogic.h"
33
40class VTK_SLICER_BASE_LOGIC_EXPORT vtkSlicerCLIModuleLogic : public vtkSlicerModuleLogic
41{
42public:
49
50 static vtkSlicerCLIModuleLogic* New();
51 vtkTypeMacro(vtkSlicerCLIModuleLogic, vtkSlicerModuleLogic);
52 void PrintSelf(ostream& os, vtkIndent indent) override;
53
56 void SetDefaultModuleDescription(const ModuleDescription& moduleDescription);
57 const ModuleDescription& GetDefaultModuleDescription() const;
58
63 bool SetDefaultParameterValue(const std::string& name, const std::string& value);
64
68 std::string GetDefaultParameterValue(const std::string& name) const;
69
76
82
83 // TODO: do we need to observe MRML here?
84 virtual void ProcessMrmlEvents(vtkObject* vtkNotUsed(caller), unsigned long vtkNotUsed(event), void* vtkNotUsed(callData)) {}
85
87 virtual void DeleteTemporaryFilesOn();
89 void SetDeleteTemporaryFiles(int value);
91
92 // Control use of in-memory data transfer by this specific CLI.
93 void SetAllowInMemoryTransfer(int value);
95
97 void SetHideWindow(int value);
98 int GetHideWindow() const;
99
105
112 void Apply(vtkMRMLCommandLineModuleNode* node, bool updateDisplay = true);
113
120 void ApplyAndWait(vtkMRMLCommandLineModuleNode* node, bool updateDisplay = true);
121
123
124 // void LazyEvaluateModuleTarget(ModuleDescription& moduleDescriptionObject);
125 // void LazyEvaluateModuleTarget(vtkMRMLCommandLineModuleNode* node)
126 // { this->LazyEvaluateModuleTarget(node->GetModuleDescription()); }
127
130
131protected:
133 void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
135 void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
137 void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
139 void ProcessMRMLLogicsEvents(vtkObject*, long unsigned int, void*) override;
140
141 std::string ConstructTemporaryFileName(const std::string& tag,
142 const std::string& type,
143 const std::string& name,
144 const std::vector<std::string>& extensions,
145 CommandLineModuleType commandType);
147 std::string FindHiddenNodeID(const ModuleDescription& d, const ModuleParameter& p);
148
149 // The method that runs the command line module
150 void ApplyTask(void* clientdata);
151
152 // Communicate progress back to the node
153 static void ProgressCallback(void*);
154
157 static void RemoveProgressInfoFromProcessOutput(std::string& text);
158
162
165
168 {
169 RequestHierarchyEditEvent = vtkCommand::UserEvent + 1
170 };
171
172 // Add a model hierarchy node and all its descendants to a scene (miniscene to sent to a CLI).
173 // The mapping of ids from the original scene to the mini scene is put in (added to) sceneToMiniSceneMap.
174 // Any files that will be created by writing out the miniscene are added to filesToDelete (i.e. models)
175 void AddCompleteModelHierarchyToMiniScene(vtkMRMLScene*, vtkMRMLModelHierarchyNode*, MRMLIDMap* sceneToMiniSceneMap, std::set<std::string>& filesToDelete);
176
177 int GetCoordinateSystemFromString(const char* coordinateSystemStr) const;
178
179private:
180 vtkSlicerCLIModuleLogic();
181 ~vtkSlicerCLIModuleLogic() override;
182 vtkSlicerCLIModuleLogic(const vtkSlicerCLIModuleLogic&) = delete;
183 void operator=(const vtkSlicerCLIModuleLogic&) = delete;
184
185 class vtkInternal;
186 vtkInternal* Internal;
187};
188
189#endif
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)
void SetHideWindow(int value)
Control whether the CLI process window is hidden (Windows only, defaults to 1).
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)