]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.cxx
UML-code sync
[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 #include <vtkRenderWindowInteractor.h>
8
9 // -------------------------------------------------------------------------
10 void cpPlugins::Interface::ProcessObject::
11 Modified( ) const
12 {
13   if( this->m_ITKObject.IsNotNull( ) )
14     this->m_ITKObject->Modified( );
15   if( this->m_VTKObject.GetPointer( ) != NULL )
16     this->m_VTKObject->Modified( );
17   this->Superclass::Modified( );
18 }
19
20 // -------------------------------------------------------------------------
21 std::vector< std::string > cpPlugins::Interface::ProcessObject::
22 GetInputsNames( ) const
23 {
24   std::vector< std::string > r;
25   auto dIt = this->m_Inputs.begin( );
26   for( ; dIt != this->m_Inputs.end( ); ++dIt )
27     r.push_back( dIt->first );
28   return( r );
29 }
30
31 // -------------------------------------------------------------------------
32 std::vector< std::string > cpPlugins::Interface::ProcessObject::
33 GetOutputsNames( ) const
34 {
35   std::vector< std::string > r;
36   auto dIt = this->m_Outputs.begin( );
37   for( ; dIt != this->m_Outputs.end( ); ++dIt )
38     r.push_back( dIt->first );
39   return( r );
40 }
41
42 // -------------------------------------------------------------------------
43 void cpPlugins::Interface::ProcessObject::
44 SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
45 {
46   _TDataContainer::iterator i = this->m_Inputs.find( id );
47   if( i != this->m_Inputs.end( ) )
48   {
49     i->second = dobj;
50     this->Modified( );
51
52   } // fi
53 }
54
55 // -------------------------------------------------------------------------
56 std::string cpPlugins::Interface::ProcessObject::
57 Update( )
58 {
59   std::string r = "";
60
61   // Force upstream updates
62   _TDataContainer::iterator i = this->m_Inputs.begin( );
63   for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
64   {
65     Self* src = dynamic_cast< Self* >( i->second->GetSource( ) );
66     if( src != NULL )
67       r = src->Update( );
68
69   } // rof
70
71   // Current update
72   if( r == "" )
73     r = this->_GenerateData( );
74
75   // Return error description, if any
76   return( r );
77 }
78
79 // -------------------------------------------------------------------------
80 void cpPlugins::Interface::ProcessObject::
81 DisconnectOutputs( )
82 {
83   _TDataContainer::iterator i = this->m_Outputs.begin( );
84   for( ; i != this->m_Outputs.end( ); ++i )
85     if( i->second.IsNotNull( ) )
86       i->second->DisconnectPipeline( );
87 }
88
89 // -------------------------------------------------------------------------
90 void cpPlugins::Interface::ProcessObject::
91 AddInteractor( vtkRenderWindowInteractor* interactor )
92 {
93 #ifdef cpPlugins_Interface_QT4
94   this->m_ParametersDialog->addInteractor( interactor );
95 #endif // cpPlugins_Interface_QT4
96 }
97
98 // -------------------------------------------------------------------------
99 cpPlugins::Interface::ProcessObject::
100 DialogResult cpPlugins::Interface::ProcessObject::
101 ExecConfigurationDialog( QWidget* parent )
102 {
103   DialogResult r = Self::DialogResult_Cancel;
104
105 #ifdef cpPlugins_Interface_QT4
106
107   this->m_ParametersDialog->setParent( NULL );
108   this->m_ParametersDialog->setParameters( this->m_Parameters );
109
110   if( !( this->m_ParametersDialog->IsModal( ) ) )
111   {
112     this->m_ParametersDialog->show( );
113     r = Self::DialogResult_Modal;
114   }
115   else
116   {
117     if( this->m_ParametersDialog->exec( ) == 1 )
118       r = Self::DialogResult_NoModal;
119     else
120       r = Self::DialogResult_Cancel;
121
122   } // fi
123
124 #endif // cpPlugins_Interface_QT4
125
126   return( r );
127 }
128
129 // -------------------------------------------------------------------------
130 cpPlugins::Interface::ProcessObject::
131 ProcessObject( )
132   : Superclass( ),
133     m_ITKObject( NULL ),
134     m_VTKObject( NULL ),
135     m_Plugins( NULL )
136 {
137   this->m_Parameters = TParameters::New( );
138   this->m_Parameters->SetProcessObject( this );
139
140   this->m_ParametersDialog = new ParametersQtDialog( );
141   this->m_ParametersDialog->setTitle(
142     this->GetClassName( ) + std::string( " basic configuration" )
143     );
144 }
145
146 // -------------------------------------------------------------------------
147 cpPlugins::Interface::ProcessObject::
148 ~ProcessObject( )
149 {
150   delete this->m_ParametersDialog;
151 }
152
153 // -------------------------------------------------------------------------
154 void cpPlugins::Interface::ProcessObject::
155 _AddInput( const std::string& name )
156 {
157   this->m_Inputs[ name ] = NULL;
158   this->Modified( );
159 }
160
161 // -------------------------------------------------------------------------
162 CPPLUGINS_PROVIDER_SOURCE( cpPlugins::Interface::ProcessObject, 1, 1 );
163
164 // eof - $RCSfile$