]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
52b56546abe3521d83e50b959caa80cc8d4e7729
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.h
1 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
2 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
3
4 #include <set>
5
6 #include <cpPlugins/Interface/DataObject.h>
7 #include <cpPlugins/Interface/Parameters.h>
8
9 #include <itkProcessObject.h>
10 #include <vtkSmartPointer.h>
11 #include <vtkAlgorithm.h>
12
13 // Some forward declarations
14 class vtkRenderWindowInteractor;
15 #ifdef cpPlugins_Interface_QT4
16 class QWidget;
17 #else
18 typedef char QWidget;
19 #endif // cpPlugins_Interface_QT4
20
21 namespace cpPlugins
22 {
23   namespace Interface
24   {
25     // Some forward declarations
26     class Plugins;
27 #ifdef cpPlugins_Interface_QT4
28     class ParametersQtDialog;
29 #else
30     typedef char ParametersQtDialog;
31 #endif // cpPlugins_Interface_QT4
32
33     /**
34      */
35     class cpPlugins_Interface_EXPORT ProcessObject
36       : public Object
37     {
38     public:
39       typedef ProcessObject                   Self;
40       typedef Object                          Superclass;
41       typedef itk::SmartPointer< Self >       Pointer;
42       typedef itk::SmartPointer< const Self > ConstPointer;
43
44       typedef Parameters TParameters;
45       typedef std::set< vtkRenderWindowInteractor* > TInteractors;
46       typedef bool DialogResult;
47
48     public:
49       itkTypeMacro( ProcessObject, Object );
50       cpPlugins_Id_Macro( ProcessObject, BaseObject );
51
52       itkBooleanMacro( Interactive );
53
54       itkGetConstObjectMacro( Parameters, TParameters );
55       itkGetObjectMacro( Parameters, TParameters );
56       itkGetConstMacro( Plugins, const Plugins* );
57       itkGetMacro( Plugins, Plugins* );
58       itkGetConstMacro( Interactive, bool );
59
60       itkSetObjectMacro( Plugins, Plugins );
61       itkSetMacro( Interactive, bool );
62
63     public:
64       // To impact pipeline
65       virtual void Modified( ) const;
66
67       virtual void GetInputsNames( std::set< std::string >& names ) const;
68       virtual void GetOutputsNames( std::set< std::string >& names ) const;
69       unsigned int GetNumberOfInputs( ) const;
70       unsigned int GetNumberOfOutputs( ) const;
71
72       virtual bool SetOutputObjectName(
73         const std::string& new_object_name,
74         const std::string& output_name
75         );
76
77       virtual void SetInput( const std::string& id, DataObject* dobj );
78
79       virtual std::string Update( );
80       virtual void DisconnectOutputs( );
81
82       virtual const TInteractors& GetInteractors( ) const;
83       virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
84       virtual bool ExecConfigurationDialog( QWidget* parent );
85
86       template< class T >
87         inline T* GetITK( );
88
89       template< class T >
90         inline const T* GetITK( ) const;
91
92       template< class T >
93         inline T* GetVTK( );
94
95       template< class T >
96         inline const T* GetVTK( ) const;
97
98       template< class T >
99         inline T* GetInput( const std::string& id );
100
101       template< class T >
102         inline const T* GetInput( const std::string& id ) const;
103
104       template< class T >
105         inline T* GetOutput( const std::string& id );
106
107       template< class T >
108         inline const T* GetOutput( const std::string& id ) const;
109
110     protected:
111       ProcessObject( );
112       virtual ~ProcessObject( );
113
114       virtual void _AddInput( const std::string& name );
115
116       template< class F >
117         inline F* _CreateITK( );
118
119       template< class F >
120         inline F* _CreateVTK( );
121
122       template< class O >
123         inline void _MakeOutput( const std::string& id );
124
125       virtual std::string _GenerateData( ) = 0;
126
127     private:
128       // Purposely not implemented
129       ProcessObject( const Self& );
130       Self& operator=( const Self& );
131
132     protected:
133       itk::ProcessObject::Pointer     m_ITKObject;
134       vtkSmartPointer< vtkAlgorithm > m_VTKObject;
135
136       Parameters::Pointer m_Parameters;
137       ParametersQtDialog* m_ParametersDialog;
138       TInteractors        m_Interactors;
139       Plugins* m_Plugins;
140       bool m_Interactive;
141
142       typedef std::map< std::string, DataObject::Pointer > _TDataContainer;
143       _TDataContainer m_Inputs;
144       _TDataContainer m_Outputs;
145       std::map< std::string, std::string > m_OutputObjectsNames;
146     };
147
148     /**
149      * Plugin provider
150      */
151     CPPLUGINS_PROVIDER_HEADER( ProcessObject );
152
153   } // ecapseman
154
155 } // ecapseman
156
157 #include <cpPlugins/Interface/ProcessObject.hxx>
158
159 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
160
161 // eof - $RCSfile$