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
rulelist.h
Go to the documentation of this file.
1
29#ifndef OPENSWMM_RENDER_RULELIST_H
30#define OPENSWMM_RENDER_RULELIST_H
31
32#include "render/rule.h"
33
34#include <QJsonArray>
35#include <QObject>
36
37#include <memory>
38#include <vector>
39
40namespace OpenSWMM::Render
41{
42
47class RuleList : public QObject
48{
49 Q_OBJECT
50
51public:
52 explicit RuleList(QObject *parent = nullptr);
53 ~RuleList() override;
54
55 RuleList(const RuleList &) = delete;
56 RuleList &operator=(const RuleList &) = delete;
57 RuleList(RuleList &&) = delete;
59
60 // ── Read access ───────────────────────────────────────────────────
61
62 [[nodiscard]] int count() const;
63 [[nodiscard]] bool isEmpty() const { return count() == 0; }
64 [[nodiscard]] Rule *at(int index) const;
65 [[nodiscard]] int indexOf(const Rule *rule) const;
66
67 [[nodiscard]] int activeIndex() const { return m_activeIndex; }
68 [[nodiscard]] Rule *activeRule() const;
69
70 // ── Mutators (each emits ruleListChanged after the change lands) ──
71
75 Rule *append(std::unique_ptr<Rule> rule);
76
78 Rule *insert(int index, std::unique_ptr<Rule> rule);
79
83 bool remove(int index);
84
88 bool move(int from, int to);
89
91 void clear();
92
95 void setActiveIndex(int index);
96
97 // ── JSON ──────────────────────────────────────────────────────────
98
99 [[nodiscard]] QJsonArray toJson() const;
100
105 void fromJson(const QJsonArray &arr);
106
125 void loadLegacySublayersAsRules(const QJsonArray &sublayers);
126
127signals:
130 void ruleChanged(int i);
132private:
133 void connectRule(Rule *r);
135 std::vector<std::unique_ptr<Rule>> m_rules;
136 int m_activeIndex = -1;
137};
138
139} // namespace OpenSWMM::Render
140
141#endif // OPENSWMM_RENDER_RULELIST_H
One layer-scope styled aspect — name + renderer + filter + scale.
Definition rule.h:51
Ordered owning container for Rules on one layer.
Definition rulelist.h:48
bool isEmpty() const
Definition rulelist.h:63
Rule * activeRule() const
Definition rulelist.cpp:44
RuleList & operator=(const RuleList &)=delete
bool remove(int index)
Remove the Rule at index. Returns true on success. Active index is adjusted so the same Rule (or its ...
Definition rulelist.cpp:100
RuleList(RuleList &&)=delete
Rule * append(std::unique_ptr< Rule > rule)
Append a Rule. The list takes ownership and reparents the Rule. Returns the raw pointer for caller co...
Definition rulelist.cpp:64
QJsonArray toJson() const
Definition rulelist.cpp:173
void clear()
Remove every Rule.
Definition rulelist.cpp:150
RuleList(const RuleList &)=delete
int activeIndex() const
Definition rulelist.h:67
void loadLegacySublayersAsRules(const QJsonArray &sublayers)
Migrate a legacy "sublayers" array (shipped .oswp format — see RENDERING_OUTPUT_SUBLAYERS_PLAN....
Definition rulelist.cpp:201
Rule * at(int index) const
Definition rulelist.cpp:27
bool move(int from, int to)
Move the Rule at from to position to. Returns false if either index is out of range or from == to....
Definition rulelist.cpp:122
void fromJson(const QJsonArray &arr)
Re-populate from a previously produced QJsonArray. Entries that fail Rule::fromJson() are skipped (fo...
Definition rulelist.cpp:181
RuleList & operator=(RuleList &&)=delete
Rule * insert(int index, std::unique_ptr< Rule > rule)
Insert at index. index is clamped to [0, count()].
Definition rulelist.cpp:79
void setActiveIndex(int index)
Update the active index. Clamped to [-1, count()-1]; -1 means no active selection.
Definition rulelist.cpp:162
int indexOf(const Rule *rule) const
Definition rulelist.cpp:34
size_t i
Definition contourjob.cpp:27
int index
Position in m_quadRegions / m_quadReports.
Definition meshgenerator.cpp:153
Definition gisrasterlayer.h:40
int count
Definition numberformat.cpp:101
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
Layer-scope Rule — one styled aspect of a layer.