MCPcopy Create free account
hub / github.com/KDE/labplot / drawBackground

Method drawBackground

src/frontend/widgets/DatapickerImageWidget.cpp:74–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void HistogramView::drawBackground(QPainter* painter, const QRectF& rect) {
75 if (!bins)
76 return;
77
78 painter->save();
79 painter->setRenderHint(QPainter::Antialiasing);
80 int max = 1;
81 for (int i = 0; i <= m_range; i++)
82 if (bins[i] > max)
83 max = bins[i];
84
85 // convert y-scale count to log scale so small counts are still visible
86 // scene rect is 1000*100 where upper 1000*80 is for histogram graph
87 // and lower 1000*20 is for histogram scale
88 QPainterPath path(QPointF(0, (log(bins[0]) * 100 / log(max))));
89 for (int i = 1; i <= m_range; i++) {
90 int x = i * 1000 / m_range;
91 int y = 80;
92 if (bins[i] > 1)
93 y = 80 - (log(bins[i]) * 80 / log(max));
94
95 path.lineTo(QPointF(x, y));
96 }
97
98 painter->drawPath(path);
99 invalidateScene(rect, QGraphicsScene::BackgroundLayer);
100 painter->restore();
101}
102
103DatapickerImageWidget::DatapickerImageWidget(QWidget* parent)
104 : BaseDock(parent)

Callers

nothing calls this directly

Calls 2

QPointFClass · 0.50
saveMethod · 0.45

Tested by

no test coverage detected