-
-#ifdef cpPlugins_Interface_QT4
-
-/*
- #include <QApplication>
- #include <QFileDialog>
- #include <QMenu>
- #include <QMessageBox>
- #include <QWidget>
-*/
-
-#ifdef _WIN32
-# define PLUGIN_PREFIX ""
-# define PLUGIN_EXT "dll"
-# define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)"
-#else // Linux
-# define PLUGIN_PREFIX "lib"
-# define PLUGIN_EXT "so"
-# define PLUGIN_REGEX "Plugins file (*.so);;All files (*)"
-#endif // _WIN32
-
-#endif // cpPlugins_Interface_QT4
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::Plugins::
-Plugins( )
- : m_Widget( NULL ),
- m_Application( NULL ),
- m_Interface( NULL ),
- m_LastLoadedPlugin( "" ),
- m_ActiveFilter( NULL )
-{
- this->m_Interface = new TInterface( );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::Plugins::
-~Plugins( )
-{
- if( this->m_Interface != NULL )
- delete this->m_Interface;
-}
-
-// -------------------------------------------------------------------------
-QWidget* cpPlugins::Interface::Plugins::
-GetWidget( )
-{
- return( this->m_Widget );
-}
-
-// -------------------------------------------------------------------------
-const QWidget* cpPlugins::Interface::Plugins::
-GetWidget( ) const
-{
- return( this->m_Widget );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-SetWidget( QWidget* widget )
-{
- this->m_Widget = widget;
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-BlockWidget( )
-{
-#ifdef cpPlugins_Interface_QT4
- if( this->m_Widget != NULL )
- {
- QApplication::setOverrideCursor( Qt::WaitCursor );
- this->m_Widget->setEnabled( false );
-
- } // fi
-#endif // cpPlugins_Interface_QT4
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-UnblockWidget( )
-{
-#ifdef cpPlugins_Interface_QT4
- if( this->m_Widget != NULL )
- {
- QApplication::restoreOverrideCursor( );
- this->m_Widget->setEnabled( true );
-
- } // fi
-#endif // cpPlugins_Interface_QT4
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-DialogLoadPlugins( )
-{
-#ifdef cpPlugins_Interface_QT4
- if( this->m_Widget != NULL )
- {
- QFileDialog dialog( this->m_Widget );
- dialog.setFileMode( QFileDialog::ExistingFile );
- dialog.setDirectory( this->m_LastLoadedPlugin.c_str( ) );
- dialog.setNameFilter( QFileDialog::tr( PLUGIN_REGEX ) );
- dialog.setDefaultSuffix( QFileDialog::tr( PLUGIN_EXT ) );
- if( !( dialog.exec( ) ) )
- return;
-
- std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
- if( !( this->LoadPlugins( fname ) ) )
- QMessageBox::critical(
- this->m_Widget,
- QMessageBox::tr( "Ignoring plugin" ),
- QMessageBox::tr( fname.c_str( ) )
- );
-
- } // fi
-#endif // cpPlugins_Interface_QT4
-}
-
-// -------------------------------------------------------------------------
-BaseApplication* cpPlugins::Interface::Plugins::
-GetApplication( )
-{
- return( this->m_Application );
-}
-
-// -------------------------------------------------------------------------
-const BaseApplication* cpPlugins::Interface::Plugins::
-GetApplication( ) const
-{
- return( this->m_Application );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-SetApplication( BaseApplication* a )
-{
- this->m_Application = a;
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-LoadPlugins( )
-{
- // TODO: what to do here?
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-LoadPlugins( const std::string& fname )
-{
- this->BlockWidget( );
-
- // Is it already loaded?
- bool ret = true;
- if( this->m_LoadedPlugins.find( fname ) == this->m_LoadedPlugins.end( ) )
- {
- // Was it succesfully loaded?
- ret = this->m_Interface->Load( fname );
-
- // Update a simple track
- if( ret )
- {
- this->m_LoadedPlugins.insert( fname );
- this->m_LastLoadedPlugin = fname;
- this->_UpdateLoadedPluginsInformation( );
-
- } // fi
-
- } // fi
-
- this->UnblockWidget( );
- return( ret );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-LoadPluginsConfigurationFile( const std::string& fname )
-{
- // Load file into a char buffer
- std::ifstream in(
- fname.c_str( ), std::ios::in | std::ios::binary | std::ios::ate
- );
- if( !in.is_open( ) )
- return( false );
-
- std::streampos size = in.tellg( );
- char* buffer = new char[ size ];
- in.seekg( 0, std::ios::beg );
- in.read( buffer, size );
- in.close( );
-
- // Read stream
- std::stringstream in_stream( buffer );
- char line[ 4096 ];
- while( in_stream )
- {
- in_stream.getline( line, 4096 );
- this->LoadPlugins( line );
-
- } // elihw
- delete buffer;
-
- return( true );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::Plugins::
-TStringContainer& cpPlugins::Interface::Plugins::
-GetLoadedPlugins( ) const
-{
- return( this->m_LoadedPlugins );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetLoadedFilters( TStringContainer& filters ) const
-{
- filters.clear( );
- auto pIt = this->m_LoadedFilters.begin( );
- for( ; pIt != this->m_LoadedFilters.end( ); ++pIt )
- for( auto fIt = pIt->second.begin( ); fIt != pIt->second.end( ); ++fIt )
- filters.insert( *fIt );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::Plugins::
-TStringContainer& cpPlugins::Interface::Plugins::
-GetLoadedFilters( const std::string& plugin ) const
-{
- static const TStringContainer EMPTY;
- auto pIt = this->m_LoadedFilters.find( plugin );
- if( pIt != this->m_LoadedFilters.end( ) )
- return( pIt->second );
- else
- return( EMPTY );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-AddInteractor( vtkRenderWindowInteractor* interactor )
-{
- this->m_Interactors.insert( interactor );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-RemoveInteractor( vtkRenderWindowInteractor* interactor )
-{
- this->m_Interactors.erase( interactor );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-ClearInteractors( )
-{
- this->m_Interactors.clear( );
-}
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Plugins_HasMacro( F ) \
- bool cpPlugins::Interface::Plugins:: \
- Has##F( ) const \
- { \
- return( this->m_IOFilters.find( #F ) != this->m_IOFilters.end( ) ); \
- }
-
-cpPlugins_Plugins_HasMacro( ImageReader );
-cpPlugins_Plugins_HasMacro( DicomSeriesReader );
-cpPlugins_Plugins_HasMacro( MeshReader );
-cpPlugins_Plugins_HasMacro( ImageWriter );
-cpPlugins_Plugins_HasMacro( MeshWriter );
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadImage( const std::string& fname, const std::string& parent )
-{
- std::vector< std::string > fnames( 1, fname );
- return( this->ReadImage( fnames, parent ) );
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadImage(
- const std::vector< std::string >& fnames, const std::string& parent
- )
-{
- // Activate reader
- auto fIt = this->m_IOFilters.find( "ImageReader" );
- if( fIt == this->m_IOFilters.end( ) )
- return( "" );
- this->m_ActiveFilter = fIt->second;
-
- // Configure reader
- TParameters* params = this->GetActiveFilterParameters( );
- params->ClearStringList( "FileNames" );
- for( auto nIt = fnames.begin( ); nIt != fnames.end( ); ++nIt )
- params->AddToStringList( "FileNames", *nIt );
-
- // Execute filter
- std::string err = this->UpdateActiveFilter( );
- if( err == "" )
- {
-#error GET OBJECT NAME
- }
- else
- {
-#error THROW ERROR
- } // fi
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadImage( const std::string& parent )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadDicomSeries( const std::string& parent )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadMesh(
- const std::string& fname, const std::string& parent
- )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadMesh( const std::string& parent )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-WriteDataObject(
- const std::string& fname, const std::string& name
- )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-WriteDataObject( const std::string& name )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-ClearDataObjects( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-DeleteDataObject( const std::string& name )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetDataObjects( TStringContainer& names )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-GetParent( const std::string& name ) const
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetChildren(
- TStringContainer& names, const std::string& name
- ) const
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetRoots( TStringContainer& names ) const
-{
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-ActivateFilter( const std::string& name )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-DeactivateFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-HasActiveFilter( ) const
-{
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-IsActiveFilterInteractive( ) const
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetActiveFilterInputsNames( TStringContainer& names ) const
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetActiveFilterOutputsNames( TStringContainer& names ) const
-{
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-ConnectInputInActiveFilter(
- const std::string& object_name, const std::string& input_name
- )
-{
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-SetOutputNameInActiveFilter(
- const std::string& new_object_name, const std::string& output_name
- )
-{
-}
-
-// -------------------------------------------------------------------------
-TParameters* cpPlugins::Interface::Plugins::
-GetActiveFilterParameters( )
-{
-}
-
-// -------------------------------------------------------------------------
-const TParameters* cpPlugins::Interface::Plugins::
-GetActiveFilterParameters( ) const
-{
-}
-
-// -------------------------------------------------------------------------
-TProcessObject::DialogResult cpPlugins::Interface::Plugins::
-ConfigureActiveFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-UpdateActiveFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-_UpdateLoadedPluginsInformation( )
-{
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-_InsertNewData( TDataObject* dobj, const std::string& parent )
-{
-}
-
-/*
- protected:
- // MVC objects
- QWidget* m_Widget;
- BaseApplication* m_Application;
-
- // Plugins interface
- TInterface m_Interface;
- TStringContainer m_LoadedPlugins;
- std::string m_LastLoadedPlugin;
-
- // Loaded filters
- std::map< std::string, TProcessObject::Pointer > m_IOFilters;
- TProcessObject::Pointer m_ActiveFilter;
- std::map< std::string, std::string > m_ActiveFilterOutputs;
- std::map< std::string, TStringContainer > m_LoadedFilters;
-
- // Loaded data objects
- typedef std::pair< std::string, TDataObject::Pointer > _TTreeNode;
- std::map< std::string, _TTreeNode > m_DataObjects;
-
- // Associated interactors
- std::set< vtkRenderWindowInteractor* > m_Interactors;
- };
-
- } // ecapseman
-
- } // ecapseman
-*/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#include <cpPlugins/Interface/Config.h>
-
-#include <fstream>
-#include <sstream>
-
-#ifdef cpPlugins_Interface_QT4
-
-#include <QApplication>
-#include <QFileDialog>
-#include <QMenu>
-#include <QMessageBox>
-#include <QWidget>
-
-#ifdef _WIN32
-# define PLUGIN_PREFIX ""
-# define PLUGIN_EXT "dll"
-# define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)"
-#else // Linux
-# define PLUGIN_PREFIX "lib"
-# define PLUGIN_EXT "so"
-# define PLUGIN_REGEX "Plugins file (*.so);;All files (*)"
-#endif // _WIN32
-
-#endif // cpPlugins_Interface_QT4
-
-
-
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-AddInteractor( vtkRenderWindowInteractor* interactor )
-{
- this->m_Interactors.insert( interactor );
-}