Slicer  4.8
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) VTK_OVERRIDE;
32 
33  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
34 
36  virtual void ReadXMLAttributes(const char** atts) VTK_OVERRIDE;
37 
39  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
40 
42  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
43 
45  virtual const char* GetNodeTagName() VTK_OVERRIDE
46  {return "CommandLineModule";}
47 
54  ParameterChangedEvent = 17000,
65  StatusModifiedEvent
66  };
67 
70  const ModuleDescription& GetModuleDescription() const;
71  ModuleDescription& GetModuleDescription();
72  std::string GetModuleDescriptionAsString() const;
73  void SetModuleDescription(const ModuleDescription& description);
74 
75  typedef enum {
77  Idle=0x00,
79  Scheduled=0x01,
81  Running=0x02,
83  Cancelling=0x04,
87  Cancelled=0x08,
90  Completing=0x10,
93  Completed=0x20,
95  ErrorsMask=0x40,
97  CompletedWithErrors= Completed | ErrorsMask,
99  BusyMask = Scheduled | Running | Cancelling | Completing
100  } StatusType;
101 
109  void SetStatus(int status, bool modify=true);
111  int GetStatus() const;
112 
115  const char* GetStatusString() const;
116 
118  void SetOutputText(const std::string& text, bool modify = true);
120  const std::string GetOutputText() const;
121 
123  void SetErrorText(const std::string& text, bool modify = true);
125  const std::string GetErrorText() const;
126 
130  bool IsBusy()const;
131 
135  void Cancel();
136 
140  {
144  AutoRunCancelsRunningProcess = 0x01,
148  AutoRunOnChangedParameter = 0x10,
153  AutoRunOnModifiedInputEvent = 0x20,
156  AutoRunOnOtherInputEvents = 0x40,
158  AutoRunOnAnyInputEvent = AutoRunOnModifiedInputEvent | AutoRunOnOtherInputEvents,
159  // <- add here new options
161  AutoRunEnabledMask = AutoRunOnChangedParameter | AutoRunOnAnyInputEvent
162  };
163 
168  void SetAutoRun(bool enable);
169 
172  bool GetAutoRun()const;
173 
179  void SetAutoRunMode(int autoRunMode);
180 
183  int GetAutoRunMode()const;
184 
188  void SetAutoRunDelay(unsigned int delayInMs);
189 
193  unsigned int GetAutoRunDelay()const;
194 
197  vtkMTimeType GetLastRunTime()const;
198 
201  vtkMTimeType GetParameterMTime()const;
202 
205  vtkMTimeType GetInputMTime()const;
206 
209  bool ReadParameterFile(const std::string& filename);
210 
216  bool WriteParameterFile(const std::string& filename, bool withHandlesToBulkParameters = true);
217 
223  bool SetParameterAsNode(const char* name, vtkMRMLNode* value);
227  bool SetParameterAsString(const char* name, const std::string& value);
231  bool SetParameterAsInt(const char* name, int value);
235  bool SetParameterAsBool(const char* name, bool value);
239  bool SetParameterAsDouble(const char* name, double value);
243  bool SetParameterAsFloat(const char* name, float value);
244 
245  std::string GetParameterAsString(const char* name) const;
246 
247  void SetModuleDescription(const char *name);
248  std::string GetModuleVersion() const;
249  std::string GetModuleTitle() const;
250  std::string GetModuleTarget() const;
251  std::string GetModuleType() const;
252  bool IsValidGroupId(unsigned int group) const;
253  bool IsValidParamId(unsigned int group, unsigned int param) const;
254  unsigned int GetNumberOfParameterGroups() const;
255  unsigned int GetNumberOfParametersInGroup(unsigned int group) const;
256  std::string GetParameterGroupLabel(unsigned int group) const;
257  std::string GetParameterGroupDescription(unsigned int group) const;
258  std::string GetParameterGroupAdvanced(unsigned int group) const;
259  std::string GetParameterTag(unsigned int group, unsigned int param) const;
260  std::string GetParameterType(unsigned int group, unsigned int param) const;
261  std::string GetParameterArgType(unsigned int group, unsigned int param) const;
262  std::string GetParameterName(unsigned int group, unsigned int param) const;
263  std::string GetParameterLongFlag(unsigned int group, unsigned int param) const;
264  std::string GetParameterLabel(unsigned int group, unsigned int param) const;
265  std::string GetParameterConstraints(unsigned int group, unsigned int param) const;
266  std::string GetParameterMaximum(unsigned int group, unsigned int param) const;
267  std::string GetParameterMinimum(unsigned int group, unsigned int param) const;
268  std::string GetParameterDescription(unsigned int group, unsigned int param) const;
269  std::string GetParameterChannel(unsigned int group, unsigned int param) const;
270  std::string GetParameterIndex(unsigned int group, unsigned int param) const;
272  std::string GetParameterDefault(unsigned int group, unsigned int param) const;
273  std::string GetParameterValue(unsigned int group, unsigned int param) const;
274  std::string GetParameterFlag(unsigned int group, unsigned int param) const;
275  std::string GetParameterMultiple(unsigned int group, unsigned int param) const;
276  std::string GetParameterFileExtensions(unsigned int group, unsigned int param) const;
277  std::string GetParameterCoordinateSystem(unsigned int group, unsigned int param) const;
278 
282  bool IsInputDefaultValue(const std::string& value)const;
283 
285  static int GetNumberOfRegisteredModules();
286  static const char* GetRegisteredModuleNameByIndex(int idx);
287  static void RegisterModuleDescription(ModuleDescription md);
288  static bool HasRegisteredModule(const std::string& name);
289  static ModuleDescription GetRegisteredModuleDescription(const std::string& name);
290 
292  virtual void Modified() VTK_OVERRIDE;
293 protected:
294  void AbortProcess();
295  virtual void ProcessMRMLEvents(vtkObject *caller, unsigned long event,
296  void *callData) VTK_OVERRIDE;
297 
298 private:
300  ~vtkMRMLCommandLineModuleNode();
301  vtkMRMLCommandLineModuleNode(const vtkMRMLCommandLineModuleNode&);
302  void operator=(const vtkMRMLCommandLineModuleNode&);
303 
304  class vtkInternal;
305  vtkInternal * Internal;
306 };
307 
308 #endif
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
CLINodeEvent
List of events that can be fired on or by the node.
virtual void Modified() VTK_OVERRIDE
Customized version of Modified() allowing to compress vtkCommand::ModifiedEvent.
Definition: vtkMRMLNode.h:430
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
MRML node for representing the parameters allowing to run a command line interface module (CLI)...