2012-02-20 21:17:13 +00:00
|
|
|
#include "dialogcolorgradation.h"
|
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QColor>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QSlider>
|
|
|
|
#include <QScrollArea>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include "baseform.h"
|
2012-02-21 13:41:02 +00:00
|
|
|
#include "tools.h"
|
2012-03-08 15:10:25 +00:00
|
|
|
#include "widgetcurveeditor.h"
|
2012-02-20 21:17:13 +00:00
|
|
|
|
|
|
|
/**************** Dialog ****************/
|
|
|
|
DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* gradation):
|
|
|
|
QDialog(parent)
|
|
|
|
{
|
|
|
|
_base = gradation;
|
|
|
|
_current = colorGradationCreate();
|
2012-03-08 15:10:25 +00:00
|
|
|
colorGradationCopy(_base, _current);
|
2012-02-20 21:17:13 +00:00
|
|
|
|
2012-03-18 19:51:06 +00:00
|
|
|
setLayout(new QVBoxLayout());
|
2012-02-20 21:17:13 +00:00
|
|
|
|
2012-03-08 15:10:25 +00:00
|
|
|
_curve_editor = new WidgetCurveEditor(this);
|
|
|
|
layout()->addWidget(_curve_editor);
|
2012-02-20 21:17:13 +00:00
|
|
|
|
2012-03-18 19:51:06 +00:00
|
|
|
_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);
|
|
|
|
|
2012-03-08 15:56:44 +00:00
|
|
|
_curve = curveCreate();
|
|
|
|
|
2012-02-20 21:17:13 +00:00
|
|
|
/*QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
|
|
|
|
QObject::connect(button, SIGNAL(clicked()), this, SLOT(revert()));
|
|
|
|
QObject::connect(button, SIGNAL(clicked()), this, SLOT(reject()));*/
|
|
|
|
|
2012-02-28 13:45:11 +00:00
|
|
|
setWindowTitle(tr("Paysages 3D - Color gradation editor"));
|
2012-02-20 21:17:13 +00:00
|
|
|
|
|
|
|
revert();
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogColorGradation::~DialogColorGradation()
|
|
|
|
{
|
2012-03-08 15:10:25 +00:00
|
|
|
colorGradationDelete(_current);
|
2012-03-08 15:56:44 +00:00
|
|
|
curveDelete(_curve);
|
2012-02-20 21:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DialogColorGradation::getGradation(QWidget* parent, ColorGradation* gradation)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
DialogColorGradation* dialog = new DialogColorGradation(parent, gradation);
|
|
|
|
result = dialog->exec();
|
|
|
|
|
|
|
|
delete dialog;
|
|
|
|
|
|
|
|
return (result != 0) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogColorGradation::closeEvent(QCloseEvent* e)
|
|
|
|
{
|
|
|
|
reject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogColorGradation::accept()
|
|
|
|
{
|
2012-03-08 15:10:25 +00:00
|
|
|
colorGradationCopy(_current, _base);
|
2012-02-20 21:17:13 +00:00
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogColorGradation::revert()
|
|
|
|
{
|
2012-03-08 15:10:25 +00:00
|
|
|
colorGradationCopy(_base, _current);
|
2012-02-20 21:17:13 +00:00
|
|
|
revertToCurrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogColorGradation::revertToCurrent()
|
|
|
|
{
|
2012-03-08 15:56:44 +00:00
|
|
|
colorGradationGetRedCurve(_current, _curve);
|
|
|
|
_curve_editor->setCurve(_curve);
|
2012-02-20 21:17:13 +00:00
|
|
|
}
|