]> Creatis software - cpPlugins.git/blob - lib/cpBaseQtApplication/ActorLUTImageProperties.cxx
...
[cpPlugins.git] / lib / cpBaseQtApplication / ActorLUTImageProperties.cxx
1 #include <cpBaseQtApplication/ActorLUTImageProperties.h>
2
3 #include <cpExtensions/Visualization/LUTImageActor.h>
4 #include <cpBaseQtApplication/ui_ActorLUTImageProperties.h>
5 #include <QColorDialog>
6
7 // -------------------------------------------------------------------------
8 cpBaseQtApplication::ActorLUTImageProperties::
9 ActorLUTImageProperties( QWidget* parent )
10   : cpBaseQtApplication::ActorProperties( parent ),
11     m_UI( new Ui::ActorLUTImageProperties )
12 {
13   this->m_UI->setupUi( this );
14 }
15
16 // -------------------------------------------------------------------------
17 cpBaseQtApplication::ActorLUTImageProperties::
18 ~ActorLUTImageProperties( )
19 {
20   delete this->m_UI;
21 }
22
23 // -------------------------------------------------------------------------
24 bool cpBaseQtApplication::ActorLUTImageProperties::
25 addActor( vtkProp* obj )
26 {
27   typedef cpExtensions::Visualization::LUTImageActor _TActor;
28
29   auto actor = dynamic_cast< _TActor* >( obj );
30   if( actor != NULL )
31   {
32     this->m_Actors.insert( obj );
33     if( this->m_Actors.size( ) == 1 )
34       this->_updateWidgets( );
35     return( true );
36   }
37   else
38     return( false );
39 }
40
41 // -------------------------------------------------------------------------
42 void cpBaseQtApplication::ActorLUTImageProperties::
43 _updateWidgets( )
44 {
45   typedef cpExtensions::Visualization::LUTImageActor _TActor;
46
47   auto actor =
48     dynamic_cast< _TActor* >( this->m_Actors.begin( )->GetPointer( ) );
49   if( actor == NULL )
50     return;
51
52   // TODO: std::cout << actor << std::endl;
53
54   // Get properties
55   /* TODO
56   auto mapp = actor->GetMapper( );
57   auto prop = actor->GetProperty( );
58   double rgb[ 3 ];
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( );
68
69   // Set widget values
70   auto palette = this->m_UI->Color->palette( );
71   palette.setColor(
72     QPalette::Button, QColor( rgb[ 0 ], rgb[ 1 ], rgb[ 2 ] )
73     );
74   this->m_UI->Color->setAutoFillBackground( true );
75   this->m_UI->Color->setPalette( palette );
76
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 );
82
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 );
89
90   // Connect stuff
91   this->connect(
92     this->m_UI->ScalarVisibility, SIGNAL( stateChanged( int ) ),
93     this, SLOT( _ScalarVisibility( int ) )
94     );
95   this->connect(
96     this->m_UI->Color, SIGNAL( clicked( ) ),
97     this, SLOT( _Color( ) )
98     );
99   this->connect(
100     this->m_UI->Opacity, SIGNAL( valueChanged( int ) ),
101     this, SLOT( _Opacity( int ) )
102     );
103   this->connect(
104     this->m_UI->LineWidth, SIGNAL( valueChanged( int ) ),
105     this, SLOT( _LineWidth( int ) )
106     );
107   this->connect(
108     this->m_UI->PointSize, SIGNAL( valueChanged( int ) ),
109     this, SLOT( _PointSize( int ) )
110     );
111   this->connect(
112     this->m_UI->Representation, SIGNAL( currentIndexChanged( int ) ),
113     this, SLOT( _Representation( int ) )
114     );
115   */
116 }
117
118 // -------------------------------------------------------------------------
119 void cpBaseQtApplication::ActorLUTImageProperties::
120 _Color( )
121 {
122   /* TODO
123   if( this->m_Actors.size( ) == 0 )
124     return;
125   QPalette pal = this->m_UI->Color->palette( );
126   QColor color =
127     QColorDialog::getColor(
128       pal.color( QPalette::Button ),
129       this,
130       "Select Color",
131       QColorDialog::DontUseNativeDialog
132       );
133   if( color.isValid( ) )
134   {
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 );
140
141   } // fi
142   */
143 }
144
145 // -------------------------------------------------------------------------
146 void cpBaseQtApplication::ActorLUTImageProperties::
147 _Opacity( int v )
148 {
149   /*
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 )
153   {
154     auto ma = dynamic_cast< vtkActor* >( aIt->GetPointer( ) );
155     ma->GetProperty( )->SetOpacity( op );
156     ma->Modified( );
157
158   } // rof
159   this->_render( );
160   */
161 }
162
163 // eof - $RCSfile$