Solving issue 2301: "segfault in pipette"

This commit is contained in:
Hombre
2014-04-24 22:35:37 +02:00
parent e693e611dc
commit c1cd47b907
3 changed files with 211 additions and 187 deletions

View File

@@ -444,7 +444,41 @@ void CropWindow::buttonRelease (int button, int num, int bstate, int x, int y) {
} }
else if (state==SEditDrag) { else if (state==SEditDrag) {
editSubscriber->button1Released(); editSubscriber->button1Released();
iarea->object = 0; if (editSubscriber) {
rtengine::Crop* crop = static_cast<rtengine::Crop*>(cropHandler.getCrop());
Coord imgPos;
action_x = x;
action_y = y;
screenCoordToImage (x, y, imgPos.x, imgPos.y);
iarea->posImage.set(imgPos.x, imgPos.y);
iarea->posScreen.set(x, y);
Coord cropPos;
screenCoordToCropBuffer(x, y, cropPos.x, cropPos.y);
if (editSubscriber->getEditingType()==ET_PIPETTE) {
iarea->object = onArea (CropImage, x, y) && !onArea (CropObserved, x, y) ? 1 : 0;
//iarea->object = cropgl && cropgl->inImageArea(iarea->posImage.x, iarea->posImage.y) ? 1 : 0;
if (iarea->object) {
crop->getPipetteData(iarea->pipetteVal, cropPos.x, cropPos.y, iarea->getPipetteRectSize());
//printf("PipetteData: %.3f %.3f %.3f\n", iarea->pipetteVal[0], iarea->pipetteVal[1], iarea->pipetteVal[2]);
}
else {
iarea->pipetteVal[0] = iarea->pipetteVal[1] = iarea->pipetteVal[2] = -1.f;
}
}
else if (editSubscriber->getEditingType()==ET_OBJECTS) {
if (onArea (CropImage, x, y))
iarea->object = crop->getObjectID(cropPos);
else
iarea->object = -1;
}
if (editSubscriber->mouseOver(bstate))
iarea->redraw ();
}
else
iarea->object = 0;
iarea->deltaImage.set(0, 0); iarea->deltaImage.set(0, 0);
iarea->deltaScreen.set(0, 0); iarea->deltaScreen.set(0, 0);
iarea->deltaPrevImage.set(0, 0); iarea->deltaPrevImage.set(0, 0);

View File

@@ -279,10 +279,10 @@ void MyDiagonalCurve::draw (int handle) {
for (unsigned int i = 1; i < nbPoints; i++) { for (unsigned int i = 1; i < nbPoints; i++) {
int pos = i*2+1; int pos = i*2+1;
double x1 = double(graphX)+1.5 + double(graphW-3)*points[pos-2]; // project (curve.x[i], 0, 1, graphW); double x1 = double(graphX)+1.5 + double(graphW-3)*points[pos-2]; // project (curve.at(i), 0, 1, graphW);
double y1 = double(graphY)-1.5 - double(graphH-3)*points[pos-1]; // project (curve.y[i], 0, 1, graphH); double y1 = double(graphY)-1.5 - double(graphH-3)*points[pos-1]; // project (curve.y.at(i)i], 0, 1, graphH);
double x2 = double(graphX)+0.5 + double(graphW-3)*points[pos]; // project (curve.x[i], 0, 1, graphW); double x2 = double(graphX)+0.5 + double(graphW-3)*points[pos]; // project (curve.at(i), 0, 1, graphW);
double y2 = double(graphY)-1.5 - double(graphH-3)*points[pos+1]; // project (curve.y[i], 0, 1, graphH); double y2 = double(graphY)-1.5 - double(graphH-3)*points[pos+1]; // project (curve.y.at(i), 0, 1, graphH);
// set the color of the line when the point is snapped to the cage // set the color of the line when the point is snapped to the cage
if (curve.x.size() == nbPoints && snapToElmt >= 1000 && ((i == (snapToElmt-1000)) || (i == (snapToElmt-999)))) if (curve.x.size() == nbPoints && snapToElmt >= 1000 && ((i == (snapToElmt-1000)) || (i == (snapToElmt-999))))
@@ -339,7 +339,7 @@ void MyDiagonalCurve::draw (int handle) {
if (curve.type!=DCT_Parametric) { if (curve.type!=DCT_Parametric) {
c = style->get_fg (state); c = style->get_fg (state);
for (int i = 0; i < (int)curve.x.size(); ++i) { for (int i = 0; i < (int)curve.x.size(); ++i) {
if (curve.x[i] == -1) continue; if (curve.x.at(i) == -1) continue;
if (snapToElmt >= 1000) { if (snapToElmt >= 1000) {
int pt = snapToElmt-1000; int pt = snapToElmt-1000;
if (i >= (pt-1) && i <= (pt+1)) if (i >= (pt-1) && i <= (pt+1))
@@ -354,8 +354,8 @@ void MyDiagonalCurve::draw (int handle) {
cr->set_source_rgb (c.get_red_p(), c.get_green_p(), c.get_blue_p()); cr->set_source_rgb (c.get_red_p(), c.get_green_p(), c.get_blue_p());
} }
double x = double(graphX+1) + double((graphW-2) * curve.x[i]); // project (curve.x[i], 0, 1, graphW); double x = double(graphX+1) + double((graphW-2) * curve.x.at(i)); // project (curve.x.at(i), 0, 1, graphW);
double y = double(graphY-1) - double((graphH-2) * curve.y[i]); // project (curve.y[i], 0, 1, graphH); double y = double(graphY-1) - double((graphH-2) * curve.y.at(i)); // project (curve.y.at(i), 0, 1, graphH);
cr->arc (x, y, RADIUS+0.5, 0, 2*M_PI); cr->arc (x, y, RADIUS+0.5, 0, 2*M_PI);
cr->fill (); cr->fill ();
@@ -434,7 +434,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
if (distanceX > minDistanceX) { if (distanceX > minDistanceX) {
/* insert a new control point */ /* insert a new control point */
if (num > 0) { if (num > 0) {
if (clampedX > curve.x[closest_point]) if (clampedX > curve.x.at(closest_point))
++closest_point; ++closest_point;
} }
itx = curve.x.begin(); itx = curve.x.begin();
@@ -445,8 +445,8 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
num++; num++;
// the graph is refreshed only if a new point is created (snaped to a pixel) // the graph is refreshed only if a new point is created (snaped to a pixel)
curve.x[closest_point] = clampedX; curve.x.at(closest_point) = clampedX;
curve.y[closest_point] = clampedY; curve.y.at(closest_point) = clampedY;
curveIsDirty = true; curveIsDirty = true;
setDirty(true); setDirty(true);
@@ -455,8 +455,8 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
} }
grab_point = closest_point; grab_point = closest_point;
lit_point = closest_point; lit_point = closest_point;
ugpX = curve.x[closest_point]; ugpX = curve.x.at(closest_point);
ugpY = curve.y[closest_point]; ugpY = curve.y.at(closest_point);
} }
if (buttonPressed) retval = true; if (buttonPressed) retval = true;
} }
@@ -479,9 +479,9 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
itx = curve.x.begin(); itx = curve.x.begin();
ity = curve.y.begin(); ity = curve.y.begin();
for (src = dst = 0; src < num; ++src) for (src = dst = 0; src < num; ++src)
if (curve.x[src] >= 0.0) { if (curve.x.at(src) >= 0.0) {
curve.x[dst] = curve.x[src]; curve.x.at(dst) = curve.x.at(src);
curve.y[dst] = curve.y[src]; curve.y.at(dst) = curve.y.at(src);
++dst; ++dst;
++itx; ++itx;
++ity; ++ity;
@@ -567,8 +567,8 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
// a point is being moved // a point is being moved
// bounds of the grabbed point // bounds of the grabbed point
double leftBound = (grab_point == 0 ) ? 0. : curve.x[grab_point-1]; double leftBound = (grab_point == 0 ) ? 0. : curve.x.at(grab_point-1);
double rightBound = (grab_point == num-1) ? 1. : curve.x[grab_point+1]; double rightBound = (grab_point == num-1) ? 1. : curve.x.at(grab_point+1);
double const bottomBound = 0.; double const bottomBound = 0.;
double const topBound = 1.; double const topBound = 1.;
@@ -578,8 +578,8 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
double topDeletionBound = topBound + minDistanceY; double topDeletionBound = topBound + minDistanceY;
// we memorize the previous position of the point, for optimization purpose // we memorize the previous position of the point, for optimization purpose
double prevPosX = curve.x[grab_point]; double prevPosX = curve.x.at(grab_point);
double prevPosY = curve.y[grab_point]; double prevPosY = curve.y.at(grab_point);
// we memorize the previous position of the point, for optimization purpose // we memorize the previous position of the point, for optimization purpose
ugpX += deltaX; ugpX += deltaX;
@@ -590,57 +590,57 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
// handling limitations along X axis // handling limitations along X axis
if (ugpX >= rightDeletionBound && (grab_point > 0 && grab_point < (num-1))) { if (ugpX >= rightDeletionBound && (grab_point > 0 && grab_point < (num-1))) {
curve.x[grab_point] = -1.; curve.x.at(grab_point) = -1.;
} }
else if (ugpX <= leftDeletionBound && (grab_point > 0 && grab_point < (num-1))) { else if (ugpX <= leftDeletionBound && (grab_point > 0 && grab_point < (num-1))) {
curve.x[grab_point] = -1.; curve.x.at(grab_point) = -1.;
} }
else else
// nextPosX is in bounds // nextPosX is in bounds
curve.x[grab_point] = CLAMP(ugpX, leftBound, rightBound); curve.x.at(grab_point) = CLAMP(ugpX, leftBound, rightBound);
// Handling limitations along Y axis // Handling limitations along Y axis
if (ugpY >= topDeletionBound && grab_point != 0 && grab_point != num-1) { if (ugpY >= topDeletionBound && grab_point != 0 && grab_point != num-1) {
curve.x[grab_point] = -1.; curve.x.at(grab_point) = -1.;
} }
else if (ugpY <= bottomDeletionBound && grab_point != 0 && grab_point != num-1) { else if (ugpY <= bottomDeletionBound && grab_point != 0 && grab_point != num-1) {
curve.x[grab_point] = -1.; curve.x.at(grab_point) = -1.;
} }
else { else {
// snapping point to specific values // snapping point to specific values
if (snapTo && curve.x[grab_point] != -1.) { if (snapTo && curve.x.at(grab_point) != -1.) {
if (grab_point > 0 && grab_point < (curve.y.size()-1)) { if (grab_point > 0 && grab_point < (curve.y.size()-1)) {
double prevX = curve.x[grab_point-1]; double prevX = curve.x.at(grab_point-1);
double prevY = curve.y[grab_point-1]; double prevY = curve.y.at(grab_point-1);
double nextX = curve.x[grab_point+1]; double nextX = curve.x.at(grab_point+1);
double nextY = curve.y[grab_point+1]; double nextY = curve.y.at(grab_point+1);
double ratio = (curve.x[grab_point]-prevX)/(nextX-prevX); double ratio = (curve.x.at(grab_point)-prevX)/(nextX-prevX);
double y = (nextY-prevY) * ratio + prevY; double y = (nextY-prevY) * ratio + prevY;
if (snapCoordinateY(y, ugpY)) snapToElmt = 1000+grab_point; if (snapCoordinateY(y, ugpY)) snapToElmt = 1000+grab_point;
} }
if (grab_point > 0) { if (grab_point > 0) {
int prevP = grab_point-1; int prevP = grab_point-1;
if (snapCoordinateY(curve.y[prevP], ugpY)) snapToElmt = prevP; if (snapCoordinateY(curve.y.at(prevP), ugpY)) snapToElmt = prevP;
} }
if (grab_point < (curve.y.size()-1)) { if (grab_point < (curve.y.size()-1)) {
int nextP = grab_point+1; int nextP = grab_point+1;
if (snapCoordinateY(curve.y[nextP], ugpY)) snapToElmt = nextP; if (snapCoordinateY(curve.y.at(nextP), ugpY)) snapToElmt = nextP;
} }
if (snapCoordinateY(1.0, ugpY)) snapToElmt = -3; if (snapCoordinateY(1.0, ugpY)) snapToElmt = -3;
if (snapCoordinateY(curve.x[grab_point], ugpY)) snapToElmt = -2; if (snapCoordinateY(curve.x.at(grab_point), ugpY)) snapToElmt = -2;
if (snapCoordinateY(0.0, ugpY)) snapToElmt = -1; if (snapCoordinateY(0.0, ugpY)) snapToElmt = -1;
curve.y[grab_point] = snapToValY; curve.y.at(grab_point) = snapToValY;
} }
else { else {
// nextPosY is in the bounds // nextPosY is in the bounds
curve.y[grab_point] = CLAMP(ugpY, 0.0, 1.0); curve.y.at(grab_point) = CLAMP(ugpY, 0.0, 1.0);
} }
} }
if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) { if (curve.x.at(grab_point) != prevPosX || curve.y.at(grab_point) != prevPosY) {
// we recalculate the curve only if we have to // we recalculate the curve only if we have to
curveIsDirty = true; curveIsDirty = true;
setDirty(true); setDirty(true);
@@ -765,7 +765,7 @@ void MyDiagonalCurve::pipetteButton1Pressed(EditDataProvider *provider, int modi
/* insert a new control point */ /* insert a new control point */
if (num > 0) { if (num > 0) {
if (clampedX > curve.x[closest_point]) if (clampedX > curve.x.at(closest_point))
++closest_point; ++closest_point;
} }
itx = curve.x.begin(); itx = curve.x.begin();
@@ -776,8 +776,8 @@ void MyDiagonalCurve::pipetteButton1Pressed(EditDataProvider *provider, int modi
num++; num++;
// the graph is refreshed only if a new point is created (snaped to a pixel) // the graph is refreshed only if a new point is created (snaped to a pixel)
curve.x[closest_point] = clampedX; curve.x.at(closest_point) = clampedX;
curve.y[closest_point] = clampedY = rtCurve.getVal(pipetteVal); curve.y.at(closest_point) = clampedY = rtCurve.getVal(pipetteVal);
curveIsDirty = true; curveIsDirty = true;
setDirty(true); setDirty(true);
@@ -786,8 +786,8 @@ void MyDiagonalCurve::pipetteButton1Pressed(EditDataProvider *provider, int modi
} }
grab_point = closest_point; grab_point = closest_point;
lit_point = closest_point; lit_point = closest_point;
ugpX = curve.x[closest_point]; ugpX = curve.x.at(closest_point);
ugpY = curve.y[closest_point]; ugpY = curve.y.at(closest_point);
} }
} }
@@ -837,21 +837,11 @@ void MyDiagonalCurve::pipetteDrag(EditDataProvider *provider, int modifierKey) {
/* graphW and graphH are the size of the graph */ /* graphW and graphH are the size of the graph */
calcDimensions(); calcDimensions();
//double minDistanceX = double(MIN_DISTANCE) / double(graphW-1);
//double minDistanceY = double(MIN_DISTANCE) / double(graphH-1);
getCursorPosition(Gdk::MOTION_NOTIFY, false, cursorX+graphX, graphY+provider->deltaScreen.y, Gdk::ModifierType(modifierKey)); getCursorPosition(Gdk::MOTION_NOTIFY, false, cursorX+graphX, graphY+provider->deltaScreen.y, Gdk::ModifierType(modifierKey));
// bounds of the grabbed point
//double const bottomBound = 0.;
//double const topBound = 1.;
//double bottomDeletionBound = bottomBound - minDistanceY;
//double topDeletionBound = topBound + minDistanceY;
// we memorize the previous position of the point, for optimization purpose // we memorize the previous position of the point, for optimization purpose
double prevPosX = curve.x[grab_point]; double prevPosX = curve.x.at(grab_point);
double prevPosY = curve.y[grab_point]; double prevPosY = curve.y.at(grab_point);
// we memorize the previous position of the point, for optimization purpose // we memorize the previous position of the point, for optimization purpose
ugpX += deltaX; ugpX += deltaX;
@@ -861,38 +851,38 @@ void MyDiagonalCurve::pipetteDrag(EditDataProvider *provider, int modifierKey) {
ugpY = CLAMP(ugpY, 0.0, 1.0); ugpY = CLAMP(ugpY, 0.0, 1.0);
// snapping point to specific values // snapping point to specific values
if (snapTo && curve.x[grab_point] != -1.) { if (snapTo && curve.x.at(grab_point) != -1.) {
if (grab_point > 0 && grab_point < (curve.y.size()-1)) { if (grab_point > 0 && grab_point < (curve.y.size()-1)) {
double prevX = curve.x[grab_point-1]; double prevX = curve.x.at(grab_point-1);
double prevY = curve.y[grab_point-1]; double prevY = curve.y.at(grab_point-1);
double nextX = curve.x[grab_point+1]; double nextX = curve.x.at(grab_point+1);
double nextY = curve.y[grab_point+1]; double nextY = curve.y.at(grab_point+1);
double ratio = (curve.x[grab_point]-prevX)/(nextX-prevX); double ratio = (curve.x.at(grab_point)-prevX)/(nextX-prevX);
double y = (nextY-prevY) * ratio + prevY; double y = (nextY-prevY) * ratio + prevY;
if (snapCoordinateY(y, ugpY)) snapToElmt = 1000+grab_point; if (snapCoordinateY(y, ugpY)) snapToElmt = 1000+grab_point;
} }
if (grab_point > 0) { if (grab_point > 0) {
int prevP = grab_point-1; int prevP = grab_point-1;
if (snapCoordinateY(curve.y[prevP], ugpY)) snapToElmt = prevP; if (snapCoordinateY(curve.y.at(prevP), ugpY)) snapToElmt = prevP;
} }
if (grab_point < (curve.y.size()-1)) { if (grab_point < (curve.y.size()-1)) {
int nextP = grab_point+1; int nextP = grab_point+1;
if (snapCoordinateY(curve.y[nextP], ugpY)) snapToElmt = nextP; if (snapCoordinateY(curve.y.at(nextP), ugpY)) snapToElmt = nextP;
} }
if (snapCoordinateY(1.0, ugpY)) snapToElmt = -3; if (snapCoordinateY(1.0, ugpY)) snapToElmt = -3;
if (snapCoordinateY(curve.x[grab_point], ugpY)) snapToElmt = -2; if (snapCoordinateY(curve.x.at(grab_point), ugpY)) snapToElmt = -2;
if (snapCoordinateY(0.0, ugpY)) snapToElmt = -1; if (snapCoordinateY(0.0, ugpY)) snapToElmt = -1;
curve.y[grab_point] = snapToValY; curve.y.at(grab_point) = snapToValY;
} }
else { else {
// nextPosY is in the bounds // nextPosY is in the bounds
curve.y[grab_point] = ugpY; curve.y.at(grab_point) = ugpY;
} }
if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) { if (curve.x.at(grab_point) != prevPosX || curve.y.at(grab_point) != prevPosY) {
// we recalculate the curve only if we have to // we recalculate the curve only if we have to
curveIsDirty = true; curveIsDirty = true;
setDirty(true); setDirty(true);
@@ -969,8 +959,8 @@ void MyDiagonalCurve::findClosestPoint() {
if (curve.type!=DCT_Parametric) { if (curve.type!=DCT_Parametric) {
for (int i = 0; i < (int)curve.x.size(); i++) { for (int i = 0; i < (int)curve.x.size(); i++) {
double dX = curve.x[i] - clampedX; double dX = curve.x.at(i) - clampedX;
double dY = curve.y[i] - clampedY; double dY = curve.y.at(i) - clampedY;
double currDistX = dX < 0. ? -dX : dX; //abs (dX); double currDistX = dX < 0. ? -dX : dX; //abs (dX);
double currDistY = dY < 0. ? -dY : dY; //abs (dY); double currDistY = dY < 0. ? -dY : dY; //abs (dY);
if (currDistX < distanceX) { if (currDistX < distanceX) {
@@ -992,7 +982,7 @@ std::vector<double> MyDiagonalCurve::getPoints () {
if (curve.type==DCT_Parametric) { if (curve.type==DCT_Parametric) {
result.push_back ((double)(DCT_Parametric)); result.push_back ((double)(DCT_Parametric));
for (int i=0; i<(int)curve.x.size(); i++) { for (int i=0; i<(int)curve.x.size(); i++) {
result.push_back (curve.x[i]); result.push_back (curve.x.at(i));
} }
} }
else { else {
@@ -1005,9 +995,9 @@ std::vector<double> MyDiagonalCurve::getPoints () {
result.push_back (double(DCT_NURBS)); result.push_back (double(DCT_NURBS));
// then we push all the points coordinate // then we push all the points coordinate
for (int i=0; i<(int)curve.x.size(); i++) { for (int i=0; i<(int)curve.x.size(); i++) {
if (curve.x[i]>=0) { if (curve.x.at(i)>=0) {
result.push_back (curve.x[i]); result.push_back (curve.x.at(i));
result.push_back (curve.y[i]); result.push_back (curve.y.at(i));
} }
} }
} }

View File

@@ -212,17 +212,17 @@ void MyFlatCurve::draw () {
//if (curve.type!=FCT_Parametric) //if (curve.type!=FCT_Parametric)
for (int i=0; i<(int)curve.x.size(); ++i) { for (int i=0; i<(int)curve.x.size(); ++i) {
if (curve.x[i] != -1.) { if (curve.x.at(i) != -1.) {
int coloredLineWidth = min( max(75,graphW)/75, 8 ); int coloredLineWidth = min( max(75,graphW)/75, 8 );
cr->set_line_width (coloredLineWidth); cr->set_line_width (coloredLineWidth);
colorProvider->colorForValue(curve.x[i], 0.5, colorCallerId, this); colorProvider->colorForValue(curve.x.at(i), 0.5, colorCallerId, this);
cr->set_source_rgb (ccRed, ccGreen, ccBlue); cr->set_source_rgb (ccRed, ccGreen, ccBlue);
if ( i==lit_point && (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointX)) ) { if ( i==lit_point && (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointX)) ) {
cr->set_line_width (2*coloredLineWidth); cr->set_line_width (2*coloredLineWidth);
} }
cr->move_to (double(graphX)+1 + innerW*curve.x[i], double(graphY-1)); cr->move_to (double(graphX)+1 + innerW*curve.x.at(i), double(graphY-1));
cr->rel_line_to (0., -innerH); cr->rel_line_to (0., -innerH);
cr->stroke (); cr->stroke ();
cr->set_line_width (coloredLineWidth); cr->set_line_width (coloredLineWidth);
@@ -236,10 +236,10 @@ void MyFlatCurve::draw () {
cr->set_line_width (2*coloredLineWidth); cr->set_line_width (2*coloredLineWidth);
} }
colorProvider->colorForValue(curve.x[i], curve.y[i], colorCallerId, this); colorProvider->colorForValue(curve.x.at(i), curve.y.at(i), colorCallerId, this);
cr->set_source_rgb (ccRed, ccGreen, ccBlue); cr->set_source_rgb (ccRed, ccGreen, ccBlue);
cr->move_to (double(graphX+1) , double(graphY-1) - innerH*curve.y[lit_point]); cr->move_to (double(graphX+1) , double(graphY-1) - innerH*curve.y.at(lit_point));
cr->rel_line_to (innerW, 0.); cr->rel_line_to (innerW, 0.);
cr->stroke (); cr->stroke ();
} }
@@ -257,7 +257,7 @@ void MyFlatCurve::draw () {
if (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointY)) { if (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointY)) {
cr->set_line_width (2.0); cr->set_line_width (2.0);
} }
cr->move_to (double(graphX)+1 + innerW*curve.x[lit_point], double(graphY-1)); cr->move_to (double(graphX)+1 + innerW*curve.x.at(lit_point), double(graphY-1));
cr->rel_line_to (0., -innerH); cr->rel_line_to (0., -innerH);
cr->stroke (); cr->stroke ();
cr->set_line_width (1.0); cr->set_line_width (1.0);
@@ -266,7 +266,7 @@ void MyFlatCurve::draw () {
if (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointY)) { if (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointY)) {
cr->set_line_width (2.0); cr->set_line_width (2.0);
} }
cr->move_to (double(graphX+1) , double(graphY-1) - innerH*curve.y[lit_point]); cr->move_to (double(graphX+1) , double(graphY-1) - innerH*curve.y.at(lit_point));
cr->rel_line_to (innerW, 0.); cr->rel_line_to (innerW, 0.);
cr->stroke (); cr->stroke ();
cr->set_line_width (1.0); cr->set_line_width (1.0);
@@ -282,9 +282,9 @@ void MyFlatCurve::draw () {
cr->stroke (); cr->stroke ();
double lineMinLength = 1. / graphW * SQUARE * 0.9; double lineMinLength = 1. / graphW * SQUARE * 0.9;
if (lit_point!=-1 && getHandles(lit_point) && curve.x[lit_point]!=-1.) { if (lit_point!=-1 && getHandles(lit_point) && curve.x.at(lit_point)!=-1.) {
double x = double(graphX+1) + innerW*curve.x[lit_point]; double x = double(graphX+1) + innerW*curve.x.at(lit_point);
double y = double(graphY) - innerH*curve.y[lit_point]; double y = double(graphY) - innerH*curve.y.at(lit_point);
double x2; double x2;
double square; double square;
bool crossingTheFrame; bool crossingTheFrame;
@@ -302,7 +302,7 @@ void MyFlatCurve::draw () {
crossingTheFrame = true; crossingTheFrame = true;
} }
x2 = double(graphX+1) + innerW*leftTanX; x2 = double(graphX+1) + innerW*leftTanX;
if (curve.x[lit_point] - leftTanX > lineMinLength || crossingTheFrame) { if (curve.x.at(lit_point) - leftTanX > lineMinLength || crossingTheFrame) {
// The left tangential vector reappear on the right side // The left tangential vector reappear on the right side
// draw the line // draw the line
cr->move_to (x, y); cr->move_to (x, y);
@@ -332,7 +332,7 @@ void MyFlatCurve::draw () {
crossingTheFrame = true; crossingTheFrame = true;
} }
x2 = double(graphX+1) +innerW*rightTanX; x2 = double(graphX+1) +innerW*rightTanX;
if (rightTanX - curve.x[lit_point] > lineMinLength || crossingTheFrame) { if (rightTanX - curve.x.at(lit_point) > lineMinLength || crossingTheFrame) {
// The left tangential vector reappear on the right side // The left tangential vector reappear on the right side
// draw the line // draw the line
cr->move_to (x, y); cr->move_to (x, y);
@@ -361,10 +361,10 @@ void MyFlatCurve::draw () {
// draw bullets // draw bullets
//if (curve.type!=FCT_Parametric) //if (curve.type!=FCT_Parametric)
for (int i = 0; i < (int)curve.x.size(); ++i) { for (int i = 0; i < (int)curve.x.size(); ++i) {
if (curve.x[i] != -1.) { if (curve.x.at(i) != -1.) {
if (i == lit_point) { if (i == lit_point) {
if (colorProvider) { if (colorProvider) {
colorProvider->colorForValue(curve.x[i], curve.y[i], colorCallerId, this); colorProvider->colorForValue(curve.x.at(i), curve.y.at(i), colorCallerId, this);
cr->set_source_rgb (ccRed, ccGreen, ccBlue); cr->set_source_rgb (ccRed, ccGreen, ccBlue);
} }
else else
@@ -373,13 +373,13 @@ void MyFlatCurve::draw () {
else if (i == snapToElmt) { else if (i == snapToElmt) {
cr->set_source_rgb (1.0, 0.0, 0.0); cr->set_source_rgb (1.0, 0.0, 0.0);
} }
else if (curve.y[i] == 0.5) else if (curve.y.at(i) == 0.5)
cr->set_source_rgb (0.0, 0.5, 0.0); cr->set_source_rgb (0.0, 0.5, 0.0);
else else
cr->set_source_rgb (c.get_red_p(), c.get_green_p(), c.get_blue_p()); cr->set_source_rgb (c.get_red_p(), c.get_green_p(), c.get_blue_p());
double x = double(graphX+1) + innerW * curve.x[i]; // project (curve.x[i], 0, 1, graphW); double x = double(graphX+1) + innerW * curve.x.at(i); // project (curve.x.at(i), 0, 1, graphW);
double y = double(graphY-1) - innerH * curve.y[i]; // project (curve.y[i], 0, 1, graphH); double y = double(graphY-1) - innerH * curve.y.at(i); // project (curve.y.at(i), 0, 1, graphH);
cr->arc (x, y, (double)RADIUS, 0, 2*M_PI); cr->arc (x, y, (double)RADIUS, 0, 2*M_PI);
cr->fill (); cr->fill ();
@@ -427,24 +427,24 @@ bool MyFlatCurve::getHandles(int n) {
if (n == -1) return false; if (n == -1) return false;
x = curve.x[n]; x = curve.x.at(n);
leftTan = curve.leftTangent[n]; leftTan = curve.leftTangent.at(n);
rightTan = curve.rightTangent[n]; rightTan = curve.rightTangent.at(n);
if (!n) { if (!n) {
// first point, the left handle is then computed with the last point's right handle // first point, the left handle is then computed with the last point's right handle
prevX = curve.x[N-1]-1.0; prevX = curve.x.at(N-1)-1.0;
nextX = curve.x[n+1]; nextX = curve.x.at(n+1);
} }
else if (n == N-1) { else if (n == N-1) {
// last point, the right handle is then computed with the first point's left handle // last point, the right handle is then computed with the first point's left handle
prevX = curve.x[n-1]; prevX = curve.x.at(n-1);
nextX = curve.x[0]+1.0; nextX = curve.x.at(0)+1.0;
} }
else { else {
// last point, the right handle is then computed with the first point's left handle // last point, the right handle is then computed with the first point's left handle
prevX = curve.x[n-1]; prevX = curve.x.at(n-1);
nextX = curve.x[n+1]; nextX = curve.x.at(n+1);
} }
if (leftTan == 0.0) leftTanX = x; if (leftTan == 0.0) leftTanX = x;
@@ -530,7 +530,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
/* insert a new control point */ /* insert a new control point */
if (num > 0) { if (num > 0) {
if (clampedX > curve.x[closest_point]) if (clampedX > curve.x.at(closest_point))
++closest_point; ++closest_point;
} }
itx = curve.x.begin(); itx = curve.x.begin();
@@ -545,10 +545,10 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
num++; num++;
// the graph is refreshed only if a new point is created // the graph is refreshed only if a new point is created
curve.x[closest_point] = clampedX; curve.x.at(closest_point) = clampedX;
curve.y[closest_point] = clampedY; curve.y.at(closest_point) = clampedY;
curve.leftTangent[closest_point] = 0.35; curve.leftTangent.at(closest_point) = 0.35;
curve.rightTangent[closest_point] = 0.35; curve.rightTangent.at(closest_point) = 0.35;
curveIsDirty = true; curveIsDirty = true;
setDirty(true); setDirty(true);
@@ -559,35 +559,35 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
// point automatically activated // point automatically activated
editedHandle = FCT_EditedHandle_CPoint; editedHandle = FCT_EditedHandle_CPoint;
ugpX = curve.x[lit_point]; ugpX = curve.x.at(lit_point);
ugpY = curve.y[lit_point]; ugpY = curve.y.at(lit_point);
break; break;
case (FCT_Area_Point): case (FCT_Area_Point):
new_type = CSMove; new_type = CSMove;
editedHandle = FCT_EditedHandle_CPoint; editedHandle = FCT_EditedHandle_CPoint;
ugpX = curve.x[lit_point]; ugpX = curve.x.at(lit_point);
ugpY = curve.y[lit_point]; ugpY = curve.y.at(lit_point);
break; break;
case (FCT_Area_H): case (FCT_Area_H):
case (FCT_Area_V): case (FCT_Area_V):
new_type = CSMove; new_type = CSMove;
editedHandle = FCT_EditedHandle_CPointUD; editedHandle = FCT_EditedHandle_CPointUD;
ugpX = curve.x[lit_point]; ugpX = curve.x.at(lit_point);
ugpY = curve.y[lit_point]; ugpY = curve.y.at(lit_point);
break; break;
case (FCT_Area_LeftTan): case (FCT_Area_LeftTan):
new_type = CSEmpty; new_type = CSEmpty;
editedHandle = FCT_EditedHandle_LeftTan; editedHandle = FCT_EditedHandle_LeftTan;
ugpX = curve.leftTangent[lit_point]; ugpX = curve.leftTangent.at(lit_point);
break; break;
case (FCT_Area_RightTan): case (FCT_Area_RightTan):
new_type = CSEmpty; new_type = CSEmpty;
editedHandle = FCT_EditedHandle_RightTan; editedHandle = FCT_EditedHandle_RightTan;
ugpX = curve.rightTangent[lit_point]; ugpX = curve.rightTangent.at(lit_point);
break; break;
default: default:
@@ -614,11 +614,11 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
itlt = curve.leftTangent.begin(); itlt = curve.leftTangent.begin();
itrt = curve.rightTangent.begin(); itrt = curve.rightTangent.begin();
for (src = dst = 0; src < num; ++src) for (src = dst = 0; src < num; ++src)
if (curve.x[src] >= 0.0) { if (curve.x.at(src) >= 0.0) {
curve.x[dst] = curve.x[src]; curve.x.at(dst) = curve.x.at(src);
curve.y[dst] = curve.y[src]; curve.y.at(dst) = curve.y.at(src);
curve.leftTangent[dst] = curve.leftTangent[src]; curve.leftTangent.at(dst) = curve.leftTangent.at(src);
curve.rightTangent[dst] = curve.rightTangent[src]; curve.rightTangent.at(dst) = curve.rightTangent.at(src);
++dst; ++dst;
++itx; ++itx;
++ity; ++ity;
@@ -729,19 +729,19 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
// display the handles // display the handles
tanHandlesDisplayed = true; tanHandlesDisplayed = true;
if (curve.x[lit_point] < 3.*minDistanceX) { if (curve.x.at(lit_point) < 3.*minDistanceX) {
// lit_point too near of the left border -> both handles are displayed on the right of the vertical line // lit_point too near of the left border -> both handles are displayed on the right of the vertical line
rightTanHandle.centerX = leftTanHandle.centerX = curve.x[lit_point] + 2.*minDistanceX; rightTanHandle.centerX = leftTanHandle.centerX = curve.x.at(lit_point) + 2.*minDistanceX;
sameSide = true; sameSide = true;
} }
else if (curve.x[lit_point] > 1.-3.*minDistanceX) { else if (curve.x.at(lit_point) > 1.-3.*minDistanceX) {
// lit_point too near of the left border -> both handles are displayed on the right of the vertical line // lit_point too near of the left border -> both handles are displayed on the right of the vertical line
rightTanHandle.centerX = leftTanHandle.centerX = curve.x[lit_point] - 2.*minDistanceX; rightTanHandle.centerX = leftTanHandle.centerX = curve.x.at(lit_point) - 2.*minDistanceX;
sameSide = true; sameSide = true;
} }
else { else {
leftTanHandle.centerX = curve.x[lit_point] - 2.*minDistanceX; leftTanHandle.centerX = curve.x.at(lit_point) - 2.*minDistanceX;
rightTanHandle.centerX = curve.x[lit_point] + 2.*minDistanceX; rightTanHandle.centerX = curve.x.at(lit_point) + 2.*minDistanceX;
} }
if (sameSide) { if (sameSide) {
if (clampedY > 1.-2.*minDistanceY) { if (clampedY > 1.-2.*minDistanceY) {
@@ -822,7 +822,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
break; break;
case (FCT_EditedHandle_LeftTan): { case (FCT_EditedHandle_LeftTan): {
double prevValue = curve.leftTangent[lit_point]; double prevValue = curve.leftTangent.at(lit_point);
ugpX -= deltaX*3; ugpX -= deltaX*3;
ugpX = CLAMP(ugpX, 0., 1.); ugpX = CLAMP(ugpX, 0., 1.);
@@ -832,13 +832,13 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
snapCoordinateX(0.35, ugpX); snapCoordinateX(0.35, ugpX);
snapCoordinateX(0.5, ugpX); snapCoordinateX(0.5, ugpX);
snapCoordinateX(1.0, ugpX); snapCoordinateX(1.0, ugpX);
curve.leftTangent[lit_point] = snapToValX; curve.leftTangent.at(lit_point) = snapToValX;
} }
else { else {
curve.leftTangent[lit_point] = ugpX; curve.leftTangent.at(lit_point) = ugpX;
} }
if (curve.leftTangent[lit_point] != prevValue) { if (curve.leftTangent.at(lit_point) != prevValue) {
curveIsDirty = true; curveIsDirty = true;
setDirty(true); setDirty(true);
draw (); draw ();
@@ -848,7 +848,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
} }
case (FCT_EditedHandle_RightTan): { case (FCT_EditedHandle_RightTan): {
double prevValue = curve.rightTangent[lit_point]; double prevValue = curve.rightTangent.at(lit_point);
ugpX += deltaX*3; ugpX += deltaX*3;
ugpX = CLAMP(ugpX, 0., 1.); ugpX = CLAMP(ugpX, 0., 1.);
@@ -858,13 +858,13 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
snapCoordinateX(0.35, ugpX); snapCoordinateX(0.35, ugpX);
snapCoordinateX(0.5, ugpX); snapCoordinateX(0.5, ugpX);
snapCoordinateX(1.0, ugpX); snapCoordinateX(1.0, ugpX);
curve.rightTangent[lit_point] = snapToValX; curve.rightTangent.at(lit_point) = snapToValX;
} }
else { else {
curve.rightTangent[lit_point] = ugpX; curve.rightTangent.at(lit_point) = ugpX;
} }
if (curve.rightTangent[lit_point] != prevValue) { if (curve.rightTangent.at(lit_point) != prevValue) {
curveIsDirty = true; curveIsDirty = true;
setDirty(true); setDirty(true);
draw (); draw ();
@@ -995,7 +995,7 @@ void MyFlatCurve::pipetteButton1Pressed(EditDataProvider *provider, int modifier
/* insert a new control point */ /* insert a new control point */
if (num > 0) { if (num > 0) {
if (clampedX > curve.x[closest_point]) if (clampedX > curve.x.at(closest_point))
++closest_point; ++closest_point;
} }
itx = curve.x.begin(); itx = curve.x.begin();
@@ -1010,10 +1010,10 @@ void MyFlatCurve::pipetteButton1Pressed(EditDataProvider *provider, int modifier
num++; num++;
// the graph is refreshed only if a new point is created // the graph is refreshed only if a new point is created
curve.x[closest_point] = clampedX; curve.x.at(closest_point) = clampedX;
curve.y[closest_point] = clampedY = rtCurve.getVal(pipetteVal); curve.y.at(closest_point) = clampedY = rtCurve.getVal(pipetteVal);
curve.leftTangent[closest_point] = 0.35; curve.leftTangent.at(closest_point) = 0.35;
curve.rightTangent[closest_point] = 0.35; curve.rightTangent.at(closest_point) = 0.35;
curveIsDirty = true; curveIsDirty = true;
setDirty(true); setDirty(true);
@@ -1024,14 +1024,14 @@ void MyFlatCurve::pipetteButton1Pressed(EditDataProvider *provider, int modifier
// point automatically activated // point automatically activated
editedHandle = FCT_EditedHandle_CPointY; editedHandle = FCT_EditedHandle_CPointY;
ugpX = curve.x[lit_point]; ugpX = curve.x.at(lit_point);
ugpY = curve.y[lit_point]; ugpY = curve.y.at(lit_point);
break; break;
} }
case (FCT_Area_V): case (FCT_Area_V):
editedHandle = FCT_EditedHandle_CPointY; editedHandle = FCT_EditedHandle_CPointY;
ugpX = curve.x[lit_point]; ugpX = curve.x.at(lit_point);
ugpY = curve.y[lit_point]; ugpY = curve.y.at(lit_point);
break; break;
default: default:
break; break;
@@ -1080,14 +1080,14 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY, bool pipetteDrag) {
double const topBound = 1.; double const topBound = 1.;
// we memorize the previous position of the point, for optimization purpose // we memorize the previous position of the point, for optimization purpose
double prevPosX = curve.x[lit_point]; double prevPosX = curve.x.at(lit_point);
double prevPosY = curve.y[lit_point]; double prevPosY = curve.y.at(lit_point);
int nbPoints = (int)curve.x.size(); int nbPoints = (int)curve.x.size();
// left and right bound rely on curve periodicity // left and right bound rely on curve periodicity
leftBound = (lit_point == 0 ) ? (periodic && !snapTo ? curve.x[nbPoints-1]-1. : 0.) : curve.x[lit_point-1]; leftBound = (lit_point == 0 ) ? (periodic && !snapTo ? curve.x.at(nbPoints-1)-1. : 0.) : curve.x.at(lit_point-1);
rightBound = (lit_point == nbPoints-1) ? (periodic && !snapTo ? curve.x[0]+1. : 1.) : curve.x[lit_point+1]; rightBound = (lit_point == nbPoints-1) ? (periodic && !snapTo ? curve.x.at(0)+1. : 1.) : curve.x.at(lit_point+1);
double leftDeletionBound = leftBound - minDistanceX; double leftDeletionBound = leftBound - minDistanceX;
double rightDeletionBound = rightBound + minDistanceX; double rightDeletionBound = rightBound + minDistanceX;
@@ -1103,11 +1103,11 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY, bool pipetteDrag) {
if (snapTo) { if (snapTo) {
if (lit_point==0) { if (lit_point==0) {
snapCoordinateX(0.0, ugpX); snapCoordinateX(0.0, ugpX);
curve.x[0] = snapToValX; curve.x.at(0) = snapToValX;
} }
else if (lit_point==(nbPoints-1)) { else if (lit_point==(nbPoints-1)) {
snapCoordinateX(1.0, ugpX); snapCoordinateX(1.0, ugpX);
curve.x[nbPoints-1] = snapToValX; curve.x.at(nbPoints-1) = snapToValX;
} }
} }
else if (lit_point==0 && ugpX<0.) { else if (lit_point==0 && ugpX<0.) {
@@ -1121,10 +1121,10 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY, bool pipetteDrag) {
rightDeletionBound += 1.; rightDeletionBound += 1.;
// adding a copy of the first point to the tail of the list // adding a copy of the first point to the tail of the list
curve.x.push_back(curve.x[0]); curve.x.push_back(curve.x.at(0));
curve.y.push_back(curve.y[0]); curve.y.push_back(curve.y.at(0));
curve.leftTangent.push_back(curve.leftTangent[0]); curve.leftTangent.push_back(curve.leftTangent.at(0));
curve.rightTangent.push_back(curve.rightTangent[0]); curve.rightTangent.push_back(curve.rightTangent.at(0));
// deleting the first point // deleting the first point
itx = curve.x.begin(); itx = curve.x.begin();
@@ -1160,10 +1160,10 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY, bool pipetteDrag) {
curve.leftTangent.insert(itlt,0); curve.leftTangent.insert(itlt,0);
curve.rightTangent.insert(itrt,0); curve.rightTangent.insert(itrt,0);
curve.x[0] = curve.x[nbPoints]; curve.x.at(0) = curve.x.at(nbPoints);
curve.y[0] = curve.y[nbPoints]; curve.y.at(0) = curve.y.at(nbPoints);
curve.leftTangent[0] = curve.leftTangent[nbPoints]; curve.leftTangent.at(0) = curve.leftTangent.at(nbPoints);
curve.rightTangent[0] = curve.rightTangent[nbPoints]; curve.rightTangent.at(0) = curve.rightTangent.at(nbPoints);
// deleting the last point // deleting the last point
curve.x.pop_back(); curve.x.pop_back();
@@ -1177,14 +1177,14 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY, bool pipetteDrag) {
// handling limitations along X axis // handling limitations along X axis
if (ugpX >= rightDeletionBound && nbPoints>2 && !snapTo) { if (ugpX >= rightDeletionBound && nbPoints>2 && !snapTo) {
curve.x[lit_point] = -1.; curve.x.at(lit_point) = -1.;
} }
else if (ugpX <= leftDeletionBound && nbPoints>2 && !snapTo) { else if (ugpX <= leftDeletionBound && nbPoints>2 && !snapTo) {
curve.x[lit_point] = -1.; curve.x.at(lit_point) = -1.;
} }
else else
// nextPosX is in bounds // nextPosX is in bounds
curve.x[lit_point] = CLAMP(ugpX, leftBound, rightBound); curve.x.at(lit_point) = CLAMP(ugpX, leftBound, rightBound);
} }
if (moveY) { if (moveY) {
@@ -1197,62 +1197,62 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY, bool pipetteDrag) {
ugpY = CLAMP(ugpY, 0.0, 1.0); ugpY = CLAMP(ugpY, 0.0, 1.0);
// snapping point to specific values // snapping point to specific values
if (snapTo && curve.x[lit_point] != -1) { if (snapTo && curve.x.at(lit_point) != -1) {
// the unclamped grabbed point is brought back in the range // the unclamped grabbed point is brought back in the range
ugpY = CLAMP(ugpY, 0.0, 1.0); ugpY = CLAMP(ugpY, 0.0, 1.0);
if (lit_point == 0) { if (lit_point == 0) {
int prevP = curve.y.size()-1; int prevP = curve.y.size()-1;
if (snapCoordinateY(curve.y[prevP], ugpY)) snapToElmt = prevP; if (snapCoordinateY(curve.y.at(prevP), ugpY)) snapToElmt = prevP;
} }
else { else {
int prevP = lit_point-1; int prevP = lit_point-1;
if (snapCoordinateY(curve.y[prevP], ugpY)) snapToElmt = prevP; if (snapCoordinateY(curve.y.at(prevP), ugpY)) snapToElmt = prevP;
} }
if (curve.y.size() > 2) { if (curve.y.size() > 2) {
if (lit_point == (curve.y.size()-1)) { if (lit_point == (curve.y.size()-1)) {
if (snapCoordinateY(curve.y[0], ugpY)) snapToElmt = 0; if (snapCoordinateY(curve.y.at(0), ugpY)) snapToElmt = 0;
} }
else { else {
int nextP = lit_point+1; int nextP = lit_point+1;
if (snapCoordinateY(curve.y[nextP], ugpY)) snapToElmt = nextP; if (snapCoordinateY(curve.y.at(nextP), ugpY)) snapToElmt = nextP;
} }
} }
if (snapCoordinateY(1.0, ugpY)) snapToElmt = -3; if (snapCoordinateY(1.0, ugpY)) snapToElmt = -3;
if (snapCoordinateY(0.5, ugpY)) snapToElmt = -2; if (snapCoordinateY(0.5, ugpY)) snapToElmt = -2;
if (snapCoordinateY(0.0, ugpY)) snapToElmt = -1; if (snapCoordinateY(0.0, ugpY)) snapToElmt = -1;
curve.y[lit_point] = snapToValY; curve.y.at(lit_point) = snapToValY;
} }
// Handling limitations along Y axis // Handling limitations along Y axis
if (ugpY >= topDeletionBound && nbPoints>2) { if (ugpY >= topDeletionBound && nbPoints>2) {
if (curve.x[lit_point] != -1.) { if (curve.x.at(lit_point) != -1.) {
deletedPointX = curve.x[lit_point]; deletedPointX = curve.x.at(lit_point);
curve.x[lit_point] = -1.; curve.x.at(lit_point) = -1.;
curve.y[lit_point] = ugpY; // This is only to force the redraw of the curve curve.y.at(lit_point) = ugpY; // This is only to force the redraw of the curve
} }
} }
else if (ugpY <= bottomDeletionBound && nbPoints>2) { else if (ugpY <= bottomDeletionBound && nbPoints>2) {
if (curve.x[lit_point] != -1.) { if (curve.x.at(lit_point) != -1.) {
deletedPointX = curve.x[lit_point]; deletedPointX = curve.x.at(lit_point);
curve.x[lit_point] = -1.; curve.x.at(lit_point) = -1.;
curve.y[lit_point] = ugpY; // This is only to force the redraw of the curve curve.y.at(lit_point) = ugpY; // This is only to force the redraw of the curve
} }
} }
else { else {
// nextPosY is in the bounds // nextPosY is in the bounds
if (!snapTo) curve.y[lit_point] = CLAMP(ugpY, 0.0, 1.0); if (!snapTo) curve.y.at(lit_point) = CLAMP(ugpY, 0.0, 1.0);
if (!moveX && curve.x[lit_point] == -1.) { if (!moveX && curve.x.at(lit_point) == -1.) {
// bring back the X value of the point if it reappear // bring back the X value of the point if it reappear
curve.x[lit_point] = deletedPointX; curve.x.at(lit_point) = deletedPointX;
} }
} }
} }
if (curve.x[lit_point] != prevPosX || curve.y[lit_point] != prevPosY) { if (curve.x.at(lit_point) != prevPosX || curve.y.at(lit_point) != prevPosY) {
// we recompute the curve only if we have to // we recompute the curve only if we have to
curveIsDirty = true; curveIsDirty = true;
setDirty(true); setDirty(true);
@@ -1359,8 +1359,8 @@ void MyFlatCurve::getMouseOverArea () {
lit_point = -1; lit_point = -1;
for (int i = 0; i < (int)curve.x.size(); i++) { for (int i = 0; i < (int)curve.x.size(); i++) {
if (curve.x[i] != -1) { if (curve.x.at(i) != -1) {
dX = curve.x[i] - preciseCursorX; dX = curve.x.at(i) - preciseCursorX;
absDX = dX>0 ? dX : -dX; absDX = dX>0 ? dX : -dX;
if (absDX < minDistX) { if (absDX < minDistX) {
minDistX = absDX; minDistX = absDX;
@@ -1369,7 +1369,7 @@ void MyFlatCurve::getMouseOverArea () {
} }
if (absDX <= minDistanceX) { if (absDX <= minDistanceX) {
aboveVLine = true; aboveVLine = true;
dY = curve.y[i] - preciseCursorY; dY = curve.y.at(i) - preciseCursorY;
dist = sqrt(dX*dX + dY*dY); dist = sqrt(dX*dX + dY*dY);
if (dist < minDist) { if (dist < minDist) {
minDist = dist; minDist = dist;
@@ -1399,7 +1399,7 @@ std::vector<double> MyFlatCurve::getPoints () {
/*if (curve.type==FCT_Parametric) { /*if (curve.type==FCT_Parametric) {
result.push_back ((double)(Parametric)); result.push_back ((double)(Parametric));
for (int i=0; i<(int)curve.x.size(); i++) { for (int i=0; i<(int)curve.x.size(); i++) {
result.push_back (curve.x[i]); result.push_back (curve.x.at(i));
} }
} }
else {*/ else {*/
@@ -1410,11 +1410,11 @@ std::vector<double> MyFlatCurve::getPoints () {
result.push_back ((double)(FCT_MinMaxCPoints)); result.push_back ((double)(FCT_MinMaxCPoints));
// then we push all the points coordinate // then we push all the points coordinate
for (int i=0; i<(int)curve.x.size(); i++) { for (int i=0; i<(int)curve.x.size(); i++) {
if (curve.x[i]>=0) { if (curve.x.at(i)>=0) {
result.push_back (curve.x[i]); result.push_back (curve.x.at(i));
result.push_back (curve.y[i]); result.push_back (curve.y.at(i));
result.push_back (curve.leftTangent[i]); result.push_back (curve.leftTangent.at(i));
result.push_back (curve.rightTangent[i]); result.push_back (curve.rightTangent.at(i));
} }
} }
//} //}