SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
selectionbeaconoverlay.h
Go to the documentation of this file.
1
33#ifndef OPENSWMMVIS_MAP_SELECTIONBEACONOVERLAY_H
34#define OPENSWMMVIS_MAP_SELECTIONBEACONOVERLAY_H
35
36#include <QColor>
37#include <QElapsedTimer>
38#include <QObject>
39#include <QPointF>
40#include <QTimer>
41#include <QVector>
42
43#include <functional>
44
45class QPainter;
46
48namespace SelectionBeacon {
49inline constexpr int kBeaconRadiusPx = 14;
50inline constexpr int kFlashMaxRadiusPx = 46;
51inline constexpr int kFlashDurationMs = 800;
52inline constexpr int kFlashFrameMs = 33;
53inline constexpr int kMaxBeacons = 250;
54}
55
56class SelectionBeaconOverlay : public QObject
57{
58 Q_OBJECT
59
60public:
61 explicit SelectionBeaconOverlay(QObject *parent = nullptr);
62
65 void setAnchors(const QVector<QPointF> &sceneAnchors);
66
67 [[nodiscard]] bool isEmpty() const { return m_anchors.isEmpty(); }
68
70 void setColor(const QColor &c);
71
76 void paint(QPainter &p,
77 const std::function<QPointF(const QPointF &)> &toPixel,
78 const QSize &viewport);
79
80signals:
84
85private:
87 [[nodiscard]] double flashProgress() const;
88
89 QVector<QPointF> m_anchors;
90 QColor m_color = QColor(255, 200, 0);
91 QElapsedTimer m_flashClock;
92 bool m_flashing = false;
93 QTimer m_frameTimer;
94};
95
96#endif // OPENSWMMVIS_MAP_SELECTIONBEACONOVERLAY_H
Definition selectionbeaconoverlay.h:57
void setColor(const QColor &c)
Definition selectionbeaconoverlay.cpp:50
void setAnchors(const QVector< QPointF > &sceneAnchors)
Definition selectionbeaconoverlay.cpp:35
bool isEmpty() const
Definition selectionbeaconoverlay.h:67
void paint(QPainter &p, const std::function< QPointF(const QPointF &)> &toPixel, const QSize &viewport)
Draws the beacon(s) in DEVICE pixels.
Definition selectionbeaconoverlay.cpp:64
ArrowPlacement p
Definition linesymbollayer.cpp:27
Definition selectionbeaconoverlay.h:48
constexpr int kBeaconRadiusPx
steady ring radius
Definition selectionbeaconoverlay.h:49
constexpr int kFlashDurationMs
Definition selectionbeaconoverlay.h:51
constexpr int kMaxBeacons
beyond this, aggregate
Definition selectionbeaconoverlay.h:53
constexpr int kFlashMaxRadiusPx
ring radius at end of flash
Definition selectionbeaconoverlay.h:50
constexpr int kFlashFrameMs
~30 fps while flashing
Definition selectionbeaconoverlay.h:52
QVector< int > parent
union-find
Definition pslgminsize.cpp:176