- Timestamp:
- Dec 13, 2023 7:43:13 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp
r102273 r102592 318 318 , m_fIsAvailable(true) 319 319 , m_fIsAreaChartAllowed(false) 320 , m_fDrawCurenValueIndicators( false)320 , m_fDrawCurenValueIndicators(true) 321 321 , m_iRightMarginCharWidth(10) 322 322 , m_iMaximumQueueSize(iMaximumQueueSize) … … 486 486 { 487 487 const int iX = width() - pEvent->position().x() - m_iMarginRight; 488 QPoint eventPosition(pEvent->position().x(), pEvent->position().y()); 488 489 m_iDataIndexUnderCursor = -1; 489 if (iX > m_iMarginLeft && iX <= width() - m_iMarginRight) 490 m_iDataIndexUnderCursor = (int)((iX) / m_fPixelPerDataPoint) + 1; 490 if (m_lineChartRect.contains(eventPosition)) 491 m_iDataIndexUnderCursor = m_iMaximumQueueSize - (int)((iX) / m_fPixelPerDataPoint) - 1; 492 //printf("m_iDataIndexUnderCursor %d\n", m_iDataIndexUnderCursor); 491 493 update(); 492 494 QIWithRetranslateUI<QWidget>::mouseMoveEvent(pEvent); … … 549 551 QFontMetrics fontMetrics(painter.font()); 550 552 int iFontHeight = fontMetrics.height(); 551 int iAverageFontWidth = fontMetrics.averageCharWidth();552 553 553 554 /* Draw the data lines: */ 554 555 float fBarWidth = m_lineChartRect.width() / (float) (m_iMaximumQueueSize - 1); 555 556 float fH = iMaximum == 0 ? 0 : m_lineChartRect.height() / (float)iMaximum; 557 const float fPenWidth = 1.5f; 558 const float fPointSize = 3.5f; 556 559 for (int k = 0; k < DATA_SERIES_SIZE; ++k) 557 560 { … … 561 564 gradient.setColorAt(0, Qt::black); 562 565 gradient.setColorAt(1, m_dataSeriesColor[k]); 563 painter.setPen(QPen(gradient, 2.5));566 painter.setPen(QPen(gradient, fPenWidth)); 564 567 } 565 568 const QQueue<quint64> *data = m_pMetric->data(k); 566 569 if (!m_fUseGradientLineColor) 567 painter.setPen(QPen(m_dataSeriesColor[k], 2.5));570 painter.setPen(QPen(m_dataSeriesColor[k], fPenWidth)); 568 571 if (m_fUseAreaChart && m_fIsAreaChartAllowed) 569 572 { … … 572 575 { 573 576 float fHeight = fH * data->at(i); 577 /* Stack 0th data series on top of the 1st data series: */ 574 578 if (k == 0) 575 579 { … … 590 594 else 591 595 { 596 /* Draw lines between data points: */ 592 597 for (int i = 0; i < data->size() - 1; ++i) 593 598 { 594 599 int j = i + 1; 595 600 float fHeight = fH * data->at(i); 596 float fX = (width() - m_iMarginRight) - ((data->size() - i - 1) * fBarWidth);601 float fX = (width() - m_iMarginRight) - ((data->size() - i - 1) * fBarWidth); 597 602 float fHeight2 = fH * data->at(j); 598 float fX2 = (width() - m_iMarginRight) - ((data->size() - j - 1) * fBarWidth);603 float fX2 = (width() - m_iMarginRight) - ((data->size() - j - 1) * fBarWidth); 599 604 QLineF bar(fX, height() - (fHeight + m_iMarginBottom), fX2, height() - (fHeight2 + m_iMarginBottom)); 600 605 painter.drawLine(bar); 606 } 607 /* Draw a point at each data point: */ 608 painter.setPen(QPen(m_dataSeriesColor[k], fPointSize)); 609 for (int i = 0; i < data->size(); ++i) 610 { 611 float fHeight = fH * data->at(i); 612 float fX = (width() - m_iMarginRight) - ((data->size() - i - 1) * fBarWidth); 613 painter.drawPoint(fX, height() - (fHeight + m_iMarginBottom)); 601 614 } 602 615 } … … 609 622 if (fHeight > 0) 610 623 { 611 painter.drawLine(m_iMarginLeft, height() - (fHeight + m_iMarginBottom), 612 width() - m_iMarginRight, height() - (fHeight + m_iMarginBottom)); 613 QPoint cursorPosition = mapFromGlobal(cursor().pos()); 624 // painter.drawLine(m_iMarginLeft, height() - (fHeight + m_iMarginBottom), 625 // width() - m_iMarginRight, height() - (fHeight + m_iMarginBottom)); 614 626 painter.setPen(mainAxisColor); 615 painter.drawLine(cursorPosition.x(), 0, 616 cursorPosition.x(), height() - m_iMarginBottom); 617 QString strValue = QString::number(data->at(data->size() - m_iDataIndexUnderCursor)); 618 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 619 painter.drawText(m_iMarginLeft - fontMetrics.horizontalAdvance(strValue) - iAverageFontWidth, 620 height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue); 621 #else 622 painter.drawText(m_iMarginLeft - fontMetrics.width(strValue) - iAverageFontWidth, 623 height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue); 624 #endif 627 float fX = (width() - m_iMarginRight) - ((data->size() - m_iDataIndexUnderCursor - 1) * fBarWidth); 628 painter.drawLine(fX, 0, fX, height() - m_iMarginBottom); 629 // int iAverageFontWidth = fontMetrics.averageCharWidth(); 630 // QString strValue = QString::number(data->at(data->size() - m_iDataIndexUnderCursor)); 631 // #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 632 // painter.drawText(m_iMarginLeft - fontMetrics.horizontalAdvance(strValue) - iAverageFontWidth, 633 // height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue); 634 // #else 635 // painter.drawText(m_iMarginLeft - fontMetrics.width(strValue) - iAverageFontWidth, 636 // height() - (fHeight + m_iMarginBottom) + 0.5 * iFontHeight, strValue); 637 // #endif 625 638 626 639 } … … 893 906 m_iMaximum = qMax(m_iMaximum, iData); 894 907 908 /* dequeue if needed and update the maximum value: */ 895 909 if (m_data[iDataSeriesIndex].size() > m_iMaximumQueueSize) 896 910 { … … 1142 1156 } 1143 1157 1144 /* Configure charts: */1145 if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName])1146 {1147 m_charts[m_strCPUMetricName]->setIsPieChartAllowed(true);1148 m_charts[m_strCPUMetricName]->setIsAreaChartAllowed(true);1149 }1150 1151 1158 QWidget *bottomSpacerWidget = new QWidget(this); 1152 1159 bottomSpacerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); … … 1293 1300 connect(&uiCommon(), &UICommon::sigAskToDetachCOM, this, &UIVMActivityMonitorLocal::sltClearCOMData); 1294 1301 setMachine(machine); 1302 1303 /* Configure charts: */ 1304 if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName]) 1305 { 1306 m_charts[m_strCPUMetricName]->setIsPieChartAllowed(true); 1307 m_charts[m_strCPUMetricName]->setIsAreaChartAllowed(true); 1308 } 1295 1309 } 1296 1310
Note:
See TracChangeset
for help on using the changeset viewer.

