]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
617ea74c0ac94f69cbc7006c2b224bd9a923cbc6
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.h
1 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
2 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
3
4 #include <map>
5 #include <set>
6
7 #include <itkDataObject.h>
8 #include <cpPlugins/Interface/ProcessObjectPort.h>
9 #include <cpPlugins/Interface/Parameters.h>
10
11 // Some forward declarations
12 class vtkRenderWindowInteractor;
13
14 namespace cpPlugins
15 {
16   namespace Interface
17   {
18     // Some forward declarations
19 #ifdef cpPlugins_Interface_QT4
20     class ParametersQtDialog;
21     class SimpleMPRWidget;
22 #else
23     typedef char ParametersQtDialog;
24     typedef char SimpleMPRWidget;
25 #endif // cpPlugins_Interface_QT4
26
27     /**
28      */
29     class cpPlugins_Interface_EXPORT ProcessObject
30       : public Object
31     {
32     public:
33       typedef ProcessObject                   Self;
34       typedef Object                          Superclass;
35       typedef itk::SmartPointer< Self >       Pointer;
36       typedef itk::SmartPointer< const Self > ConstPointer;
37
38       typedef Parameters TParameters;
39       typedef std::set< vtkRenderWindowInteractor* > TInteractors;
40       typedef bool DialogResult;
41
42     public:
43       itkTypeMacro( ProcessObject, Object );
44       cpPlugins_Id_Macro( ProcessObject, BaseObject );
45
46       itkGetConstObjectMacro( Parameters, TParameters );
47
48       itkGetObjectMacro( Parameters, TParameters );
49       itkGetMacro( ParametersDialog, ParametersQtDialog* );
50       itkGetMacro( SingleInteractor, vtkRenderWindowInteractor* );
51       itkGetMacro( MPRViewer, SimpleMPRWidget* );
52
53       itkSetObjectMacro( ParametersDialog, ParametersQtDialog );
54       itkSetObjectMacro( SingleInteractor, vtkRenderWindowInteractor );
55       itkSetObjectMacro( MPRViewer, SimpleMPRWidget );
56
57     public:
58       virtual void SetITK( itk::LightObject* o );
59       virtual void SetVTK( vtkObjectBase* o );
60
61       // IO management
62       std::set< std::string > GetInputsNames( ) const;
63       std::set< std::string > GetOutputsNames( ) const;
64       unsigned int GetNumberOfInputs( ) const;
65       unsigned int GetNumberOfOutputs( ) const;
66
67       OutputProcessObjectPort& GetOutput( const std::string& id );
68       const OutputProcessObjectPort& GetOutput( const std::string& id ) const;
69
70       /* TODO
71          template< class T >
72          inline T* GetInputData( const std::string& id );
73          template< class T >
74          inline const T* GetInputData( const std::string& id ) const;
75          template< class T >
76          inline T* GetOutputData( const std::string& id );
77          template< class T >
78          inline const T* GetOutputData( const std::string& id ) const;
79       */
80       DataObject* GetInputData( const std::string& id );
81       const DataObject* GetInputData( const std::string& id ) const;
82       DataObject* GetOutputData( const std::string& id );
83       const DataObject* GetOutputData( const std::string& id ) const;
84
85       bool SetInput(
86         const std::string& id, const OutputProcessObjectPort& port
87         );
88
89       void DisconnectInputs( );
90       void DisconnectOutputs( );
91       void Disconnect( );
92
93       // Pipeline execution
94       virtual itk::ModifiedTimeType GetMTime( ) const;
95       virtual std::string Update( );
96
97     protected:
98       ProcessObject( );
99       virtual ~ProcessObject( );
100
101       void _AddInput( const std::string& name, bool required = true );
102       template< class O >
103         inline void _AddOutput( const std::string& name );
104       template< class F >
105         inline F* _CreateITK( );
106       template< class F >
107         inline F* _CreateVTK( );
108
109       virtual std::string _GenerateData( ) = 0;
110
111     private:
112       // Purposely not implemented
113       ProcessObject( const Self& );
114       Self& operator=( const Self& );
115
116     protected:
117       typedef std::map< std::string, InputProcessObjectPort >  _TInputs;
118       typedef std::map< std::string, OutputProcessObjectPort > _TOutputs;
119       _TInputs  m_Inputs;
120       _TOutputs m_Outputs;
121       Parameters::Pointer m_Parameters;
122
123       itk::ModifiedTimeType m_LastExecutionTime;
124
125       ParametersQtDialog*        m_ParametersDialog;
126       vtkRenderWindowInteractor* m_SingleInteractor;
127       SimpleMPRWidget*           m_MPRViewer;
128     };
129
130   } // ecapseman
131
132 } // ecapseman
133
134 #include <cpPlugins/Interface/ProcessObject.hxx>
135
136 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
137
138 // eof - $RCSfile$