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
ProjectSerializer Class Reference

#include <projectserializer.h>

Collaboration diagram for ProjectSerializer:

Static Public Member Functions

static bool saveToFile (const QString &oswpPath, SWMMVisProjectWindow *pw, QString *errorOut=nullptr)
 
static bool saveToFile (const QString &oswpPath, SWMMVisProject *proj, QString *errorOut=nullptr)
 
static bool applyFromFile (const QString &oswpPath, SWMMVisProjectWindow *pw, QString *errorOut=nullptr, QStringList *warningsOut=nullptr)
 
static QString sidecarPathFor (const QString &inpPath)
 
static QString toRelativePath (const QString &path, const QString &oswpFile)
 
static QString resolveStoredPath (const QString &stored, const QString &oswpFile)
 

Static Public Attributes

static constexpr int kCurrentSchemaVersion = 5
 

Member Function Documentation

◆ applyFromFile()

bool ProjectSerializer::applyFromFile ( const QString &  oswpPath,
SWMMVisProjectWindow pw,
QString *  errorOut = nullptr,
QStringList *  warningsOut = nullptr 
)
static

Read a .oswp and apply any state it carries to pw's already-loaded SWMM layer and canvas. Silently skips keys the current build doesn't understand (forward-compat). Returns true if the file was parsed successfully. An absent file is not an error — callers Just-Load the .inp and call this opportunistically. Single-instance overload reads sessions[0]. Referenced files that no longer exist (results .out, GIS rasters/vectors) are skipped and reported via warningsOut so the caller can surface them — the load itself proceeds.

Here is the call graph for this function:

◆ resolveStoredPath()

QString ProjectSerializer::resolveStoredPath ( const QString &  stored,
const QString &  oswpFile 
)
inlinestatic

Resolve a path read from a .oswp file: relative paths are resolved against oswpFile's parent directory; absolute paths pass through unchanged (v1–v3 backward compat); empty input returns empty. Inlined alongside toRelativePath.

◆ saveToFile() [1/2]

bool ProjectSerializer::saveToFile ( const QString &  oswpPath,
SWMMVisProject proj,
QString *  errorOut = nullptr 
)
static

Multi-instance overload (AA-3.4). Iterates proj's instance list and writes one sessions[N] block per window, plus the project-level canvas / basemaps / preferences blocks.

Here is the call graph for this function:

◆ saveToFile() [2/2]

bool ProjectSerializer::saveToFile ( const QString &  oswpPath,
SWMMVisProjectWindow pw,
QString *  errorOut = nullptr 
)
static

Write a .oswp sidecar describing pw's current GUI state. Single-instance convenience overload: synthesises a one-entry sessions[] array. Returns true on success; writes an error string on failure.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sidecarPathFor()

QString ProjectSerializer::sidecarPathFor ( const QString &  inpPath)
inlinestatic

Canonical sidecar path: same directory + basename as the given .inp, with the extension swapped to .oswp. Empty input returns empty. Inlined alongside toRelativePath / resolveStoredPath (Slice RB.5) so unit tests can exercise it without linking the full ProjectSerializer .cpp.

Here is the caller graph for this function:

◆ toRelativePath()

QString ProjectSerializer::toRelativePath ( const QString &  path,
const QString &  oswpFile 
)
inlinestatic

Convert path to a path relative to the directory containing oswpFile. Returns the cleaned absolute path unchanged when the two are on different volumes (cross-drive on Windows) or when path is already empty. Uses QDir::relativeFilePath — does not resolve symlinks, to preserve the user's symlink intent across save/load. Inlined so unit tests can exercise it without linking the full ProjectSerializer .cpp (which pulls in MapCanvas etc.).

Member Data Documentation

◆ kCurrentSchemaVersion

constexpr int ProjectSerializer::kCurrentSchemaVersion = 5
staticconstexpr

Current writer version.

Schema 5 (2026-09-07) added the "feature" gisLayers type — an editable, GeoPackage-backed FeatureLayer carrying role / zPolicy / symbol alongside the path-shaped record the other two types use. Readers of schema 4 dispatch only on "raster" / "vector" and fall through silently on an unknown type, so older builds degrade by skipping feature layers rather than failing to open the project.


The documentation for this class was generated from the following files: