#include <cpBaseQtApplication/MainWindow.h>
-#include <cpExtensions/QT/SimpleMPRWidget.h>
-#include <cpBaseQtApplication/ActorPropertiesQDialog.h>
-#include <cpBaseQtApplication/Editor.h>
-#include <cpBaseQtApplication/PathsDialog.h>
-#include <vtkRenderer.h>
#include <QApplication>
-#include <QColorDialog>
#include <QDir>
#include <QFileDialog>
#include <QFileInfo>
#include <QMessageBox>
-#include <QTreeWidget>
+
+#include <cpExtensions/QT/SimpleMPRWidget.h>
+#include <cpExtensions/QT/ConfigurationChooser.h>
+
+#include <vtkDataSet.h>
+
+#include <cpBaseQtApplication/Editor.h>
+#include <cpBaseQtApplication/PathsDialog.h>
+#include <cpBaseQtApplication/PluginsNavigator.h>
+#include <cpBaseQtApplication/ActorPropertiesQDialog.h>
+
+/* TODO
+ #include <cpPlugins/Interface/Plugins.h>
+ #include <cpPlugins/BaseObjects/Widget.h>
+ #include <vtkImageData.h>
+ #include <vtkPolyData.h>
+ #include <vtkRenderer.h>
+ #include <QColorDialog>
+*/
// -------------------------------------------------------------------------
bool cpBaseQtApplication::MainWindow::_TBlocker::
// -------------------------------------------------------------------------
cpBaseQtApplication::MainWindow::
-MainWindow(
- int argc, char* argv[],
- QApplication* app,
- QWidget* parent
- )
+MainWindow( int argc, char* argv[], QApplication* app, QWidget* parent )
: Superclass( parent ),
m_Application( app ),
- m_PluginsPath( "." ),
- m_TreeWidget( NULL ),
+ m_Navigator( NULL ),
m_Editor( NULL ),
m_MPR( NULL )
{
+ // Use some evident paths
QFileInfo e_path( argv[ 0 ] );
QDir r_path( "." );
+ std::set< std::string > paths;
+ paths.insert( e_path.canonicalPath( ).toStdString( ) );
+ paths.insert( r_path.canonicalPath( ).toStdString( ) );
+ std::stringstream env;
+ for( auto p = paths.begin( ); p != paths.end( ); ++p )
+ env << *p << cpPlugins_ENV_SEPARATOR;
+
+ // Some variables
this->m_RunPath = r_path.canonicalPath( ).toStdString( );
- std::stringstream paths;
- paths
- << e_path.canonicalPath( ).toStdString( )
- << cpPlugins_SEPARATOR
- << this->m_RunPath;
-
- try { this->m_Interface.AddEnvironments( this->m_RunPath ); }
- catch( ... ) { }
- try { this->m_Interface.OpenEnvironments( this->m_RunPath ); }
- catch( ... ) { }
- try { this->m_Interface.SaveEnvironments( this->m_RunPath ); }
- catch( ... ) { }
- this->UpdateEnvironment( );
- this->m_Workspace.SetInterface( &( this->m_Interface ) );
+
+ // Get the plugins interface
+ this->m_Plugins = TPlugins::New( );
+ try { this->m_Plugins->AddEnvironments( env.str( ) ); } catch( ... ) { }
+ try { this->m_Plugins->LoadPaths( this->m_RunPath ); } catch( ... ) { }
+ this->updateEnvironment( );
+ try { this->m_Plugins->SavePaths( this->m_RunPath ); } catch( ... ) { }
+
+ // Create local workspace
+ this->m_Workspace = TWorkspace::New( );
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-UpdateEnvironment( )
+updateEnvironment( )
{
try
{
- this->m_Interface.LoadEnvironments( );
- this->m_Interface.GuessPlugins( );
+ this->m_Plugins->LoadEnvironments( );
+ this->m_Plugins->GuessPlugins( );
}
catch( std::exception& err )
{
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_Configure(
- QTreeWidget* tree,
- cpExtensions::QT::SimpleMPRWidget* mpr,
- cpBaseQtApplication::Editor* editor
- )
+updateFilter( const std::string& name )
{
- this->m_TreeWidget = tree;
- this->_UpdateLoadedPlugins( );
- this->m_Editor = editor;
- this->m_MPR = mpr;
- if( this->m_Editor != NULL )
- {
- this->m_Editor->setWorkspace( &( this->m_Workspace ) );
-
- // Slots <-> signals
- this->connect(
- this->m_Editor,
- SIGNAL( execFilter( const std::string& ) ),
- this,
- SLOT( _ExecFilter( const std::string& ) )
- );
- this->connect(
- this->m_Editor,
- SIGNAL( showFilterOutput( const std::string&, const std::string& ) ),
- this,
- SLOT( _ShowData( const std::string&, const std::string& ) )
- );
- this->connect(
- this->m_Editor,
- SIGNAL( hideFilterOutput( const std::string&, const std::string& ) ),
- this,
- SLOT( _HideData( const std::string&, const std::string& ) )
- );
- this->connect(
- this->m_Editor,
- SIGNAL( visualPropertiesFilterOutput( const std::string&, const std::string& ) ),
- this,
- SLOT( _DataProperties( const std::string&, const std::string& ) )
- );
-
- } // fi
- if( this->m_MPR != NULL )
- this->m_Workspace.SetMPRViewer( this->m_MPR );
- this->_ClearWorkspace( );
+ auto filter = this->m_Workspace->GetFilter( name );
+ if( filter != NULL )
+ cpBaseQtApplication_Execute( filter->Update( ) );
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_ClearWorkspace( )
+showData( const std::string& name, const std::string& port )
{
- if( this->m_Editor != NULL )
- this->m_Editor->clear( );
- if( this->m_MPR != NULL )
- this->m_MPR->Clear( );
- this->m_Workspace.Clear( );
-}
-
-// -------------------------------------------------------------------------
-void cpBaseQtApplication::MainWindow::
-_AddEnvironments( const std::string& environments )
-{
- try { this->m_Interface.AddEnvironments( environments ); }
- catch( ... ) { }
- try { this->m_Interface.SaveEnvironments( this->m_RunPath ); }
- catch( ... ) { }
- this->UpdateEnvironment( );
-}
-
-// -------------------------------------------------------------------------
-void cpBaseQtApplication::MainWindow::
-_LoadPlugins( const std::string& filename )
-{
- try
- {
- this->m_Interface.LoadFile( filename );
- this->_UpdateLoadedPlugins( );
- }
- catch( std::exception& err )
- {
- QMessageBox::critical(
- this,
- "Error loading plugins path",
- err.what( )
+ this->updateFilter( name );
+ auto filter = this->m_Workspace->GetFilter( name );
+ if( filter != NULL )
+ this->showData(
+ filter->GetOutput( port ), port + std::string( "@" ) + name
);
-
- } // yrt
-}
-
-// -------------------------------------------------------------------------
-void cpBaseQtApplication::MainWindow::
-_LoadPluginsFromPath( const std::string& path )
-{
- try
- {
- this->m_Interface.LoadDirectory( path );
- this->_UpdateLoadedPlugins( );
- }
- catch( std::exception& err )
- {
+ else
QMessageBox::critical(
this,
- "Error loading plugins path",
- err.what( )
+ QMessageBox::tr( "Error showing data" ),
+ QMessageBox::tr( "Unknown filter." )
);
-
- } // yrt
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_UpdateLoadedPlugins( )
+showData( cpPlugins::BaseObjects::DataObject* data, const std::string& name )
{
- if( this->m_TreeWidget == NULL )
+ if( this->m_MPR == NULL || data == NULL )
return;
- this->_Block( );
- auto categories = this->m_Interface.GetCategories( );
- unsigned int filter_count = 0;
- for( auto cIt = categories.begin( ); cIt != categories.end( ); ++cIt )
- {
- // Create or get category
- QList< QTreeWidgetItem* > cat_items =
- this->m_TreeWidget->findItems(
- cIt->c_str( ), Qt::MatchExactly | Qt::MatchRecursive
- );
- QTreeWidgetItem* cat = NULL;
- if( cat_items.size( ) == 0 )
- {
- cat = new QTreeWidgetItem(
- ( QTreeWidgetItem* )( NULL ), QStringList( cIt->c_str( ) )
- );
- this->m_TreeWidget->addTopLevelItem( cat );
- }
- else
- cat = cat_items[ 0 ];
-
- // Create filters
- auto filters = this->m_Interface.GetFilters( *cIt );
- filter_count += filters.size( );
- for( auto fIt = filters.begin( ); fIt != filters.end( ); ++fIt )
- {
- QList< QTreeWidgetItem* > filter_items =
- this->m_TreeWidget->findItems(
- fIt->c_str( ), Qt::MatchExactly | Qt::MatchRecursive
- );
- auto fiIt = filter_items.begin( );
- auto found_fiIt = filter_items.end( );
- for( ; fiIt != filter_items.end( ); ++fiIt )
- if( ( *fiIt )->parent( ) == cat )
- found_fiIt = fiIt;
-
- // Add filter
- if( found_fiIt == filter_items.end( ) )
- QTreeWidgetItem* filter = new QTreeWidgetItem(
- cat, QStringList( fIt->c_str( ) )
- );
-
- } // rof
-
- } // rof
- this->m_TreeWidget->expandAll( );
- this->_UnBlock( );
-
- if( filter_count == 0 )
+
+ // Associate visual data
+ this->_block( );
+ bool success = this->m_MPR->Add( data->GetVTK< vtkDataSet >( ), name );
+ this->_unBlock( );
+
+ // Show data or show an error
+ if( success )
+ this->m_MPR->Render( );
+ else
QMessageBox::critical(
this,
- "Error loading default plugins",
- "No plugins loaded: remember to load some!!!"
+ QMessageBox::tr( "Error showing data" ),
+ QMessageBox::tr( "Unknown conversion to a \"vtkProp\" object." )
);
}
// -------------------------------------------------------------------------
-void cpBaseQtApplication::MainWindow::
-_Block( )
-{
- this->m_Application->setOverrideCursor( Qt::WaitCursor );
- this->m_Application->installEventFilter( &( this->m_Blocker ) );
-}
+/* TODO
+ void cpBaseQtApplication::MainWindow::
+ hideData( const std::string& name, const std::string& port )
+ {
+ this->hideData( port + std::string( "@" ) + name );
+ }
+
+ // -------------------------------------------------------------------------
+ void cpBaseQtApplication::MainWindow::
+ hideData( const std::string& name )
+ {
+ }
+*/
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_UnBlock( )
+dataProperties( const std::string& name, const std::string& port )
{
- while( this->m_Application->overrideCursor( ) )
- this->m_Application->restoreOverrideCursor( );
- this->m_Application->removeEventFilter( &( this->m_Blocker ) );
+ this->dataProperties( port + std::string( "@" ) + name );
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_LoadWorkspace( const std::string& filename )
+dataProperties( const std::string& name )
{
- this->_ClearWorkspace( );
- std::string err = this->m_Workspace.LoadWorkspace( filename );
- if( err != "" )
- {
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error loading workspace" ),
- QMessageBox::tr( err.c_str( ) )
- );
- }
- else
+ if( this->m_MPR == NULL )
+ return;
+
+ auto props = this->m_MPR->GetViewProps( name );
+ if( props.size( ) > 0 )
{
- /* TODO
- if( this->m_Editor != NULL )
- this->m_Editor->setWorkspace( this->m_Workspace );
- */
+ this->_block( );
+ auto dlg = new cpBaseQtApplication::ActorPropertiesQDialog( NULL );
+ dlg->setProps( props );
+ dlg->addRenderWindow( this->m_MPR->GetXRenderWindow( ) );
+ dlg->addRenderWindow( this->m_MPR->GetYRenderWindow( ) );
+ dlg->addRenderWindow( this->m_MPR->GetZRenderWindow( ) );
+ dlg->addRenderWindow( this->m_MPR->GetWRenderWindow( ) );
+ this->_unBlock( );
+ dlg->exec( );
} // fi
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_SaveWorkspace( const std::string& filename )
+_block( )
{
- std::string err = this->m_Workspace.SaveWorkspace( filename );
- if( err != "" )
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error saving workspace" ),
- QMessageBox::tr( err.c_str( ) )
- );
+ if( this->m_Application != NULL )
+ {
+ this->m_Application->setOverrideCursor( Qt::WaitCursor );
+ this->m_Application->installEventFilter( &( this->m_Blocker ) );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_BackgroundProperties( unsigned int i )
+_unBlock( )
{
- if( this->m_MPR == NULL )
- return;
-
- QColor color =
- QColorDialog::getColor(
- QColor( 0, 0, 0 ),
- this,
- "Select Color",
- QColorDialog::DontUseNativeDialog
- );
- if( color.isValid( ) )
+ if( this->m_Application != NULL )
{
- double r = double( color.red( ) ) / double( 255 );
- double g = double( color.green( ) ) / double( 255 );
- double b = double( color.blue( ) ) / double( 255 );
- if( i >= 4 )
- {
- unsigned int maxId = ( i == 4 )? 3: 4;
- for( unsigned int j = 0; j < maxId; ++j )
- {
- auto ren = this->m_MPR->GetRenderer( j );
- if( ren != NULL )
- {
- ren->SetBackground( r, g, b );
- ren->Render( );
-
- } // fi
-
- } // rof
- }
- else
- {
- auto ren = this->m_MPR->GetRenderer( i );
- if( ren != NULL )
- {
- ren->SetBackground( r, g, b );
- ren->Render( );
-
- } // fi
-
- } // fi
+ while( this->m_Application->overrideCursor( ) )
+ this->m_Application->restoreOverrideCursor( );
+ this->m_Application->removeEventFilter( &( this->m_Blocker ) );
} // fi
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_ShowData( const std::string& filter_name, const std::string& output_name )
+_configure( PluginsNavigator* nav, TMPR* mpr, Editor* edt )
{
- if( this->m_MPR == NULL )
- return;
+ this->m_Navigator = nav;
+ this->m_MPR = mpr;
+ this->m_Editor = edt;
+ this->_updatePlugins( );
+ if( this->m_Editor != NULL )
+ this->m_Editor->setWorkspace( this->m_Workspace );
- auto output = this->m_Workspace.GetOutput( filter_name, output_name );
- if( output != NULL )
+ // Associate interactors
+ if( this->m_MPR != NULL )
{
- this->_Block( );
- auto actor = output->GetVTKActor( );
- if( actor != NULL )
- {
- this->m_MPR->AddActor(
- actor, output_name + std::string( "@" ) + filter_name
- );
- this->_UnBlock( );
- }
- else
- {
- this->_UnBlock( );
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error showing data" ),
- QMessageBox::tr( "Unknown VTK conversion." )
- );
-
- } // fi
- }
- else
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error showing data" ),
- QMessageBox::tr( "Unknown port name." )
- );
+ this->m_Workspace->AddInteractor( this->m_MPR->GetXInteractor( ) );
+ this->m_Workspace->AddInteractor( this->m_MPR->GetYInteractor( ) );
+ this->m_Workspace->AddInteractor( this->m_MPR->GetZInteractor( ) );
+ this->m_Workspace->AddInteractor( this->m_MPR->GetWInteractor( ) );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_HideData( const std::string& filter, const std::string& output )
+_updatePlugins( )
{
- std::cout << "MainWindow::HideData" << std::endl;
- /* TODO
- */
+ if( this->m_Navigator == NULL )
+ return;
+ this->_block( );
+ this->m_Navigator->Update( );
+ this->_unBlock( );
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_DataProperties(
- const std::string& filter_name, const std::string& output_name
- )
+_loadWorkspace( const std::string& filename )
{
- if( this->m_MPR == NULL )
- return;
-
- auto output = this->m_Workspace.GetOutput( filter_name, output_name );
- if( output != NULL )
+ try
{
- this->_Block( );
- auto actors = this->m_MPR->GetActors(
- output_name + std::string( "@" ) + filter_name
- );
- auto dlg = new ActorPropertiesQDialog( NULL );
- for( auto i = actors.begin( ); i != actors.end( ); ++i )
- dlg->addActor( *i );
- dlg->addRenderWindow( this->m_MPR->GetRenderWindow( 0 ) );
- dlg->addRenderWindow( this->m_MPR->GetRenderWindow( 1 ) );
- dlg->addRenderWindow( this->m_MPR->GetRenderWindow( 2 ) );
- dlg->addRenderWindow( this->m_MPR->GetRenderWindow( 3 ) );
- this->_UnBlock( );
- dlg->exec( );
+ this->m_Workspace->Load( filename );
}
- else
+ catch( std::exception& err )
+ {
QMessageBox::critical(
this,
- QMessageBox::tr( "Error showing data" ),
- QMessageBox::tr( "Unknown port name." )
+ QMessageBox::tr( "Error loading workspace" ),
+ QMessageBox::tr( err.what( ) )
);
+
+ } // yrt
+ if( this->m_Editor != NULL )
+ this->m_Editor->redrawWorkspace( );
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_InteractiveLoadPlugins( )
+_loadWorkspace( )
{
QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::ExistingFiles );
- dlg.setDirectory( this->m_PluginsPath.c_str( ) );
-
- std::stringstream filter;
- std::string suffix = std::string( cpPlugins_LIB_EXT );
- filter << "Plugins file (*." << cpPlugins_LIB_EXT << ");;All files (*)";
- dlg.setNameFilter( filter.str( ).c_str( ) );
- dlg.setDefaultSuffix( suffix.c_str( ) );
+ dlg.setFileMode( QFileDialog::ExistingFile );
+ dlg.setDirectory( "." );
+ dlg.setNameFilter(
+ QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
+ );
+ dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
if( !( dlg.exec( ) ) )
return;
- QStringList names = dlg.selectedFiles( );
- for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt )
- this->_LoadPlugins( qIt->toStdString( ) );
+ this->_loadWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_InteractiveLoadPluginsFromPath( )
+_saveWorkspace( const std::string& filename )
{
- QFileDialog d( this );
- d.setFileMode( QFileDialog::DirectoryOnly );
- d.setDirectory( this->m_PluginsPath.c_str( ) );
- if( !( d.exec( ) ) )
- return;
- this->_LoadPluginsFromPath( d.selectedFiles( ).begin( )->toStdString( ) );
-}
+ try
+ {
+ this->m_Workspace->Save( filename );
+ }
+ catch( std::exception& err )
+ {
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error saving workspace" ),
+ QMessageBox::tr( err.what( ) )
+ );
-// -------------------------------------------------------------------------
-void cpBaseQtApplication::MainWindow::
-_ShowPlugins( )
-{
- auto paths = this->m_Interface.GetPaths( );
- auto plugins = this->m_Interface.GetPlugins( );
- std::stringstream info;
- info << "----- PATHS -----" << std::endl;
- for( auto i = paths.begin( ); i != paths.end( ); ++i )
- info << " " << *i << std::endl;
- info << std::endl << "----- PLUGINS -----" << std::endl;
- for( auto i = plugins.begin( ); i != plugins.end( ); ++i )
- info << " " << *i << std::endl;
- QMessageBox::information(
- this,
- "Loaded libraries and plugins information",
- info.str( ).c_str( )
- );
+ } // yrt
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_InteractiveLoadWorkspace( )
+_saveWorkspace( )
{
QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::ExistingFile );
+ dlg.setFileMode( QFileDialog::AnyFile );
dlg.setDirectory( "." );
+ dlg.setAcceptMode( QFileDialog::AcceptSave );
dlg.setNameFilter(
QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
);
dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
if( !( dlg.exec( ) ) )
return;
- this->_LoadWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
+ this->_saveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_InteractiveSaveWorkspace( )
+_showPlugins( )
{
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::AnyFile );
- dlg.setDirectory( "." );
- dlg.setAcceptMode( QFileDialog::AcceptSave );
- dlg.setNameFilter(
- QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
+ std::stringstream info;
+ this->m_Plugins->Print( info );
+ QMessageBox::information(
+ this,
+ "Loaded libraries and plugins information",
+ info.str( ).c_str( )
);
- dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
- if( !( dlg.exec( ) ) )
- return;
- this->_SaveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_InteractiveAddEnviromentPaths( )
+_addEnvironmentPaths( const std::string& envs )
+{
+ try { this->m_Plugins->AddEnvironments( envs ); } catch( ... ) { }
+ try { this->m_Plugins->SavePaths( this->m_RunPath ); } catch( ... ) { }
+ this->updateEnvironment( );
+ this->_updatePlugins( );
+}
+
+// -------------------------------------------------------------------------
+void cpBaseQtApplication::MainWindow::
+_addEnvironmentPaths( )
{
PathsDialog dlg( this );
- dlg.addPaths( this->m_Interface.GetPaths( ) );
+ dlg.addPaths( this->m_Plugins->GetPaths( ) );
if( dlg.exec( ) )
{
auto paths = dlg.getPaths( );
std::stringstream envs;
for( auto p = paths.begin( ); p != paths.end( ); ++p )
- envs << *p << cpPlugins_SEPARATOR;
- this->_AddEnvironments( envs.str( ) );
- this->UpdateEnvironment( );
+ envs << *p << cpPlugins_ENV_SEPARATOR;
+ this->_addEnvironmentPaths( envs.str( ) );
} // fi
}
// -------------------------------------------------------------------------
void cpBaseQtApplication::MainWindow::
-_ExecFilter( const std::string& filter_name )
+_loadPlugins( const std::string& filename )
{
- this->_Block( );
try
{
- this->m_Workspace.Execute( filter_name );
- this->_UnBlock( );
+ this->m_Plugins->LoadFile( filename );
+ this->_updatePlugins( );
}
- catch( itk::ExceptionObject& err1 )
+ catch( std::exception& err )
{
- this->_UnBlock( );
QMessageBox::critical(
this,
- QMessageBox::tr( "Error executing filter" ),
- QMessageBox::tr( err1.GetDescription( ) )
+ "Error loading plugins path",
+ err.what( )
);
- }
- catch( std::exception& err2 )
+
+ } // yrt
+}
+
+// -------------------------------------------------------------------------
+void cpBaseQtApplication::MainWindow::
+_loadPlugins( )
+{
+ QFileDialog dlg( this );
+ dlg.setFileMode( QFileDialog::ExistingFiles );
+
+ std::stringstream filter;
+ std::string suffix = std::string( cpPlugins_LIB_EXT );
+ filter << "Plugins file (*" << cpPlugins_LIB_EXT << ");;All files (*)";
+ dlg.setNameFilter( filter.str( ).c_str( ) );
+ dlg.setDefaultSuffix( suffix.c_str( ) );
+ if( !( dlg.exec( ) ) )
+ return;
+ QStringList names = dlg.selectedFiles( );
+ for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt )
+ this->_loadPlugins( qIt->toStdString( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpBaseQtApplication::MainWindow::
+_loadPluginsFromPath( const std::string& path )
+{
+ try
{
- this->_UnBlock( );
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error executing filter" ),
- QMessageBox::tr( err2.what( ) )
- );
+ this->m_Plugins->LoadDirectory( path );
+ this->_updatePlugins( );
}
- catch( ... )
+ catch( std::exception& err )
{
- this->_UnBlock( );
QMessageBox::critical(
this,
- QMessageBox::tr( "Error executing filter" ),
- QMessageBox::tr( "Unknown error" )
+ "Error loading plugins path",
+ err.what( )
);
} // yrt
}
+// -------------------------------------------------------------------------
+void cpBaseQtApplication::MainWindow::
+_loadPluginsFromPath( )
+{
+ QFileDialog d( this );
+ d.setFileMode( QFileDialog::DirectoryOnly );
+ if( !( d.exec( ) ) )
+ return;
+ this->_loadPluginsFromPath( d.selectedFiles( ).begin( )->toStdString( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpBaseQtApplication::MainWindow::
+_actorsProperties( )
+{
+ if( this->m_MPR != NULL )
+ {
+ auto dlg = new cpExtensions::QT::ConfigurationChooser( this );
+ dlg->setData( this->m_MPR );
+ dlg->exec( );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+/* TODO
+ void cpBaseQtApplication::MainWindow::
+ _ClearWorkspace( )
+ {
+ if( this->m_Editor != NULL )
+ this->m_Editor->clear( );
+ this->m_Workspace->Clear( );
+ }
+*/
+
// eof - $RCSfile$