]> Creatis software - cpPlugins.git/blob - appli/PipelineEditor/PipelineEditor.cxx
More plugins added
[cpPlugins.git] / appli / PipelineEditor / PipelineEditor.cxx
1 #include "PipelineEditor.h"
2 #include "ui_PipelineEditor.h"
3
4 #include <cpPipelineEditor/Editor.h>
5 #include <QMessageBox>
6
7 // -------------------------------------------------------------------------
8 PipelineEditor::
9 PipelineEditor( int argc, char* argv[], QApplication* app, QWidget* parent )
10   : Superclass( argc, argv, app, parent ),
11     m_UI( new Ui::PipelineEditor )
12 {
13   // Basic configuration
14   this->m_UI->setupUi( this );
15   this->_Configure(
16     this->m_UI->LoadedPlugins,
17     this->m_UI->Viewer,
18     this->m_UI->Canvas->editor( )
19     );
20
21   // Connect actions to slots
22   this->connect(
23     this->m_UI->ButtonLoadPluginsFile, SIGNAL( clicked( ) ),
24     this, SLOT( _InteractiveLoadPlugins( ) )
25     );
26   this->connect(
27     this->m_UI->ButtonLoadPluginsPath, SIGNAL( clicked( ) ),
28     this, SLOT( _InteractiveLoadPluginsFromPath( ) )
29     );
30   this->connect(
31     this->m_UI->ActionOpenWorkspace, SIGNAL( triggered( ) ),
32     this, SLOT( _InteractiveLoadWorkspace( ) )
33     );
34   this->connect(
35     this->m_UI->ActionSaveWorkspace, SIGNAL( triggered( ) ),
36     this, SLOT( _InteractiveSaveWorkspace( ) )
37     );
38   this->connect(
39     this->m_UI->Canvas->editor( ),
40     SIGNAL( execFilter( const std::string& ) ),
41     this,
42     SLOT( _ExecFilter( const std::string& ) )
43     );
44   this->connect(
45     this->m_UI->Canvas->editor( ),
46     SIGNAL( showFilterOutput( const std::string&, const std::string& ) ),
47     this,
48     SLOT( _ShowFilterOutput( const std::string&, const std::string& ) )
49     );
50 }
51
52 // -------------------------------------------------------------------------
53 PipelineEditor::
54 ~PipelineEditor( )
55 {
56   delete this->m_UI;
57 }
58
59 // -------------------------------------------------------------------------
60 void PipelineEditor::
61 _ShowFilterOutput(
62   const std::string& filter_name, const std::string& output_name
63   )
64 {
65   typedef cpPlugins::DataObject _TDataObject;
66
67   // Update filter, if needed
68   this->_ExecFilter( filter_name );
69
70   // Get output
71   auto filter = this->m_Workspace.GetFilter( filter_name );
72   if( filter != NULL )
73   {
74     auto output = filter->GetOutputData( output_name );
75     if( output != NULL )
76     {
77       std::string data_name = output_name + "@" + filter_name;
78       auto idata = output->GetVTK< vtkImageData >( );
79       auto mdata = output->GetVTK< vtkPolyData >( );
80       if( idata != NULL )
81       {
82         if( this->m_UI->Viewer->AddData( idata, data_name, "" ) )
83         {
84           if( this->m_UI->Viewer->GetNumberOfData( ) > 1 )
85             this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 );
86           else
87             this->m_UI->Viewer->SetMainImage( data_name );
88           this->_Block( );
89           this->m_UI->Viewer->ShowData( data_name );
90           this->_UnBlock( );
91
92         } // fi
93       }
94       else if( mdata != NULL )
95       {
96         if( this->m_UI->Viewer->AddData( mdata, data_name ) )
97         {
98           this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 );
99           this->_Block( );
100           this->m_UI->Viewer->ShowData( data_name );
101           this->_UnBlock( );
102
103         } // fi
104       }
105       else
106         QMessageBox::critical(
107           this,
108           QMessageBox::tr( "Error showing data" ),
109           QMessageBox::tr( "No known VTK conversion!" )
110           );
111
112     } // fi
113
114   } // fi
115 }
116
117 // eof - $RCSfile$