From b80abe60e8477a0a3f4a130c47e2d928e955b98f Mon Sep 17 00:00:00 2001 From: heckflosse Date: Mon, 20 Aug 2018 21:54:21 +0200 Subject: [PATCH] When Demosaic/None is set, always show raw values and never show Lab/HSV values, #4584 --- rtgui/cropwindow.cc | 6 ++- rtgui/navigator.cc | 72 +++++++++++++++++++++-------------- rtgui/navigator.h | 4 +- rtgui/pointermotionlistener.h | 4 +- 4 files changed, 51 insertions(+), 35 deletions(-) diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index 3865591ce..c02f3632f 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -1053,12 +1053,14 @@ void CropWindow::pointerMoved (int bstate, int x, int y) int rval = pix[0]; int gval = pix[1]; int bval = pix[2]; + bool isRaw = false; if (vx < imwidth && vy < imheight) { rtengine::StagedImageProcessor* ipc = iarea->getImProcCoordinator(); if(ipc) { procparams::ProcParams params; ipc->getParams(¶ms); - if(params.raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::NONE) || params.raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::NONE)) { + isRaw = params.raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::NONE) || params.raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::NONE); + if(isRaw) { ImageSource *isrc = static_cast(ipc->getInitialImage()); isrc->getRawValues(mx, my, params.coarse.rotate, rval, gval, bval); } @@ -1066,7 +1068,7 @@ void CropWindow::pointerMoved (int bstate, int x, int y) // Updates the Navigator // TODO: possible double color conversion if rval, gval, bval come from cropHandler.cropPixbuftrue ? see issue #4583 - pmlistener->pointerMoved (true, cropHandler.colorParams.outputProfile, cropHandler.colorParams.workingProfile, mx, my, rval, gval, bval); + pmlistener->pointerMoved (true, cropHandler.colorParams.outputProfile, cropHandler.colorParams.workingProfile, mx, my, rval, gval, bval, isRaw); if (pmhlistener) { // Updates the HistogramRGBArea diff --git a/rtgui/navigator.cc b/rtgui/navigator.cc index e34a909df..732b9f323 100644 --- a/rtgui/navigator.cc +++ b/rtgui/navigator.cc @@ -224,24 +224,30 @@ void Navigator::setInvalid (int fullWidth, int fullHeight) LAB_L->set_text (M("NAVIGATOR_NA")); } -void Navigator::getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB) +void Navigator::getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB, bool isRaw) { - switch (currentRGBUnit) { - case (Options::NavigatorUnit::R0_1): - sR = Glib::ustring::format(std::fixed, std::setprecision(4), r / 255.f); - sG = Glib::ustring::format(std::fixed, std::setprecision(4), g / 255.f); - sB = Glib::ustring::format(std::fixed, std::setprecision(4), b / 255.f); - break; - case (Options::NavigatorUnit::R0_255): + if (isRaw) { sR = Glib::ustring::format(std::fixed, std::setprecision(0), r); sG = Glib::ustring::format(std::fixed, std::setprecision(0), g); sB = Glib::ustring::format(std::fixed, std::setprecision(0), b); - break; - case (Options::NavigatorUnit::PERCENT): - default: - sR = Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%"); - sG = Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%"); - sB = Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f / 255.f) + Glib::ustring("%"); + } else { + switch (currentRGBUnit) { + case (Options::NavigatorUnit::R0_1): + sR = Glib::ustring::format(std::fixed, std::setprecision(4), r / 255.f); + sG = Glib::ustring::format(std::fixed, std::setprecision(4), g / 255.f); + sB = Glib::ustring::format(std::fixed, std::setprecision(4), b / 255.f); + break; + case (Options::NavigatorUnit::R0_255): + sR = Glib::ustring::format(std::fixed, std::setprecision(0), r); + sG = Glib::ustring::format(std::fixed, std::setprecision(0), g); + sB = Glib::ustring::format(std::fixed, std::setprecision(0), b); + break; + case (Options::NavigatorUnit::PERCENT): + default: + sR = Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%"); + sG = Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%"); + sB = Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f / 255.f) + Glib::ustring("%"); + } } } @@ -274,34 +280,42 @@ void Navigator::getLABText (float l, float a, float b, Glib::ustring &sL, Glib:: } // if !validPos then x/y contain the full image size -void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustring profileW, int x, int y, int r, int g, int b) +void Navigator::pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool isRaw) { if (!validPos) { setInvalid (x, y); } else { Glib::ustring s1, s2, s3; - float h, s, v; - float LAB_a, LAB_b, LAB_l; position->set_text (Glib::ustring::compose ("x: %1, y: %2", x, y)); - getRGBText (r, g, b, s1, s2, s3); + getRGBText (r, g, b, s1, s2, s3, isRaw); R->set_text (s1); G->set_text (s2); B->set_text (s3); + if (isRaw) { + H->set_text ("--"); + S->set_text ("--"); + V->set_text ("--"); + LAB_L->set_text ("--"); + LAB_A->set_text ("--"); + LAB_B->set_text ("--"); + } else { + float h, s, v; + float LAB_a, LAB_b, LAB_l; + Color::rgb2hsv01(r / 255.f, g / 255.f, b / 255.f, h, s, v); + getHSVText (h, s, v, s1, s2, s3); + H->set_text (s1); + S->set_text (s2); + V->set_text (s3); - Color::rgb2hsv01(r / 255.f, g / 255.f, b / 255.f, h, s, v); - getHSVText (h, s, v, s1, s2, s3); - H->set_text (s1); - S->set_text (s2); - V->set_text (s3); - - Color::rgb2lab01(profile, profileW, r / 255.f, g / 255.f, b / 255.f, LAB_l, LAB_a, LAB_b, options.rtSettings.HistogramWorking); // TODO: Really sure this function works? - getLABText (LAB_l, LAB_a, LAB_b, s1, s2, s3); - LAB_L->set_text (s1); - LAB_A->set_text (s2); - LAB_B->set_text (s3); + Color::rgb2lab01(profile, profileW, r / 255.f, g / 255.f, b / 255.f, LAB_l, LAB_a, LAB_b, options.rtSettings.HistogramWorking); // TODO: Really sure this function works? + getLABText (LAB_l, LAB_a, LAB_b, s1, s2, s3); + LAB_L->set_text (s1); + LAB_A->set_text (s2); + LAB_B->set_text (s3); + } } } diff --git a/rtgui/navigator.h b/rtgui/navigator.h index 6108e2809..e7689b7c2 100644 --- a/rtgui/navigator.h +++ b/rtgui/navigator.h @@ -55,10 +55,10 @@ public: // pointermotionlistener interface // void pointerMoved (bool validPos, int x, int y, int r, int g, int b); - void pointerMoved (bool validPos, Glib::ustring profile, Glib::ustring profileW, int x, int y, int r, int g, int b); + void pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool raw = false); void setInvalid (int fullWidth = -1, int fullHeight = -1); - void getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB); + void getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB, bool isRaw = false); void getHSVText (float h, float s, float v, Glib::ustring &sH, Glib::ustring &sS, Glib::ustring &sV); void getLABText (float l, float a, float b, Glib::ustring &sL, Glib::ustring &sA, Glib::ustring &sB); diff --git a/rtgui/pointermotionlistener.h b/rtgui/pointermotionlistener.h index 09a9b3b4f..7a275972d 100644 --- a/rtgui/pointermotionlistener.h +++ b/rtgui/pointermotionlistener.h @@ -27,9 +27,9 @@ protected: public: virtual ~PointerMotionListener() {} - virtual void pointerMoved (bool validPos, Glib::ustring profile, Glib::ustring profileW, int x, int y, int r, int g, int b) {} + virtual void pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool isRaw = false) {} virtual void toggleFreeze () {} - virtual void getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB) { sR = "--"; sG = "--"; sB = "--"; } + virtual void getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB, bool isRaw = false) { sR = "--"; sG = "--"; sB = "--"; } virtual void getHSVText (float h, float s, float v, Glib::ustring &sH, Glib::ustring &sS, Glib::ustring &sV) { sH = "--"; sS = "--"; sV = "--"; } virtual void getLABText (float l, float a, float b, Glib::ustring &sL, Glib::ustring &sA, Glib::ustring &sB) { sL = "--"; sA = "--"; sB = "--"; }