X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FQT%2FWindowLevelImageConfiguration.cxx;h=c865f55d0a3d249646a7f7ac5211f9bc973d18b3;hb=f77263a8b9bbfb4d3f2f179b1da79cf5c55faed3;hp=ca1c3c101b3bcb8996e15d7756a12a3f5b4ac6f8;hpb=3393941bf8f26babc7b592db434b40c1b747a687;p=cpPlugins.git diff --git a/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx b/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx index ca1c3c1..c865f55 100644 --- a/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx +++ b/lib/cpExtensions/QT/WindowLevelImageConfiguration.cxx @@ -35,6 +35,10 @@ setData( SimpleMPRWidget* data ) this->m_Data->GetWindowLevel( win_lev ); // Intensity range + this->m_UI->MinimumBox->setMinimum( -1000000 ); + this->m_UI->MinimumBox->setMaximum( 1000000 ); + this->m_UI->MaximumBox->setMinimum( -1000000 ); + this->m_UI->MaximumBox->setMaximum( 1000000 ); this->m_UI->MinimumBox->setValue( range[ 0 ] ); this->m_UI->MaximumBox->setValue( range[ 1 ] ); @@ -77,13 +81,7 @@ setData( SimpleMPRWidget* data ) default : this->m_UI->InterpolatorBox->setCurrentIndex( 0 ); break; } // hctiws - /* TODO - this->connect( - this->m_UI->Top, SIGNAL( splitterMoved( int, int ) ), - this, SLOT( _SyncBottom( int, int ) ) - ); - */ - + // Slots <-> signals this->connect( this->m_UI->MaximumBox, SIGNAL( valueChanged( int ) ), this, SLOT( _maximumValue( int ) ) @@ -124,24 +122,88 @@ setData( SimpleMPRWidget* data ) void cpExtensions::QT::WindowLevelImageConfiguration:: _maximumValue( int v ) { + double range[ 2 ]; + range[ 0 ] = double( this->m_UI->MinimumBox->value( ) ); + range[ 1 ] = double( v ); + this->m_Data->SetScalarRange( range ); } // ------------------------------------------------------------------------- void cpExtensions::QT::WindowLevelImageConfiguration:: _minimumValue( int v ) { + double range[ 2 ]; + range[ 0 ] = double( v ); + range[ 1 ] = double( this->m_UI->MaximumBox->value( ) ); + this->m_Data->SetScalarRange( range ); } // ------------------------------------------------------------------------- void cpExtensions::QT::WindowLevelImageConfiguration:: _levelValue( int v ) { + double r[ 2 ]; + double l, s; + + this->m_Data->GetScalarRange( r ); + if( this->sender( ) == this->m_UI->LevelSlider ) + { + s = double( v ) / double( this->m_UI->LevelSlider->maximum( ) ); + l = ( ( r[ 1 ] - r[ 0 ] ) * s ) + r[ 0 ]; + } + else + { + l = double( v ); + s = ( l - r[ 0 ] ) / ( r[ 1 ] - r[ 0 ] ); + + } // fi + s *= this->m_UI->LevelSlider->maximum( ); + + bool b = this->m_UI->LevelSlider->blockSignals( true ); + this->m_UI->LevelSlider->setValue( s ); + this->m_UI->LevelSlider->blockSignals( b ); + b = this->m_UI->LevelBox->blockSignals( true ); + this->m_UI->LevelBox->setValue( l ); + this->m_UI->LevelBox->blockSignals( b ); + + double wl[ 2 ]; + this->m_Data->GetWindowLevel( wl ); + wl[ 1 ] = l; + this->m_Data->SetWindowLevel( wl ); } // ------------------------------------------------------------------------- void cpExtensions::QT::WindowLevelImageConfiguration:: _windowValue( int v ) { + double r[ 2 ]; + double w, s; + + this->m_Data->GetScalarRange( r ); + if( this->sender( ) == this->m_UI->WindowSlider ) + { + s = double( v ) / double( this->m_UI->WindowSlider->maximum( ) ); + w = ( ( r[ 1 ] - r[ 0 ] ) * s ) + r[ 0 ]; + } + else + { + w = double( v ); + s = ( w - r[ 0 ] ) / ( r[ 1 ] - r[ 0 ] ); + + } // fi + s *= this->m_UI->WindowSlider->maximum( ); + + bool b = this->m_UI->WindowSlider->blockSignals( true ); + this->m_UI->WindowSlider->setValue( s ); + this->m_UI->WindowSlider->blockSignals( b ); + b = this->m_UI->WindowBox->blockSignals( true ); + this->m_UI->WindowBox->setValue( w ); + this->m_UI->WindowBox->blockSignals( b ); + + double wl[ 2 ]; + this->m_Data->GetWindowLevel( wl ); + wl[ 0 ] = w; + this->m_Data->SetWindowLevel( wl ); } // ------------------------------------------------------------------------- @@ -164,6 +226,12 @@ _opacityValue( int v ) void cpExtensions::QT::WindowLevelImageConfiguration:: _interpolatorValue( int v ) { + switch( v ) + { + case 1 : this->m_Data->SetImageInterpolation( 'L' ); break; + case 2 : this->m_Data->SetImageInterpolation( 'C' ); break; + default : this->m_Data->SetImageInterpolation( 'N' ); break; + } // hctiws } #endif // cpExtensions_QT4