paysages : Fixed holes in curve rendering.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@343 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-06-09 09:49:23 +00:00 committed by ThunderK
parent f541c081db
commit 19fb234a28
4 changed files with 12 additions and 4 deletions

1
TODO
View file

@ -16,7 +16,6 @@ Technology Preview 2 :
- Fix the distorted sun appearance. - Fix the distorted sun appearance.
- Improve curve editor. - Improve curve editor.
=> Add curve modes => Add curve modes
=> Improve curve rendering
=> Add axis labels and grid => Add axis labels and grid
=> Add logarithmic mode => Add logarithmic mode
- Improve 3d explorer - Improve 3d explorer

View file

@ -27,7 +27,7 @@ public:
QPainter painter(this); QPainter painter(this);
int width = this->width(); int width = this->width();
int height = this->height(); int height = this->height();
double position, value; double position, value, prev_value, next_value;
painter.fillRect(rect(), QColor(255, 255, 255)); painter.fillRect(rect(), QColor(255, 255, 255));
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
@ -35,6 +35,10 @@ public:
painter.setPen(QColor(0, 0, 0)); painter.setPen(QColor(0, 0, 0));
position = _xmin + (_xmax - _xmin) * (double)x / (double)(width - 1); position = _xmin + (_xmax - _xmin) * (double)x / (double)(width - 1);
value = (curveGetValue(_curve, position) - _ymin) * (_ymax - _ymin); 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))); painter.drawPoint(x, height - 1 - (int)(value * (double)(height - 1)));
} }
} }

View file

@ -41,7 +41,7 @@ void WidgetCurveEditor::paintEvent(QPaintEvent* event)
int width, height; int width, height;
double dwidth, dheight; double dwidth, dheight;
CurvePoint point; CurvePoint point;
double position, value; double position, value, prev_value, next_value;
width = this->width(); width = this->width();
height = this->height(); height = this->height();
@ -55,7 +55,12 @@ void WidgetCurveEditor::paintEvent(QPaintEvent* event)
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
position = ((double)x) / dwidth; position = ((double)x) / dwidth;
value = curveGetValue(_curve, position); 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)); painter.drawPoint(x, height - 1 - (int)(value * dheight));
} }

View file

@ -850,7 +850,7 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>InputCurve</name> <name>InputCurve</name>
<message> <message>
<location filename="../gui_qt/inputcurve.cpp" line="58"/> <location filename="../gui_qt/inputcurve.cpp" line="62"/>
<source>Edit</source> <source>Edit</source>
<translation type="unfinished">Editer</translation> <translation type="unfinished">Editer</translation>
</message> </message>