paysages: Added band previews to colorgradation editor.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@278 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
f479af8417
commit
6f5c201df3
7 changed files with 135 additions and 34 deletions
1
TODO
1
TODO
|
@ -1,4 +1,5 @@
|
||||||
- Implement scaling and scrolling on previews.
|
- Implement scaling and scrolling on previews.
|
||||||
|
- Improve color gradation dialog (with curve editor ?).
|
||||||
- Replace FILE* by a custom type for Save and Load.
|
- Replace FILE* by a custom type for Save and Load.
|
||||||
- Water and terrain LOD moves with the camera, fix it like in the wanderer.
|
- Water and terrain LOD moves with the camera, fix it like in the wanderer.
|
||||||
- Restore render progress.
|
- Restore render progress.
|
||||||
|
|
|
@ -20,11 +20,27 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad
|
||||||
_current = colorGradationCreate();
|
_current = colorGradationCreate();
|
||||||
colorGradationCopy(_base, _current);
|
colorGradationCopy(_base, _current);
|
||||||
|
|
||||||
setLayout(new QHBoxLayout());
|
setLayout(new QVBoxLayout());
|
||||||
|
|
||||||
_curve_editor = new WidgetCurveEditor(this);
|
_curve_editor = new WidgetCurveEditor(this);
|
||||||
layout()->addWidget(_curve_editor);
|
layout()->addWidget(_curve_editor);
|
||||||
|
|
||||||
|
_preview_red = new PreviewColorGradation(this, gradation, COLORGRADATIONBAND_RED);
|
||||||
|
_preview_red->setMinimumHeight(50);
|
||||||
|
layout()->addWidget(_preview_red);
|
||||||
|
|
||||||
|
_preview_green = new PreviewColorGradation(this, gradation, COLORGRADATIONBAND_GREEN);
|
||||||
|
_preview_green->setMinimumHeight(50);
|
||||||
|
layout()->addWidget(_preview_green);
|
||||||
|
|
||||||
|
_preview_blue = new PreviewColorGradation(this, gradation, COLORGRADATIONBAND_BLUE);
|
||||||
|
_preview_blue->setMinimumHeight(50);
|
||||||
|
layout()->addWidget(_preview_blue);
|
||||||
|
|
||||||
|
_preview_final = new PreviewColorGradation(this, gradation, COLORGRADATIONBAND_FINAL);
|
||||||
|
_preview_final->setMinimumHeight(50);
|
||||||
|
layout()->addWidget(_preview_final);
|
||||||
|
|
||||||
_curve = curveCreate();
|
_curve = curveCreate();
|
||||||
|
|
||||||
/*QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
|
/*QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "baseform.h"
|
#include "baseform.h"
|
||||||
#include "widgetcurveeditor.h"
|
#include "widgetcurveeditor.h"
|
||||||
|
#include "previewcolorgradation.h"
|
||||||
|
|
||||||
#include "../lib_paysages/color.h"
|
#include "../lib_paysages/color.h"
|
||||||
#include "../lib_paysages/curve.h"
|
#include "../lib_paysages/curve.h"
|
||||||
|
@ -32,6 +33,10 @@ private:
|
||||||
ColorGradation* _current;
|
ColorGradation* _current;
|
||||||
Curve* _curve;
|
Curve* _curve;
|
||||||
WidgetCurveEditor* _curve_editor;
|
WidgetCurveEditor* _curve_editor;
|
||||||
|
PreviewColorGradation* _preview_red;
|
||||||
|
PreviewColorGradation* _preview_green;
|
||||||
|
PreviewColorGradation* _preview_blue;
|
||||||
|
PreviewColorGradation* _preview_final;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,37 +5,14 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include "dialogcolorgradation.h"
|
#include "dialogcolorgradation.h"
|
||||||
|
#include "previewcolorgradation.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
class ColorGradationPreview:public QWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ColorGradationPreview(QWidget* parent, ColorGradation* gradation) : QWidget(parent)
|
|
||||||
{
|
|
||||||
this->gradation = gradation;
|
|
||||||
}
|
|
||||||
|
|
||||||
void paintEvent(QPaintEvent* event)
|
|
||||||
{
|
|
||||||
QPainter painter(this);
|
|
||||||
int width = this->width();
|
|
||||||
int height = this->height();
|
|
||||||
|
|
||||||
for (int x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
painter.setPen(colorToQColor(colorGradationGet(gradation, (double)x / (double)width)));
|
|
||||||
painter.drawLine(x, 0, x, height - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorGradation* gradation;
|
|
||||||
};
|
|
||||||
|
|
||||||
InputColorGradation::InputColorGradation(QWidget* form, QString label, ColorGradation* value) : BaseInput(form, label)
|
InputColorGradation::InputColorGradation(QWidget* form, QString label, ColorGradation* value) : BaseInput(form, label)
|
||||||
{
|
{
|
||||||
_value = value;
|
_value = value;
|
||||||
|
|
||||||
_preview = new ColorGradationPreview(form, value);
|
_preview = new PreviewColorGradation(form, value, COLORGRADATIONBAND_FINAL);
|
||||||
_preview->setMinimumSize(200, 20);
|
_preview->setMinimumSize(200, 20);
|
||||||
|
|
||||||
_control = new QPushButton(tr("Edit"), form);
|
_control = new QPushButton(tr("Edit"), form);
|
||||||
|
|
68
gui_qt/previewcolorgradation.cpp
Normal file
68
gui_qt/previewcolorgradation.cpp
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
#include "previewcolorgradation.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QSlider>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include "baseform.h"
|
||||||
|
#include "tools.h"
|
||||||
|
#include "widgetcurveeditor.h"
|
||||||
|
|
||||||
|
/**************** Preview ****************/
|
||||||
|
PreviewColorGradation::PreviewColorGradation(QWidget* parent, ColorGradation* gradation, EnumColorGradationBand band) : QWidget(parent)
|
||||||
|
{
|
||||||
|
this->gradation = gradation;
|
||||||
|
this->band = band;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewColorGradation::paintEvent(QPaintEvent* event)
|
||||||
|
{
|
||||||
|
Curve* curve;
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
int width = this->width();
|
||||||
|
int height = this->height();
|
||||||
|
|
||||||
|
curve = curveCreate();
|
||||||
|
|
||||||
|
switch (band)
|
||||||
|
{
|
||||||
|
case COLORGRADATIONBAND_RED:
|
||||||
|
colorGradationGetRedCurve(gradation, curve);
|
||||||
|
break;
|
||||||
|
case COLORGRADATIONBAND_GREEN:
|
||||||
|
colorGradationGetGreenCurve(gradation, curve);
|
||||||
|
break;
|
||||||
|
case COLORGRADATIONBAND_BLUE:
|
||||||
|
colorGradationGetBlueCurve(gradation, curve);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
switch (band)
|
||||||
|
{
|
||||||
|
case COLORGRADATIONBAND_RED:
|
||||||
|
painter.setPen(QColor::fromRgbF(curveGetValue(curve, (double)x / (double)width), 0.0, 0.0));
|
||||||
|
break;
|
||||||
|
case COLORGRADATIONBAND_GREEN:
|
||||||
|
painter.setPen(QColor::fromRgbF(0.0, curveGetValue(curve, (double)x / (double)width), 0.0));
|
||||||
|
break;
|
||||||
|
case COLORGRADATIONBAND_BLUE:
|
||||||
|
painter.setPen(QColor::fromRgbF(0.0, 0.0, curveGetValue(curve, (double)x / (double)width)));
|
||||||
|
break;
|
||||||
|
case COLORGRADATIONBAND_FINAL:
|
||||||
|
painter.setPen(colorToQColor(colorGradationGet(gradation, (double)x / (double)width)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
painter.drawLine(x, 0, x, height - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
curveDelete(curve);
|
||||||
|
}
|
28
gui_qt/previewcolorgradation.h
Normal file
28
gui_qt/previewcolorgradation.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef _PAYSAGES_QT_PREVIEWCOLORGRADATION_H_
|
||||||
|
#define _PAYSAGES_QT_PREVIEWCOLORGRADATION_H_
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "../lib_paysages/color.h"
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
COLORGRADATIONBAND_RED,
|
||||||
|
COLORGRADATIONBAND_GREEN,
|
||||||
|
COLORGRADATIONBAND_BLUE,
|
||||||
|
COLORGRADATIONBAND_FINAL
|
||||||
|
} EnumColorGradationBand;
|
||||||
|
|
||||||
|
class PreviewColorGradation:public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
PreviewColorGradation(QWidget* parent, ColorGradation* gradation, EnumColorGradationBand band);
|
||||||
|
void paintEvent(QPaintEvent* event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ColorGradation* gradation;
|
||||||
|
EnumColorGradationBand band;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -4,34 +4,40 @@
|
||||||
<context>
|
<context>
|
||||||
<name>BaseForm</name>
|
<name>BaseForm</name>
|
||||||
<message>
|
<message>
|
||||||
|
<location filename="../gui_qt/baseform.cpp" line="33"/>
|
||||||
<source>Layers : </source>
|
<source>Layers : </source>
|
||||||
<translation type="obsolete">Niveaux :</translation>
|
<translation>Niveaux :</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
|
<location filename="../gui_qt/baseform.cpp" line="39"/>
|
||||||
<source>Add layer</source>
|
<source>Add layer</source>
|
||||||
<translation type="obsolete">Ajouter un niveau</translation>
|
<translation>Ajouter un niveau</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
|
<location filename="../gui_qt/baseform.cpp" line="43"/>
|
||||||
<source>Delete layer</source>
|
<source>Delete layer</source>
|
||||||
<translation type="obsolete">Supprimer un niveau</translation>
|
<translation>Supprimer un niveau</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
|
<location filename="../gui_qt/baseform.cpp" line="73"/>
|
||||||
<source>Apply</source>
|
<source>Apply</source>
|
||||||
<translation type="obsolete">Appliquer</translation>
|
<translation>Appliquer</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
|
<location filename="../gui_qt/baseform.cpp" line="76"/>
|
||||||
<source>Revert</source>
|
<source>Revert</source>
|
||||||
<translation type="obsolete">Annuler les modifications</translation>
|
<translation>Annuler les modifications</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
|
<location filename="../gui_qt/baseform.cpp" line="239"/>
|
||||||
<source>Layer %1</source>
|
<source>Layer %1</source>
|
||||||
<translation type="obsolete">Niveau %1</translation>
|
<translation>Niveau %1</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DialogColorGradation</name>
|
<name>DialogColorGradation</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/dialogcolorgradation.cpp" line="34"/>
|
<location filename="../gui_qt/dialogcolorgradation.cpp" line="50"/>
|
||||||
<source>Paysages 3D - Color gradation editor</source>
|
<source>Paysages 3D - Color gradation editor</source>
|
||||||
<translation>Paysages 3D - Editeur de gradients de couleur</translation>
|
<translation>Paysages 3D - Editeur de gradients de couleur</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -492,7 +498,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>InputColorGradation</name>
|
<name>InputColorGradation</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/inputcolorgradation.cpp" line="41"/>
|
<location filename="../gui_qt/inputcolorgradation.cpp" line="18"/>
|
||||||
<source>Edit</source>
|
<source>Edit</source>
|
||||||
<translation>Editer</translation>
|
<translation>Editer</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
Loading…
Reference in a new issue