Skip to content
Permalink
Browse files

Update terrain map whenever an active layer requests repaint

  • Loading branch information
wonder-sk committed Sep 15, 2017
1 parent 489a21d commit 63adb73f55014b1d51de7ad7c30f1ce1857564c6
Showing with 31 additions and 1 deletion.
  1. +24 −1 src/3d/terrain/terrain.cpp
  2. +7 −0 src/3d/terrain/terrain.h
@@ -45,7 +45,9 @@ Terrain::Terrain( int maxLevel, const Map3D &map, Qt3DCore::QNode *parent )

connect( &map, &Map3D::showTerrainBoundingBoxesChanged, this, &Terrain::onShowBoundingBoxesChanged );
connect( &map, &Map3D::showTerrainTilesInfoChanged, this, &Terrain::invalidateMapImages );
connect( &map, &Map3D::layersChanged, this, &Terrain::invalidateMapImages );
connect( &map, &Map3D::layersChanged, this, &Terrain::onLayersChanged );

connectToLayersRepaintRequest();

mTerrainToMapTransform = new QgsCoordinateTransform( map.terrainGenerator()->crs(), map.crs );

@@ -102,6 +104,27 @@ void Terrain::invalidateMapImages()
needsUpdate = true;
}

void Terrain::onLayersChanged()
{
connectToLayersRepaintRequest();
invalidateMapImages();
}

void Terrain::connectToLayersRepaintRequest()
{
Q_FOREACH ( QgsMapLayer *layer, mLayers )
{
disconnect( layer, &QgsMapLayer::repaintRequested, this, &Terrain::invalidateMapImages );
}

mLayers = map.layers();

Q_FOREACH ( QgsMapLayer *layer, mLayers )
{
connect( layer, &QgsMapLayer::repaintRequested, this, &Terrain::invalidateMapImages );
}
}


// -----------

@@ -13,6 +13,7 @@ namespace Qt3DRender
class Map3D;
class MapTextureGenerator;
class QgsCoordinateTransform;
class QgsMapLayer;
class TerrainChunkEntity;
class TerrainGenerator;
class TerrainMapUpdateJobFactory;
@@ -38,16 +39,22 @@ class Terrain : public ChunkedEntity
private slots:
void onShowBoundingBoxesChanged();
void invalidateMapImages();
void onLayersChanged();

private:

void connectToLayersRepaintRequest();

const Map3D ↦
//! picker of terrain to know height of terrain when dragging
Qt3DRender::QObjectPicker *mTerrainPicker;
MapTextureGenerator *mMapTextureGenerator;
QgsCoordinateTransform *mTerrainToMapTransform;

std::unique_ptr<TerrainMapUpdateJobFactory> mUpdateJobFactory;

//! layers that are currently being used for map rendering (and thus being watched for renderer updates)
QList<QgsMapLayer *> mLayers;
};


0 comments on commit 63adb73

Please sign in to comment.
You can’t perform that action at this time.