]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
Getting ready for interactive initialization.
[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 #ifdef cpPlugins_Interface_QT4
32     class ParametersQtDialog;
33 #else
34     typedef char ParametersQtDialog;
35 #endif // cpPlugins_Interface_QT4
36
37     /**
38      */
39     class cpPlugins_Interface_EXPORT ProcessObject
40       : public Object
41     {
42     public:
43       typedef ProcessObject                   Self;
44       typedef Object                          Superclass;
45       typedef itk::SmartPointer< Self >       Pointer;
46       typedef itk::SmartPointer< const Self > ConstPointer;
47
48       typedef Parameters TParameters;
49
50       enum DialogResult
51       {
52         DialogResult_NoModal = 0,
53         DialogResult_Modal,
54         DialogResult_Cancel
55       };
56
57     public:
58       itkTypeMacro( ProcessObject, Object );
59       cpPlugins_Id_Macro(
60         cpPlugins::Interface::ProcessObject, "BaseObject"
61         );
62
63     public:
64       // To impact pipeline
65       virtual void Modified( ) const;
66
67       virtual TParameters* GetParameters( );
68       virtual const TParameters* GetParameters( ) const;
69
70       virtual unsigned int GetNumberOfInputs( ) const;
71       virtual unsigned int GetNumberOfOutputs( ) const;
72
73       virtual std::vector< std::string > GetInputsNames( ) const;
74       virtual std::vector< std::string > GetOutputsNames( ) const;
75
76       virtual void SetInput( const std::string& id, DataObject* dobj );
77
78       virtual std::string Update( );
79       virtual void DisconnectOutputs( );
80
81       virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
82       virtual DialogResult ExecConfigurationDialog( QWidget* parent );
83
84       template< class T >
85         inline T* GetITK( );
86
87       template< class T >
88         inline const T* GetITK( ) const;
89
90       template< class T >
91         inline T* GetVTK( );
92
93       template< class T >
94         inline const T* GetVTK( ) const;
95
96       template< class T >
97         inline T* GetInput( const std::string& id );
98
99       template< class T >
100         inline const T* GetInput( const std::string& id ) const;
101
102       template< class T >
103         inline T* GetOutput( const std::string& id );
104
105       template< class T >
106         inline const T* GetOutput( const std::string& id ) const;
107
108     protected:
109       ProcessObject( );
110       virtual ~ProcessObject( );
111
112       virtual void _AddInput( const std::string& name );
113
114       template< class F >
115         inline F* _CreateITK( );
116
117       template< class F >
118         inline F* _CreateVTK( );
119
120       template< class O >
121         inline void _MakeOutput( const std::string& id );
122
123       virtual std::string _GenerateData( ) = 0;
124
125     private:
126       // Purposely not implemented
127       ProcessObject( const Self& );
128       Self& operator=( const Self& );
129
130     protected:
131       itk::ProcessObject::Pointer     m_ITKObject;
132       vtkSmartPointer< vtkAlgorithm > m_VTKObject;
133
134       Parameters::Pointer m_Parameters;
135       ParametersQtDialog* m_ParametersDialog;
136
137       typedef std::map< std::string, DataObject::Pointer > _TDataContainer;
138       _TDataContainer m_Inputs;
139       _TDataContainer m_Outputs;
140     };
141
142   } // ecapseman
143
144 } // ecapseman
145
146 #include <cpPlugins/Interface/ProcessObject.hxx>
147
148 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
149
150 // eof - $RCSfile$