#include "MyTracer.h"XxwTracer::XxwTracer(QCustomPlot*_plot, TracerType _type, QObject *parent)
: QObject(parent),
m_plot(_plot),
m_type(_type)
{
m_visible= true;
m_tracer= Q_NULLPTR;//跟踪的点
m_label = Q_NULLPTR;//显示的数值
m_arrow = Q_NULLPTR;//箭头
if(m_plot)
{
QColor clrDefault(Qt::red);
QBrush brushDefault(Qt::NoBrush);
QPen penDefault(clrDefault);//penDefault.setBrush(brushDefault);
penDefault.setWidthF(0.5);
m_tracer= newQCPItemTracer(m_plot);
m_tracer->setStyle(QCPItemTracer::tsCircle);
m_tracer->setPen(penDefault);
m_tracer->setBrush(brushDefault);
m_label= newQCPItemText(m_plot);
m_label->setLayer("overlay");
m_label->setClipToAxisRect(false);
m_label->setPadding(QMargins(5, 5, 5, 5));
m_label->setBrush(brushDefault);
m_label->setPen(penDefault);
m_label->position->setParentAnchor(m_tracer->position);//m_label->setFont(QFont("宋体", 8));
m_label->setFont(QFont("Arial", 8));
m_label->setColor(clrDefault);
m_label->setText("");
m_arrow= newQCPItemLine(m_plot);
QPen arrowPen(clrDefault,1);
m_arrow->setPen(penDefault);
m_arrow->setLayer("overlay");