1 #include "cpPipelineEditor.h"
2 #include "ui_cpPipelineEditor.h"
6 #include <cpPlugins/Interface/Workspace.h>
8 // -------------------------------------------------------------------------
9 #define cpPipelineEditor_ConnectAction( ACTION ) \
11 this->m_UI->Action##ACTION, SIGNAL( triggered( ) ), \
12 this, SLOT( _Action##ACTION( ) ) \
15 // -------------------------------------------------------------------------
17 cpPipelineEditor( QWidget* parent )
18 : QMainWindow( parent ),
19 m_UI( new Ui::cpPipelineEditor ),
22 this->m_UI->setupUi( this );
24 // Connect actions to slots
25 cpPipelineEditor_ConnectAction( OpenWorkspace );
28 // -------------------------------------------------------------------------
33 if( this->m_Workspace != NULL )
34 delete this->m_Workspace;
37 // -------------------------------------------------------------------------
38 void cpPipelineEditor::
39 _ActionOpenWorkspace( )
41 QFileDialog dlg( this );
42 dlg.setFileMode( QFileDialog::ExistingFile );
43 dlg.setDirectory( "." );
45 QFileDialog::tr( "Workspace file (*.xml);;All files (*)" )
47 dlg.setDefaultSuffix( QFileDialog::tr( "xml" ) );
48 if( !( dlg.exec( ) ) )
50 std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
52 if( this->m_Workspace != NULL )
53 delete this->m_Workspace;
54 this->m_Workspace = new cpPlugins::Interface::Workspace( );
55 std::string err = this->m_Workspace->LoadWorkspace( fname );
58 this->m_UI->GraphCanvas->setWorkspace( this->m_Workspace );
59 this->m_UI->GraphCanvas->draw( );
63 delete this->m_Workspace;
64 this->m_Workspace = NULL;
65 QMessageBox::critical(
67 QMessageBox::tr( "Error loading workspace" ),
68 QMessageBox::tr( err.c_str( ) )