Now the Lab curves are properly handeled in the history (MSG are still to be created)
This commit is contained in:
@@ -51,7 +51,8 @@ Curve::Curve (const std::vector<double>& p, int poly_pn) : x(NULL), y(NULL), ypp
|
|||||||
if (kind==Spline)
|
if (kind==Spline)
|
||||||
spline_cubic_set ();
|
spline_cubic_set ();
|
||||||
else if (kind==NURBS && N > 2)
|
else if (kind==NURBS && N > 2)
|
||||||
NURBS_set ();
|
NURBS_set ();
|
||||||
|
else kind=Linear;
|
||||||
}
|
}
|
||||||
else if (kind==Parametric) {
|
else if (kind==Parametric) {
|
||||||
if (p.size()!=8 && p.size()!=9)
|
if (p.size()!=8 && p.size()!=9)
|
||||||
@@ -110,7 +111,7 @@ void Curve::NURBS_set () {
|
|||||||
|
|
||||||
std::vector<double> sc_x(nbSubCurvesPoints); // X sub-curve points ( XP0,XP1,XP2, XP2,XP3,XP4, ...)
|
std::vector<double> sc_x(nbSubCurvesPoints); // X sub-curve points ( XP0,XP1,XP2, XP2,XP3,XP4, ...)
|
||||||
std::vector<double> sc_y(nbSubCurvesPoints); // Y sub-curve points ( YP0,YP1,YP2, YP2,YP3,YP4, ...)
|
std::vector<double> sc_y(nbSubCurvesPoints); // Y sub-curve points ( YP0,YP1,YP2, YP2,YP3,YP4, ...)
|
||||||
std::vector<double> sc_length(N-2); // Length of the subcurves
|
std::vector<double> sc_length(N+2); // Length of the subcurves
|
||||||
double total_length=0.;
|
double total_length=0.;
|
||||||
|
|
||||||
// Create the list of Bezier sub-curves
|
// Create the list of Bezier sub-curves
|
||||||
@@ -159,24 +160,24 @@ void Curve::NURBS_set () {
|
|||||||
total_length += length;
|
total_length += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int total_points = 0;
|
poly_x.clear();
|
||||||
for (unsigned int i=0; i < sc_x.size(); i+=3) {
|
poly_y.clear();
|
||||||
total_points += (int)(((double)ppn+N-2) * sc_length[i/3] / total_length) + (i==0 ? 1 : 0) - 1;
|
unsigned int sc_xsize=j-1;
|
||||||
}
|
|
||||||
poly_x.resize(total_points);
|
|
||||||
poly_y.resize(total_points);
|
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
// create the polyline with the number of points adapted to the X range of the sub-curve
|
// create the polyline with the number of points adapted to the X range of the sub-curve
|
||||||
for (unsigned int i=0; i < sc_x.size(); i+=3) {
|
for (unsigned int i=0; i < sc_xsize /*sc_x.size()*/; i+=3) {
|
||||||
// TODO: Speeding-up the interface by caching the polyline, instead of rebuilding it at each action on sliders !!!
|
// TODO: Speeding-up the interface by caching the polyline, instead of rebuilding it at each action on sliders !!!
|
||||||
int nbr_points = (int)(((double)ppn+N-2) * sc_length[i/3] / total_length);
|
int nbr_points = (int)(((double)(ppn+N-2) * sc_length[i/3] )/ total_length);
|
||||||
|
if (nbr_points<0){
|
||||||
|
for(int it=0;it < sc_x.size(); it+=3) printf("sc_length[%d/3]=%f \n",it,sc_length[it/3]);
|
||||||
|
printf("NURBS: error detected!\n i=%d nbr_points=%d ppn=%d N=%d sc_length[i/3]=%f total_length=%f",i,nbr_points,ppn,N,sc_length[i/3],total_length);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
// increment along the curve, not along the X axis
|
// increment along the curve, not along the X axis
|
||||||
double increment = 1.0 / (double)(nbr_points-1);
|
double increment = 1.0 / (double)(nbr_points-1);
|
||||||
if (!i) {
|
if (!i) {
|
||||||
poly_x[j ] = sc_x[i];
|
poly_x.push_back( sc_x[i]);
|
||||||
poly_y[j++] = sc_y[i];
|
poly_y.push_back(sc_y[i]);
|
||||||
}
|
}
|
||||||
for (k=1; k<(nbr_points-1); k++) {
|
for (k=1; k<(nbr_points-1); k++) {
|
||||||
double t = k*increment;
|
double t = k*increment;
|
||||||
@@ -186,12 +187,12 @@ void Curve::NURBS_set () {
|
|||||||
double tr2t = tr*2*t;
|
double tr2t = tr*2*t;
|
||||||
|
|
||||||
// adding a point to the polyline
|
// adding a point to the polyline
|
||||||
poly_x[j ] = tr2*sc_x[i] + tr2t*sc_x[i+1] + t2*sc_x[i+2];
|
poly_x.push_back( tr2*sc_x[i] + tr2t*sc_x[i+1] + t2*sc_x[i+2]);
|
||||||
poly_y[j++] = tr2*sc_y[i] + tr2t*sc_y[i+1] + t2*sc_y[i+2];
|
poly_y.push_back( tr2*sc_y[i] + tr2t*sc_y[i+1] + t2*sc_y[i+2]);
|
||||||
}
|
}
|
||||||
// adding the last point of the sub-curve
|
// adding the last point of the sub-curve
|
||||||
poly_x[j ] = sc_x[i+2];
|
poly_x.push_back( sc_x[i+2]);
|
||||||
poly_y[j++] = sc_y[i+2];
|
poly_y.push_back(sc_y[i+2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -162,6 +162,6 @@ class Curve {
|
|||||||
double getVal (double x);
|
double getVal (double x);
|
||||||
void getVal (const std::vector<double>& t, std::vector<double>& res);
|
void getVal (const std::vector<double>& t, std::vector<double>& res);
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -412,8 +412,12 @@ void CurveEditor::typeSelectionChanged () {
|
|||||||
|
|
||||||
void CurveEditor::curveChanged () {
|
void CurveEditor::curveChanged () {
|
||||||
|
|
||||||
if (cl)
|
if (cl) {
|
||||||
cl->curveChanged ();
|
if (cl->isMulti())
|
||||||
|
cl->curveChanged (this);
|
||||||
|
else
|
||||||
|
cl->curveChanged ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveEditor::curveResetPressed () {
|
void CurveEditor::curveResetPressed () {
|
||||||
|
@@ -19,10 +19,18 @@
|
|||||||
#ifndef _CURVELISTENER_
|
#ifndef _CURVELISTENER_
|
||||||
#define _CURVELISTENER_
|
#define _CURVELISTENER_
|
||||||
|
|
||||||
|
class CurveEditor;
|
||||||
|
|
||||||
class CurveListener {
|
class CurveListener {
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool multi;
|
||||||
public:
|
public:
|
||||||
virtual void curveChanged () {}
|
virtual void curveChanged () {}
|
||||||
|
virtual void curveChanged (CurveEditor* ce) {}
|
||||||
|
void setMulti(bool value) { multi = value; }
|
||||||
|
bool isMulti() { return multi; }
|
||||||
|
CurveListener() : multi(false) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -43,47 +43,50 @@ LCurve::LCurve () : ToolPanel(), brAdd(false), contrAdd(false) {
|
|||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
|
||||||
Gtk::HBox* abox = Gtk::manage (new Gtk::HBox ());
|
Gtk::HBox* abox = Gtk::manage (new Gtk::HBox ());
|
||||||
abox->set_border_width (2);
|
abox->set_border_width (2);
|
||||||
|
|
||||||
// brightness = Gtk::manage (new Adjuster (M("TP_LUMACURVE_BRIGHTNESS"), -100, 100, 0.01, 0));
|
// brightness = Gtk::manage (new Adjuster (M("TP_LUMACURVE_BRIGHTNESS"), -100, 100, 0.01, 0));
|
||||||
//contrast = Gtk::manage (new Adjuster (M("TP_LUMACURVE_CONTRAST"), -100, 100, 1, 0));
|
//contrast = Gtk::manage (new Adjuster (M("TP_LUMACURVE_CONTRAST"), -100, 100, 1, 0));
|
||||||
brightness = Gtk::manage (new Adjuster (M("TP_LABCURVE_BRIGHTNESS"), -100, 100, 0.01, 0));
|
brightness = Gtk::manage (new Adjuster (M("TP_LABCURVE_BRIGHTNESS"), -100, 100, 0.01, 0));
|
||||||
contrast = Gtk::manage (new Adjuster (M("TP_LABCURVE_CONTRAST"), -100, 100, 1, 0));
|
contrast = Gtk::manage (new Adjuster (M("TP_LABCURVE_CONTRAST"), -100, 100, 1, 0));
|
||||||
saturation = Gtk::manage (new Adjuster (M("TP_LABCURVE_SATURATION"), -100, 100, 1, 0));
|
saturation = Gtk::manage (new Adjuster (M("TP_LABCURVE_SATURATION"), -100, 100, 1, 0));
|
||||||
|
|
||||||
pack_start (*brightness);
|
pack_start (*brightness);
|
||||||
brightness->show ();
|
brightness->show ();
|
||||||
|
|
||||||
pack_start (*contrast);
|
pack_start (*contrast);
|
||||||
contrast->show ();
|
contrast->show ();
|
||||||
|
|
||||||
pack_start (*saturation);
|
pack_start (*saturation);
|
||||||
saturation->show ();
|
saturation->show ();
|
||||||
|
|
||||||
Gtk::HSeparator *hsep3 = Gtk::manage (new Gtk::HSeparator());
|
Gtk::HSeparator *hsep3 = Gtk::manage (new Gtk::HSeparator());
|
||||||
hsep3->show ();
|
hsep3->show ();
|
||||||
pack_start (*hsep3);
|
pack_start (*hsep3);
|
||||||
|
|
||||||
lshape = Gtk::manage (new CurveEditor ());
|
lshape = Gtk::manage (new CurveEditor ());
|
||||||
lshape->show ();
|
lshape->show ();
|
||||||
lshape->setCurveListener (this);
|
lshape->setCurveListener (this);
|
||||||
|
CurveListener::setMulti(true);
|
||||||
|
|
||||||
ashape = Gtk::manage (new CurveEditor ());
|
ashape = Gtk::manage (new CurveEditor ());
|
||||||
ashape->show ();
|
ashape->show ();
|
||||||
ashape->setCurveListener (this);
|
ashape->setCurveListener (this);
|
||||||
|
CurveListener::setMulti(true);
|
||||||
|
|
||||||
bshape = Gtk::manage (new CurveEditor ());
|
bshape = Gtk::manage (new CurveEditor ());
|
||||||
bshape->show ();
|
bshape->show ();
|
||||||
bshape->setCurveListener (this);
|
bshape->setCurveListener (this);
|
||||||
|
CurveListener::setMulti(true);
|
||||||
|
|
||||||
pack_start (*lshape, Gtk::PACK_SHRINK, 4);
|
pack_start (*lshape, Gtk::PACK_SHRINK, 4);
|
||||||
pack_start (*ashape, Gtk::PACK_SHRINK, 4);
|
pack_start (*ashape, Gtk::PACK_SHRINK, 4);
|
||||||
pack_start (*bshape, Gtk::PACK_SHRINK, 4);
|
pack_start (*bshape, Gtk::PACK_SHRINK, 4);
|
||||||
|
|
||||||
|
|
||||||
brightness->setAdjusterListener (this);
|
brightness->setAdjusterListener (this);
|
||||||
contrast->setAdjusterListener (this);
|
contrast->setAdjusterListener (this);
|
||||||
saturation->setAdjusterListener (this);
|
saturation->setAdjusterListener (this);
|
||||||
|
|
||||||
//channel->signal_changed().connect( sigc::mem_fun(*this, &LCurve::channel) );
|
//channel->signal_changed().connect( sigc::mem_fun(*this, &LCurve::channel) );
|
||||||
@@ -158,12 +161,15 @@ void LCurve::setDefaults (const ProcParams* defParams, const ParamsEdited* pedit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LCurve::curveChanged () {
|
void LCurve::curveChanged (CurveEditor* ce) {
|
||||||
|
|
||||||
if (listener) {
|
if (listener) {
|
||||||
listener->panelChanged (EvLLCurve, M("HISTORY_CUSTOMCURVE"));
|
if (ce == lshape)
|
||||||
listener->panelChanged (EvLaCurve, M("HISTORY_CUSTOMCURVE"));
|
listener->panelChanged (EvLLCurve, M("HISTORY_CUSTOMCURVE"));
|
||||||
listener->panelChanged (EvLbCurve, M("HISTORY_CUSTOMCURVE"));
|
if (ce == ashape)
|
||||||
|
listener->panelChanged (EvLaCurve, M("HISTORY_CUSTOMCURVE"));
|
||||||
|
if (ce == bshape)
|
||||||
|
listener->panelChanged (EvLbCurve, M("HISTORY_CUSTOMCURVE"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ class LCurve : public Gtk::VBox, public AdjusterListener, public ToolPanel, publ
|
|||||||
void setBatchMode (bool batchMode);
|
void setBatchMode (bool batchMode);
|
||||||
void setAdjusterBehavior (bool bradd, bool contradd, bool satadd);
|
void setAdjusterBehavior (bool bradd, bool contradd, bool satadd);
|
||||||
|
|
||||||
void curveChanged ();
|
void curveChanged (CurveEditor* ce);
|
||||||
void adjusterChanged (Adjuster* a, double newval);
|
void adjusterChanged (Adjuster* a, double newval);
|
||||||
void updateCurveBackgroundHistogram (unsigned* hist);
|
void updateCurveBackgroundHistogram (unsigned* hist);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user