Changeset 83496 in vbox
- Timestamp:
- Mar 31, 2020 12:02:10 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/monitor
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/monitor/UIMonitorCommon.cpp
r83380 r83496 17 17 18 18 /* Qt includes: */ 19 #include <QPainter> 19 20 #include <QXmlStreamReader> 20 21 … … 147 148 } 148 149 } 150 151 /* static */ 152 QPainterPath UIMonitorCommon::doughnutSlice(const QRectF &outerRectangle, const QRectF &innerRectangle, float fStartAngle, float fSweepAngle) 153 { 154 QPainterPath subPath1; 155 subPath1.moveTo(outerRectangle.center()); 156 subPath1.arcTo(outerRectangle, fStartAngle, 157 -1.f * fSweepAngle); 158 subPath1.closeSubpath(); 159 160 QPainterPath subPath2; 161 subPath2.moveTo(innerRectangle.center()); 162 subPath2.arcTo(innerRectangle, fStartAngle, 163 -1.f * fSweepAngle); 164 subPath2.closeSubpath(); 165 166 return subPath1.subtracted(subPath2); 167 } 168 169 /* static */ 170 QPainterPath UIMonitorCommon::wholeArc(const QRectF &rectangle) 171 { 172 QPainterPath arc; 173 arc.addEllipse(rectangle); 174 return arc; 175 } 176 177 /* static */ 178 void UIMonitorCommon::drawCombinedDoughnutChart(quint64 data1, const QColor &data1Color, 179 quint64 data2, const QColor &data2Color, 180 QPainter &painter, quint64 iMaximum, 181 const QRectF &chartRect, const QRectF &innerRect, int iOverlayAlpha) 182 { 183 /* Draw two arcs. one for the inner the other for the outer circle: */ 184 painter.setPen(QPen(QColor(100, 100, 100, iOverlayAlpha), 1)); 185 painter.drawArc(chartRect, 0, 3600 * 16); 186 painter.drawArc(innerRect, 0, 3600 * 16); 187 188 /* Draw a translucent white background: */ 189 QPainterPath background = wholeArc(chartRect).subtracted(wholeArc(innerRect)); 190 painter.setPen(Qt::NoPen); 191 painter.setBrush(QColor(255, 255, 255, iOverlayAlpha)); 192 painter.drawPath(background); 193 194 /* Draw a doughnut slice for the first data series: */ 195 float fAngle = 360.f * data1 / (float)iMaximum; 196 painter.setBrush(data1Color); 197 painter.drawPath(doughnutSlice(chartRect, innerRect, 90, fAngle)); 198 199 float fAngle2 = 360.f * data2 / (float)iMaximum; 200 painter.setBrush(data2Color); 201 painter.drawPath(doughnutSlice(chartRect, innerRect, 90 - fAngle, fAngle2)); 202 } -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/UIMonitorCommon.h
r83380 r83496 49 49 QVector<CUnknown>& objectList, quint64 &iOutTotalRAM, quint64 &iOutFreeRAM); 50 50 51 52 static QPainterPath doughnutSlice(const QRectF &outerRectangle, const QRectF &innerRectangle, float fStartAngle, float fSweepAngle); 53 static QPainterPath wholeArc(const QRectF &rectangle); 54 static void drawCombinedDoughnutChart(quint64 data1, const QColor &data1Color, 55 quint64 data2, const QColor &data2Color, 56 QPainter &painter, quint64 iMaximum, 57 const QRectF &chartRect, const QRectF &innerRect, int iOverlayAlpha); 58 59 51 60 private: 52 61 -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/performance/UIPerformanceMonitor.cpp
r83380 r83496 108 108 void drawDoughnutChart(QPainter &painter, quint64 iMaximum, int iDataIndex, 109 109 const QRectF &chartRect, const QRectF &innerRect); 110 /** Draws a doughnut shaped shart for two data series combines. the 2nd data is added on top of 1st. */111 void drawCombinedDoughnutChart(QPainter &painter, quint64 iMaximum,112 const QRectF &chartRect, const QRectF &innerRect);113 110 114 111 /** Drawing an overlay rectangle over the charts to indicate that they are disabled. */ 115 112 void drawDisabledChartRectangle(QPainter &painter); 116 /* Returns a half translucent complete arc. */117 QPainterPath wholeArc(const QRectF &rectangle);118 QPainterPath doughnutSlice(const QRectF &outerRectangle, const QRectF &innerRectangle,119 float fStartAngle, float fSweepAngle);120 113 QConicalGradient conicalGradientForDataSeries(const QRectF &rectangle, int iDataIndex); 121 114 /** @} */ … … 187 180 retranslateUi(); 188 181 } 189 190 182 191 183 bool UIChart::isPieChartAllowed() const … … 474 466 475 467 /* Draw a white filled circle and that the arc for data: */ 476 QPainterPath background = wholeArc(chartRect);468 QPainterPath background = UIMonitorCommon::wholeArc(chartRect); 477 469 painter.setPen(Qt::NoPen); 478 470 painter.setBrush(QColor(255, 255, 255, m_iOverlayAlpha)); … … 502 494 503 495 /* Draw a white filled circle and the arc for data: */ 504 QPainterPath background = wholeArc(chartRect).subtracted(wholeArc(innerRect));496 QPainterPath background = UIMonitorCommon::wholeArc(chartRect).subtracted(UIMonitorCommon::wholeArc(innerRect)); 505 497 painter.setPen(Qt::NoPen); 506 498 painter.setBrush(QColor(255, 255, 255, m_iOverlayAlpha)); … … 510 502 float fAngle = 360.f * data->back() / (float)iMaximum; 511 503 painter.setBrush(conicalGradientForDataSeries(chartRect, iDataIndex)); 512 painter.drawPath(doughnutSlice(chartRect, innerRect, 90, fAngle)); 513 } 514 515 void UIChart::drawCombinedDoughnutChart(QPainter &painter, quint64 iMaximum, 516 const QRectF &chartRect, const QRectF &innerRect) 517 { 518 int iDataIndex = 0; 519 const QQueue<quint64> *data = m_pMetric->data(iDataIndex); 520 if (!data || data->isEmpty()) 521 return; 522 523 /* Draw two arcs. one for the inner the other for the outer circle: */ 524 painter.setPen(QPen(QColor(100, 100, 100, m_iOverlayAlpha), 1)); 525 painter.drawArc(chartRect, 0, 3600 * 16); 526 painter.drawArc(innerRect, 0, 3600 * 16); 527 528 /* Draw a translucent white background: */ 529 QPainterPath background = wholeArc(chartRect).subtracted(wholeArc(innerRect)); 530 painter.setPen(Qt::NoPen); 531 painter.setBrush(QColor(255, 255, 255, m_iOverlayAlpha)); 532 painter.drawPath(background); 533 534 /* Draw a doughnut slice for the first data series: */ 535 float fAngle = 360.f * data->back() / (float)iMaximum; 536 painter.setBrush(dataSeriesColor(iDataIndex, 50)); 537 painter.drawPath(doughnutSlice(chartRect, innerRect, 90, fAngle)); 538 539 /* Draw another slice for 2nd data series on top of the first if necessary: */ 540 iDataIndex = 1; 541 const QQueue<quint64> *data2 = m_pMetric->data(iDataIndex); 542 if (data2 && !data2->isEmpty()) 543 { 544 float fAngle2 = 360.f * data2->back() / (float)iMaximum; 545 painter.setBrush(dataSeriesColor(iDataIndex, 50)); 546 painter.drawPath(doughnutSlice(chartRect, innerRect, 90 - fAngle, fAngle2)); 547 } 548 } 549 550 QPainterPath UIChart::wholeArc(const QRectF &rectangle) 551 { 552 QPainterPath arc; 553 arc.addEllipse(rectangle); 554 return arc; 504 painter.drawPath(UIMonitorCommon::doughnutSlice(chartRect, innerRect, 90, fAngle)); 555 505 } 556 506 … … 567 517 } 568 518 569 QPainterPath UIChart::doughnutSlice(const QRectF &outerRectangle, const QRectF &innerRectangle, float fStartAngle, float fSweepAngle)570 {571 QPainterPath subPath1;572 subPath1.moveTo(outerRectangle.center());573 subPath1.arcTo(outerRectangle, fStartAngle,574 -1.f * fSweepAngle);575 subPath1.closeSubpath();576 577 QPainterPath subPath2;578 subPath2.moveTo(innerRectangle.center());579 subPath2.arcTo(innerRectangle, fStartAngle,580 -1.f * fSweepAngle);581 subPath2.closeSubpath();582 583 return subPath1.subtracted(subPath2);584 }585 586 519 void UIChart::drawCombinedPieCharts(QPainter &painter, quint64 iMaximum) 587 520 { … … 600 533 QSizeF(0.5 * chartRect.width(), 0.5 * chartRect.height())); 601 534 /* Draw a doughnut chart where data series are stacked on to of each other: */ 602 drawCombinedDoughnutChart(painter, iMaximum, chartRect, innerRect); 535 if (m_pMetric->data(0) && !m_pMetric->data(0)->isEmpty() && 536 m_pMetric->data(1) && !m_pMetric->data(1)->isEmpty()) 537 UIMonitorCommon::drawCombinedDoughnutChart(m_pMetric->data(0)->back(), dataSeriesColor(0, 50), 538 m_pMetric->data(1)->back(), dataSeriesColor(1, 50), 539 painter, iMaximum, chartRect, innerRect, m_iOverlayAlpha); 603 540 #if 0 604 541 /* Draw a doughnut shaped chart and then pie chart inside it: */ -
trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp
r83494 r83496 61 61 }; 62 62 63 64 /********************************************************************************************************************************* 65 * Class UIVMResourceMonitorHostStatsWidget definition. * 66 *********************************************************************************************************************************/ 67 68 class UIVMResourceMonitorHostStatsWidget : public QWidget 69 { 70 71 Q_OBJECT; 72 73 74 public: 75 76 UIVMResourceMonitorHostStatsWidget(QWidget *pParent = 0); 77 78 }; 79 63 80 /********************************************************************************************************************************* 64 81 * Class UIVMResourceMonitorTableView definition. * … … 167 184 }; 168 185 169 /********************************************************************************************************************************* 170 * Class UIVMResourceMonitorProxyModel definition. * 186 187 /********************************************************************************************************************************* 188 * Class UIVMResourceMonitorProxyModel definition. * 171 189 *********************************************************************************************************************************/ 172 190 class UIResourceMonitorProxyModel : public QSortFilterProxyModel … … 250 268 251 269 /********************************************************************************************************************************* 252 * UIVMResourceMonitorDelegate definition. 270 * UIVMResourceMonitorDelegate definition. * 253 271 *********************************************************************************************************************************/ 254 272 /** A QItemDelegate child class to disable dashed lines drawn around selected cells in QTableViews */ … … 264 282 265 283 266 267 /********************************************************************************************************************************* 268 * Class UIVMResourceMonitorTableView implementation. * 284 /********************************************************************************************************************************* 285 * Class UIVMResourceMonitorHostStatsWidget implementation. * 286 *********************************************************************************************************************************/ 287 288 UIVMResourceMonitorHostStatsWidget::UIVMResourceMonitorHostStatsWidget(QWidget *pParent /* = 0 */) 289 :QWidget(pParent) 290 { 291 } 292 293 294 /********************************************************************************************************************************* 295 * Class UIVMResourceMonitorTableView implementation. * 269 296 *********************************************************************************************************************************/ 270 297 … … 414 441 415 442 /********************************************************************************************************************************* 416 * Class UIVMResourceMonitorHostStats implementation. 443 * Class UIVMResourceMonitorHostStats implementation. * 417 444 *********************************************************************************************************************************/ 418 445 … … 427 454 428 455 /********************************************************************************************************************************* 429 * Class UIVMResourceMonitorCheckBox implementation. 456 * Class UIVMResourceMonitorCheckBox implementation. * 430 457 *********************************************************************************************************************************/ 431 458 … … 446 473 447 474 /********************************************************************************************************************************* 448 * Class UIVMResourceMonitorProxyModel implementation. 475 * Class UIVMResourceMonitorProxyModel implementation. * 449 476 *********************************************************************************************************************************/ 450 477 UIResourceMonitorProxyModel::UIResourceMonitorProxyModel(QObject *parent /* = 0 */)
Note:
See TracChangeset
for help on using the changeset viewer.