QFileInfo info( argv[ 0 ] );
if( info.exists( ) )
{
- this->m_PluginsPath = info.canonicalPath( ).toStdString( );
- this->_LoadPluginsFromPath( this->m_PluginsPath );
+ if( !( this->m_Interface.LoadConfiguration( cpPlugins_CONFIG_FILE ) ) )
+ {
+ this->m_PluginsPath = info.canonicalPath( ).toStdString( );
+ this->_LoadPluginsFromPath( this->m_PluginsPath );
+ }
+ else
+ this->_UpdateLoadedPlugins( );
} // fi
} // rof
this->_UnBlock( );
+ this->m_Interface.SaveConfiguration( cpPlugins_CONFIG_FILE );
}
// -------------------------------------------------------------------------
void PipelineEditor::
_ButtonLoadPluginsFile( )
{
- /*
QFileDialog dlg( this );
dlg.setFileMode( QFileDialog::ExistingFiles );
dlg.setDirectory( "." );
std::stringstream name_filter;
- std::string suffix = std::string( cpPlugins_PLUGIN_EXT ).substr( 1 );
-
- name_filter << "Plugins file (*" << cpPlugins_PLUGIN_EXT << ");;All files (*)";
+ std::string suffix = std::string( cpPlugins_PLUGIN_EXT );
+ name_filter
+ << "Plugins file (*." << cpPlugins_PLUGIN_EXT << ");;All files (*)";
dlg.setNameFilter( name_filter.str( ).c_str( ) );
dlg.setDefaultSuffix( suffix.c_str( ) );
QStringList names = dlg.selectedFiles( );
std::stringstream err_str;
for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt )
- err_str << this->m_Interface->Load( qIt->toStdString( ) );
+ {
+ try
+ {
+ this->m_Interface.LoadPluginFile( qIt->toStdString( ) );
+ }
+ catch( std::exception& err )
+ {
+ err_str << err.what( ) << std::endl;
+
+ } // yrt
+
+ } // rof
// Show an error message
std::string err = err_str.str( );
);
// Update view
- this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath );
+ // TODO: this->m_Interface.SaveDefaultConfiguration( this->m_PluginsPath );
this->_UpdateLoadedPlugins( );
- */
}
// -------------------------------------------------------------------------
_ButtonLoadPluginsPath( )
{
/*
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::DirectoryOnly );
- dlg.setDirectory( "." );
- if( !( dlg.exec( ) ) )
+ QFileDialog dlg( this );
+ dlg.setFileMode( QFileDialog::DirectoryOnly );
+ dlg.setDirectory( "." );
+ if( !( dlg.exec( ) ) )
return;
- // Read
- std::string dir = dlg.selectedFiles( ).begin( )->toStdString( );
- std::string err = this->m_Interface->LoadFromFolder( dir, false );
- if( err != "" )
+ // Read
+ std::string dir = dlg.selectedFiles( ).begin( )->toStdString( );
+ std::string err = this->m_Interface->LoadFromFolder( dir, false );
+ if( err != "" )
QMessageBox::critical(
- this,
- "Error loading plugins directory",
- err.c_str( )
- );
+ this,
+ "Error loading plugins directory",
+ err.c_str( )
+ );
- // Update view
- this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath );
- this->_UpdateLoadedPlugins( );
+ // Update view
+ this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath );
+ this->_UpdateLoadedPlugins( );
*/
}
} // fi
}
+// -------------------------------------------------------------------------
+bool cpPlugins::BaseWidget::
+IsInteractive( )
+{
+ return( true );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseWidget::
+SetInteractionObjects( const std::vector< void* >& objs )
+{
+ if( objs.size( ) > 0 )
+ {
+ vtkRenderWindowInteractor* rwi =
+ reinterpret_cast< vtkRenderWindowInteractor* >( objs[ 0 ] );
+ this->SetSingleInteractor( rwi );
+ }
+ if( objs.size( ) > 1 )
+ {
+ TMPRWidget* wdg = reinterpret_cast< TMPRWidget* >( objs[ 1 ] );
+ this->SetMPRViewer( wdg );
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
cpPlugins::BaseWidget::
BaseWidget( )
void SetMPRViewer( TMPRWidget* v );
void SetSingleInteractor( vtkRenderWindowInteractor* i );
+ virtual bool IsInteractive( ) override;
+ virtual void SetInteractionObjects(
+ const std::vector< void* >& objs
+ ) override;
+
protected:
BaseWidget( );
virtual ~BaseWidget( );
#include <cpPlugins/Interface.h>
#ifdef cpPlugins_SYS_WINDOWS
+# include <Windows.h>
#else // cpPlugins_SYS_WINDOWS
# include <dlfcn.h>
#endif // cpPlugins_SYS_WINDOWS
return( this->m_Filters );
}
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::
+LoadConfiguration( const std::string& filename )
+{
+ std::ifstream in( filename.c_str( ) );
+ if( !in )
+ return( false );
+
+ this->UnloadAll( );
+ std::string line;
+ while( std::getline( in, line ) )
+ {
+ try
+ {
+ this->LoadPluginFile( line );
+ }
+ catch( ... )
+ {
+ // Do nothing
+
+ } // yrt
+
+ } // elihw
+ return( true );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::
+SaveConfiguration( const std::string& filename ) const
+{
+ std::ofstream out( filename.c_str( ) );
+ if( !out )
+ return( false );
+ auto dIt = this->m_DynLibraries.begin( );
+ for( ; dIt != this->m_DynLibraries.end( ); ++dIt )
+ out << dIt->first << std::endl;
+ out.close( );
+}
+
// -------------------------------------------------------------------------
void cpPlugins::Interface::
LoadPluginFile( const std::string& filename )
{
void* hnd = NULL;
#ifdef cpPlugins_SYS_WINDOWS
- // TODO:
+ hnd = ::LoadLibraryA( fname.c_str( ) );
#else // cpPlugins_SYS_WINDOWS
hnd = dlopen( fname.c_str( ), RTLD_NOW | RTLD_GLOBAL );
dlerror( );
TFilters cpPlugins::Interface::
_DLGetFilters( void* hnd )
{
+ typedef const TFilters ( *f_t )( );
+
TFilters filters;
#ifdef cpPlugins_SYS_WINDOWS
- // TODO:
+ auto f = ( f_t )(
+ ::GetProcAddress( ( HMODULE )hnd, "cpPlugins_LoadedFilters" )
+ );
+ std::cout << f << std::endl;
#else // cpPlugins_SYS_WINDOWS
- typedef const TFilters ( *f_t )( );
auto f = ( f_t ) dlsym( hnd, "cpPlugins_LoadedFilters" );
const char* err = dlerror( );
if( err != NULL )
);
} // fi
- filters = f( );
#endif // cpPlugins_SYS_WINDOWS
+ filters = f( );
return( filters );
}
_DLClose( void* hnd )
{
#ifdef cpPlugins_SYS_WINDOWS
- // TODO:
+ ::FreeLibrary( ( HMODULE )hnd );
#else // cpPlugins_SYS_WINDOWS
dlclose( hnd );
#endif // cpPlugins_SYS_WINDOWS
const TFilters& GetFilters( );
+ bool LoadConfiguration( const std::string& filename );
+ bool SaveConfiguration( const std::string& filename ) const;
void LoadPluginFile( const std::string& filename );
void UnloadAll( );
#endif // cpPlugins_QT4
}
+// -------------------------------------------------------------------------
+bool cpPlugins::ProcessObject::
+IsInteractive( )
+{
+ return( false );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::ProcessObject::
+SetInteractionObjects( const std::vector< void* >& objs )
+{
+ // Do nothing
+}
+
// -------------------------------------------------------------------------
cpPlugins::ProcessObject::
ProcessObject( )
namespace cpPlugins
{
- // Forward declaration
- /* TODO
- class ParametersQtDialog;
- */
-
/**
*/
class cpPlugins_EXPORT ProcessObject
// Qt dialog creation
virtual ParametersQtDialog* CreateQtDialog( );
+ virtual bool IsInteractive( );
+ virtual void SetInteractionObjects( const std::vector< void* >& objs );
protected:
ProcessObject( );
this->m_Interface->Create( category, filter );
if( f.IsNotNull( ) )
{
- BaseWidget* bw = dynamic_cast< BaseWidget* >( f.GetPointer( ) );
- if( bw != NULL )
+ if( f->IsInteractive( ) )
{
- bw->SetSingleInteractor( this->m_SingleInteractor );
- bw->SetMPRViewer( this->m_MPRViewer );
+ std::vector< void* > interactive_objects;
+ interactive_objects.push_back( this->m_SingleInteractor );
+ interactive_objects.push_back( this->m_MPRViewer );
+ f->SetInteractionObjects( interactive_objects );
} // fi
Object::Pointer o = f.GetPointer( );
i complex
+i map
i string
i vector
i itkArray.h
c itk::ImportImageContainer< unsigned long , std::complex< #5 > >
c itk::ImportImageContainer< unsigned long , itk::RGBPixel< #1 > >
c itk::ImportImageContainer< unsigned long , itk::RGBAPixel< #1 > >
+c itk::SimpleDataObjectDecorator< std::map< itk::Index< #6 >, std::pair< itk::Index< #6 >, short >, itk::Functor::IndexLexicographicCompare< #6 > > >
a #1 = #integers;#floats
a #2 = #all_dims
a #3 = bool;std::string