You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Include/iPlot/iPlotBase/Helper/ZxAxisHelper.h

109 lines
3.0 KiB
C

#pragma once
#include <QObject>
#include "Defines.h"
#include "iPlotBase_global.h"
class ZxSubAxisBase;
class QPainter;
// 该类是ZxSubAxisBase的分发处理
class I_PLOTBASE_EXPORT ZxAxisHelper : public QObject
{
Q_OBJECT
public:
static const double g_Sub_ScaleTick_Len;
static const double g_Main_ScaleTick_Len;
public:
explicit ZxAxisHelper(ZxSubAxisBase* p);
~ZxAxisHelper();
// 统一调用接口
virtual void getPreferedSize(QPainter* painter, \
double& w, double& h);//预估大小
virtual void drawAxis(QPainter* painter); //绘制坐标
virtual void drawGrids(QPainter* painter, QRectF& rtInner);//Plot网格线
virtual QRectF getAxisRect(); //最大外范围
// 获取类型
AxisType getAxisType();
protected:
// 预估大小
virtual void getPreferedTitleSize(QPainter* painter, \
double& w, double& h);//预估大小
virtual void getPreferedTickSize(QPainter* painter, \
double& w, double& h);//预估大小
virtual QRectF getPreferedTickSumRect(QPainter* painter);
virtual void adjustPreferedSize(double& w, double& h);
// 取得待显示的刻度文本标识
virtual QMap<double, QString> getTickInfos();
// 绘制函数
virtual void drawBaseLine(QPainter* painter, QRectF& rt);
virtual void drawTickAndTags(QPainter* painter, QRectF& rt);
virtual void drawTitle(QPainter* painter, QRectF& rt);
virtual void drawFocus(QPainter* painter, QRectF& rt);
virtual void drawOneTickLine(QPainter* painter, double fPos, bool bMainInterval);
virtual void drawOneTickTag(QPainter* painter, double fPos, QString s);
virtual void drawOneGridLine(QPainter* painter, double fPos, QRectF& rtInner);
// 获取绘制的位置信息
virtual void locateOneTickTag(QPainter* painter, double fPos, QString s, \
QRectF& rt, int& flag);
virtual void locateTitle(QPainter* painter, QString s, \
QRectF& rt, int& flag);
virtual void metricStr(QPainter* painter, QString s, double& w, double& h);
protected:
// 范围判断
bool isMidIn(double f, double f1, double f2);
// 从坐标轴获取参数
void bindParas();
// 是否可以显示
virtual bool canTickShow(QRectF rt);
// 裁剪区
virtual void clipBounds(QPainter* painter, QRectF& rt);
// 合并Rect
void uniteTickBound(QRectF rt);
// 旋转式绘制
void rotateText(QPainter* painter, QRectF& rt, \
int flag, QString s, double fAngle);
public slots:
protected:
// 载体及载体类型
ZxSubAxisBase* m_pAxis;
AxisType m_oAxisType;
// x or y and out or inner
bool m_bAxisX;
bool m_bScaleOut;
// 范围
QRectF m_rtBound; //whole
QRectF m_rtTickSum; //所有刻度文字的范围合集
QRectF m_rtTickLastVisible;
QRectF m_rtTitle;
friend class ZxSubAxisBase;
};