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
legendoverlay.h
Go to the documentation of this file.
1
33#ifndef OPENSWMMVIS_UI_WIDGETS_LEGENDOVERLAY_H
34#define OPENSWMMVIS_UI_WIDGETS_LEGENDOVERLAY_H
35
36#include <QPoint>
37#include <QPointer>
38#include <QRect>
39#include <QSize>
40#include <QVector>
41#include <QWidget>
42
43class MapCanvas;
45
46namespace OpenSWMM::Render { class LegendOverlayStyle; }
47
48namespace openswmmvis::ui {
49
50class LegendOverlay : public QWidget
51{
52 Q_OBJECT
53public:
54 explicit LegendOverlay(MapCanvas *canvas);
55 ~LegendOverlay() override;
56
59 void setCanvas(MapCanvas *canvas);
60
64 OpenSWMM::Render::LegendOverlayStyle *style() const noexcept { return m_style; }
65
70 void setStyle(OpenSWMM::Render::LegendOverlayStyle *style, bool takeOwnership = false);
71
72signals:
77
78protected:
79 void paintEvent(QPaintEvent *event) override;
80 void mousePressEvent(QMouseEvent *event) override;
81 void mouseMoveEvent(QMouseEvent *event) override;
82 void mouseReleaseEvent(QMouseEvent *event) override;
83 void contextMenuEvent(QContextMenuEvent *event) override;
84 bool eventFilter(QObject *watched, QEvent *event) override;
85
86private slots:
87 void onStyleChanged();
88 void openPropertiesDialog();
89 void copyLegendImage();
90 void resetLayout();
91 void autoSize();
92
93private:
94 void recomputeLayout();
95 void clampInsideCanvas();
96 void anchorToCanvas(); // re-place per style().anchor() if not Free.
97
98 // ── Slice US.B2 — interactive resize ────────────────────────────────
101 [[nodiscard]] int edgesAt(const QPoint &pos) const;
103 void updateCursor(int edges);
104 void connectLayer(OpenSWMMVisLayer *layer);
105 void disconnectLayer(OpenSWMMVisLayer *layer);
106
108 struct ItemBand {
109 QString classKey; // renderer's per-class identifier; empty = no per-class edit
110 int yTop = 0;
111 int yBottom = 0;
112 };
113 struct LayerBand {
114 QPointer<OpenSWMMVisLayer> layer;
115 int yTop = 0; // header top in widget coords
116 int yBottom = 0; // bottom of the last row of this layer
117 QVector<ItemBand> items; // per-row bands inside this layer's section
118 };
119
122 OpenSWMMVisLayer *layerAtY(int y) const;
123
127 QPair<OpenSWMMVisLayer *, QString> itemAtY(int y) const;
128
129 QPointer<MapCanvas> m_canvas;
130 OpenSWMM::Render::LegendOverlayStyle *m_style = nullptr;
131 bool m_ownsStyle = false;
132 QPoint m_dragStartOffset;
133 bool m_dragging = false;
134 bool m_positioned = false;
135 QVector<LayerBand> m_layerBands;
136
137 // Slice US.B2 — interactive resize state.
138 int m_resizeEdges = 0;
139 QRect m_resizeStartGeom;
140 QPoint m_resizeStartGlobal;
141 bool m_resizing = false;
142};
143
144} // namespace openswmmvis::ui
145
146#endif // OPENSWMMVIS_UI_WIDGETS_LEGENDOVERLAY_H
The central map display widget — QGIS-style hybrid rendering.
Definition mapcanvas.h:63
Model object holding the on-canvas legend's chrome configuration.
Definition legendoverlaystyle.h:50
Abstract base class for all layers displayed in the MapCanvas.
Definition openswmmvislayer.h:116
Definition legendoverlay.h:51
void paintEvent(QPaintEvent *event) override
Definition legendoverlay.cpp:323
void hideRequested()
Emitted when the user selects "Hide Legend" from the context menu. The toolbar should toggle actionSh...
bool eventFilter(QObject *watched, QEvent *event) override
Definition legendoverlay.cpp:732
void contextMenuEvent(QContextMenuEvent *event) override
Definition legendoverlay.cpp:581
void mouseMoveEvent(QMouseEvent *event) override
Definition legendoverlay.cpp:516
OpenSWMM::Render::LegendOverlayStyle * style() const noexcept
Returns the LegendOverlayStyle this overlay paints with. Never null while the overlay exists....
Definition legendoverlay.h:64
void mouseReleaseEvent(QMouseEvent *event) override
Definition legendoverlay.cpp:551
~LegendOverlay() override
Definition legendoverlay.cpp:104
void mousePressEvent(QMouseEvent *event) override
Definition legendoverlay.cpp:495
void setStyle(OpenSWMM::Render::LegendOverlayStyle *style, bool takeOwnership=false)
Swap in a different (project- or canvas-scoped) style. The overlay disconnects from the previous styl...
Definition legendoverlay.cpp:153
void setCanvas(MapCanvas *canvas)
Re-bind to a (possibly null) canvas; disconnects from the old canvas's signals and connects to the ne...
Definition legendoverlay.cpp:112
Definition gisrasterlayer.h:40
Definition openswmmvislayer.h:43
int pos
Definition queryparser.cpp:36