Changeset 102594 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Dec 14, 2023 2:06:44 PM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp
r102592 r102594 61 61 /** The time in seconds between metric inquries done to API. */ 62 62 const ULONG g_iPeriod = 1; 63 /** The number of data points we store in UIChart. with g_iPeriod=1 it corresponds to 2 min. of data. */ 64 //const int m_iMaximumQueueSize = 120; 63 65 64 /** This is passed to IPerformanceCollector during its setup. When 1 that means IPerformanceCollector object does a data cache of size 1. */ 66 65 const int g_iMetricSetupCount = 1; … … 202 201 QConicalGradient conicalGradientForDataSeries(const QRectF &rectangle, int iDataIndex); 203 202 /** @} */ 203 int maxDataSize() const; 204 204 205 205 UIMetric *m_pMetric; … … 487 487 const int iX = width() - pEvent->position().x() - m_iMarginRight; 488 488 QPoint eventPosition(pEvent->position().x(), pEvent->position().y()); 489 int iDataSize = maxDataSize(); 489 490 m_iDataIndexUnderCursor = -1; 490 if (m_lineChartRect.contains(eventPosition)) 491 if (iDataSize > 0 && m_lineChartRect.contains(eventPosition)) 492 { 491 493 m_iDataIndexUnderCursor = m_iMaximumQueueSize - (int)((iX) / m_fPixelPerDataPoint) - 1; 492 //printf("m_iDataIndexUnderCursor %d\n", m_iDataIndexUnderCursor); 494 m_iDataIndexUnderCursor = m_iDataIndexUnderCursor - (m_iMaximumQueueSize - iDataSize); 495 } 496 493 497 update(); 494 498 QIWithRetranslateUI<QWidget>::mouseMoveEvent(pEvent); … … 614 618 } 615 619 } 620 616 621 /* Draw a horizontal and vertical line on data point under the mouse cursor 617 622 * and draw the value on the left hand side of the chart: */ 618 623 if (m_fDrawCurenValueIndicators && m_iDataIndexUnderCursor >= 0 && m_iDataIndexUnderCursor < data->size()) 619 624 { 625 620 626 painter.setPen(QPen(m_dataSeriesColor[k], 0.5)); 621 float fHeight = fH * data->at(data->size() - m_iDataIndexUnderCursor); 622 if (fHeight > 0) 623 { 624 // painter.drawLine(m_iMarginLeft, height() - (fHeight + m_iMarginBottom), 625 // width() - m_iMarginRight, height() - (fHeight + m_iMarginBottom)); 626 painter.setPen(mainAxisColor); 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 638 639 } 627 painter.setPen(mainAxisColor); 628 float fX = (width() - m_iMarginRight) - ((data->size() - m_iDataIndexUnderCursor - 1) * fBarWidth); 629 painter.drawLine(fX, 0, fX, height() - m_iMarginBottom); 640 630 } 641 631 } … … 744 734 gradient.setColorAt(1, pieColor); 745 735 return gradient; 736 } 737 738 int UIChart::maxDataSize() const 739 { 740 int iSize = 0; 741 for (int k = 0; k < DATA_SERIES_SIZE; ++k) 742 { 743 if (m_pMetric->data(k)) 744 iSize = qMax(iSize, m_pMetric->data(k)->size()); 745 } 746 return iSize; 746 747 } 747 748 … … 858 859 , m_iMaximumQueueSize(iMaximumQueueSize) 859 860 { 860 RT_NOREF(iMaximumQueueSize); /* Unused according to Clang 11. */861 861 m_iTotal[0] = 0; 862 862 m_iTotal[1] = 0; … … 865 865 UIMetric::UIMetric() 866 866 : m_iMaximum(0) 867 #if 0 /* Unused according to Clang 11. */868 , m_iMaximumQueueSize(0)869 #endif870 867 , m_fRequiresGuestAdditions(false) 871 868 , m_fIsInitialized(false) 869 , m_iMaximumQueueSize(0) 872 870 { 873 871 }
Note:
See TracChangeset
for help on using the changeset viewer.