#include <cpPlugins/Interface/ProcessObject.h>
-#include <cpPlugins/Interface/DataObject.h>
+
+#ifdef cpPlugins_Interface_QT4
+#include <QApplication>
+#include <cpPlugins/Interface/ParametersQtDialog.h>
+#include <cpPlugins/Interface/SimpleMPRWidget.h>
+#endif // cpPlugins_Interface_QT4
+
+#include <vtkRenderWindowInteractor.h>
// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-ProcessObject( )
- : Superclass( ),
- m_OutputsDisconnected( false )
+std::set< std::string > cpPlugins::Interface::ProcessObject::
+GetInputsNames( ) const
{
+ std::set< std::string > names;
+ auto dIt = this->m_Inputs.begin( );
+ for( ; dIt != this->m_Inputs.end( ); ++dIt )
+ names.insert( dIt->first );
+ return( names );
}
// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-~ProcessObject( )
+std::set< std::string > cpPlugins::Interface::ProcessObject::
+GetOutputsNames( ) const
{
- this->_DeleteOutputs( );
+ std::set< std::string > names;
+ auto dIt = this->m_Outputs.begin( );
+ for( ; dIt != this->m_Outputs.end( ); ++dIt )
+ names.insert( dIt->first );
+ return( names );
}
// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::ProcessObject::
-GetClassName( ) const
+unsigned int cpPlugins::Interface::ProcessObject::
+GetNumberOfInputs( ) const
{
- return( "cpPlugins::Interface::ProcessObject" );
+ return( this->m_Inputs.size( ) );
}
// -------------------------------------------------------------------------
-const cpPlugins::Interface::ProcessObject::
-TParameters& cpPlugins::Interface::ProcessObject::
-GetDefaultParameters( ) const
+unsigned int cpPlugins::Interface::ProcessObject::
+GetNumberOfOutputs( ) const
{
- return( this->m_DefaultParameters );
+ return( this->m_Outputs.size( ) );
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetParameters( const TParameters& params )
+bool cpPlugins::Interface::ProcessObject::
+SetInput(
+ const std::string& id, cpPlugins::Interface::DataObject::Pointer* dobj
+ )
{
- this->m_Parameters = params;
+ _TDataContainer::iterator i = this->m_Inputs.find( id );
+ if( i != this->m_Inputs.end( ) )
+ {
+ i->second = dobj;
+ this->Modified( );
+ return( true );
+ }
+ else
+ return( false );
}
// -------------------------------------------------------------------------
-unsigned int cpPlugins::Interface::ProcessObject::
-GetNumberOfInputs( ) const
+std::string cpPlugins::Interface::ProcessObject::
+Update( )
{
- return( this->m_Inputs.size( ) );
+ std::string r = "";
+
+ // Force upstream updates
+ _TDataContainer::iterator i = this->m_Inputs.begin( );
+ for( ; i != this->m_Inputs.end( ) && r == ""; ++i )
+ {
+ if( i->second->IsNotNull( ) )
+ {
+ Self* src = dynamic_cast< Self* >( ( *( i->second ) )->GetSource( ) );
+ if( src != NULL )
+ r = src->Update( );
+ }
+ else
+ r = "cpPlugins::Interface::ProcessObject: No input connected.";
+
+ } // rof
+
+ // Current update
+ if( r == "" )
+ r = this->_GenerateData( );
+
+ // Return error description, if any
+ return( r );
}
// -------------------------------------------------------------------------
-unsigned int cpPlugins::Interface::ProcessObject::
-GetNumberOfOutputs( ) const
+void cpPlugins::Interface::ProcessObject::
+DisconnectOutputs( )
{
- return( this->m_Outputs.size( ) );
+ _TDataContainer::iterator i = this->m_Outputs.begin( );
+ for( ; i != this->m_Outputs.end( ); ++i )
+ if( i->second->IsNotNull( ) )
+ ( *( i->second ) )->DisconnectPipeline( );
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetNumberOfInputs( unsigned int n )
+vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
+GetSingleInteractor( )
{
- this->m_Inputs.clear( );
- this->m_Inputs.resize( n, NULL );
+ return( this->m_SingleInteractor );
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetNumberOfOutputs( unsigned int n )
+const vtkRenderWindowInteractor* cpPlugins::Interface::ProcessObject::
+GetSingleInteractor( ) const
{
- this->_DeleteOutputs( );
- this->m_Outputs.clear( );
- this->m_Outputs.resize( n, NULL );
- this->m_OutputsDisconnected = false;
+ return( this->m_SingleInteractor );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::ProcessObject::
-SetInput(
- unsigned int idx, const cpPlugins::Interface::DataObject* dobj
- )
+SetSingleInteractor( vtkRenderWindowInteractor* interactor )
{
- if( idx < this->m_Inputs.size( ) )
- this->m_Inputs[ idx ] = dobj;
+ this->m_SingleInteractor = interactor;
}
// -------------------------------------------------------------------------
-cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
-GetOutput( unsigned int idx )
+cpPlugins::Interface::
+SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
+GetMPRViewer( )
{
- if( idx < this->m_Outputs.size( ) )
- return( this->m_Outputs[ idx ] );
- else
- return( NULL );
+ return( this->m_MPRViewer );
}
// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::ProcessObject::
-Update( )
+const cpPlugins::Interface::
+SimpleMPRWidget* cpPlugins::Interface::ProcessObject::
+GetMPRViewer( ) const
{
- // Force upstream updates
- for( unsigned int idx = 0; idx < this->m_Inputs.size( ); ++idx )
- this->m_Inputs[ idx ]->GetSource( )->Update( );
-
- // Current update
- std::string ret = this->_GenerateData( );
- this->m_OutputsDisconnected = false;
-
- // Return error description, if any
- return( ret );
+ return( this->m_MPRViewer );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::ProcessObject::
-DisconnectOutputs( )
+SetMPRViewer( cpPlugins::Interface::SimpleMPRWidget* wdg )
{
- this->m_OutputsDisconnected = true;
- for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
- if( this->m_Outputs[ idx ] != NULL )
- this->m_Outputs[ idx ]->GetDataObject( )->DisconnectPipeline( );
+ this->m_MPRViewer = wdg;
}
// -------------------------------------------------------------------------
-itk::DataObject* cpPlugins::Interface::ProcessObject::
-_GetInput( unsigned int idx )
+bool cpPlugins::Interface::ProcessObject::
+ExecConfigurationDialog( QWidget* parent )
{
- if( idx < this->m_Inputs.size( ) )
- return( this->m_Inputs[ idx ]->GetDataObject( ) );
+ bool r = false;
+#ifdef cpPlugins_Interface_QT4
+ if( this->m_ParametersDialog != NULL )
+ {
+ this->m_ParametersDialog->setParent( NULL );
+ this->m_ParametersDialog->setParameters( this->m_Parameters );
+ r = ( this->m_ParametersDialog->exec( ) == 1 );
+ }
else
- return( NULL );
+ r = false;
+#endif // cpPlugins_Interface_QT4
+ return( r );
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-_SetOutput( unsigned int idx, itk::DataObject* dobj )
+cpPlugins::Interface::ProcessObject::
+ProcessObject( )
+ : Superclass( ),
+ m_ParametersDialog( NULL ),
+ m_MPRViewer( NULL )
{
- if( idx < this->m_Outputs.size( ) )
- if( this->m_Outputs[ idx ] != NULL )
- this->m_Outputs[ idx ]->SetDataObject( dobj );
+ this->m_Parameters = TParameters::New( );
+ this->m_Parameters->SetProcessObject( this );
+
+#ifdef cpPlugins_Interface_QT4
+ if( QApplication::instance( ) != NULL )
+ this->m_ParametersDialog = new ParametersQtDialog( );
+#endif // cpPlugins_Interface_QT4
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+~ProcessObject( )
+{
+#ifdef cpPlugins_Interface_QT4
+ if( this->m_ParametersDialog != NULL )
+ delete this->m_ParametersDialog;
+#endif // cpPlugins_Interface_QT4
+
+ /*
+ auto iIt = this->m_Inputs.begin( );
+ for( ; iIt != this->m_Inputs.end( ); ++iIt )
+ delete iIt->second;
+ this->m_Inputs.clear( );
+ */
+
+ auto oIt = this->m_Outputs.begin( );
+ for( ; oIt != this->m_Outputs.end( ); ++oIt )
+ delete oIt->second;
+ this->m_Outputs.clear( );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::ProcessObject::
-_DeleteOutputs( )
+_AddInput( const std::string& name )
{
- if( !( this->m_OutputsDisconnected ) )
- for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
- if( this->m_Outputs[ idx ] != NULL )
- delete this->m_Outputs[ idx ];
+ auto i = this->m_Inputs.find( name );
+ if( i == this->m_Inputs.end( ) )
+ {
+ this->m_Inputs[ name ] = NULL;
+ this->Modified( );
+
+ } // fi
}
// eof - $RCSfile$