Solving issue 1528: "HSV equalizer channels sometimes can't be switched properly"
This commit is contained in:
@@ -332,9 +332,9 @@ void DiagonalCurveEditorSubGroup::switchGUI() {
|
|||||||
customCurve->setPoints (dCurve->customCurveEd);
|
customCurve->setPoints (dCurve->customCurveEd);
|
||||||
customCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
|
customCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
|
||||||
customCurve->setColoredBar(leftBar, bottomBar);
|
customCurve->setColoredBar(leftBar, bottomBar);
|
||||||
|
customCurve->forceResize();
|
||||||
parent->pack_start (*customCurveBox);
|
parent->pack_start (*customCurveBox);
|
||||||
customCurveBox->check_resize();
|
customCurveBox->check_resize();
|
||||||
customCurve->forceResize();
|
|
||||||
break;
|
break;
|
||||||
case (DCT_Parametric):
|
case (DCT_Parametric):
|
||||||
{
|
{
|
||||||
@@ -362,17 +362,17 @@ void DiagonalCurveEditorSubGroup::switchGUI() {
|
|||||||
shcSelector->setBgGradient(bgGradient);
|
shcSelector->setBgGradient(bgGradient);
|
||||||
shcSelector->setMargins( (leftBar ? MyCurve::getBarWidth()+CBAR_MARGIN : RADIUS), RADIUS );
|
shcSelector->setMargins( (leftBar ? MyCurve::getBarWidth()+CBAR_MARGIN : RADIUS), RADIUS );
|
||||||
paramCurve->setColoredBar(leftBar, NULL);
|
paramCurve->setColoredBar(leftBar, NULL);
|
||||||
parent->pack_start (*paramCurveBox);
|
|
||||||
paramCurve->forceResize();
|
paramCurve->forceResize();
|
||||||
|
parent->pack_start (*paramCurveBox);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (DCT_NURBS):
|
case (DCT_NURBS):
|
||||||
NURBSCurve->setPoints (dCurve->NURBSCurveEd);
|
NURBSCurve->setPoints (dCurve->NURBSCurveEd);
|
||||||
NURBSCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
|
NURBSCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
|
||||||
NURBSCurve->setColoredBar(leftBar, bottomBar);
|
NURBSCurve->setColoredBar(leftBar, bottomBar);
|
||||||
|
NURBSCurve->forceResize();
|
||||||
parent->pack_start (*NURBSCurveBox);
|
parent->pack_start (*NURBSCurveBox);
|
||||||
NURBSCurveBox->check_resize();
|
NURBSCurveBox->check_resize();
|
||||||
NURBSCurve->forceResize();
|
|
||||||
break;
|
break;
|
||||||
default: // (DCT_Linear, DCT_Unchanged)
|
default: // (DCT_Linear, DCT_Unchanged)
|
||||||
// ... do nothing
|
// ... do nothing
|
||||||
@@ -407,13 +407,13 @@ void DiagonalCurveEditorSubGroup::savePressed () {
|
|||||||
|
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
if (p[ix]==(double)(DCT_Linear))
|
if (p[ix]==(double)(DCT_Linear))
|
||||||
f << "Linear\n";
|
f << "Linear" << std::endl;
|
||||||
else if (p[ix]==(double)(DCT_Spline))
|
else if (p[ix]==(double)(DCT_Spline))
|
||||||
f << "Spline\n";
|
f << "Spline" << std::endl;
|
||||||
else if (p[ix]==(double)(DCT_NURBS))
|
else if (p[ix]==(double)(DCT_NURBS))
|
||||||
f << "NURBS\n";
|
f << "NURBS" << std::endl;
|
||||||
else if (p[ix]==(double)(DCT_Parametric))
|
else if (p[ix]==(double)(DCT_Parametric))
|
||||||
f << "Parametric\n";
|
f << "Parametric" << std::endl;
|
||||||
if (p[ix]==(double)(DCT_Parametric)) {
|
if (p[ix]==(double)(DCT_Parametric)) {
|
||||||
ix++;
|
ix++;
|
||||||
for (unsigned int i=0; i<p.size()-1; i++, ix++)
|
for (unsigned int i=0; i<p.size()-1; i++, ix++)
|
||||||
|
@@ -171,9 +171,9 @@ void FlatCurveEditorSubGroup::switchGUI() {
|
|||||||
CPointsCurve->setPoints (dCurve->controlPointsCurveEd);
|
CPointsCurve->setPoints (dCurve->controlPointsCurveEd);
|
||||||
CPointsCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
|
CPointsCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
|
||||||
CPointsCurve->setColoredBar(leftBar, bottomBar);
|
CPointsCurve->setColoredBar(leftBar, bottomBar);
|
||||||
|
CPointsCurve->forceResize();
|
||||||
parent->pack_start (*CPointsCurveBox);
|
parent->pack_start (*CPointsCurveBox);
|
||||||
CPointsCurveBox->check_resize();
|
CPointsCurveBox->check_resize();
|
||||||
CPointsCurve->forceResize();
|
|
||||||
break;
|
break;
|
||||||
default: // (DCT_Linear, DCT_Unchanged)
|
default: // (DCT_Linear, DCT_Unchanged)
|
||||||
// ... do nothing
|
// ... do nothing
|
||||||
@@ -202,9 +202,9 @@ void FlatCurveEditorSubGroup::savePressed () {
|
|||||||
|
|
||||||
int ix = 0;
|
int ix = 0;
|
||||||
if (p[ix]==(double)(FCT_Linear))
|
if (p[ix]==(double)(FCT_Linear))
|
||||||
f << "Linear\n";
|
f << "Linear" << std::endl;
|
||||||
else if (p[ix]==(double)(FCT_MinMaxCPoints))
|
else if (p[ix]==(double)(FCT_MinMaxCPoints))
|
||||||
f << "ControlPoints\n";
|
f << "ControlPoints" << std::endl;
|
||||||
ix++;
|
ix++;
|
||||||
for (unsigned int i=0; i<p.size()/2; i++, ix+=2)
|
for (unsigned int i=0; i<p.size()/2; i++, ix+=2)
|
||||||
f << p[ix] << ' ' << p[ix+1] << std::endl;
|
f << p[ix] << ' ' << p[ix+1] << std::endl;
|
||||||
@@ -291,7 +291,7 @@ void FlatCurveEditorSubGroup::storeCurveValues (CurveEditor* ce, const std::vect
|
|||||||
const std::vector<double> FlatCurveEditorSubGroup::getCurveFromGUI (int type) {
|
const std::vector<double> FlatCurveEditorSubGroup::getCurveFromGUI (int type) {
|
||||||
switch ((FlatCurveType)type) {
|
switch ((FlatCurveType)type) {
|
||||||
case (FCT_MinMaxCPoints):
|
case (FCT_MinMaxCPoints):
|
||||||
return CPointsCurve->getPoints ();
|
return CPointsCurve->getPoints ();
|
||||||
default: {
|
default: {
|
||||||
// linear and other solutions
|
// linear and other solutions
|
||||||
std::vector<double> lcurve (1);
|
std::vector<double> lcurve (1);
|
||||||
|
@@ -35,6 +35,7 @@ MyCurve::MyCurve () : listener(NULL) {
|
|||||||
colorProvider = NULL;
|
colorProvider = NULL;
|
||||||
sized = RS_Pending;
|
sized = RS_Pending;
|
||||||
snapToElmt = -100;
|
snapToElmt = -100;
|
||||||
|
curveIsDirty = true;
|
||||||
|
|
||||||
set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
|
set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
|
||||||
add_events(Gdk::EXPOSURE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK);
|
add_events(Gdk::EXPOSURE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK);
|
||||||
|
@@ -81,7 +81,7 @@ class MyCurve : public Gtk::DrawingArea, public BackBuffer, public ColorCaller {
|
|||||||
* -2 : identity value
|
* -2 : identity value
|
||||||
* -1 : minimum value
|
* -1 : minimum value
|
||||||
* [0;1000[ : control point that it's snapped to
|
* [0;1000[ : control point that it's snapped to
|
||||||
* >=1000 : moved control point which is snapped to to the line made by it neighbors
|
* >=1000 : moved control point which snaps to the line made by its previous and next point
|
||||||
*/
|
*/
|
||||||
int snapToElmt;
|
int snapToElmt;
|
||||||
bool snapTo;
|
bool snapTo;
|
||||||
@@ -89,6 +89,7 @@ class MyCurve : public Gtk::DrawingArea, public BackBuffer, public ColorCaller {
|
|||||||
double snapToVal;
|
double snapToVal;
|
||||||
MyCurveIdleHelper* mcih;
|
MyCurveIdleHelper* mcih;
|
||||||
enum ResizeState sized;
|
enum ResizeState sized;
|
||||||
|
bool curveIsDirty;
|
||||||
|
|
||||||
virtual std::vector<double> get_vector (int veclen) = 0;
|
virtual std::vector<double> get_vector (int veclen) = 0;
|
||||||
int getGraphMinSize() { return GRAPH_SIZE + RADIUS + 1; }
|
int getGraphMinSize() { return GRAPH_SIZE + RADIUS + 1; }
|
||||||
@@ -107,6 +108,7 @@ class MyCurve : public Gtk::DrawingArea, public BackBuffer, public ColorCaller {
|
|||||||
void updateBackgroundHistogram (LUTu & hist) {return;} ;
|
void updateBackgroundHistogram (LUTu & hist) {return;} ;
|
||||||
void forceResize() { sized = RS_Force; }
|
void forceResize() { sized = RS_Force; }
|
||||||
void refresh();
|
void refresh();
|
||||||
|
void setCurveDirty () { curveIsDirty = true; }
|
||||||
void styleChanged (const Glib::RefPtr<Gtk::Style>& style);
|
void styleChanged (const Glib::RefPtr<Gtk::Style>& style);
|
||||||
virtual std::vector<double> getPoints () = 0;
|
virtual std::vector<double> getPoints () = 0;
|
||||||
virtual void setPoints (const std::vector<double>& p) = 0;
|
virtual void setPoints (const std::vector<double>& p) = 0;
|
||||||
|
@@ -100,7 +100,7 @@ void MyDiagonalCurve::interpolate () {
|
|||||||
point.resize (nbPoints);
|
point.resize (nbPoints);
|
||||||
std::vector<double> vector = get_vector (nbPoints);
|
std::vector<double> vector = get_vector (nbPoints);
|
||||||
for (int i = 0; i < nbPoints; ++i) {
|
for (int i = 0; i < nbPoints; ++i) {
|
||||||
float currX = float(i)/float(nbPoints-1);
|
float currX = float(i)/float(nbPoints-1);
|
||||||
point.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
point.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
||||||
}
|
}
|
||||||
upoint.clear ();
|
upoint.clear ();
|
||||||
@@ -114,31 +114,33 @@ void MyDiagonalCurve::interpolate () {
|
|||||||
curve.x.at(activeParam-1) = 100;
|
curve.x.at(activeParam-1) = 100;
|
||||||
vector = get_vector (nbPoints);
|
vector = get_vector (nbPoints);
|
||||||
for (int i = 0; i < nbPoints; ++i) {
|
for (int i = 0; i < nbPoints; ++i) {
|
||||||
float currX = float(i)/float(nbPoints-1);
|
float currX = float(i)/float(nbPoints-1);
|
||||||
upoint.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
upoint.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
||||||
}
|
}
|
||||||
curve.x.at(activeParam-1) = -100;
|
curve.x.at(activeParam-1) = -100;
|
||||||
vector = get_vector (nbPoints);
|
vector = get_vector (nbPoints);
|
||||||
for (int i = 0; i < nbPoints; ++i) {
|
for (int i = 0; i < nbPoints; ++i) {
|
||||||
float currX = float(i)/float(nbPoints-1);
|
float currX = float(i)/float(nbPoints-1);
|
||||||
lpoint.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
lpoint.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
||||||
}
|
}
|
||||||
curve.x.at(activeParam-1) = tmp;
|
curve.x.at(activeParam-1) = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curveIsDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyDiagonalCurve::draw (int handle) {
|
void MyDiagonalCurve::draw (int handle) {
|
||||||
if (!isDirty()) {
|
if (!isDirty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::Window > win = get_window();
|
Glib::RefPtr<Gdk::Window > win = get_window();
|
||||||
if (!surfaceCreated() || !win)
|
if (!surfaceCreated() || !win)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// re-calculate curve if dimensions changed
|
// re-calculate curve if dimensions changed
|
||||||
if (prevGraphW != graphW || prevGraphH != graphH || int(point.size()) != graphW-2)
|
if (curveIsDirty || prevGraphW != graphW || prevGraphH != graphH || int(point.size()) != graphW-2)
|
||||||
interpolate ();
|
interpolate ();
|
||||||
|
|
||||||
Gtk::StateType state = !is_sensitive() ? Gtk::STATE_INSENSITIVE : Gtk::STATE_NORMAL;
|
Gtk::StateType state = !is_sensitive() ? Gtk::STATE_INSENSITIVE : Gtk::STATE_NORMAL;
|
||||||
@@ -159,7 +161,7 @@ void MyDiagonalCurve::draw (int handle) {
|
|||||||
unsigned int valMax = 0;
|
unsigned int valMax = 0;
|
||||||
for (int i=0; i<256; i++)
|
for (int i=0; i<256; i++)
|
||||||
if (bghist[i]>valMax)
|
if (bghist[i]>valMax)
|
||||||
valMax = bghist[i];
|
valMax = bghist[i];
|
||||||
// draw histogram
|
// draw histogram
|
||||||
cr->set_line_width (1.0);
|
cr->set_line_width (1.0);
|
||||||
double stepSize = (graphW-3) / 255.0;
|
double stepSize = (graphW-3) / 255.0;
|
||||||
@@ -175,7 +177,7 @@ void MyDiagonalCurve::draw (int handle) {
|
|||||||
//if (i>0)
|
//if (i>0)
|
||||||
cr->line_to (double(graphX)+1.5+double(i)*stepSize, double(graphY-1)-val);
|
cr->line_to (double(graphX)+1.5+double(i)*stepSize, double(graphY-1)-val);
|
||||||
}
|
}
|
||||||
cr->line_to (double(graphX)+1.5+255.*stepSize, double(graphY-1));
|
cr->line_to (double(graphX)+1.5+255.*stepSize, double(graphY-1));
|
||||||
cr->close_path();
|
cr->close_path();
|
||||||
cr->fill ();
|
cr->fill ();
|
||||||
}
|
}
|
||||||
@@ -268,7 +270,7 @@ void MyDiagonalCurve::draw (int handle) {
|
|||||||
// draw the left colored bar
|
// draw the left colored bar
|
||||||
if (leftBar) {
|
if (leftBar) {
|
||||||
// first the background
|
// first the background
|
||||||
int bWidth = getBarWidth();
|
int bWidth = getBarWidth();
|
||||||
BackBuffer *bb = this;
|
BackBuffer *bb = this;
|
||||||
leftBar->setDrawRectangle(win, 1, graphY-graphH+1, bWidth-2, graphH-2);
|
leftBar->setDrawRectangle(win, 1, graphY-graphH+1, bWidth-2, graphH-2);
|
||||||
leftBar->expose(bb);
|
leftBar->expose(bb);
|
||||||
@@ -283,8 +285,8 @@ void MyDiagonalCurve::draw (int handle) {
|
|||||||
// draw the bottom colored bar
|
// draw the bottom colored bar
|
||||||
if (bottomBar) {
|
if (bottomBar) {
|
||||||
// first the background
|
// first the background
|
||||||
int bWidth = getBarWidth();
|
int bWidth = getBarWidth();
|
||||||
BackBuffer *bb = this;
|
BackBuffer *bb = this;
|
||||||
bottomBar->setDrawRectangle(win, graphX+1, graphY+CBAR_MARGIN+1, graphW-2, bWidth-2);
|
bottomBar->setDrawRectangle(win, graphX+1, graphY+CBAR_MARGIN+1, graphW-2, bWidth-2);
|
||||||
bottomBar->expose(bb);
|
bottomBar->expose(bb);
|
||||||
|
|
||||||
@@ -368,11 +370,13 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
|||||||
}
|
}
|
||||||
sized = RS_Pending;
|
sized = RS_Pending;
|
||||||
// setDrawRectangle will allocate the backbuffer Surface
|
// setDrawRectangle will allocate the backbuffer Surface
|
||||||
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height()))
|
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height())) {
|
||||||
interpolate ();
|
setDirty(true);
|
||||||
|
curveIsDirty = true;
|
||||||
|
}
|
||||||
draw (lit_point);
|
draw (lit_point);
|
||||||
GdkRectangle *rectangle = &(event->expose.area);
|
GdkRectangle *rectangle = &(event->expose.area);
|
||||||
copySurface(win, rectangle);
|
copySurface(win, rectangle);
|
||||||
|
|
||||||
retval = true;
|
retval = true;
|
||||||
break;
|
break;
|
||||||
@@ -407,7 +411,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
|||||||
curve.x[closest_point] = clampedX;
|
curve.x[closest_point] = clampedX;
|
||||||
curve.y[closest_point] = clampedY;
|
curve.y[closest_point] = clampedY;
|
||||||
|
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
draw (closest_point);
|
draw (closest_point);
|
||||||
notifyListener ();
|
notifyListener ();
|
||||||
@@ -449,7 +453,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
|||||||
if (curve.x.empty()) {
|
if (curve.x.empty()) {
|
||||||
curve.x.push_back (0);
|
curve.x.push_back (0);
|
||||||
curve.y.push_back (0);
|
curve.y.push_back (0);
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
draw (lit_point);
|
draw (lit_point);
|
||||||
}
|
}
|
||||||
@@ -598,7 +602,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
|||||||
|
|
||||||
if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) {
|
if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) {
|
||||||
// we recalculate the curve only if we have to
|
// we recalculate the curve only if we have to
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
draw (lit_point);
|
draw (lit_point);
|
||||||
notifyListener ();
|
notifyListener ();
|
||||||
@@ -751,6 +755,7 @@ void MyDiagonalCurve::setPoints (const std::vector<double>& p) {
|
|||||||
}
|
}
|
||||||
activeParam = -1;
|
activeParam = -1;
|
||||||
}
|
}
|
||||||
|
curveIsDirty = true;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
queue_draw ();
|
queue_draw ();
|
||||||
}
|
}
|
||||||
@@ -818,7 +823,7 @@ void MyDiagonalCurve::reset() {
|
|||||||
curve.y.at(1) = 1.;
|
curve.y.at(1) = 1.;
|
||||||
grab_point = -1;
|
grab_point = -1;
|
||||||
lit_point = -1;
|
lit_point = -1;
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
break;
|
break;
|
||||||
case DCT_Parametric :
|
case DCT_Parametric :
|
||||||
curve.x.resize(7);
|
curve.x.resize(7);
|
||||||
@@ -833,11 +838,11 @@ void MyDiagonalCurve::reset() {
|
|||||||
curve.x.at(6) = 0.00;
|
curve.x.at(6) = 0.00;
|
||||||
grab_point = -1; // not sure that it's necessary
|
grab_point = -1; // not sure that it's necessary
|
||||||
lit_point = -1; // not sure that it's necessary
|
lit_point = -1; // not sure that it's necessary
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
draw(-1);
|
draw(-1);
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,8 @@ MyFlatCurve::MyFlatCurve () {
|
|||||||
|
|
||||||
graphW = get_allocation().get_width() - RADIUS * 2;
|
graphW = get_allocation().get_width() - RADIUS * 2;
|
||||||
graphH = get_allocation().get_height() - RADIUS * 2;
|
graphH = get_allocation().get_height() - RADIUS * 2;
|
||||||
prevGraphW = 0;
|
prevGraphW = graphW;
|
||||||
prevGraphH = 0;
|
prevGraphH = graphH;
|
||||||
lit_point = -1;
|
lit_point = -1;
|
||||||
closest_point = 0;
|
closest_point = 0;
|
||||||
buttonPressed = false;
|
buttonPressed = false;
|
||||||
@@ -78,25 +78,27 @@ void MyFlatCurve::interpolate () {
|
|||||||
int nbPoints = graphW-2;
|
int nbPoints = graphW-2;
|
||||||
point.resize (nbPoints);
|
point.resize (nbPoints);
|
||||||
std::vector<double> vector = get_vector (nbPoints);
|
std::vector<double> vector = get_vector (nbPoints);
|
||||||
for (int i = 0; i < int(point.size()); ++i) {
|
for (int i = 0; i < nbPoints; ++i) {
|
||||||
float currX = float(i)/float(nbPoints-1);
|
float currX = float(i)/float(nbPoints-1);
|
||||||
point.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
point.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
||||||
}
|
}
|
||||||
upoint.clear ();
|
upoint.clear ();
|
||||||
lpoint.clear ();
|
lpoint.clear ();
|
||||||
|
|
||||||
|
curveIsDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFlatCurve::draw () {
|
void MyFlatCurve::draw () {
|
||||||
if (!isDirty()) {
|
if (!isDirty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::Window> win = get_window();
|
Glib::RefPtr<Gdk::Window> win = get_window();
|
||||||
if (!surfaceCreated() || !win)
|
if (!surfaceCreated() || !win)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// re-calculate curve if dimensions changed
|
// re-calculate curve if dimensions changed
|
||||||
if (prevGraphW != graphW || prevGraphH != graphH || (int)point.size() != graphW-2)
|
if (curveIsDirty || prevGraphW != graphW || prevGraphH != graphH || (int)point.size() != graphW-2)
|
||||||
interpolate ();
|
interpolate ();
|
||||||
|
|
||||||
double innerW = double(graphW-2);
|
double innerW = double(graphW-2);
|
||||||
@@ -135,7 +137,7 @@ void MyFlatCurve::draw () {
|
|||||||
// draw the left colored bar
|
// draw the left colored bar
|
||||||
if (leftBar) {
|
if (leftBar) {
|
||||||
// first the background
|
// first the background
|
||||||
int bWidth = getBarWidth();
|
int bWidth = getBarWidth();
|
||||||
BackBuffer *bb = this;
|
BackBuffer *bb = this;
|
||||||
leftBar->setDrawRectangle(win, 1, graphY-graphH+1, bWidth-2, graphH-2);
|
leftBar->setDrawRectangle(win, 1, graphY-graphH+1, bWidth-2, graphH-2);
|
||||||
leftBar->expose(bb);
|
leftBar->expose(bb);
|
||||||
@@ -150,7 +152,7 @@ void MyFlatCurve::draw () {
|
|||||||
// draw the bottom colored bar
|
// draw the bottom colored bar
|
||||||
if (bottomBar) {
|
if (bottomBar) {
|
||||||
// first the background
|
// first the background
|
||||||
int bWidth = getBarWidth();
|
int bWidth = getBarWidth();
|
||||||
BackBuffer *bb = this;
|
BackBuffer *bb = this;
|
||||||
bottomBar->setDrawRectangle(win, graphX+1, graphY+CBAR_MARGIN+1, graphW-2, bWidth-2);
|
bottomBar->setDrawRectangle(win, graphX+1, graphY+CBAR_MARGIN+1, graphW-2, bWidth-2);
|
||||||
bottomBar->expose(bb);
|
bottomBar->expose(bb);
|
||||||
@@ -371,7 +373,7 @@ void MyFlatCurve::draw () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDirty(false);
|
setDirty(false);
|
||||||
queue_draw();
|
queue_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -455,13 +457,15 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
|||||||
}
|
}
|
||||||
sized = RS_Pending;
|
sized = RS_Pending;
|
||||||
// setDrawRectangle will allocate the backbuffer Surface
|
// setDrawRectangle will allocate the backbuffer Surface
|
||||||
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height()))
|
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height())) {
|
||||||
interpolate ();
|
setDirty(true);
|
||||||
|
curveIsDirty = true;
|
||||||
|
}
|
||||||
draw ();
|
draw ();
|
||||||
GdkRectangle *rectangle = &(event->expose.area);
|
GdkRectangle *rectangle = &(event->expose.area);
|
||||||
copySurface(win, rectangle);
|
copySurface(win, rectangle);
|
||||||
|
|
||||||
retval = true;
|
retval = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,7 +510,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
|||||||
curve.leftTangent[closest_point] = 0.35;
|
curve.leftTangent[closest_point] = 0.35;
|
||||||
curve.rightTangent[closest_point] = 0.35;
|
curve.rightTangent[closest_point] = 0.35;
|
||||||
|
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
draw ();
|
draw ();
|
||||||
notifyListener ();
|
notifyListener ();
|
||||||
@@ -595,7 +599,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
|||||||
curve.y.push_back (0.5);
|
curve.y.push_back (0.5);
|
||||||
curve.leftTangent.push_back (0.3);
|
curve.leftTangent.push_back (0.3);
|
||||||
curve.rightTangent.push_back (0.3);
|
curve.rightTangent.push_back (0.3);
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -798,7 +802,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (curve.leftTangent[lit_point] != prevValue) {
|
if (curve.leftTangent[lit_point] != prevValue) {
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
draw ();
|
draw ();
|
||||||
notifyListener ();
|
notifyListener ();
|
||||||
@@ -823,7 +827,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (curve.rightTangent[lit_point] != prevValue) {
|
if (curve.rightTangent[lit_point] != prevValue) {
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
draw ();
|
draw ();
|
||||||
notifyListener ();
|
notifyListener ();
|
||||||
@@ -1034,7 +1038,7 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY) {
|
|||||||
|
|
||||||
if (curve.x[lit_point] != prevPosX || curve.y[lit_point] != prevPosY) {
|
if (curve.x[lit_point] != prevPosX || curve.y[lit_point] != prevPosY) {
|
||||||
// we recompute the curve only if we have to
|
// we recompute the curve only if we have to
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
draw ();
|
draw ();
|
||||||
notifyListener ();
|
notifyListener ();
|
||||||
@@ -1216,6 +1220,7 @@ void MyFlatCurve::setPoints (const std::vector<double>& p) {
|
|||||||
curve.rightTangent.push_back (p[ix++]);
|
curve.rightTangent.push_back (p[ix++]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
curveIsDirty = true;
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
queue_draw ();
|
queue_draw ();
|
||||||
}
|
}
|
||||||
@@ -1233,30 +1238,29 @@ void MyFlatCurve::reset() {
|
|||||||
case FCT_MinMaxCPoints :
|
case FCT_MinMaxCPoints :
|
||||||
defaultCurve();
|
defaultCurve();
|
||||||
lit_point = -1;
|
lit_point = -1;
|
||||||
interpolate ();
|
curveIsDirty = true;
|
||||||
break;
|
break;
|
||||||
//case Parametric :
|
//case Parametric :
|
||||||
// Nothing to do (?)
|
// Nothing to do (?)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFlatCurve::defaultCurve () {
|
void MyFlatCurve::defaultCurve () {
|
||||||
|
|
||||||
curve.x.clear();
|
curve.x.resize(6);
|
||||||
curve.y.clear();
|
curve.y.resize(6);
|
||||||
curve.leftTangent.clear();
|
curve.leftTangent.resize(6);
|
||||||
curve.rightTangent.clear();
|
curve.rightTangent.resize(6);
|
||||||
|
|
||||||
// Point for RGBCMY colors
|
// Point for RGBCMY colors
|
||||||
for (int i=0; i<6; i++) {
|
for (int i=0; i<6; i++) {
|
||||||
curve.x.push_back((1./6.)*i);
|
curve.x.at(i) = (1./6.)*i;
|
||||||
curve.y.push_back(0.5);
|
curve.y.at(i) = 0.5;
|
||||||
curve.leftTangent.push_back(0.35);
|
curve.leftTangent.at(i) = 0.35;
|
||||||
curve.rightTangent.push_back(0.35);
|
curve.rightTangent.at(i) = 0.35;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user