代码拉取完成,页面将自动刷新
同步操作将从 xmlhh/LXCustomPlot 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "LXCustomPlot.h"
#include <QDebug>
LXCustomPlot::LXCustomPlot(QWidget *parent)
: QCustomPlot(parent)
, m_isShowTracer(false)
, m_xTracer(Q_NULLPTR)
, m_yTracer(Q_NULLPTR)
, m_dataTracers(QList<LXTracer *>())
, m_lineTracer(Q_NULLPTR)
{
setOpenGl(true);
qDebug() << "OpenGL is open " << openGl();
}
void LXCustomPlot::mouseMoveEvent(QMouseEvent *event)
{
QCustomPlot::mouseMoveEvent(event);
if(m_isShowTracer)
{
//当前鼠标位置(像素坐标)
int x_pos = event->pos().x();
int y_pos = event->pos().y();
//像素坐标转成实际的x,y轴的坐标
float x_val = this->xAxis->pixelToCoord(x_pos);
float y_val = this->yAxis->pixelToCoord(y_pos);
if(Q_NULLPTR == m_xTracer)
{
m_xTracer = new LXTracer(this, LXTracer::XAxisTracer); //x轴
}
m_xTracer->updatePosition(x_val, y_val);
if(Q_NULLPTR == m_yTracer)
{
m_yTracer = new LXTracer(this, LXTracer::YAxisTracer); //y轴
}
m_yTracer->updatePosition(x_val, y_val);
int nTracerCount = m_dataTracers.count();
int nGraphCount = graphCount();
if(nTracerCount < nGraphCount)
{
for(int i = nTracerCount; i < nGraphCount; ++i)
{
LXTracer *tracer = new LXTracer(this, LXTracer::DataTracer);
m_dataTracers.append(tracer);
}
}
else if(nTracerCount > nGraphCount)
{
for(int i = nGraphCount; i < nTracerCount; ++i)
{
LXTracer *tracer = m_dataTracers[i];
if(tracer)
{
tracer->setVisible(false);
}
}
}
// for (int i = 0; i < nGraphCount; ++i)
// {
// XxwTracer *tracer = m_dataTracers[i];
// if(!tracer)
// {
// tracer = new XxwTracer(this, XxwTracer::DataTracer);
// }
// tracer->setVisible(true);
// tracer->setPen(this->graph(i)->pen());
// tracer->setBrush(Qt::NoBrush);
// tracer->setLabelPen(this->graph(i)->pen());
// auto iter = this->graph(i)->data()->findBegin(x_val);
// double value = iter->mainValue();
//// double value = this->graph(i)->data()->findBegin(x_val)->value;
// tracer->updatePosition(x_val, value);
// }
if(Q_NULLPTR == m_lineTracer)
{
m_lineTracer = new LXTraceLine(this, LXTraceLine::Both); //直线
}
m_lineTracer->updatePosition(x_val, y_val);
this->replot();//曲线重绘
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。