X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2FPipelineEditor%2FPipelineEditor.cxx;h=2f7d7eabee3d7f4adf90e6a7fc8241dc7cf40901;hb=ddc5b66441101ed6584f4972ca0c4d13c588dacf;hp=5fe9bdf70014a9fb8eb6b7e2ab693cf5a73c022d;hpb=dc1614d6180dbb97486870a379ae73e2c70525a1;p=cpPlugins.git diff --git a/appli/PipelineEditor/PipelineEditor.cxx b/appli/PipelineEditor/PipelineEditor.cxx index 5fe9bdf..2f7d7ea 100644 --- a/appli/PipelineEditor/PipelineEditor.cxx +++ b/appli/PipelineEditor/PipelineEditor.cxx @@ -61,10 +61,20 @@ PipelineEditor( int argc, char* argv[], QApplication* app, QWidget* parent ) 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 + QDir exec_dir( "." ); + if( exec_dir.exists( ) ) + this->_LoadPluginsFromPath( exec_dir.canonicalPath( ).toStdString( ) ); /* TODO this->m_Interface = new cpPlugins::Interface( ); @@ -130,14 +140,16 @@ _LoadPluginsFromPath( const std::string& path ) { try { - this->m_Interface.LoadPluginFile( fIt->toStdString( ) ); + this->m_Interface.LoadPluginFile( + ( dir.absolutePath( ) + QDir::separator( ) + *fIt ).toStdString( ) + ); } - catch( ... ) + catch( std::exception& err ) { // Just ignore un-loadable libraries - } + } // yrt - } // yrt + } // rof this->_UpdateLoadedPlugins( ); } @@ -154,6 +166,7 @@ _UpdateLoadedPlugins( ) "Error loading default plugins", "No plugins loaded: remember to load some!!!" ); + this->_UnBlock( ); return; } // fi @@ -200,6 +213,7 @@ _UpdateLoadedPlugins( ) } // rof this->_UnBlock( ); + this->m_Interface.SaveConfiguration( cpPlugins_CONFIG_FILE ); } // ------------------------------------------------------------------------- @@ -223,15 +237,14 @@ _UnBlock( ) 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( ) ); @@ -242,7 +255,18 @@ _ButtonLoadPluginsFile( ) 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( ); @@ -254,9 +278,8 @@ _ButtonLoadPluginsFile( ) ); // Update view - this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath ); + // TODO: this->m_Interface.SaveDefaultConfiguration( this->m_PluginsPath ); this->_UpdateLoadedPlugins( ); - */ } // ------------------------------------------------------------------------- @@ -264,25 +287,25 @@ void PipelineEditor:: _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( ); */ } @@ -407,6 +430,14 @@ _ShowFilterOutput( } else if( mdata != NULL ) { + if( this->m_UI->Viewer->AddData( mdata, data_name ) ) + { + this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 ); + this->_Block( ); + this->m_UI->Viewer->ShowData( data_name ); + this->_UnBlock( ); + + } // fi } else QMessageBox::critical(