paysages : Curve editor (WIP).
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@277 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
c9fd2cca95
commit
f479af8417
6 changed files with 39 additions and 1 deletions
|
@ -25,6 +25,8 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad
|
||||||
_curve_editor = new WidgetCurveEditor(this);
|
_curve_editor = new WidgetCurveEditor(this);
|
||||||
layout()->addWidget(_curve_editor);
|
layout()->addWidget(_curve_editor);
|
||||||
|
|
||||||
|
_curve = curveCreate();
|
||||||
|
|
||||||
/*QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
|
/*QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
|
||||||
QObject::connect(button, SIGNAL(clicked()), this, SLOT(revert()));
|
QObject::connect(button, SIGNAL(clicked()), this, SLOT(revert()));
|
||||||
QObject::connect(button, SIGNAL(clicked()), this, SLOT(reject()));*/
|
QObject::connect(button, SIGNAL(clicked()), this, SLOT(reject()));*/
|
||||||
|
@ -37,6 +39,7 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad
|
||||||
DialogColorGradation::~DialogColorGradation()
|
DialogColorGradation::~DialogColorGradation()
|
||||||
{
|
{
|
||||||
colorGradationDelete(_current);
|
colorGradationDelete(_current);
|
||||||
|
curveDelete(_curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogColorGradation::getGradation(QWidget* parent, ColorGradation* gradation)
|
bool DialogColorGradation::getGradation(QWidget* parent, ColorGradation* gradation)
|
||||||
|
@ -70,5 +73,6 @@ void DialogColorGradation::revert()
|
||||||
|
|
||||||
void DialogColorGradation::revertToCurrent()
|
void DialogColorGradation::revertToCurrent()
|
||||||
{
|
{
|
||||||
// TODO
|
colorGradationGetRedCurve(_current, _curve);
|
||||||
|
_curve_editor->setCurve(_curve);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "widgetcurveeditor.h"
|
#include "widgetcurveeditor.h"
|
||||||
|
|
||||||
#include "../lib_paysages/color.h"
|
#include "../lib_paysages/color.h"
|
||||||
|
#include "../lib_paysages/curve.h"
|
||||||
|
|
||||||
class DialogColorGradation : public QDialog
|
class DialogColorGradation : public QDialog
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,7 @@ private:
|
||||||
private:
|
private:
|
||||||
ColorGradation* _base;
|
ColorGradation* _base;
|
||||||
ColorGradation* _current;
|
ColorGradation* _current;
|
||||||
|
Curve* _curve;
|
||||||
WidgetCurveEditor* _curve_editor;
|
WidgetCurveEditor* _curve_editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,21 @@ WidgetCurveEditor::~WidgetCurveEditor()
|
||||||
curveDelete(_curve);
|
curveDelete(_curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WidgetCurveEditor::setCurve(Curve* curve)
|
||||||
|
{
|
||||||
|
curveCopy(curve, _curve);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WidgetCurveEditor::getCurve(Curve* curve)
|
||||||
|
{
|
||||||
|
curveCopy(_curve, curve);
|
||||||
|
}
|
||||||
|
|
||||||
void WidgetCurveEditor::paintEvent(QPaintEvent* event)
|
void WidgetCurveEditor::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
|
int i, n;
|
||||||
|
CurvePoint point;
|
||||||
double position, value;
|
double position, value;
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
@ -29,4 +42,11 @@ void WidgetCurveEditor::paintEvent(QPaintEvent* event)
|
||||||
value = curveGetValue(_curve, position);
|
value = curveGetValue(_curve, position);
|
||||||
painter.drawPoint(x, 499 - (int)(value * 499.0));
|
painter.drawPoint(x, 499 - (int)(value * 499.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n = curveGetPointCount(_curve);
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
curveGetPoint(_curve, i, &point);
|
||||||
|
painter.drawEllipse(QPoint((int)(point.position * 499.0), 499 - (int)(point.value * 499.0)), 4.0, 4.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@ public:
|
||||||
WidgetCurveEditor(QWidget* parent);
|
WidgetCurveEditor(QWidget* parent);
|
||||||
~WidgetCurveEditor();
|
~WidgetCurveEditor();
|
||||||
|
|
||||||
|
void setCurve(Curve* curve);
|
||||||
|
void getCurve(Curve* curve);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent* event);
|
void paintEvent(QPaintEvent* event);
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,14 @@ void curveGetPoint(Curve* curve, int number, CurvePoint* point)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void curveSetPoint(Curve* curve, int number, CurvePoint* point)
|
||||||
|
{
|
||||||
|
if (number >= 0 && number < curve->nbpoints)
|
||||||
|
{
|
||||||
|
curve->points[number] = *point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int _point_compare(const void* part1, const void* part2)
|
int _point_compare(const void* part1, const void* part2)
|
||||||
{
|
{
|
||||||
if (((CurvePoint*)part1)->position > ((CurvePoint*)part2)->position)
|
if (((CurvePoint*)part1)->position > ((CurvePoint*)part2)->position)
|
||||||
|
|
|
@ -25,6 +25,7 @@ int curveAddPoint(Curve* curve, CurvePoint* point);
|
||||||
int curveQuickAddPoint(Curve* curve, double position, double value);
|
int curveQuickAddPoint(Curve* curve, double position, double value);
|
||||||
int curveGetPointCount(Curve* curve);
|
int curveGetPointCount(Curve* curve);
|
||||||
void curveGetPoint(Curve* curve, int number, CurvePoint* point);
|
void curveGetPoint(Curve* curve, int number, CurvePoint* point);
|
||||||
|
void curveSetPoint(Curve* curve, int number, CurvePoint* point);
|
||||||
void curveValidate(Curve* curve);
|
void curveValidate(Curve* curve);
|
||||||
|
|
||||||
double curveGetValue(Curve* curve, double position);
|
double curveGetValue(Curve* curve, double position);
|
||||||
|
|
Loading…
Reference in a new issue