1 #include "PipelineEditor.h"
2 #include "ui_PipelineEditor.h"
4 #include <cpPipelineEditor/Editor.h>
5 #include <cpExtensions/QT/PropertyWidget.h>
7 #include <vtkRenderWindowInteractor.h>
9 // -------------------------------------------------------------------------
11 PipelineEditor( int argc, char* argv[], QApplication* app, QWidget* parent )
12 : Superclass( argc, argv, app, parent ),
13 m_UI( new Ui::PipelineEditor )
15 // Basic configuration
16 this->m_UI->setupUi( this );
18 this->m_UI->LoadedPlugins,
20 this->m_UI->Canvas->editor( )
23 // Connect actions to slots
25 this->m_UI->ButtonLoadPluginsFile, SIGNAL( clicked( ) ),
26 this, SLOT( _InteractiveLoadPlugins( ) )
29 this->m_UI->ButtonLoadPluginsPath, SIGNAL( clicked( ) ),
30 this, SLOT( _InteractiveLoadPluginsFromPath( ) )
33 this->m_UI->ActionOpenWorkspace, SIGNAL( triggered( ) ),
34 this, SLOT( _InteractiveLoadWorkspace( ) )
37 this->m_UI->ActionSaveWorkspace, SIGNAL( triggered( ) ),
38 this, SLOT( _InteractiveSaveWorkspace( ) )
41 this->m_UI->Canvas->editor( ),
42 SIGNAL( execFilter( const std::string& ) ),
44 SLOT( _ExecFilter( const std::string& ) )
47 this->m_UI->Canvas->editor( ),
48 SIGNAL( showFilterOutput( const std::string&, const std::string& ) ),
50 SLOT( _ShowFilterOutput( const std::string&, const std::string& ) )
53 this->m_UI->Canvas->editor( ),
54 SIGNAL( hideFilterOutput( const std::string&, const std::string& ) ),
56 SLOT( _HideFilterOutput( const std::string&, const std::string& ) )
59 this->m_UI->Canvas->editor( ),
60 SIGNAL( visualPropertiesFilterOutput( const std::string&, const std::string& ) ),
62 SLOT( _PropertiesFilterOutput( const std::string&, const std::string& ) )
66 // -------------------------------------------------------------------------
73 // -------------------------------------------------------------------------
76 const std::string& filter_name, const std::string& output_name
79 typedef cpPlugins::DataObject _TDataObject;
81 // Update filter, if needed
82 this->_ExecFilter( filter_name );
85 auto filter = this->m_Workspace.GetFilter( filter_name );
88 auto output = filter->GetOutputData( output_name );
91 std::string data_name = output_name + "@" + filter_name;
92 auto idata = output->GetVTK< vtkImageData >( );
93 auto mdata = output->GetVTK< vtkPolyData >( );
96 if( this->m_UI->Viewer->AddData( idata, data_name, "" ) )
98 if( this->m_UI->Viewer->GetNumberOfData( ) > 1 )
99 this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 );
101 this->m_UI->Viewer->SetMainImage( data_name );
103 this->m_UI->Viewer->ShowData( data_name );
108 else if( mdata != NULL )
110 if( this->m_UI->Viewer->AddData( mdata, data_name ) )
112 this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 );
114 this->m_UI->Viewer->ShowData( data_name );
120 QMessageBox::critical(
122 QMessageBox::tr( "Error showing data" ),
123 QMessageBox::tr( "No known VTK conversion!" )
131 // -------------------------------------------------------------------------
132 void PipelineEditor::
134 const std::string& filter_name, const std::string& output_name
138 auto filter = this->m_Workspace.GetFilter( filter_name );
141 auto output = filter->GetOutputData( output_name );
144 std::string data_name = output_name + "@" + filter_name;
145 this->m_UI->Viewer->HideData( data_name );
152 // -------------------------------------------------------------------------
153 void PipelineEditor::
154 _PropertiesFilterOutput(
155 const std::string& filter_name, const std::string& output_name
159 auto filter = this->m_Workspace.GetFilter( filter_name );
162 auto output = filter->GetOutputData( output_name );
165 std::string data_name = output_name + "@" + filter_name;
166 auto prop = this->m_UI->Viewer->GetProp( data_name );
168 cpExtensions::QT::PropertyWidget* wdg =
169 new cpExtensions::QT::PropertyWidget( NULL );
170 wdg->SetProp( prop );
171 wdg->SetRenderWindow( this->m_UI->Viewer->GetInteractor( 3 )->GetRenderWindow( ) );
175 QMessageBox::critical(
177 QMessageBox::tr( "Error showing data" ),
178 QMessageBox::tr( "No known VTK conversion!" )