"Fossies" - the Fresh Open Source Software Archive

Member "rawtherapee-5.7/rtgui/colorappearance.cc" (10 Sep 2019, 69034 Bytes) of package /linux/misc/rawtherapee-5.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "colorappearance.cc" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.6_vs_5.7.

    1 /*
    2  *  This file is part of RawTherapee.
    3  *
    4  *  Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
    5  *
    6  *  RawTherapee is free software: you can redistribute it and/or modify
    7  *  it under the terms of the GNU General Public License as published by
    8  *  the Free Software Foundation, either version 3 of the License, or
    9  *  (at your option) any later version.
   10  *
   11  *  RawTherapee is distributed in the hope that it will be useful,
   12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  *  GNU General Public License for more details.
   15  *
   16  *  You should have received a copy of the GNU General Public License
   17  *  along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.
   18  */
   19 #include <cmath>
   20 
   21 #include "colorappearance.h"
   22 
   23 #include "guiutils.h"
   24 
   25 #include "../rtengine/color.h"
   26 #include "../rtengine/procparams.h"
   27 
   28 #define MINTEMP0 2000   //1200
   29 #define MAXTEMP0 12000  //12000
   30 #define CENTERTEMP0 5000
   31 #define MINGREEN0 0.8
   32 #define MAXGREEN0 1.2
   33 
   34 #define MINLA0 0.01
   35 #define MAXLA0 16384
   36 #define CENTERLA0 500
   37 
   38 using namespace rtengine;
   39 using namespace rtengine::procparams;
   40 
   41 static double wbSlider2Temp (double sval)
   42 {
   43 
   44     // slider range: 0 - 10000
   45     double temp;
   46 
   47     if (sval <= 5000) {
   48         // linear below center-temp
   49         temp = MINTEMP0 + (sval / 5000.0) * (CENTERTEMP0 - MINTEMP0);
   50     } else {
   51         const double slope = (double) (CENTERTEMP0 - MINTEMP0) / (MAXTEMP0 - CENTERTEMP0);
   52         double x = (sval - 5000) / 5000; // x 0..1
   53         double y = x * slope + (1.0 - slope) * pow (x, 4.0);
   54         //double y = pow(x, 4.0);
   55         temp = CENTERTEMP0 + y * (MAXTEMP0 - CENTERTEMP0);
   56     }
   57 
   58     if (temp < MINTEMP0) {
   59         temp = MINTEMP0;
   60     }
   61 
   62     if (temp > MAXTEMP0) {
   63         temp = MAXTEMP0;
   64     }
   65 
   66     return temp;
   67 }
   68 
   69 static double wbSlider2la (double sval)
   70 {
   71 
   72     // slider range: 0 - 10000
   73     double la;
   74 
   75     if (sval <= 500) {
   76         // linear below center-temp
   77         la = MINLA0 + (sval / 500.0) * (CENTERLA0 - MINLA0);
   78     } else {
   79         const double slope = (double) (CENTERLA0 - MINLA0) / (MAXLA0 - CENTERLA0);
   80         double x = (sval - 500) / 500; // x 0..1
   81         double y = x * slope + (1.0 - slope) * pow (x, 4.0);
   82         //double y = pow(x, 4.0);
   83         la = CENTERLA0 + y * (MAXLA0 - CENTERLA0);
   84     }
   85 
   86     if (la < MINLA0) {
   87         la = MINLA0;
   88     }
   89 
   90     if (la > MAXLA0) {
   91         la = MAXLA0;
   92     }
   93 
   94     return la;
   95 }
   96 
   97 static double wbla2Slider (double la)
   98 {
   99 
  100     double sval;
  101 
  102     if (la <= CENTERLA0) {
  103         sval = ((la - MINLA0) / (CENTERLA0 - MINLA0)) * 500.0;
  104     } else {
  105         const double slope = (double) (CENTERLA0 - MINLA0) / (MAXLA0 - CENTERLA0);
  106         const double y = (la - CENTERLA0) / (MAXLA0 - CENTERLA0);
  107         double x = pow (y, 0.25); // rough guess of x, will be a little lower
  108         double k = 0.1;
  109         bool add = true;
  110 
  111         // the y=f(x) function is a mess to invert, therefore we have this trial-refinement loop instead.
  112         // from tests, worst case is about 20 iterations, ie no problem
  113         for (;;) {
  114             double y1 = x * slope + (1.0 - slope) * pow (x, 4.0);
  115 
  116             if (500 * fabs (y1 - y) < 0.1) {
  117                 break;
  118             }
  119 
  120             if (y1 < y) {
  121                 if (!add) {
  122                     k /= 2;
  123                 }
  124 
  125                 x += k;
  126                 add = true;
  127             } else {
  128                 if (add) {
  129                     k /= 2;
  130                 }
  131 
  132                 x -= k;
  133                 add = false;
  134             }
  135         }
  136 
  137         sval = 500.0 + x * 500.0;
  138     }
  139 
  140     if (sval < 0) {
  141         sval = 0;
  142     }
  143 
  144     if (sval > 16384.) {
  145         sval = 16384.;
  146     }
  147 
  148     return sval;
  149 }
  150 
  151 
  152 
  153 static double wbTemp2Slider (double temp)
  154 {
  155 
  156     double sval;
  157 
  158     if (temp <= CENTERTEMP0) {
  159         sval = ((temp - MINTEMP0) / (CENTERTEMP0 - MINTEMP0)) * 5000.0;
  160     } else {
  161         const double slope = (double) (CENTERTEMP0 - MINTEMP0) / (MAXTEMP0 - CENTERTEMP0);
  162         const double y = (temp - CENTERTEMP0) / (MAXTEMP0 - CENTERTEMP0);
  163         double x = pow (y, 0.25); // rough guess of x, will be a little lower
  164         double k = 0.1;
  165         bool add = true;
  166 
  167         // the y=f(x) function is a mess to invert, therefore we have this trial-refinement loop instead.
  168         // from tests, worst case is about 20 iterations, ie no problem
  169         for (;;) {
  170             double y1 = x * slope + (1.0 - slope) * pow (x, 4.0);
  171 
  172             if (5000 * fabs (y1 - y) < 0.1) {
  173                 break;
  174             }
  175 
  176             if (y1 < y) {
  177                 if (!add) {
  178                     k /= 2;
  179                 }
  180 
  181                 x += k;
  182                 add = true;
  183             } else {
  184                 if (add) {
  185                     k /= 2;
  186                 }
  187 
  188                 x -= k;
  189                 add = false;
  190             }
  191         }
  192 
  193         sval = 5000.0 + x * 5000.0;
  194     }
  195 
  196     if (sval < 0) {
  197         sval = 0;
  198     }
  199 
  200     if (sval > 10000) {
  201         sval = 10000;
  202     }
  203 
  204     return sval;
  205 }
  206 
  207 
  208 ColorAppearance::ColorAppearance () : FoldableToolPanel (this, "colorappearance", M ("TP_COLORAPP_LABEL"), false, true)
  209 {
  210     CurveListener::setMulti (true);
  211     std::vector<GradientMilestone> milestones;
  212     milestones.push_back ( GradientMilestone (0., 0., 0., 0.) );
  213     milestones.push_back ( GradientMilestone (1., 1., 1., 1.) );
  214 
  215 
  216     // ------------------------ Process #1: Converting to CIECAM
  217 
  218 
  219     // Process 1 frame
  220     Gtk::Frame *p1Frame;
  221     // Vertical box container for the content of the Process 1 frame
  222     Gtk::VBox *p1VBox;
  223 
  224     p1Frame = Gtk::manage (new Gtk::Frame (M ("TP_COLORAPP_LABEL_SCENE")) );
  225     p1Frame->set_label_align (0.025, 0.5);
  226 
  227     p1VBox = Gtk::manage ( new Gtk::VBox());
  228     p1VBox->set_spacing (2);
  229 
  230     degree  = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CIECAT_DEGREE"),    0.,  100.,  1.,   100.));
  231 
  232     if (degree->delay < options.adjusterMaxDelay) {
  233         degree->delay = options.adjusterMaxDelay;
  234     }
  235 
  236     degree->throwOnButtonRelease();
  237     degree->addAutoButton (M ("TP_COLORAPP_CAT02ADAPTATION_TOOLTIP"));
  238     p1VBox->pack_start (*degree);
  239 
  240     // surrsource = Gtk::manage (new Gtk::CheckButton (M ("TP_COLORAPP_SURSOURCE")));
  241     // surrsource->set_tooltip_markup (M ("TP_COLORAPP_SURSOURCE_TOOLTIP"));
  242 
  243 
  244     Gtk::HBox* surrHBox1 = Gtk::manage (new Gtk::HBox ());
  245     surrHBox1->set_spacing (2);
  246     surrHBox1->set_tooltip_markup (M ("TP_COLORAPP_SURROUND_TOOLTIP"));
  247     Gtk::Label* surrLabel1 = Gtk::manage (new Gtk::Label (M ("TP_COLORAPP_SURROUND") + ":"));
  248     surrHBox1->pack_start (*surrLabel1, Gtk::PACK_SHRINK);
  249     surrsrc = Gtk::manage (new MyComboBoxText ());
  250     surrsrc->append (M ("TP_COLORAPP_SURROUND_AVER"));
  251     surrsrc->append (M ("TP_COLORAPP_SURROUND_DIM"));
  252     surrsrc->append (M ("TP_COLORAPP_SURROUND_DARK"));
  253     surrsrc->append (M ("TP_COLORAPP_SURROUND_EXDARK"));
  254     surrsrc->set_active (0);
  255     surrHBox1->pack_start (*surrsrc);
  256     p1VBox->pack_start (*surrHBox1);
  257 
  258 //   p1VBox->pack_start (*surrsource, Gtk::PACK_SHRINK);
  259 
  260     Gtk::HBox* wbmHBox = Gtk::manage (new Gtk::HBox ());
  261     wbmHBox->set_spacing (2);
  262     wbmHBox->set_tooltip_markup (M ("TP_COLORAPP_MODEL_TOOLTIP"));
  263     Gtk::Label* wbmLab = Gtk::manage (new Gtk::Label (M ("TP_COLORAPP_MODEL") + ":"));
  264     wbmHBox->pack_start (*wbmLab, Gtk::PACK_SHRINK);
  265     wbmodel = Gtk::manage (new MyComboBoxText ());
  266     wbmodel->append (M ("TP_COLORAPP_WBRT"));
  267     wbmodel->append (M ("TP_COLORAPP_WBCAM"));
  268     wbmodel->append (M ("TP_COLORAPP_FREE"));
  269 
  270     wbmodel->set_active (0);
  271     wbmHBox->pack_start (*wbmodel);
  272     p1VBox->pack_start (*wbmHBox);
  273 
  274     Gtk::Image* itempL =  Gtk::manage (new RTImage ("circle-blue-small.png"));
  275     Gtk::Image* itempR =  Gtk::manage (new RTImage ("circle-yellow-small.png"));
  276     Gtk::Image* igreenL = Gtk::manage (new RTImage ("circle-magenta-small.png"));
  277     Gtk::Image* igreenR = Gtk::manage (new RTImage ("circle-green-small.png"));
  278 
  279 
  280     tempsc = Gtk::manage (new Adjuster (M ("TP_WBALANCE_TEMPERATURE"), MINTEMP0, MAXTEMP0, 5, CENTERTEMP0, itempL, itempR, &wbSlider2Temp, &wbTemp2Slider));
  281     greensc = Gtk::manage (new Adjuster (M ("TP_WBALANCE_GREEN"), MINGREEN0, MAXGREEN0, 0.001, 1.0, igreenL, igreenR));
  282     tempsc->set_tooltip_markup (M ("TP_COLORAPP_TEMP_TOOLTIP"));
  283 
  284     tempsc->show();
  285     greensc->show();
  286     p1VBox->pack_start (*tempsc);
  287     p1VBox->pack_start (*greensc);
  288 
  289 
  290 //   adapscen = Gtk::manage (new Adjuster (M ("TP_COLORAPP_ABSOLUTELUMINANCE"), 0.01, 16384., 0.001, 2000.)); // EV -7  ==> EV 17
  291     adapscen = Gtk::manage (new Adjuster (M ("TP_COLORAPP_ABSOLUTELUMINANCE"), MINLA0, MAXLA0, 0.01, 1997.4, NULL, NULL, &wbSlider2la, &wbla2Slider));
  292 
  293     if (adapscen->delay < options.adjusterMaxDelay) {
  294         adapscen->delay = options.adjusterMaxDelay;
  295     }
  296 
  297     adapscen->throwOnButtonRelease();
  298     adapscen->addAutoButton();
  299     p1VBox->pack_start (*adapscen);
  300 
  301     ybscen = Gtk::manage (new Adjuster (M ("TP_COLORAPP_MEANLUMINANCE"), 1, 90, 1, 18));
  302 
  303     if (ybscen->delay < options.adjusterMaxDelay) {
  304         ybscen->delay = options.adjusterMaxDelay;
  305     }
  306 
  307     ybscen->throwOnButtonRelease();
  308     ybscen->addAutoButton();
  309     p1VBox->pack_start (*ybscen);
  310 
  311     p1Frame->add (*p1VBox);
  312     pack_start (*p1Frame, Gtk::PACK_EXPAND_WIDGET, 4);
  313 
  314 
  315     // ------------------------ Process #2: Modifying image inside CIECAM
  316 
  317 
  318     // Process 1 frame
  319 
  320     expadjust = Gtk::manage (new MyExpander (false, M ("TP_COLORAPP_LABEL_CAM02")));
  321     setExpandAlignProperties (expadjust, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START);
  322     expadjust->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &ColorAppearance::foldAllButMe), expadjust) );
  323     /*
  324         Gtk::Frame *p2Frame;
  325         // Vertical box container for the content of the Process 1 frame
  326         Gtk::VBox *p2VBox;
  327 
  328         p2Frame = Gtk::manage (new Gtk::Frame (M ("TP_COLORAPP_LABEL_CAM02")) );
  329         p2Frame->set_label_align (0.025, 0.5);
  330     */
  331     Gtk::VBox *p2VBox;
  332 
  333     p2VBox = Gtk::manage ( new Gtk::VBox());
  334     p2VBox->set_spacing (2);
  335 
  336     Gtk::HBox* alHBox = Gtk::manage (new Gtk::HBox ());
  337     alHBox->set_spacing (2);
  338     alHBox->set_tooltip_markup (M ("TP_COLORAPP_ALGO_TOOLTIP"));
  339     Gtk::Label* alLabel = Gtk::manage (new Gtk::Label (M ("TP_COLORAPP_ALGO") + ":"));
  340     alHBox->pack_start (*alLabel, Gtk::PACK_SHRINK);
  341     algo = Gtk::manage (new MyComboBoxText ());
  342     algo->append (M ("TP_COLORAPP_ALGO_JC"));
  343     algo->append (M ("TP_COLORAPP_ALGO_JS"));
  344     algo->append (M ("TP_COLORAPP_ALGO_QM"));
  345     algo->append (M ("TP_COLORAPP_ALGO_ALL"));
  346     algo->set_active (0);
  347     alHBox->pack_start (*algo);
  348     p2VBox->pack_start (*alHBox);
  349 
  350     p2VBox->pack_start (*Gtk::manage (new  Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET, 4);
  351 
  352     jlight = Gtk::manage (new Adjuster (M ("TP_COLORAPP_LIGHT"), -100.0, 100.0, 0.1, 0.));
  353 
  354     if (jlight->delay < options.adjusterMaxDelay) {
  355         jlight->delay = options.adjusterMaxDelay;
  356     }
  357 
  358     jlight->throwOnButtonRelease();
  359     jlight->set_tooltip_markup (M ("TP_COLORAPP_LIGHT_TOOLTIP"));
  360     p2VBox->pack_start (*jlight);
  361 
  362     qbright = Gtk::manage (new Adjuster (M ("TP_COLORAPP_BRIGHT"), -100.0, 100.0, 0.1, 0.));
  363 
  364     if (qbright->delay < options.adjusterMaxDelay) {
  365         qbright->delay = options.adjusterMaxDelay;
  366     }
  367 
  368     qbright->throwOnButtonRelease();
  369     qbright->set_tooltip_markup (M ("TP_COLORAPP_BRIGHT_TOOLTIP"));
  370     p2VBox->pack_start (*qbright);
  371 
  372     chroma = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CHROMA"), -100.0, 100.0, 0.1, 0.));
  373 
  374     if (chroma->delay < options.adjusterMaxDelay) {
  375         chroma->delay = options.adjusterMaxDelay;
  376     }
  377 
  378     chroma->throwOnButtonRelease();
  379     chroma->set_tooltip_markup (M ("TP_COLORAPP_CHROMA_TOOLTIP"));
  380     p2VBox->pack_start (*chroma);
  381 
  382 
  383     schroma = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CHROMA_S"), -100.0, 100.0, 0.1, 0.));
  384 
  385     if (schroma->delay < options.adjusterMaxDelay) {
  386         schroma->delay = options.adjusterMaxDelay;
  387     }
  388 
  389     schroma->throwOnButtonRelease();
  390     schroma->set_tooltip_markup (M ("TP_COLORAPP_CHROMA_S_TOOLTIP"));
  391     p2VBox->pack_start (*schroma);
  392 
  393     mchroma = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CHROMA_M"), -100.0, 100.0, 0.1, 0.));
  394 
  395     if (mchroma->delay < options.adjusterMaxDelay) {
  396         mchroma->delay = options.adjusterMaxDelay;
  397     }
  398 
  399     mchroma->throwOnButtonRelease();
  400     mchroma->set_tooltip_markup (M ("TP_COLORAPP_CHROMA_M_TOOLTIP"));
  401     p2VBox->pack_start (*mchroma);
  402 
  403     rstprotection = Gtk::manage ( new Adjuster (M ("TP_COLORAPP_RSTPRO"), 0., 100., 0.1, 0.) );
  404 
  405     if (rstprotection->delay < options.adjusterMaxDelay) {
  406         rstprotection->delay = options.adjusterMaxDelay;
  407     }
  408 
  409     rstprotection->throwOnButtonRelease();
  410     rstprotection->set_tooltip_markup (M ("TP_COLORAPP_RSTPRO_TOOLTIP"));
  411     p2VBox->pack_start (*rstprotection);
  412 
  413     contrast = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CONTRAST"), -100.0, 100.0, 0.1, 0.));
  414 
  415     if (contrast->delay < options.adjusterMaxDelay) {
  416         contrast->delay = options.adjusterMaxDelay;
  417     }
  418 
  419     contrast->throwOnButtonRelease();
  420     contrast->set_tooltip_markup (M ("TP_COLORAPP_CONTRAST_TOOLTIP"));
  421     p2VBox->pack_start (*contrast);
  422 
  423     qcontrast = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CONTRAST_Q"), -100.0, 100.0, 0.1, 0.));
  424 
  425     if (qcontrast->delay < options.adjusterMaxDelay) {
  426         qcontrast->delay = options.adjusterMaxDelay;
  427     }
  428 
  429     qcontrast->throwOnButtonRelease();
  430     qcontrast->set_tooltip_markup (M ("TP_COLORAPP_CONTRAST_Q_TOOLTIP"));
  431     p2VBox->pack_start (*qcontrast);
  432 
  433 
  434     colorh = Gtk::manage (new Adjuster (M ("TP_COLORAPP_HUE"), -100.0, 100.0, 0.1, 0.));
  435 
  436     if (colorh->delay < options.adjusterMaxDelay) {
  437         colorh->delay = options.adjusterMaxDelay;
  438     }
  439 
  440     colorh->throwOnButtonRelease();
  441     colorh->set_tooltip_markup (M ("TP_COLORAPP_HUE_TOOLTIP"));
  442     p2VBox->pack_start (*colorh);
  443 
  444     tonecie = Gtk::manage (new Gtk::CheckButton (M ("TP_COLORAPP_TONECIE")));
  445     tonecie->set_tooltip_markup (M ("TP_COLORAPP_TONECIE_TOOLTIP"));
  446     tonecieconn = tonecie->signal_toggled().connect ( sigc::mem_fun (*this, &ColorAppearance::tonecie_toggled) );
  447     p2VBox->pack_start (*tonecie);
  448     /*
  449         sharpcie = Gtk::manage (new Gtk::CheckButton (M("TP_COLORAPP_SHARPCIE")));
  450         sharpcie->set_tooltip_markup (M("TP_COLORAPP_SHARPCIE_TOOLTIP"));
  451         sharpcieconn = sharpcie->signal_toggled().connect( sigc::mem_fun(*this, &ColorAppearance::sharpcie_toggled) );
  452         p2VBox->pack_start (*sharpcie);
  453     */
  454     p2VBox->pack_start (*Gtk::manage (new  Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET, 4);
  455 
  456     toneCurveMode = Gtk::manage (new MyComboBoxText ());
  457     toneCurveMode->append (M ("TP_COLORAPP_TCMODE_LIGHTNESS"));
  458     toneCurveMode->append (M ("TP_COLORAPP_TCMODE_BRIGHTNESS"));
  459     toneCurveMode->set_active (0);
  460     toneCurveMode->set_tooltip_text (M ("TP_COLORAPP_TCMODE_LABEL1"));
  461 
  462     curveEditorG = new CurveEditorGroup (options.lastToneCurvesDir, M ("TP_COLORAPP_CURVEEDITOR1"));
  463     curveEditorG->setCurveListener (this);
  464     curveEditorG->setTooltip (M ("TP_COLORAPP_CURVEEDITOR1_TOOLTIP"));
  465 
  466     shape = static_cast<DiagonalCurveEditor*> (curveEditorG->addCurve (CT_Diagonal, "", toneCurveMode));
  467 
  468 
  469 
  470     tcmodeconn = toneCurveMode->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::curveMode1Changed), true );
  471 
  472     toneCurveMode2 = Gtk::manage (new MyComboBoxText ());
  473     toneCurveMode2->append (M ("TP_COLORAPP_TCMODE_LIGHTNESS"));
  474     toneCurveMode2->append (M ("TP_COLORAPP_TCMODE_BRIGHTNESS"));
  475     toneCurveMode2->set_active (0);
  476     toneCurveMode2->set_tooltip_text (M ("TP_COLORAPP_TCMODE_LABEL2"));
  477 
  478     curveEditorG2 = new CurveEditorGroup (options.lastToneCurvesDir, M ("TP_COLORAPP_CURVEEDITOR2"));
  479     curveEditorG2->setCurveListener (this);
  480 
  481     shape2 = static_cast<DiagonalCurveEditor*> (curveEditorG2->addCurve (CT_Diagonal, "", toneCurveMode2));
  482 
  483     tcmode2conn = toneCurveMode2->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::curveMode2Changed), true );
  484 
  485     toneCurveMode3 = Gtk::manage (new MyComboBoxText ());
  486     toneCurveMode3->append (M ("TP_COLORAPP_TCMODE_CHROMA"));
  487     toneCurveMode3->append (M ("TP_COLORAPP_TCMODE_SATUR"));
  488     toneCurveMode3->append (M ("TP_COLORAPP_TCMODE_COLORF"));
  489     toneCurveMode3->set_active (0);
  490     toneCurveMode3->set_tooltip_text (M ("TP_COLORAPP_TCMODE_LABEL3"));
  491 
  492     curveEditorG3 = new CurveEditorGroup (options.lastToneCurvesDir, M ("TP_COLORAPP_CURVEEDITOR3"));
  493     curveEditorG3->setCurveListener (this);
  494 
  495     shape3 = static_cast<DiagonalCurveEditor*> (curveEditorG3->addCurve (CT_Diagonal, "", toneCurveMode3));
  496     shape3->setRangeLabels (
  497         M ("TP_LABCURVE_CURVEEDITOR_CC_RANGE1"), M ("TP_LABCURVE_CURVEEDITOR_CC_RANGE2"),
  498         M ("TP_LABCURVE_CURVEEDITOR_CC_RANGE3"), M ("TP_LABCURVE_CURVEEDITOR_CC_RANGE4")
  499     );
  500     shape3->setBottomBarColorProvider (this, 1);
  501     shape3->setLeftBarColorProvider (this, 1);
  502     shape3->setRangeDefaultMilestones (0.05, 0.2, 0.58);
  503 
  504 
  505 //  shape3->setBottomBarColorProvider(this, 2);
  506 //  shape3->setLeftBarColorProvider(this, 2);
  507 //  shape3->setRangeDefaultMilestones(0.05, 0.2, 0.58);
  508 
  509     // The milestones are still the same than those define above
  510     //milestones.push_back( GradientMilestone(0., 0., 0., 0.) );
  511     //milestones.push_back( GradientMilestone(1., 1., 1., 1.) );
  512     shape->setBottomBarBgGradient (milestones);
  513     shape->setLeftBarBgGradient (milestones);
  514     shape2->setBottomBarBgGradient (milestones);
  515     shape2->setLeftBarBgGradient (milestones);
  516 
  517     std::vector<GradientMilestone> shape3Milestones;
  518     float R, G, B;
  519 
  520     for (int i = 0; i < 7; i++) {
  521         float x = float (i) * (1.0f / 6.0);
  522         Color::hsv2rgb01 (x, 0.5f, 0.5f, R, G, B);
  523         shape3Milestones.push_back ( GradientMilestone (double (x), double (R), double (G), double (B)) );
  524     }
  525 
  526     shape3->setBottomBarBgGradient (shape3Milestones);
  527     shape3->setLeftBarBgGradient (shape3Milestones);
  528 
  529     shape3->setRangeDefaultMilestones (0.05, 0.2, 0.58);
  530 
  531     curveEditorG->curveListComplete();
  532 
  533     curveEditorG2->curveListComplete();
  534     curveEditorG2->setTooltip (M ("TP_COLORAPP_CURVEEDITOR2_TOOLTIP"));
  535 
  536     curveEditorG3->curveListComplete();
  537     curveEditorG3->setTooltip (M ("TP_COLORAPP_CURVEEDITOR3_TOOLTIP"));
  538     tcmode3conn = toneCurveMode3->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::curveMode3Changed), true );
  539 
  540     p2VBox->pack_start ( *curveEditorG, Gtk::PACK_SHRINK, 2);
  541     p2VBox->pack_start ( *curveEditorG2, Gtk::PACK_SHRINK, 2);
  542     p2VBox->pack_start ( *curveEditorG3, Gtk::PACK_SHRINK, 2);
  543 
  544     // ------------------------ Choice CIECAM data
  545 
  546 
  547     datacie = Gtk::manage (new Gtk::CheckButton (M ("TP_COLORAPP_DATACIE")));
  548     datacie->set_tooltip_markup (M ("TP_COLORAPP_DATACIE_TOOLTIP"));
  549     datacieconn = datacie->signal_toggled().connect ( sigc::mem_fun (*this, &ColorAppearance::datacie_toggled) );
  550     p2VBox->pack_start (*datacie);
  551 
  552     //-------------------------
  553 
  554 
  555 
  556 //    p2Frame->add (*p2VBox);
  557     expadjust->add (*p2VBox, false);
  558     expadjust->setLevel (2);
  559     pack_start (*expadjust);
  560 
  561 //    pack_start (*p2Frame, Gtk::PACK_EXPAND_WIDGET, 4);
  562 
  563 
  564 
  565     // ------------------------ Process #3: Converting back to Lab/RGB
  566 
  567 
  568     // Process 3 frame
  569     Gtk::Frame *p3Frame;
  570     // Vertical box container for the content of the Process 3 frame
  571     Gtk::VBox *p3VBox;
  572 
  573     p3Frame = Gtk::manage (new Gtk::Frame (M ("TP_COLORAPP_LABEL_VIEWING")) ); // "Editing viewing conditions" ???
  574     p3Frame->set_label_align (0.025, 0.5);
  575 
  576     p3VBox = Gtk::manage ( new Gtk::VBox());
  577     p3VBox->set_spacing (2);
  578 
  579     Gtk::Image* itempL1 =  Gtk::manage (new RTImage ("circle-blue-small.png"));
  580     Gtk::Image* itempR1 =  Gtk::manage (new RTImage ("circle-yellow-small.png"));
  581     Gtk::Image* igreenL1 = Gtk::manage (new RTImage ("circle-magenta-small.png"));
  582     Gtk::Image* igreenR1 = Gtk::manage (new RTImage ("circle-green-small.png"));
  583 //   adaplum = Gtk::manage (new Adjuster (M ("TP_COLORAPP_ABSOLUTELUMINANCE"), 0.1,  16384., 0.1,   16.));
  584     adaplum = Gtk::manage (new Adjuster (M ("TP_COLORAPP_ABSOLUTELUMINANCE"), MINLA0, MAXLA0, 0.01, 16, NULL, NULL, &wbSlider2la, &wbla2Slider));
  585 
  586     if (adaplum->delay < options.adjusterMaxDelay) {
  587         adaplum->delay = options.adjusterMaxDelay;
  588     }
  589 
  590     adaplum->throwOnButtonRelease();
  591     adaplum->set_tooltip_markup (M ("TP_COLORAPP_VIEWING_ABSOLUTELUMINANCE_TOOLTIP"));
  592     p3VBox->pack_start (*adaplum);
  593 
  594 //   Gtk::Image* iblueredL = Gtk::manage (new RTImage ("circle-blue-small.png"));
  595 //   Gtk::Image* iblueredR = Gtk::manage (new RTImage ("circle-red-small.png"));
  596 
  597     degreeout  = Gtk::manage (new Adjuster (M ("TP_COLORAPP_CIECAT_DEGREE"),    0.,  100.,  1.,   100.));
  598 
  599     if (degreeout->delay < options.adjusterMaxDelay) {
  600         degreeout->delay = options.adjusterMaxDelay;
  601     }
  602 
  603     degreeout->throwOnButtonRelease();
  604     degreeout->addAutoButton (M ("TP_COLORAPP_CAT02ADAPTATION_TOOLTIP"));
  605     p3VBox->pack_start (*degreeout);
  606     /*
  607         Gtk::Image* itempL1 =  Gtk::manage (new RTImage ("circle-blue-small.png"));
  608         Gtk::Image* itempR1 =  Gtk::manage (new RTImage ("circle-yellow-small.png"));
  609         Gtk::Image* igreenL1 = Gtk::manage (new RTImage ("circle-magenta-small.png"));
  610         Gtk::Image* igreenR1 = Gtk::manage (new RTImage ("circle-green-small.png"));
  611     */
  612     tempout = Gtk::manage (new Adjuster (M ("TP_WBALANCE_TEMPERATURE"), MINTEMP0, MAXTEMP0, 5, CENTERTEMP0, itempR1, itempL1, &wbSlider2Temp, &wbTemp2Slider));
  613     greenout = Gtk::manage (new Adjuster (M ("TP_WBALANCE_GREEN"), MINGREEN0, MAXGREEN0, 0.001, 1.0, igreenR1, igreenL1));
  614     ybout = Gtk::manage (new Adjuster (M ("TP_COLORAPP_MEANLUMINANCE"), 5, 90, 1, 18));
  615     tempout->set_tooltip_markup (M ("TP_COLORAPP_TEMP_TOOLTIP"));
  616 
  617     tempout->show();
  618     greenout->show();
  619     ybout->show();
  620     p3VBox->pack_start (*tempout);
  621     p3VBox->pack_start (*greenout);
  622     p3VBox->pack_start (*ybout);
  623 
  624     Gtk::HBox* surrHBox = Gtk::manage (new Gtk::HBox ());
  625     surrHBox->set_spacing (2);
  626     surrHBox->set_tooltip_markup (M ("TP_COLORAPP_SURROUND_TOOLTIP"));
  627     Gtk::Label* surrLabel = Gtk::manage (new Gtk::Label (M ("TP_COLORAPP_SURROUND") + ":"));
  628     surrHBox->pack_start (*surrLabel, Gtk::PACK_SHRINK);
  629     surround = Gtk::manage (new MyComboBoxText ());
  630     surround->append (M ("TP_COLORAPP_SURROUND_AVER"));
  631     surround->append (M ("TP_COLORAPP_SURROUND_DIM"));
  632     surround->append (M ("TP_COLORAPP_SURROUND_DARK"));
  633     surround->append (M ("TP_COLORAPP_SURROUND_EXDARK"));
  634     surround->set_active (1);
  635     surrHBox->pack_start (*surround);
  636     p3VBox->pack_start (*surrHBox);
  637 
  638     p3Frame->add (*p3VBox);
  639     pack_start (*p3Frame, Gtk::PACK_EXPAND_WIDGET, 4);
  640 
  641 
  642     // ------------------------ Lab Gamut control
  643 
  644 
  645     gamut = Gtk::manage (new Gtk::CheckButton (M ("TP_COLORAPP_GAMUT")));
  646     gamut->set_tooltip_markup (M ("TP_COLORAPP_GAMUT_TOOLTIP"));
  647     gamutconn = gamut->signal_toggled().connect ( sigc::mem_fun (*this, &ColorAppearance::gamut_toggled) );
  648     pack_start (*gamut, Gtk::PACK_SHRINK);
  649 
  650     // ------------------------ Bad pixel control
  651 
  652     /*
  653         badpix = Gtk::manage (new Gtk::CheckButton (M("TP_COLORAPP_BADPIX")));
  654         badpix->set_tooltip_markup (M("TP_COLORAPP_BADPIX_TOOLTIP"));
  655         badpixconn = badpix->signal_toggled().connect( sigc::mem_fun(*this, &ColorAppearance::badpix_toggled) );
  656         pack_start (*badpix, Gtk::PACK_SHRINK);
  657     */
  658     badpixsl = Gtk::manage (new Adjuster (M ("TP_COLORAPP_BADPIXSL"), 0,  2, 1,  0));
  659 
  660     if (badpixsl->delay < options.adjusterMaxDelay) {
  661         badpixsl->delay = options.adjusterMaxDelay;
  662     }
  663 
  664     badpixsl->throwOnButtonRelease();
  665     badpixsl->set_tooltip_markup (M ("TP_COLORAPP_BADPIXSL_TOOLTIP"));
  666     pack_start (*badpixsl, Gtk::PACK_SHRINK);
  667 
  668 
  669     //reset button
  670     neutral = Gtk::manage (new Gtk::Button (M ("TP_COLORAPP_NEUTRAL")));
  671     setExpandAlignProperties (neutral, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START);
  672     RTImage *resetImg = Gtk::manage (new RTImage ("undo-small.png", "redo-small.png"));
  673     setExpandAlignProperties (resetImg, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
  674     neutral->set_image (*resetImg);
  675     neutral->set_tooltip_text (M ("TP_COLORAPP_NEUTRAL_TIP"));
  676     neutralconn = neutral->signal_pressed().connect ( sigc::mem_fun (*this, &ColorAppearance::neutral_pressed) );
  677     neutral->show();
  678 
  679     //-------------
  680 
  681     pack_start (*neutral);
  682 
  683     // ------------------------ Listening events
  684 
  685 
  686 //   surrconn = surrsource->signal_toggled().connect ( sigc::mem_fun (*this, &ColorAppearance::surrsource_toggled) );
  687     wbmodelconn = wbmodel->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::wbmodelChanged) );
  688     algoconn = algo->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::algoChanged) );
  689     surroundconn = surround->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::surroundChanged) );
  690     surrsrcconn = surrsrc->signal_changed().connect ( sigc::mem_fun (*this, &ColorAppearance::surrsrcChanged) );
  691 
  692     degree->setAdjusterListener  (this);
  693     degreeout->setAdjusterListener  (this);
  694     adapscen->setAdjusterListener (this);
  695     ybscen->setAdjusterListener (this);
  696     adaplum->setAdjusterListener (this);
  697     badpixsl->setAdjusterListener (this);
  698     jlight->setAdjusterListener  (this);
  699     qbright->setAdjusterListener  (this);
  700     colorh->setAdjusterListener  (this);
  701     chroma->setAdjusterListener  (this);
  702     schroma->setAdjusterListener  (this);
  703     mchroma->setAdjusterListener  (this);
  704     contrast->setAdjusterListener  (this);
  705     qcontrast->setAdjusterListener  (this);
  706     rstprotection->setAdjusterListener  (this);
  707     tempout->setAdjusterListener  (this);
  708     greenout->setAdjusterListener  (this);
  709     ybout->setAdjusterListener  (this);
  710     tempsc->setAdjusterListener  (this);
  711     greensc->setAdjusterListener  (this);
  712 
  713 
  714     show_all();
  715 }
  716 
  717 ColorAppearance::~ColorAppearance ()
  718 {
  719     idle_register.destroy();
  720 
  721     delete curveEditorG;
  722     delete curveEditorG2;
  723     delete curveEditorG3;
  724 }
  725 
  726 void ColorAppearance::foldAllButMe (GdkEventButton* event, MyExpander *expander)
  727 {
  728     if (event->button == 3) {
  729         expadjust->set_expanded (expadjust == expander);
  730     }
  731 }
  732 
  733 void ColorAppearance::writeOptions (std::vector<int> &tpOpen)
  734 {
  735     tpOpen.push_back (expadjust->get_expanded ());
  736 }
  737 
  738 void ColorAppearance::updateToolState (std::vector<int> &tpOpen)
  739 {
  740     if (tpOpen.size() >= 1) {
  741         expadjust->set_expanded (tpOpen.at (0));
  742     }
  743 }
  744 
  745 void ColorAppearance::neutral_pressed ()
  746 {
  747     jlight->resetValue (false);
  748     qbright->resetValue (false);
  749     chroma->resetValue (false);
  750     schroma->resetValue (false);
  751     mchroma->resetValue (false);
  752     rstprotection->resetValue (false);
  753     contrast->resetValue (false);
  754     qcontrast->resetValue (false);
  755     colorh->resetValue (false);
  756     tempout->resetValue (false);
  757     greenout->resetValue (false);
  758     ybout->resetValue (false);
  759     tempsc->resetValue (false);
  760     greensc->resetValue (false);
  761     badpixsl->resetValue (false);
  762     wbmodel->set_active (0);
  763     toneCurveMode->set_active (0);
  764     toneCurveMode2->set_active (0);
  765     toneCurveMode3->set_active (0);
  766     shape->reset();
  767     shape2->reset();
  768     shape3->reset();
  769     gamutconn.block (true);
  770     gamut->set_active (true);
  771     gamutconn.block (false);
  772     degree->setAutoValue (true);
  773     degree->resetValue (false);
  774     adapscen->resetValue (false);
  775     adapscen->setAutoValue (true);
  776     degreeout->resetValue (false);
  777     degreeout->setAutoValue (true);
  778     ybscen->resetValue (false);
  779     ybscen->setAutoValue (true);
  780 }
  781 
  782 bool ColorAppearance::bgTTipQuery (int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip)
  783 {
  784     return true;
  785 }
  786 
  787 bool ColorAppearance::srTTipQuery (int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip)
  788 {
  789     return true;
  790 }
  791 
  792 void ColorAppearance::read (const ProcParams* pp, const ParamsEdited* pedited)
  793 {
  794 
  795     disableListener ();
  796     tcmodeconn.block (true);
  797     tcmode2conn.block (true);
  798     tcmode3conn.block (true);
  799     shape->setCurve (pp->colorappearance.curve);
  800     shape2->setCurve (pp->colorappearance.curve2);
  801     shape3->setCurve (pp->colorappearance.curve3);
  802     toneCurveMode->set_active (toUnderlying(pp->colorappearance.curveMode));
  803     toneCurveMode2->set_active (toUnderlying(pp->colorappearance.curveMode2));
  804     toneCurveMode3->set_active (toUnderlying(pp->colorappearance.curveMode3));
  805     curveMode3Changed(); // This will set the correct sensitive state of depending Adjusters
  806 
  807     if (pedited) {
  808         degree->setEditedState        (pedited->colorappearance.degree ? Edited : UnEdited);
  809         degreeout->setEditedState        (pedited->colorappearance.degreeout ? Edited : UnEdited);
  810         adapscen->setEditedState      (pedited->colorappearance.adapscen ? Edited : UnEdited);
  811         ybscen->setEditedState      (pedited->colorappearance.ybscen ? Edited : UnEdited);
  812         adaplum->setEditedState       (pedited->colorappearance.adaplum ? Edited : UnEdited);
  813         badpixsl->setEditedState      (pedited->colorappearance.badpixsl ? Edited : UnEdited);
  814         jlight->setEditedState        (pedited->colorappearance.jlight ? Edited : UnEdited);
  815         qbright->setEditedState       (pedited->colorappearance.qbright ? Edited : UnEdited);
  816         chroma->setEditedState        (pedited->colorappearance.chroma ? Edited : UnEdited);
  817         schroma->setEditedState       (pedited->colorappearance.schroma ? Edited : UnEdited);
  818         mchroma->setEditedState       (pedited->colorappearance.mchroma ? Edited : UnEdited);
  819         rstprotection->setEditedState (pedited->colorappearance.rstprotection ? Edited : UnEdited);
  820         tempout->setEditedState (pedited->colorappearance.tempout ? Edited : UnEdited);
  821         greenout->setEditedState (pedited->colorappearance.greenout ? Edited : UnEdited);
  822         ybout->setEditedState (pedited->colorappearance.ybout ? Edited : UnEdited);
  823         tempsc->setEditedState (pedited->colorappearance.tempsc ? Edited : UnEdited);
  824         greensc->setEditedState (pedited->colorappearance.greensc ? Edited : UnEdited);
  825         contrast->setEditedState      (pedited->colorappearance.contrast ? Edited : UnEdited);
  826         qcontrast->setEditedState     (pedited->colorappearance.qcontrast ? Edited : UnEdited);
  827         colorh->setEditedState        (pedited->colorappearance.colorh ? Edited : UnEdited);
  828 //        surrsource->set_inconsistent  (!pedited->colorappearance.surrsource);
  829         gamut->set_inconsistent       (!pedited->colorappearance.gamut);
  830         //  badpix->set_inconsistent      (!pedited->colorappearance.badpix);
  831         datacie->set_inconsistent     (!pedited->colorappearance.datacie);
  832         tonecie->set_inconsistent     (!pedited->colorappearance.tonecie);
  833         //  sharpcie->set_inconsistent    (!pedited->colorappearance.sharpcie);
  834 
  835         degree->setAutoInconsistent   (multiImage && !pedited->colorappearance.autodegree);
  836         degreeout->setAutoInconsistent   (multiImage && !pedited->colorappearance.autodegreeout);
  837         adapscen->setAutoInconsistent (multiImage && !pedited->colorappearance.autoadapscen);
  838         ybscen->setAutoInconsistent (multiImage && !pedited->colorappearance.autoybscen);
  839         set_inconsistent              (multiImage && !pedited->colorappearance.enabled);
  840 
  841         shape->setUnChanged (!pedited->colorappearance.curve);
  842         shape2->setUnChanged (!pedited->colorappearance.curve2);
  843         shape3->setUnChanged (!pedited->colorappearance.curve3);
  844 
  845         if (!pedited->colorappearance.curveMode) {
  846             toneCurveMode->set_active (2);
  847         }
  848 
  849         if (!pedited->colorappearance.curveMode2) {
  850             toneCurveMode2->set_active (2);
  851         }
  852 
  853         if (!pedited->colorappearance.curveMode3) {
  854             toneCurveMode3->set_active (3);
  855         }
  856 
  857 
  858     }
  859 
  860     setEnabled (pp->colorappearance.enabled);
  861 
  862     surrsrcconn.block (true);
  863 
  864     if (pedited && !pedited->colorappearance.surrsrc) {
  865         surrsrc->set_active (4);
  866     } else if (pp->colorappearance.surrsrc == "Average") {
  867         surrsrc->set_active (0);
  868     } else if (pp->colorappearance.surrsrc == "Dim") {
  869         surrsrc->set_active (1);
  870     } else if (pp->colorappearance.surrsrc == "Dark") {
  871         surrsrc->set_active (2);
  872     } else if (pp->colorappearance.surrsrc == "ExtremelyDark") {
  873         surrsrc->set_active (3);
  874     }
  875 
  876     surrsrcconn.block (false);
  877     // Have to be manually called to handle initial state update
  878     surrsrcChanged();
  879 
  880 
  881     surroundconn.block (true);
  882 
  883     if (pedited && !pedited->colorappearance.surround) {
  884         surround->set_active (4);
  885     } else if (pp->colorappearance.surround == "Average") {
  886         surround->set_active (0);
  887     } else if (pp->colorappearance.surround == "Dim") {
  888         surround->set_active (1);
  889     } else if (pp->colorappearance.surround == "Dark") {
  890         surround->set_active (2);
  891     } else if (pp->colorappearance.surround == "ExtremelyDark") {
  892         surround->set_active (3);
  893     }
  894 
  895     surroundconn.block (false);
  896     // Have to be manually called to handle initial state update
  897     surroundChanged();
  898 
  899 
  900 
  901     wbmodelconn.block (true);
  902 
  903     if (pedited && !pedited->colorappearance.wbmodel) {
  904         wbmodel->set_active (3);
  905     } else if (pp->colorappearance.wbmodel == "RawT") {
  906         wbmodel->set_active (0);
  907     } else if (pp->colorappearance.wbmodel == "RawTCAT02") {
  908         wbmodel->set_active (1);
  909     } else if (pp->colorappearance.wbmodel == "free") {
  910         wbmodel->set_active (2);
  911     }
  912 
  913     wbmodelconn.block (false);
  914     // Have to be manually called to handle initial state update
  915     wbmodelChanged();
  916 
  917     algoconn.block (true);
  918 
  919     if (pedited && !pedited->colorappearance.algo) {
  920         algo->set_active (4);
  921     } else if (pp->colorappearance.algo == "JC") {
  922         algo->set_active (0);
  923     } else if (pp->colorappearance.algo == "JS") {
  924         algo->set_active (1);
  925     } else if (pp->colorappearance.algo == "QM") {
  926         algo->set_active (2);
  927     } else if (pp->colorappearance.algo == "ALL") {
  928         algo->set_active (3);
  929     }
  930 
  931     algoconn.block (false);
  932     // Have to be manually called to handle initial state update
  933     algoChanged();
  934 
  935     //  surrconn.block (true);
  936     //  surrsource->set_active (pp->colorappearance.surrsource);
  937     //  surrconn.block (false);
  938     gamutconn.block (true);
  939     gamut->set_active (pp->colorappearance.gamut);
  940     gamutconn.block (false);
  941 //  badpixconn.block (true);
  942 //  badpix->set_active (pp->colorappearance.badpix);
  943 //  badpixconn.block (false);
  944     datacieconn.block (true);
  945     datacie->set_active (pp->colorappearance.datacie);
  946     datacieconn.block (false);
  947     tonecieconn.block (true);
  948     tonecie->set_active (pp->colorappearance.tonecie);
  949     tonecieconn.block (false);
  950 //  sharpcieconn.block (true);
  951 //  sharpcie->set_active (pp->colorappearance.sharpcie);
  952 //  sharpcieconn.block (false);
  953 
  954 //   lastsurr = pp->colorappearance.surrsource;
  955     lastgamut = pp->colorappearance.gamut;
  956 //  lastbadpix=pp->colorappearance.badpix;
  957     lastdatacie = pp->colorappearance.datacie;
  958     lasttonecie = pp->colorappearance.tonecie;
  959 //  lastsharpcie=pp->colorappearance.sharpcie;
  960 
  961     lastAutoDegree = pp->colorappearance.autodegree;
  962     lastAutoAdapscen = pp->colorappearance.autoadapscen;
  963     lastAutoDegreeout = pp->colorappearance.autodegreeout;
  964     lastAutoybscen = pp->colorappearance.autoybscen;
  965 
  966     degree->setValue (pp->colorappearance.degree);
  967     degree->setAutoValue (pp->colorappearance.autodegree);
  968     adapscen->setValue (pp->colorappearance.adapscen);
  969     adapscen->setAutoValue (pp->colorappearance.autoadapscen);
  970     degreeout->setValue (pp->colorappearance.degreeout);
  971     degreeout->setAutoValue (pp->colorappearance.autodegreeout);
  972     ybscen->setValue (pp->colorappearance.ybscen);
  973     ybscen->setAutoValue (pp->colorappearance.autoybscen);
  974 
  975     adaplum->setValue (pp->colorappearance.adaplum);
  976     badpixsl->setValue (pp->colorappearance.badpixsl);
  977     jlight->setValue (pp->colorappearance.jlight);
  978     qbright->setValue (pp->colorappearance.qbright);
  979     chroma->setValue (pp->colorappearance.chroma);
  980     schroma->setValue (pp->colorappearance.schroma);
  981     mchroma->setValue (pp->colorappearance.mchroma);
  982     rstprotection->setValue (pp->colorappearance.rstprotection);
  983     contrast->setValue (pp->colorappearance.contrast);
  984     qcontrast->setValue (pp->colorappearance.qcontrast);
  985     colorh->setValue (pp->colorappearance.colorh);
  986     tempout->setValue (pp->colorappearance.tempout);
  987     greenout->setValue (pp->colorappearance.greenout);
  988     ybout->setValue (pp->colorappearance.ybout);
  989     tempsc->setValue (pp->colorappearance.tempsc);
  990     greensc->setValue (pp->colorappearance.greensc);
  991 
  992     tcmode3conn.block (false);
  993     tcmode2conn.block (false);
  994     tcmodeconn.block (false);
  995     enableListener ();
  996 }
  997 void ColorAppearance::autoOpenCurve  ()
  998 {
  999     shape->openIfNonlinear();
 1000     shape2->openIfNonlinear();
 1001     shape3->openIfNonlinear();
 1002 
 1003 }
 1004 
 1005 
 1006 void ColorAppearance::write (ProcParams* pp, ParamsEdited* pedited)
 1007 {
 1008 
 1009     pp->colorappearance.degree        = degree->getValue ();
 1010     pp->colorappearance.autodegree    = degree->getAutoValue ();
 1011     pp->colorappearance.degreeout        = degreeout->getValue ();
 1012     pp->colorappearance.autodegreeout    = degreeout->getAutoValue ();
 1013     pp->colorappearance.enabled       = getEnabled();
 1014     pp->colorappearance.adapscen      = adapscen->getValue ();
 1015     pp->colorappearance.autoadapscen  = adapscen->getAutoValue ();
 1016     pp->colorappearance.ybscen      = ybscen->getValue ();
 1017     pp->colorappearance.autoybscen  = ybscen->getAutoValue ();
 1018     pp->colorappearance.adaplum       = adaplum->getValue ();
 1019     pp->colorappearance.badpixsl      = badpixsl->getValue ();
 1020     pp->colorappearance.jlight        = jlight->getValue ();
 1021     pp->colorappearance.qbright       = qbright->getValue ();
 1022     pp->colorappearance.chroma        = chroma->getValue ();
 1023     pp->colorappearance.schroma       = schroma->getValue ();
 1024     pp->colorappearance.mchroma       = mchroma->getValue ();
 1025     pp->colorappearance.contrast      = contrast->getValue ();
 1026     pp->colorappearance.qcontrast     = qcontrast->getValue ();
 1027     pp->colorappearance.colorh        = colorh->getValue ();
 1028     pp->colorappearance.rstprotection = rstprotection->getValue ();
 1029     //  pp->colorappearance.surrsource    = surrsource->get_active();
 1030     pp->colorappearance.gamut         = gamut->get_active();
 1031 //  pp->colorappearance.badpix        = badpix->get_active();
 1032     pp->colorappearance.datacie       = datacie->get_active();
 1033     pp->colorappearance.tonecie       = tonecie->get_active();
 1034 //  pp->colorappearance.sharpcie      = sharpcie->get_active();
 1035     pp->colorappearance.curve         = shape->getCurve ();
 1036     pp->colorappearance.curve2        = shape2->getCurve ();
 1037     pp->colorappearance.curve3        = shape3->getCurve ();
 1038     pp->colorappearance.tempout        = tempout->getValue ();
 1039     pp->colorappearance.greenout        = greenout->getValue ();
 1040     pp->colorappearance.ybout        = ybout->getValue ();
 1041     pp->colorappearance.tempsc        = tempsc->getValue ();
 1042     pp->colorappearance.greensc        = greensc->getValue ();
 1043 
 1044     int tcMode = toneCurveMode->get_active_row_number();
 1045 
 1046     if      (tcMode == 0) {
 1047         pp->colorappearance.curveMode = ColorAppearanceParams::TcMode::LIGHT;
 1048     } else if (tcMode == 1) {
 1049         pp->colorappearance.curveMode = ColorAppearanceParams::TcMode::BRIGHT;
 1050     }
 1051 
 1052     tcMode = toneCurveMode2->get_active_row_number();
 1053 
 1054     if      (tcMode == 0) {
 1055         pp->colorappearance.curveMode2 = ColorAppearanceParams::TcMode::LIGHT;
 1056     } else if (tcMode == 1) {
 1057         pp->colorappearance.curveMode2 = ColorAppearanceParams::TcMode::BRIGHT;
 1058     }
 1059 
 1060     int tcMode3 = toneCurveMode3->get_active_row_number();
 1061 
 1062     if      (tcMode3 == 0) {
 1063         pp->colorappearance.curveMode3 = ColorAppearanceParams::CtcMode::CHROMA;
 1064     } else if (tcMode3 == 1) {
 1065         pp->colorappearance.curveMode3 = ColorAppearanceParams::CtcMode::SATUR;
 1066     } else if (tcMode3 == 2) {
 1067         pp->colorappearance.curveMode3 = ColorAppearanceParams::CtcMode::COLORF;
 1068     }
 1069 
 1070     if (pedited) {
 1071         pedited->colorappearance.degree        = degree->getEditedState ();
 1072         pedited->colorappearance.degreeout        = degreeout->getEditedState ();
 1073         pedited->colorappearance.adapscen      = adapscen->getEditedState ();
 1074         pedited->colorappearance.adaplum       = adaplum->getEditedState ();
 1075         pedited->colorappearance.ybscen      = ybscen->getEditedState ();
 1076         pedited->colorappearance.badpixsl      = badpixsl->getEditedState ();
 1077         pedited->colorappearance.jlight        = jlight->getEditedState ();
 1078         pedited->colorappearance.qbright       = qbright->getEditedState ();
 1079         pedited->colorappearance.chroma        = chroma->getEditedState ();
 1080         pedited->colorappearance.schroma       = schroma->getEditedState ();
 1081         pedited->colorappearance.mchroma       = mchroma->getEditedState ();
 1082         pedited->colorappearance.contrast      = contrast->getEditedState ();
 1083         pedited->colorappearance.qcontrast     = qcontrast->getEditedState ();
 1084         pedited->colorappearance.colorh        = colorh->getEditedState ();
 1085         pedited->colorappearance.rstprotection = rstprotection->getEditedState ();
 1086         pedited->colorappearance.autodegree    = !degree->getAutoInconsistent();
 1087         pedited->colorappearance.autodegreeout    = !degreeout->getAutoInconsistent();
 1088         pedited->colorappearance.autoadapscen  = !adapscen->getAutoInconsistent();
 1089         pedited->colorappearance.autoybscen  = !ybscen->getAutoInconsistent();
 1090         pedited->colorappearance.enabled       = !get_inconsistent();
 1091         pedited->colorappearance.surround      = surround->get_active_text() != M ("GENERAL_UNCHANGED");
 1092         pedited->colorappearance.surrsrc      = surrsrc->get_active_text() != M ("GENERAL_UNCHANGED");
 1093         pedited->colorappearance.wbmodel       = wbmodel->get_active_text() != M ("GENERAL_UNCHANGED");
 1094         pedited->colorappearance.algo          = algo->get_active_text() != M ("GENERAL_UNCHANGED");
 1095         //     pedited->colorappearance.surrsource    = !surrsource->get_inconsistent();
 1096         pedited->colorappearance.gamut         = !gamut->get_inconsistent();
 1097         //  pedited->colorappearance.badpix        = !badpix->get_inconsistent();
 1098         pedited->colorappearance.datacie       = !datacie->get_inconsistent();
 1099         pedited->colorappearance.tonecie       = !tonecie->get_inconsistent();
 1100         //  pedited->colorappearance.sharpcie      = !sharpcie->get_inconsistent();
 1101         pedited->colorappearance.curve         = !shape->isUnChanged ();
 1102         pedited->colorappearance.curve2        = !shape2->isUnChanged ();
 1103         pedited->colorappearance.curve3        = !shape3->isUnChanged ();
 1104         pedited->colorappearance.curveMode     = toneCurveMode->get_active_row_number() != 2;
 1105         pedited->colorappearance.curveMode2    = toneCurveMode2->get_active_row_number() != 2;
 1106         pedited->colorappearance.curveMode3    = toneCurveMode3->get_active_row_number() != 3;
 1107         pedited->colorappearance.tempout        = tempout->getEditedState ();
 1108         pedited->colorappearance.greenout        = greenout->getEditedState ();
 1109         pedited->colorappearance.ybout        = ybout->getEditedState ();
 1110         pedited->colorappearance.tempsc        = tempsc->getEditedState ();
 1111         pedited->colorappearance.greensc        = greensc->getEditedState ();
 1112 
 1113     }
 1114 
 1115     if (surrsrc->get_active_row_number() == 0) {
 1116         pp->colorappearance.surrsrc = "Average";
 1117     } else if (surrsrc->get_active_row_number() == 1) {
 1118         pp->colorappearance.surrsrc = "Dim";
 1119     } else if (surrsrc->get_active_row_number() == 2) {
 1120         pp->colorappearance.surrsrc = "Dark";
 1121     } else if (surrsrc->get_active_row_number() == 3) {
 1122         pp->colorappearance.surrsrc = "ExtremelyDark";
 1123     }
 1124 
 1125 
 1126     if (surround->get_active_row_number() == 0) {
 1127         pp->colorappearance.surround = "Average";
 1128     } else if (surround->get_active_row_number() == 1) {
 1129         pp->colorappearance.surround = "Dim";
 1130     } else if (surround->get_active_row_number() == 2) {
 1131         pp->colorappearance.surround = "Dark";
 1132     } else if (surround->get_active_row_number() == 3) {
 1133         pp->colorappearance.surround = "ExtremelyDark";
 1134     }
 1135 
 1136     if (wbmodel->get_active_row_number() == 0) {
 1137         pp->colorappearance.wbmodel = "RawT";
 1138     } else if (wbmodel->get_active_row_number() == 1) {
 1139         pp->colorappearance.wbmodel = "RawTCAT02";
 1140     } else if (wbmodel->get_active_row_number() == 2) {
 1141         pp->colorappearance.wbmodel = "free";
 1142 
 1143     }
 1144 
 1145     if (algo->get_active_row_number() == 0) {
 1146         pp->colorappearance.algo = "JC";
 1147     } else if (algo->get_active_row_number() == 1) {
 1148         pp->colorappearance.algo = "JS";
 1149     } else if (algo->get_active_row_number() == 2) {
 1150         pp->colorappearance.algo = "QM";
 1151     } else if (algo->get_active_row_number() == 3) {
 1152         pp->colorappearance.algo = "ALL";
 1153     }
 1154 
 1155 }
 1156 void ColorAppearance::curveChanged (CurveEditor* ce)
 1157 {
 1158 
 1159     if (listener) {
 1160         if (ce == shape) {
 1161             listener->panelChanged (EvCATCurve1, M ("HISTORY_CUSTOMCURVE"));
 1162         } else if (ce == shape2) {
 1163             listener->panelChanged (EvCATCurve2, M ("HISTORY_CUSTOMCURVE"));
 1164         } else if (ce == shape3) {
 1165             listener->panelChanged (EvCATCurve3, M ("HISTORY_CUSTOMCURVE"));
 1166         }
 1167     }
 1168 }
 1169 
 1170 void ColorAppearance::curveMode1Changed ()
 1171 {
 1172     if (listener) {
 1173         Glib::signal_idle().connect (sigc::mem_fun (*this, &ColorAppearance::curveMode1Changed_));
 1174     }
 1175 }
 1176 
 1177 bool ColorAppearance::curveMode1Changed_ ()
 1178 {
 1179     if (listener) {
 1180         listener->panelChanged (EvCATCurveMode1, toneCurveMode->get_active_text());
 1181     }
 1182 
 1183     return false;
 1184 }
 1185 
 1186 void ColorAppearance::curveMode2Changed ()
 1187 {
 1188     if (listener) {
 1189         Glib::signal_idle().connect (sigc::mem_fun (*this, &ColorAppearance::curveMode2Changed_));
 1190     }
 1191 }
 1192 
 1193 bool ColorAppearance::curveMode2Changed_ ()
 1194 {
 1195     if (listener) {
 1196         listener->panelChanged (EvCATCurveMode2, toneCurveMode2->get_active_text());
 1197     }
 1198 
 1199     return false;
 1200 }
 1201 
 1202 void ColorAppearance::curveMode3Changed ()
 1203 {
 1204     int tcMode3 = toneCurveMode3->get_active_row_number();
 1205 
 1206     if      (tcMode3 == 0) {
 1207         chroma->set_sensitive (true);
 1208         schroma->set_sensitive (true);
 1209     } else if (tcMode3 == 2) {
 1210         chroma->set_sensitive (false);
 1211         schroma->set_sensitive (false);
 1212     } else if (tcMode3 == 1) {
 1213         chroma->set_sensitive (false);
 1214         schroma->set_sensitive (true);
 1215     }
 1216 
 1217     if (listener) {
 1218         Glib::signal_idle().connect (sigc::mem_fun (*this, &ColorAppearance::curveMode3Changed_));
 1219     }
 1220 }
 1221 
 1222 bool ColorAppearance::curveMode3Changed_ ()
 1223 {
 1224     if (listener) {
 1225         listener->panelChanged (EvCATCurveMode3, toneCurveMode3->get_active_text());
 1226     }
 1227 
 1228     return false;
 1229 }
 1230 /*
 1231 void ColorAppearance::surrsource_toggled ()
 1232 {
 1233 
 1234     if (batchMode) {
 1235         if (surrsource->get_inconsistent()) {
 1236             surrsource->set_inconsistent (false);
 1237             surrconn.block (true);
 1238             surrsource->set_active (false);
 1239             surrconn.block (false);
 1240         } else if (lastsurr) {
 1241             surrsource->set_inconsistent (true);
 1242         }
 1243 
 1244         lastsurr = surrsource->get_active ();
 1245     }
 1246 
 1247     if (listener) {
 1248         if (surrsource->get_active ()) {
 1249             listener->panelChanged (EvCATsurr, M ("GENERAL_ENABLED"));
 1250         } else {
 1251             listener->panelChanged (EvCATsurr, M ("GENERAL_DISABLED"));
 1252         }
 1253     }
 1254 }
 1255 */
 1256 void ColorAppearance::gamut_toggled ()
 1257 {
 1258 
 1259     if (batchMode) {
 1260         if (gamut->get_inconsistent()) {
 1261             gamut->set_inconsistent (false);
 1262             gamutconn.block (true);
 1263             gamut->set_active (false);
 1264             gamutconn.block (false);
 1265         } else if (lastgamut) {
 1266             gamut->set_inconsistent (true);
 1267         }
 1268 
 1269         lastgamut = gamut->get_active ();
 1270     }
 1271 
 1272     if (listener) {
 1273         if (gamut->get_active ()) {
 1274             listener->panelChanged (EvCATgamut, M ("GENERAL_ENABLED"));
 1275         } else {
 1276             listener->panelChanged (EvCATgamut, M ("GENERAL_DISABLED"));
 1277         }
 1278     }
 1279 
 1280 
 1281 }
 1282 /*
 1283 void ColorAppearance::badpix_toggled () {
 1284 
 1285     if (batchMode) {
 1286         if (badpix->get_inconsistent()) {
 1287             badpix->set_inconsistent (false);
 1288             badpixconn.block (true);
 1289             badpix->set_active (false);
 1290             badpixconn.block (false);
 1291         }
 1292         else if (lastbadpix)
 1293             badpix->set_inconsistent (true);
 1294 
 1295         lastbadpix = badpix->get_active ();
 1296     }
 1297     if (listener) {
 1298         if (badpix->get_active ())
 1299             listener->panelChanged (EvCATbadpix, M("GENERAL_ENABLED"));
 1300         else
 1301             listener->panelChanged (EvCATbadpix, M("GENERAL_DISABLED"));
 1302     }
 1303 
 1304 
 1305 }
 1306 */
 1307 void ColorAppearance::datacie_toggled ()
 1308 {
 1309 
 1310     if (batchMode) {
 1311         if (datacie->get_inconsistent()) {
 1312             datacie->set_inconsistent (false);
 1313             datacieconn.block (true);
 1314             datacie->set_active (false);
 1315             datacieconn.block (false);
 1316         } else if (lastdatacie) {
 1317             datacie->set_inconsistent (true);
 1318         }
 1319 
 1320         lastdatacie = datacie->get_active ();
 1321     }
 1322 
 1323     if (listener) {
 1324         if (datacie->get_active ()) {
 1325             listener->panelChanged (EvCATdatacie, M ("GENERAL_ENABLED"));
 1326         } else {
 1327             listener->panelChanged (EvCATdatacie, M ("GENERAL_DISABLED"));
 1328         }
 1329     }
 1330 }
 1331 void ColorAppearance::tonecie_toggled ()
 1332 {
 1333 
 1334     if (batchMode) {
 1335         if (tonecie->get_inconsistent()) {
 1336             tonecie->set_inconsistent (false);
 1337             tonecieconn.block (true);
 1338             tonecie->set_active (false);
 1339             tonecieconn.block (false);
 1340         } else if (lasttonecie) {
 1341             tonecie->set_inconsistent (true);
 1342         }
 1343 
 1344         lasttonecie = tonecie->get_active ();
 1345     }
 1346 
 1347     if (listener) {
 1348         if (tonecie->get_active ()) {
 1349             listener->panelChanged (EvCATtonecie, M ("GENERAL_ENABLED"));
 1350         } else {
 1351             listener->panelChanged (EvCATtonecie, M ("GENERAL_DISABLED"));
 1352         }
 1353     }
 1354 
 1355 }
 1356 /*
 1357 void ColorAppearance::sharpcie_toggled () {
 1358 
 1359     if (batchMode) {
 1360         if (sharpcie->get_inconsistent()) {
 1361             sharpcie->set_inconsistent (false);
 1362             sharpcieconn.block (true);
 1363             sharpcie->set_active (false);
 1364             sharpcieconn.block (false);
 1365         }
 1366         else if (lastsharpcie)
 1367             sharpcie->set_inconsistent (true);
 1368 
 1369         lastsharpcie = sharpcie->get_active ();
 1370     }
 1371     if (listener) {
 1372         if (sharpcie->get_active ())
 1373             listener->panelChanged (EvCATsharpcie, M("GENERAL_ENABLED"));
 1374         else
 1375             listener->panelChanged (EvCATsharpcie, M("GENERAL_DISABLED"));
 1376     }
 1377 
 1378 }
 1379 */
 1380 
 1381 void ColorAppearance::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited)
 1382 {
 1383 
 1384     degree->setDefault (defParams->colorappearance.degree);
 1385     degreeout->setDefault (defParams->colorappearance.degreeout);
 1386     adapscen->setDefault (defParams->colorappearance.adapscen);
 1387     ybscen->setDefault (defParams->colorappearance.ybscen);
 1388     adaplum->setDefault (defParams->colorappearance.adaplum);
 1389     badpixsl->setDefault (defParams->colorappearance.badpixsl);
 1390     jlight->setDefault (defParams->colorappearance.jlight);
 1391     qbright->setDefault (defParams->colorappearance.qbright);
 1392     chroma->setDefault (defParams->colorappearance.chroma);
 1393     schroma->setDefault (defParams->colorappearance.schroma);
 1394     mchroma->setDefault (defParams->colorappearance.mchroma);
 1395     rstprotection->setDefault (defParams->colorappearance.rstprotection);
 1396     contrast->setDefault (defParams->colorappearance.contrast);
 1397     qcontrast->setDefault (defParams->colorappearance.qcontrast);
 1398     colorh->setDefault (defParams->colorappearance.colorh);
 1399     tempout->setDefault (defParams->colorappearance.tempout);
 1400     greenout->setDefault (defParams->colorappearance.greenout);
 1401     ybout->setDefault (defParams->colorappearance.ybout);
 1402     tempsc->setDefault (defParams->colorappearance.tempsc);
 1403     greensc->setDefault (defParams->colorappearance.greensc);
 1404 
 1405     if (pedited) {
 1406         degree->setDefaultEditedState (pedited->colorappearance.degree ? Edited : UnEdited);
 1407         degreeout->setDefaultEditedState (pedited->colorappearance.degreeout ? Edited : UnEdited);
 1408         adapscen->setDefaultEditedState (pedited->colorappearance.adapscen ? Edited : UnEdited);
 1409         ybscen->setDefaultEditedState (pedited->colorappearance.ybscen ? Edited : UnEdited);
 1410         adaplum->setDefaultEditedState (pedited->colorappearance.adaplum ? Edited : UnEdited);
 1411         badpixsl->setDefaultEditedState (pedited->colorappearance.badpixsl ? Edited : UnEdited);
 1412         jlight->setDefaultEditedState (pedited->colorappearance.jlight ? Edited : UnEdited);
 1413         qbright->setDefaultEditedState (pedited->colorappearance.qbright ? Edited : UnEdited);
 1414         chroma->setDefaultEditedState (pedited->colorappearance.chroma ? Edited : UnEdited);
 1415         schroma->setDefaultEditedState (pedited->colorappearance.schroma ? Edited : UnEdited);
 1416         mchroma->setDefaultEditedState (pedited->colorappearance.mchroma ? Edited : UnEdited);
 1417         rstprotection->setDefaultEditedState (pedited->colorappearance.rstprotection ? Edited : UnEdited);
 1418         contrast->setDefaultEditedState (pedited->colorappearance.contrast ? Edited : UnEdited);
 1419         qcontrast->setDefaultEditedState (pedited->colorappearance.qcontrast ? Edited : UnEdited);
 1420         colorh->setDefaultEditedState (pedited->colorappearance.colorh ? Edited : UnEdited);
 1421         tempout->setDefaultEditedState (pedited->colorappearance.tempout ? Edited : UnEdited);
 1422         greenout->setDefaultEditedState (pedited->colorappearance.greenout ? Edited : UnEdited);
 1423         ybout->setDefaultEditedState (pedited->colorappearance.ybout ? Edited : UnEdited);
 1424         tempsc->setDefaultEditedState (pedited->colorappearance.tempsc ? Edited : UnEdited);
 1425         greensc->setDefaultEditedState (pedited->colorappearance.greensc ? Edited : UnEdited);
 1426 
 1427     } else {
 1428         degree->setDefaultEditedState (Irrelevant);
 1429         degreeout->setDefaultEditedState (Irrelevant);
 1430         adapscen->setDefaultEditedState (Irrelevant);
 1431         ybscen->setDefaultEditedState (Irrelevant);
 1432         adaplum->setDefaultEditedState (Irrelevant);
 1433         badpixsl->setDefaultEditedState (Irrelevant);
 1434         jlight->setDefaultEditedState (Irrelevant);
 1435         qbright->setDefaultEditedState (Irrelevant);
 1436         chroma->setDefaultEditedState (Irrelevant);
 1437         schroma->setDefaultEditedState (Irrelevant);
 1438         mchroma->setDefaultEditedState (Irrelevant);
 1439         contrast->setDefaultEditedState (Irrelevant);
 1440         qcontrast->setDefaultEditedState (Irrelevant);
 1441         rstprotection->setDefaultEditedState (Irrelevant);
 1442         colorh->setDefaultEditedState (Irrelevant);
 1443         tempout->setDefaultEditedState (Irrelevant);
 1444         greenout->setDefaultEditedState (Irrelevant);
 1445         ybout->setDefaultEditedState (Irrelevant);
 1446         tempsc->setDefaultEditedState (Irrelevant);
 1447         greensc->setDefaultEditedState (Irrelevant);
 1448 
 1449     }
 1450 }
 1451 
 1452 void ColorAppearance::autoCamChanged (double ccam, double ccamout)
 1453 {
 1454     idle_register.add(
 1455         [this, ccam, ccamout]() -> bool
 1456         {
 1457             disableListener();
 1458             degree->setValue(ccam);
 1459             degreeout->setValue(ccamout);
 1460             enableListener();
 1461             return false;
 1462         }
 1463     );
 1464 }
 1465 
 1466 void ColorAppearance::adapCamChanged (double cadap)
 1467 {
 1468     idle_register.add(
 1469         [this, cadap]() -> bool
 1470         {
 1471             disableListener();
 1472             adapscen->setValue(cadap);
 1473             enableListener();
 1474             return false;
 1475         }
 1476     );
 1477 }
 1478 
 1479 void ColorAppearance::ybCamChanged (int ybsc)
 1480 {
 1481     idle_register.add(
 1482         [this, ybsc]() -> bool
 1483         {
 1484             disableListener();
 1485             ybscen->setValue(ybsc);
 1486             enableListener();
 1487             return false;
 1488         }
 1489     );
 1490 }
 1491 
 1492 void ColorAppearance::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller)
 1493 {
 1494 
 1495     float R = 0.f, G = 0.f, B = 0.f;
 1496 
 1497     if (elemType == ColorCaller::CCET_VERTICAL_BAR) {
 1498         valY = 0.5;
 1499     }
 1500 
 1501     if (callerId == 1) {    // cc - bottom bar
 1502 
 1503         float value = (1.f - 0.7f) * float (valX) + 0.7f;
 1504         // whole hue range
 1505         // Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before)
 1506         Color::hsv2rgb01 (float (valY*0.8), float (valX), value, R, G, B);
 1507     }
 1508 
 1509     caller->ccRed = double (R);
 1510     caller->ccGreen = double (G);
 1511     caller->ccBlue = double (B);
 1512 }
 1513 
 1514 void ColorAppearance::adjusterChanged(Adjuster* a, double newval)
 1515 {
 1516     if (listener && (multiImage || getEnabled()) ) {
 1517         if (a == degree) {
 1518             listener->panelChanged (EvCATDegree, a->getTextValue());
 1519         } else if (a == degreeout) {
 1520             listener->panelChanged (EvCATDegreeout, a->getTextValue());
 1521         } else if (a == adapscen) {
 1522             listener->panelChanged (EvCATAdapscen, a->getTextValue());
 1523         } else if (a == ybscen) {
 1524             listener->panelChanged (EvCATybscen, a->getTextValue());
 1525         } else if (a == adaplum) {
 1526             listener->panelChanged (EvCATAdapLum, a->getTextValue());
 1527         } else if (a == badpixsl) {
 1528             listener->panelChanged (EvCATbadpix, a->getTextValue());
 1529         } else if (a == jlight) {
 1530             listener->panelChanged (EvCATJLight, a->getTextValue());
 1531         } else if (a == qbright) {
 1532             listener->panelChanged (EvCATQbright, a->getTextValue());
 1533         } else if (a == chroma) {
 1534             listener->panelChanged (EvCATChroma, a->getTextValue());
 1535         } else if (a == schroma) {
 1536             listener->panelChanged (EvCATSChroma, a->getTextValue());
 1537         } else if (a == mchroma) {
 1538             listener->panelChanged (EvCATMChroma, a->getTextValue());
 1539         } else if (a == rstprotection) {
 1540             listener->panelChanged (EvCATRstpro, a->getTextValue());
 1541         } else if (a == contrast) {
 1542             listener->panelChanged (EvCATContrast, a->getTextValue());
 1543         } else if (a == colorh) {
 1544             listener->panelChanged (EvCAThue, a->getTextValue());
 1545         } else if (a == qcontrast) {
 1546             listener->panelChanged (EvCATQContrast, a->getTextValue());
 1547         } else if (a == tempout) {
 1548             listener->panelChanged (EvCATtempout, a->getTextValue());
 1549         } else if (a == greenout) {
 1550             listener->panelChanged (EvCATgreenout, a->getTextValue());
 1551         } else if (a == ybout) {
 1552             listener->panelChanged (EvCATybout, a->getTextValue());
 1553         } else if (a == tempsc) {
 1554             listener->panelChanged (EvCATtempsc, a->getTextValue());
 1555         } else if (a == greensc) {
 1556             listener->panelChanged (EvCATgreensc, a->getTextValue());
 1557 
 1558         }
 1559 
 1560     }
 1561 }
 1562 
 1563 void ColorAppearance::adjusterAutoToggled(Adjuster* a, bool newval)
 1564 {
 1565     if (multiImage) {
 1566         if (degree->getAutoInconsistent()) {
 1567             degree->setAutoInconsistent (false);
 1568             degree->setAutoValue (false);
 1569         } else if (lastAutoDegree) {
 1570             degree->setAutoInconsistent (true);
 1571         }
 1572 
 1573         lastAutoDegree = degree->getAutoValue();
 1574 
 1575         if (degreeout->getAutoInconsistent()) {
 1576             degreeout->setAutoInconsistent (false);
 1577             degreeout->setAutoValue (false);
 1578         } else if (lastAutoDegreeout) {
 1579             degreeout->setAutoInconsistent (true);
 1580         }
 1581 
 1582         lastAutoDegreeout = degreeout->getAutoValue();
 1583 
 1584         if (adapscen->getAutoInconsistent()) {
 1585             adapscen->setAutoInconsistent (false);
 1586             adapscen->setAutoValue (false);
 1587         } else if (lastAutoAdapscen) {
 1588             adapscen->setAutoInconsistent (true);
 1589         }
 1590 
 1591         lastAutoAdapscen = adapscen->getAutoValue();
 1592 
 1593         if (ybscen->getAutoInconsistent()) {
 1594             ybscen->setAutoInconsistent (false);
 1595             ybscen->setAutoValue (false);
 1596         } else if (lastAutoybscen) {
 1597             ybscen->setAutoInconsistent (true);
 1598         }
 1599 
 1600         lastAutoybscen = ybscen->getAutoValue();
 1601 
 1602     }
 1603 
 1604     if (listener && (multiImage || getEnabled()) ) {
 1605 
 1606         if (a == degree) {
 1607             if (degree->getAutoInconsistent()) {
 1608                 listener->panelChanged (EvCATAutoDegree, M ("GENERAL_UNCHANGED"));
 1609             } else if (degree->getAutoValue()) {
 1610                 listener->panelChanged (EvCATAutoDegree, M ("GENERAL_ENABLED"));
 1611             } else {
 1612                 listener->panelChanged (EvCATAutoDegree, M ("GENERAL_DISABLED"));
 1613             }
 1614         }
 1615 
 1616         if (a == degreeout) {
 1617             if (degreeout->getAutoInconsistent()) {
 1618                 listener->panelChanged (EvCATAutoDegreeout, M ("GENERAL_UNCHANGED"));
 1619             } else if (degreeout->getAutoValue()) {
 1620                 listener->panelChanged (EvCATAutoDegreeout, M ("GENERAL_ENABLED"));
 1621             } else {
 1622                 listener->panelChanged (EvCATAutoDegreeout, M ("GENERAL_DISABLED"));
 1623             }
 1624         }
 1625 
 1626 
 1627         if (a == adapscen) {
 1628             if (adapscen->getAutoInconsistent()) {
 1629                 listener->panelChanged (EvCATAutoAdap, M ("GENERAL_UNCHANGED"));
 1630             } else if (adapscen->getAutoValue()) {
 1631                 listener->panelChanged (EvCATAutoAdap, M ("GENERAL_ENABLED"));
 1632             } else {
 1633                 listener->panelChanged (EvCATAutoAdap, M ("GENERAL_DISABLED"));
 1634             }
 1635         }
 1636 
 1637         if (a == ybscen) {
 1638             if (ybscen->getAutoInconsistent()) {
 1639                 listener->panelChanged (EvCATAutoyb, M ("GENERAL_UNCHANGED"));
 1640             } else if (ybscen->getAutoValue()) {
 1641                 listener->panelChanged (EvCATAutoyb, M ("GENERAL_ENABLED"));
 1642             } else {
 1643                 listener->panelChanged (EvCATAutoyb, M ("GENERAL_DISABLED"));
 1644             }
 1645         }
 1646 
 1647 
 1648     }
 1649 }
 1650 void ColorAppearance::enabledChanged ()
 1651 {
 1652 
 1653     if (listener) {
 1654         if (get_inconsistent()) {
 1655             listener->panelChanged (EvCATEnabled, M ("GENERAL_UNCHANGED"));
 1656         } else if (getEnabled()) {
 1657             listener->panelChanged (EvCATEnabled, M ("GENERAL_ENABLED"));
 1658             curveEditorG->set_sensitive (true);
 1659             toneCurveMode->set_sensitive (true);
 1660         } else {
 1661             listener->panelChanged (EvCATEnabled, M ("GENERAL_DISABLED"));
 1662         }
 1663     }
 1664 }
 1665 
 1666 void ColorAppearance::surrsrcChanged ()
 1667 {
 1668 
 1669     if (listener && (multiImage || getEnabled()) ) {
 1670         listener->panelChanged (EvCATsurr, surrsrc->get_active_text ());
 1671     }
 1672 }
 1673 
 1674 
 1675 void ColorAppearance::surroundChanged ()
 1676 {
 1677 
 1678     if (listener && (multiImage || getEnabled()) ) {
 1679         listener->panelChanged (EvCATMethodsur, surround->get_active_text ());
 1680     }
 1681 }
 1682 
 1683 void ColorAppearance::wbmodelChanged ()
 1684 {
 1685     if (wbmodel->get_active_row_number() == 0 || wbmodel->get_active_row_number() == 1) {
 1686         tempsc->hide();
 1687         greensc->hide();
 1688     }
 1689 
 1690     if (wbmodel->get_active_row_number() == 2) {
 1691         tempsc->show();
 1692         greensc->show();
 1693     }
 1694 
 1695     if (listener && (multiImage || getEnabled()) ) {
 1696         listener->panelChanged (EvCATMethodWB, wbmodel->get_active_text ());
 1697     }
 1698 }
 1699 
 1700 
 1701 void ColorAppearance::algoChanged ()
 1702 {
 1703 
 1704     if ( algo->get_active_row_number() == 0 ) {
 1705         contrast->show();
 1706         rstprotection->show();
 1707         qcontrast->hide();
 1708         jlight->show();
 1709         mchroma->hide();
 1710         chroma->show();
 1711         schroma->hide();
 1712         qbright->hide();
 1713         colorh->hide();
 1714         tonecie->hide();
 1715         //  sharpcie->hide();
 1716         curveEditorG->show();
 1717         curveEditorG2->show();
 1718         curveEditorG3->show();
 1719     } else if ( algo->get_active_row_number() == 1 ) {
 1720         rstprotection->show();
 1721         contrast->show();
 1722         qcontrast->hide();
 1723         jlight->show();
 1724         mchroma->hide();
 1725         chroma->hide();
 1726         schroma->show();
 1727         qbright->hide();
 1728         colorh->hide();
 1729         tonecie->hide();
 1730 //      sharpcie->hide();
 1731         curveEditorG->show();
 1732         curveEditorG2->show();
 1733         curveEditorG3->show();
 1734     } else if ( algo->get_active_row_number() == 2 ) {
 1735         contrast->hide();
 1736         rstprotection->show();
 1737         qcontrast->show();
 1738         jlight->hide();
 1739         mchroma->show();
 1740         chroma->hide();
 1741         schroma->hide();
 1742         qbright->show();
 1743         colorh->hide();
 1744         tonecie->show();
 1745         //  sharpcie->show();
 1746         //  sharpcie->hide();
 1747         curveEditorG->show();
 1748         curveEditorG2->show();
 1749         curveEditorG3->show();
 1750     } else if ( algo->get_active_row_number() >= 3 ) { // ">=3" because everything has to be visible with the "(unchanged)" option too
 1751         contrast->show();
 1752         rstprotection->show();
 1753         qcontrast->show();
 1754         jlight->show();
 1755         mchroma->show();
 1756         chroma->show();
 1757         schroma->show();
 1758         qbright->show();
 1759         colorh->show();
 1760         tonecie->show();
 1761 //      sharpcie->show();
 1762 //      sharpcie->hide();
 1763         curveEditorG->show();
 1764         curveEditorG2->show();
 1765         curveEditorG3->show();
 1766     }
 1767 
 1768     if (listener && (multiImage || getEnabled()) ) {
 1769         listener->panelChanged (EvCATMethodalg, algo->get_active_text ());
 1770     }
 1771 }
 1772 
 1773 void ColorAppearance::setBatchMode (bool batchMode)
 1774 {
 1775 
 1776     ToolPanel::setBatchMode (batchMode);
 1777 
 1778     degree->showEditedCB ();
 1779     degreeout->showEditedCB ();
 1780     adapscen->showEditedCB ();
 1781     adaplum->showEditedCB ();
 1782     ybscen->showEditedCB ();
 1783     badpixsl->showEditedCB ();
 1784     jlight->showEditedCB ();
 1785     qbright->showEditedCB ();
 1786     chroma->showEditedCB ();
 1787     schroma->showEditedCB ();
 1788     mchroma->showEditedCB ();
 1789     rstprotection->showEditedCB ();
 1790     contrast->showEditedCB ();
 1791     qcontrast->showEditedCB ();
 1792     colorh->showEditedCB ();
 1793     tempout->showEditedCB ();
 1794     greenout->showEditedCB ();
 1795     ybout->showEditedCB ();
 1796     tempsc->showEditedCB ();
 1797     greensc->showEditedCB ();
 1798 
 1799     surround->append (M ("GENERAL_UNCHANGED"));
 1800     surrsrc->append (M ("GENERAL_UNCHANGED"));
 1801     wbmodel->append (M ("GENERAL_UNCHANGED"));
 1802     algo->append (M ("GENERAL_UNCHANGED"));
 1803     toneCurveMode->append (M ("GENERAL_UNCHANGED"));
 1804     toneCurveMode2->append (M ("GENERAL_UNCHANGED"));
 1805     toneCurveMode3->append (M ("GENERAL_UNCHANGED"));
 1806 
 1807     curveEditorG->setBatchMode (batchMode);
 1808     curveEditorG2->setBatchMode (batchMode);
 1809     curveEditorG3->setBatchMode (batchMode);
 1810 }
 1811 
 1812 void ColorAppearance::updateCurveBackgroundHistogram(
 1813     const LUTu& histToneCurve,
 1814     const LUTu& histLCurve,
 1815     const LUTu& histCCurve,
 1816     const LUTu& histLCAM,
 1817     const LUTu& histCCAM,
 1818     const LUTu& histRed,
 1819     const LUTu& histGreen,
 1820     const LUTu& histBlue,
 1821     const LUTu& histLuma,
 1822     const LUTu& histLRETI
 1823 )
 1824 {
 1825     shape->updateBackgroundHistogram(histLCAM);
 1826     shape3->updateBackgroundHistogram(histCCAM);
 1827 }
 1828 
 1829 
 1830 
 1831 void ColorAppearance::setAdjusterBehavior (bool degreeadd, bool adapscenadd, bool adaplumadd, bool badpixsladd, bool jlightadd, bool chromaadd, bool contrastadd, bool rstprotectionadd, bool qbrightadd, bool qcontrastadd, bool schromaadd, bool mchromaadd, bool colorhadd)
 1832 {
 1833 
 1834     degree->setAddMode (degreeadd);
 1835     adapscen->setAddMode (adapscenadd);
 1836     adaplum->setAddMode (adaplumadd);
 1837     badpixsl->setAddMode (badpixsladd);
 1838     jlight->setAddMode (jlightadd);
 1839     qbright->setAddMode (qbrightadd);
 1840     chroma->setAddMode (chromaadd);
 1841     schroma->setAddMode (schromaadd);
 1842     mchroma->setAddMode (mchromaadd);
 1843     rstprotection->setAddMode (rstprotectionadd);
 1844     contrast->setAddMode (contrastadd);
 1845     qcontrast->setAddMode (qcontrastadd);
 1846     colorh->setAddMode (colorhadd);
 1847 }
 1848 
 1849 void ColorAppearance::trimValues (rtengine::procparams::ProcParams* pp)
 1850 {
 1851 
 1852     degree->trimValue (pp->colorappearance.degree);
 1853     degreeout->trimValue (pp->colorappearance.degreeout);
 1854     adapscen->trimValue (pp->colorappearance.adapscen);
 1855     ybscen->trimValue (pp->colorappearance.ybscen);
 1856     adaplum->trimValue (pp->colorappearance.adaplum);
 1857     badpixsl->trimValue (pp->colorappearance.badpixsl);
 1858     jlight->trimValue (pp->colorappearance.jlight);
 1859     qbright->trimValue (pp->colorappearance.qbright);
 1860     chroma->trimValue (pp->colorappearance.chroma);
 1861     schroma->trimValue (pp->colorappearance.schroma);
 1862     mchroma->trimValue (pp->colorappearance.mchroma);
 1863     rstprotection->trimValue (pp->colorappearance.rstprotection);
 1864     contrast->trimValue (pp->colorappearance.contrast);
 1865     qcontrast->trimValue (pp->colorappearance.qcontrast);
 1866     colorh->trimValue (pp->colorappearance.colorh);
 1867     tempout->trimValue (pp->colorappearance.tempout);
 1868     greenout->trimValue (pp->colorappearance.greenout);
 1869     ybout->trimValue (pp->colorappearance.ybout);
 1870     tempsc->trimValue (pp->colorappearance.tempsc);
 1871     greensc->trimValue (pp->colorappearance.greensc);
 1872 
 1873 }