diff --git a/rtengine/flatcurves.cc b/rtengine/flatcurves.cc index c661b618e..179bbe9b0 100644 --- a/rtengine/flatcurves.cc +++ b/rtengine/flatcurves.cc @@ -102,10 +102,18 @@ bool FlatCurve::setIdentityValue (double iVal) { break; } } - if (identity) - kind = FCT_Empty; - else + + if (!identity && N > (periodic?1:0) ) { + CtrlPoints_set (); + fillHash(); kind = FCT_MinMaxCPoints; + } + else { + poly_x.clear(); + poly_y.clear(); + hash.clear(); + kind = FCT_Empty; + } return kind==FCT_Empty; } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index d07acc454..c99a0ac53 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -376,13 +376,14 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { if(params.blackwhite.enabled) {actListener->autoColorTonChanged(0, satTH, satPR);} else { if(params.colorToning.autosat){ - if(params.colorToning.method=="Lab") indi=1; - else if(params.colorToning.method=="RGBCurves") indi=1; - else if(params.colorToning.method=="RGBSliders") indi=1; - else if(params.colorToning.method=="Splico") indi=2; - else if(params.colorToning.method=="Splitlr") indi=2; - - actListener->autoColorTonChanged(indi, satTH, satPR);} + if(params.colorToning.method=="Lab") indi=1; + else if(params.colorToning.method=="RGBCurves") indi=1; + else if(params.colorToning.method=="RGBSliders") indi=1; + else if(params.colorToning.method=="Splico") indi=2; + else if(params.colorToning.method=="Splitlr") indi=2; + + actListener->autoColorTonChanged(indi, satTH, satPR); + } } } // if it's just crop we just need the histogram, no image updates diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 05427352c..3047aadb4 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -115,46 +115,65 @@ ColorToningParams::ColorToningParams () : hlColSat(60, 80, false), shadowsColSat setDefault(); } +void ColorToningParams::getDefaultColorCurve(std::vector &curve) { + double v[8]= { 0.050, 0.62, 0.25, 0.25, + 0.585, 0.11, 0.25, 0.25 }; + + curve.resize(9); + curve.at(0) = double(FCT_MinMaxCPoints); + for (size_t i=1; i &curve) { + double v[16]={ 0.00, 0.3, 0.35, 0.00, + 0.25, 0.8, 0.35, 0.35, + 0.70, 0.8, 0.35, 0.35, + 1.00, 0.3, 0.00, 0.00 }; + curve.resize(17); + curve.at(0 ) = double(FCT_MinMaxCPoints); + for (size_t i=1; i &curve) { + double v[6]= { 0.00, 0.00, + 0.35, 0.65, + 1.00, 1.00 }; + + curve.resize(7); + curve.at(0) = double(DCT_NURBS); + for (size_t i=1; i &curve) { + double v[6]= { 0.00, 0.00, + 0.35, 0.65, + 1.00, 1.00 }; + + curve.resize(7); + curve.at(0) = double(DCT_NURBS); + for (size_t i=1; i &colorCurve, std::vector &opacityCurve) const { diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 72fa73290..ec8438397 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -307,6 +307,11 @@ class ColorToningParams { void slidersToCurve(std::vector &colorCurve, std::vector &opacityCurve) const; /// @brief Fill the ColorGradientCurve and OpacityCurve LUTf from the control points curve or sliders value void getCurves(ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3]) const; + + static void getDefaultColorCurve(std::vector &curve); + static void getDefaultOpacityCurve(std::vector &curve); + static void getDefaultCLCurve(std::vector &curve); + static void getDefaultCL2Curve(std::vector &curve); }; /** diff --git a/rtgui/colortoning.cc b/rtgui/colortoning.cc index 2b8cd07a9..b43eb35f0 100644 --- a/rtgui/colortoning.cc +++ b/rtgui/colortoning.cc @@ -72,6 +72,9 @@ ColorToning::ColorToning () : FoldableToolPanel(this) milestones.push_back( GradientMilestone(0., 0., 0., 0.) ); milestones.push_back( GradientMilestone(1., 1., 1., 1.) ); colorShape->setBottomBarBgGradient(milestones); + std::vector defaultCurve; + rtengine::ColorToningParams::getDefaultColorCurve(defaultCurve); + colorShape->setResetCurve(FCT_MinMaxCPoints, defaultCurve); // This will add the reset button at the end of the curveType buttons colorCurveEditorG->curveListComplete(); @@ -98,8 +101,10 @@ ColorToning::ColorToning () : FoldableToolPanel(this) opacityCurveEditorG = new CurveEditorGroup (options.lastColorToningCurvesDir, M("TP_COLORTONING_OPACITY")); opacityCurveEditorG->setCurveListener (this); + rtengine::ColorToningParams::getDefaultOpacityCurve(defaultCurve); opacityShape = static_cast(opacityCurveEditorG->addCurve(CT_Flat, "", NULL, false)); opacityShape->setIdentityValue(0.); + opacityShape->setResetCurve(FlatCurveType(defaultCurve.at(0)), defaultCurve); opacityShape->setBottomBarBgGradient(milestones); // This will add the reset button at the end of the curveType buttons @@ -117,7 +122,10 @@ ColorToning::ColorToning () : FoldableToolPanel(this) clCurveEditorG = new CurveEditorGroup (options.lastColorToningCurvesDir, M(labchroma1)); clCurveEditorG->setCurveListener (this); + + rtengine::ColorToningParams::getDefaultCLCurve(defaultCurve); clshape = static_cast(clCurveEditorG->addCurve(CT_Diagonal, M("TP_COLORTONING_AB"),irg)); + clshape->setResetCurve(DiagonalCurveType(defaultCurve.at(0)), defaultCurve); clshape->setTooltip(M("TP_LABCURVE_CURVEEDITOR_CL_TOOLTIP")); //clshape->setEditID(EUID_Lab_CLCurve, BT_SINGLEPLANE_FLOAT); @@ -137,7 +145,9 @@ ColorToning::ColorToning () : FoldableToolPanel(this) cl2CurveEditorG = new CurveEditorGroup (options.lastColorToningCurvesDir, M(labchroma1)); cl2CurveEditorG->setCurveListener (this); + rtengine::ColorToningParams::getDefaultCL2Curve(defaultCurve); cl2shape = static_cast(cl2CurveEditorG->addCurve(CT_Diagonal, M("TP_COLORTONING_BY"),iby)); + cl2shape->setResetCurve(DiagonalCurveType(defaultCurve.at(0)), defaultCurve); cl2shape->setTooltip(M("TP_LABCURVE_CURVEEDITOR_LL_TOOLTIP")); //clshape->setEditID(EUID_Lab_CLCurve, BT_SINGLEPLANE_FLOAT); @@ -152,18 +162,18 @@ ColorToning::ColorToning () : FoldableToolPanel(this) pack_start( *cl2CurveEditorG, Gtk::PACK_SHRINK, 2); //--------------------- Reset curves ----------------------------- - neutrcurHBox = Gtk::manage (new Gtk::HBox ()); - neutrcurHBox->set_border_width (2); + neutralCurvesHBox = Gtk::manage (new Gtk::HBox ()); + neutralCurvesHBox->set_border_width (2); - neutralcur = Gtk::manage (new Gtk::Button (M("TP_COLORTONING_NEUTRALCUR"))); + neutralCurves = Gtk::manage (new Gtk::Button (M("TP_COLORTONING_NEUTRALCUR"))); RTImage *resetImgc = Gtk::manage (new RTImage ("gtk-undo-ltr-small.png", "gtk-undo-rtl-small.png")); - neutralcur->set_image(*resetImgc); - neutralcur->set_tooltip_text (M("TP_COLORTONING_NEUTRALCUR_TIP")); - neutralcurconn = neutralcur->signal_pressed().connect( sigc::mem_fun(*this, &ColorToning::neutralcur_pressed) ); - neutralcur->show(); - neutrcurHBox->pack_start (*neutralcur); + neutralCurves->set_image(*resetImgc); + neutralCurves->set_tooltip_text (M("TP_COLORTONING_NEUTRALCUR_TIP")); + neutralcurvesconn = neutralCurves->signal_pressed().connect( sigc::mem_fun(*this, &ColorToning::neutralCurves_pressed) ); + neutralCurves->show(); + neutralCurvesHBox->pack_start (*neutralCurves); - pack_start (*neutrcurHBox); + pack_start (*neutralCurvesHBox); //----------- Sliders + balance ------------------------------ @@ -340,37 +350,18 @@ ColorToning::~ColorToning() { delete cl2CurveEditorG; } -void ColorToning::neutralcur_pressed () { +void ColorToning::neutralCurves_pressed () { disableListener(); - - std::vector p; -// double fla[9]={1,0.25,0.8,0.25,0.25,0.75,0.6,0.25,0.25}; - double fla[9]={1,0.05,0.62,0.25,0.25,0.585,0.11,0.25,0.25}; - for(int i=0;i<9;i++) p.push_back(fla[i]); - colorShape->setCurve(p); + bool changed = false; + changed |= colorShape->reset(); + changed |= opacityShape->reset(); + changed |= clshape->reset(); + changed |= cl2shape->reset(); - std::vector p2; + enableListener(); - - //double fla2[9]={1,0.7,0.8,0.35,0.35,1,0.3,0,0}; - double fla2[17]={1,0.,0.3,0.35,0.,0.25,0.8,0.35,0.35,0.7,0.8,0.35,0.35,1.0,0.3,0.,0.}; - for(int i=0;i<17;i++) p2.push_back(fla2[i]); - opacityShape->setCurve(p2); - - std::vector p3; - double fla3[9]={3,0,0,0.35,0.65,1,1}; - for(int i=0;i<7;i++) p3.push_back(fla3[i]); - clshape->setCurve(p3); - - std::vector p4; - double fla4[9]={3,0,0,0.35,0.65,1,1}; - for(int i=0;i<7;i++) p4.push_back(fla4[i]); - cl2shape->setCurve(p4); - - enableListener(); - - if (listener && enabled->get_active()) + if (listener && enabled->get_active() && changed) listener->panelChanged (EvColorToningNeutralcur, M("ADJUSTER_RESET_TO_DEFAULT")); } @@ -525,10 +516,10 @@ void ColorToning::write (ProcParams* pp, ParamsEdited* pedited) { pp->colorToning.hlColSat = hlColSat->getValue (); pp->colorToning.shadowsColSat = shadowsColSat->getValue (); - pp->colorToning.autosat = autosat->get_active(); + pp->colorToning.autosat = autosat->get_active(); pp->colorToning.satProtectionThreshold = satProtectionThreshold->getIntValue(); pp->colorToning.saturatedOpacity = saturatedOpacity->getIntValue(); - pp->colorToning.strengthprotection = strengthprotection->getIntValue(); + pp->colorToning.strengthprotection = strengthprotection->getIntValue(); if (pedited) { pedited->colorToning.redlow = redlow->getEditedState (); @@ -715,19 +706,18 @@ bool ColorToning::CTComp_ () { saturatedOpacity->setValue (nextsatpr); satProtectionThreshold->setValue (nextsatth); if(nextbw==1) { - saturatedOpacity->show(); - satProtectionThreshold->show(); - autosat->show(); + saturatedOpacity->show(); + satProtectionThreshold->show(); + autosat->show(); } else { - saturatedOpacity->hide(); - satProtectionThreshold->hide(); - autosat->hide(); + saturatedOpacity->hide(); + satProtectionThreshold->hide(); + autosat->hide(); } enableListener (); - return false; } @@ -794,8 +784,6 @@ void ColorToning::twocolorChanged (bool changedbymethod) { clCurveEditorG->show(); // visible cl2CurveEditorG->show(); // visible irg->show(); - - } } else if(method->get_active_row_number()==1) { // RGB Sliders @@ -844,7 +832,7 @@ void ColorToning::methodChanged () { opacityCurveEditorG->hide(); clCurveEditorG->hide(); cl2CurveEditorG->hide(); - neutrcurHBox->show(); + neutralCurvesHBox->show(); hlColSat->hide(); shadowsColSat->hide(); balance->hide(); @@ -872,7 +860,7 @@ void ColorToning::methodChanged () { opacityCurveEditorG->hide(); clCurveEditorG->hide(); cl2CurveEditorG->hide(); - neutrcurHBox->hide(); + neutralCurvesHBox->hide(); hlColSat->show(); shadowsColSat->show(); balance->show(); @@ -898,7 +886,7 @@ void ColorToning::methodChanged () { opacityCurveEditorG->show(); clCurveEditorG->hide(); cl2CurveEditorG->hide(); - neutrcurHBox->show(); + neutralCurvesHBox->show(); hlColSat->hide(); shadowsColSat->hide(); balance->hide(); @@ -923,7 +911,7 @@ void ColorToning::methodChanged () { opacityCurveEditorG->hide(); clCurveEditorG->hide(); cl2CurveEditorG->hide(); - neutrcurHBox->hide(); + neutralCurvesHBox->hide(); hlColSat->hide(); shadowsColSat->hide(); balance->hide(); @@ -947,13 +935,13 @@ void ColorToning::methodChanged () { opacityCurveEditorG->hide(); clCurveEditorG->hide(); cl2CurveEditorG->hide(); - neutrcurHBox->hide(); + neutralCurvesHBox->hide(); hlColSat->show(); shadowsColSat->show(); balance->show(); satLimiterSep->hide(); satProtectionThreshold->hide(); - saturatedOpacity->hide(); + saturatedOpacity->hide(); strengthprotection->show(); chanMixerBox->hide(); diff --git a/rtgui/colortoning.h b/rtgui/colortoning.h index 888bf2455..7de412b44 100644 --- a/rtgui/colortoning.h +++ b/rtgui/colortoning.h @@ -30,7 +30,7 @@ class ColorToning : public ToolParamBlock, public FoldableToolPanel, public rte DiagonalCurveEditor* clshape; DiagonalCurveEditor* cl2shape; Gtk::HBox* ctbox; - + Gtk::VBox* chanMixerBox; MyComboBoxText* method; sigc::connection methodconn; @@ -52,30 +52,30 @@ class ColorToning : public ToolParamBlock, public FoldableToolPanel, public rte ThresholdAdjuster* hlColSat; Adjuster* satProtectionThreshold; Adjuster* saturatedOpacity; - Adjuster* strengthprotection; - Gtk::Image* itot; - Gtk::Image* iby; - Gtk::Image* irg; - + Adjuster* strengthprotection; + Gtk::Image* itot; + Gtk::Image* iby; + Gtk::Image* irg; + Gtk::Button* neutral; - Gtk::Button* neutralcur; + Gtk::Button* neutralCurves; Gtk::HBox* neutrHBox; - Gtk::HBox* neutrcurHBox; + Gtk::HBox* neutralCurvesHBox; Gtk::HBox* chromaHbox; Gtk::Label* colLabel; Gtk::Label* interLabel; Gtk::Label* chroLabel; - int nextbw; - int nextsatth; - int nextsatpr; - Glib::ustring labchroma1; - Glib::ustring labchroma2; - Glib::ustring nextbalcolor; - Glib::ustring balcolor; + int nextbw; + int nextsatth; + int nextsatpr; + Glib::ustring labchroma1; + Glib::ustring labchroma2; + Glib::ustring nextbalcolor; + Glib::ustring balcolor; bool lastEnabled; sigc::connection enaConn; bool lasttwocolor; - sigc::connection neutralconn, twocconn, neutralcurconn; + sigc::connection neutralconn, twocconn, neutralcurvesconn; bool lastautosat; sigc::connection autosatConn; @@ -86,29 +86,29 @@ class ColorToning : public ToolParamBlock, public FoldableToolPanel, public rte public: ColorToning (); ~ColorToning(); - void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); - void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); - void setBatchMode (bool batchMode); - void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); - void trimValues (rtengine::procparams::ProcParams* pp); - void adjusterChanged (Adjuster* a, double newval); - void adjusterChanged (ThresholdAdjuster* a, double newBottom, double newTop); - void setAdjusterBehavior (bool splitAdd, bool satThresholdAdd, bool satOpacityAdd, bool strprotectAdd, bool balanceAdd); - void neutral_pressed (); - void neutralcur_pressed (); - void autoColorTonChanged (int bwct, int satthres, int satprot); - bool CTComp_ (); + void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); + void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); + void setBatchMode (bool batchMode); + void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited=NULL); + void trimValues (rtengine::procparams::ProcParams* pp); + void adjusterChanged (Adjuster* a, double newval); + void adjusterChanged (ThresholdAdjuster* a, double newBottom, double newTop); + void setAdjusterBehavior (bool splitAdd, bool satThresholdAdd, bool satOpacityAdd, bool strprotectAdd, bool balanceAdd); + void neutral_pressed (); + void neutralCurves_pressed (); + void autoColorTonChanged (int bwct, int satthres, int satprot); + bool CTComp_ (); - void enabledChanged (); - void curveChanged (CurveEditor* ce); - void autosatChanged (); - void autoOpenCurve (); - void methodChanged (); - void twocolorChanged (bool changedbymethod); - void twoColorChangedByGui(); - void lumamodeChanged (); + void enabledChanged (); + void curveChanged (CurveEditor* ce); + void autosatChanged (); + void autoOpenCurve (); + void methodChanged (); + void twocolorChanged (bool changedbymethod); + void twoColorChangedByGui (); + void lumamodeChanged (); - void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller); + void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller); }; #endif diff --git a/rtgui/curveeditor.cc b/rtgui/curveeditor.cc index 225e7aed1..1cadad6a6 100644 --- a/rtgui/curveeditor.cc +++ b/rtgui/curveeditor.cc @@ -25,6 +25,10 @@ #include +bool CurveEditor::reset() { + return subGroup->curveReset(this); +} + DiagonalCurveEditor::DiagonalCurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEditorSubGroup* ceSubGroup) : CurveEditor::CurveEditor(text, static_cast(ceGroup), ceSubGroup) { // Order set in the same order than "enum DiagonalCurveType". Shouldn't change, for compatibility reason @@ -62,6 +66,25 @@ std::vector DiagonalCurveEditor::getCurve () { } } +void DiagonalCurveEditor::setResetCurve(DiagonalCurveType cType, const std::vector &resetCurve) { + switch (cType) { + case (DCT_NURBS): + if (resetCurve.size() && DiagonalCurveType(resetCurve.at(0)) == cType) + NURBSResetCurve = resetCurve; + break; + case (DCT_Parametric): + if (resetCurve.size() && DiagonalCurveType(resetCurve.at(0)) == cType) + paramResetCurve = resetCurve; + break; + case (DCT_Spline): + if (resetCurve.size() && DiagonalCurveType(resetCurve.at(0)) == cType) + customResetCurve = resetCurve; + break; + default: + break; + } +} + void DiagonalCurveEditor::setRangeLabels(Glib::ustring r1, Glib::ustring r2, Glib::ustring r3, Glib::ustring r4) { rangeLabels[0] = r1; rangeLabels[1] = r2; @@ -122,6 +145,17 @@ std::vector FlatCurveEditor::getCurve () { } } +void FlatCurveEditor::setResetCurve(FlatCurveType cType, const std::vector &resetCurve) { + switch (cType) { + case (FCT_MinMaxCPoints): + if (resetCurve.size() && FlatCurveType(resetCurve.at(0)) == cType) + controlPointsResetCurve = resetCurve; + break; + default: + break; + } +} + /* * CurveEditor (CurveEditorGroup* ceGroup, Glib::ustring text) * @@ -333,7 +367,6 @@ bool CurveEditor::drag(int modifierKey) { } CursorShape CurveEditor::getCursor(int objectID) { - printf("CurveEditor::getCursor\n"); if (remoteDrag) return CSResizeHeight; return CSOpenHand; diff --git a/rtgui/curveeditor.h b/rtgui/curveeditor.h index 877bed0e7..45ef69cc3 100644 --- a/rtgui/curveeditor.h +++ b/rtgui/curveeditor.h @@ -23,6 +23,8 @@ #include "../rtengine/LUT.h" #include "coloredbar.h" #include "edit.h" +#include "mydiagonalcurve.h" +#include "myflatcurve.h" class CurveEditorGroup; class CurveEditorSubGroup; @@ -113,6 +115,7 @@ class CurveEditor : public EditSubscriber { virtual void setIdentityValue (const double iValue=0.5) {}; virtual double getIdentityValue () { return 0.5; }; virtual std::vector getCurve () = 0; + bool reset(); void setTooltip(Glib::ustring ttip); sigc::signal signal_curvegraph_enter(); @@ -143,8 +146,11 @@ class DiagonalCurveEditor : public CurveEditor { protected: // reflects the buttonType active selection ; used as a pre-'selectionChange' reminder value std::vector customCurveEd; + std::vector customResetCurve; std::vector paramCurveEd; + std::vector paramResetCurve; std::vector NURBSCurveEd; + std::vector NURBSResetCurve; Glib::ustring rangeLabels[4]; double rangeMilestones[3]; @@ -155,6 +161,9 @@ class DiagonalCurveEditor : public CurveEditor { void getRangeLabels(Glib::ustring &r1, Glib::ustring &r2, Glib::ustring &r3, Glib::ustring &r4); void setRangeDefaultMilestones(double m1, double m2, double m3); void getRangeDefaultMilestones(double &m1, double &m2, double &m3); + + // set the reset curve for a given curve type. This is optional; all curve type have a default reset curve + void setResetCurve(DiagonalCurveType cType, const std::vector &resetCurve); }; @@ -170,6 +179,7 @@ class FlatCurveEditor : public CurveEditor { protected: // reflects the buttonType active selection ; used as a pre-'selectionChange' reminder value std::vector controlPointsCurveEd; + std::vector controlPointsResetCurve; bool periodic; double identityValue; @@ -178,6 +188,9 @@ class FlatCurveEditor : public CurveEditor { virtual void setIdentityValue (const double iValue=0.5) { identityValue = iValue; } virtual double getIdentityValue () { return identityValue; }; std::vector getCurve (); + + // set the reset curve for a given curve type. This is optional; all curve type have a default reset curve + void setResetCurve(FlatCurveType cType, const std::vector &resetCurve); }; #endif diff --git a/rtgui/curveeditorgroup.cc b/rtgui/curveeditorgroup.cc index d0fe49e44..8c5d08562 100644 --- a/rtgui/curveeditorgroup.cc +++ b/rtgui/curveeditorgroup.cc @@ -294,7 +294,7 @@ float CurveEditorGroup::blendPipetteValues (float chan1, float chan2, float chan */ void CurveEditorGroup::curveResetPressed () { if (displayedCurve) { - if (displayedCurve->subGroup->curveReset(displayedCurve->selected, displayedCurve->getIdentityValue())) { + if (displayedCurve->subGroup->curveReset(displayedCurve)) { curveChanged(); } } diff --git a/rtgui/curveeditorgroup.h b/rtgui/curveeditorgroup.h index 84a3ec79e..2650f5770 100644 --- a/rtgui/curveeditorgroup.h +++ b/rtgui/curveeditorgroup.h @@ -125,6 +125,8 @@ public: virtual void pipetteButton1Released(EditDataProvider *provider) =0; virtual void pipetteDrag(EditDataProvider *provider, int modifierKey) =0; + virtual bool curveReset (CurveEditor *ce) = 0; // Reset a curve editor, return TRUE if successful (curve changed) + protected: /** @@ -137,7 +139,6 @@ protected: Glib::ustring outputFile (); Glib::ustring inputFile (); - virtual bool curveReset (int cType, double iValue) = 0; // Reset a curve editor, return TRUE if successful (curve changed) virtual void storeCurveValues (CurveEditor* ce, const std::vector& p) = 0; virtual void storeDisplayedCurve () = 0; virtual void restoreDisplayedHistogram() {}; diff --git a/rtgui/curvelistener.h b/rtgui/curvelistener.h index c1119703d..e9c265821 100644 --- a/rtgui/curvelistener.h +++ b/rtgui/curvelistener.h @@ -33,6 +33,12 @@ class CurveListener { void setMulti(bool value) { multi = value; } bool isMulti() { return multi; } + /** @brief Ask the reset curve for a given curve type + * @param ce CurveEditor that we want to reset + * @param curve Actual curve for the return value. The actual curve type (given by the first value of the vector) + * should be kept the same. Change the curve type if REALLY necessary! */ + virtual bool getResetCurve(CurveEditor *ce, std::vector &curve) { return false; }; + /** @brief Blend pipette values from its different channels into a single value If the buffer has more than one channel and one channel, this method will blend them together. @param chan1 first channel's value diff --git a/rtgui/diagonalcurveeditorsubgroup.cc b/rtgui/diagonalcurveeditorsubgroup.cc index 2c524e80c..85a9c4465 100644 --- a/rtgui/diagonalcurveeditorsubgroup.cc +++ b/rtgui/diagonalcurveeditorsubgroup.cc @@ -856,14 +856,19 @@ void DiagonalCurveEditorSubGroup::removeEditor () { removeIfThere (parent, NURBSCurveBox, false); } -bool DiagonalCurveEditorSubGroup::curveReset(int cType, double iValue) { - switch ((DiagonalCurveType) cType) { +bool DiagonalCurveEditorSubGroup::curveReset(CurveEditor *ce) { + if (!ce) + return false; + + DiagonalCurveEditor *dce = static_cast(ce); + + switch (ce->selected) { case (DCT_NURBS) : // = Control cage - NURBSCurve->reset (); + NURBSCurve->reset (dce->NURBSResetCurve, dce->getIdentityValue()); return true; break; case (DCT_Spline) : // = Custom - customCurve->reset (); + customCurve->reset (dce->customResetCurve, dce->getIdentityValue()); return true; break; case (DCT_Parametric) : @@ -878,7 +883,7 @@ bool DiagonalCurveEditorSubGroup::curveReset(int cType, double iValue) { shadows->resetPressed(NULL); shcSelector->setDefaults(mileStone[0], mileStone[1], mileStone[2]); shcSelector->reset(); - paramCurve->reset (); + paramCurve->reset (dce->paramResetCurve, dce->getIdentityValue()); return true; break; } diff --git a/rtgui/diagonalcurveeditorsubgroup.h b/rtgui/diagonalcurveeditorsubgroup.h index 638a25648..a0361485c 100644 --- a/rtgui/diagonalcurveeditorsubgroup.h +++ b/rtgui/diagonalcurveeditorsubgroup.h @@ -81,6 +81,8 @@ public: void pipetteButton1Released(EditDataProvider *provider); void pipetteDrag(EditDataProvider *provider, int modifierKey); + bool curveReset (CurveEditor *ce); + protected: void storeCurveValues (CurveEditor* ce, const std::vector& p); void storeDisplayedCurve (); @@ -90,7 +92,6 @@ protected: void copyPressed (); void pastePressed (); void editToggled (Gtk::ToggleButton *button); - bool curveReset (int cType, double iValue); void removeEditor (); const std::vector getCurveFromGUI (int type); void shcChanged (); diff --git a/rtgui/flatcurveeditorsubgroup.cc b/rtgui/flatcurveeditorsubgroup.cc index 84d3c3ccc..3b77ba6dd 100644 --- a/rtgui/flatcurveeditorsubgroup.cc +++ b/rtgui/flatcurveeditorsubgroup.cc @@ -445,10 +445,15 @@ void FlatCurveEditorSubGroup::removeEditor () { removeIfThere (parent, CPointsCurveBox, false); } -bool FlatCurveEditorSubGroup::curveReset(int cType, double iValue) { - switch ((FlatCurveType) cType) { +bool FlatCurveEditorSubGroup::curveReset(CurveEditor *ce) { + if (!ce) + return false; + + FlatCurveEditor *fce = static_cast(ce); + + switch (FlatCurveType(ce->selected)) { case (FCT_MinMaxCPoints) : // = Control cage - CPointsCurve->reset (iValue); + CPointsCurve->reset (fce->controlPointsResetCurve, fce->getIdentityValue()); return true; break; /*case (FCT_Parametric) : diff --git a/rtgui/flatcurveeditorsubgroup.h b/rtgui/flatcurveeditorsubgroup.h index 083a3d420..4903aa309 100644 --- a/rtgui/flatcurveeditorsubgroup.h +++ b/rtgui/flatcurveeditorsubgroup.h @@ -54,6 +54,8 @@ public: void pipetteButton1Released(EditDataProvider *provider); void pipetteDrag(EditDataProvider *provider, int modifierKey); + bool curveReset (CurveEditor *ce); + protected: void storeCurveValues (CurveEditor* ce, const std::vector& p); void storeDisplayedCurve (); @@ -62,7 +64,6 @@ protected: void loadPressed (); void copyPressed (); void pastePressed (); - bool curveReset (int cType, double iValue); void removeEditor (); const std::vector getCurveFromGUI (int type); void editToggled (Gtk::ToggleButton *button); diff --git a/rtgui/mycurve.h b/rtgui/mycurve.h index 09d0c2f54..602ce5257 100644 --- a/rtgui/mycurve.h +++ b/rtgui/mycurve.h @@ -121,7 +121,7 @@ class MyCurve : public Gtk::DrawingArea, public BackBuffer, public ColorCaller { virtual std::vector getPoints () = 0; virtual void setPoints (const std::vector& p) = 0; virtual bool handleEvents (GdkEvent* event) = 0; - virtual void reset (double identityValue=0.5) = 0; + virtual void reset (const std::vector &resetCurve, double identityValue=0.5) = 0; virtual void pipetteMouseOver (EditDataProvider *provider, int modifierKey) =0; virtual void pipetteButton1Pressed(EditDataProvider *provider, int modifierKey) =0; diff --git a/rtgui/mydiagonalcurve.cc b/rtgui/mydiagonalcurve.cc index 4a4549ce3..916fb380e 100644 --- a/rtgui/mydiagonalcurve.cc +++ b/rtgui/mydiagonalcurve.cc @@ -1079,7 +1079,12 @@ void MyDiagonalCurve::updateBackgroundHistogram (LUTu & hist) { } -void MyDiagonalCurve::reset(double identityValue) { +void MyDiagonalCurve::reset(const std::vector &resetCurve, double identityValue) { + + if (!resetCurve.empty()) { + setPoints(resetCurve); + return; + } switch (curve.type) { case DCT_Spline : diff --git a/rtgui/mydiagonalcurve.h b/rtgui/mydiagonalcurve.h index 4aaad9e55..5866b4ade 100644 --- a/rtgui/mydiagonalcurve.h +++ b/rtgui/mydiagonalcurve.h @@ -78,7 +78,7 @@ class MyDiagonalCurve : public MyCurve { void setType (DiagonalCurveType t); bool handleEvents (GdkEvent* event); void setActiveParam (int ac); - void reset (double identityValue=0.5); + void reset (const std::vector &resetCurve, double identityValue=0.5); void updateBackgroundHistogram (LUTu & hist); void pipetteMouseOver (EditDataProvider *provider, int modifierKey); diff --git a/rtgui/myflatcurve.cc b/rtgui/myflatcurve.cc index 60e116794..0bce7c073 100644 --- a/rtgui/myflatcurve.cc +++ b/rtgui/myflatcurve.cc @@ -1448,9 +1448,15 @@ void MyFlatCurve::setType (FlatCurveType t) { setDirty(true); } -void MyFlatCurve::reset(double identityValue) { +void MyFlatCurve::reset(const std::vector &resetCurve, double identityValue) { calcDimensions(); + // If a resetCurve exist (non empty) + if (!resetCurve.empty()) { + setPoints(resetCurve); + return; + } + switch (curve.type) { case FCT_MinMaxCPoints : defaultCurve(identityValue); diff --git a/rtgui/myflatcurve.h b/rtgui/myflatcurve.h index 353d7a350..e57662351 100644 --- a/rtgui/myflatcurve.h +++ b/rtgui/myflatcurve.h @@ -119,7 +119,7 @@ class MyFlatCurve : public MyCurve { void setPoints (const std::vector& p); void setType (FlatCurveType t); bool handleEvents (GdkEvent* event); - void reset (double identityValue=0.5); + void reset (const std::vector &resetCurve, double identityValue=0.5); //void updateBackgroundHistogram (unsigned int* hist); void pipetteMouseOver (EditDataProvider *provider, int modifierKey);