diff --git a/Code/Common/mvdColorBandDynamicsWidget.h b/Code/Common/mvdColorBandDynamicsWidget.h index 1a5e9d76137db46ce300a650104a5b44f0d7c887..8f36738dd54f429f595a7baef0dcfb4d5746ea7b 100644 --- a/Code/Common/mvdColorBandDynamicsWidget.h +++ b/Code/Common/mvdColorBandDynamicsWidget.h @@ -181,6 +181,9 @@ signals: void ResetIntensityClicked( RgbaChannel ); /** */ void ResetQuantileClicked( RgbaChannel ); + /** */ + void ApplyAllClicked( RgbaChannel, double, double); + /*-[ PROTECTED SECTION ]---------------------------------------------------*/ @@ -222,6 +225,7 @@ private slots: inline void on_minMaxButton_clicked(); inline void on_defaultsButton_clicked(); + inline void on_applyAllButton_clicked(); }; } // end namespace 'mvd'. @@ -421,6 +425,17 @@ ColorBandDynamicsWidget emit ResetQuantileClicked( m_Channel ); } +/*****************************************************************************/ +inline +void +ColorBandDynamicsWidget +::on_applyAllButton_clicked() +{ + emit ApplyAllClicked( m_Channel, + m_UI->lowQuantileSpinBox->value(), + m_UI->highQuantileSpinBox->value()); +} + } // end namespace 'mvd' #endif // __mvdColorBandDynamicsWidget_h diff --git a/Code/Common/mvdColorBandDynamicsWidget.ui b/Code/Common/mvdColorBandDynamicsWidget.ui index 75f8d6fd2a6509da84fe72a3ea925c890408770b..53a262fb102e56bb292b37299779609395275de9 100644 --- a/Code/Common/mvdColorBandDynamicsWidget.ui +++ b/Code/Common/mvdColorBandDynamicsWidget.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>358</width> - <height>103</height> + <width>392</width> + <height>111</height> </rect> </property> <property name="windowTitle"> @@ -17,39 +17,7 @@ <locale language="C" country="AnyCountry"/> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="1"> - <widget class="QLabel" name="lowLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Low</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="highLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>High</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="0" column="3"> + <item row="0" column="0"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QLabel" name="rLabel"> @@ -101,6 +69,57 @@ </item> </layout> </item> + <item row="0" column="1"> + <widget class="QLabel" name="lowLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Low</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="highLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>High</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QPushButton" name="applyAllButton"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Apply quantiles to all channels.</string> + </property> + <property name="text"> + <string>Apply to all</string> + </property> + </widget> + </item> <item row="1" column="0"> <widget class="QLabel" name="intensityLabel"> <property name="sizePolicy"> diff --git a/Code/Common/mvdColorDynamicsController.cxx b/Code/Common/mvdColorDynamicsController.cxx index 292456ae4fbfdf3689c309549a921ef2891189bf..fcafc27e5c88a14414fc69d12e8af91f1725d1a7 100644 --- a/Code/Common/mvdColorDynamicsController.cxx +++ b/Code/Common/mvdColorDynamicsController.cxx @@ -124,6 +124,15 @@ ColorDynamicsController SLOT( OnResetIntensityClicked( RgbaChannel ) ) ); + QObject::connect( + colorDynamicsWidget, + SIGNAL( ApplyAllClicked( RgbaChannel, double, double ) ), + // to: + this, + SLOT( OnApplyAllClicked( RgbaChannel, double, double ) ) + ); + + // // Connect controller to model. QObject::connect( @@ -211,6 +220,15 @@ ColorDynamicsController this, SLOT( OnResetIntensityClicked( RgbaChannel ) ) ); + + QObject::disconnect( + colorDynamicsWidget, + SIGNAL( ApplyAllClicked( RgbaChannel, double, double ) ), + // from: + this, + SLOT( OnApplyAllClicked( RgbaChannel, double, double ) ) + ); + } /*******************************************************************************/ @@ -609,6 +627,67 @@ ColorDynamicsController emit ModelUpdated(); } +void +ColorDynamicsController +::OnApplyAllClicked( RgbaChannel channel, double low, double high ) +{ + qDebug() << QString( "OnApplyAllChanged(%1)" ).arg( RGBA_CHANNEL_NAMES[ channel ] ); + + // Get image-model. + VectorImageModel* imageModel = GetModel< VectorImageModel >(); + assert( imageModel!=NULL ); + assert( imageModel->GetHistogramModel()!=NULL ); + + // Reference settings. + VectorImageModel::Settings& settings = imageModel->GetSettings(); + + for( int i=0; i<RGBA_CHANNEL_ALPHA; ++i ) + { + + HistogramModel::MeasurementType lintensity = + imageModel->GetHistogramModel()->Quantile( + settings.RgbChannel( i ), + 0.01 * low, + BOUND_LOWER + ); + + // Calculate quantile intensity. + HistogramModel::MeasurementType uintensity = + imageModel->GetHistogramModel()->Quantile( + settings.RgbChannel( i ), + 0.01 * high, + BOUND_UPPER + ); + + // Update quantile intensity in model. + settings.DynamicsParam( 2 * i ) = lintensity; + settings.DynamicsParam( 2 * i + 1 ) = uintensity; + + // Get color-dynamics widgets. + ColorDynamicsWidget* colorDynWgt = GetWidget< ColorDynamicsWidget >(); + assert( colorDynWgt!=NULL ); + + ColorBandDynamicsWidget* colorBandDynWgt = colorDynWgt->GetChannel( static_cast< RgbaChannel >(i) ); + assert( colorBandDynWgt!=NULL ); + + // Block widget signals to prevent recursive signal/slot loops. + colorBandDynWgt->blockSignals( true ); + + // Refresh low-intensity display. + colorBandDynWgt->SetHighIntensity( uintensity ); + colorBandDynWgt->SetLowIntensity( lintensity ); + colorBandDynWgt->SetLowQuantile( low ); + colorBandDynWgt->SetHighQuantile( high ); + + colorBandDynWgt->blockSignals( false ); + } + + // Now, emit this controller's signal to cause display refresh. + emit ModelUpdated(); +} + + + /*******************************************************************************/ } // end namespace 'mvd' diff --git a/Code/Common/mvdColorDynamicsController.h b/Code/Common/mvdColorDynamicsController.h index e9d031b57de0715ba363d36d3ec4a60b78ef6220..78a402696a72d28c2802dfcc7773bcc34176e88f 100644 --- a/Code/Common/mvdColorDynamicsController.h +++ b/Code/Common/mvdColorDynamicsController.h @@ -234,6 +234,15 @@ private slots: * quantiles. */ void OnResetQuantileClicked( RgbaChannel channel ); + + /** + * \brief Slot called when the apply all button has been clicked. + * + * \param channel RGB channel for which to reset low and high + * quantiles. + */ + void OnApplyAllClicked( RgbaChannel channel, double low, double high ); + }; } // end namespace 'mvd'. diff --git a/Code/Common/mvdColorDynamicsWidget.cxx b/Code/Common/mvdColorDynamicsWidget.cxx index 560aee31ba50e1c1645d502e6609ba22fdf256b3..f3aa7a7a0495b6d057c56eb66500fbaafcf2ae2f 100644 --- a/Code/Common/mvdColorDynamicsWidget.cxx +++ b/Code/Common/mvdColorDynamicsWidget.cxx @@ -118,6 +118,15 @@ ColorDynamicsWidget this, SIGNAL( ResetIntensityClicked( RgbaChannel ) ) ); + + QObject::connect( + widget, + SIGNAL( ApplyAllClicked( RgbaChannel, double, double ) ), + // TO: + this, + SIGNAL( ApplyAllClicked( RgbaChannel, double, double ) ) + ); + } } diff --git a/Code/Common/mvdColorDynamicsWidget.h b/Code/Common/mvdColorDynamicsWidget.h index 148a83a3800e573960555fe24cc55d7339a41de3..1133a157f3fdb478b8dbab4942cd0a264d488dbc 100644 --- a/Code/Common/mvdColorDynamicsWidget.h +++ b/Code/Common/mvdColorDynamicsWidget.h @@ -114,6 +114,9 @@ signals: void ResetIntensityClicked( RgbaChannel ); /** */ void ResetQuantileClicked( RgbaChannel ); + /** */ + void ApplyAllClicked( RgbaChannel, double, double ); + /*-[ PROTECTED SECTION ]---------------------------------------------------*/ diff --git a/Code/Common/mvdColorDynamicsWidget.ui b/Code/Common/mvdColorDynamicsWidget.ui index 9a10d03acecd93828a34f056d2912dfa7cf70b17..980f00eef8400b880fccd8d64c8def6d2edc33df 100644 --- a/Code/Common/mvdColorDynamicsWidget.ui +++ b/Code/Common/mvdColorDynamicsWidget.ui @@ -19,7 +19,6 @@ <layout class="QGridLayout" name="gridLayout_2"> <item row="0" column="0"> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> <widget class="ColorBandDynamicsWidget" name="redWidget" native="true"> <property name="minimumSize"> @@ -36,6 +35,13 @@ </property> </widget> </item> + <item row="1" column="0"> + <widget class="Line" name="line1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> <item row="2" column="0"> <widget class="ColorBandDynamicsWidget" name="greenWidget" native="true"> <property name="minimumSize"> @@ -46,6 +52,13 @@ </property> </widget> </item> + <item row="3" column="0"> + <widget class="Line" name="line2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> <item row="4" column="0"> <widget class="ColorBandDynamicsWidget" name="blueWidget" native="true"> <property name="minimumSize"> @@ -58,21 +71,7 @@ </item> </layout> </item> - <item row="1" column="0"> - <widget class="Line" name="line1"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="Line" name="line2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="1" column="0"> + <item row="1" column="0"> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum>