]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
ddd1c21aa150ad2cd38987e82ad1bfb4f76d3677
[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* 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* GetInput( const std::string& id );
80
81       template< class T >
82         inline const T* GetInput( const std::string& id ) const;
83
84       template< class T >
85         inline T* GetOutput( const std::string& id );
86
87       template< class T >
88         inline const T* GetOutput( const std::string& id ) const;
89
90     protected:
91       ProcessObject( );
92       virtual ~ProcessObject( );
93
94       virtual void _AddInput( const std::string& name );
95
96       template< class O >
97         inline void _AddOutput( const std::string& id );
98
99       template< class F >
100         inline F* _CreateITK( );
101
102       template< class F >
103         inline F* _CreateVTK( );
104
105       virtual std::string _GenerateData( ) = 0;
106
107     private:
108       // Purposely not implemented
109       ProcessObject( const Self& );
110       Self& operator=( const Self& );
111
112     protected:
113       Parameters::Pointer m_Parameters;
114       ParametersQtDialog* m_ParametersDialog;
115
116       vtkSmartPointer< vtkRenderWindowInteractor > m_SingleInteractor;
117       SimpleMPRWidget*                             m_MPRViewer;
118       bool                                         m_Interactive;
119
120       typedef std::map< std::string, DataObject::Pointer > _TDataContainer;
121       _TDataContainer m_Inputs;
122       _TDataContainer m_Outputs;
123     };
124
125     /**
126      * Plugin provider
127      */
128     CPPLUGINS_PROVIDER_HEADER( ProcessObject );
129
130   } // ecapseman
131
132 } // ecapseman
133
134 #include <cpPlugins/Interface/ProcessObject.hxx>
135
136 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
137
138 // eof - $RCSfile$