: Superclass( parent ),
m_Application( app ),
m_PluginsPath( "." ),
+ m_Interface( NULL ),
+ m_Workspace( NULL ),
m_TreeWidget( NULL ),
m_Editor( NULL ),
m_MPR( NULL )
{
- this->m_Interface.GuessAccesiblePlugins( );
-
- // Try to load plugins from executable dir
+ this->m_ApplicationPath = ".";
QFileInfo info( argv[ 0 ] );
if( info.exists( ) )
- this->_LoadPluginsFromPath( info.canonicalPath( ).toStdString( ) );
-
- // Prepare workspace
- this->m_Workspace.SetInterface( &( this->m_Interface ) );
+ this->m_ApplicationPath = info.canonicalPath( ).toStdString( );
}
// -------------------------------------------------------------------------
cpPipelineEditor::BaseQtMainWindow::
~BaseQtMainWindow( )
{
- this->m_Interface.UnloadAll( );
+ if( this->m_Workspace != NULL )
+ delete this->m_Workspace;
+ delete this->m_Interface;
}
// -------------------------------------------------------------------------
cpPipelineEditor::Editor* editor
)
{
+ if( this->m_Interface != NULL )
+ {
+ delete this->m_Interface;
+ this->m_Interface = NULL;
+
+ } // fi
+
+ try
+ {
+ this->m_Interface = new cpPlugins::Interface( );
+ this->m_Interface->GuessAccesiblePlugins( );
+ }
+ catch( std::exception& err )
+ {
+ if( this->m_Interface != NULL )
+ delete this->m_Interface;
+ this->m_Interface = NULL;
+ QMessageBox::critical(
+ this,
+ "Error creating plugins interface",
+ err.what( )
+ );
+ std::exit( 1 );
+
+ } // yrt
+
+ // Try to load plugins from executable dir
+ this->_LoadPluginsFromPath( this->m_ApplicationPath );
+
+ // Finish configuration
this->m_TreeWidget = tree;
if( this->m_TreeWidget != NULL )
this->_UpdateLoadedPlugins( );
this->m_Editor = editor;
- if( this->m_Editor != NULL )
- this->m_Editor->setWorkspace( &( this->m_Workspace ) );
- if( mpr != NULL )
- this->m_Workspace.SetMPRViewer( mpr );
this->m_MPR = mpr;
+ this->_CreateWorkspace( );
+}
+
+// -------------------------------------------------------------------------
+void cpPipelineEditor::BaseQtMainWindow::
+_CreateWorkspace( )
+{
+ if( this->m_Workspace != NULL )
+ delete this->m_Workspace;
+ this->m_Workspace = new cpPlugins::Workspace( );
+ this->m_Workspace->SetInterface( this->m_Interface );
+ if( this->m_Editor != NULL )
+ this->m_Editor->setWorkspace( this->m_Workspace );
+ if( this->m_MPR != NULL )
+ this->m_Workspace->SetMPRViewer( this->m_MPR );
}
// -------------------------------------------------------------------------
{
try
{
- this->m_Interface.LoadPluginFile( filename );
+ this->m_Interface->LoadPluginFile( filename );
this->_UpdateLoadedPlugins( );
}
catch( std::exception& err )
{
try
{
- this->m_Interface.LoadPluginDir( path );
+ this->m_Interface->LoadPluginDir( path );
this->_UpdateLoadedPlugins( );
}
catch( std::exception& err )
_UpdateLoadedPlugins( )
{
this->_Block( );
- auto filters = this->m_Interface.GetFilters( );
+ auto filters = this->m_Interface->GetFilters( );
if( filters.size( ) == 0 )
{
this->_UnBlock( );
void cpPipelineEditor::BaseQtMainWindow::
_LoadWorkspace( const std::string& filename )
{
- std::string err = this->m_Workspace.LoadWorkspace( filename );
+ this->_CreateWorkspace( );
+ std::string err = this->m_Workspace->LoadWorkspace( filename );
if( err != "" )
{
QMessageBox::critical(
else
{
if( this->m_Editor != NULL )
- this->m_Editor->setWorkspace( &( this->m_Workspace ) );
+ this->m_Editor->setWorkspace( this->m_Workspace );
} // fi
}
void cpPipelineEditor::BaseQtMainWindow::
_SaveWorkspace( const std::string& filename )
{
- 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_Workspace != NULL )
+ {
+ std::string err = this->m_Workspace->SaveWorkspace( filename );
+ if( err != "" )
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error saving workspace" ),
+ QMessageBox::tr( err.c_str( ) )
+ );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpPipelineEditor::BaseQtMainWindow::
_ShowData( const std::string& filter_name, const std::string& output_name )
{
- if( this->m_MPR == NULL )
+ if( this->m_MPR == NULL || this->m_Workspace == NULL )
return;
- auto output = this->m_Workspace.GetOutput( filter_name, output_name );
+
+ auto output = this->m_Workspace->GetOutput( filter_name, output_name );
if( output != NULL )
{
this->_Block( );
void cpPipelineEditor::BaseQtMainWindow::
_HideData( const std::string& filter, const std::string& output )
{
+ std::cout << "BaseQtMainWindow::HideData" << std::endl;
+ /* TODO
+ */
}
// -------------------------------------------------------------------------
const std::string& filter_name, const std::string& output_name
)
{
- if( this->m_MPR == NULL )
+ if( this->m_MPR == NULL || this->m_Workspace == NULL )
return;
- auto output = this->m_Workspace.GetOutput( filter_name, output_name );
+
+ auto output = this->m_Workspace->GetOutput( filter_name, output_name );
if( output != NULL )
{
this->_Block( );
void cpPipelineEditor::BaseQtMainWindow::
_BackgroundProperties( unsigned int i )
{
+ if( this->m_MPR == NULL )
+ return;
+
QColor color =
QColorDialog::getColor(
QColor( 0, 0, 0 ),
dlg.setFileMode( QFileDialog::ExistingFiles );
dlg.setDirectory( this->m_PluginsPath.c_str( ) );
- std::stringstream name_filter;
+ std::stringstream filter;
std::string suffix = std::string( cpPlugins_LIB_EXT );
- name_filter
- << "Plugins file (*." << cpPlugins_LIB_EXT << ");;All files (*)";
- dlg.setNameFilter( name_filter.str( ).c_str( ) );
+ 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 cpPipelineEditor::BaseQtMainWindow::
_InteractiveLoadPluginsFromPath( )
{
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::DirectoryOnly );
- dlg.setDirectory( this->m_PluginsPath.c_str( ) );
- if( !( dlg.exec( ) ) )
+ QFileDialog d( this );
+ d.setFileMode( QFileDialog::DirectoryOnly );
+ d.setDirectory( this->m_PluginsPath.c_str( ) );
+ if( !( d.exec( ) ) )
return;
- this->_LoadPluginsFromPath( dlg.selectedFiles( ).begin( )->toStdString( ) );
+ this->_LoadPluginsFromPath( d.selectedFiles( ).begin( )->toStdString( ) );
}
// -------------------------------------------------------------------------
void cpPipelineEditor::BaseQtMainWindow::
_InteractiveSaveWorkspace( )
{
- 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;
- this->_SaveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
+ if( this->m_Workspace != NULL )
+ {
+ 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;
+ this->_SaveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpPipelineEditor::BaseQtMainWindow::
_ExecFilter( const std::string& filter_name )
{
+ if( this->m_Workspace == NULL )
+ return;
+
this->_Block( );
try
{
- this->m_Workspace.Execute( filter_name );
+ this->m_Workspace->Execute( filter_name );
this->_UnBlock( );
}
catch( itk::ExceptionObject& err1 )