1 Star 0 Fork 11

albert/LXCustomPlot

forked from xmlhh/LXCustomPlot 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
LXTracer.h 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
xmlhh 提交于 2020-12-22 15:16 . Type:feat
#ifndef MYTRACER_H
#define MYTRACER_H
#include <QObject>
#include "qcustomplot.h"
///
/// \brief The XxwTracer class:在图表中显示鼠标所在位置的x,y值的追踪显示器
///
class LXTracer : public QObject
{
Q_OBJECT
public:
enum TracerType
{
XAxisTracer,//依附在x轴上显示x值
YAxisTracer,//依附在y轴上显示y值
DataTracer//在图中显示x,y值
};
explicit LXTracer(QCustomPlot *_plot, TracerType _type, QObject *parent = Q_NULLPTR);
~LXTracer();
void setPen(const QPen &pen);
void setBrush(const QBrush &brush);
void setText(const QString &text);
void setLabelPen(const QPen &pen);
void updatePosition(double xValue, double yValue);
void setVisible(bool m_visible);
protected:
bool m_visible;//是否可见
TracerType m_type;//类型
QCustomPlot *m_plot;//图表
QCPItemTracer *m_tracer;//跟踪的点
QCPItemText *m_label;//显示的数值
QCPItemLine *m_arrow;//箭头
};
///
/// \brief The XxwCrossLine class:用于显示鼠标移动过程中的鼠标位置的直线
///
class LXTraceLine : public QObject
{
public:
enum LineType
{
VerticalLine,//垂直线
HorizonLine, //水平线
Both//同时显示水平和垂直线
};
explicit LXTraceLine(QCustomPlot *_plot, LineType _type = VerticalLine, QObject *parent = Q_NULLPTR);
~LXTraceLine();
void initLine();
void updatePosition(double xValue, double yValue);
void setVisible(bool vis)
{
if(m_lineV)
m_lineV->setVisible(vis);
if(m_lineH)
m_lineH->setVisible(vis);
}
protected:
bool m_visible;//是否可见
LineType m_type;//类型
QCustomPlot *m_plot;//图表
QCPItemStraightLine *m_lineV; //垂直线
QCPItemStraightLine *m_lineH; //水平线
};
#endif // MYTRACER_H
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/albert2111/LXCustomPlot.git
git@gitee.com:albert2111/LXCustomPlot.git
albert2111
LXCustomPlot
LXCustomPlot
main

搜索帮助