2,新增“Apps”; 3,新增“Common”; 4,新增“FileList”; 5,新增“MediaX”; 6,新增“OpenSource”; 7,新增“Samples”; 8,新增“SoftwareBusinessLines”.
120 lines
4.8 KiB
C++
120 lines
4.8 KiB
C++
#include "WaterfallChart.h"
|
|
#include "ui_WaterfallChart.h"
|
|
|
|
WaterfallChart::WaterfallChart(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::WaterfallChart)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
qint64 nFileSize = m_varDataParser.GetFileSize("..\\SoundSenseData.dat");
|
|
|
|
m_pDasStopData = new float[nFileSize/sizeof(float) + 1];
|
|
|
|
m_varDataParser.ParseFile(m_varDasStopDataHeader, m_pDasStopData, "..\\SoundSenseData.dat");
|
|
|
|
//
|
|
ui->m_pCustomPlot_WaterfallChart->setBackground(QColor(90,90,100,0) );
|
|
ui->m_pCustomPlot_WaterfallChart->axisRect()->setBackground(QColor(90,90,100,0) );
|
|
|
|
CustomPlot_Chart(0);
|
|
|
|
connect(ui->m_comboBox_ChartIndex, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &WaterfallChart::OnCurrentIndexChanged);
|
|
}
|
|
|
|
WaterfallChart::~WaterfallChart()
|
|
{
|
|
if(nullptr != m_pDasStopData)
|
|
{
|
|
delete [] m_pDasStopData;
|
|
m_pDasStopData = nullptr;
|
|
}
|
|
|
|
delete ui;
|
|
}
|
|
|
|
void WaterfallChart::CustomPlot_Chart(int nChartIndex)
|
|
{
|
|
//
|
|
//ui->m_pCustomPlot->setBackground(QColor(90,90,100,0) );
|
|
//ui->m_pCustomPlot->axisRect()->setBackground(QColor(90,90,100,0) );
|
|
|
|
|
|
/*
|
|
ui->m_pCustomPlot_WaterfallChart->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
|
|
QCP::iSelectLegend | QCP::iSelectPlottables);
|
|
*/
|
|
|
|
ui->m_pCustomPlot_WaterfallChart->clearGraphs();
|
|
|
|
ui->m_pCustomPlot_WaterfallChart->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
|
|
QCP::iSelectLegend | QCP::iSelectPlottables);
|
|
|
|
//
|
|
QLinearGradient plotGradient;
|
|
|
|
plotGradient.setStart(0, 0);
|
|
plotGradient.setFinalStop(0, 200);
|
|
|
|
plotGradient.setColorAt(0, QColor(0, 12, 40));//QColor(80, 80, 80)
|
|
plotGradient.setColorAt(1, QColor(0, 12, 40));//QColor(50, 50, 50)
|
|
|
|
ui->m_pCustomPlot_WaterfallChart->setBackground(plotGradient);
|
|
|
|
//
|
|
// 设置x/y轴文本色、轴线色、字体等
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->setTickLabelColor(Qt::white);
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->setLabelColor(QColor(0, 160, 230));
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->setBasePen(QPen(Qt::white));//(QColor(32, 178, 170)));
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->setTickPen(QPen(Qt::white));//(QColor(128, 0, 255)));
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->setSubTickPen(QPen((Qt::white)));//(QColor(255, 165, 0));
|
|
QFont xFont = ui->m_pCustomPlot_WaterfallChart->xAxis->labelFont();
|
|
xFont.setPixelSize(20);
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->setLabelFont(xFont);
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->setLabel("日统计");
|
|
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->setTickLabelColor(Qt::white);
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->setLabelColor(QColor(0, 160, 230));
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->setBasePen(QPen((Qt::white)));//QColor(32, 178, 170)));
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->setTickPen(QPen((Qt::white)));//QColor(128, 0, 255)));
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->setSubTickPen(QPen((Qt::white)));//QColor(255, 165, 0));
|
|
QFont yFont = ui->m_pCustomPlot_WaterfallChart->yAxis->labelFont();
|
|
yFont.setPixelSize(20);
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->setLabelFont(yFont);
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->setLabel("统计量");
|
|
|
|
//
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->setRange(0, 2000);
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->setSubTicks(false);
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->ticker()->setTickCount(6);
|
|
ui->m_pCustomPlot_WaterfallChart->xAxis->grid()->setVisible(false);
|
|
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->setRange(-0.2, 0.2);
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->setSubTicks(false);
|
|
ui->m_pCustomPlot_WaterfallChart->yAxis->ticker()->setTickCount(5);
|
|
|
|
// 画线
|
|
ui->m_pCustomPlot_WaterfallChart->addGraph();
|
|
ui->m_pCustomPlot_WaterfallChart->graph(0)->setPen(QPen(QBrush(QColor(0, 255, 0, 128)),2) );
|
|
//ui->m_pCustomPlot_WaterfallChart->graph(0)->setBrush(QBrush(QColor(0, 255, 0, 128)) );
|
|
ui->m_pCustomPlot_WaterfallChart->addGraph();
|
|
ui->m_pCustomPlot_WaterfallChart->graph(1)->setPen(QPen(QBrush(QColor(255, 0, 0, 128)),2));
|
|
//ui->m_pCustomPlot_WaterfallChart->graph(1)->setBrush(QBrush(QColor(255, 0, 0, 128)) );
|
|
QVector<double> x(2000), y0(2000), y1(2000);
|
|
for (int i=0; i< 2000; i+=10)
|
|
{
|
|
x[i] = i;
|
|
y0[i] = m_pDasStopData[10+ i + nChartIndex*2000] - 0.05;
|
|
y1[i] = m_pDasStopData[10+ i + nChartIndex*2000] + 0.05;
|
|
|
|
}
|
|
ui->m_pCustomPlot_WaterfallChart->graph(0)->setData(x, y0);
|
|
ui->m_pCustomPlot_WaterfallChart->graph(1)->setData(x, y1);
|
|
ui->m_pCustomPlot_WaterfallChart->replot();
|
|
}
|
|
|
|
void WaterfallChart::OnCurrentIndexChanged(int nIndex)
|
|
{
|
|
CustomPlot_Chart(nIndex);
|
|
}
|