2012-03-18 19:51:06 +00:00
|
|
|
#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;
|
|
|
|
}
|
2013-01-16 14:26:46 +00:00
|
|
|
|
|
|
|
void PreviewColorGradation::paintEvent(QPaintEvent*)
|
2012-03-18 19:51:06 +00:00
|
|
|
{
|
|
|
|
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:
|
2012-06-17 09:40:40 +00:00
|
|
|
painter.setPen(QColor::fromRgbF(curveGetValue(curve, (double)x / (double)width), 0.0, 0.0));
|
2012-03-18 19:51:06 +00:00
|
|
|
break;
|
|
|
|
case COLORGRADATIONBAND_GREEN:
|
2012-06-17 09:40:40 +00:00
|
|
|
painter.setPen(QColor::fromRgbF(0.0, curveGetValue(curve, (double)x / (double)width), 0.0));
|
2012-03-18 19:51:06 +00:00
|
|
|
break;
|
|
|
|
case COLORGRADATIONBAND_BLUE:
|
2012-06-17 09:40:40 +00:00
|
|
|
painter.setPen(QColor::fromRgbF(0.0, 0.0, curveGetValue(curve, (double)x / (double)width)));
|
2012-03-18 19:51:06 +00:00
|
|
|
break;
|
|
|
|
case COLORGRADATIONBAND_FINAL:
|
2012-06-17 09:40:40 +00:00
|
|
|
painter.setPen(colorToQColor(colorGradationGet(gradation, (double)x / (double)width)));
|
2012-03-18 19:51:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
painter.drawLine(x, 0, x, height - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
curveDelete(curve);
|
|
|
|
}
|
2012-03-18 21:00:50 +00:00
|
|
|
|
2013-01-16 14:26:46 +00:00
|
|
|
void PreviewColorGradation::mouseReleaseEvent(QMouseEvent*)
|
2012-03-18 21:00:50 +00:00
|
|
|
{
|
|
|
|
emit clicked();
|
|
|
|
}
|