]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
MPR finished
[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
47       enum DialogResult
48       {
49         DialogResult_NoModal = 0,
50         DialogResult_Modal,
51         DialogResult_Cancel
52       };
53
54     public:
55       itkTypeMacro( ProcessObject, Object );
56       cpPlugins_Id_Macro( ProcessObject, "BaseObject" );
57
58       itkBooleanMacro( Interactive );
59
60       itkGetConstObjectMacro( Parameters, TParameters );
61       itkGetObjectMacro( Parameters, TParameters );
62       itkGetConstMacro( Plugins, const Plugins* );
63       itkGetMacro( Plugins, Plugins* );
64       itkGetConstMacro( Interactive, bool );
65
66       itkSetObjectMacro( Plugins, Plugins );
67       itkSetMacro( Interactive, bool );
68
69     public:
70       // To impact pipeline
71       virtual void Modified( ) const;
72
73       virtual void GetInputsNames( std::set< std::string >& names ) const;
74       virtual void GetOutputsNames( std::set< std::string >& names ) const;
75
76       virtual bool SetOutputObjectName(
77         const std::string& new_object_name,
78         const std::string& output_name
79         );
80
81       virtual void SetInput( const std::string& id, DataObject* dobj );
82
83       virtual std::string Update( );
84       virtual void DisconnectOutputs( );
85
86       virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
87       virtual DialogResult ExecConfigurationDialog( QWidget* parent );
88
89       template< class T >
90         inline T* GetITK( );
91
92       template< class T >
93         inline const T* GetITK( ) const;
94
95       template< class T >
96         inline T* GetVTK( );
97
98       template< class T >
99         inline const T* GetVTK( ) const;
100
101       template< class T >
102         inline T* GetInput( const std::string& id );
103
104       template< class T >
105         inline const T* GetInput( const std::string& id ) const;
106
107       template< class T >
108         inline T* GetOutput( const std::string& id );
109
110       template< class T >
111         inline const T* GetOutput( const std::string& id ) const;
112
113     protected:
114       ProcessObject( );
115       virtual ~ProcessObject( );
116
117       virtual void _AddInput( const std::string& name );
118
119       template< class F >
120         inline F* _CreateITK( );
121
122       template< class F >
123         inline F* _CreateVTK( );
124
125       template< class O >
126         inline void _MakeOutput( const std::string& id );
127
128       virtual std::string _GenerateData( ) = 0;
129
130     private:
131       // Purposely not implemented
132       ProcessObject( const Self& );
133       Self& operator=( const Self& );
134
135     protected:
136       itk::ProcessObject::Pointer     m_ITKObject;
137       vtkSmartPointer< vtkAlgorithm > m_VTKObject;
138
139       Parameters::Pointer m_Parameters;
140       ParametersQtDialog* m_ParametersDialog;
141       TInteractors        m_Interactors;
142       Plugins* m_Plugins;
143       bool m_Interactive;
144
145       typedef std::map< std::string, DataObject::Pointer > _TDataContainer;
146       _TDataContainer m_Inputs;
147       _TDataContainer m_Outputs;
148       std::map< std::string, std::string > m_OutputObjectsNames;
149     };
150
151     /**
152      * Plugin provider
153      */
154     CPPLUGINS_PROVIDER_HEADER( ProcessObject );
155
156   } // ecapseman
157
158 } // ecapseman
159
160 #include <cpPlugins/Interface/ProcessObject.hxx>
161
162 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
163
164 // eof - $RCSfile$