Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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) VTK_OVERRIDE;
49 
52  void SetDefaultModuleDescription(const ModuleDescription& moduleDescription);
53  const ModuleDescription& GetDefaultModuleDescription()const;
54 
60  vtkMRMLCommandLineModuleNode* CreateNode();
61 
66  vtkMRMLCommandLineModuleNode* CreateNodeInScene();
67 
68  // TODO: do we need to observe MRML here?
69  virtual void ProcessMrmlEvents(vtkObject * vtkNotUsed(caller),
70  unsigned long vtkNotUsed(event),
71  void * vtkNotUsed(callData)){}
72 
74  virtual void DeleteTemporaryFilesOn();
75  virtual void DeleteTemporaryFilesOff();
76  void SetDeleteTemporaryFiles(int value);
77  int GetDeleteTemporaryFiles() const;
78 
79  // Control use of in-memory data transfer by this specific CLI.
80  void SetAllowInMemoryTransfer(int value);
81  int GetAllowInMemoryTransfer() const;
82 
84  virtual void RedirectModuleStreamsOn();
85  virtual void RedirectModuleStreamsOff();
86  void SetRedirectModuleStreams(int value);
87  int GetRedirectModuleStreams() const;
88 
95  void Apply( vtkMRMLCommandLineModuleNode* node, bool updateDisplay = true );
96 
103  void ApplyAndWait ( vtkMRMLCommandLineModuleNode* node, bool updateDisplay = true);
104 
105  void KillProcesses();
106 
107 // void LazyEvaluateModuleTarget(ModuleDescription& moduleDescriptionObject);
108 // void LazyEvaluateModuleTarget(vtkMRMLCommandLineModuleNode* node)
109 // { this->LazyEvaluateModuleTarget(node->GetModuleDescription()); }
110 
112  virtual void SetMRMLApplicationLogic(vtkMRMLApplicationLogic* logic) VTK_OVERRIDE;
113 
114 protected:
116  virtual void SetMRMLSceneInternal(vtkMRMLScene * newScene) VTK_OVERRIDE;
118  virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node) VTK_OVERRIDE;
120  virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event,
121  void *callData) VTK_OVERRIDE;
123  void ProcessMRMLLogicsEvents(vtkObject*, long unsigned int, void*) VTK_OVERRIDE;
124 
125 
126  std::string ConstructTemporaryFileName(const std::string& tag,
127  const std::string& type,
128  const std::string& name,
129  const std::vector<std::string>& extensions,
130  CommandLineModuleType commandType);
131  std::string ConstructTemporarySceneFileName(vtkMRMLScene *scene);
132  std::string FindHiddenNodeID(const ModuleDescription& d,
133  const ModuleParameter& p);
134 
135  // The method that runs the command line module
136  void ApplyTask(void *clientdata);
137 
138  // Communicate progress back to the node
139  static void ProgressCallback(void *);
140 
143  bool IsCommandLineModuleNodeUpdatingDisplay(
144  vtkMRMLCommandLineModuleNode* commandLineModuleNode)const;
145 
147  void AutoRun(vtkMRMLCommandLineModuleNode* cliNode);
148 
150  enum Events{
151  RequestHierarchyEditEvent = vtkCommand::UserEvent + 1
152  };
153 
154  // Add a model hierarchy node and all its descendents to a scene (miniscene to sent to a CLI).
155  // The mapping of ids from the original scene to the mini scene is put in (added to) sceneToMiniSceneMap.
156  // Any files that will be created by writing out the miniscene are added to filesToDelete (i.e. models)
157  void AddCompleteModelHierarchyToMiniScene(vtkMRMLScene*, vtkMRMLModelHierarchyNode*, MRMLIDMap* sceneToMiniSceneMap, std::set<std::string> &filesToDelete);
158 
159 private:
161  virtual ~vtkSlicerCLIModuleLogic();
163  void operator=(const vtkSlicerCLIModuleLogic&);
164 
165  class vtkInternal;
166  vtkInternal * Internal;
167 };
168 
169 #endif
170 
static vtkSlicerModuleLogic * New()
The Usual vtk class functions.
Logic for running CLI.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
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:54
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:135
MRML node for representing the parameters allowing to run a command line interface module (CLI)...
Events
List of custom events fired by the class.