Slicer  5.3
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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
17 #include "vtkSlicerModuleLogic.h"
18 
19 // MRMLCLI includes
21 class ModuleDescription;
22 class ModuleParameter;
23 
24 // MRML include
25 #include "vtkMRMLScene.h"
27 class MRMLIDMap;
28 
29 // STL includes
30 #include <string>
31 
32 #include "qSlicerBaseQTCLIExport.h"
33 
35 
42 class Q_SLICER_BASE_QTCLI_EXPORT vtkSlicerCLIModuleLogic :
44 {
45 public:
46  static vtkSlicerCLIModuleLogic *New();
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
52  void SetDefaultModuleDescription(const ModuleDescription& moduleDescription);
53  const ModuleDescription& GetDefaultModuleDescription()const;
54 
59  bool SetDefaultParameterValue(const std::string& name, const std::string& value);
60 
64  std::string GetDefaultParameterValue(const std::string& name) const;
65 
71  vtkMRMLCommandLineModuleNode* CreateNode();
72 
77  vtkMRMLCommandLineModuleNode* CreateNodeInScene();
78 
79  // TODO: do we need to observe MRML here?
80  virtual void ProcessMrmlEvents(vtkObject * vtkNotUsed(caller),
81  unsigned long vtkNotUsed(event),
82  void * vtkNotUsed(callData)){}
83 
85  virtual void DeleteTemporaryFilesOn();
86  virtual void DeleteTemporaryFilesOff();
87  void SetDeleteTemporaryFiles(int value);
88  int GetDeleteTemporaryFiles() const;
89 
90  // Control use of in-memory data transfer by this specific CLI.
91  void SetAllowInMemoryTransfer(int value);
92  int GetAllowInMemoryTransfer() const;
93 
95  virtual void RedirectModuleStreamsOn();
96  virtual void RedirectModuleStreamsOff();
97  void SetRedirectModuleStreams(int value);
98  int GetRedirectModuleStreams() const;
99 
106  void Apply( vtkMRMLCommandLineModuleNode* node, bool updateDisplay = true );
107 
114  void ApplyAndWait ( vtkMRMLCommandLineModuleNode* node, bool updateDisplay = true);
115 
116  void KillProcesses();
117 
118 // void LazyEvaluateModuleTarget(ModuleDescription& moduleDescriptionObject);
119 // void LazyEvaluateModuleTarget(vtkMRMLCommandLineModuleNode* node)
120 // { this->LazyEvaluateModuleTarget(node->GetModuleDescription()); }
121 
123  void SetMRMLApplicationLogic(vtkMRMLApplicationLogic* logic) override;
124 
125 protected:
127  void SetMRMLSceneInternal(vtkMRMLScene * newScene) override;
129  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
131  void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event,
132  void *callData) override;
134  void ProcessMRMLLogicsEvents(vtkObject*, long unsigned int, void*) override;
135 
136 
137  std::string ConstructTemporaryFileName(const std::string& tag,
138  const std::string& type,
139  const std::string& name,
140  const std::vector<std::string>& extensions,
141  CommandLineModuleType commandType);
142  std::string ConstructTemporarySceneFileName(vtkMRMLScene *scene);
143  std::string FindHiddenNodeID(const ModuleDescription& d,
144  const ModuleParameter& p);
145 
146  // The method that runs the command line module
147  void ApplyTask(void *clientdata);
148 
149  // Communicate progress back to the node
150  static void ProgressCallback(void *);
151 
154  bool IsCommandLineModuleNodeUpdatingDisplay(
155  vtkMRMLCommandLineModuleNode* commandLineModuleNode)const;
156 
158  void AutoRun(vtkMRMLCommandLineModuleNode* cliNode);
159 
161  enum Events{
162  RequestHierarchyEditEvent = vtkCommand::UserEvent + 1
163  };
164 
165  // Add a model hierarchy node and all its descendents to a scene (miniscene to sent to a CLI).
166  // The mapping of ids from the original scene to the mini scene is put in (added to) sceneToMiniSceneMap.
167  // Any files that will be created by writing out the miniscene are added to filesToDelete (i.e. models)
168  void AddCompleteModelHierarchyToMiniScene(vtkMRMLScene*, vtkMRMLModelHierarchyNode*, MRMLIDMap* sceneToMiniSceneMap, std::set<std::string> &filesToDelete);
169 
170  int GetCoordinateSystemFromString(const char* coordinateSystemStr)const;
171 
172 private:
174  ~vtkSlicerCLIModuleLogic() override;
176  void operator=(const vtkSlicerCLIModuleLogic&) = delete;
177 
178  class vtkInternal;
179  vtkInternal * Internal;
180 };
181 
182 #endif
183 
void PrintSelf(ostream &os, vtkIndent indent) override
static vtkSlicerModuleLogic * New()
The Usual vtk class functions.
Logic for running CLI.
list extensions
Definition: conf.py:36
virtual void ProcessMRMLLogicsEvents(vtkObject *caller, unsigned long event, void *callData)
virtual void ProcessMrmlEvents(vtkObject *vtkNotUsed(caller), unsigned long vtkNotUsed(event), void *vtkNotUsed(callData))
virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData)
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode *)
virtual void SetMRMLApplicationLogic(vtkMRMLApplicationLogic *logic)
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
MRML node to represent a hierarchyu of models.
CommandLineModuleType
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
MRML node for representing the parameters allowing to run a command line interface module (CLI)...
Events
List of custom events fired by the class.