- Timestamp:
- Sep 24, 2019 3:00:42 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp
r80913 r80979 164 164 void setIsPieChartAllowed(bool fWithPieChart); 165 165 166 bool drawPieChart() const;167 void set DrawPieChart(bool fDrawPieChart);166 bool usePieChart() const; 167 void setShowPieChart(bool fShowPieChart); 168 168 169 169 bool useGradientLineColor() const; 170 170 void setUseGradientLineColor(bool fUseGradintLineColor); 171 172 bool useAreaChart() const; 173 void setUseAreaChart(bool fUseAreaChart); 174 175 bool isAreaChartAllowed() const; 176 void setIsAreaChartAllowed(bool fIsAreaChartAllowed); 171 177 172 178 QColor dataSeriesColor(int iDataSeriesIndex); … … 187 193 void sltCreateContextMenu(const QPoint &point); 188 194 void sltResetMetric(); 189 void sltSetDrawPieChart(bool fDrawPieChart); 195 void sltSetShowPieChart(bool fShowPieChart); 196 void sltSetUseAreaChart(bool fUseAreaChart); 190 197 191 198 private: … … 224 231 * option to show it to user. see m_fIsPieChartAllowed. */ 225 232 bool m_fIsPieChartAllowed; 226 /** m_f DrawPieChart is considered only if m_fIsPieChartAllowed is true. */227 bool m_f DrawPieChart;233 /** m_fShowPieChart is considered only if m_fIsPieChartAllowed is true. */ 234 bool m_fShowPieChart; 228 235 bool m_fUseGradientLineColor; 236 /** When it is true we draw an area graph where data series drawn on top of each other. 237 * We draw first data0 then data 1 on top. Makes sense where the summation of data is guaranteed not to exceed some max. */ 238 bool m_fUseAreaChart; 239 /** For some charts it does not make sense to have an area chart. */ 240 bool m_fIsAreaChartAllowed; 229 241 QColor m_dataSeriesColor[DATA_SERIES_SIZE]; 230 242 QString m_strXAxisLabel; … … 232 244 QString m_strResetActionLabel; 233 245 QString m_strPieChartToggleActionLabel; 246 QString m_strAreaChartToggleActionLabel; 234 247 }; 235 248 … … 543 556 , m_iOverlayAlpha(80) 544 557 , m_fIsPieChartAllowed(false) 545 , m_f DrawPieChart(true)558 , m_fShowPieChart(true) 546 559 , m_fUseGradientLineColor(false) 560 , m_fUseAreaChart(true) 561 , m_fIsAreaChartAllowed(false) 547 562 { 548 563 setContextMenuPolicy(Qt::CustomContextMenu); … … 589 604 } 590 605 591 bool UIChart:: drawPieChart() const592 { 593 return m_f DrawPieChart;594 } 595 596 void UIChart::set DrawPieChart(bool fDrawChart)597 { 598 if (m_f DrawPieChart == fDrawChart)599 return; 600 m_f DrawPieChart = fDrawChart;606 bool UIChart::usePieChart() const 607 { 608 return m_fShowPieChart; 609 } 610 611 void UIChart::setShowPieChart(bool fDrawChart) 612 { 613 if (m_fShowPieChart == fDrawChart) 614 return; 615 m_fShowPieChart = fDrawChart; 601 616 update(); 602 617 } … … 615 630 } 616 631 632 bool UIChart::useAreaChart() const 633 { 634 return m_fUseAreaChart; 635 } 636 637 void UIChart::setUseAreaChart(bool fUseAreaChart) 638 { 639 if (m_fUseAreaChart == fUseAreaChart) 640 return; 641 m_fUseAreaChart = fUseAreaChart; 642 update(); 643 } 644 645 bool UIChart::isAreaChartAllowed() const 646 { 647 return m_fIsAreaChartAllowed; 648 } 649 650 void UIChart::setIsAreaChartAllowed(bool fIsAreaChartAllowed) 651 { 652 m_fIsAreaChartAllowed = fIsAreaChartAllowed; 653 } 617 654 618 655 QColor UIChart::dataSeriesColor(int iDataSeriesIndex) … … 658 695 m_strResetActionLabel = QApplication::translate("UIVMInformationDialog", "Reset"); 659 696 m_strPieChartToggleActionLabel = QApplication::translate("UIVMInformationDialog", "Show Pie Chart"); 697 m_strAreaChartToggleActionLabel = QApplication::translate("UIVMInformationDialog", "Draw Area Chart"); 660 698 update(); 661 699 } … … 729 767 if (!m_fUseGradientLineColor) 730 768 painter.setPen(QPen(m_dataSeriesColor[k], 2.5)); 731 for (int i = 0; i < data->size() - 1; ++i)769 if (m_fUseAreaChart && m_fIsAreaChartAllowed) 732 770 { 733 int j = i + 1; 734 float fHeight = fH * data->at(i); 735 float fX = (width() - m_iMarginRight) - ((data->size() -i - 1) * fBarWidth); 736 float fHeight2 = fH * data->at(j); 737 float fX2 = (width() - m_iMarginRight) - ((data->size() -j - 1) * fBarWidth); 738 QLineF bar(fX, height() - (fHeight + m_iMarginBottom), fX2, height() - (fHeight2 + m_iMarginBottom)); 739 painter.drawLine(bar); 771 QVector<QPointF> points; 772 for (int i = 0; i < data->size(); ++i) 773 { 774 float fHeight = fH * data->at(i); 775 if (k == 0) 776 { 777 if (m_pMetric->data(1) && m_pMetric->data(1)->size() > i) 778 fHeight += fH * m_pMetric->data(1)->at(i); 779 } 780 float fX = (width() - m_iMarginRight) - ((data->size() - i - 1) * fBarWidth); 781 if (i == 0) 782 points << QPointF(fX, height() - m_iMarginBottom); 783 points << QPointF(fX, height() - (fHeight + m_iMarginBottom)); 784 if (i == data->size() - 1) 785 points << QPointF(fX, height() - + m_iMarginBottom); 786 } 787 painter.setPen(Qt::NoPen); 788 painter.setBrush(m_dataSeriesColor[k]); 789 painter.drawPolygon(points, Qt::WindingFill); 790 } 791 else 792 { 793 for (int i = 0; i < data->size() - 1; ++i) 794 { 795 int j = i + 1; 796 float fHeight = fH * data->at(i); 797 float fX = (width() - m_iMarginRight) - ((data->size() -i - 1) * fBarWidth); 798 float fHeight2 = fH * data->at(j); 799 float fX2 = (width() - m_iMarginRight) - ((data->size() -j - 1) * fBarWidth); 800 QLineF bar(fX, height() - (fHeight + m_iMarginBottom), fX2, height() - (fHeight2 + m_iMarginBottom)); 801 painter.drawLine(bar); 802 } 740 803 } 741 804 } … … 764 827 } 765 828 766 if (m_fIsPieChartAllowed && m_f DrawPieChart)829 if (m_fIsPieChartAllowed && m_fShowPieChart) 767 830 drawCombinedPieCharts(painter, iMaximum); 768 831 } … … 969 1032 QAction *pPieChartToggle = menu.addAction(m_strPieChartToggleActionLabel); 970 1033 pPieChartToggle->setCheckable(true); 971 pPieChartToggle->setChecked(m_fDrawPieChart); 972 connect(pPieChartToggle, &QAction::toggled, this, &UIChart::sltSetDrawPieChart); 973 } 1034 pPieChartToggle->setChecked(m_fShowPieChart); 1035 connect(pPieChartToggle, &QAction::toggled, this, &UIChart::sltSetShowPieChart); 1036 } 1037 if (m_fIsAreaChartAllowed) 1038 { 1039 QAction *pAreaChartToggle = menu.addAction(m_strAreaChartToggleActionLabel); 1040 pAreaChartToggle->setCheckable(true); 1041 pAreaChartToggle->setChecked(m_fUseAreaChart); 1042 connect(pAreaChartToggle, &QAction::toggled, this, &UIChart::sltSetUseAreaChart); 1043 } 1044 974 1045 menu.exec(mapToGlobal(point)); 975 1046 } … … 981 1052 } 982 1053 983 void UIChart::sltSetDrawPieChart(bool fDrawPieChart) 984 { 985 setDrawPieChart(fDrawPieChart); 1054 void UIChart::sltSetShowPieChart(bool fShowPieChart) 1055 { 1056 setShowPieChart(fShowPieChart); 1057 } 1058 1059 void UIChart::sltSetUseAreaChart(bool fUseAreaChart) 1060 { 1061 setUseAreaChart(fUseAreaChart); 986 1062 } 987 1063 … … 1297 1373 /* Configure charts: */ 1298 1374 if (m_charts.contains(m_strCPUMetricName) && m_charts[m_strCPUMetricName]) 1375 { 1299 1376 m_charts[m_strCPUMetricName]->setIsPieChartAllowed(true); 1377 m_charts[m_strCPUMetricName]->setIsAreaChartAllowed(true); 1378 } 1300 1379 1301 1380 m_pRuntimeInfoWidget = new UIRuntimeInfoWidget(0, m_machine, m_console);
Note:
See TracChangeset
for help on using the changeset viewer.