MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / invalidate_

Method invalidate_

src/openms_gui/source/VISUAL/HistogramWidget.cpp:226–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224 }
225
226 void HistogramWidget::invalidate_()
227 {
228 //apply log trafo if needed
229 Math::Histogram<> dist(dist_);
230 if (log_mode_)
231 {
232 dist.applyLogTransformation(100.0);
233 }
234
235 QPainter painter(&buffer_);
236 buffer_.fill(palette().window().color());
237 UInt w = buffer_.width();
238 UInt h = buffer_.height();
239 UInt pen_width = std::min(margin_, UInt(0.5 * w / dist.size()));
240
241 //draw distribution
242 QPen pen;
243 pen.setWidth(pen_width);
244 pen.setColor(QColor(100, 125, 175));
245 painter.setPen(pen);
246
247 for (Size i = 0; i < dist.size(); ++i)
248 {
249 if (dist[i] != 0)
250 {
251 UInt bin_pos = UInt((double(i) / (dist.size() - 1)) * (w - margin_));
252 UInt bin_height = UInt(((double)dist[i] / dist.maxValue()) * (h - margin_));
253 painter.drawLine(bin_pos + 1, h, bin_pos + 1, h - bin_height);
254 }
255 }
256
257 //calculate total intensity
258 double total_sum = 0;
259 for (Size i = 0; i < dist.size(); ++i)
260 {
261 total_sum += dist[i];
262 }
263
264 // draw part of total intensity
265 painter.setPen(Qt::red);
266 QPoint last_point(1, h);
267 QPoint point;
268 double int_sum = 0;
269 for (Size i = 0; i < dist.size(); ++i)
270 {
271 int_sum += dist[i];
272 point.setX(UInt((double(i) / (dist.size() - 1)) * (w - margin_)));
273 point.setY(UInt((1 - (int_sum / total_sum)) * (h - margin_) + margin_));
274 painter.drawLine(last_point, point);
275 last_point = point;
276 }
277 // draw coord system (on top distribution)
278 painter.setPen(Qt::black);
279 painter.drawLine(0, h - 1, w - margin_ + Int(0.5 * pen_width), h - 1);
280
281 update();
282 }
283

Callers

nothing calls this directly

Calls 11

QColorClass · 0.85
colorMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80
maxValueMethod · 0.80
setXMethod · 0.80
setYMethod · 0.80
sizeMethod · 0.45
setWidthMethod · 0.45
setColorMethod · 0.45

Tested by

no test coverage detected