cesium-native  0.41.0
RasterOverlayTile.h
1 #pragma once
2 
3 #include <CesiumAsync/AsyncSystem.h>
4 #include <CesiumAsync/IAssetRequest.h>
5 #include <CesiumGeometry/Rectangle.h>
6 #include <CesiumGltf/Model.h>
7 #include <CesiumUtility/IntrusivePointer.h>
8 #include <CesiumUtility/ReferenceCounted.h>
9 
10 #include <vector>
11 
12 namespace CesiumUtility {
13 struct Credit;
14 }
15 
16 namespace CesiumRasterOverlays {
17 
18 class RasterOverlay;
19 class RasterOverlayTileProvider;
20 
32 class RasterOverlayTile final
33  : public CesiumUtility::ReferenceCountedNonThreadSafe<RasterOverlayTile> {
34 public:
38  enum class LoadState {
42  Placeholder = -2,
43 
47  Failed = -1,
48 
52  Unloaded = 0,
53 
57  Loading = 1,
58 
62  Loaded = 2,
63 
67  Done = 3
68  };
69 
79  enum class MoreDetailAvailable {
80 
82  No = 0,
83 
85  Yes = 1,
86 
89  Unknown = 2
90  };
91 
103 
125  RasterOverlayTileProvider& tileProvider,
126  const glm::dvec2& targetScreenPixels,
127  const CesiumGeometry::Rectangle& imageryRectangle) noexcept;
128 
131 
136  return *this->_pTileProvider;
137  }
138 
142  const RasterOverlayTileProvider& getTileProvider() const noexcept {
143  return *this->_pTileProvider;
144  }
145 
150 
154  const RasterOverlay& getOverlay() const noexcept;
155 
160  const CesiumGeometry::Rectangle& getRectangle() const noexcept {
161  return this->_rectangle;
162  }
163 
171  glm::dvec2 getTargetScreenPixels() const noexcept {
172  return this->_targetScreenPixels;
173  }
174 
178  LoadState getState() const noexcept { return this->_state; }
179 
183  const std::vector<CesiumUtility::Credit>& getCredits() const noexcept {
184  return this->_tileCredits;
185  }
186 
196  getImage() const noexcept {
197  return this->_pImage;
198  }
199 
209  return this->_pImage;
210  }
211 
222 
226  void* getRendererResources() const noexcept {
227  return this->_pRendererResources;
228  }
229 
235  void setRendererResources(void* pValue) noexcept {
236  this->_pRendererResources = pValue;
237  }
238 
244  return this->_moreDetailAvailable;
245  }
246 
247 private:
248  friend class RasterOverlayTileProvider;
249 
250  void setState(LoadState newState) noexcept;
251 
252  // This is a raw pointer instead of an IntrusivePointer in order to avoid
253  // circular references, particularly among a placeholder tile provider and
254  // placeholder tile. However, to avoid undefined behavior, the tile provider
255  // is required to outlive the tile. In normal use, the RasterOverlayCollection
256  // ensures that this is true.
257  RasterOverlayTileProvider* _pTileProvider;
258  glm::dvec2 _targetScreenPixels;
259  CesiumGeometry::Rectangle _rectangle;
260  std::vector<CesiumUtility::Credit> _tileCredits;
261  LoadState _state;
263  void* _pRendererResources;
264  MoreDetailAvailable _moreDetailAvailable;
265 };
266 } // namespace CesiumRasterOverlays
Provides individual tiles for a RasterOverlay on demand.
Raster image data for a tile in a quadtree.
RasterOverlayTile(RasterOverlayTileProvider &tileProvider) noexcept
Constructs a placeholder tile for the tile provider.
void * getRendererResources() const noexcept
Returns the renderer resources that have been created for this tile.
void setRendererResources(void *pValue) noexcept
Set the renderer resources for this tile.
const CesiumGeometry::Rectangle & getRectangle() const noexcept
Returns the CesiumGeometry::Rectangle that defines the bounds of this tile in the raster overlay's pr...
glm::dvec2 getTargetScreenPixels() const noexcept
Gets the number of screen pixels in each direction that should be covered by this tile's texture.
CesiumUtility::IntrusivePointer< const CesiumGltf::ImageAsset > getImage() const noexcept
Returns the image data for the tile.
MoreDetailAvailable isMoreDetailAvailable() const noexcept
Determines if more detailed data is available for the spatial area covered by this tile.
RasterOverlayTile(RasterOverlayTileProvider &tileProvider, const glm::dvec2 &targetScreenPixels, const CesiumGeometry::Rectangle &imageryRectangle) noexcept
Creates a new instance.
RasterOverlayTileProvider & getTileProvider() noexcept
Returns the RasterOverlayTileProvider that created this instance.
const RasterOverlayTileProvider & getTileProvider() const noexcept
Returns the RasterOverlayTileProvider that created this instance.
void loadInMainThread()
Create the renderer resources for the loaded image.
const std::vector< CesiumUtility::Credit > & getCredits() const noexcept
Returns the list of Credits needed for this tile.
RasterOverlay & getOverlay() noexcept
Returns the RasterOverlay that created this instance.
CesiumUtility::IntrusivePointer< CesiumGltf::ImageAsset > getImage() noexcept
Returns the image data for the tile.
LoadState getState() const noexcept
Returns the current LoadState.
LoadState
Lifecycle states of a raster overlay tile.
@ Loading
The request for loading the image data is still pending.
@ Placeholder
Indicator for a placeholder tile.
@ Loaded
The image data has been loaded and the image has been created.
@ Failed
The image request or image creation failed.
@ Done
The rendering resources for the image data have been created.
MoreDetailAvailable
Tile availability states.
@ Unknown
It is not known whether more detailed raster tiles are available.
@ No
There are no more detailed raster tiles.
The base class for a rasterized image that can be draped over a Tileset. The image may be very,...
A smart pointer that calls addReference and releaseReference on the controlled object.
A reference-counted base class, meant to be used with IntrusivePointer.
Basic geometry classes for Cesium.
Classes for raster overlays, which allow draping massive 2D textures over a model.
Utility classes for Cesium.
A 2D rectangle.
Definition: Rectangle.h:14