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/iBase/iUtils/ZxScaleHelper.h

55 lines
1.4 KiB
C

#pragma once
#include "Defines.h"
#include "LlUtils_global.h"
/// @brief 坐标轴刻度的计算
class I_UTILSSHARED_EXPORT ZxScaleHelper
{
public:
ZxScaleHelper();
~ZxScaleHelper();
/// @brief 求取坐标轴的刻度显示
/// @param fMin 左值,通常为最小值
/// @param fMax 右值,通常为最大值
/// @param bAxisX 是否X轴
/// @param bLinear 是否线性
/// @param bExpand 是否流量自动扩展一个tick
/// @param pVecScales结果存储位置
/// @note 1通常 fMin < fMax; 对于fMin > fMax 的情况也做了相应处理(返回结果也是倒着)
bool calAxisScales(double& fMin, double& fMax, \
bool bAxisX, \
bool bLinear = true, \
bool bExpand = false, \
QVector<double>* pVecScales = NULL);
private:
// 内部接口(目前刻度计算函数,还有待较大完善空间)
bool checkReverse();
bool checkSameValue();
bool checkLogicalZero();
void adjustIncrease(double& f, double& fMin);
bool calScaleByLinear();
bool calScaleByLogical();
void finalAdjustP();
private:
// 计算过程中涉及到的一些中间变量
double m_fMax;
double m_fMin;
double m_fMinRaw;
double m_fMaxRaw;
bool m_bAxisX;
bool m_bLinear;
bool m_bNeedTurn;
bool m_bExpand;
double m_fTickIncrease;
QVector<double>* m_pVecTicks;
};