- // Create or get category
- QList< QTreeWidgetItem* > cat_items =
- this->m_UI->LoadedPlugins->findItems(
- cIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
- );
- QTreeWidgetItem* cat = NULL;
- if( cat_items.size( ) == 0 )
- {
- cat = new QTreeWidgetItem(
- ( QTreeWidgetItem* )( NULL ), QStringList( cIt->first.c_str( ) )
- );
- this->m_UI->LoadedPlugins->addTopLevelItem( cat );
- }
- else
- cat = cat_items[ 0 ];
-
- // Create filters
- auto fIt = cIt->second.begin( );
- for( ; fIt != cIt->second.end( ); ++fIt )
- {
- QList< QTreeWidgetItem* > filter_items =
- this->m_UI->LoadedPlugins->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->_UnBlock( );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_Block( )
-{
- this->m_Application->setOverrideCursor( Qt::WaitCursor );
- this->m_Application->installEventFilter( &( this->m_Blocker ) );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_UnBlock( )
-{
- while( this->m_Application->overrideCursor( ) )
- this->m_Application->restoreOverrideCursor( );
- this->m_Application->removeEventFilter( &( this->m_Blocker ) );
-}
-
-// -------------------------------------------------------------------------
-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 (*)";
- dlg.setNameFilter( name_filter.str( ).c_str( ) );
- dlg.setDefaultSuffix( suffix.c_str( ) );
-
- if( !( dlg.exec( ) ) )
- return;
-
- // Read
- 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( ) );
-
- // Show an error message
- std::string err = err_str.str( );
- if( err.size( ) > 0 )
- QMessageBox::critical(
- this,
- "Error loading plugins",
- err.c_str( )
- );
-
- // Update view
- this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath );
- this->_UpdateLoadedPlugins( );
- */
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ButtonLoadPluginsPath( )
-{
- /*
- 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 != "" )
- QMessageBox::critical(
- this,
- "Error loading plugins directory",
- err.c_str( )
- );
-
- // Update view
- this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath );
- this->_UpdateLoadedPlugins( );
- */
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ActionOpenWorkspace( )
-{
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::ExistingFile );
- dlg.setDirectory( "." );
- dlg.setNameFilter(
- QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
- );
- dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
- if( !( dlg.exec( ) ) )
- return;
-
- std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
- if( this->m_Workspace != NULL )
- delete this->m_Workspace;
- this->m_Workspace = new cpPlugins::Workspace( );
- this->m_Workspace->SetInterface( &( this->m_Interface ) );
- this->m_Workspace->SetMPRViewer( this->m_UI->Viewer );
- std::string err = this->m_Workspace->LoadWorkspace( fname );
- if( err != "" )
- {
- delete this->m_Workspace;
- this->m_Workspace = NULL;
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error loading workspace" ),
- QMessageBox::tr( err.c_str( ) )
- );
- }
- else
- this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ActionSaveWorkspace( )
-{
- if( this->m_Workspace == NULL )
- return;
-
- QFileDialog dlg( this );
- 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;
- std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
-
- std::string err = this->m_Workspace->SaveWorkspace( fname );
- if( err != "" )
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error saving workspace" ),
- QMessageBox::tr( err.c_str( ) )
- );
-}
-
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ExecFilter( const std::string& filter_name )
-{
- if( this->m_Workspace != NULL )
- {
- // Update filter, if needed
- this->_Block( );
- std::string err = this->m_Workspace->Execute( filter_name );
- this->_UnBlock( );
- if( err != "" )
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error executing filter" ),
- QMessageBox::tr( err.c_str( ) )
- );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ShowFilterOutput(
- const std::string& filter_name, const std::string& output_name
- )
-{
- typedef cpPlugins::DataObject _TDataObject;
-
- // Update filter, if needed
- this->_ExecFilter( filter_name );
-
- // Get output
- auto filter = this->m_Workspace->GetFilter( filter_name );
- if( filter != NULL )
- {
- auto output = filter->GetOutputData( output_name );
- if( output != NULL )