Skip to content
Snippets Groups Projects
Commit cd44739a authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Adding buttons to apply quantile to all bands

parent f9cc4408
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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">
......
......@@ -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'
......@@ -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'.
......
......@@ -118,6 +118,15 @@ ColorDynamicsWidget
this,
SIGNAL( ResetIntensityClicked( RgbaChannel ) )
);
QObject::connect(
widget,
SIGNAL( ApplyAllClicked( RgbaChannel, double, double ) ),
// TO:
this,
SIGNAL( ApplyAllClicked( RgbaChannel, double, double ) )
);
}
}
......
......@@ -114,6 +114,9 @@ signals:
void ResetIntensityClicked( RgbaChannel );
/** */
void ResetQuantileClicked( RgbaChannel );
/** */
void ApplyAllClicked( RgbaChannel, double, double );
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment