]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
...
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.h
1 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
2 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
3
4 #include <map>
5 #include <set>
6
7 #include <itkDataObject.h>
8 #include <cpPlugins/Interface/ProcessObjectPort.h>
9 #include <cpPlugins/Interface/Parameters.h>
10
11 // Some forward declarations
12 class vtkRenderWindowInteractor;
13
14 namespace cpPlugins
15 {
16   namespace Interface
17   {
18     // Some forward declarations
19 #ifdef cpPlugins_Interface_QT4
20     class ParametersQtDialog;
21     class SimpleMPRWidget;
22 #else
23     typedef char ParametersQtDialog;
24     typedef char SimpleMPRWidget;
25 #endif // cpPlugins_Interface_QT4
26
27     /**
28      */
29     class cpPlugins_Interface_EXPORT ProcessObject
30       : public Object
31     {
32     public:
33       typedef ProcessObject                   Self;
34       typedef Object                          Superclass;
35       typedef itk::SmartPointer< Self >       Pointer;
36       typedef itk::SmartPointer< const Self > ConstPointer;
37
38       typedef Parameters TParameters;
39       typedef std::set< vtkRenderWindowInteractor* > TInteractors;
40       typedef bool DialogResult;
41
42     public:
43       itkTypeMacro( ProcessObject, Object );
44       cpPlugins_Id_Macro( ProcessObject, BaseObject );
45
46       itkGetConstObjectMacro( Parameters, TParameters );
47
48       itkGetObjectMacro( Parameters, TParameters );
49       itkGetMacro( ParametersDialog, ParametersQtDialog* );
50       itkGetMacro( SingleInteractor, vtkRenderWindowInteractor* );
51       itkGetMacro( MPRViewer, SimpleMPRWidget* );
52
53       itkSetObjectMacro( ParametersDialog, ParametersQtDialog );
54       itkSetObjectMacro( SingleInteractor, vtkRenderWindowInteractor );
55       itkSetObjectMacro( MPRViewer, SimpleMPRWidget );
56
57     public:
58       virtual void SetITK( itk::LightObject* o );
59       virtual void SetVTK( vtkObjectBase* o );
60
61       // IO management
62       std::set< std::string > GetInputsNames( ) const;
63       std::set< std::string > GetOutputsNames( ) const;
64       unsigned int GetNumberOfInputs( ) const;
65       unsigned int GetNumberOfOutputs( ) const;
66
67       OutputProcessObjectPort& GetOutput( const std::string& id );
68       const OutputProcessObjectPort& GetOutput( const std::string& id ) const;
69
70       template< class T >
71         inline T* GetInputData( const std::string& id );
72       template< class T >
73         inline const T* GetInputData( const std::string& id ) const;
74       template< class T >
75         inline T* GetOutputData( const std::string& id );
76       template< class T >
77         inline const T* GetOutputData( const std::string& id ) const;
78
79       bool SetInput(
80         const std::string& id, const OutputProcessObjectPort& port
81         );
82
83       void DisconnectInputs( );
84       void DisconnectOutputs( );
85       void Disconnect( );
86
87       // Pipeline execution
88       virtual itk::ModifiedTimeType GetMTime( ) const;
89       virtual std::string Update( );
90
91     protected:
92       ProcessObject( );
93       virtual ~ProcessObject( );
94
95       void _AddInput( const std::string& name, bool required = true );
96       template< class O >
97         inline void _AddOutput( const std::string& name );
98       template< class F >
99         inline F* _CreateITK( );
100       template< class F >
101         inline F* _CreateVTK( );
102
103       virtual std::string _GenerateData( ) = 0;
104
105     private:
106       // Purposely not implemented
107       ProcessObject( const Self& );
108       Self& operator=( const Self& );
109
110     protected:
111       typedef std::map< std::string, InputProcessObjectPort >  _TInputs;
112       typedef std::map< std::string, OutputProcessObjectPort > _TOutputs;
113       _TInputs  m_Inputs;
114       _TOutputs m_Outputs;
115       Parameters::Pointer m_Parameters;
116
117       itk::ModifiedTimeType m_LastExecutionTime;
118
119       ParametersQtDialog*        m_ParametersDialog;
120       vtkRenderWindowInteractor* m_SingleInteractor;
121       SimpleMPRWidget*           m_MPRViewer;
122     };
123
124   } // ecapseman
125
126 } // ecapseman
127
128 #include <cpPlugins/Interface/ProcessObject.hxx>
129
130 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
131
132 // eof - $RCSfile$