MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / paintEvent

Method paintEvent

ASAP/MiniMap.cpp:65–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65void MiniMap::paintEvent(QPaintEvent *event) {
66 QPainter painter(this);
67 if (!_overview.isNull()) {
68 painter.drawPixmap(1, 1, width(), height(), _overview);
69 painter.setPen(QPen(Qt::white, 2));
70 painter.drawRect(1, 1, width() - 2, height() - 2);
71 painter.setPen(QPen(Qt::black, 1));
72 painter.drawRect(0, 0, width() - 1, height() - 1);
73 if (_manager && _drawCoverageMap) {
74 painter.save();
75 std::vector<QPainterPath> pths = _manager->getCoverageMaps();
76 QPainterPath bck;
77 bck.addRect(QRectF(0, 0, width() - 1., height() - 1.));
78 painter.setPen(Qt::PenStyle::NoPen);
79 painter.setBrush(QBrush(QColor(0, 0, 0, 50)));
80 painter.drawPath(bck);
81 for (std::vector<QPainterPath>::const_iterator it = pths.begin(); it != pths.end(); ++it) {
82 if (!it->isEmpty()) {
83 QTransform trans;
84 trans = trans.scale(width() / static_cast<float>(_overview.width()), height() / static_cast<float>(_overview.height()));
85 QPainterPath qpf2 = trans.map(*it);
86 unsigned int colorIndex = (it - pths.begin()) % 6;
87 painter.setPen(QPen(QColor(coverageColors[colorIndex])));
88 painter.setBrush(QBrush(QColor(255, 255, 255, 50 / (it - pths.begin() + 1))));
89 painter.drawPath(qpf2);
90 }
91 }
92 painter.restore();
93 }
94 if (_fieldOfView.isValid() && !_fieldOfView.isEmpty()) {
95 QPen blue = QPen(QColor("blue"));
96 blue.setWidth(3);
97 painter.setPen(blue);
98 float rectX = width() * (_fieldOfView.left() / _overview.width()) + 1;
99 float rectY = height() * (_fieldOfView.top() / _overview.height()) + 1;
100 float rectW = width() * (_fieldOfView.width() / _overview.width()) - 2;
101 float rectH = height() * (_fieldOfView.height() / _overview.height()) - 2;
102 if (rectW > 3 && rectH > 3) {
103 painter.drawRect(rectX, rectY, rectW, rectH);
104 }
105 else {
106 painter.drawLine(rectX + rectW / 2. - 5, rectY + rectH / 2., rectX + rectW / 2. + 5, rectY + rectH / 2.);
107 painter.drawLine(rectX + rectW / 2., rectY + rectH / 2. - 5, rectX + rectW / 2., rectY + rectH / 2. + 5);
108 }
109 }
110 }
111}
112
113QSize MiniMap::sizeHint() const {
114 QSize size(0, 0);

Callers

nothing calls this directly

Calls 2

getCoverageMapsMethod · 0.80
saveMethod · 0.45

Tested by

no test coverage detected