Fix vector out of range crash when using LH/HH curves in Color & Light

This commit is contained in:
Pandagrapher
2018-09-22 18:00:35 +02:00
parent f945466df5
commit 72477fcd8b
2 changed files with 41 additions and 38 deletions

View File

@@ -160,7 +160,6 @@ Locallab::Locallab():
ToolVBox* const panel = Gtk::manage(new ToolVBox()); ToolVBox* const panel = Gtk::manage(new ToolVBox());
CurveListener::setMulti(true); CurveListener::setMulti(true);
std::vector<GradientMilestone> milestones;
float R, G, B; float R, G, B;
// Settings // Settings
@@ -196,20 +195,20 @@ Locallab::Locallab():
llshape = static_cast<DiagonalCurveEditor*>(llCurveEditorG->addCurve(CT_Diagonal, "L(L)")); llshape = static_cast<DiagonalCurveEditor*>(llCurveEditorG->addCurve(CT_Diagonal, "L(L)"));
llshape->setResetCurve(DCT_NURBS, {(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0}); llshape->setResetCurve(DCT_NURBS, {(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0});
llshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP")); llshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP"));
milestones.clear(); std::vector<GradientMilestone> mllshape;
milestones.push_back(GradientMilestone(0., 0., 0., 0.)); mllshape.push_back(GradientMilestone(0., 0., 0., 0.));
milestones.push_back(GradientMilestone(1., 1., 1., 1.)); mllshape.push_back(GradientMilestone(1., 1., 1., 1.));
llshape->setBottomBarBgGradient(milestones); llshape->setBottomBarBgGradient(mllshape);
llshape->setLeftBarBgGradient(milestones); llshape->setLeftBarBgGradient(mllshape);
ccshape = static_cast<DiagonalCurveEditor*>(llCurveEditorG->addCurve(CT_Diagonal, "C(C)")); ccshape = static_cast<DiagonalCurveEditor*>(llCurveEditorG->addCurve(CT_Diagonal, "C(C)"));
ccshape->setResetCurve(DCT_NURBS, {(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0}); ccshape->setResetCurve(DCT_NURBS, {(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0});
ccshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP")); ccshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP"));
milestones.clear(); std::vector<GradientMilestone> mccshape;
milestones.push_back(GradientMilestone(0., 0., 0., 0.)); mccshape.push_back(GradientMilestone(0., 0., 0., 0.));
milestones.push_back(GradientMilestone(1., 1., 1., 1.)); mccshape.push_back(GradientMilestone(1., 1., 1., 1.));
ccshape->setBottomBarBgGradient(milestones); ccshape->setBottomBarBgGradient(mccshape);
ccshape->setLeftBarBgGradient(milestones); ccshape->setLeftBarBgGradient(mccshape);
llCurveEditorG->newLine(); llCurveEditorG->newLine();
@@ -218,31 +217,31 @@ Locallab::Locallab():
LHshape->setResetCurve(FCT_MinMaxCPoints, {(double)FCT_MinMaxCPoints, 0.0, 0.50, 0.35, 0.35, 0.166, 0.50, 0.35, 0.35, 0.333, 0.50, 0.35, 0.35, 0.50, 0.50, 0.35, 0.35, 0.666, 0.50, 0.35, 0.35, 0.833, 0.50, 0.35, 0.35}); LHshape->setResetCurve(FCT_MinMaxCPoints, {(double)FCT_MinMaxCPoints, 0.0, 0.50, 0.35, 0.35, 0.166, 0.50, 0.35, 0.35, 0.333, 0.50, 0.35, 0.35, 0.50, 0.50, 0.35, 0.35, 0.666, 0.50, 0.35, 0.35, 0.833, 0.50, 0.35, 0.35});
LHshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP")); LHshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP"));
LHshape->setCurveColorProvider(this, 1); LHshape->setCurveColorProvider(this, 1);
milestones.clear(); std::vector<GradientMilestone> mLHshape;
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
float x = float (i) * (1.0f / 6.0); float x = float (i) * (1.0f / 6.0);
Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B);
milestones.push_back(GradientMilestone(double (x), double (R), double (G), double (B))); mLHshape.push_back(GradientMilestone(double (x), double (R), double (G), double (B)));
} }
LHshape->setBottomBarBgGradient(milestones); LHshape->setBottomBarBgGradient(mLHshape);
HHshape = static_cast<FlatCurveEditor*>(llCurveEditorG->addCurve(CT_Flat, "H(H)", nullptr, false, true)); HHshape = static_cast<FlatCurveEditor*>(llCurveEditorG->addCurve(CT_Flat, "H(H)", nullptr, false, true));
HHshape->setIdentityValue(0.); HHshape->setIdentityValue(0.);
HHshape->setResetCurve(FCT_MinMaxCPoints, {(double)FCT_MinMaxCPoints, 0.0, 0.50, 0.35, 0.35, 0.166, 0.50, 0.35, 0.35, 0.333, 0.50, 0.35, 0.35, 0.50, 0.50, 0.35, 0.35, 0.666, 0.50, 0.35, 0.35, 0.833, 0.50, 0.35, 0.35}); HHshape->setResetCurve(FCT_MinMaxCPoints, {(double)FCT_MinMaxCPoints, 0.0, 0.50, 0.35, 0.35, 0.166, 0.50, 0.35, 0.35, 0.333, 0.50, 0.35, 0.35, 0.50, 0.50, 0.35, 0.35, 0.666, 0.50, 0.35, 0.35, 0.833, 0.50, 0.35, 0.35});
HHshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP")); HHshape->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_LL_TOOLTIP"));
HHshape->setCurveColorProvider(this, 1); HHshape->setCurveColorProvider(this, 1);
milestones.clear(); std::vector<GradientMilestone> mHHshape;
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
float x = float (i) * (1.0f / 6.0); float x = float (i) * (1.0f / 6.0);
Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B);
milestones.push_back(GradientMilestone(double (x), double (R), double (G), double (B))); mHHshape.push_back(GradientMilestone(double (x), double (R), double (G), double (B)));
} }
HHshape->setBottomBarBgGradient(milestones); HHshape->setBottomBarBgGradient(mHHshape);
llCurveEditorG->curveListComplete(); llCurveEditorG->curveListComplete();
@@ -295,11 +294,11 @@ Locallab::Locallab():
shapeexpos = static_cast<DiagonalCurveEditor*>(curveEditorG->addCurve(CT_Diagonal, "")); shapeexpos = static_cast<DiagonalCurveEditor*>(curveEditorG->addCurve(CT_Diagonal, ""));
shapeexpos->setResetCurve(DCT_NURBS, {(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0}); shapeexpos->setResetCurve(DCT_NURBS, {(double)DCT_NURBS, 0.0, 0.0, 1.0, 1.0});
shapeexpos->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_TONES_TOOLTIP")); shapeexpos->setTooltip(M("TP_LOCALLAB_CURVEEDITOR_TONES_TOOLTIP"));
milestones.clear(); std::vector<GradientMilestone> mshapeexpos;
milestones.push_back(GradientMilestone(0., 0., 0., 0.)); mshapeexpos.push_back(GradientMilestone(0., 0., 0., 0.));
milestones.push_back(GradientMilestone(1., 1., 1., 1.)); mshapeexpos.push_back(GradientMilestone(1., 1., 1., 1.));
shapeexpos->setBottomBarBgGradient(milestones); shapeexpos->setBottomBarBgGradient(mshapeexpos);
shapeexpos->setLeftBarBgGradient(milestones); shapeexpos->setLeftBarBgGradient(mshapeexpos);
curveEditorG->curveListComplete(); curveEditorG->curveListComplete();
@@ -340,14 +339,14 @@ Locallab::Locallab():
skinTonesCurve = static_cast<DiagonalCurveEditor*>(curveEditorGG->addCurve(CT_Diagonal, M("TP_VIBRANCE_CURVEEDITOR_SKINTONES"))); skinTonesCurve = static_cast<DiagonalCurveEditor*>(curveEditorGG->addCurve(CT_Diagonal, M("TP_VIBRANCE_CURVEEDITOR_SKINTONES")));
skinTonesCurve->setTooltip(M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_TOOLTIP")); skinTonesCurve->setTooltip(M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_TOOLTIP"));
milestones.clear(); std::vector<GradientMilestone> mskinTonesCurve;
// -0.1 rad < Hue < 1.6 rad // -0.1 rad < Hue < 1.6 rad
Color::hsv2rgb01(0.92f, 0.45f, 0.6f, R, G, B); Color::hsv2rgb01(0.92f, 0.45f, 0.6f, R, G, B);
milestones.push_back(GradientMilestone(0.0, double (R), double (G), double (B))); mskinTonesCurve.push_back(GradientMilestone(0.0, double (R), double (G), double (B)));
Color::hsv2rgb01(0.14056f, 0.45f, 0.6f, R, G, B); Color::hsv2rgb01(0.14056f, 0.45f, 0.6f, R, G, B);
milestones.push_back(GradientMilestone(1.0, double (R), double (G), double (B))); mskinTonesCurve.push_back(GradientMilestone(1.0, double (R), double (G), double (B)));
skinTonesCurve->setBottomBarBgGradient(milestones); skinTonesCurve->setBottomBarBgGradient(mskinTonesCurve);
skinTonesCurve->setLeftBarBgGradient(milestones); skinTonesCurve->setLeftBarBgGradient(mskinTonesCurve);
skinTonesCurve->setRangeLabels( skinTonesCurve->setRangeLabels(
M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE1"), M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE2"), M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE1"), M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE2"),
M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE3"), M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE4") M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE3"), M("TP_VIBRANCE_CURVEEDITOR_SKINTONES_RANGE4")
@@ -1479,7 +1478,7 @@ void Locallab::write(ProcParams* pp, ParamsEdited* pedited)
// Update Locallab tools GUI // Update Locallab tools GUI
disableListener(); disableListener();
updateLocallabGUI(pp, pp->locallab.selspot); updateSpecificGUIState();
enableListener(); enableListener();
} }
@@ -1680,7 +1679,7 @@ void Locallab::pastsattog_toggled()
*/ */
} }
// Update Vibrance GUI according to pastsattog button state // Update Vibrance GUI according to pastsattog button state (to be compliant with updateSpecificGUIState function)
if (pastSatTog->get_active()) { if (pastSatTog->get_active()) {
// Link both slider, so we set saturated and psThresholds unsensitive // Link both slider, so we set saturated and psThresholds unsensitive
psThreshold->set_sensitive(false); psThreshold->set_sensitive(false);
@@ -1796,7 +1795,7 @@ void Locallab::blurMethodChanged()
{ {
printf("blurMethodChanged\n"); printf("blurMethodChanged\n");
// Update Blur & Noise GUI according to blurMethod combobox // Update Blur & Noise GUI according to blurMethod combobox (to be compliant with updateSpecificGUIState function)
if (blurMethod->get_active_row_number() == 0 || blurMethod->get_active_row_number() == 2) { if (blurMethod->get_active_row_number() == 0 || blurMethod->get_active_row_number() == 2) {
sensibn->show(); sensibn->show();
} else { } else {
@@ -1931,7 +1930,7 @@ void Locallab::inversshaChanged()
*/ */
} }
// Update Sharpening GUI according to inverssha button state // Update Sharpening GUI according to inverssha button state (to be compliant with updateSpecificGUIState function)
if (inverssha->get_active()) { if (inverssha->get_active()) {
sensisha->hide(); sensisha->hide();
} else { } else {
@@ -1968,7 +1967,7 @@ void Locallab::inversretChanged()
*/ */
} }
// Update Retinex GUI according to inversret button state // Update Retinex GUI according to inversret button state (to be compliant with updateSpecificGUIState function)
if (inversret->get_active()) { if (inversret->get_active()) {
sensih->hide(); sensih->hide();
} else { } else {
@@ -2247,7 +2246,7 @@ void Locallab::adjusterChanged(Adjuster * a, double newval)
// Exposure // Exposure
if (a == black) { if (a == black) {
// Update Exposure GUI according to black adjuster state // Update Exposure GUI according to black adjuster state (to be compliant with updateSpecificGUIState function)
shcompr->set_sensitive(!((int)black->getValue() == 0)); // At black = 0, shcompr value has no effect shcompr->set_sensitive(!((int)black->getValue() == 0)); // At black = 0, shcompr value has no effect
} }
@@ -3042,7 +3041,10 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, int
// Others // Others
avoid->set_active((bool)pp->locallab.avoid.at(index)); avoid->set_active((bool)pp->locallab.avoid.at(index));
} }
}
void Locallab::updateSpecificGUIState()
{
// Update Color & Light GUI according to invers button state // Update Color & Light GUI according to invers button state
if (invers->get_active()) { if (invers->get_active()) {
sensi->show(); sensi->show();
@@ -3060,10 +3062,10 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, int
} }
// Update Exposure GUI according to black adjuster state // Update Exposure GUI according to black adjuster state (to be compliant with adjusterChanged function)
shcompr->set_sensitive(!((int)black->getValue() == 0)); // At black = 0, shcompr value has no effect shcompr->set_sensitive(!((int)black->getValue() == 0)); // At black = 0, shcompr value has no effect
// Update Vibrance GUI according to pastsattog button state // Update Vibrance GUI according to pastsattog button state (to be compliant with pastsattog_toggled function)
if (pastSatTog->get_active()) { if (pastSatTog->get_active()) {
// Link both slider, so we set saturated and psThresholds unsensitive // Link both slider, so we set saturated and psThresholds unsensitive
psThreshold->set_sensitive(false); psThreshold->set_sensitive(false);
@@ -3075,21 +3077,21 @@ void Locallab::updateLocallabGUI(const rtengine::procparams::ProcParams* pp, int
saturated->set_sensitive(true); saturated->set_sensitive(true);
} }
// Update Blur & Noise GUI according to blurMethod combobox // Update Blur & Noise GUI according to blurMethod combobox (to be compliant with blurMethodChanged function)
if (blurMethod->get_active_row_number() == 0 || blurMethod->get_active_row_number() == 2) { if (blurMethod->get_active_row_number() == 0 || blurMethod->get_active_row_number() == 2) {
sensibn->show(); sensibn->show();
} else { } else {
sensibn->hide(); sensibn->hide();
} }
// Update Retinex GUI according to inversret button state // Update Retinex GUI according to inversret button state (to be compliant with inversretChanged function)
if (inversret->get_active()) { if (inversret->get_active()) {
sensih->hide(); sensih->hide();
} else { } else {
sensih->show(); sensih->show();
} }
// Update Sharpening GUI according to inverssha button state // Update Sharpening GUI according to inverssha button state (to be compliant with inversshaChanged function)
if (inverssha->get_active()) { if (inverssha->get_active()) {
sensisha->hide(); sensisha->hide();
} else { } else {

View File

@@ -211,6 +211,7 @@ private:
// Locallab GUI management function // Locallab GUI management function
void updateLocallabGUI(const rtengine::procparams::ProcParams* pp, int index); void updateLocallabGUI(const rtengine::procparams::ProcParams* pp, int index);
void updateSpecificGUIState();
public: public:
Locallab(); Locallab();