]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
MVC pattern finished
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.h
1 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
2 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
3
4 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
5
6 #include <map>
7 #include <vector>
8
9 #include <cpPlugins/Interface/Config.h>
10 #include <cpPlugins/Interface/Object.h>
11 #include <cpPlugins/Interface/DataObject.h>
12 #include <cpPlugins/Interface/Parameters.h>
13
14 #ifdef cpPlugins_Interface_QT4
15 class QWidget;
16 #else
17 typedef char QWidget;
18 #endif // cpPlugins_Interface_QT4
19
20 #include <itkProcessObject.h>
21
22 #include <vtkSmartPointer.h>
23 #include <vtkAlgorithm.h>
24
25 class vtkRenderWindowInteractor;
26
27 namespace cpPlugins
28 {
29   namespace Interface
30   {
31     class Plugins;
32 #ifdef cpPlugins_Interface_QT4
33     class ParametersQtDialog;
34 #else
35     typedef char ParametersQtDialog;
36 #endif // cpPlugins_Interface_QT4
37
38     /**
39      */
40     class cpPlugins_Interface_EXPORT ProcessObject
41       : public Object
42     {
43     public:
44       typedef ProcessObject                   Self;
45       typedef Object                          Superclass;
46       typedef itk::SmartPointer< Self >       Pointer;
47       typedef itk::SmartPointer< const Self > ConstPointer;
48
49       typedef Parameters TParameters;
50
51       enum DialogResult
52       {
53         DialogResult_NoModal = 0,
54         DialogResult_Modal,
55         DialogResult_Cancel
56       };
57
58     public:
59       itkTypeMacro( ProcessObject, Object );
60       cpPlugins_Id_Macro(
61         cpPlugins::Interface::ProcessObject, "BaseObject"
62         );
63
64     public:
65       // To impact pipeline
66       virtual void Modified( ) const;
67
68       virtual bool IsInteractive( ) const;
69       virtual TParameters* GetParameters( );
70       virtual const TParameters* GetParameters( ) const;
71
72       Plugins* GetPlugins( );
73       const Plugins* GetPlugins( ) const;
74       void SetPlugins( Plugins* p );
75
76       virtual unsigned int GetNumberOfInputs( ) const;
77       virtual unsigned int GetNumberOfOutputs( ) 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
144       typedef std::map< std::string, DataObject::Pointer > _TDataContainer;
145       _TDataContainer m_Inputs;
146       _TDataContainer m_Outputs;
147     };
148
149   } // ecapseman
150
151 } // ecapseman
152
153 #include <cpPlugins/Interface/ProcessObject.hxx>
154
155 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
156
157 // eof - $RCSfile$