|
@@ -9,10 +9,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
- std::hash<std::string> h;
|
|
|
- size_t n = h("Just fucking google it");
|
|
|
- std::cout << n << std::endl;
|
|
|
-
|
|
|
+ qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //设
|
|
|
m_chart = new QChart();
|
|
|
m_chart->setTheme(QChart::ChartThemeLight);//设置白色主题
|
|
|
m_chart->setDropShadowEnabled(true);//背景阴影 m_chart->setAutoFillBackground(true); //设置背景自动填充
|
|
@@ -24,7 +21,20 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
m_chart->setTitle("曲线图");
|
|
|
|
|
|
|
|
|
+ //创建X轴和Y轴
|
|
|
+ QValueAxis *axisX = new QValueAxis;
|
|
|
+ axisX->setRange(-1000* AXIS_X_SEL[mnDefAxisXIndex],0); //默认则坐标为动态计算大小的
|
|
|
+ axisX->setLabelFormat("%dms");
|
|
|
+ mpAxisX = axisX;
|
|
|
|
|
|
+ //修改说明样式
|
|
|
+ m_chart->legend()->setVisible(true);
|
|
|
+ m_chart->legend()->setAlignment(Qt::AlignBottom);//底部对齐
|
|
|
+ m_chart->legend()->setBackgroundVisible(true);//设置背景是否可视
|
|
|
+ m_chart->legend()->setAutoFillBackground(true);//设置背景自动填充
|
|
|
+ m_chart->legend()->setColor(QColor(222,233,251));//设置颜色
|
|
|
+ m_chart->legend()->setLabelColor(QColor(0,100,255));//设置标签颜色
|
|
|
+ m_chart->legend()->setMaximumHeight(50);
|
|
|
|
|
|
|
|
|
|
|
@@ -41,8 +51,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
QTimer * timer;
|
|
|
timer = new QTimer();
|
|
|
connect(timer,SIGNAL(timeout()),this,SLOT(onTimer()));
|
|
|
- timer->start(100);
|
|
|
+ timer->start(50);
|
|
|
|
|
|
+ mnTitleMode = 0;
|
|
|
setWindowTitle("ADC IV Chart View");
|
|
|
}
|
|
|
|
|
@@ -93,7 +104,11 @@ void MainWindow::on_actionSelect_Data_triggered()
|
|
|
}
|
|
|
if(bhave == false)
|
|
|
{
|
|
|
+ m_chart->removeAxis(mvectorCUShow[i].mpaxisY);
|
|
|
+ m_chart->removeSeries(mvectorCUShow[i].mlineseries);
|
|
|
+ delete mvectorCUShow[i].mpaxisY;
|
|
|
delete mvectorCUShow[i].mlineseries;
|
|
|
+
|
|
|
mvectorCUShow.erase(mvectorCUShow.begin()+i);
|
|
|
}
|
|
|
|
|
@@ -114,12 +129,14 @@ void MainWindow::on_actionSelect_Data_triggered()
|
|
|
{
|
|
|
CUShow xcu;
|
|
|
xcu.mstrname = mvectorused[i];
|
|
|
- mvectorCUShow.push_back(xcu);
|
|
|
|
|
|
- mvectorCUShow[mvectorCUShow.size()-1].mlineseries = new QLineSeries();
|
|
|
- QLineSeries * plineseries = mvectorCUShow[mvectorCUShow.size()-1].mlineseries;
|
|
|
|
|
|
- plineseries->setColor(QColor(255,0,0));
|
|
|
+
|
|
|
+ xcu.mlineseries = new QLineSeries();
|
|
|
+ QLineSeries * plineseries = xcu.mlineseries;
|
|
|
+
|
|
|
+ xcu.mcolor = GetRandColor();
|
|
|
+ plineseries->setColor(xcu.mcolor);
|
|
|
|
|
|
plineseries->setName(xcu.mstrname.data());
|
|
|
|
|
@@ -128,27 +145,63 @@ void MainWindow::on_actionSelect_Data_triggered()
|
|
|
plineseries->setPointLabelsVisible(false);
|
|
|
|
|
|
|
|
|
+ std::vector<iv::ivchart::ivchartunit> xvectorcu = mpivchartproc->GetChartUnit(xcu.mstrname);
|
|
|
+
|
|
|
+ if(xvectorcu.size()>0)
|
|
|
+ {
|
|
|
+ xcu.mfRangeMin = xvectorcu[0].fvalue_rangemin();
|
|
|
+ xcu.mfRangeMax = xvectorcu[0].fvalue_rangemax();
|
|
|
+ }
|
|
|
+
|
|
|
m_chart->addSeries(plineseries);//添加系列到QChart上
|
|
|
|
|
|
- //创建X轴和Y轴
|
|
|
- QValueAxis *axisX = new QValueAxis;
|
|
|
- axisX->setRange(-3000,0); //默认则坐标为动态计算大小的
|
|
|
- axisX->setLabelFormat("%dms");
|
|
|
+
|
|
|
QValueAxis *axisY = new QValueAxis;
|
|
|
- axisY->setRange(-1,1); //默认则坐标为动态计算大小的
|
|
|
- axisY->setTitleText("value值");
|
|
|
+ axisY->setRange(xcu.mfRangeMin,xcu.mfRangeMax); //默认则坐标为动态计算大小的
|
|
|
+ axisY->setTitleText(xcu.mstrname.data());
|
|
|
+
|
|
|
+ axisY->setLinePenColor(plineseries->pen().color());
|
|
|
+
|
|
|
|
|
|
- axisY->setLinePenColor(QColor(0,255,0));
|
|
|
+ // axisY->setGridLinePen((plineseries->pen()));
|
|
|
+ xcu.mpaxisY = axisY;
|
|
|
|
|
|
- m_chart->setAxisX(axisX,plineseries);
|
|
|
+ m_chart->setAxisX(mpAxisX,plineseries);
|
|
|
m_chart->setAxisY(axisY,plineseries);
|
|
|
+
|
|
|
+ mvectorCUShow.push_back(xcu);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ mbViewPause = false;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void MainWindow::onTimer()
|
|
|
{
|
|
|
+ std::string strsavingpath;
|
|
|
+ bool bsaving = false;
|
|
|
+ bsaving = mpivchartproc->GetSavingPath(strsavingpath);
|
|
|
+ if(bsaving == false)
|
|
|
+ {
|
|
|
+ if(mnTitleMode == 1)
|
|
|
+ {
|
|
|
+ setWindowTitle(mstrTitle.data());
|
|
|
+ mnTitleMode = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(mnTitleMode == 0)
|
|
|
+ {
|
|
|
+ std::string strtitle = mstrTitle;
|
|
|
+ strtitle = strtitle + strsavingpath;
|
|
|
+ setWindowTitle(strtitle.data());
|
|
|
+ mnTitleMode = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mbViewPause)return;
|
|
|
unsigned int i;
|
|
|
for(i=0;i<mvectorCUShow.size();i++)
|
|
|
{
|
|
@@ -156,6 +209,7 @@ void MainWindow::onTimer()
|
|
|
unsigned int j;
|
|
|
qint64 nnow = QDateTime::currentMSecsSinceEpoch();
|
|
|
QList<QPointF> xListPoint;
|
|
|
+ mvectorCUShow[i].mlineseries->clear();
|
|
|
for(j=0;j<xvectorcu.size();j++)
|
|
|
{
|
|
|
|
|
@@ -163,6 +217,83 @@ void MainWindow::onTimer()
|
|
|
// qDebug("%f %f ",xListPoint[0].x(),xListPoint[0].y());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
mvectorCUShow[i].mlineseries->replace(xListPoint);
|
|
|
+ xListPoint.clear();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+QColor MainWindow::GetRandColor()
|
|
|
+{
|
|
|
+ // qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
|
+ unsigned char R,G,B;
|
|
|
+ R = qrand()%255;
|
|
|
+ G = qrand()%255;
|
|
|
+ B = qrand()%255;
|
|
|
+
|
|
|
+ QColor xcolor(R,G,B);
|
|
|
+ return xcolor;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::keyPressEvent(QKeyEvent *event)
|
|
|
+{
|
|
|
+
|
|
|
+ //按键按下,key值放入容器,如果是长按触发的repeat就不判断
|
|
|
+ if(!event->isAutoRepeat())
|
|
|
+ mPressKeys.insert(event->key());
|
|
|
+
|
|
|
+ if(mPressKeys.contains(Qt::Key_P) &&(mPressKeys.contains(Qt::Key_Control)))
|
|
|
+ {
|
|
|
+ if(mbViewPause)mbViewPause = false;
|
|
|
+ else mbViewPause = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ qDebug("key count is %d",mPressKeys.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mPressKeys.contains(Qt::Key_S) &&(mPressKeys.contains(Qt::Key_Control)))
|
|
|
+ {
|
|
|
+ mpivchartproc->ChangeSaveMode();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::keyReleaseEvent(QKeyEvent *event)
|
|
|
+{
|
|
|
+ if(!event->isAutoRepeat())mPressKeys.remove(event->key());
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_actionSet_AxisX_triggered()
|
|
|
+{
|
|
|
+
|
|
|
+ int nsel = mnDefAxisXIndex;
|
|
|
+ DialogSetAxisX saxix(AXIS_X_SEL,6,nsel,this);
|
|
|
+ int nrtn = saxix.exec();
|
|
|
+ if(nrtn != saxix.Accepted)
|
|
|
+ {
|
|
|
+ return;
|
|
|
}
|
|
|
+ if(nsel != mnDefAxisXIndex)
|
|
|
+ {
|
|
|
+ mnDefAxisXIndex = nsel;
|
|
|
+ mpAxisX->setRange((-1000)*AXIS_X_SEL[mnDefAxisXIndex],0);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_actionivc_to_csv_triggered()
|
|
|
+{
|
|
|
+ Dialogivctocsv ivctocst;
|
|
|
+ ivctocst.exec();
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_actionHelp_triggered()
|
|
|
+{
|
|
|
+ QString helpinfo = tr("Select Data 选择绘图数据\nSet AxisX 设置X轴\nivctocsv 转换数据为csv\n"
|
|
|
+ "Ctrl+P 暂停和继续\n"
|
|
|
+ "Ctrl+S 保存和暂停保存");
|
|
|
+ QMessageBox::information(this,"Help",helpinfo,QMessageBox::Yes);
|
|
|
}
|