]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
...
[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 <itkDataObject.h>
7
8 #include <cpPlugins/Interface/DataObject.h>
9 #include <cpPlugins/Interface/Parameters.h>
10
11 // Some forward declarations
12 class vtkRenderWindowInteractor;
13 #ifdef cpPlugins_Interface_QT4
14 class QWidget;
15 #else
16 typedef char QWidget;
17 #endif // cpPlugins_Interface_QT4
18
19 namespace cpPlugins
20 {
21   namespace Interface
22   {
23     // Some forward declarations
24 #ifdef cpPlugins_Interface_QT4
25     class ParametersQtDialog;
26     class SimpleMPRWidget;
27 #else
28     typedef char ParametersQtDialog;
29     typedef char SimpleMPRWidget;
30 #endif // cpPlugins_Interface_QT4
31
32     /**
33      */
34     class cpPlugins_Interface_EXPORT ProcessObject
35       : public Object
36     {
37     public:
38       typedef ProcessObject                   Self;
39       typedef Object                          Superclass;
40       typedef itk::SmartPointer< Self >       Pointer;
41       typedef itk::SmartPointer< const Self > ConstPointer;
42
43       typedef Parameters TParameters;
44       typedef std::set< vtkRenderWindowInteractor* > TInteractors;
45       typedef bool DialogResult;
46
47     public:
48       itkTypeMacro( ProcessObject, Object );
49       cpPlugins_Id_Macro( ProcessObject, BaseObject );
50
51       itkBooleanMacro( Interactive );
52       itkGetConstMacro( Interactive, bool );
53       itkSetMacro( Interactive, bool );
54
55       itkGetConstObjectMacro( Parameters, TParameters );
56       itkGetObjectMacro( Parameters, TParameters );
57
58     public:
59       virtual std::set< std::string > GetInputsNames( ) const;
60       virtual std::set< std::string > GetOutputsNames( ) const;
61       unsigned int GetNumberOfInputs( ) const;
62       unsigned int GetNumberOfOutputs( ) const;
63
64       virtual bool SetInput( const std::string& id, DataObject::Pointer* dobj );
65
66       virtual std::string Update( );
67       virtual void DisconnectOutputs( );
68
69       // Widgets management
70       vtkRenderWindowInteractor* GetSingleInteractor( );
71       const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
72       void SetSingleInteractor( vtkRenderWindowInteractor* interactor );
73       SimpleMPRWidget* GetMPRViewer( );
74       const SimpleMPRWidget* GetMPRViewer( ) const;
75       void SetMPRViewer( SimpleMPRWidget* wdg );
76       virtual bool ExecConfigurationDialog( QWidget* parent );
77
78       template< class T >
79         inline T* GetInputData( const std::string& id );
80
81       template< class T >
82         inline const T* GetInputData( const std::string& id ) const;
83
84       template< class T >
85         inline T* GetOutputData( const std::string& id );
86
87       template< class T >
88         inline const T* GetOutputData( const std::string& id ) const;
89
90       DataObject::Pointer* GetOutputPort( const std::string& id )
91       {
92         auto i = this->m_Outputs.find( id );
93         if( i != this->m_Outputs.end( ) )
94           return( i->second );
95         else
96           return( NULL );
97       }
98
99       const DataObject::Pointer* GetOutputPort( const std::string& id ) const
100       {
101         auto i = this->m_Outputs.find( id );
102         if( i != this->m_Outputs.end( ) )
103           return( i->second );
104         else
105           return( NULL );
106       }
107
108     protected:
109       ProcessObject( );
110       virtual ~ProcessObject( );
111
112       virtual void _AddInput( const std::string& name );
113
114       template< class O >
115         inline void _AddOutput( const std::string& id );
116
117       template< class F >
118         inline F* _CreateITK( );
119
120       template< class F >
121         inline F* _CreateVTK( );
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       Parameters::Pointer m_Parameters;
132       ParametersQtDialog* m_ParametersDialog;
133
134       vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
135       SimpleMPRWidget*                             m_MPRViewer;
136       bool                                         m_Interactive;
137
138       typedef std::map< std::string, DataObject::Pointer* > _TDataContainer;
139       _TDataContainer m_Inputs;
140       _TDataContainer m_Outputs;
141     };
142
143   } // ecapseman
144
145 } // ecapseman
146
147 #include <cpPlugins/Interface/ProcessObject.hxx>
148
149 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
150
151 // eof - $RCSfile$