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