From 19fb234a28e8f3c0aa451e09fc43c63b3eb07851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sat, 9 Jun 2012 09:49:23 +0000 Subject: [PATCH] paysages : Fixed holes in curve rendering. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@343 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 1 - gui_qt/inputcurve.cpp | 6 +++++- gui_qt/widgetcurveeditor.cpp | 7 ++++++- i18n/paysages_fr.ts | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 4d03b12..c37dfb3 100644 --- a/TODO +++ b/TODO @@ -16,7 +16,6 @@ Technology Preview 2 : - Fix the distorted sun appearance. - Improve curve editor. => Add curve modes - => Improve curve rendering => Add axis labels and grid => Add logarithmic mode - Improve 3d explorer diff --git a/gui_qt/inputcurve.cpp b/gui_qt/inputcurve.cpp index cc38bb3..32f6150 100644 --- a/gui_qt/inputcurve.cpp +++ b/gui_qt/inputcurve.cpp @@ -27,7 +27,7 @@ public: QPainter painter(this); int width = this->width(); int height = this->height(); - double position, value; + double position, value, prev_value, next_value; painter.fillRect(rect(), QColor(255, 255, 255)); for (int x = 0; x < width; x++) @@ -35,6 +35,10 @@ public: painter.setPen(QColor(0, 0, 0)); position = _xmin + (_xmax - _xmin) * (double)x / (double)(width - 1); value = (curveGetValue(_curve, position) - _ymin) * (_ymax - _ymin); + prev_value = curveGetValue(_curve, position - 1.0 / (double)(width - 1)); + next_value = curveGetValue(_curve, position + 1.0 / (double)(width - 1)); + + painter.drawLine(x, height - 1 - (int)((value + (prev_value - value) / 2.0) * (double)(height - 1)), x, height - 1 - (int)((value + (next_value - value) / 2.0) * (double)(height - 1))); painter.drawPoint(x, height - 1 - (int)(value * (double)(height - 1))); } } diff --git a/gui_qt/widgetcurveeditor.cpp b/gui_qt/widgetcurveeditor.cpp index fdb6023..31cc085 100644 --- a/gui_qt/widgetcurveeditor.cpp +++ b/gui_qt/widgetcurveeditor.cpp @@ -41,7 +41,7 @@ void WidgetCurveEditor::paintEvent(QPaintEvent* event) int width, height; double dwidth, dheight; CurvePoint point; - double position, value; + double position, value, prev_value, next_value; width = this->width(); height = this->height(); @@ -55,7 +55,12 @@ void WidgetCurveEditor::paintEvent(QPaintEvent* event) for (int x = 0; x < width; x++) { position = ((double)x) / dwidth; + value = curveGetValue(_curve, position); + prev_value = curveGetValue(_curve, position - 1.0 / dwidth); + next_value = curveGetValue(_curve, position + 1.0 / dwidth); + + painter.drawLine(x, height - 1 - (int)((value + (prev_value - value) / 2.0) * dheight), x, height - 1 - (int)((value + (next_value - value) / 2.0) * dheight)); painter.drawPoint(x, height - 1 - (int)(value * dheight)); } diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index 9c8ebea..e9ba179 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -850,7 +850,7 @@ Maintenir Ctrl : Plus rapide InputCurve - + Edit Editer