]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.cxx
f832743feb2d5ce57eb43af8f7e1046e8a2550a4
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
1 #include <cpPlugins/Interface/ProcessObject.h>
2
3 #ifdef cpPlugins_Interface_QT4
4 #include <cpPlugins/Interface/ParametersQtDialog.h>
5 #endif // cpPlugins_Interface_QT4
6
7 // -------------------------------------------------------------------------
8 cpPlugins::Interface::ProcessObject::
9 TParameters* cpPlugins::Interface::ProcessObject::
10 GetParameters( )
11 {
12   return( this->m_Parameters.GetPointer( ) );
13 }
14
15 // -------------------------------------------------------------------------
16 const cpPlugins::Interface::ProcessObject::
17 TParameters* cpPlugins::Interface::ProcessObject::
18 GetParameters( ) const
19 {
20   return( this->m_Parameters.GetPointer( ) );
21 }
22
23 // -------------------------------------------------------------------------
24 unsigned int cpPlugins::Interface::ProcessObject::
25 GetNumberOfInputs( ) const
26 {
27   return( this->m_Inputs.size( ) );
28 }
29
30 // -------------------------------------------------------------------------
31 unsigned int cpPlugins::Interface::ProcessObject::
32 GetNumberOfOutputs( ) const
33 {
34   return( this->m_Outputs.size( ) );
35 }
36
37 // -------------------------------------------------------------------------
38 void cpPlugins::Interface::ProcessObject::
39 SetNumberOfInputs( unsigned int n )
40 {
41   this->m_Inputs.clear( );
42   this->m_Inputs.resize( n );
43   this->Modified( );
44 }
45
46 // -------------------------------------------------------------------------
47 void cpPlugins::Interface::ProcessObject::
48 SetNumberOfOutputs( unsigned int n )
49 {
50   this->m_Outputs.clear( );
51   this->m_Outputs.resize( n );
52   this->Modified( );
53 }
54
55 // -------------------------------------------------------------------------
56 void cpPlugins::Interface::ProcessObject::
57 SetInput( unsigned int idx, cpPlugins::Interface::DataObject* dobj )
58 {
59   if( idx < this->m_Inputs.size( ) )
60   {
61     this->m_Inputs[ idx ] = dobj;
62     this->Modified( );
63
64   } // fi
65 }
66
67 // -------------------------------------------------------------------------
68 std::string cpPlugins::Interface::ProcessObject::
69 Update( )
70 {
71   std::string r = "";
72
73   // Force upstream updates
74   for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i )
75   {
76     Self* src = dynamic_cast< Self* >( this->m_Inputs[ i ]->GetSource( ) );
77     if( src != NULL )
78       r = src->Update( );
79
80   } // rof
81
82   // Current update
83   if( r == "" )
84     r = this->_GenerateData( );
85
86   // Return error description, if any
87   return( r );
88 }
89
90 // -------------------------------------------------------------------------
91 void cpPlugins::Interface::ProcessObject::
92 DisconnectOutputs( )
93 {
94   for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
95     if( this->m_Outputs[ idx ].IsNotNull( ) )
96       this->m_Outputs[ idx ]->DisconnectPipeline( );
97 }
98
99 // -------------------------------------------------------------------------
100 bool cpPlugins::Interface::ProcessObject::
101 ExecConfigurationDialog( QWidget* parent )
102 {
103   bool r = false;
104
105 #ifdef cpPlugins_Interface_QT4
106
107   r = cpPlugins::Interface::ParametersQtDialog(
108     this->m_Parameters,
109     this->GetClassName( ) + std::string( " basic configuration" ),
110     parent
111     );
112   /*
113     if( r )
114     // TODO: !!! this->m_Parameters = parameters;
115     */
116
117 #endif // cpPlugins_Interface_QT4
118
119   return( r );
120 }
121
122 // -------------------------------------------------------------------------
123 cpPlugins::Interface::ProcessObject::
124 ProcessObject( )
125   : Superclass( ),
126     m_ITKObject( NULL ),
127     m_VTKObject( NULL )
128 {
129   this->m_Parameters = TParameters::New( );
130 }
131
132 // -------------------------------------------------------------------------
133 cpPlugins::Interface::ProcessObject::
134 ~ProcessObject( )
135 {
136 }
137
138 // eof - $RCSfile$