Changeset 80250 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 13, 2019 12:45:41 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIPerformanceMonitor.cpp
r80249 r80250 37 37 #include "CPerformanceMetric.h" 38 38 39 #define DATA_SERIES_SIZE 2 39 40 const ULONG iPeriod = 1; 40 41 const int iMaximumQueueSize = 120; 41 42 const int iMetricSetupCount = 1; 42 43 const int iDecimalCount = 2; 44 43 45 /********************************************************************************************************************************* 44 46 * UIChart definition. * … … 91 93 QStringList m_textList; 92 94 int m_iPieChartSize; 93 QRect m_pieChartRect ;95 QRect m_pieChartRect[DATA_SERIES_SIZE]; 94 96 bool m_fDrawPieChart; 95 97 bool m_fUseGradientLineColor; 96 QColor m_dataSeriesColor[ 2];98 QColor m_dataSeriesColor[DATA_SERIES_SIZE]; 97 99 QString m_strXAxisLabel; 98 100 }; … … 118 120 m_iMarginBottom = 2 * qApp->QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 119 121 m_iPieChartSize = 1.5f * qApp->style()->pixelMetric(QStyle::PM_LargeIconSize); 120 m_pieChartRect = QRect(1.5 * m_iMarginLeft, 1.5 * m_iMarginTop, m_iPieChartSize, m_iPieChartSize); 122 m_pieChartRect[0] = QRect(1.5 * m_iMarginLeft, 1.5 * m_iMarginTop, m_iPieChartSize, m_iPieChartSize); 123 m_pieChartRect[1] = QRect(m_pieChartRect[0].x() + m_iPieChartSize + 0.5 * m_iMarginLeft, 1.5 * m_iMarginTop, m_iPieChartSize, m_iPieChartSize); 121 124 m_size = QSize(6 * m_iPieChartSize, 2 * m_iPieChartSize); 122 125 } … … 172 175 QColor UIChart::dataSeriesColor(int iDataSeriesIndex) 173 176 { 174 if (iDataSeriesIndex >= 2)177 if (iDataSeriesIndex >= DATA_SERIES_SIZE) 175 178 return QColor(); 176 179 return m_dataSeriesColor[iDataSeriesIndex]; … … 179 182 void UIChart::setDataSeriesColor(int iDataSeriesIndex, const QColor &color) 180 183 { 181 if (iDataSeriesIndex >= 2)184 if (iDataSeriesIndex >= DATA_SERIES_SIZE) 182 185 return; 183 186 if (m_dataSeriesColor[iDataSeriesIndex] == color) … … 285 288 float fBarWidth = iChartWidth / (float) (iMaximumQueueSize - 1); 286 289 float fH = iChartHeight / (float)iMaximum; 287 if (m_fUseGradientLineColor)288 { 289 QLinearGradient gradient(0, 0, 0, iChartHeight);290 gradient.setColorAt(1.0, Qt::green);291 gradient.setColorAt(0.5, Qt::yellow);292 gradient.setColorAt(0.0, Qt::red);293 painter.setPen(QPen(gradient, 2.5));294 }295 for (int k = 0; k < 2; ++k)296 { 290 for (int k = 0; k < DATA_SERIES_SIZE; ++k) 291 { 292 if (m_fUseGradientLineColor) 293 { 294 QLinearGradient gradient(0, 0, 0, iChartHeight); 295 gradient.setColorAt(0, Qt::black); 296 gradient.setColorAt(1, m_dataSeriesColor[k]); 297 painter.setPen(QPen(gradient, 2.5)); 298 } 299 297 300 const QQueue<ULONG> *data = m_pSubMetric->data(k); 298 301 if (!m_fUseGradientLineColor) … … 354 357 void UIChart::drawPieCharts(QPainter &painter, ULONG iMaximum) 355 358 { 356 /* Draw a whole non-filled circle: */ 357 painter.setPen(QPen(Qt::gray, 1)); 358 painter.drawArc(m_pieChartRect, 0, 3600 * 16); 359 360 QPointF center(m_pieChartRect.center()); 361 QPainterPath fillPath; 362 fillPath.moveTo(center); 363 fillPath.arcTo(m_pieChartRect, 90/*startAngle*/, 364 -1 * 360 /*sweepLength*/); 365 366 /* First draw a white filled circle and that the arc for data: */ 367 painter.setPen(Qt::NoPen); 368 painter.setBrush(QColor(255, 255, 255, 175)); 369 painter.drawPath(fillPath); 370 371 /* Prepare the gradient for the pie chart: */ 372 QConicalGradient pieGradient; 373 pieGradient.setCenter(m_pieChartRect.center()); 374 pieGradient.setAngle(90); 375 pieGradient.setColorAt(0, Qt::red); 376 pieGradient.setColorAt(0.5, Qt::yellow); 377 pieGradient.setColorAt(1, Qt::green); 378 379 /* Draw the pie chart for the 0th data series only: */ 380 const QQueue<ULONG> *data = m_pSubMetric->data(0); 381 if (data && !data->isEmpty()) 382 { 359 for (int i = 0; i < DATA_SERIES_SIZE; ++i) 360 { 361 /* Draw the pie chart for the 0th data series only: */ 362 const QQueue<ULONG> *data = m_pSubMetric->data(i); 363 if (!data || data->isEmpty()) 364 continue; 365 366 /* Draw a whole non-filled circle: */ 367 painter.setPen(QPen(Qt::gray, 1)); 368 painter.drawArc(m_pieChartRect[i], 0, 3600 * 16); 369 370 QPointF center(m_pieChartRect[i].center()); 371 QPainterPath fillPath; 372 fillPath.moveTo(center); 373 fillPath.arcTo(m_pieChartRect[i], 90/*startAngle*/, 374 -1 * 360 /*sweepLength*/); 375 376 /* First draw a white filled circle and that the arc for data: */ 377 painter.setPen(Qt::NoPen); 378 painter.setBrush(QColor(255, 255, 255, 175)); 379 painter.drawPath(fillPath); 380 381 /* Prepare the gradient for the pie chart: */ 382 QConicalGradient pieGradient; 383 pieGradient.setCenter(m_pieChartRect[i].center()); 384 pieGradient.setAngle(90); 385 pieGradient.setColorAt(0, Qt::black); 386 pieGradient.setColorAt(1, m_dataSeriesColor[i]); 387 383 388 QPainterPath dataPath; 384 389 dataPath.moveTo(center); 385 390 float fAngle = 360.f * data->back() / (float)iMaximum; 386 dataPath.arcTo(m_pieChartRect , 90/*startAngle*/,391 dataPath.arcTo(m_pieChartRect[i], 90/*startAngle*/, 387 392 -1 * fAngle /*sweepLength*/); 388 393 painter.setBrush(pieGradient); 389 394 painter.drawPath(dataPath); 395 390 396 } 391 397 } … … 436 442 void UISubMetric::addData(int iDataSeriesIndex, ULONG fData) 437 443 { 438 if (iDataSeriesIndex >= 2)444 if (iDataSeriesIndex >= DATA_SERIES_SIZE) 439 445 return; 440 446 m_data[iDataSeriesIndex].enqueue(fData); … … 445 451 const QQueue<ULONG> *UISubMetric::data(int iDataSeriesIndex) const 446 452 { 447 if (iDataSeriesIndex >= 2)453 if (iDataSeriesIndex >= DATA_SERIES_SIZE) 448 454 return 0; 449 455 return &m_data[iDataSeriesIndex]; … … 498 504 m_strCPUInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "CPU Load"); 499 505 iMaximum = qMax(iMaximum, m_strCPUInfoLabelTitle.length()); 506 507 m_strCPUInfoLabelGuest = QApplication::translate("UIVMInformationDialog", "Guest Load"); 508 iMaximum = qMax(iMaximum, m_strCPUInfoLabelGuest.length()); 509 m_strCPUInfoLabelVMM = QApplication::translate("UIVMInformationDialog", "VMM Load"); 510 iMaximum = qMax(iMaximum, m_strCPUInfoLabelVMM.length()); 500 511 501 512 m_strRAMInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "RAM Usage"); … … 526 537 QFontMetrics labelFontMetric(pLabel->font()); 527 538 int iWidth = iMaximum * labelFontMetric.width('x'); 528 printf("%d %d\n", labelFontMetric.width('x'), labelFontMetric.width('X'));529 539 foreach (QLabel *pInfoLabel, m_infoLabels) 530 540 pInfoLabel->setFixedWidth(iWidth); … … 576 586 if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName]) 577 587 m_charts[m_strCPUMetricName]->setUseGradientLineColor(false); 588 if (m_charts.contains(m_strRAMMetricName) && m_charts[m_strRAMMetricName]) 589 m_charts[m_strRAMMetricName]->setUseGradientLineColor(false); 578 590 579 591 QWidget *bottomSpacerWidget = new QWidget(this); … … 622 634 if (aReturnDataLengths[i] == 0) 623 635 continue; 624 if (aReturnNames[i].contains("Disk"), Qt::CaseInsensitive)625 printf("%f\n", 22.2);626 636 /* Read the last of the return data disregarding the rest since we are caching the data in GUI side: */ 627 637 float fData = returnData[aReturnDataIndices[i] + aReturnDataLengths[i] - 1] / (float)aReturnScales[i]; … … 755 765 CPUMetric.addData(1, iOtherPercentage); 756 766 CPUMetric.setMaximum(100); 757 if (m_infoLabels.contains(m_strCPUMetricName) && m_infoLabels[m_strCPUMetricName])767 if (m_infoLabels.contains(m_strCPUMetricName) && m_infoLabels[m_strCPUMetricName]) 758 768 { 759 769 QString strInfo; 770 QString strReceiveColor; 760 771 if (m_infoLabels[m_strCPUMetricName]->isEnabled()) 761 strInfo = QString("<b>%1</b><br/>%2%3").arg(m_strCPUInfoLabelTitle).arg(QString::number(iExecutingPercentage)).arg("%"); 772 strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4\%</font><br/><font color=\"%5\">%6: %7\%</font>") 773 .arg(m_strCPUInfoLabelTitle) 774 .arg(dataColorString(m_strCPUMetricName, 0)) 775 .arg(m_strCPUInfoLabelGuest).arg(QString::number(iExecutingPercentage)) 776 .arg(dataColorString(m_strCPUMetricName, 1)) 777 .arg(m_strCPUInfoLabelVMM).arg(QString::number(iOtherPercentage)); 762 778 else 763 779 strInfo = QString("<b>%1</b><br/>%2%3").arg(m_strCPUInfoLabelTitle).arg("--").arg("%"); 764 780 m_infoLabels[m_strCPUMetricName]->setText(strInfo); 765 781 } 782 766 783 if (m_charts.contains(m_strCPUMetricName)) 767 784 m_charts[m_strCPUMetricName]->update(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIPerformanceMonitor.h
r80249 r80250 144 144 /** CPU info label strings. */ 145 145 QString m_strCPUInfoLabelTitle; 146 QString m_strCPUInfoLabelGuest; 147 QString m_strCPUInfoLabelVMM; 146 148 /** RAM usage info label strings. */ 147 149 QString m_strRAMInfoLabelTitle;
Note:
See TracChangeset
for help on using the changeset viewer.