1 #include <cpExtensions/QT/WindowLevelImageConfiguration.h>
3 #ifdef cpExtensions_QT4
5 #include <cpExtensions/QT/ui_WindowLevelImageConfiguration.h>
6 #include <cpExtensions/QT/SimpleMPRWidget.h>
8 // -------------------------------------------------------------------------
9 cpExtensions::QT::WindowLevelImageConfiguration::
10 WindowLevelImageConfiguration( QWidget* parent, Qt::WindowFlags f )
11 : Superclass( parent, f ),
12 m_UI( new Ui::WindowLevelImageConfiguration )
14 this->m_UI->setupUi( this );
17 // -------------------------------------------------------------------------
18 cpExtensions::QT::WindowLevelImageConfiguration::
19 ~WindowLevelImageConfiguration( )
24 // -------------------------------------------------------------------------
25 void cpExtensions::QT::WindowLevelImageConfiguration::
26 setData( SimpleMPRWidget* data )
28 if( this->m_Data != data )
33 double range[ 2 ], win_lev[ 2 ];
34 this->m_Data->GetScalarRange( range );
35 this->m_Data->GetWindowLevel( win_lev );
38 this->m_UI->MinimumBox->setValue( range[ 0 ] );
39 this->m_UI->MaximumBox->setValue( range[ 1 ] );
42 double off = range[ 1 ] - range[ 0 ];
43 this->m_UI->WindowBox->setMinimum( 0 );
44 this->m_UI->WindowBox->setMaximum( off );
45 this->m_UI->LevelBox->setMinimum( range[ 0 ] );
46 this->m_UI->LevelBox->setMaximum( range[ 1 ] );
47 this->m_UI->WindowBox->setValue( win_lev[ 0 ] );
48 this->m_UI->LevelBox->setValue( win_lev[ 1 ] );
50 double w = win_lev[ 0 ] / off;
52 double( this->m_UI->WindowSlider->maximum( ) ) -
53 double( this->m_UI->WindowSlider->minimum( ) );
54 w += double( this->m_UI->WindowSlider->minimum( ) );
55 this->m_UI->WindowSlider->setValue( w );
57 double l = ( win_lev[ 1 ] - range[ 0 ] ) / off;
59 double( this->m_UI->LevelSlider->maximum( ) ) -
60 double( this->m_UI->LevelSlider->minimum( ) );
61 l += double( this->m_UI->LevelSlider->minimum( ) );
62 this->m_UI->LevelSlider->setValue( l );
65 double o = this->m_Data->GetImageOpacity( );
67 double( this->m_UI->OpacitySlider->maximum( ) ) -
68 double( this->m_UI->OpacitySlider->minimum( ) );
69 o += double( this->m_UI->OpacitySlider->minimum( ) );
70 this->m_UI->OpacitySlider->setValue( o );
73 switch( this->m_Data->GetImageInterpolation( ) )
75 case 'L': this->m_UI->InterpolatorBox->setCurrentIndex( 1 ); break;
76 case 'C': this->m_UI->InterpolatorBox->setCurrentIndex( 2 ); break;
77 default : this->m_UI->InterpolatorBox->setCurrentIndex( 0 ); break;
82 this->m_UI->Top, SIGNAL( splitterMoved( int, int ) ),
83 this, SLOT( _SyncBottom( int, int ) )
88 this->m_UI->MaximumBox, SIGNAL( valueChanged( int ) ),
89 this, SLOT( _maximumValue( int ) )
92 this->m_UI->MinimumBox, SIGNAL( valueChanged( int ) ),
93 this, SLOT( _minimumValue( int ) )
96 this->m_UI->LevelBox, SIGNAL( valueChanged( int ) ),
97 this, SLOT( _levelValue( int ) )
100 this->m_UI->LevelSlider, SIGNAL( valueChanged( int ) ),
101 this, SLOT( _levelValue( int ) )
104 this->m_UI->WindowBox, SIGNAL( valueChanged( int ) ),
105 this, SLOT( _windowValue( int ) )
108 this->m_UI->WindowSlider, SIGNAL( valueChanged( int ) ),
109 this, SLOT( _windowValue( int ) )
112 this->m_UI->OpacitySlider, SIGNAL( valueChanged( int ) ),
113 this, SLOT( _opacityValue( int ) )
116 this->m_UI->InterpolatorBox, SIGNAL( currentIndexChanged( int ) ),
117 this, SLOT( _interpolatorValue( int ) )
123 // -------------------------------------------------------------------------
124 void cpExtensions::QT::WindowLevelImageConfiguration::
125 _maximumValue( int v )
129 // -------------------------------------------------------------------------
130 void cpExtensions::QT::WindowLevelImageConfiguration::
131 _minimumValue( int v )
135 // -------------------------------------------------------------------------
136 void cpExtensions::QT::WindowLevelImageConfiguration::
141 // -------------------------------------------------------------------------
142 void cpExtensions::QT::WindowLevelImageConfiguration::
143 _windowValue( int v )
147 // -------------------------------------------------------------------------
148 void cpExtensions::QT::WindowLevelImageConfiguration::
149 _opacityValue( int v )
151 if( this->m_Data != NULL )
153 double o = double( v );
154 o -= double( this->m_UI->OpacitySlider->minimum( ) );
156 double( this->m_UI->OpacitySlider->maximum( ) ) -
157 double( this->m_UI->OpacitySlider->minimum( ) );
158 this->m_Data->SetImageOpacity( o );
163 // -------------------------------------------------------------------------
164 void cpExtensions::QT::WindowLevelImageConfiguration::
165 _interpolatorValue( int v )
169 #endif // cpExtensions_QT4