1 #include <cpBaseQtApplication/ActorLUTImageProperties.h>
3 #include <cpExtensions/Visualization/LUTImageActor.h>
4 #include <cpBaseQtApplication/ui_ActorLUTImageProperties.h>
5 #include <QColorDialog>
7 // -------------------------------------------------------------------------
8 cpBaseQtApplication::ActorLUTImageProperties::
9 ActorLUTImageProperties( QWidget* parent )
10 : cpBaseQtApplication::ActorProperties( parent ),
11 m_UI( new Ui::ActorLUTImageProperties )
13 this->m_UI->setupUi( this );
16 // -------------------------------------------------------------------------
17 cpBaseQtApplication::ActorLUTImageProperties::
18 ~ActorLUTImageProperties( )
23 // -------------------------------------------------------------------------
24 bool cpBaseQtApplication::ActorLUTImageProperties::
25 addActor( vtkProp* obj )
27 typedef cpExtensions::Visualization::LUTImageActor _TActor;
29 auto actor = dynamic_cast< _TActor* >( obj );
32 this->m_Actors.insert( obj );
33 if( this->m_Actors.size( ) == 1 )
34 this->_updateWidgets( );
41 // -------------------------------------------------------------------------
42 void cpBaseQtApplication::ActorLUTImageProperties::
45 typedef cpExtensions::Visualization::LUTImageActor _TActor;
48 dynamic_cast< _TActor* >( this->m_Actors.begin( )->GetPointer( ) );
52 // TODO: std::cout << actor << std::endl;
56 auto mapp = actor->GetMapper( );
57 auto prop = actor->GetProperty( );
59 prop->GetColor( rgb );
60 rgb[ 0 ] *= double( 255 );
61 rgb[ 1 ] *= double( 255 );
62 rgb[ 2 ] *= double( 255 );
63 double op = prop->GetOpacity( );
64 double lw = prop->GetLineWidth( );
65 double ps = prop->GetPointSize( );
66 bool sv = ( mapp->GetScalarVisibility( ) == 1 );
67 int rep = prop->GetRepresentation( );
70 auto palette = this->m_UI->Color->palette( );
72 QPalette::Button, QColor( rgb[ 0 ], rgb[ 1 ], rgb[ 2 ] )
74 this->m_UI->Color->setAutoFillBackground( true );
75 this->m_UI->Color->setPalette( palette );
77 op *= double( this->m_UI->Opacity->maximum( ) );
78 this->m_UI->Opacity->setValue( int( op ) );
79 this->m_UI->LineWidth->setValue( int( lw ) );
80 this->m_UI->PointSize->setValue( int( ps ) );
81 this->m_UI->ScalarVisibility->setChecked( sv );
83 if( rep == VTK_POINTS )
84 this->m_UI->Representation->setCurrentIndex( 0 );
85 else if( rep == VTK_WIREFRAME )
86 this->m_UI->Representation->setCurrentIndex( 1 );
87 else if( rep == VTK_SURFACE )
88 this->m_UI->Representation->setCurrentIndex( 2 );
92 this->m_UI->ScalarVisibility, SIGNAL( stateChanged( int ) ),
93 this, SLOT( _ScalarVisibility( int ) )
96 this->m_UI->Color, SIGNAL( clicked( ) ),
97 this, SLOT( _Color( ) )
100 this->m_UI->Opacity, SIGNAL( valueChanged( int ) ),
101 this, SLOT( _Opacity( int ) )
104 this->m_UI->LineWidth, SIGNAL( valueChanged( int ) ),
105 this, SLOT( _LineWidth( int ) )
108 this->m_UI->PointSize, SIGNAL( valueChanged( int ) ),
109 this, SLOT( _PointSize( int ) )
112 this->m_UI->Representation, SIGNAL( currentIndexChanged( int ) ),
113 this, SLOT( _Representation( int ) )
118 // -------------------------------------------------------------------------
119 void cpBaseQtApplication::ActorLUTImageProperties::
123 if( this->m_Actors.size( ) == 0 )
125 QPalette pal = this->m_UI->Color->palette( );
127 QColorDialog::getColor(
128 pal.color( QPalette::Button ),
131 QColorDialog::DontUseNativeDialog
133 if( color.isValid( ) )
135 pal.setColor( QPalette::Button, color );
136 this->m_UI->Color->setAutoFillBackground( true );
137 this->m_UI->Color->setPalette( pal );
138 this->m_UI->Color->update( );
139 this->_ScalarVisibility( 0 );
145 // -------------------------------------------------------------------------
146 void cpBaseQtApplication::ActorLUTImageProperties::
150 double op = double( v ) / double( this->m_UI->Opacity->maximum( ) );
151 auto aIt = this->m_Actors.begin( );
152 for( ; aIt != this->m_Actors.end( ); ++aIt )
154 auto ma = dynamic_cast< vtkActor* >( aIt->GetPointer( ) );
155 ma->GetProperty( )->SetOpacity( op );