119{
123
124 QLabel::paintEvent(event);
125 QPainter painter(this);
126 painter.fillRect(0, 0, this->width(), this->height(), this->
palette().dark().color());
127 painter.setPen(this->
palette().light().color());
128
129 const int gridHeight = this->height() - painter.fontMetrics().height();
130
131 painter.save();
132
134 Q_FOREACH (float k, horGrid.keys()) {
135 float i = horGrid.value(k);
136 painter.drawLine(qRound(i), 0, qRound(i), gridHeight);
137 painter.drawText(QPointF(qRound(i), this->height()-2), QString::number(k));
138 }
139
142 unsigned int highest = 0;
143
144 for (int chan = 0; chan < channels.size(); chan++) {
147
148 int nthPercentile = 2 * histogramTemp.size() / 100;
149
150 std::nth_element(histogramTemp.begin(),
151 histogramTemp.begin() + nthPercentile, histogramTemp.end(), std::greater<int>());
152 unsigned int max = *(histogramTemp.begin() + nthPercentile);
153
154 highest = std::max(max, highest);
155 }
156 }
157
159 Q_FOREACH (float k, vertGrid.keys()) {
160 float i = vertGrid.value(k);
161 painter.drawLine(0., gridHeight -i, this->width(), gridHeight -i);
162 }
163
164 painter.restore();
165
166 painter.setCompositionMode(QPainter::CompositionMode_Plus);
167 const float barWidth = float(this->width()-1) / float(nBins);
168 float logVerticalMax = std::log10(vertGrid.keys().last()*10)*0.1;
169
170 for (int chan = 0; chan < (int)nChannels; chan++) {
172 QColor color = channels.at(chan)->color();
173
174
176 color = QColor(Qt::gray);
177 }
178
179 QColor fill_color = color;
180 fill_color.setAlphaF(.25);
181 painter.setBrush(fill_color);
182 QPen pen = QPen(color);
183 pen.setWidth(0);
184 painter.setPen(pen);
185
187 QPainterPath path;
188 path.moveTo(QPointF(1, gridHeight));
189 for (qint32 i = 0; i < nBins; ++i) {
192 const float maxBin = !
m_logarithmic? highest: logVerticalMax;
193 const float v = curBinVertical > 0? ((std::max((
float)maxBin - curBinVertical, 0.f))/maxBin)*gridHeight: 0;
194 path.lineTo(QPointF((i*barWidth) - (barWidth*0.5),
v));
195
196 }
197 path.lineTo(QPointF(this->width(), gridHeight));
198 path.closeSubpath();
199 painter.drawPath(path);
200 } else {
201 painter.setBrush(color);
202 painter.setPen(Qt::transparent);
203 float start = 1.0;
204 for (qint32 i = 0; i < nBins; ++i) {
205
206 const float curBinEnd = 1.0+(i*barWidth)+barWidth;
209 if (curBinVertical > 0) {
210 const int v = std::max(qRound((curBinVertical/maxBin)*gridHeight), 1);
211 const QRect bar(QPoint(qRound(start), std::max(gridHeight -
v, 0)),
212 QPoint(qRound(curBinEnd), gridHeight));
213 painter.drawRect(bar);
214 }
215 start = curBinEnd;
216 }
217 }
218 }
219 }
220 }
221}
@ ALPHA
The channel represents the opacity of a pixel.
QList< KoChannelInfo * > channels
virtual quint32 channelCount() const =0
virtual quint32 colorChannelCount() const =0
constexpr std::enable_if< sizeof...(values)==0, size_t >::type max()
rgba palette[MAX_PALETTE]