Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/axiscontrol.h
Show All 22 Lines | |||||
23 | #include <QGraphicsEllipseItem> | 23 | #include <QGraphicsEllipseItem> | ||
24 | 24 | | |||
25 | #include "atcorewidgets_export.h" | 25 | #include "atcorewidgets_export.h" | ||
26 | 26 | | |||
27 | class ATCOREWIDGETS_EXPORT PieButton : public QObject, public QGraphicsEllipseItem | 27 | class ATCOREWIDGETS_EXPORT PieButton : public QObject, public QGraphicsEllipseItem | ||
28 | { | 28 | { | ||
29 | Q_OBJECT | 29 | Q_OBJECT | ||
30 | public: | 30 | public: | ||
31 | PieButton(QLatin1Char &axis, int value, int size, int angle); | 31 | PieButton(QLatin1Char &axis, double value, int size, int angle); | ||
32 | void setPalette(QPalette palette); | 32 | void setPalette(QPalette palette); | ||
33 | protected: | 33 | protected: | ||
34 | void mousePressEvent(QGraphicsSceneMouseEvent *); | 34 | void mousePressEvent(QGraphicsSceneMouseEvent *); | ||
35 | void hoverEnterEvent(QGraphicsSceneHoverEvent *); | 35 | void hoverEnterEvent(QGraphicsSceneHoverEvent *); | ||
36 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *); | 36 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *); | ||
37 | signals: | 37 | signals: | ||
38 | void clicked(QLatin1Char axis, int value); | 38 | void clicked(QLatin1Char axis, double value); | ||
39 | private: | 39 | private: | ||
40 | QLatin1Char _axis; | 40 | QLatin1Char _axis; | ||
41 | int _value; | 41 | double _value; | ||
42 | QPalette _palette; | 42 | QPalette _palette; | ||
43 | }; | 43 | }; | ||
44 | 44 | | |||
45 | class ATCOREWIDGETS_EXPORT RectButton : public QObject, public QGraphicsRectItem | 45 | class ATCOREWIDGETS_EXPORT RectButton : public QObject, public QGraphicsRectItem | ||
46 | { | 46 | { | ||
47 | Q_OBJECT | 47 | Q_OBJECT | ||
48 | 48 | | |||
49 | public: | 49 | public: | ||
50 | RectButton(QLatin1Char &axis, int value, int size); | 50 | RectButton(QLatin1Char &axis, double value, int size); | ||
51 | void setPalette(QPalette palette); | 51 | void setPalette(QPalette palette); | ||
52 | void setSelected(bool selected); | ||||
52 | protected: | 53 | protected: | ||
53 | void mousePressEvent(QGraphicsSceneMouseEvent *); | 54 | void mousePressEvent(QGraphicsSceneMouseEvent *); | ||
54 | void hoverEnterEvent(QGraphicsSceneHoverEvent *); | 55 | void hoverEnterEvent(QGraphicsSceneHoverEvent *); | ||
55 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *); | 56 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *); | ||
56 | signals: | 57 | signals: | ||
57 | void clicked(QLatin1Char axis, int value); | 58 | void clicked(QLatin1Char axis, double value); | ||
58 | private: | 59 | private: | ||
60 | bool _selected; | ||||
59 | QLatin1Char _axis; | 61 | QLatin1Char _axis; | ||
60 | int _value; | 62 | double _value; | ||
61 | QPalette _palette; | 63 | QPalette _palette; | ||
62 | }; | 64 | }; | ||
63 | 65 | | |||
64 | /** | 66 | /** | ||
65 | * @brief AxisControl is a Widget to generate axis relative movements. | 67 | * @brief AxisControl is a Widget to generate axis relative movements. | ||
66 | * | 68 | * | ||
67 | * Usage: | 69 | * Usage: | ||
68 | * Create a instance of AxisControl and connect the clicked signal, it will give you the axis and value that was clicked. | 70 | * Create a instance of AxisControl and connect the clicked signal, it will give you the axis and value that was clicked. | ||
69 | */ | 71 | */ | ||
70 | class ATCOREWIDGETS_EXPORT AxisControl : public QGraphicsView | 72 | class ATCOREWIDGETS_EXPORT AxisControl : public QGraphicsView | ||
71 | { | 73 | { | ||
72 | Q_OBJECT | 74 | Q_OBJECT | ||
73 | 75 | | |||
74 | public: | 76 | public: | ||
75 | explicit AxisControl(const QList<int> &movementValues = {1, 10, 25}, QWidget *parent = nullptr); | 77 | explicit AxisControl(const QList<double> &movementValues = {0.1, 1, 10}, QWidget *parent = nullptr); | ||
76 | 78 | | |||
77 | private: | 79 | private: | ||
78 | void setLabels(QGraphicsItem *item, QLatin1Char &axis, int value); | 80 | void createScene(); | ||
81 | void setLabels(QGraphicsItem *item, QLatin1Char &axis, double value); | ||||
82 | void setValues(const QList<double> &movementValues); | ||||
83 | QList<double> _mValues; | ||||
84 | double _setScale; | ||||
79 | 85 | | |||
80 | protected: | 86 | protected: | ||
81 | void resizeEvent(QResizeEvent *); | 87 | void resizeEvent(QResizeEvent *); | ||
82 | 88 | | |||
83 | signals: | 89 | signals: | ||
84 | /** | 90 | /** | ||
85 | * @brief User has clicked to move an axis. | 91 | * @brief User has clicked to move an axis. | ||
86 | * @param axis: Axis to move | 92 | * @param axis: Axis to move | ||
87 | * @param value: Amount to move | 93 | * @param value: Amount to move | ||
88 | */ | 94 | */ | ||
89 | void clicked(QLatin1Char axis, int value); | 95 | void clicked(QLatin1Char axis, double value); | ||
90 | | ||||
91 | }; | 96 | }; |