1 #include "PipelineEditor.h"
2 #include "ui_PipelineEditor.h"
6 #include <cpPipelineEditor/Editor.h>
7 #include <cpExtensions/QT/PropertyWidget.h>
9 #include <vtkImageData.h>
10 #include <vtkPolyData.h>
11 #include <vtkRenderWindowInteractor.h>
13 // -------------------------------------------------------------------------
15 PipelineEditor( int argc, char* argv[], QApplication* app, QWidget* parent )
16 : Superclass( argc, argv, app, parent ),
17 m_UI( new Ui::PipelineEditor )
19 // Basic configuration
20 this->m_UI->setupUi( this );
22 this->m_UI->LoadedPlugins,
24 this->m_UI->Canvas->editor( )
27 // Connect actions to slots
29 this->m_UI->ButtonLoadPluginsFile, SIGNAL( clicked( ) ),
30 this, SLOT( _InteractiveLoadPlugins( ) )
33 this->m_UI->ButtonLoadPluginsPath, SIGNAL( clicked( ) ),
34 this, SLOT( _InteractiveLoadPluginsFromPath( ) )
37 this->m_UI->ActionOpenWorkspace, SIGNAL( triggered( ) ),
38 this, SLOT( _InteractiveLoadWorkspace( ) )
41 this->m_UI->ActionSaveWorkspace, SIGNAL( triggered( ) ),
42 this, SLOT( _InteractiveSaveWorkspace( ) )
45 this->m_UI->Canvas->editor( ),
46 SIGNAL( execFilter( const std::string& ) ),
48 SLOT( _ExecFilter( const std::string& ) )
51 this->m_UI->Canvas->editor( ),
52 SIGNAL( showFilterOutput( const std::string&, const std::string& ) ),
54 SLOT( _ShowFilterOutput( const std::string&, const std::string& ) )
57 this->m_UI->Canvas->editor( ),
58 SIGNAL( hideFilterOutput( const std::string&, const std::string& ) ),
60 SLOT( _HideFilterOutput( const std::string&, const std::string& ) )
63 this->m_UI->Canvas->editor( ),
64 SIGNAL( visualPropertiesFilterOutput( const std::string&, const std::string& ) ),
66 SLOT( _PropertiesFilterOutput( const std::string&, const std::string& ) )
70 // -------------------------------------------------------------------------
77 // -------------------------------------------------------------------------
80 const std::string& filter_name, const std::string& output_name
83 // Update filter, if needed
84 this->_ExecFilter( filter_name );
87 auto filter = this->m_Workspace.GetFilter( filter_name );
90 auto id = filter->GetOutputData< vtkImageData >( output_name );
91 auto md = filter->GetOutputData< vtkPolyData >( output_name );
95 this->m_UI->Viewer->Clear( );
96 this->m_UI->Viewer->SetMainImage( id );
102 this->m_UI->Viewer->AddMesh( md );
106 QMessageBox::critical(
108 QMessageBox::tr( "Error showing data" ),
109 QMessageBox::tr( "No known VTK conversion!" )
113 QMessageBox::critical(
115 QMessageBox::tr( "Error showing data" ),
116 QMessageBox::tr( "Unknown filter." )
120 // -------------------------------------------------------------------------
121 void PipelineEditor::
123 const std::string& filter_name, const std::string& output_name
128 auto filter = this->m_Workspace.GetFilter( filter_name );
131 auto output = filter->GetOutputData( output_name );
134 std::string data_name = output_name + "@" + filter_name;
135 this->m_UI->Viewer->HideData( data_name );
143 // -------------------------------------------------------------------------
144 void PipelineEditor::
145 _PropertiesFilterOutput(
146 const std::string& filter_name, const std::string& output_name
150 auto filter = this->m_Workspace.GetFilter( filter_name );
153 auto output = filter->GetOutputData< vtkPolyData >( output_name );
156 auto actor = this->m_UI->Viewer->GetActor( output );
159 cpExtensions::QT::PropertyWidget* wdg =
160 new cpExtensions::QT::PropertyWidget( NULL );
161 wdg->SetProp( actor );
162 wdg->SetRenderWindow(
163 this->m_UI->Viewer->GetInteractor( 3 )->GetRenderWindow( )
170 QMessageBox::critical(
172 QMessageBox::tr( "Error showing data" ),
173 QMessageBox::tr( "No known VTK conversion!" )