提交 846204fe 编写于 作者: M manjaro-xfce

Plot显示更为美观

上级 44a7f7aa
...@@ -89,6 +89,7 @@ void DialogPlots::deal_package(QByteArray package) ...@@ -89,6 +89,7 @@ void DialogPlots::deal_package(QByteArray package)
if (channels<2) if (channels<2)
{ {
serials = new QLineSeries(this); serials = new QLineSeries(this);
serials->setPen(QPen(QColor(255,255,0)));
} }
else else
{ {
...@@ -117,7 +118,7 @@ void DialogPlots::deal_package(QByteArray package) ...@@ -117,7 +118,7 @@ void DialogPlots::deal_package(QByteArray package)
pv->setChart(chart); pv->setChart(chart);
chart->setTitle(tr("SUB%1 PATH%2").arg(pheader->subject_id).arg(pheader->path_id)); chart->setTitle(tr("SUB%1 PATH%2").arg(pheader->subject_id).arg(pheader->path_id));
pv->setRubberBand(QChartView::RectangleRubberBand); pv->setRubberBand(QChartView::VerticalRubberBand);
chart->addSeries(serials); chart->addSeries(serials);
serials->attachAxis(ax); serials->attachAxis(ax);
...@@ -288,20 +289,21 @@ void DialogPlots::on_pushButton_reset_clicked() ...@@ -288,20 +289,21 @@ void DialogPlots::on_pushButton_reset_clicked()
bool needup_x = false,needup_y = false; bool needup_x = false,needup_y = false;
if (max_x > new_max_x) new_max_x = max_x + seed_x * 0.2,needup_x=true; if (max_x != new_max_x) new_max_x = max_x ,needup_x=true;
if (max_x *1.2 < new_max_x) new_max_x = max_x + seed_x * 0.2,needup_x=true; //if (max_x *1.2 < new_max_x) new_max_x = max_x + seed_x * 0.2,needup_x=true;
if (max_y > new_max_y) new_max_y = max_y + seed_y * 0.2,needup_y=true; if (max_y > new_max_y) new_max_y = max_y + seed_y * 0.2,needup_y=true;
if (max_y *1.2 < new_max_y) new_max_y = max_y + seed_y * 0.2,needup_y=true; if (max_y *1.2 < new_max_y) new_max_y = max_y + seed_y * 0.2,needup_y=true;
if (min_x < new_min_x) new_min_x = min_x,needup_x=true; if (min_x != new_min_x) new_min_x = min_x,needup_x=true;
if (min_x > new_min_x * 1.2) new_min_x = min_x,needup_x=true; //if (min_x > new_min_x * 1.2) new_min_x = min_x,needup_x=true;
if (min_y < new_min_y) new_min_y = min_y,needup_y=true; if (min_y < new_min_y) new_min_y = min_y,needup_y=true;
if (min_y > new_min_y * 1.2) new_min_y = min_y,needup_y=true; if (min_y > new_min_y * 1.2) new_min_y = min_y,needup_y=true;
if (needup_x==true) if (needup_x==true)
ax->setRange(new_min_x,new_max_x); ax->setRange(new_min_x,new_max_x);
if (needup_y==true) if (needup_y==true)
...@@ -343,7 +345,32 @@ void DialogPlots::timerEvent(QTimerEvent *event) ...@@ -343,7 +345,32 @@ void DialogPlots::timerEvent(QTimerEvent *event)
QXYSeries * serials = m_chat_serials[subid]; QXYSeries * serials = m_chat_serials[subid];
const int pts = m_plot_buffer[hash_subidx].size(); const int pts = m_plot_buffer[hash_subidx].size();
const double * fdata = m_plot_buffer[hash_subidx].constData();
QList<QVector<double> > & avgList = m_plot_lastUpdates[hash_subidx];
bool clear_lst = false;
for (QList<QVector<double> >::iterator pit = avgList.begin();pit!=avgList.end();++pit)
{
if (pit->size()!=pts)
{
clear_lst = true;
break;
}
}
if (clear_lst)
avgList.clear();
avgList.push_back(m_plot_buffer[hash_subidx]);
while (avgList.size()>6)
avgList.pop_front();
QVector<double> vec_tmp(pts,0);
double * fdata = vec_tmp.data();
const int avgsz = avgList.size();
for (QList<QVector<double> >::iterator pit = avgList.begin();pit!=avgList.end();++pit)
{
for (int i=0;i<pts;++i)
fdata[i] += pit->at(i)/avgsz;
}
double max_x = 0, max_y = fdata[0]; double max_x = 0, max_y = fdata[0];
double min_x = 0, min_y = fdata[0]; double min_x = 0, min_y = fdata[0];
...@@ -377,11 +404,12 @@ void DialogPlots::timerEvent(QTimerEvent *event) ...@@ -377,11 +404,12 @@ void DialogPlots::timerEvent(QTimerEvent *event)
{ {
QChart * ca = m_chars[subid]; QChart * ca = m_chars[subid];
QValueAxis * axx = m_char_axis_x[subid]; QValueAxis * axx = m_char_axis_x[subid];
QValueAxis * axy = m_char_axis_y[subid];
double dmin = axx->min(); double dmin = axx->min();
double dmax = axx->max(); double dmax = axx->max();
QRectF r = ca->plotArea(); QRectF r = ca->plotArea();
ws->setMinMaxRange(axy->min(),axy->max());
ws->append_data(m_plot_buffer[hash_subidx], ws->append_data(m_plot_buffer[hash_subidx],
r.left(), r.left(),
r.right(), r.right(),
...@@ -423,20 +451,21 @@ void DialogPlots::timerEvent(QTimerEvent *event) ...@@ -423,20 +451,21 @@ void DialogPlots::timerEvent(QTimerEvent *event)
bool needup_x = false,needup_y = false; bool needup_x = false,needup_y = false;
if (max_x > new_max_x) new_max_x = max_x + seed_x * 0.2,needup_x=true; if (max_x != new_max_x) new_max_x = max_x ,needup_x=true;
if (max_x *1.2 < new_max_x) new_max_x = max_x + seed_x * 0.2,needup_x=true; //if (max_x *1.2 < new_max_x) new_max_x = max_x + seed_x * 0.2,needup_x=true;
if (max_y > new_max_y) new_max_y = max_y + seed_y * 0.2,needup_y=true; if (max_y > new_max_y) new_max_y = max_y + seed_y * 0.2,needup_y=true;
if (max_y *1.2 < new_max_y) new_max_y = max_y + seed_y * 0.2,needup_y=true; if (max_y *1.2 < new_max_y) new_max_y = max_y + seed_y * 0.2,needup_y=true;
if (min_x < new_min_x) new_min_x = min_x,needup_x=true; if (min_x != new_min_x) new_min_x = min_x,needup_x=true;
if (min_x > new_min_x * 1.2) new_min_x = min_x,needup_x=true; //if (min_x > new_min_x * 1.2) new_min_x = min_x,needup_x=true;
if (min_y < new_min_y) new_min_y = min_y,needup_y=true; if (min_y < new_min_y) new_min_y = min_y,needup_y=true;
if (min_y > new_min_y * 1.2) new_min_y = min_y,needup_y=true; if (min_y > new_min_y * 1.2) new_min_y = min_y,needup_y=true;
if (ui->checkBox_auto_reser->isChecked())
if (ui->checkBox_auto_reser->isChecked() || needup_x)
{ {
if (needup_x==true) if (needup_x==true)
ax->setRange(new_min_x,new_max_x); ax->setRange(new_min_x,new_max_x);
...@@ -445,7 +474,7 @@ void DialogPlots::timerEvent(QTimerEvent *event) ...@@ -445,7 +474,7 @@ void DialogPlots::timerEvent(QTimerEvent *event)
} }
} }
refid = startTimer(40); refid = startTimer(25);
} }
} }
...@@ -42,6 +42,7 @@ private: ...@@ -42,6 +42,7 @@ private:
QVector<int> m_plot_types; QVector<int> m_plot_types;
QMap<quint64,QVector<double> > m_plot_buffer; QMap<quint64,QVector<double> > m_plot_buffer;
QMap<quint64,QList<QVector<double> > > m_plot_lastUpdates;
QMap<quint64,bool > m_plot_refresh; QMap<quint64,bool > m_plot_refresh;
int tid = -1; int tid = -1;
......
...@@ -45,6 +45,7 @@ void SpectroWidget::append_data(QVector<double> vec_data, ...@@ -45,6 +45,7 @@ void SpectroWidget::append_data(QVector<double> vec_data,
for (int r = 0;r<width;++r) for (int r = 0;r<width;++r)
{ {
m_image.setPixel(r,0,qRgb(0,0,0));
if (r<left || r>right) if (r<left || r>right)
continue; continue;
int from = (r-left)/(right-left)*(right_x-left_x) + left_x+.5; int from = (r-left)/(right-left)*(right_x-left_x) + left_x+.5;
...@@ -65,15 +66,21 @@ void SpectroWidget::append_data(QVector<double> vec_data, ...@@ -65,15 +66,21 @@ void SpectroWidget::append_data(QVector<double> vec_data,
} }
else if (vii>=0.75 && vii<1) else if (vii>=0.75 && vii<1)
{ {
red = 255; red = (1-vii)/0.25*255;
green = 255; green = 255;
blue = (vii-0.75)/0.25*255; blue = (vii-0.75)/0.25*255;
} }
else if (vii>=1) else if (vii>=1)
red = 255, blue = 255, green = 255; red = 0, blue = 255, green = 255;
m_image.setPixel(r,0,qRgb(red,green,blue)); m_image.setPixel(r,0,qRgb(red,green,blue));
} }
update(); update();
} }
void SpectroWidget::setMinMaxRange(double vmin, double vmax)
{
m_maxBound = vmax;
m_minBound = vmin;
}
...@@ -10,6 +10,8 @@ public: ...@@ -10,6 +10,8 @@ public:
explicit SpectroWidget(QWidget *parent = nullptr); explicit SpectroWidget(QWidget *parent = nullptr);
protected: protected:
void paintEvent(QPaintEvent * evt); void paintEvent(QPaintEvent * evt);
public slots:
void setMinMaxRange(double vmin, double vmax);
public: public:
void append_data(QVector<double> vec_data, void append_data(QVector<double> vec_data,
double left, double left,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册