]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx
Architecture updated.
[cpPlugins.git] / lib / cpExtensions / QT / WindowLevelImageConfiguration.cxx
1 #include <cpExtensions/QT/WindowLevelImageConfiguration.h>
2
3 #ifdef cpExtensions_QT4
4
5 #include <cpExtensions/QT/ui_WindowLevelImageConfiguration.h>
6 #include <cpExtensions/QT/SimpleMPRWidget.h>
7
8 // -------------------------------------------------------------------------
9 cpExtensions::QT::WindowLevelImageConfiguration::
10 WindowLevelImageConfiguration( QWidget* parent, Qt::WindowFlags f )
11   : Superclass( parent, f ),
12     m_UI( new Ui::WindowLevelImageConfiguration )
13 {
14   this->m_UI->setupUi( this );
15 }
16
17 // -------------------------------------------------------------------------
18 cpExtensions::QT::WindowLevelImageConfiguration::
19 ~WindowLevelImageConfiguration( )
20 {
21   delete this->m_UI;
22 }
23
24 // -------------------------------------------------------------------------
25 void cpExtensions::QT::WindowLevelImageConfiguration::
26 setData( SimpleMPRWidget* data )
27 {
28   if( this->m_Data != data )
29   {
30     this->m_Data = data;
31
32     // Get data
33     double range[ 2 ], win_lev[ 2 ];
34     this->m_Data->GetScalarRange( range );
35     this->m_Data->GetWindowLevel( win_lev );
36
37     // Intensity range
38     this->m_UI->MinimumBox->setValue( range[ 0 ] );
39     this->m_UI->MaximumBox->setValue( range[ 1 ] );
40
41     // Window/level
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 ] );
49
50     double w = win_lev[ 0 ] / off;
51     w *=
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 );
56
57     double l = ( win_lev[ 1 ] - range[ 0 ] ) / off;
58     l *=
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 );
63
64     // Opacity
65     double o = this->m_Data->GetImageOpacity( );
66     o *=
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 );
71
72     // Interpolation mode
73     switch( this->m_Data->GetImageInterpolation( ) )
74     {
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;
78     } // hctiws
79
80     /* TODO
81        this->connect(
82        this->m_UI->Top, SIGNAL( splitterMoved( int, int ) ),
83        this, SLOT( _SyncBottom( int, int ) )
84        );
85     */
86
87     this->connect(
88       this->m_UI->MaximumBox, SIGNAL( valueChanged( int ) ),
89       this, SLOT( _maximumValue( int ) )
90       );
91     this->connect(
92       this->m_UI->MinimumBox, SIGNAL( valueChanged( int ) ),
93       this, SLOT( _minimumValue( int ) )
94       );
95     this->connect(
96       this->m_UI->LevelBox, SIGNAL( valueChanged( int ) ),
97       this, SLOT( _levelValue( int ) )
98       );
99     this->connect(
100       this->m_UI->LevelSlider, SIGNAL( valueChanged( int ) ),
101       this, SLOT( _levelValue( int ) )
102       );
103     this->connect(
104       this->m_UI->WindowBox, SIGNAL( valueChanged( int ) ),
105       this, SLOT( _windowValue( int ) )
106       );
107     this->connect(
108       this->m_UI->WindowSlider, SIGNAL( valueChanged( int ) ),
109       this, SLOT( _windowValue( int ) )
110       );
111     this->connect(
112       this->m_UI->OpacitySlider, SIGNAL( valueChanged( int ) ),
113       this, SLOT( _opacityValue( int ) )
114       );
115     this->connect(
116       this->m_UI->InterpolatorBox, SIGNAL( currentIndexChanged( int ) ),
117       this, SLOT( _interpolatorValue( int ) )
118       );
119
120   } // fi
121 }
122
123 // -------------------------------------------------------------------------
124 void cpExtensions::QT::WindowLevelImageConfiguration::
125 _maximumValue( int v )
126 {
127 }
128
129 // -------------------------------------------------------------------------
130 void cpExtensions::QT::WindowLevelImageConfiguration::
131 _minimumValue( int v )
132 {
133 }
134
135 // -------------------------------------------------------------------------
136 void cpExtensions::QT::WindowLevelImageConfiguration::
137 _levelValue( int v )
138 {
139 }
140
141 // -------------------------------------------------------------------------
142 void cpExtensions::QT::WindowLevelImageConfiguration::
143 _windowValue( int v )
144 {
145 }
146
147 // -------------------------------------------------------------------------
148 void cpExtensions::QT::WindowLevelImageConfiguration::
149 _opacityValue( int v )
150 {
151   if( this->m_Data != NULL )
152   {
153     double o = double( v );
154     o -= double( this->m_UI->OpacitySlider->minimum( ) );
155     o /=
156       double( this->m_UI->OpacitySlider->maximum( ) ) -
157       double( this->m_UI->OpacitySlider->minimum( ) );
158     this->m_Data->SetImageOpacity( o );
159
160   } // fi
161 }
162
163 // -------------------------------------------------------------------------
164 void cpExtensions::QT::WindowLevelImageConfiguration::
165 _interpolatorValue( int v )
166 {
167 }
168
169 #endif // cpExtensions_QT4
170
171 // eof - $RCSfile$