diff --git a/rtgui/curveeditor.cc b/rtgui/curveeditor.cc index 09c7b0cd7..645b67f3b 100644 --- a/rtgui/curveeditor.cc +++ b/rtgui/curveeditor.cc @@ -22,6 +22,7 @@ #include #include #include +#include extern Glib::ustring argv0; @@ -89,7 +90,7 @@ CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEd bgHistValid = false; selected = DCT_Linear; - histogram = new unsigned int[256]; // histogram values + histogram(256); // histogram values group = ceGroup; subGroup = ceSubGroup; @@ -107,7 +108,6 @@ CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEd CurveEditor::~CurveEditor () { - delete [] histogram; } void CurveEditor::setCurve (const std::vector& p) { @@ -134,15 +134,15 @@ void CurveEditor::setUnChanged (bool uc) { /* * Update the backgrounds histograms */ -void CurveEditor::updateBackgroundHistogram (unsigned int* hist) { +void CurveEditor::updateBackgroundHistogram (LUTu & hist) { // Copy the histogram in the curve editor cache - if (hist!=NULL) { - memcpy (histogram, hist, 256*sizeof(unsigned int)); + if (hist) { + histogram=hist; bgHistValid = true; } else bgHistValid = false; - + // Then call the curve editor group to eventually update the histogram subGroup->updateBackgroundHistogram (this); } diff --git a/rtgui/curveeditor.h b/rtgui/curveeditor.h index 66c6c999a..4028ff9b1 100644 --- a/rtgui/curveeditor.h +++ b/rtgui/curveeditor.h @@ -20,6 +20,7 @@ #define _CURVEEDITOR_ #include +#include class CurveEditorGroup; class CurveEditorSubGroup; @@ -32,7 +33,7 @@ class CurveEditorSubGroup; /* * This class is an interface between RT and the curve editor group ; it handles the methods - * related to a specific curve. It is created by CurveEditorGroup::addCurve + * related to a specific curve. It is created by CurveEditorGroup::addCurve */ class CurveEditor { @@ -51,7 +52,7 @@ class CurveEditor { */ PopUpToggleButton* curveType; - unsigned int* histogram; // histogram values + LUTu histogram; // histogram values bool bgHistValid; int selected; @@ -70,7 +71,7 @@ class CurveEditor { void curveTypeToggled(); bool isUnChanged (); void setUnChanged (bool uc); - void updateBackgroundHistogram (unsigned int* hist); + void updateBackgroundHistogram (LUTu & hist); void setCurve (const std::vector& p); virtual std::vector getCurve () = 0; }; @@ -98,7 +99,7 @@ class DiagonalCurveEditor : public CurveEditor { /* - ********************** Flat Curve Editor ********************** + ********************** Flat Curve Editor ********************** */ diff --git a/rtgui/diagonalcurveeditorsubgroup.cc b/rtgui/diagonalcurveeditorsubgroup.cc index 497243bf8..be11431d6 100644 --- a/rtgui/diagonalcurveeditorsubgroup.cc +++ b/rtgui/diagonalcurveeditorsubgroup.cc @@ -323,12 +323,12 @@ void DiagonalCurveEditorSubGroup::storeDisplayedCurve() { * Restore the histogram to all types from the CurveEditor object to the widgets */ void DiagonalCurveEditorSubGroup::restoreDisplayedHistogram() { - if (parent->displayedCurve) { - paramCurve->updateBackgroundHistogram (parent->displayedCurve->bgHistValid ? parent->displayedCurve->histogram : NULL); - customCurve->updateBackgroundHistogram (parent->displayedCurve->bgHistValid ? parent->displayedCurve->histogram : NULL); - NURBSCurve->updateBackgroundHistogram (parent->displayedCurve->bgHistValid ? parent->displayedCurve->histogram : NULL); + if (parent->displayedCurve /*&& initslope==1*/) { + paramCurve->updateBackgroundHistogram (parent->displayedCurve->histogram); + customCurve->updateBackgroundHistogram (parent->displayedCurve->histogram); + NURBSCurve->updateBackgroundHistogram (parent->displayedCurve->histogram); } - + } void DiagonalCurveEditorSubGroup::storeCurveValues (CurveEditor* ce, const std::vector& p) { @@ -465,9 +465,9 @@ bool DiagonalCurveEditorSubGroup::adjusterLeft (GdkEventCrossing* ev, int ac) { } void DiagonalCurveEditorSubGroup::updateBackgroundHistogram (CurveEditor* ce) { - if (ce==parent->displayedCurve) { - paramCurve->updateBackgroundHistogram (ce->bgHistValid ? ce->histogram : NULL); - customCurve->updateBackgroundHistogram (ce->bgHistValid ? ce->histogram : NULL); - NURBSCurve->updateBackgroundHistogram (ce->bgHistValid ? ce->histogram : NULL); + if (ce==parent->displayedCurve /*&& initslope==1*/) { + paramCurve->updateBackgroundHistogram (ce->histogram); + customCurve->updateBackgroundHistogram (ce->histogram); + NURBSCurve->updateBackgroundHistogram (ce->histogram); } } diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index c7b6db864..dc2d99ec3 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -1275,7 +1275,7 @@ void EditorPanel::beforeAfterToggled () { } } -void EditorPanel::histogramChanged (unsigned int* rh, unsigned int* gh, unsigned int* bh, unsigned int* lh, unsigned int* bcrgb, unsigned int* bcl) { +void EditorPanel::histogramChanged (LUTu & rh, LUTu & gh, LUTu & bh, LUTu & lh, LUTu & bcrgb, LUTu & bcl) { histogramPanel->histogramChanged (rh, gh, bh, lh); tpc->updateCurveBackgroundHistogram (bcrgb, bcl); diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index 8eeeba0eb..270b004f0 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -149,7 +149,7 @@ class EditorPanel : public Gtk::VBox, void historyBeforeLineChanged (const rtengine::procparams::ProcParams& params); // HistogramListener - void histogramChanged (unsigned int* rh, unsigned int* gh, unsigned int* bh, unsigned int* lh, unsigned int* bcrgb, unsigned int* bcl); + void histogramChanged (LUTu & rh, LUTu & gh, LUTu & bh, LUTu & lh, LUTu & bcrgb, LUTu & bcl); // event handlers void info_toggled (); diff --git a/rtgui/flatcurveeditorsubgroup.cc b/rtgui/flatcurveeditorsubgroup.cc index c564395db..860b3a42d 100644 --- a/rtgui/flatcurveeditorsubgroup.cc +++ b/rtgui/flatcurveeditorsubgroup.cc @@ -193,10 +193,10 @@ void FlatCurveEditorSubGroup::storeDisplayedCurve() { */ void FlatCurveEditorSubGroup::restoreDisplayedHistogram() { if (parent->displayedCurve) { - //paramCurve->updateBackgroundHistogram (parent->displayedCurve->bgHistValid ? parent->displayedCurve->histogram : NULL); - CPointsCurve->updateBackgroundHistogram (parent->displayedCurve->bgHistValid ? parent->displayedCurve->histogram : NULL); + //paramCurve->updateBackgroundHistogram (parent->displayedCurve->histogram); + CPointsCurve->updateBackgroundHistogram (parent->displayedCurve->histogram); } - + } void FlatCurveEditorSubGroup::storeCurveValues (CurveEditor* ce, const std::vector& p) { diff --git a/rtgui/histogrampanel.cc b/rtgui/histogrampanel.cc index 3c240d5bc..2b3461440 100644 --- a/rtgui/histogrampanel.cc +++ b/rtgui/histogrampanel.cc @@ -19,6 +19,8 @@ #include #include #include +#include + HistogramPanel::HistogramPanel () { @@ -77,10 +79,10 @@ void HistogramPanel::rgbv_toggled () { HistogramArea::HistogramArea () : valid(false), showFull(true), oldwidth(-1), needVal(true), needRed(true), needGreen(true), needBlue(true) { - lhist = new unsigned int[256]; - rhist = new unsigned int[256]; - ghist = new unsigned int[256]; - bhist = new unsigned int[256]; + lhist(256); + rhist(256); + ghist(256); + bhist(256); haih = new HistogramAreaIdleHelper; haih->harea = this; @@ -97,10 +99,6 @@ HistogramArea::~HistogramArea () { else delete haih; - delete [] lhist; - delete [] rhist; - delete [] ghist; - delete [] bhist; } void HistogramArea::updateOptions (bool r, bool g, bool b, bool v) { @@ -136,18 +134,18 @@ int histupdate (void* data) { return 0; } -void HistogramArea::update (unsigned int* rh, unsigned int* gh, unsigned int* bh, unsigned int* lh) { - - if (rh!=NULL) { - memcpy (lhist, lh, 256*sizeof(unsigned int)); - memcpy (rhist, rh, 256*sizeof(unsigned int)); - memcpy (ghist, gh, 256*sizeof(unsigned int)); - memcpy (bhist, bh, 256*sizeof(unsigned int)); +void HistogramArea::update (LUTu & rh, LUTu & gh, LUTu & bh, LUTu & lh) { + + if (rh) { + lhist=lh; + rhist=rh; + ghist=gh; + bhist=bh; valid = true; } else valid = false; - + haih->pending++; g_idle_add (histupdate, haih); } @@ -427,7 +425,7 @@ void HistogramArea::on_realize () { } void HistogramArea::drawCurve(Cairo::RefPtr &cr, - unsigned int * data, double scale, int hsize, int vsize) + LUTu & data, double scale, int hsize, int vsize) { cr->move_to (0, vsize-1); for (int i = 0; i < 256; i++) { @@ -440,7 +438,7 @@ void HistogramArea::drawCurve(Cairo::RefPtr &cr, } void HistogramArea::drawMarks(Cairo::RefPtr &cr, - unsigned int * data, double scale, int hsize, int & ui, int & oi) + LUTu & data, double scale, int hsize, int & ui, int & oi) { int s = 8; diff --git a/rtgui/histogrampanel.h b/rtgui/histogrampanel.h index 43d96928f..467088542 100644 --- a/rtgui/histogrampanel.h +++ b/rtgui/histogrampanel.h @@ -21,6 +21,7 @@ #include #include +#include class HistogramArea; struct HistogramAreaIdleHelper { @@ -44,10 +45,10 @@ class HistogramArea : public Gtk::DrawingArea { Gdk::Color lgray; Gdk::Color mgray; Gdk::Color dgray; - unsigned int* lhist; - unsigned int* rhist; - unsigned int* ghist; - unsigned int* bhist; + LUTu lhist; + LUTu rhist; + LUTu ghist; + LUTu bhist; bool valid; bool showFull; int oldwidth, oldheight; @@ -65,7 +66,7 @@ class HistogramArea : public Gtk::DrawingArea { ~HistogramArea(); void renderHistogram (); - void update (unsigned int* rh, unsigned int* gh, unsigned int* bh, unsigned int* lh); + void update (LUTu &rh, LUTu &gh, LUTu &bh, LUTu &lh); void updateOptions (bool r, bool g, bool b, bool v); void on_realize(); bool on_expose_event(GdkEventExpose* event); @@ -73,9 +74,9 @@ class HistogramArea : public Gtk::DrawingArea { void styleChanged (const Glib::RefPtr& style); private: void drawCurve(Cairo::RefPtr &cr, - unsigned int * data, double scale, int hsize, int vsize); + LUTu & data, double scale, int hsize, int vsize); void drawMarks(Cairo::RefPtr &cr, - unsigned int * data, double scale, int hsize, int & ui, int & oi); + LUTu & data, double scale, int hsize, int & ui, int & oi); }; class HistogramPanel : public Gtk::HBox { @@ -94,7 +95,7 @@ class HistogramPanel : public Gtk::HBox { HistogramPanel (); - void histogramChanged (unsigned int* rh, unsigned int* gh, unsigned int* bh, unsigned int* lh) { histogramArea->update (rh, gh, bh, lh); } + void histogramChanged (LUTu &rh, LUTu &gh, LUTu &bh, LUTu &lh) { histogramArea->update (rh, gh, bh, lh); } void rgbv_toggled (); void resized (Gtk::Allocation& req); }; diff --git a/rtgui/labcurve.cc b/rtgui/labcurve.cc index cc847decc..8c01999c3 100644 --- a/rtgui/labcurve.cc +++ b/rtgui/labcurve.cc @@ -359,7 +359,7 @@ void LCurve::setAdjusterBehavior (bool bradd, bool contradd, bool satadd) { } -void LCurve::updateCurveBackgroundHistogram (unsigned* hist) { +void LCurve::updateCurveBackgroundHistogram (LUTu & hist) { lshape->updateBackgroundHistogram (hist); } diff --git a/rtgui/labcurve.h b/rtgui/labcurve.h index 68efe3c7a..a223eb38d 100644 --- a/rtgui/labcurve.h +++ b/rtgui/labcurve.h @@ -65,7 +65,7 @@ class LCurve : public Gtk::VBox, public AdjusterListener, public FoldableToolPan void adjusterChanged (Adjuster* a, double newval); void avoidclip_toggled (); void enablelimiter_toggled (); - void updateCurveBackgroundHistogram (unsigned* hist); + void updateCurveBackgroundHistogram (LUTu & hist); virtual void colorForValue (double valX, double valY); }; diff --git a/rtgui/mycurve.h b/rtgui/mycurve.h index e1dfdc91c..2b8c346d6 100644 --- a/rtgui/mycurve.h +++ b/rtgui/mycurve.h @@ -24,6 +24,7 @@ #include #include #include +#include #define RADIUS 3 /* radius of the control points */ #define SQUARE 2 /* half length of the square shape of the tangent handles */ @@ -83,7 +84,7 @@ class MyCurve : public Gtk::DrawingArea { void setCurveListener (CurveListener* cl) { listener = cl; } void setColorProvider (ColorProvider* cp) { colorProvider = cp; } void notifyListener (); - void updateBackgroundHistogram (unsigned int* hist) {return;} ; + void updateBackgroundHistogram (LUTu & hist) {return;} ; void forceResize() { sized = RS_Force; } virtual std::vector getPoints () = 0; virtual void setPoints (const std::vector& p) = 0; diff --git a/rtgui/mydiagonalcurve.cc b/rtgui/mydiagonalcurve.cc index 4255be0c1..f8f3d5c4b 100644 --- a/rtgui/mydiagonalcurve.cc +++ b/rtgui/mydiagonalcurve.cc @@ -656,18 +656,20 @@ int diagonalmchistupdate (void* data) { return 0; } -void MyDiagonalCurve::updateBackgroundHistogram (unsigned int* hist) { - +void MyDiagonalCurve::updateBackgroundHistogram (LUTu & hist) { + if (hist!=NULL) { - memcpy (bghist, hist, 256*sizeof(unsigned int)); + //memcpy (bghist, hist, 256*sizeof(unsigned int)); + for (int i=0; i<256; i++) bghist[i]=hist[i]; + //hist = bghist; bghistvalid = true; } else bghistvalid = false; - + mcih->pending++; g_idle_add (diagonalmchistupdate, mcih); - + } void MyDiagonalCurve::reset() { diff --git a/rtgui/mydiagonalcurve.h b/rtgui/mydiagonalcurve.h index 9aee97358..c130d37c5 100644 --- a/rtgui/mydiagonalcurve.h +++ b/rtgui/mydiagonalcurve.h @@ -24,6 +24,8 @@ #include #include #include +#include + // For compatibility and simplicity reason, order shouldn't change, and must be identical to the order specified in the curveType widget enum DiagonalCurveType { @@ -76,7 +78,7 @@ class MyDiagonalCurve : public MyCurve { bool handleEvents (GdkEvent* event); void setActiveParam (int ac); void reset (); - void updateBackgroundHistogram (unsigned int* hist); + void updateBackgroundHistogram (LUTu & hist); }; #endif diff --git a/rtgui/tonecurve.cc b/rtgui/tonecurve.cc index 8bebb3a9b..9cd678a49 100644 --- a/rtgui/tonecurve.cc +++ b/rtgui/tonecurve.cc @@ -393,7 +393,7 @@ void ToneCurve::setAdjusterBehavior (bool expadd, bool hlcompadd, bool hlcompthr satAdd = satadd; } -void ToneCurve::updateCurveBackgroundHistogram (unsigned* hist) { +void ToneCurve::updateCurveBackgroundHistogram (LUTu & hist) { shape->updateBackgroundHistogram (hist); } diff --git a/rtgui/tonecurve.h b/rtgui/tonecurve.h index 5c79b295c..2b5303f81 100644 --- a/rtgui/tonecurve.h +++ b/rtgui/tonecurve.h @@ -69,7 +69,7 @@ class ToneCurve : public Gtk::VBox, public AdjusterListener, public FoldableTool void curveChanged (); void expandCurve (bool isExpanded); bool isCurveExpanded (); - void updateCurveBackgroundHistogram (unsigned* hist); + void updateCurveBackgroundHistogram (LUTu & hist); }; #endif diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index b017bb4aa..57ad8fd61 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -470,7 +470,7 @@ int ToolPanelCoordinator::getSpotWBRectSize () { return whitebalance->getSize (); } -void ToolPanelCoordinator::updateCurveBackgroundHistogram (unsigned* histrgb, unsigned* histl) { +void ToolPanelCoordinator::updateCurveBackgroundHistogram (LUTu &histrgb, LUTu &histl) { curve->updateCurveBackgroundHistogram (histrgb); lcurve->updateCurveBackgroundHistogram (histl); diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index 694f3ea7b..aa269b959 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -149,7 +149,7 @@ class ToolPanelCoordinator : public ToolPanelListener, ~ToolPanelCoordinator (); bool getChangedState () { return hasChanged; } - void updateCurveBackgroundHistogram (unsigned* histrgb, unsigned* histl); + void updateCurveBackgroundHistogram (LUTu & histrgb, LUTu & histl); void foldAllButOne (Gtk::Box* parent, FoldableToolPanel* openedSection); // multiple listeners can be added that are notified on changes (typical: profile panel and the history)