1 #include <cpBaseQtApplication/ActorPropertiesQDialog.h>
3 #include <cpBaseQtApplication/ActorAxesProperties.h>
4 #include <cpBaseQtApplication/ActorImageProperties.h>
5 #include <cpBaseQtApplication/ActorLUTImageProperties.h>
6 #include <cpBaseQtApplication/ActorPolyDataProperties.h>
9 #include <vtkPropCollection.h>
16 #include <vtkImageData.h>
17 #include <vtkImageProperty.h>
18 #include <vtkMapper.h>
19 #include <vtkProperty.h>
22 #include <QColorDialog>
23 #include <QDoubleSpinBox>
24 #include <QPushButton>
28 // -------------------------------------------------------------------------
29 cpBaseQtApplication::ActorPropertiesQDialog::
30 ActorPropertiesQDialog( QWidget* parent, Qt::WindowFlags f )
31 : QDialog( parent, f ),
34 this->m_Title = new QLabel( this );
35 this->m_Title->setText( "Visualization properties" );
36 this->m_MainLayout = new QGridLayout( this );
37 this->m_ToolsLayout = new QVBoxLayout( );
38 this->m_ToolsLayout->addWidget( this->m_Title );
39 this->m_MainLayout->addLayout( this->m_ToolsLayout, 0, 0, 1, 1 );
42 // -------------------------------------------------------------------------
43 cpBaseQtApplication::ActorPropertiesQDialog::
44 ~ActorPropertiesQDialog( )
48 // -------------------------------------------------------------------------
49 void cpBaseQtApplication::ActorPropertiesQDialog::
50 setProps( const TProps& props )
52 if( this->m_MainWidget == NULL )
54 std::map< std::string, std::set< vtkProp* > > all_props;
55 for( auto coll = props.begin( ); coll != props.end( ); ++coll )
57 ( *coll )->InitTraversal( );
58 while( auto p = ( *coll )->GetNextProp( ) )
59 all_props[ p->GetClassName( ) ].insert( p );
63 std::stringstream title;
64 title << "Parameters for an object of class";
65 auto wl_actors = all_props.find( "WindowLevelImageActor" );
66 auto lt_actors = all_props.find( "LUTImageActor" );
67 auto actors = all_props.end( );
68 if( wl_actors != all_props.end( ) )
71 this->m_MainWidget = new cpBaseQtApplication::ActorImageProperties( this );
74 else if( lt_actors != all_props.end( ) )
76 title << "\"LUT Image\"";
77 this->m_MainWidget = new cpBaseQtApplication::ActorLUTImageProperties( this );
82 if( all_props.size( ) == 1 )
85 dynamic_cast< vtkActor* >( *( all_props.begin( )->second.begin( ) ) );
90 new cpBaseQtApplication::ActorPolyDataProperties( this );
91 actors = all_props.begin( );
99 if( actors != all_props.end( ) )
101 this->m_Title->setText( title.str( ).c_str( ) );
102 this->m_ToolsLayout->addWidget( this->m_MainWidget );
103 this->m_Buttons = new QDialogButtonBox( QDialogButtonBox::Ok );
105 this->m_Buttons, SIGNAL( accepted( ) ), this, SLOT( accept( ) )
108 this->m_Buttons, SIGNAL( rejected( ) ), this, SLOT( reject( ) )
110 this->m_ToolsLayout->addWidget( this->m_Buttons );
112 for( auto a = actors->second.begin( ); a != actors->second.end( ); ++a )
113 this->m_MainWidget->addActor( *a );
120 // -------------------------------------------------------------------------
121 bool cpBaseQtApplication::ActorPropertiesQDialog::
122 addRenderWindow( vtkRenderWindow* win )
124 if( this->m_MainWidget != NULL && win != NULL )
125 return( this->m_MainWidget->addRenderWindow( win ) );