]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.cxx
Widget integration (step 3/6). WARNING: IT DOES NOT COMPILE YET
[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 const cpPlugins::Interface::Parameters&
9 cpPlugins::Interface::ProcessObject::
10 GetDefaultParameters( ) const
11 {
12   return( this->m_DefaultParameters );
13 }
14
15 // -------------------------------------------------------------------------
16 void cpPlugins::Interface::ProcessObject::
17 SetParameters( const cpPlugins::Interface::Parameters& params )
18 {
19   this->m_Parameters = params;
20   this->Modified( );
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   Parameters parameters = this->m_DefaultParameters;
108   r = cpPlugins::Interface::ParametersQtDialog(
109     parameters,
110     this->m_ClassName + std::string( " basic configuration" ),
111     parent
112     );
113   if( r )
114     this->m_Parameters = parameters;
115
116 #endif // cpPlugins_Interface_QT4
117
118   return( r );
119 }
120
121 // -------------------------------------------------------------------------
122 cpPlugins::Interface::ProcessObject::
123 ProcessObject( )
124   : Superclass( ),
125     m_ITKObject( NULL ),
126     m_VTKObject( NULL )
127 {
128   this->m_ClassName = "cpPlugins::Interface::ProcessObject";
129   this->m_ClassCategory = "BasicObject";
130 }
131
132 // -------------------------------------------------------------------------
133 cpPlugins::Interface::ProcessObject::
134 ~ProcessObject( )
135 {
136 }
137
138 // eof - $RCSfile$