summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-09-07 18:28:40 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-09-07 18:28:40 +0200
commit23e183dbfa08a06a0ab73b17f002dce3a97fde15 (patch)
tree3e30a6c22315738310890c6e7e263d1f554e82ff /src
parent4597762a61d5290094736e0d8761fa80dda13555 (diff)
style
Diffstat (limited to 'src')
-rw-r--r--src/CurveEditor.cxx46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/CurveEditor.cxx b/src/CurveEditor.cxx
index a0f4057..ec8fc25 100644
--- a/src/CurveEditor.cxx
+++ b/src/CurveEditor.cxx
@@ -38,7 +38,8 @@ CurveEditor::draw() {
fl_xyline(x(), y() + h() / 2, x() + w());
fl_yxline(x() + w() / 2, y(), y() + h());
- if (n < 3) return;
+ if (n < 3)
+ return;
fl_push_clip(x(), y(), w(), h());
fl_color(FL_WHITE);
@@ -51,10 +52,9 @@ CurveEditor::draw() {
}
fl_end_line();
- for (int i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++)
fl_rectf((int) rint(x() + w() * X[i] - 2),
(int) rint(y() + h() - h() * Y[i] - 2), 4, 4);
- }
fl_pop_clip();
}
@@ -63,13 +63,12 @@ int
CurveEditor::handle(int event) {
double mark_x = (double) (Fl::event_x() - x()) / w();
double mark_y = 1.0 - (double) (Fl::event_y() - y()) / h();
- int i;
switch (event) {
case FL_PUSH:
Fl::focus(this);
if (Fl::event_button() == 1) {
- for (i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++) {
if (mark_x >= X[i] - 0.02 && mark_x <= X[i] + 0.02) {
marked_point = i;
move_point(i, mark_x, mark_y);
@@ -82,18 +81,19 @@ CurveEditor::handle(int event) {
}
return 1;
case FL_DRAG:
- if (marked_point < 0) return 1;
+ if (marked_point < 0)
+ return 1;
if (marked_point > 0 && mark_x <= X[marked_point - 1] ||
marked_point < n - 1 && mark_x >= X[marked_point + 1]) {
remove_point(marked_point);
marked_point = -1;
- } else {
+ } else
move_point(marked_point, mark_x, mark_y);
- }
return 1;
case FL_RELEASE:
if (marked_point >= 0) {
- if (cb) cb(this, cb_data);
+ if (cb)
+ cb(this, cb_data);
marked_point = -1;
}
return 1;
@@ -109,15 +109,15 @@ int
CurveEditor::add_point(double _x, double _y) {
int i;
- if (_x < 0.0 || _x > 1.0 || _y < 0.0 || _y > 1.0) {
+ if (_x < 0.0 || _x > 1.0 || _y < 0.0 || _y > 1.0)
return -1;
- }
X = (double*) realloc(X, (n + 1) * sizeof(double));
Y = (double*) realloc(Y, (n + 1) * sizeof(double));
for (i = 0; i < n; i++) {
- if (_x == X[i]) return -1;
+ if (_x == X[i])
+ return -1;
if (_x < X[i]) {
memmove(&X[i + 1], &X[i], sizeof(double) * (n - i));
memmove(&Y[i + 1], &Y[i], sizeof(double) * (n - i));
@@ -128,7 +128,6 @@ CurveEditor::add_point(double _x, double _y) {
X[i] = _x;
Y[i] = _y;
n++;
-
init();
return i;
@@ -136,8 +135,10 @@ CurveEditor::add_point(double _x, double _y) {
void
CurveEditor::init() {
- if (n < 3) return;
- if (spline) gsl_spline_free(spline);
+ if (n < 3)
+ return;
+ if (spline)
+ gsl_spline_free(spline);
spline = gsl_spline_alloc(gsl_interp_cspline, n);
gsl_spline_init(spline, X, Y, n);
redraw();
@@ -148,9 +149,8 @@ CurveEditor::move_point(int i, double _x, double _y) {
if (i >= n ||
(_x < 0.0 || _x > 1.0 || _y < 0.0 || _y > 1.0) ||
(i < n - 1 && _x >= X[i + 1]) ||
- (i > 0 && _x <= X[i - 1])) {
+ (i > 0 && _x <= X[i - 1]))
return;
- }
X[i] = _x;
Y[i] = _y;
@@ -160,7 +160,8 @@ CurveEditor::move_point(int i, double _x, double _y) {
void
CurveEditor::remove_point(int i) {
- if (i < 0 || i >= n) return;
+ if (i < 0 || i >= n)
+ return;
memmove(&X[i], &X[i + 1], sizeof(double) * (n - i));
memmove(&Y[i], &Y[i + 1], sizeof(double) * (n - i));
@@ -170,15 +171,18 @@ CurveEditor::remove_point(int i) {
void
CurveEditor::get_point(int i, double *_x, double *_y) {
- if (i < 0 || i >= n) return;
+ if (i < 0 || i >= n)
+ return;
*_x = X[i];
*_y = Y[i];
}
void CurveEditor::clear() {
- if (X) free(X);
- if (Y) free(Y);
+ if (X)
+ free(X);
+ if (Y)
+ free(Y);
X = Y = NULL;
n = 0;