paysages : Added grid and axis labels to curve editor.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@365 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
834f96d3a6
commit
1539c75d6d
13 changed files with 86 additions and 21 deletions
|
@ -25,6 +25,7 @@ GUI :
|
|||
* New material editor.
|
||||
* Added render timer.
|
||||
* Previews locations and render params are now saved.
|
||||
* Added grid and axis labels to curve editor.
|
||||
* Added camera location to previews.
|
||||
|
||||
Misc :
|
||||
|
|
2
TODO
2
TODO
|
@ -23,8 +23,8 @@ Technology Preview 2 :
|
|||
- Fix the distorted sun appearance.
|
||||
- Improve curve editor.
|
||||
=> Add curve modes
|
||||
=> Add axis labels and grid
|
||||
=> Add logarithmic mode
|
||||
=> Add zoom and scrolling
|
||||
- Fix "RGB parameters out of range" (and segfault) on preview while moving render params fast in render tab.
|
||||
=> May need to change the updateData system.
|
||||
=> Previews need to be paused while updating data.
|
||||
|
|
|
@ -285,9 +285,9 @@ BaseInput* BaseForm::addInputNoise(QString label, NoiseGenerator* value)
|
|||
return addInput(new InputNoise(form, label, value));
|
||||
}
|
||||
|
||||
BaseInput* BaseForm::addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax)
|
||||
BaseInput* BaseForm::addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel)
|
||||
{
|
||||
return addInput(new InputCurve(form, label, value, xmin, xmax, ymin, ymax));
|
||||
return addInput(new InputCurve(form, label, value, xmin, xmax, ymin, ymax, xlabel, ylabel));
|
||||
}
|
||||
|
||||
BaseInput* BaseForm::addInputMaterial(QString label, SurfaceMaterial* material)
|
||||
|
|
|
@ -47,7 +47,7 @@ protected:
|
|||
BaseInput* addInputColor(QString label, Color* value);
|
||||
BaseInput* addInputColorGradation(QString label, ColorGradation* value);
|
||||
BaseInput* addInputNoise(QString label, NoiseGenerator* value);
|
||||
BaseInput* addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax);
|
||||
BaseInput* addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel);
|
||||
BaseInput* addInputMaterial(QString label, SurfaceMaterial* material);
|
||||
BaseInput* addInputEnum(QString label, int* value, const QStringList& values);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "widgetcurveeditor.h"
|
||||
|
||||
/**************** Dialog ****************/
|
||||
DialogCurve::DialogCurve(QWidget *parent, Curve* curve, double xmin, double xmax, double ymin, double ymax) : QDialog(parent)
|
||||
DialogCurve::DialogCurve(QWidget *parent, Curve* curve, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel) : QDialog(parent)
|
||||
{
|
||||
QWidget* buttons;
|
||||
QWidget* form;
|
||||
|
@ -40,6 +40,7 @@ DialogCurve::DialogCurve(QWidget *parent, Curve* curve, double xmin, double xmax
|
|||
label->setWordWrap(true);
|
||||
form_layout->addWidget(label, 0, 1);
|
||||
_curve_editor = new WidgetCurveEditor(form, xmin, xmax, ymin, ymax);
|
||||
_curve_editor->setAxisLabels(xlabel, ylabel);
|
||||
_curve_editor->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
form_layout->addWidget(_curve_editor, 0, 0);
|
||||
|
||||
|
@ -70,11 +71,11 @@ DialogCurve::~DialogCurve()
|
|||
curveDelete(_current);
|
||||
}
|
||||
|
||||
bool DialogCurve::getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax)
|
||||
bool DialogCurve::getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel)
|
||||
{
|
||||
int result;
|
||||
|
||||
DialogCurve* dialog = new DialogCurve(parent, curve, xmin, xmax, ymin, ymax);
|
||||
DialogCurve* dialog = new DialogCurve(parent, curve, xmin, xmax, ymin, ymax, xlabel, ylabel);
|
||||
result = dialog->exec();
|
||||
|
||||
delete dialog;
|
||||
|
|
|
@ -11,10 +11,10 @@ class DialogCurve : public QDialog
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DialogCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax);
|
||||
explicit DialogCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel);
|
||||
~DialogCurve();
|
||||
|
||||
static bool getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax);
|
||||
static bool getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel);
|
||||
|
||||
public slots:
|
||||
virtual void accept();
|
||||
|
|
|
@ -157,7 +157,7 @@ FormClouds::FormClouds(QWidget *parent):
|
|||
addInputDouble(tr("Lower altitude"), &_layer.ymin, -10.0, 50.0, 0.5, 5.0);
|
||||
addInputDouble(tr("Upper altitude"), &_layer.ymax, -10.0, 50.0, 0.5, 5.0);
|
||||
addInputDouble(tr("Max coverage"), &_layer.base_coverage, 0.0, 1.0, 0.01, 0.1);
|
||||
addInputCurve(tr("Coverage by altitude"), _layer.coverage_by_altitude, 0.0, 1.0, 0.0, 1.0);
|
||||
addInputCurve(tr("Coverage by altitude"), _layer.coverage_by_altitude, 0.0, 1.0, 0.0, 1.0, tr("Altitude in cloud layer"), tr("Coverage value"));
|
||||
addInputNoise(tr("Shape noise"), _layer.shape_noise);
|
||||
addInputDouble(tr("Shape scaling"), &_layer.shape_scaling, 1.0, 10.0, 0.1, 1.0);
|
||||
addInputNoise(tr("Edge noise"), _layer.edge_noise);
|
||||
|
|
|
@ -111,7 +111,7 @@ FormSky::FormSky(QWidget *parent):
|
|||
addInputColor(tr("Sun color"), &_definition.sun_color);
|
||||
addInputDouble(tr("Sun radius"), &_definition.sun_radius, 0.0, 0.4, 0.004, 0.04);
|
||||
addInputDouble(tr("Sun halo radius"), &_definition.sun_halo_size, 0.0, 0.4, 0.004, 0.04);
|
||||
addInputCurve(tr("Sun halo profile"), _definition.sun_halo_profile, 0.0, 1.0, 0.0, 1.0);
|
||||
addInputCurve(tr("Sun halo profile"), _definition.sun_halo_profile, 0.0, 1.0, 0.0, 1.0, tr("Distance to center of the sun"), tr("Light influence (halo opacity)"));
|
||||
addInputDouble(tr("Influence of skydome on lighting"), &_definition.dome_lighting, 0.0, 2.0, 0.01, 0.1);
|
||||
input = addInputBoolean(tr("Auto colors from daytime"), &_definition.model_custom.auto_from_daytime);
|
||||
input->setVisibilityCondition((int*)&_definition.model, SKY_MODEL_CUSTOM);
|
||||
|
|
|
@ -49,13 +49,15 @@ public:
|
|||
double _ymax;
|
||||
};
|
||||
|
||||
InputCurve::InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax) : BaseInput(form, label)
|
||||
InputCurve::InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel) : BaseInput(form, label)
|
||||
{
|
||||
_value = value;
|
||||
_xmin = xmin;
|
||||
_xmax = xmax;
|
||||
_ymin = ymin;
|
||||
_ymax = ymax;
|
||||
_xlabel = xlabel;
|
||||
_ylabel = ylabel;
|
||||
|
||||
_preview = new CurveSmallPreview(form, value, xmin, xmax, ymin, ymax);
|
||||
_preview->setMinimumSize(100, 40);
|
||||
|
@ -84,7 +86,7 @@ void InputCurve::revert()
|
|||
|
||||
void InputCurve::editCurve()
|
||||
{
|
||||
if (DialogCurve::getCurve(_control, _value, _xmin, _xmax, _ymin, _ymax))
|
||||
if (DialogCurve::getCurve(_control, _value, _xmin, _xmax, _ymin, _ymax, _xlabel, _ylabel))
|
||||
{
|
||||
applyValue();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class InputCurve:public BaseInput
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax);
|
||||
InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel);
|
||||
|
||||
public slots:
|
||||
virtual void updatePreview();
|
||||
|
@ -27,6 +27,8 @@ private:
|
|||
double _xmax;
|
||||
double _ymin;
|
||||
double _ymax;
|
||||
QString _xlabel;
|
||||
QString _ylabel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <qt4/QtGui/qpaintengine.h>
|
||||
#include "../lib_paysages/tools.h"
|
||||
|
||||
WidgetCurveEditor::WidgetCurveEditor(QWidget *parent, double xmin, double xmax, double ymin, double ymax) : QWidget(parent)
|
||||
|
@ -18,6 +19,12 @@ WidgetCurveEditor::~WidgetCurveEditor()
|
|||
curveDelete(_curve);
|
||||
}
|
||||
|
||||
void WidgetCurveEditor::setAxisLabels(QString xlabel, QString ylabel)
|
||||
{
|
||||
_xlabel = xlabel;
|
||||
_ylabel = ylabel;
|
||||
}
|
||||
|
||||
void WidgetCurveEditor::setCurve(Curve* curve)
|
||||
{
|
||||
curveCopy(curve, _curve);
|
||||
|
@ -49,9 +56,35 @@ void WidgetCurveEditor::paintEvent(QPaintEvent* event)
|
|||
dwidth = (double)(width - 1);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.fillRect(0, 0, width, height, QColor(255, 255, 255));
|
||||
painter.setPen(_pen);
|
||||
painter.fillRect(rect(), Qt::white);
|
||||
|
||||
// Draw grid
|
||||
painter.setPen(QPen(Qt::lightGray));
|
||||
for (int x = 0; x <= 10; x++)
|
||||
{
|
||||
int vx = (x == 10) ? width - 1 : x * width / 10;
|
||||
painter.drawLine(vx, 0, vx, height -1);
|
||||
vx = (x == 10) ? height - 1 : x * height / 10;
|
||||
painter.drawLine(0, vx, width - 1, vx);
|
||||
}
|
||||
|
||||
// Draw labels
|
||||
painter.setPen(QColor(50, 50, 50));
|
||||
if (not _xlabel.isEmpty())
|
||||
{
|
||||
painter.drawText(rect(), Qt::AlignCenter | Qt::AlignBottom, _xlabel);
|
||||
}
|
||||
if (not _ylabel.isEmpty())
|
||||
{
|
||||
painter.rotate(-90.0);
|
||||
painter.translate(-height, 0.0);
|
||||
painter.drawText(0, 0, height, 20, Qt::AlignCenter | Qt::AlignTop, _ylabel);
|
||||
painter.translate(height, 0.0);
|
||||
painter.rotate(90.0);
|
||||
}
|
||||
|
||||
// Draw curve path
|
||||
painter.setPen(_pen);
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
position = ((double)x) / dwidth;
|
||||
|
@ -64,7 +97,9 @@ void WidgetCurveEditor::paintEvent(QPaintEvent* event)
|
|||
painter.drawPoint(x, height - 1 - (int)(value * dheight));
|
||||
}
|
||||
|
||||
// Draw handles
|
||||
n = curveGetPointCount(_curve);
|
||||
painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing, true);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
curveGetPoint(_curve, i, &point);
|
||||
|
|
|
@ -13,6 +13,8 @@ public:
|
|||
WidgetCurveEditor(QWidget* parent, double xmin, double xmax, double ymin, double ymax);
|
||||
~WidgetCurveEditor();
|
||||
|
||||
void setAxisLabels(QString xlabel, QString ylabel);
|
||||
|
||||
void setCurve(Curve* curve);
|
||||
void getCurve(Curve* curve);
|
||||
|
||||
|
@ -34,6 +36,8 @@ private:
|
|||
Curve* _curve;
|
||||
int _dragged;
|
||||
QColor _pen;
|
||||
QString _xlabel;
|
||||
QString _ylabel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -101,22 +101,22 @@ Right click on a point to delete it.</source>
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcurve.cpp" line="50"/>
|
||||
<location filename="../gui_qt/dialogcurve.cpp" line="51"/>
|
||||
<source>Validate</source>
|
||||
<translation type="unfinished">Valider</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcurve.cpp" line="54"/>
|
||||
<location filename="../gui_qt/dialogcurve.cpp" line="55"/>
|
||||
<source>Revert</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcurve.cpp" line="58"/>
|
||||
<location filename="../gui_qt/dialogcurve.cpp" line="59"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished">Annuler</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogcurve.cpp" line="62"/>
|
||||
<location filename="../gui_qt/dialogcurve.cpp" line="63"/>
|
||||
<source>Paysages 3D - Curve editor</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -421,6 +421,16 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<source>Coverage by altitude</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="160"/>
|
||||
<source>Altitude in cloud layer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="160"/>
|
||||
<source>Coverage value</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formclouds.cpp" line="161"/>
|
||||
<source>Shape noise</source>
|
||||
|
@ -665,6 +675,16 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<source>Zenith color</source>
|
||||
<translation>Couleur du ciel au zénith</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formsky.cpp" line="114"/>
|
||||
<source>Distance to center of the sun</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formsky.cpp" line="114"/>
|
||||
<source>Light influence (halo opacity)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/formsky.cpp" line="116"/>
|
||||
<source>Auto colors from daytime</source>
|
||||
|
@ -931,7 +951,7 @@ Maintenir Ctrl : Plus rapide</translation>
|
|||
<context>
|
||||
<name>InputCurve</name>
|
||||
<message>
|
||||
<location filename="../gui_qt/inputcurve.cpp" line="62"/>
|
||||
<location filename="../gui_qt/inputcurve.cpp" line="64"/>
|
||||
<source>Edit</source>
|
||||
<translation type="unfinished">Editer</translation>
|
||||
</message>
|
||||
|
|
Loading…
Reference in a new issue