VirtualBox

Changeset 80250 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 13, 2019 12:45:41 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9510: Some more improvements on charts etc.

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  
    3737#include "CPerformanceMetric.h"
    3838
     39#define DATA_SERIES_SIZE 2
    3940const ULONG iPeriod = 1;
    4041const int iMaximumQueueSize = 120;
    4142const int iMetricSetupCount = 1;
    4243const int iDecimalCount = 2;
     44
    4345/*********************************************************************************************************************************
    4446*   UIChart definition.                                                                                     *
     
    9193    QStringList m_textList;
    9294    int m_iPieChartSize;
    93     QRect m_pieChartRect;
     95    QRect m_pieChartRect[DATA_SERIES_SIZE];
    9496    bool m_fDrawPieChart;
    9597    bool m_fUseGradientLineColor;
    96     QColor m_dataSeriesColor[2];
     98    QColor m_dataSeriesColor[DATA_SERIES_SIZE];
    9799    QString m_strXAxisLabel;
    98100};
     
    118120    m_iMarginBottom = 2 * qApp->QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin);
    119121    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);
    121124    m_size = QSize(6 * m_iPieChartSize, 2 * m_iPieChartSize);
    122125}
     
    172175QColor UIChart::dataSeriesColor(int iDataSeriesIndex)
    173176{
    174     if (iDataSeriesIndex >= 2)
     177    if (iDataSeriesIndex >= DATA_SERIES_SIZE)
    175178        return QColor();
    176179    return m_dataSeriesColor[iDataSeriesIndex];
     
    179182void UIChart::setDataSeriesColor(int iDataSeriesIndex, const QColor &color)
    180183{
    181     if (iDataSeriesIndex >= 2)
     184    if (iDataSeriesIndex >= DATA_SERIES_SIZE)
    182185        return;
    183186    if (m_dataSeriesColor[iDataSeriesIndex] == color)
     
    285288    float fBarWidth = iChartWidth / (float) (iMaximumQueueSize - 1);
    286289    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
    297300        const QQueue<ULONG> *data = m_pSubMetric->data(k);
    298301        if (!m_fUseGradientLineColor)
     
    354357void UIChart::drawPieCharts(QPainter &painter, ULONG iMaximum)
    355358{
    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
    383388        QPainterPath dataPath;
    384389        dataPath.moveTo(center);
    385390        float fAngle = 360.f * data->back() / (float)iMaximum;
    386         dataPath.arcTo(m_pieChartRect, 90/*startAngle*/,
     391        dataPath.arcTo(m_pieChartRect[i], 90/*startAngle*/,
    387392                       -1 * fAngle /*sweepLength*/);
    388393        painter.setBrush(pieGradient);
    389394        painter.drawPath(dataPath);
     395
    390396    }
    391397}
     
    436442void UISubMetric::addData(int iDataSeriesIndex, ULONG fData)
    437443{
    438     if (iDataSeriesIndex >= 2)
     444    if (iDataSeriesIndex >= DATA_SERIES_SIZE)
    439445        return;
    440446    m_data[iDataSeriesIndex].enqueue(fData);
     
    445451const QQueue<ULONG> *UISubMetric::data(int iDataSeriesIndex) const
    446452{
    447     if (iDataSeriesIndex >= 2)
     453    if (iDataSeriesIndex >= DATA_SERIES_SIZE)
    448454        return 0;
    449455    return &m_data[iDataSeriesIndex];
     
    498504    m_strCPUInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "CPU Load");
    499505    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());
    500511
    501512    m_strRAMInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "RAM Usage");
     
    526537            QFontMetrics labelFontMetric(pLabel->font());
    527538            int iWidth = iMaximum * labelFontMetric.width('x');
    528             printf("%d %d\n", labelFontMetric.width('x'), labelFontMetric.width('X'));
    529539            foreach (QLabel *pInfoLabel, m_infoLabels)
    530540                pInfoLabel->setFixedWidth(iWidth);
     
    576586    if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName])
    577587        m_charts[m_strCPUMetricName]->setUseGradientLineColor(false);
     588    if (m_charts.contains(m_strRAMMetricName) && m_charts[m_strRAMMetricName])
     589        m_charts[m_strRAMMetricName]->setUseGradientLineColor(false);
    578590
    579591    QWidget *bottomSpacerWidget = new QWidget(this);
     
    622634        if (aReturnDataLengths[i] == 0)
    623635            continue;
    624         if (aReturnNames[i].contains("Disk"), Qt::CaseInsensitive)
    625             printf("%f\n", 22.2);
    626636        /* Read the last of the return data disregarding the rest since we are caching the data in GUI side: */
    627637        float fData = returnData[aReturnDataIndices[i] + aReturnDataLengths[i] - 1] / (float)aReturnScales[i];
     
    755765    CPUMetric.addData(1, iOtherPercentage);
    756766    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])
    758768    {
    759769        QString strInfo;
     770        QString strReceiveColor;
    760771        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));
    762778        else
    763779            strInfo = QString("<b>%1</b><br/>%2%3").arg(m_strCPUInfoLabelTitle).arg("--").arg("%");
    764780        m_infoLabels[m_strCPUMetricName]->setText(strInfo);
    765781    }
     782
    766783    if (m_charts.contains(m_strCPUMetricName))
    767784        m_charts[m_strCPUMetricName]->update();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIPerformanceMonitor.h

    r80249 r80250  
    144144        /** CPU info label strings. */
    145145        QString m_strCPUInfoLabelTitle;
     146        QString m_strCPUInfoLabelGuest;
     147        QString  m_strCPUInfoLabelVMM;
    146148        /** RAM usage info label strings. */
    147149        QString m_strRAMInfoLabelTitle;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette