From d1e3741eff9eda4670209a10da531a503acf08fb Mon Sep 17 00:00:00 2001 From: James Hogan Date: Wed, 4 Feb 2009 23:29:22 +0000 Subject: [PATCH] Elevation correction triggers signal to refresh DEM channels if they depend on it Lambertian shading changed to use corrected elevation --- geo/tcChannelDem.cpp | 11 +++++++---- geo/tcChannelDem.h | 4 ++-- geo/tcElevationOptimization.cpp | 3 ++- geo/tcLambertianShading.cpp | 2 +- geo/tcSrtmModel.cpp | 1 + 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/geo/tcChannelDem.cpp b/geo/tcChannelDem.cpp index c052b1e..fb5f60d 100644 --- a/geo/tcChannelDem.cpp +++ b/geo/tcChannelDem.cpp @@ -31,12 +31,15 @@ */ /// Primary constructor. -tcChannelDem::tcChannelDem(tcSrtmModel* dem, tcGeoImageData* imagery, const QString& name, const QString& description) +tcChannelDem::tcChannelDem(tcSrtmModel* dem, tcGeoImageData* imagery, const QString& name, const QString& description, bool depend) : tcChannel(name, description) , m_dem(dem) , m_imagery(imagery) { - connect(dem, SIGNAL(dataSetChanged()), this, SLOT(invalidate())); + if (depend) + { + connect(dem, SIGNAL(dataSetChanged()), this, SLOT(invalidate())); + } } /// Destructor. @@ -71,9 +74,9 @@ float tcChannelDem::altitudeAt(const tcGeo& coordinate, bool corrected, bool* ac } /// Get the texture-space normal vector at a geographical coordinate. -maths::Vector<3,float> tcChannelDem::normalAt(const tcGeo& coordinate) const +maths::Vector<3,float> tcChannelDem::normalAt(const tcGeo& coordinate, bool corrected, bool* accurate) const { - return m_dem->normalAt(coordinate); + return m_dem->normalAt(coordinate, corrected, accurate); } /// Get the lighting direction vector at a geographical coordinate. diff --git a/geo/tcChannelDem.h b/geo/tcChannelDem.h index eb04090..1984f10 100644 --- a/geo/tcChannelDem.h +++ b/geo/tcChannelDem.h @@ -42,7 +42,7 @@ class tcChannelDem : public tcChannel */ /// Primary constructor. - tcChannelDem(tcSrtmModel* dem, tcGeoImageData* imagery, const QString& name, const QString& description); + tcChannelDem(tcSrtmModel* dem, tcGeoImageData* imagery, const QString& name, const QString& description, bool depend = true); /// Destructor. virtual ~tcChannelDem(); @@ -67,7 +67,7 @@ class tcChannelDem : public tcChannel float altitudeAt(const tcGeo& coordinate, bool corrected = false, bool* accurate = 0) const; /// Get the texture-space normal vector at a geographical coordinate. - maths::Vector<3,float> normalAt(const tcGeo& coordinate) const; + maths::Vector<3,float> normalAt(const tcGeo& coordinate, bool corrected = false, bool* accurate = 0) const; /// Get the lighting direction vector at a geographical coordinate. maths::Vector<3,float> lightDirectionAt(const tcGeo& coordinate) const; diff --git a/geo/tcElevationOptimization.cpp b/geo/tcElevationOptimization.cpp index cf8e835..9767be2 100644 --- a/geo/tcElevationOptimization.cpp +++ b/geo/tcElevationOptimization.cpp @@ -42,7 +42,8 @@ tcElevationOptimization::tcElevationOptimization(tcChannel* shadowChannel, tcChannel* shadingChannel, tcSrtmModel* dem, tcGeoImageData* imagery) : tcChannelDem(dem, imagery, tr("Elevation Optimization"), - tr("Optimizes elevation using image data.")) + tr("Optimizes elevation using image data."), + false) , m_shadowChannel(shadowChannel) , m_shadingChannel(shadingChannel) , m_elevationData(0) diff --git a/geo/tcLambertianShading.cpp b/geo/tcLambertianShading.cpp index d9270b5..dcdca8c 100644 --- a/geo/tcLambertianShading.cpp +++ b/geo/tcLambertianShading.cpp @@ -90,7 +90,7 @@ tcAbstractPixelData* tcLambertianShading::loadPortion(double x1, double y1, doub tcGeo geoCoord = geoAt(coord); // Get some elevation data - maths::Vector<3,float> normal = normalAt(geoCoord); + maths::Vector<3,float> normal = normalAt(geoCoord, true); maths::Vector<3,float> light; if (m_customDirectionEnabled) { diff --git a/geo/tcSrtmModel.cpp b/geo/tcSrtmModel.cpp index 16aa4c6..1db9170 100644 --- a/geo/tcSrtmModel.cpp +++ b/geo/tcSrtmModel.cpp @@ -266,4 +266,5 @@ void tcSrtmModel::setDataSet(const QString& name) void tcSrtmModel::updateFromElevationData(const tcElevationData* elevation) { m_cache->updateFromElevationData(elevation); + emit dataSetChanged(); } -- 2.11.4.GIT