10#ifndef LAYERTREEPANEL_H
11#define LAYERTREEPANEL_H
13#include <QAbstractItemModel>
28class QSortFilterProxyModel;
91 QModelIndex
index(
int row,
int column,
const QModelIndex &
parent = {})
const override;
92 QModelIndex
parent(
const QModelIndex &child)
const override;
95 QVariant
data(
const QModelIndex &
index,
int role = Qt::DisplayRole)
const override;
96 bool setData(
const QModelIndex &
index,
const QVariant &value,
int role)
override;
97 Qt::ItemFlags
flags(
const QModelIndex &
index)
const override;
98 QVariant
headerData(
int section, Qt::Orientation orientation,
int role)
const override;
103 int row,
int column,
const QModelIndex &
parent)
const override;
105 int row,
int column,
const QModelIndex &
parent)
override;
106 QMimeData *
mimeData(
const QModelIndexList &indexes)
const override;
192 void onLayerOrderChanged();
201 QVector<OpenSWMMVisLayer *> layers;
212 int kindOrdinal = -1;
214 static constexpr int kKindsPerSwmmModelLayer = 11;
226 void rebuildCategories();
227 void rebuildKindRows();
228 void rebuildSublayerRows();
230 int sublayerRowIndex(
const void *sublayerRowPtr)
const;
236 QPointer<MapCanvas> m_canvas;
237 QVector<Category> m_categories;
238 QHash<OpenSWMMVisLayer *, int> m_layerToCategory;
239 QHash<OpenSWMMVisLayer *, std::array<KindRow, kKindsPerSwmmModelLayer>>
241 QSet<const void *> m_kindRowPtrSet;
247 QHash<OpenSWMMVisLayer *, std::vector<SublayerRow>>
248 m_sublayerRowStorage;
249 QSet<const void *> m_sublayerRowPtrSet;
317 const QString &routingId = QString());
345 const QString &rendererId);
385 void onRemoveSelectedLayer();
386 void onZoomToSelectedLayer();
387 void onMoveLayerUp();
388 void onMoveLayerDown();
389 void onMoveCategoryUp();
390 void onMoveCategoryDown();
391 void onSelectionChanged();
392 void onLayerDoubleClicked(
const QModelIndex &
index);
393 void onContextMenuRequested(
const QPoint &
pos);
394 void onSearchTextChanged(
const QString &
text);
399 QModelIndex toSourceIndex(
const QModelIndex &proxyIdx)
const;
404 void moveSelectedLayerToRow(
int targetRow);
405 void moveSelectedCategoryToRow(
int targetRow);
409 void rememberCurrentRow();
410 void restoreRememberedRow();
412 struct RememberedRow {
414 QPointer<OpenSWMMVisLayer> layer;
417 RememberedRow m_remembered;
419 QPointer<MapCanvas> m_canvas;
420 QTreeView *m_treeView =
nullptr;
421 QLineEdit *m_searchEdit =
nullptr;
423 QSortFilterProxyModel *m_proxy =
nullptr;
426 QPointer<SWMMResultsLayer> m_activeResults1D;
427 QPointer<SWMM2DResultsLayer> m_activeResults2D;
QAbstractItemModel that mirrors the layer stack of a MapCanvas, grouped by category.
Definition layertreepanel.h:72
QModelIndex indexForLayer(OpenSWMMVisLayer *layer) const
Definition layertreepanel.cpp:1304
bool reorderCategory(int categoryId, int dstTreeRow)
Slice LTR-2026-09-19 — moves the category group categoryId (an openswmmvis::ui::CategoryId currently ...
Definition layertreepanel.cpp:1111
bool isSublayerIndex(const QModelIndex &index) const
Definition layertreepanel.cpp:1354
int columnCount(const QModelIndex &parent={}) const override
Definition layertreepanel.cpp:657
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Definition layertreepanel.cpp:846
Qt::DropActions supportedDropActions() const override
Definition layertreepanel.cpp:1004
void setCanvas(MapCanvas *canvas)
Rebind to a different MapCanvas (called on MDI tab switch). Pass nullptr to detach (empty tree).
Definition layertreepanel.cpp:251
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Definition layertreepanel.cpp:1161
MapCanvas * canvas() const
Definition layertreepanel.cpp:287
QModelIndex indexForSublayer(OpenSWMMVisLayer *layer, OpenSWMM::Render::ISublayer *sublayer) const
Definition layertreepanel.cpp:1313
OpenSWMMVisLayer * kindParentLayer(const QModelIndex &index) const
Definition layertreepanel.cpp:1340
void notifyHostSubOrderChanged()
Slice GUI-2026-05-30 §2 / §3 — notify the model that the sublayer or kind paint-order on a host layer...
Definition layertreepanel.cpp:1422
OpenSWMM::Render::ISublayer * sublayerForIndex(const QModelIndex &index) const
Definition layertreepanel.cpp:1368
bool isKindIndex(const QModelIndex &index) const
Definition layertreepanel.cpp:1333
QStringList mimeTypes() const override
Definition layertreepanel.cpp:997
QModelIndex indexForCategory(int categoryId) const
Definition layertreepanel.cpp:1296
OpenSWMMVisLayer * layerForIndex(const QModelIndex &index) const
Returns the OpenSWMMVisLayer for a layer-row index, or nullptr for category rows / invalid indices.
Definition layertreepanel.cpp:1274
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
Definition layertreepanel.cpp:1057
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition layertreepanel.cpp:930
int categoryIdForIndex(const QModelIndex &index) const
Definition layertreepanel.cpp:1289
int rowCount(const QModelIndex &parent={}) const override
Definition layertreepanel.cpp:627
QMimeData * mimeData(const QModelIndexList &indexes) const override
Definition layertreepanel.cpp:1010
OpenSWMMVisLayer * sublayerParentLayer(const QModelIndex &index) const
Definition layertreepanel.cpp:1361
bool isCategoryIndex(const QModelIndex &index) const
True if index is a category header row (no associated layer).
Definition layertreepanel.cpp:1326
~LayerTreeModel() override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition layertreepanel.cpp:662
int kindOrdinal(const QModelIndex &index) const
Definition layertreepanel.cpp:1346
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition layertreepanel.cpp:980
Embeddable widget containing the layer tree.
Definition layertreepanel.h:274
void setActiveResultsLayer(SWMMResultsLayer *layer)
Cache the project window's active 1D / 2D results layers so the context-menu "Set as Active Results L...
Definition layertreepanel.cpp:2140
void setActive2DResultsLayerRequested(class SWMM2DResultsLayer *layer)
void setCanvas(MapCanvas *canvas)
Rebind the panel and its model to a different canvas.
Definition layertreepanel.cpp:1461
void layerSelected(OpenSWMMVisLayer *layer)
Emitted when the user selects a layer in the tree.
void plotKindObjectRequested(int kindOrdinal, const QString &objectName)
Slice PT.1 — emitted when the user picks "Plot timeseries…" on a kind sub-row's right-click menu and ...
void layerStyleRequested(OpenSWMMVisLayer *layer)
Emitted when the user picks "Set Style…" on a layer's context menu. SWMMVis listens and opens the Sym...
void layerKindStyleRequested(OpenSWMMVisLayer *layer, int kindOrdinal, const QString &rendererId)
Slice BI-MK.LT — emitted when the user picks a Style option from a kind sub-row's right-click menu....
void setActive2DResultsLayer(SWMM2DResultsLayer *layer)
Definition layertreepanel.cpp:2145
LayerTreeModel * model() const
Definition layertreepanel.h:292
void attributeTableRequested(OpenSWMMVisLayer *layer)
Emitted when the user picks "Open Attribute Table" on a layer's context menu. SWMMVis raises the Attr...
void setActiveResultsLayerRequested(class SWMMResultsLayer *layer)
Emitted when the user picks "Set as Active Results Layer" on a results layer's context menu....
~LayerTreePanel() override
void layerPropertiesRequested(OpenSWMMVisLayer *layer, const QString &routingId=QString())
Emitted when the user requests to view properties for a layer. routingId is empty for plain "Properti...
void kindSelected(OpenSWMMVisLayer *layer, int kindOrdinal)
Emitted when the user selects a SWMM kind sub-row (e.g. "Storage"). kindOrdinal matches the SWMMModel...
void plotTimeSeriesFromOutputLayerRequested(class SWMMResultsLayer *layer)
Emitted when the user right-clicks a SWMM Output (.out) layer and picks "Plot Time Series…"....
OpenSWMMVisLayer * selectedLayer() const
Returns the currently selected layer, or nullptr.
Definition layertreepanel.cpp:1450
The central map display widget — QGIS-style hybrid rendering.
Definition mapcanvas.h:63
One toggleable visual aspect of a results / model layer.
Definition isublayer.h:87
Abstract base class for all layers displayed in the MapCanvas.
Definition openswmmvislayer.h:116
Top-level project container managing sessions, the SWMM model layer, and persistence paths for one SW...
Definition openswmmvisworkspace.h:42
Definition swmm2dresultslayer.h:550
Overlays time-stepped simulation results on the SWMM network geometry.
Definition swmmresultslayer.h:96
SWMM_FilePathRole role
Definition ioportabilitynormalizer.cpp:22
int index
Position in m_quadRegions / m_quadReports.
Definition meshgenerator.cpp:153
Definition gisrasterlayer.h:40
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
int pos
Definition queryparser.cpp:36
QString text
Definition queryparser.cpp:35
QString name
Definition sectionmodelbuilders.cpp:474