diff --git a/global.h b/global.h index 51a0dbc..7389d17 100644 --- a/global.h +++ b/global.h @@ -16,6 +16,8 @@ extern "C"{ # pragma execution_character_set("utf-8") #endif +extern float gOffset[20]; + typedef struct { @@ -86,7 +88,10 @@ public: float x = 0; while(mRuning){ int count = 0; - + if(mPause){ + QThread::msleep(10); + continue; + } for(int it = 0;it < mConf.size();it++) { auto itr = mConf.at(it); @@ -121,6 +126,56 @@ public: for(int i =0;i < resp_length;i++){ log += QString::asprintf("0x%02x ",rsp[i]); } + log += "\r\n流速: "; + float tmp = 0; + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[0]*1000; + + if((tmp > 0)&&(float(tmp<= 200))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[0]*1000; + }else if((tmp > 200)&&((tmp<= 400))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[1]*1000; + }else if((tmp > 400)&&((tmp<= 600))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[2]*1000; + }else if((tmp > 600)&&((tmp<= 800))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[3]*1000; + }else if((tmp > 800)&&((tmp<= 1000))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[4]*1000; + }else if((tmp > 1000)&&((tmp<= 1200))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[5]*1000; + }else if((tmp > 1200)&&((tmp<= 1400))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[6]*1000; + }else if((tmp > 1400)&&((tmp<= 1600))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[7]*1000; + }else if((tmp > 1600)&&((tmp<= 1800))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[8]*1000; + }else if((tmp > 1800)&&((tmp<= 2000))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[9]*1000; + }else if((tmp > 2000)&&((tmp<= 2200))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[10]*1000; + }else if((tmp > 2200)&&((tmp<= 2400))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[11]*1000; + }else if((tmp > 2400)&&((tmp<= 2600))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[12]*1000; + }else if((tmp > 2600)&&((tmp<= 2800))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[13]*1000; + }else if((tmp > 2800)&&((tmp<= 3000))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[14]*1000; + }else if((tmp > 3000)&&((tmp<= 3400))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[15]*1000; + }else if((tmp > 3400)&&((tmp<= 3800))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[16]*1000; + }else if((tmp > 3800)&&((tmp<= 4200))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[17]*1000; + }else if((tmp > 4200)&&((tmp<= 4600))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[18]*1000; + }else if((tmp > 4600)&&((tmp<= 5000))){ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[20]*1000; + }else{ + tmp = float(rsp[3]*256 + rsp[4]) + gOffset[0]*1000; + } + + log += QString::asprintf("%.2f\r\n",tmp); + if(ret < 0){ log += "超时"; } @@ -156,7 +211,7 @@ public: mMux.unlock(); } } - qDebug()<<"keep alive"; +// qDebug()<<"keep alive"; QThread::msleep(100); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 33d507f..225f006 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -35,7 +35,6 @@ MainWindow::MainWindow(QWidget *parent) ui->comboBox->addItem("57600"); ui->comboBox->addItem("115200"); - } MainWindow::~MainWindow() diff --git a/sub.ui b/sub.ui index 44128a0..69f4909 100644 --- a/sub.ui +++ b/sub.ui @@ -83,6 +83,20 @@ + + + + 计算 + + + + + + + 清除 + + + @@ -99,7 +113,7 @@ - + @@ -126,10 +140,17 @@ + + + + 数值: + + + - + diff --git a/subform.cpp b/subform.cpp index 734f372..5a0d4c6 100644 --- a/subform.cpp +++ b/subform.cpp @@ -14,6 +14,7 @@ # pragma execution_character_set("utf-8") #endif +float gOffset[20]; SubForm::SubForm(QString addr,int baurate,int device_addr,int rate) :ui(new Ui::Form) { @@ -46,18 +47,110 @@ SubForm::SubForm(QString addr,int baurate,int device_addr,int rate) if(this->mLines.find(z->addr) != mLines.end()){ static int i = 0; qDebug()<< mLines[z->addr]->count()<<"fsdf"; - mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0])); + if(fabs(float(z->val1[0])) < 10000) { - mCapMax++; + if((z->val1[0] > 0)&&(float(z->val1[0]<= 200))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[0]*1000)); + }else if((z->val1[0] > 200)&&((z->val1[0]<= 400))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[1]*1000)); + }else if((z->val1[0] > 400)&&((z->val1[0]<= 600))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[2]*1000)); + }else if((z->val1[0] > 600)&&((z->val1[0]<= 800))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[3]*1000)); + }else if((z->val1[0] > 800)&&((z->val1[0]<= 1000))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[4]*1000)); + }else if((z->val1[0] > 1000)&&((z->val1[0]<= 1200))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[5]*1000)); + }else if((z->val1[0] > 1200)&&((z->val1[0]<= 1400))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[6]*1000)); + }else if((z->val1[0] > 1400)&&((z->val1[0]<= 1600))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[7]*1000)); + }else if((z->val1[0] > 1600)&&((z->val1[0]<= 1800))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[8]*1000)); + }else if((z->val1[0] > 1800)&&((z->val1[0]<= 2000))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[9]*1000)); + }else if((z->val1[0] > 2000)&&((z->val1[0]<= 2200))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[10]*1000)); + }else if((z->val1[0] > 2200)&&((z->val1[0]<= 2400))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[11]*1000)); + }else if((z->val1[0] > 2400)&&((z->val1[0]<= 2600))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[12]*1000)); + }else if((z->val1[0] > 2600)&&((z->val1[0]<= 2800))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[13]*1000)); + }else if((z->val1[0] > 2800)&&((z->val1[0]<= 3000))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[14]*1000)); + }else if((z->val1[0] > 3000)&&((z->val1[0]<= 3400))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[15]*1000)); + }else if((z->val1[0] > 3400)&&((z->val1[0]<= 3800))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[16]*1000)); + }else if((z->val1[0] > 3800)&&((z->val1[0]<= 4200))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[17]*1000)); + }else if((z->val1[0] > 4200)&&((z->val1[0]<= 4600))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[18]*1000)); + }else if((z->val1[0] > 4600)&&((z->val1[0]<= 5000))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[19]*1000)); + }else{ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0])); + } + + mCapMax++; + } }else{ mLines[z->addr] = new QLineSeries; mChart->addSeries(mLines[z->addr]); // mLines[z->addr]->attachAxis(mAxisX); // mLines[z->addr]->attachAxis(mAxisY); - mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0])); + if(fabs(float(z->val1[0])) < 10000){ + if((z->val1[0] > 0)&&(float(z->val1[0]<= 200))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[0]*1000)); + }else if((z->val1[0] > 200)&&((z->val1[0]<= 400))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[1]*1000)); + }else if((z->val1[0] > 400)&&((z->val1[0]<= 600))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[2]*1000)); + }else if((z->val1[0] > 600)&&((z->val1[0]<= 800))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[3]*1000)); + }else if((z->val1[0] > 800)&&((z->val1[0]<= 1000))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[4]*1000)); + }else if((z->val1[0] > 1000)&&((z->val1[0]<= 1200))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[5]*1000)); + }else if((z->val1[0] > 1200)&&((z->val1[0]<= 1400))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[6]*1000)); + }else if((z->val1[0] > 1400)&&((z->val1[0]<= 1600))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[7]*1000)); + }else if((z->val1[0] > 1600)&&((z->val1[0]<= 1800))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[8]*1000)); + }else if((z->val1[0] > 1800)&&((z->val1[0]<= 2000))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[9]*1000)); + }else if((z->val1[0] > 2000)&&((z->val1[0]<= 2200))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[10]*1000)); + }else if((z->val1[0] > 2200)&&((z->val1[0]<= 2400))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[11]*1000)); + }else if((z->val1[0] > 2400)&&((z->val1[0]<= 2600))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[12]*1000)); + }else if((z->val1[0] > 2600)&&((z->val1[0]<= 2800))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[13]*1000)); + }else if((z->val1[0] > 2800)&&((z->val1[0]<= 3000))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[14]*1000)); + }else if((z->val1[0] > 3000)&&((z->val1[0]<= 3400))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[15]*1000)); + }else if((z->val1[0] > 3400)&&((z->val1[0]<= 3800))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[16]*1000)); + }else if((z->val1[0] > 3800)&&((z->val1[0]<= 4200))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[17]*1000)); + }else if((z->val1[0] > 4200)&&((z->val1[0]<= 4600))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[18]*1000)); + }else if((z->val1[0] > 4600)&&((z->val1[0]<= 5000))){ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0] + gOffset[19]*1000)); + }else{ + mLines[z->addr]->append( (mCapMax + 1),float(z->val1[0])); + } + + + mCapMax++; + + } mLines[z->addr]->setName(QString::asprintf("%d",z->addr)); - mCapMax++; } // mSeries1->append(sd,z->val1); pTime.append(QDateTime::currentDateTime().toString("yyyyMMdd-hh:mm:ss")); @@ -105,15 +198,58 @@ SubForm::SubForm(QString addr,int baurate,int device_addr,int rate) }else{ mModel->item(found->row(),0)->setData(QString("%1").arg(z->addr),Qt::DisplayRole); - if(succ) - mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0]),Qt::DisplayRole); + if(succ){ + if((z->val1[0] > 0)&&(float(z->val1[0]<= 200))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[0]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 200)&&((z->val1[0]<= 400))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[1]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 400)&&((z->val1[0]<= 600))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[2]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 600)&&((z->val1[0]<= 800))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[3]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 800)&&((z->val1[0]<= 1000))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[4]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 1000)&&((z->val1[0]<= 1200))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[5]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 1200)&&((z->val1[0]<= 1400))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[6]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 1400)&&((z->val1[0]<= 1600))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[7]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 1600)&&((z->val1[0]<= 1800))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[8]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 1800)&&((z->val1[0]<= 2000))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[9]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 2000)&&((z->val1[0]<= 2200))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[10]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 2200)&&((z->val1[0]<= 2400))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[11]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 2400)&&((z->val1[0]<= 2600))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[12]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 2600)&&((z->val1[0]<= 2800))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[13]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 2800)&&((z->val1[0]<= 3000))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[14]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 3000)&&((z->val1[0]<= 3400))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[15]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 3400)&&((z->val1[0]<= 3800))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[16]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 3800)&&((z->val1[0]<= 4200))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[17]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 4200)&&((z->val1[0]<= 4600))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[18]*1000),Qt::DisplayRole); + }else if((z->val1[0] > 4600)&&((z->val1[0]<= 5000))){ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0] + gOffset[19]*1000),Qt::DisplayRole); + }else{ + mModel->item(found->row(),1)->setData(QString("%1").arg(z->val1[0]),Qt::DisplayRole); + } + + } else mModel->item(found->row(),1)->setData(QString("ʱ"),Qt::DisplayRole); mModel->item(found->row(),2)->setData(QString("%1").arg(z->time),Qt::DisplayRole); } - sd ++; if(sd > mMaxX){ mMaxX += 1024; @@ -121,13 +257,43 @@ SubForm::SubForm(QString addr,int baurate,int device_addr,int rate) } delete z; } + }); pTimer->start(10); qDebug()<lineEdit_2->setText(addr); gAsyncData->AddConfig(this->mConfig); ui->tableView->setColumnWidth(2,230); - connect(gAsyncData,SIGNAL(Info(QString)),this,SLOT( on_log(QString))); + connect(gAsyncData,SIGNAL(Info(QString)),this,SLOT(on_log(QString))); + + ui->graphicsView->setRubberBand(QChartView::RectangleRubberBand); + + + + // connect(this, &MainWindow::rubberBandChanged,this, &MainWindow::rubberZoomAdapt); +// mRubberBand = this->mChart->findChild(); +// mRubberBand->installEventFilter(this); +// mRubberBand->installEventFilter(this); +// connect(this, &SubForm::rubberBandChanged,this, &SubForm::rubberZoomAdapt); + +// QObject::connect(qobject_cast(ui->graphicsView), +// &QGraphicsView::rubberBandChanged, +// this, +// &SubForm::rubberZoomAdapt); + + QFile file("offset.csv"); + bool isopen = file.open(QFile::ReadOnly); + if(isopen){ + qDebug() << "open txt file is success"; + } + QString tmp = QString(file.readAll()); + QStringList iat = tmp.split("\r\n"); + qDebug()< 20){ + for(int i = 0;i < iat.size();i++){ + gOffset[i] = iat.at(i).toFloat(); + } + } } void SubForm::on_pushButton_clicked() { @@ -183,9 +349,9 @@ void SubForm::init_charts() mChart->addSeries(mSeries1); // mAxisX->setMin(0); //YΧ - mAxisX->setMax(1024); - mMaxX = 1024; - mAxisX->setTickCount(17); + mAxisX->setMax(256); + mMaxX = 256; + mAxisX->setTickCount(8); mAxisX->setLabelFormat("%d"); mAxisX->setTitleText("point"); //X mAxisX->setLineVisible(true); @@ -198,7 +364,7 @@ void SubForm::init_charts() mAxisY->setMin(-10); //YΧ mAxisY->setMax(100); - mAxisY->setTickCount(11); + mAxisY->setTickCount(6); mAxisY->setLabelFormat("%d"); mAxisY->setLinePenColor(QColor(Qt::yellow)); // mAxisY->setGridLineColor(QColor(Qt::yellow)); @@ -226,13 +392,21 @@ void SubForm::init_charts() mChart->setMargins(QMargins(0,0,0,0)); ui->graphicsView->setChart(mChart); + + +// ui->graphicsView->setRubberBand(QChartView::HorizontalRubberBand); +// this->mRubberBand = ui->graphicsView->findChild(); +// this->mRubberBand->installEventFilter(this); + +// connect(this, &SubForm::rubberBandChanged,this, &SubForm::rubberZoomAdapt); + ui->graphicsView->setRenderHint(QPainter::TextAntialiasing); // ui->graphicsView->setBackgroundBrush(QBrush(QColor(Qt::black),Qt::SolidPattern)); ui->graphicsView->scene()->setBackgroundBrush(QBrush(QColor(Qt::black),Qt::SolidPattern)); - ui->graphicsView->setRubberBand(QChartView::VerticalRubberBand); + ui->graphicsView->setRubberBand(QChartView::RectangleRubberBand); mChart->legend()->setAlignment(Qt::AlignBottom);// - mChart->legend()->setContentsMargins(10,10,10,10);//left,top,right,bottom + mChart->legend()->setContentsMargins(0,0,0,0);//left,top,right,bottom mChart->legend()->setVisible(true);// QFont font = mChart->legend()->font(); font.setItalic(!font.italic()); @@ -240,6 +414,36 @@ void SubForm::init_charts() font.setPointSizeF(12); mChart->legend()->setFont(font);//С mChart->legend()->setLabelColor(Qt::white); // + + + + ui->graphicsView->setRenderHint(QPainter::Antialiasing); + ui->graphicsView->setRubberBand(QChartView::NoRubberBand); + ui->graphicsView->setDragMode(QChartView::RubberBandDrag); + + connect(ui->graphicsView,&QChartView::rubberBandChanged,this,[=](QRect viewportRect, QPointF fromScenePoint, QPointF toScenePoint){ + qDebug()<<"rubberBandChanged"<chart()->series().first(); +// QVector ver = series->pointsVector(); +// // qDebug() << "ver="<req.append(Req{ - ui->lineEdit->text().toUShort(), - ui->lineEdit_3->text().toUShort(), - }); + ui->lineEdit->text().toUShort(), + ui->lineEdit_3->text().toUShort(), + }); } void SubForm::on_log(QString info) @@ -275,6 +479,41 @@ void SubForm::on_pushButton_3_clicked() void SubForm::on_pushButton_4_clicked() { - gAsyncData->Continue(); + gAsyncData->Continue(); +} + +void SubForm::rubberZoomAdapt(QPointF fp, QPointF tp) +{ + qDebug()<<"rubberZoomAdapt"<mAxisX->max()<mAxisX->min(); + auto itr = this->mLines.begin(); + for(int i = 0;i < itr.value()->count();i++){ + qDebug()<<"on_pushButton_5_clicked"<at(i); + if((i >= mAxisX->min()) && (i <= mAxisX->max())){ + sum += itr.value()->at(i).y(); + count++; + } + } + qDebug()<<"on_pushButton_5_clicked count"<label_7->setText(QString::asprintf("ֵ:%f",sum/float(count))); +} + +void SubForm::on_pushButton_6_clicked() +{ + for(auto itr = this->mLines.begin();itr != this->mLines.end();itr++){ + itr.value()->removePoints(0,itr.value()->points().size()); + itr.value()->clear(); + } + this->mCapMax = 0; + } diff --git a/subform.h b/subform.h index 12335f5..929c13e 100644 --- a/subform.h +++ b/subform.h @@ -13,15 +13,19 @@ #include "global.h" #include #include - +#include +#include +#include QT_BEGIN_NAMESPACE namespace Ui { class Form; } QT_END_NAMESPACE +using namespace QtCharts; -class SubForm :QWidget + +class SubForm :public QWidget { Q_OBJECT public: @@ -41,6 +45,15 @@ private slots: void on_pushButton_4_clicked(); + void on_pushButton_5_clicked(); + + void on_pushButton_6_clicked(); + +public slots: + void rubberZoomAdapt(QPointF fp, QPointF tp); + +signals: + void rubberBandChanged(QPointF fp, QPointF tp); private: Ui::Form *ui; QChart *mChart; @@ -59,6 +72,8 @@ private: bool mStart; QStandardItemModel *mModel; int mCapMax = 0; + QRubberBand *mRubberBand; + }; diff --git a/untitled.pro b/untitled.pro index e4eee29..58d49a7 100644 --- a/untitled.pro +++ b/untitled.pro @@ -8,7 +8,7 @@ CONFIG += c++11 # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -include(G:\project\c++qt\qsswraper\qsswraper.pri) +include(C:\\Users\\zheng\\Documents\\qsswraper\\qsswraper.pri) SOURCES += \