Big update: implemented toggling between three modes. Button does not yet update when double clicking. Completely removed fullMode-related code.

This commit is contained in:
Thanatomanic
2018-06-15 23:16:20 +02:00
parent 658d975fa1
commit dec54d00ad
4 changed files with 175 additions and 139 deletions

View File

@@ -21,6 +21,7 @@
#include "guiutils.h" #include "guiutils.h"
#include "options.h" #include "options.h"
#include <cstring> #include <cstring>
#include <cmath>
#include "../rtengine/LUT.h" #include "../rtengine/LUT.h"
#include "rtimage.h" #include "rtimage.h"
#include "../rtengine/improccoordinator.h" #include "../rtengine/improccoordinator.h"
@@ -71,8 +72,8 @@ HistogramPanel::HistogramPanel ()
valueImage = new RTImage ("histValue.png"); valueImage = new RTImage ("histValue.png");
chroImage = new RTImage ("histChro.png"); chroImage = new RTImage ("histChro.png");
rawImage = new RTImage ("histRaw.png"); rawImage = new RTImage ("histRaw.png");
//fullImage = new RTImage ("histFull.png");
barImage = new RTImage ("histBar.png"); barImage = new RTImage ("histBar.png");
modeImage = new RTImage ("histFull.png"); // needs replacement!
redImage_g = new RTImage ("histRedg.png"); redImage_g = new RTImage ("histRedg.png");
greenImage_g = new RTImage ("histGreeng.png"); greenImage_g = new RTImage ("histGreeng.png");
@@ -80,8 +81,9 @@ HistogramPanel::HistogramPanel ()
valueImage_g = new RTImage ("histValueg.png"); valueImage_g = new RTImage ("histValueg.png");
chroImage_g = new RTImage ("histChrog.png"); chroImage_g = new RTImage ("histChrog.png");
rawImage_g = new RTImage ("histRawg.png"); rawImage_g = new RTImage ("histRawg.png");
//fullImage_g = new RTImage ("histFullg.png");
barImage_g = new RTImage ("histBarg.png"); barImage_g = new RTImage ("histBarg.png");
modeImage_g = new RTImage ("histFullg.png"); // needs replacement!
modeImage_g2 = new RTImage ("histBarg.png"); // needs replacement!
showRed = Gtk::manage (new Gtk::ToggleButton ()); showRed = Gtk::manage (new Gtk::ToggleButton ());
showGreen = Gtk::manage (new Gtk::ToggleButton ()); showGreen = Gtk::manage (new Gtk::ToggleButton ());
@@ -89,8 +91,8 @@ HistogramPanel::HistogramPanel ()
showValue = Gtk::manage (new Gtk::ToggleButton ()); showValue = Gtk::manage (new Gtk::ToggleButton ());
showChro = Gtk::manage (new Gtk::ToggleButton ()); showChro = Gtk::manage (new Gtk::ToggleButton ());
showRAW = Gtk::manage (new Gtk::ToggleButton ()); showRAW = Gtk::manage (new Gtk::ToggleButton ());
//showFull = Gtk::manage (new Gtk::ToggleButton ());
showBAR = Gtk::manage (new Gtk::ToggleButton ()); showBAR = Gtk::manage (new Gtk::ToggleButton ());
showMode = Gtk::manage (new Gtk::Button ());
showRed->set_name("histButton"); showRed->set_name("histButton");
showRed->set_can_focus(false); showRed->set_can_focus(false);
@@ -104,10 +106,10 @@ HistogramPanel::HistogramPanel ()
showChro->set_can_focus(false); showChro->set_can_focus(false);
showRAW->set_name("histButton"); showRAW->set_name("histButton");
showRAW->set_can_focus(false); showRAW->set_can_focus(false);
//showFull->set_name("fullButton");
//showFull->set_can_focus(false);
showBAR->set_name("histButton"); showBAR->set_name("histButton");
showBAR->set_can_focus(false); showBAR->set_can_focus(false);
showMode->set_name("histButton");
showMode->set_can_focus(false);
showRed->set_relief (Gtk::RELIEF_NONE); showRed->set_relief (Gtk::RELIEF_NONE);
showGreen->set_relief (Gtk::RELIEF_NONE); showGreen->set_relief (Gtk::RELIEF_NONE);
@@ -115,8 +117,8 @@ HistogramPanel::HistogramPanel ()
showValue->set_relief (Gtk::RELIEF_NONE); showValue->set_relief (Gtk::RELIEF_NONE);
showChro->set_relief (Gtk::RELIEF_NONE); showChro->set_relief (Gtk::RELIEF_NONE);
showRAW->set_relief (Gtk::RELIEF_NONE); showRAW->set_relief (Gtk::RELIEF_NONE);
//showFull->set_relief (Gtk::RELIEF_NONE);
showBAR->set_relief (Gtk::RELIEF_NONE); showBAR->set_relief (Gtk::RELIEF_NONE);
showMode->set_relief (Gtk::RELIEF_NONE);
showRed->set_tooltip_text (M("HISTOGRAM_TOOLTIP_R")); showRed->set_tooltip_text (M("HISTOGRAM_TOOLTIP_R"));
showGreen->set_tooltip_text (M("HISTOGRAM_TOOLTIP_G")); showGreen->set_tooltip_text (M("HISTOGRAM_TOOLTIP_G"));
@@ -124,8 +126,8 @@ HistogramPanel::HistogramPanel ()
showValue->set_tooltip_text (M("HISTOGRAM_TOOLTIP_L")); showValue->set_tooltip_text (M("HISTOGRAM_TOOLTIP_L"));
showChro->set_tooltip_text (M("HISTOGRAM_TOOLTIP_CHRO")); showChro->set_tooltip_text (M("HISTOGRAM_TOOLTIP_CHRO"));
showRAW->set_tooltip_text (M("HISTOGRAM_TOOLTIP_RAW")); showRAW->set_tooltip_text (M("HISTOGRAM_TOOLTIP_RAW"));
//showFull->set_tooltip_text (M("HISTOGRAM_TOOLTIP_FULL"));
showBAR->set_tooltip_text (M("HISTOGRAM_TOOLTIP_BAR")); showBAR->set_tooltip_text (M("HISTOGRAM_TOOLTIP_BAR"));
showMode->set_tooltip_text (M("HISTOGRAM_TOOLTIP_FULL")); // needs replacement!
buttonGrid = Gtk::manage (new Gtk::Grid ()); buttonGrid = Gtk::manage (new Gtk::Grid ());
buttonGrid->set_orientation(Gtk::ORIENTATION_VERTICAL); buttonGrid->set_orientation(Gtk::ORIENTATION_VERTICAL);
@@ -136,7 +138,6 @@ HistogramPanel::HistogramPanel ()
showChro->set_active (false);//unactive by default showChro->set_active (false);//unactive by default
showRAW->set_active (false); showRAW->set_active (false);
//showFull->set_active (!options.histogramFullMode);
showBAR->set_active (options.histogramBar); showBAR->set_active (options.histogramBar);
showRed->set_image (showRed->get_active() ? *redImage : *redImage_g); showRed->set_image (showRed->get_active() ? *redImage : *redImage_g);
@@ -145,8 +146,14 @@ HistogramPanel::HistogramPanel ()
showValue->set_image (showValue->get_active() ? *valueImage : *valueImage_g); showValue->set_image (showValue->get_active() ? *valueImage : *valueImage_g);
showChro->set_image (showChro->get_active() ? *chroImage : *chroImage_g); showChro->set_image (showChro->get_active() ? *chroImage : *chroImage_g);
showRAW->set_image (showRAW->get_active() ? *rawImage : *rawImage_g); showRAW->set_image (showRAW->get_active() ? *rawImage : *rawImage_g);
//showFull->set_image (showFull->get_active() ? *fullImage : *fullImage_g);
showBAR->set_image (showBAR->get_active() ? *barImage : *barImage_g); showBAR->set_image (showBAR->get_active() ? *barImage : *barImage_g);
if (options.histogramDrawMode == 0)
showMode->set_image(*modeImage);
else if (options.histogramDrawMode == 1)
showMode->set_image(*modeImage_g);
else
showMode->set_image(*modeImage_g2);
showRed->set_hexpand(false); showRed->set_hexpand(false);
showRed->set_vexpand(false); showRed->set_vexpand(false);
@@ -172,14 +179,14 @@ HistogramPanel::HistogramPanel ()
showRAW->set_vexpand(false); showRAW->set_vexpand(false);
showRAW->set_halign(Gtk::ALIGN_CENTER); showRAW->set_halign(Gtk::ALIGN_CENTER);
showRAW->set_valign(Gtk::ALIGN_START); showRAW->set_valign(Gtk::ALIGN_START);
//showFull->set_hexpand(false);
//showFull->set_vexpand(false);
//showFull->set_halign(Gtk::ALIGN_CENTER);
//showFull->set_valign(Gtk::ALIGN_START);
showBAR->set_hexpand(false); showBAR->set_hexpand(false);
showBAR->set_vexpand(false); showBAR->set_vexpand(false);
showBAR->set_halign(Gtk::ALIGN_CENTER); showBAR->set_halign(Gtk::ALIGN_CENTER);
showBAR->set_valign(Gtk::ALIGN_START); showBAR->set_valign(Gtk::ALIGN_START);
showMode->set_hexpand(false);
showMode->set_vexpand(false);
showMode->set_halign(Gtk::ALIGN_CENTER);
showMode->set_valign(Gtk::ALIGN_START);
showRed->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::red_toggled), showRed ); showRed->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::red_toggled), showRed );
showGreen->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::green_toggled), showGreen ); showGreen->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::green_toggled), showGreen );
@@ -187,8 +194,8 @@ HistogramPanel::HistogramPanel ()
showValue->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::value_toggled), showValue ); showValue->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::value_toggled), showValue );
showChro->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::chro_toggled), showChro ); showChro->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::chro_toggled), showChro );
showRAW->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::raw_toggled), showRAW ); showRAW->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::raw_toggled), showRAW );
//showFull->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::full_toggled), showFull );
showBAR->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::bar_toggled), showBAR ); showBAR->signal_toggled().connect( sigc::mem_fun(*this, &HistogramPanel::bar_toggled), showBAR );
showMode->signal_released().connect( sigc::mem_fun(*this, &HistogramPanel::mode_released), showMode );
buttonGrid->add (*showRed); buttonGrid->add (*showRed);
buttonGrid->add (*showGreen); buttonGrid->add (*showGreen);
@@ -196,8 +203,8 @@ HistogramPanel::HistogramPanel ()
buttonGrid->add (*showValue); buttonGrid->add (*showValue);
buttonGrid->add (*showChro); buttonGrid->add (*showChro);
buttonGrid->add (*showRAW); buttonGrid->add (*showRAW);
//buttonGrid->add (*showFull);
buttonGrid->add (*showBAR); buttonGrid->add (*showBAR);
buttonGrid->add (*showMode);
// Put the button vbox next to the window's border to be less disturbing // Put the button vbox next to the window's border to be less disturbing
if (options.histogramPosition == 1) { if (options.histogramPosition == 1) {
@@ -221,8 +228,8 @@ HistogramPanel::~HistogramPanel ()
delete valueImage; delete valueImage;
delete chroImage; delete chroImage;
delete rawImage; delete rawImage;
//delete fullImage;
delete barImage; delete barImage;
delete modeImage;
delete redImage_g; delete redImage_g;
delete greenImage_g; delete greenImage_g;
@@ -230,8 +237,9 @@ HistogramPanel::~HistogramPanel ()
delete valueImage_g; delete valueImage_g;
delete chroImage_g; delete chroImage_g;
delete rawImage_g; delete rawImage_g;
//delete fullImage_g;
delete barImage_g; delete barImage_g;
delete modeImage_g;
delete modeImage_g2;
} }
@@ -312,21 +320,26 @@ void HistogramPanel::raw_toggled ()
rgbv_toggled(); rgbv_toggled();
} }
/*void HistogramPanel::full_toggled ()
{
options.histogramFullMode = !showFull->get_active();
showFull->set_image(showFull->get_active() ? *fullImage : *fullImage_g);
rgbv_toggled();
}*/
void HistogramPanel::bar_toggled () void HistogramPanel::bar_toggled ()
{ {
showBAR->set_image(showBAR->get_active() ? *barImage : *barImage_g); showBAR->set_image(showBAR->get_active() ? *barImage : *barImage_g);
rgbv_toggled(); rgbv_toggled();
} }
void HistogramPanel::mode_released ()
{
options.histogramDrawMode = (options.histogramDrawMode + 1) % 3;
if (options.histogramDrawMode == 0)
showMode->set_image(*modeImage);
else if (options.histogramDrawMode == 1)
showMode->set_image(*modeImage_g);
else
showMode->set_image(*modeImage_g2);
rgbv_toggled();
}
void HistogramPanel::rgbv_toggled () void HistogramPanel::rgbv_toggled ()
{ {
// Update Display // Update Display
histogramArea->updateOptions (showRed->get_active(), showGreen->get_active(), showBlue->get_active(), showValue->get_active(), showRAW->get_active(), /*showFull->get_active(),*/ showChro->get_active()); histogramArea->updateOptions (showRed->get_active(), showGreen->get_active(), showBlue->get_active(), showValue->get_active(), showRAW->get_active(), showChro->get_active(), options.histogramDrawMode);
histogramArea->queue_draw (); histogramArea->queue_draw ();
histogramRGBArea->updateOptions (showRed->get_active(), showGreen->get_active(), showBlue->get_active(), showValue->get_active(), showRAW->get_active(), showBAR->get_active(), showChro->get_active()); histogramRGBArea->updateOptions (showRed->get_active(), showGreen->get_active(), showBlue->get_active(), showValue->get_active(), showRAW->get_active(), showBAR->get_active(), showChro->get_active());
@@ -386,18 +399,27 @@ void HistogramPanel::reorder (Gtk::PositionType align)
} }
} }
// FullModeListener interface: // DrawModeListener interface:
/*void HistogramPanel::toggle_button_full () void HistogramPanel::toggle_button_mode ()
{ {
showFull->set_active (!showFull->get_active ()); // Does not seem to be called from HistogramArea::on_button_press_event ... why?
showFull->set_image(showFull->get_active() ? *fullImage : *fullImage_g); //
}*/ // printf("%i\n",options.histogramDrawMode);
// fflush(stdout);
if (options.histogramDrawMode == 0)
showMode->set_image(*modeImage);
else if (options.histogramDrawMode == 1)
showMode->set_image(*modeImage_g);
else
showMode->set_image(*modeImage_g2);
}
// //
// //
// //
// HistogramRGBArea // HistogramRGBArea
HistogramRGBArea::HistogramRGBArea () ://needChroma unactive by default HistogramRGBArea::HistogramRGBArea () ://needChroma unactive by default, luma too
val(0), r(0), g(0), b(0), frozen(false), valid(false), needRed(true), needGreen(true), needBlue(true), needLuma(false), rawMode(false), showMode(options.histogramBar), barDisplayed(options.histogramBar), needChroma(false), parent(nullptr) val(0), r(0), g(0), b(0), frozen(false), valid(false), needRed(true), needGreen(true), needBlue(true), needLuma(false), rawMode(false), showMode(options.histogramBar), barDisplayed(options.histogramBar), needChroma(false), parent(nullptr)
{ {
@@ -672,8 +694,8 @@ bool HistogramRGBArea::on_button_press_event (GdkEventButton* event)
// //
// //
// HistogramArea // HistogramArea
HistogramArea::HistogramArea (/*FullModeListener *fml*/) : //needChroma unactive by default HistogramArea::HistogramArea (DrawModeListener *fml) : //needChroma unactive by default, luma too
valid(false), /*fullMode(options.histogramFullMode), myFullModeListener(fml),*/ oldwidth(-1), oldheight(-1), needLuma(false), needRed(true), needGreen(true), needBlue(true), rawMode(false), needChroma(false) valid(false), drawMode(options.histogramDrawMode), myDrawModeListener(fml), oldwidth(-1), oldheight(-1), needLuma(false), needRed(true), needGreen(true), needBlue(true), rawMode(false), needChroma(false)
{ {
lhist(256); lhist(256);
@@ -750,7 +772,7 @@ void HistogramArea::get_preferred_width_for_height_vfunc (int height, int &minim
get_preferred_width_vfunc (minimum_width, natural_width); get_preferred_width_vfunc (minimum_width, natural_width);
} }
void HistogramArea::updateOptions (bool r, bool g, bool b, bool l, bool raw, /*bool full,*/ bool c) void HistogramArea::updateOptions (bool r, bool g, bool b, bool l, bool raw, bool c, int mode)
{ {
needRed = r; needRed = r;
@@ -758,8 +780,8 @@ void HistogramArea::updateOptions (bool r, bool g, bool b, bool l, bool raw, /*b
needBlue = b; needBlue = b;
needLuma = l; needLuma = l;
rawMode = raw; rawMode = raw;
//fullMode = !full;
needChroma = c; needChroma = c;
drawMode = mode;
updateBackBuffer (); updateBackBuffer ();
} }
@@ -867,7 +889,7 @@ void HistogramArea::updateBackBuffer ()
// does not take into account 0 and 255 values // does not take into account 0 and 255 values
// them are handled separately // them are handled separately
unsigned int fullhistheight = 0; int fullhistheight = 0;
for (int i = 1; i < 255; i++) { for (int i = 1; i < 255; i++) {
if (needLuma && lhisttemp[i] > fullhistheight) { if (needLuma && lhisttemp[i] > fullhistheight) {
@@ -891,58 +913,8 @@ void HistogramArea::updateBackBuffer ()
} }
} }
int realhistheight = fullhistheight; if (fullhistheight < winh - 2) {
fullhistheight = winh - 2;
// though much faster than before, this still takes a lot of time especially for big files if rawMode is true
/*if (!fullMode) {
int area = 0;
#ifdef __SSE2__
vint onev = _mm_set1_epi32(1);
vint iv = (vint)ZEROV;
#endif
for (unsigned i = 0; i < fullhistheight; i++) {
#ifdef __SSE2__
vint areatempv = (vint)ZEROV;
for (int j = 0; j < 256; j += 4) {
vmask mask1v = _mm_cmpgt_epi32(LVI(lhisttemp[j]), iv);
vmask mask2v = _mm_cmpgt_epi32(LVI(rhtemp[j]), iv);
vmask mask3v = _mm_cmpgt_epi32(LVI(ghtemp[j]), iv);
vmask mask4v = _mm_cmpgt_epi32(LVI(bhtemp[j]), iv);
mask1v = _mm_or_si128(mask1v, mask2v);
mask3v = _mm_or_si128(mask3v, mask4v);
mask2v = _mm_cmpgt_epi32(LVI(chisttemp[j]), iv);
mask1v = _mm_or_si128(mask1v, mask3v);
mask1v = _mm_or_si128(mask1v, mask2v);
areatempv = _mm_add_epi32(areatempv, _mm_and_si128(mask1v, onev));
}
areatempv = _mm_add_epi32(areatempv, (vint)_mm_movehl_ps((vfloat)areatempv, (vfloat)areatempv));
areatempv = _mm_add_epi32(areatempv, _mm_shuffle_epi32(areatempv, 1));
area += _mm_cvtsi128_si32(areatempv);
iv = _mm_add_epi32(iv, onev);
#else
for (int j = 0; j < 256; j++)
if (lhisttemp[j] > i || rhtemp[j] > i || ghtemp[j] > i || bhtemp[j] > i || chisttemp[j] > i) {
area++;
}
#endif
if ((double)area / (256 * (i + 1)) < 0.3) {
realhistheight = i;
break;
}
}
}*/
if (realhistheight < winh - 2) {
realhistheight = winh - 2;
} }
cr->set_antialias (Cairo::ANTIALIAS_SUBPIXEL); cr->set_antialias (Cairo::ANTIALIAS_SUBPIXEL);
@@ -952,57 +924,57 @@ void HistogramArea::updateBackBuffer ()
int ui = 0, oi = 0; int ui = 0, oi = 0;
if (needBlue) { if (needBlue) {
drawCurve(cr, bhchanged, realhistheight, w, h); drawCurve(cr, bhchanged, fullhistheight, w, h);
cr->set_source_rgba (0.0, 0.0, 1.0, 0.4); cr->set_source_rgba (0.0, 0.0, 1.0, 0.4);
cr->fill (); cr->fill ();
drawCurve(cr, bhchanged, realhistheight, w, h); drawCurve(cr, bhchanged, fullhistheight, w, h);
cr->set_source_rgba (0.0, 0.0, 1.0, 0.9); cr->set_source_rgba (0.0, 0.0, 1.0, 0.9);
cr->stroke (); cr->stroke ();
drawMarks(cr, bhchanged, realhistheight, w, ui, oi); drawMarks(cr, bhchanged, fullhistheight, w, ui, oi);
} }
if (needGreen) { if (needGreen) {
drawCurve(cr, ghchanged, realhistheight, w, h); drawCurve(cr, ghchanged, fullhistheight, w, h);
cr->set_source_rgba (0.0, 1.0, 0.0, 0.4); cr->set_source_rgba (0.0, 1.0, 0.0, 0.4);
cr->fill (); cr->fill ();
drawCurve(cr, ghchanged, realhistheight, w, h); drawCurve(cr, ghchanged, fullhistheight, w, h);
cr->set_source_rgba (0.0, 1.0, 0.0, 0.9); cr->set_source_rgba (0.0, 1.0, 0.0, 0.9);
cr->stroke (); cr->stroke ();
drawMarks(cr, ghchanged, realhistheight, w, ui, oi); drawMarks(cr, ghchanged, fullhistheight, w, ui, oi);
} }
if (needRed) { if (needRed) {
drawCurve(cr, rhchanged, realhistheight, w, h); drawCurve(cr, rhchanged, fullhistheight, w, h);
cr->set_source_rgba (1.0, 0.0, 0.0, 0.4); cr->set_source_rgba (1.0, 0.0, 0.0, 0.4);
cr->fill (); cr->fill ();
drawCurve(cr, rhchanged, realhistheight, w, h); drawCurve(cr, rhchanged, fullhistheight, w, h);
cr->set_source_rgba (1.0, 0.0, 0.0, 0.9); cr->set_source_rgba (1.0, 0.0, 0.0, 0.9);
cr->stroke (); cr->stroke ();
drawMarks(cr, rhchanged, realhistheight, w, ui, oi); drawMarks(cr, rhchanged, fullhistheight, w, ui, oi);
} }
cr->set_operator(Cairo::OPERATOR_SOURCE); cr->set_operator(Cairo::OPERATOR_SOURCE);
if (needLuma && !rawMode) { if (needLuma && !rawMode) {
drawCurve(cr, lhist, realhistheight, w, h); drawCurve(cr, lhist, fullhistheight, w, h);
cr->set_source_rgb (0.9, 0.9, 0.9); cr->set_source_rgb (0.9, 0.9, 0.9);
cr->stroke (); cr->stroke ();
drawMarks(cr, lhist, realhistheight, w, ui, oi); drawMarks(cr, lhist, fullhistheight, w, ui, oi);
} }
if (needChroma && !rawMode) { if (needChroma && !rawMode) {
drawCurve(cr, chist, realhistheight, w, h); drawCurve(cr, chist, fullhistheight, w, h);
cr->set_source_rgb (0.15, 0.15, 0.15); cr->set_source_rgb (0.4, 0.4, 0.4);
cr->stroke (); cr->stroke ();
drawMarks(cr, chist, realhistheight, w, ui, oi); drawMarks(cr, chist, fullhistheight, w, ui, oi);
} }
} }
@@ -1016,7 +988,7 @@ void HistogramArea::updateBackBuffer ()
std::valarray<double> ch_ds (1); std::valarray<double> ch_ds (1);
ch_ds[0] = 4; ch_ds[0] = 4;
cr->set_dash (ch_ds, 0); cr->set_dash (ch_ds, 0);
cr->move_to(w / 4 + 0.5, 1.5); cr->move_to(w / 4 + 0.5, 1.5);
cr->line_to(w / 4 + 0.5, h - 2); cr->line_to(w / 4 + 0.5, h - 2);
cr->stroke(); cr->stroke();
@@ -1026,16 +998,44 @@ void HistogramArea::updateBackBuffer ()
cr->move_to(3 * w / 4 + 0.5, 1.5); cr->move_to(3 * w / 4 + 0.5, 1.5);
cr->line_to(3 * w / 4 + 0.5, h - 2); cr->line_to(3 * w / 4 + 0.5, h - 2);
cr->stroke(); cr->stroke();
cr->move_to(1.5, h / 4 + 0.5);
cr->line_to(w - 2, h / 4 + 0.5); if (options.histogramDrawMode == 0)
cr->stroke(); {
cr->move_to(1.5, 2 * h / 4 + 0.5); cr->move_to(1.5, h / 4 + 0.5);
cr->line_to(w - 2, 2 * h / 4 + 0.5); cr->line_to(w - 2, h / 4 + 0.5);
cr->stroke(); cr->stroke();
cr->move_to(1.5, 3 * h / 4 + 0.5); cr->move_to(1.5, 2 * h / 4 + 0.5);
cr->line_to(w - 2, 3 * h / 4 + 0.5); cr->line_to(w - 2, 2 * h / 4 + 0.5);
cr->stroke(); cr->stroke();
cr->move_to(1.5, 3 * h / 4 + 0.5);
cr->line_to(w - 2, 3 * h / 4 + 0.5);
cr->stroke();
}
if (options.histogramDrawMode == 1)
{
cr->move_to(1.5, h - scalingFunctionLog(h,h / 4 + 0.5));
cr->line_to(w - 2, h - scalingFunctionLog(h,h / 4 + 0.5));
cr->stroke();
cr->move_to(1.5, h - scalingFunctionLog(h,2 * h / 4 + 0.5));
cr->line_to(w - 2, h - scalingFunctionLog(h,2 * h / 4 + 0.5));
cr->stroke();
cr->move_to(1.5, h - scalingFunctionLog(h,3 * h / 4 + 0.5));
cr->line_to(w - 2, h - scalingFunctionLog(h,3 * h / 4 + 0.5));
cr->stroke();
}
if (options.histogramDrawMode == 2)
{
cr->move_to(1.5, scalingFunctionCube(h,h / 4 + 0.5));
cr->line_to(w - 2, scalingFunctionCube(h,h / 4 + 0.5));
cr->stroke();
cr->move_to(1.5, scalingFunctionCube(h,2 * h / 4 + 0.5));
cr->line_to(w - 2, scalingFunctionCube(h,2 * h / 4 + 0.5));
cr->stroke();
cr->move_to(1.5, scalingFunctionCube(h,3 * h / 4 + 0.5));
cr->line_to(w - 2, scalingFunctionCube(h,3 * h / 4 + 0.5));
cr->stroke();
}
cr->unset_dash(); cr->unset_dash();
// Draw the frame's border // Draw the frame's border
@@ -1055,6 +1055,18 @@ void HistogramArea::on_realize ()
add_events(Gdk::BUTTON_PRESS_MASK); add_events(Gdk::BUTTON_PRESS_MASK);
} }
double HistogramArea::scalingFunctionLog(double vsize, double val)
{
double factor = 1.0; // can be tuned if necessary - makes the log 'steeper'
return vsize * log(factor / (factor + val)) / log(factor / vsize);
}
double HistogramArea::scalingFunctionCube(double vsize, double val)
{
double factor = 3.0; // can be tuned; higher values compress the middel part of the scale
return (val * (4 * (-1.0 + factor) * val * val - 6.0 * (-1.0 + factor) * val * vsize + (-2.0 + 3.0 * factor) * vsize *vsize))/(factor * vsize * vsize);
}
void HistogramArea::drawCurve(Cairo::RefPtr<Cairo::Context> &cr, void HistogramArea::drawCurve(Cairo::RefPtr<Cairo::Context> &cr,
LUTu & data, double scale, int hsize, int vsize) LUTu & data, double scale, int hsize, int vsize)
{ {
@@ -1063,6 +1075,11 @@ void HistogramArea::drawCurve(Cairo::RefPtr<Cairo::Context> &cr,
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
double val = data[i] * (double)(vsize - 2) / scale; double val = data[i] * (double)(vsize - 2) / scale;
if (drawMode == 1)
val = scalingFunctionLog((double)vsize,val);
if (drawMode == 2)
val = scalingFunctionCube((double)vsize,val);
if (val > vsize - 1) { if (val > vsize - 1) {
val = vsize - 1; val = vsize - 1;
@@ -1111,18 +1128,18 @@ bool HistogramArea::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)
bool HistogramArea::on_button_press_event (GdkEventButton* event) bool HistogramArea::on_button_press_event (GdkEventButton* event)
{ {
if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
/*if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
fullMode = !fullMode; drawMode = (drawMode + 1) % 3;
options.histogramFullMode = fullMode; options.histogramDrawMode = (options.histogramDrawMode + 1) % 3;
if (myFullModeListener) { if (myDrawModeListener) { // This doesn't seem te be work? Therefore no update of the button graphics...
myFullModeListener->toggle_button_full (); myDrawModeListener->toggle_button_mode ();
} }
updateBackBuffer (); updateBackBuffer ();
queue_draw (); queue_draw ();
}*/ }
return true; return true;
} }

View File

@@ -108,6 +108,13 @@ public:
virtual void toggle_button_full () {} virtual void toggle_button_full () {}
};*/ };*/
class DrawModeListener
{
public:
virtual ~DrawModeListener() {}
virtual void toggle_button_mode () {}
};
class HistogramArea : public Gtk::DrawingArea, public BackBuffer class HistogramArea : public Gtk::DrawingArea, public BackBuffer
{ {
private: private:
@@ -118,21 +125,23 @@ protected:
LUTu lhistRaw, rhistRaw, ghistRaw, bhistRaw; LUTu lhistRaw, rhistRaw, ghistRaw, bhistRaw;
bool valid; bool valid;
//bool fullMode; int drawMode;
//FullModeListener *myFullModeListener; DrawModeListener *myDrawModeListener;
int oldwidth, oldheight; int oldwidth, oldheight;
bool needLuma, needRed, needGreen, needBlue, rawMode, needChroma; bool needLuma, needRed, needGreen, needBlue, rawMode, needChroma;
HistogramAreaIdleHelper* haih; HistogramAreaIdleHelper* haih;
public: public:
explicit HistogramArea(/*FullModeListener *fml = nullptr*/); explicit HistogramArea(DrawModeListener *fml = nullptr);
~HistogramArea(); ~HistogramArea();
void updateBackBuffer (); void updateBackBuffer ();
void update (LUTu &histRed, LUTu &histGreen, LUTu &histBlue, LUTu &histLuma, LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw, LUTu &histChroma); void update (LUTu &histRed, LUTu &histGreen, LUTu &histBlue, LUTu &histLuma, LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw, LUTu &histChroma);
void updateOptions (bool r, bool g, bool b, bool l, bool raw, /*bool full ,*/ bool c); void updateOptions (bool r, bool g, bool b, bool l, bool raw, bool c, int mode);
void on_realize(); void on_realize();
bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr); bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr);
bool on_button_press_event (GdkEventButton* event); bool on_button_press_event (GdkEventButton* event);
@@ -145,9 +154,11 @@ private:
void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const; void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const;
void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const; void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const;
void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const; void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const;
double scalingFunctionLog(double vsize, double val);
double scalingFunctionCube(double vsize, double val);
}; };
class HistogramPanel : public Gtk::Grid, public PointerMotionListener/*, public FullModeListener*/ class HistogramPanel : public Gtk::Grid, public PointerMotionListener, public DrawModeListener
{ {
protected: protected:
@@ -161,16 +172,15 @@ protected:
Gtk::ToggleButton* showBlue; Gtk::ToggleButton* showBlue;
Gtk::ToggleButton* showValue; Gtk::ToggleButton* showValue;
Gtk::ToggleButton* showRAW; Gtk::ToggleButton* showRAW;
//Gtk::ToggleButton* showFull;
Gtk::ToggleButton* showBAR; Gtk::ToggleButton* showBAR;
Gtk::ToggleButton* showChro; Gtk::ToggleButton* showChro;
Gtk::Button* showMode;
Gtk::Image *redImage; Gtk::Image *redImage;
Gtk::Image *greenImage; Gtk::Image *greenImage;
Gtk::Image *blueImage; Gtk::Image *blueImage;
Gtk::Image *valueImage; Gtk::Image *valueImage;
Gtk::Image *rawImage; Gtk::Image *rawImage;
//Gtk::Image *fullImage;
Gtk::Image *barImage; Gtk::Image *barImage;
Gtk::Image *chroImage; Gtk::Image *chroImage;
@@ -179,10 +189,12 @@ protected:
Gtk::Image *blueImage_g; Gtk::Image *blueImage_g;
Gtk::Image *valueImage_g; Gtk::Image *valueImage_g;
Gtk::Image *rawImage_g; Gtk::Image *rawImage_g;
//Gtk::Image *fullImage_g;
Gtk::Image *barImage_g; Gtk::Image *barImage_g;
Gtk::Image *chroImage_g; Gtk::Image *chroImage_g;
Gtk::Image *modeImage;
Gtk::Image *modeImage_g;
Gtk::Image *modeImage_g2;
sigc::connection rconn; sigc::connection rconn;
void setHistInvalid (); void setHistInvalid ();
@@ -209,14 +221,14 @@ public:
void blue_toggled (); void blue_toggled ();
void value_toggled (); void value_toggled ();
void raw_toggled (); void raw_toggled ();
//void full_toggled ();
void chro_toggled (); void chro_toggled ();
void bar_toggled (); void bar_toggled ();
void mode_released ();
void rgbv_toggled (); void rgbv_toggled ();
void resized (Gtk::Allocation& req); void resized (Gtk::Allocation& req);
// fullModeListener interface // drawModeListener interface
//void toggle_button_full (); void toggle_button_mode ();
}; };
#endif #endif

View File

@@ -415,7 +415,8 @@ void Options::setDefaults ()
multiDisplayMode = 0; multiDisplayMode = 0;
histogramPosition = 1; histogramPosition = 1;
histogramBar = true; histogramBar = true;
histogramFullMode = false; //histogramFullMode = false;
histogramDrawMode = 0;
curvebboxpos = 1; curvebboxpos = 1;
prevdemo = PD_Sidecar; prevdemo = PD_Sidecar;
rgbDenoiseThreadLimit = 0; rgbDenoiseThreadLimit = 0;
@@ -1290,8 +1291,12 @@ void Options::readFromFile (Glib::ustring fname)
histogramBar = keyFile.get_boolean ("GUI", "HistogramBar"); histogramBar = keyFile.get_boolean ("GUI", "HistogramBar");
} }
if (keyFile.has_key ("GUI", "HistogramFullMode")) { //if (keyFile.has_key ("GUI", "HistogramFullMode")) {
histogramFullMode = keyFile.get_boolean ("GUI", "HistogramFullMode"); // histogramFullMode = keyFile.get_boolean ("GUI", "HistogramFullMode");
//}
if (keyFile.has_key ("GUI", "HistogramDrawMode")) {
histogramDrawMode = keyFile.get_integer ("GUI", "HistogramDrawMode");
} }
if (keyFile.has_key ("GUI", "NavigatorRGBUnit")) { if (keyFile.has_key ("GUI", "NavigatorRGBUnit")) {
@@ -1938,7 +1943,8 @@ void Options::saveToFile (Glib::ustring fname)
keyFile.set_double_list ("GUI", "NavGuideBrush", navGuideBrush); keyFile.set_double_list ("GUI", "NavGuideBrush", navGuideBrush);
keyFile.set_integer ("GUI", "HistogramPosition", histogramPosition); keyFile.set_integer ("GUI", "HistogramPosition", histogramPosition);
keyFile.set_boolean ("GUI", "HistogramBar", histogramBar); keyFile.set_boolean ("GUI", "HistogramBar", histogramBar);
keyFile.set_boolean ("GUI", "HistogramFullMode", histogramFullMode); //keyFile.set_boolean ("GUI", "HistogramFullMode", histogramFullMode);
keyFile.set_integer ("GUI", "HistogramDrawMode", histogramDrawMode);
keyFile.set_integer ("GUI", "NavigatorRGBUnit", (int)navRGBUnit); keyFile.set_integer ("GUI", "NavigatorRGBUnit", (int)navRGBUnit);
keyFile.set_integer ("GUI", "NavigatorHSVUnit", (int)navHSVUnit); keyFile.set_integer ("GUI", "NavigatorHSVUnit", (int)navHSVUnit);
keyFile.set_boolean ("GUI", "ShowFilmStripToolBar", showFilmStripToolBar); keyFile.set_boolean ("GUI", "ShowFilmStripToolBar", showFilmStripToolBar);

View File

@@ -256,7 +256,8 @@ public:
int histogramPosition; // 0=disabled, 1=left pane, 2=right pane int histogramPosition; // 0=disabled, 1=left pane, 2=right pane
//int histogramWorking; // 0=disabled, 1=left pane, 2=right pane //int histogramWorking; // 0=disabled, 1=left pane, 2=right pane
bool histogramBar; bool histogramBar;
bool histogramFullMode; //bool histogramFullMode;
int histogramDrawMode;
bool FileBrowserToolbarSingleRow; bool FileBrowserToolbarSingleRow;
bool hideTPVScrollbar; bool hideTPVScrollbar;
bool UseIconNoText; bool UseIconNoText;