MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / paint_hover_measure

Method paint_hover_measure

DSView/pv/view/dsosignal.cpp:1262–1324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1260}
1261
1262void DsoSignal::paint_hover_measure(QPainter &p, QColor fore, QColor back)
1263{
1264 const int hw_offset = get_hw_offset();
1265 // Hover measure
1266 if (_hover_en && _hover_point != QPointF(-1, -1)) {
1267 QString hover_str = get_voltage(hw_offset - _hover_value, 2);
1268 const int hover_width = p.boundingRect(0, 0, INT_MAX, INT_MAX,
1269 Qt::AlignLeft | Qt::AlignTop, hover_str).width() + 10;
1270 const int hover_height = p.boundingRect(0, 0, INT_MAX, INT_MAX,
1271 Qt::AlignLeft | Qt::AlignTop, hover_str).height();
1272 QRectF hover_rect(_hover_point.x(), _hover_point.y()-hover_height/2, hover_width, hover_height);
1273 if (hover_rect.right() > get_view_rect().right())
1274 hover_rect.moveRight(_hover_point.x());
1275 if (hover_rect.top() < get_view_rect().top())
1276 hover_rect.moveTop(_hover_point.y());
1277 if (hover_rect.bottom() > get_view_rect().bottom())
1278 hover_rect.moveBottom(_hover_point.y());
1279
1280 p.setPen(fore);
1281 p.setBrush(back);
1282 p.drawRect(_hover_point.x()-1, _hover_point.y()-1, HoverPointSize, HoverPointSize);
1283 p.drawText(hover_rect, Qt::AlignCenter | Qt::AlignTop | Qt::TextDontClip, hover_str);
1284 }
1285
1286 auto &cursor_list = _view->get_cursorList();
1287 auto i = cursor_list.begin();
1288
1289 while (i != cursor_list.end()) {
1290 float pt_value;
1291
1292 int chan_index = (*i)->index();
1293 if (_data->has_data(chan_index) == false){
1294 i++;
1295 continue;
1296 }
1297
1298 const QPointF pt = get_point(chan_index, pt_value);
1299 if (pt == QPointF(-1, -1)) {
1300 i++;
1301 continue;
1302 }
1303
1304 QString pt_str = get_voltage(hw_offset - pt_value, 2);
1305 const int pt_width = p.boundingRect(0, 0, INT_MAX, INT_MAX,
1306 Qt::AlignLeft | Qt::AlignTop, pt_str).width() + 10;
1307 const int pt_height = p.boundingRect(0, 0, INT_MAX, INT_MAX,
1308 Qt::AlignLeft | Qt::AlignTop, pt_str).height();
1309 QRectF pt_rect(pt.x(), pt.y()-pt_height/2, pt_width, pt_height);
1310 if (pt_rect.right() > get_view_rect().right())
1311 pt_rect.moveRight(pt.x());
1312 if (pt_rect.top() < get_view_rect().top())
1313 pt_rect.moveTop(pt.y());
1314 if (pt_rect.bottom() > get_view_rect().bottom())
1315 pt_rect.moveBottom(pt.y());
1316
1317 p.drawRect(pt.x()-1, pt.y()-1, 2, 2);
1318 p.drawLine(pt.x()-2, pt.y()-2, pt.x()+2, pt.y()+2);
1319 p.drawLine(pt.x()+2, pt.y()-2, pt.x()-2, pt.y()+2);

Callers

nothing calls this directly

Calls 3

indexMethod · 0.80
endMethod · 0.45
has_dataMethod · 0.45

Tested by

no test coverage detected