Slicer  4.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLCommandLineModuleNode.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8 =========================================================================auto=*/
9 
10 #ifndef __vtkMRMLCommandLineModuleNode_h
11 #define __vtkMRMLCommandLineModuleNode_h
12 
14 #include <vtkMRMLNode.h>
15 
16 #include "vtkMRMLCLIExport.h"
17 
18 class ModuleDescription;
19 
26 class VTK_MRML_CLI_EXPORT vtkMRMLCommandLineModuleNode : public vtkMRMLNode
27 {
28 public:
29  static vtkMRMLCommandLineModuleNode *New();
31  void PrintSelf(ostream& os, vtkIndent indent) override;
32 
33  vtkMRMLNode* CreateNodeInstance() override;
34 
36  void ReadXMLAttributes(const char** atts) override;
37 
39  void WriteXML(ostream& of, int indent) override;
40 
44 
46  const char* GetNodeTagName() override
47  {return "CommandLineModule";}
48 
55  ParameterChangedEvent = 17000,
66  StatusModifiedEvent
67  };
68 
71  const ModuleDescription& GetModuleDescription() const;
72  ModuleDescription& GetModuleDescription();
73  std::string GetModuleDescriptionAsString() const;
74  void SetModuleDescription(const ModuleDescription& description);
75 
76  typedef enum {
78  Idle=0x00,
80  Scheduled=0x01,
82  Running=0x02,
84  Cancelling=0x04,
88  Cancelled=0x08,
91  Completing=0x10,
94  Completed=0x20,
96  ErrorsMask=0x40,
98  CompletedWithErrors= Completed | ErrorsMask,
100  BusyMask = Scheduled | Running | Cancelling | Completing
101  } StatusType;
102 
110  void SetStatus(int status, bool modify=true);
112  int GetStatus() const;
113 
116  const char* GetStatusString() const;
117 
119  void SetOutputText(const std::string& text, bool modify = true);
121  const std::string GetOutputText() const;
122 
124  void SetErrorText(const std::string& text, bool modify = true);
126  const std::string GetErrorText() const;
127 
131  bool IsBusy()const;
132 
133  int GetProgress()const;
134 
138  void Cancel();
139 
143  {
147  AutoRunCancelsRunningProcess = 0x01,
151  AutoRunOnChangedParameter = 0x10,
156  AutoRunOnModifiedInputEvent = 0x20,
159  AutoRunOnOtherInputEvents = 0x40,
161  AutoRunOnAnyInputEvent = AutoRunOnModifiedInputEvent | AutoRunOnOtherInputEvents,
162  // <- add here new options
164  AutoRunEnabledMask = AutoRunOnChangedParameter | AutoRunOnAnyInputEvent
165  };
166 
171  void SetAutoRun(bool enable);
172 
175  bool GetAutoRun()const;
176 
182  void SetAutoRunMode(int autoRunMode);
183 
186  int GetAutoRunMode()const;
187 
191  void SetAutoRunDelay(unsigned int delayInMs);
192 
196  unsigned int GetAutoRunDelay()const;
197 
200  vtkMTimeType GetLastRunTime()const;
201 
204  vtkMTimeType GetParameterMTime()const;
205 
208  vtkMTimeType GetInputMTime()const;
209 
212  bool ReadParameterFile(const std::string& filename);
213 
219  bool WriteParameterFile(const std::string& filename, bool withHandlesToBulkParameters = true);
220 
226  bool SetParameterAsNode(const char* name, vtkMRMLNode* value);
230  bool SetParameterAsString(const char* name, const std::string& value);
234  bool SetParameterAsInt(const char* name, int value);
238  bool SetParameterAsBool(const char* name, bool value);
242  bool SetParameterAsDouble(const char* name, double value);
246  bool SetParameterAsFloat(const char* name, float value);
247 
248  std::string GetParameterAsString(const char* name) const;
249 
250  void SetModuleDescription(const char *name);
251  std::string GetModuleVersion() const;
252  std::string GetModuleTitle() const;
253  std::string GetModuleTarget() const;
254  std::string GetModuleType() const;
255  bool IsValidGroupId(unsigned int group) const;
256  bool IsValidParamId(unsigned int group, unsigned int param) const;
257  unsigned int GetNumberOfParameterGroups() const;
258  unsigned int GetNumberOfParametersInGroup(unsigned int group) const;
259  std::string GetParameterGroupLabel(unsigned int group) const;
260  std::string GetParameterGroupDescription(unsigned int group) const;
261  std::string GetParameterGroupAdvanced(unsigned int group) const;
262  std::string GetParameterTag(unsigned int group, unsigned int param) const;
263  std::string GetParameterType(unsigned int group, unsigned int param) const;
264  std::string GetParameterArgType(unsigned int group, unsigned int param) const;
265  std::string GetParameterName(unsigned int group, unsigned int param) const;
266  std::string GetParameterLongFlag(unsigned int group, unsigned int param) const;
267  std::string GetParameterLabel(unsigned int group, unsigned int param) const;
268  std::string GetParameterConstraints(unsigned int group, unsigned int param) const;
269  std::string GetParameterMaximum(unsigned int group, unsigned int param) const;
270  std::string GetParameterMinimum(unsigned int group, unsigned int param) const;
271  std::string GetParameterDescription(unsigned int group, unsigned int param) const;
272  std::string GetParameterChannel(unsigned int group, unsigned int param) const;
273  std::string GetParameterIndex(unsigned int group, unsigned int param) const;
275  std::string GetParameterDefault(unsigned int group, unsigned int param) const;
276  std::string GetParameterValue(unsigned int group, unsigned int param) const;
277  std::string GetParameterFlag(unsigned int group, unsigned int param) const;
278  std::string GetParameterMultiple(unsigned int group, unsigned int param) const;
279  std::string GetParameterFileExtensions(unsigned int group, unsigned int param) const;
280  std::string GetParameterCoordinateSystem(unsigned int group, unsigned int param) const;
281 
285  bool IsInputDefaultValue(const std::string& value)const;
286 
288  static int GetNumberOfRegisteredModules();
289  static const char* GetRegisteredModuleNameByIndex(int idx);
290  static void RegisterModuleDescription(ModuleDescription md);
291  static bool HasRegisteredModule(const std::string& name);
292  static ModuleDescription GetRegisteredModuleDescription(const std::string& name);
293 
295  void Modified() override;
296 protected:
297  void AbortProcess();
298  void ProcessMRMLEvents(vtkObject *caller, unsigned long event,
299  void *callData) override;
300 
301 private:
303  ~vtkMRMLCommandLineModuleNode() override;
305  void operator=(const vtkMRMLCommandLineModuleNode&) = delete;
306 
307  class vtkInternal;
308  vtkInternal * Internal;
309 };
310 
311 #endif
virtual void ReadXMLAttributes(const char **atts)
void operator=(const vtkMRMLNode &)
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
virtual void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData)
Propagate events generated in mrml.
virtual void WriteXML(ostream &of, int indent)
CLINodeEvent
List of events that can be fired on or by the node.
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
void PrintSelf(ostream &os, vtkIndent indent) override
#define vtkMRMLCopyContentMacro(thisClassName)
Definition: vtkMRMLNode.h:142
void Modified() override
Customized version of Modified() allowing to compress vtkCommand::ModifiedEvent.
Definition: vtkMRMLNode.h:507
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)...