summaryrefslogtreecommitdiff
path: root/gauge.h
diff options
context:
space:
mode:
authorJoshua Drake <joshua.drake@ditchwitch.com>2023-06-20 10:15:47 -0500
committerJoshua Drake <joshua.drake@ditchwitch.com>2023-06-20 10:15:47 -0500
commit58d6674897c90a69aea7bc370e429fbc9d73bcca (patch)
treeab40f2c477c3af60435f54f4646fd24cee78ac04 /gauge.h
Initial CommitHEADmaster
Diffstat (limited to 'gauge.h')
-rw-r--r--gauge.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/gauge.h b/gauge.h
new file mode 100644
index 0000000..7bb9133
--- /dev/null
+++ b/gauge.h
@@ -0,0 +1,51 @@
+/*
+ * JD 12/9/2022
+*/
+#ifndef GAUGE_H
+#define GAUGE_H
+
+#include <QWidget>
+#include <QPainter>
+#include <QString>
+#include <QPixmap>
+#include <QTransform>
+#include <QPixmap>
+#include <QFontMetrics>
+
+#define DEFUALT_IMAGE_ANGLE 90
+
+class Gauge : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit Gauge(QWidget *parent = nullptr);
+ void paintEvent(QPaintEvent *);
+
+signals:
+
+public slots:
+ void setNeedleImage(QPixmap p) {m_needle = p; update();}
+ void setNeedleImage(QString path);
+ //void obtainLength();
+ void setOrigin(int x,int y);
+ void setOrigin(QPoint o);
+ void setHorizontalOffset(int o) {m_needle_horizontal_offset = o; update();}
+ void setStartAngle(qreal a);
+ void setEndAngle(qreal a);
+ void setGaugePercentage(qreal p) {m_gauge_percentage = p; update();}
+
+
+protected:
+
+private:
+ //double m_needle_length;
+ double m_gauge_percentage;
+ int m_needle_horizontal_offset; //Use if needle isn't centered within the image.
+ QPoint m_needle_origin;
+ QPoint m_draw_point;
+ QPixmap m_needle;
+ qreal m_start_angle;
+ qreal m_end_angle;
+};
+
+#endif // GAUGE_H