85 lines
2.6 KiB
C++
85 lines
2.6 KiB
C++
|
|
#pragma once
|
|
|
|
#include "../RenderAble.h"
|
|
|
|
|
|
namespace YSG {
|
|
// const double delta = event->angleDelta().y();
|
|
// double wheelSteps = delta / 120.0;
|
|
// double factor = qPow(0.8, wheelSteps);
|
|
struct AbsAxis_Prop{
|
|
int x{};
|
|
int y{};
|
|
Qt::Orientation orientation = Qt::Horizontal;
|
|
int tickLength = 10;
|
|
int subTickLength = 5;
|
|
double coordStart = 0;
|
|
double coordLength = 20;
|
|
QColor color = Qt::white;
|
|
QChar formatChar = 'f';
|
|
QLocale locale;
|
|
QString unitText = "";
|
|
QFont unitTextFont;
|
|
QPen unitTextPen = QPen(Qt::white);
|
|
QBrush unitTextBackgroundBrush = QBrush(Qt::black);
|
|
int rotate = 0; // 不旋转
|
|
};
|
|
struct AbsAxisPrivate;
|
|
class LIB_DECL AbsAxis : public RenderAble {
|
|
public:
|
|
Q_Ptr2(AbsAxis)
|
|
PROP(int, x)
|
|
PROP(int, y)
|
|
PROP(Qt::Orientation, orientation)
|
|
PROP(size_t, pixelSize)
|
|
PROP(int, tickLength)
|
|
PROP(int, subTickLength)
|
|
PROP(QColor, color)
|
|
PROP(QChar, formatChar)
|
|
PROP(QLocale, locale)
|
|
PROP(QString, unitText)
|
|
PROP(QFont, unitTextFont)
|
|
PROP(QPen, unitTextPen)
|
|
PROP(QBrush, unitTextBackgroundBrush)
|
|
PROP(int, rotate) // 不旋转
|
|
[[nodiscard]] virtual double pixelToCoord(double pixel, SRC src);
|
|
[[nodiscard]] virtual double coordToPixel(double coord, SRC src);
|
|
[[nodiscard]] virtual double getTickStep(const Range &range);
|
|
[[nodiscard]] virtual int getSubTickCount(double tickStep);
|
|
virtual QString getTickLabel(double tick, SRC);
|
|
virtual QVector<double> createTickVector(double tickStep, const Range &range);
|
|
virtual QVector<double> createSubTickVector(int subTickCount, const QVector<double> &ticks, const Range& range);
|
|
virtual QVector<QString> createLabelVector(const QVector<double> &ticks, SRC);
|
|
double startCoord(SRC=SRC::Edit);
|
|
double endCoord(SRC=SRC::Edit);
|
|
Range coordRange(SRC=SRC::Edit);
|
|
int getPixelPointSize(Range range, SRC=SRC::Edit);
|
|
int getPixelPointSize(SRC=SRC::Edit);
|
|
template <typename That> struct BuilderT;
|
|
};
|
|
template <typename That>
|
|
struct AbsAxis::BuilderT : protected AbsAxis_Prop {
|
|
PROP_BT(int, x)
|
|
PROP_BT(int, y)
|
|
PROP_BT(Qt::Orientation, orientation)
|
|
PROP_BT(size_t, pixelSize)
|
|
PROP_BT(int, tickLength)
|
|
PROP_BT(int, subTickLength)
|
|
PROP_BT(QColor, color)
|
|
PROP_BT(QChar, formatChar)
|
|
PROP_BT(QLocale, locale)
|
|
PROP_BT(QString, unitText)
|
|
PROP_BT(QFont, unitTextFont)
|
|
PROP_BT(QPen, unitTextPen)
|
|
PROP_BT(QBrush, unitTextBackgroundBrush)
|
|
PROP_BT(int, rotate) // 不旋转
|
|
SETTER_T(QString, layerName, "axis")
|
|
protected:
|
|
Plot *plot{};
|
|
size_t pixelSize{};
|
|
void set(AbsAxis* ret);
|
|
};
|
|
}
|
|
|