vtkCommandLineModuleLogic.h

Go to the documentation of this file.
00001 /*=auto=========================================================================
00002 
00003   Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
00004 
00005   See Doc/copyright/copyright.txt
00006   or http://www.slicer.org/copyright/copyright.txt for details.
00007 
00008   Program:   3D Slicer
00009   Module:    $RCSfile: vtkCommandLineModuleLogic.h,v $
00010   Date:      $Date: 2006/03/19 17:12:29 $
00011   Version:   $Revision: 1.3 $
00012 
00013 =========================================================================auto=*/
00014 #ifndef __vtkCommandLineModuleLogic_h
00015 #define __vtkCommandLineModuleLogic_h
00016 
00017 #include "vtkSlicerModuleLogic.h"
00018 #include "vtkMRMLScene.h"
00019 
00020 #include "vtkCommandLineModule.h"
00021 #include "vtkMRMLCommandLineModuleNode.h"
00022 #include "vtkSlicerApplication.h"
00023 
00024 #include <string>
00025 
00026 typedef enum { CommandLineModule, SharedObjectModule, PythonModule } CommandLineModuleType;
00027 
00028 class VTK_COMMANDLINEMODULE_EXPORT vtkCommandLineModuleLogic : public vtkSlicerModuleLogic
00029 {
00030 public:
00031   static vtkCommandLineModuleLogic *New();
00032   vtkTypeMacro(vtkCommandLineModuleLogic,vtkSlicerModuleLogic);
00033   void PrintSelf(ostream& os, vtkIndent indent);
00034 
00035   // TODO: do we need to observe MRML here?
00036   virtual void ProcessMrmlEvents ( vtkObject * vtkNotUsed(caller), unsigned long vtkNotUsed(event),
00037                                    void * vtkNotUsed(callData) ){};
00038 
00039   // Description: Get/Set MRML node storing parameter values
00040   vtkGetObjectMacro (CommandLineModuleNode, vtkMRMLCommandLineModuleNode);
00041   vtkSetObjectMacro (CommandLineModuleNode, vtkMRMLCommandLineModuleNode);
00042 
00043   // Description: For debugging, control deletion of temp files
00044   vtkBooleanMacro (DeleteTemporaryFiles, int);
00045   vtkSetMacro (DeleteTemporaryFiles, int);
00046   vtkGetMacro (DeleteTemporaryFiles, int);
00047 
00048   // Description: For debugging, control redirection of cout and cerr
00049   vtkBooleanMacro (RedirectModuleStreams, int);
00050   vtkSetMacro (RedirectModuleStreams, int);
00051   vtkGetMacro (RedirectModuleStreams, int);
00052   
00053   // The method that schedules the command line module to run
00054   void Apply();
00055   void Apply( vtkMRMLCommandLineModuleNode* node );
00056   void ApplyAndWait ( vtkMRMLCommandLineModuleNode* node );
00057 
00058   // Set/Get the directory to use for temporary files
00059   void SetTemporaryDirectory(const char *tempdir)
00060     { this->TemporaryDirectory = tempdir; }
00061   const char *GetTemporaryDirectory() const
00062     { return this->TemporaryDirectory.c_str(); }
00063 
00064 //BTX
00065   void LazyEvaluateModuleTarget(ModuleDescription& moduleDescriptionObject);
00066 //ETX
00067   void LazyEvaluateModuleTarget(vtkMRMLCommandLineModuleNode* node) 
00068     { this->LazyEvaluateModuleTarget(node->GetModuleDescription()); }
00069 
00070 protected:
00071   //BTX
00072   std::string ConstructTemporaryFileName(const std::string& tag,
00073                                          const std::string& type,
00074                                          const std::string& name,
00075                                      const std::vector<std::string>& extensions,
00076                                      CommandLineModuleType commandType) const;
00077   std::string ConstructTemporarySceneFileName(vtkMRMLScene *scene);
00078   std::string FindHiddenNodeID(const ModuleDescription& d,
00079                                const ModuleParameter& p);
00080   //ETX
00081 
00082   // The method that runs the command line module
00083   void ApplyTask(void *clientdata);
00084 
00085   // Communicate progress back to the node
00086   static void ProgressCallback(void *);
00087   
00088 private:
00089   vtkCommandLineModuleLogic();
00090   virtual ~vtkCommandLineModuleLogic();
00091   vtkCommandLineModuleLogic(const vtkCommandLineModuleLogic&);
00092   void operator=(const vtkCommandLineModuleLogic&);
00093 
00094   int DeleteTemporaryFiles;
00095 
00096   int RedirectModuleStreams;
00097 
00098   vtkMRMLCommandLineModuleNode* CommandLineModuleNode;
00099 //BTX
00100   std::string TemporaryDirectory;
00101 //ETX
00102 };
00103 
00104 #endif
00105 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1