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

Base class owning the tile cache + parent-fallback compositor shared by tile-pyramid layers. More...

#include <tilepyramidlayer.h>

Inheritance diagram for TilePyramidLayer:
Collaboration diagram for TilePyramidLayer:

Classes

struct  TileDraw
 A resolved per-tile draw: paint src (a sub-rect of img, in image pixels with row 0 = the tile extent's yMax edge) into the tile's destination footprint. exact is false when the image is a coarser-tile stand-in. More...
 

Public Member Functions

 TilePyramidLayer (OpenSWMMVisWorkspace *parent=nullptr)
 
 ~TilePyramidLayer () override
 
- Public Member Functions inherited from OpenSWMMVisLayer
 OpenSWMMVisLayer (OpenSWMMVisWorkspace *parent)
 
 OpenSWMMVisLayer (const QString &name="Unlabeled Layer", OpenSWMMVisWorkspace *parent=nullptr)
 
virtual ~OpenSWMMVisLayer ()
 
QString layerId () const
 Returns the layer's immutable unique identifier (UUID).
 
QString name () const
 Returns the user-visible name of this layer.
 
void setName (const QString &name)
 Sets the user-visible name.
 
OpenSWMMVisLayerType layerType () const
 Returns the layer type discriminator.
 
bool isVisible () const
 Returns true when this layer should be drawn.
 
void setVisible (bool visible)
 Shows or hides this layer.
 
double opacity () const
 Returns the layer opacity in the range [0.0, 1.0]. 0.0 = fully transparent; 1.0 = fully opaque.
 
void setOpacity (double opacity)
 Sets the layer opacity. Values are clamped to [0.0, 1.0].
 
SpatialReferenceSystemsrs () const
 Returns the spatial reference system for this layer, or nullptr if the layer has no known CRS.
 
void setSRS (SpatialReferenceSystem *srs, bool ownsSRS=false)
 Sets (or replaces) the CRS for this layer.
 
QString crsDescription () const
 Returns a human-readable summary of this layer's CRS for display in the Properties window.
 
MapExtent extent () const
 Returns the layer extent in the layer's own CRS.
 
void setExtent (const MapExtent &extent)
 Sets the layer spatial extent (in the layer's CRS).
 
virtual QString sourceDescription () const
 Human-readable source of this layer: a file path, a service URL, or a description for in-memory / derived layers.
 
virtual QVector< QPair< QString, QString > > extendedMetadata () const
 Ordered key→value pairs of TYPE-SPECIFIC metadata, rendered by the Metadata tab below the common block the dialog builds itself.
 
virtual bool isRasterLayer () const
 Returns true for layers that render into a raster buffer (WMS, WMTS, GISRaster) rather than populating QGraphicsItems.
 
virtual bool isBasemapLayer () const
 Returns true for world-spanning basemap layers (XYZ tile providers, WMS/WMTS services covering the whole world) that should NOT be included when computing the data-driven full extent.
 
virtual void render (QPainter *painter, const MapExtent &extent, const QSize &imageSize, const SpatialReferenceSystem *srs)
 Renders this layer's content directly into painter.
 
virtual void fetchCache (const MapExtent &extent, const QSize &viewportSize, const SpatialReferenceSystem *srs)
 Triggers any asynchronous (or synchronous) tile/data fetch needed to populate this layer's internal cache for the given view state.
 
void setViewportSize (int w, int h)
 Called by MapCanvas before refreshScene so layers can request the correct pixel dimensions for tile/image requests.
 
int viewportWidth () const
 
int viewportHeight () const
 
QVector< OpenSWMMVisLayer * > children () const
 Returns the ordered list of child layers.
 
virtual void populateScene (QGraphicsScene *scene, const MapExtent &canvasExtent, const SpatialReferenceSystem *canvasSRS)=0
 Creates / updates QGraphicsItems representing this layer in the scene.
 
virtual void depopulateScene (QGraphicsScene *scene)
 Removes all QGraphicsItems belonging to this layer from the scene.
 
virtual void refreshScene (QGraphicsScene *scene, const MapExtent &canvasExtent, const SpatialReferenceSystem *canvasSRS)
 Smart scene refresh — updates existing items instead of destroying and recreating.
 
double layerZValue () const
 Returns the z-value base assigned to this layer by the canvas. Items within the layer should use z-values relative to this.
 
virtual std::vector< std::unique_ptr< openswmmvis::ui::ILayerStyleSubject > > styleSubjects ()
 Slice U-2 — return the styleable subjects for the unified LayerStyleDialog.
 
void setLayerZValue (double z)
 Called by the canvas to set this layer's z-value band.
 
virtual void onCanvasCRSChanged (const SpatialReferenceSystem *newCanvasSRS)
 Called when the user changes the canvas CRS so layers can pre-compute any CRS-dependent transform caches.
 
virtual OpenSWMM::Render::IFeatureRendererrenderer () const
 
virtual void setRenderer (std::unique_ptr< OpenSWMM::Render::IFeatureRenderer >)
 
virtual OpenSWMM::Render::RuleListruleList ()
 
virtual const OpenSWMM::Render::RuleListruleList () const
 
const OpenSWMM::Render::TemporalSpectemporalSpec () const
 
void setTemporalSpec (const OpenSWMM::Render::TemporalSpec &spec)
 
const OpenSWMM::Render::LabelConfiglabelConfig () const
 
virtual void setLabelConfig (const OpenSWMM::Render::LabelConfig &cfg)
 
const OpenSWMM::Render::MaskSpecmaskSpec () const
 
void setMaskSpec (const OpenSWMM::Render::MaskSpec &spec)
 
const OpenSWMM::Render::AuxiliaryStorageSpecauxStorageSpec () const
 
void setAuxStorageSpec (const OpenSWMM::Render::AuxiliaryStorageSpec &spec)
 
const QVector< OpenSWMM::Render::JoinSpec > & joins () const
 
void setJoins (const QVector< OpenSWMM::Render::JoinSpec > &joins)
 
const OpenSWMM::Render::DiagramSpecdiagramSpec () const
 
void setDiagramSpec (const OpenSWMM::Render::DiagramSpec &spec)
 
OpenSWMMVisWorkspaceworkspace () const
 
void setBasicAuth (const QString &username, const QString &password)
 Sets HTTP Basic authentication for all subsequent network requests.
 
void setHttpHeaders (const BasemapHttpHeaders &headers)
 Sets arbitrary extra HTTP headers applied to every request.
 
BasemapHttpHeaders httpHeaders () const
 

Protected Member Functions

void cacheTile (const QString &key, const QImage &img, const MapExtent &extent, int level)
 Insert a produced tile (no-op for null images). extent is the tile's geographic extent in the subclass's tile CRS; level is the subclass's pyramid-level tag (metadata only — the fallback search is extent-based).
 
bool isTileCached (const QString &key) const
 True when key holds a non-null cached tile. Does not promote the entry in the LRU.
 
QImage cachedTileImage (const QString &key) const
 The cached image for key, or a null QImage.
 
void clearTiles ()
 Drop every cached tile (style / CRS / source change).
 
void setTileCacheCapacity (int maxTiles)
 
int tileCacheCapacity () const
 
bool resolveTileForDraw (const QString &key, const MapExtent &tileExtent, double maxSpanRatio, TileDraw &out) const
 Resolve the image + source sub-rect that should paint the tile key with geographic extent tileExtent.
 
- Protected Member Functions inherited from OpenSWMMVisLayer
bool addChild (OpenSWMMVisLayer *child)
 
bool removeChild (OpenSWMMVisLayer *child)
 
void setLayerType (OpenSWMMVisLayerType type)
 

Additional Inherited Members

- Public Types inherited from OpenSWMMVisLayer
enum  OpenSWMMVisLayerType {
  SWMMDefaultLayer = 0 ,
  SWMMModelLayer = 1 ,
  SWMMResultsLayer = 2 ,
  SWMMGISLayer = 3 ,
  SWMMVectorLayer = 4 ,
  SWMMRasterLayer = 5 ,
  SWMMImageryLayer = 6 ,
  SWMMTabularDataLayer = 7 ,
  SWMMTabularyTimeSeriesLayer = 8 ,
  SWMMSubProjectLayer = 9 ,
  SWMMWMSLayer = 10 ,
  SWMMWMTSLayer = 11 ,
  SWMM2DMeshLayer = 12 ,
  SWMM2DResultsLayer = 13 ,
  SWMMAnnotationLayer = 14 ,
  SWMMFeatureLayer = 15
}
 Discriminator for the concrete layer class. More...
 
- Signals inherited from OpenSWMMVisLayer
void nameChanged (const QString &newName)
 
void layerTypeChanged (OpenSWMMVisLayerType newType)
 
void visibilityChanged (bool visible)
 
void opacityChanged (double opacity)
 
void srsChanged (SpatialReferenceSystem *newSRS)
 
void extentChanged (const MapExtent &newExtent)
 
void childrenChanged ()
 
void repaintRequested ()
 
void temporalSpecChanged (const OpenSWMM::Render::TemporalSpec &spec)
 
void maskSpecChanged (const OpenSWMM::Render::MaskSpec &spec)
 
void auxStorageSpecChanged (const OpenSWMM::Render::AuxiliaryStorageSpec &spec)
 
void joinsChanged (const QVector< OpenSWMM::Render::JoinSpec > &joins)
 
void diagramSpecChanged (const OpenSWMM::Render::DiagramSpec &spec)
 
void labelConfigChanged ()
 
- Protected Attributes inherited from OpenSWMMVisLayer
QByteArray m_authHeader
 "Basic <base64>" or empty
 
BasemapHttpHeaders m_httpHeaders
 arbitrary headers (incl. "referer")
 
- Properties inherited from OpenSWMMVisLayer
QString Name
 
bool Visible
 
double Opacity
 
QString LayerId
 
OpenSWMMVisLayerType LayerType
 
QVector< OpenSWMMVisLayer * > Children
 
QString CRS
 

Detailed Description

Base class owning the tile cache + parent-fallback compositor shared by tile-pyramid layers.

Subclasses keep their layer-specific tile production (GDAL warp for GISRasterLayer, HTTP GetTile for WMTSLayer) and placement (axis-aligned vs quadToQuad draw); the base resolves "what image / sub-rect should paint this tile" under one lock.

The fallback is extent-based and grid-agnostic: every cached tile carries its geographic extent (in the subclass's tile CRS), and a missing tile falls back to the smallest cached tile whose extent contains it — no assumption of power-of-two col/row halving, which is what lets the raster's dyadic grid and WMTS's arbitrary TileMatrixSets share one implementation.

Thread-safety: all protected cache operations lock an internal mutex, so a worker-thread render() may resolve tiles while the GUI thread inserts or clears them.

Constructor & Destructor Documentation

◆ TilePyramidLayer()

TilePyramidLayer::TilePyramidLayer ( OpenSWMMVisWorkspace parent = nullptr)
explicit

◆ ~TilePyramidLayer()

TilePyramidLayer::~TilePyramidLayer ( )
overridedefault

Member Function Documentation

◆ cachedTileImage()

QImage TilePyramidLayer::cachedTileImage ( const QString &  key) const
protected

The cached image for key, or a null QImage.

Here is the caller graph for this function:

◆ cacheTile()

void TilePyramidLayer::cacheTile ( const QString &  key,
const QImage &  img,
const MapExtent extent,
int  level 
)
protected

Insert a produced tile (no-op for null images). extent is the tile's geographic extent in the subclass's tile CRS; level is the subclass's pyramid-level tag (metadata only — the fallback search is extent-based).

Here is the call graph for this function:

◆ clearTiles()

void TilePyramidLayer::clearTiles ( )
protected

Drop every cached tile (style / CRS / source change).

Here is the caller graph for this function:

◆ isTileCached()

bool TilePyramidLayer::isTileCached ( const QString &  key) const
protected

True when key holds a non-null cached tile. Does not promote the entry in the LRU.

Here is the caller graph for this function:

◆ resolveTileForDraw()

bool TilePyramidLayer::resolveTileForDraw ( const QString &  key,
const MapExtent tileExtent,
double  maxSpanRatio,
TileDraw out 
) const
protected

Resolve the image + source sub-rect that should paint the tile key with geographic extent tileExtent.

Returns the exact cached tile when present. Otherwise searches the cache for the smallest tile whose extent contains tileExtent (the nearest coarser stand-in) and returns the extent-derived sub-rect of its image. Candidates wider than maxSpanRatio × the tile's own span are rejected so the stand-in never degenerates below a few source pixels.

Returns
true when something can be painted for this tile.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTileCacheCapacity()

void TilePyramidLayer::setTileCacheCapacity ( int  maxTiles)
protected
Here is the caller graph for this function:

◆ tileCacheCapacity()

int TilePyramidLayer::tileCacheCapacity ( ) const
protected
Here is the caller graph for this function:

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