42 Q_ASSERT(colorSpaces.size() == histograms.size());
45 m_d->histogramIndex = 0;
46 qDeleteAll(
m_d->histogramPainters);
47 m_d->histogramPainters.clear();
49 if (histograms.size() == 0) {
55 for (
int i = 0; i < histograms.size(); ++i) {
63 for (
int i = 0; i < histograms.size(); ++i) {
65 m_d->histogramPainters[i]->setup(histograms[i], colorSpaces[i], finalChannels[i]);
81 Q_ASSERT(
m_d->histogramPainters.size() > 0);
82 Q_ASSERT(histogramIndex >= 0 && histogramIndex < m_d->histogramPainters.size());
84 const QColor
defaultColor =
m_d->histogramPainters[
m_d->histogramIndex]->defaultColor();
87 m_d->histogramIndex = histogramIndex;
88 m_d->histogramPainters[
m_d->histogramIndex]->setChannels(
channels);
164 QPainter painter(
this);
170 if (
m_d->histogramPainters.size() > 0 &&
171 m_d->histogramPainters[
m_d->histogramIndex]->channels().size() > 0) {
173 QImage histogramImage =
m_d->histogramPainters[
m_d->histogramIndex]->paint(size());
175 QLinearGradient shadowGradient(QPointF(0.0, 0.0), QPointF(0.0,
static_cast<qreal
>(height()) * 0.2));
176 shadowGradient.setColorAt(0.00, QColor(0, 0, 0, 64));
177 shadowGradient.setColorAt(0.25, QColor(0, 0, 0, 36));
178 shadowGradient.setColorAt(0.50, QColor(0, 0, 0, 16));
179 shadowGradient.setColorAt(0.75, QColor(0, 0, 0, 4));
180 shadowGradient.setColorAt(1.00, QColor(0, 0, 0, 0));
181 QPainter histogramPainter(&histogramImage);
182 histogramPainter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
183 histogramPainter.fillRect(histogramImage.rect(), shadowGradient);
185 painter.setOpacity(0.5);
187 painter.drawImage(0, 0, histogramImage);
188 painter.setOpacity(1.0);
190 const qreal w =
static_cast<qreal
>(width());
191 const qreal h =
static_cast<qreal
>(height());
192 const qreal radius = qMin(w, h) * 0.3;
193 const QPointF center = QPointF(w / 2.0, h / 2.0);
194 const int penWidth =
static_cast<int>(qRound(radius / 8));
195 painter.setPen(QPen(
palette().alternateBase(), penWidth, Qt::SolidLine, Qt::FlatCap));
196 painter.setBrush(Qt::NoBrush);
197 painter.setRenderHint(QPainter::Antialiasing);
198 painter.drawEllipse(center, radius, radius);
199 painter.drawLine(center + QPointF(radius, -radius), center + QPointF(-radius, radius));
203 QColor c =
palette().text().color();
205 painter.setPen(QPen(c, 1));
206 painter.setBrush(Qt::NoBrush);
207 painter.setRenderHint(QPainter::Antialiasing,
false);
208 painter.drawRect(0, 0, width() - 1, height() - 1);
void setup(const QVector< KisHistogram * > &histograms, const QVector< const KoColorSpace * > &colorSpaces, const QVector< QVector< int > > &channels={})
Sets up the widget by passing a collection of KisHistograms, the color space for each histogram and t...