-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3D] Fix reset view button #60413
base: master
Are you sure you want to change the base?
[3D] Fix reset view button #60413
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
#include "qgsapplication.h" | ||
#include "qgscolorschemeregistry.h" | ||
#include "qgscolorutils.h" | ||
#include "qgsvirtualpointcloudprovider.h" | ||
|
||
QgsPointCloudLayerElevationProperties::QgsPointCloudLayerElevationProperties( QObject *parent ) | ||
: QgsMapLayerElevationProperties( parent ) | ||
|
@@ -127,11 +128,28 @@ QgsDoubleRange QgsPointCloudLayerElevationProperties::calculateZRange( QgsMapLay | |
{ | ||
if ( pcLayer->dataProvider() ) | ||
{ | ||
double zMin = std::numeric_limits<double>::quiet_NaN(); | ||
double zMax = std::numeric_limits<double>::quiet_NaN(); | ||
const QgsPointCloudStatistics stats = pcLayer->statistics(); | ||
if ( !stats.statisticsMap().isEmpty() ) | ||
{ | ||
// try to fetch z range from provider metadata | ||
zMin = stats.minimum( QStringLiteral( "Z" ) ); | ||
zMax = stats.maximum( QStringLiteral( "Z" ) ); | ||
} | ||
// try to fetch the elevation properties from virtual point cloud metadata | ||
else if ( QgsVirtualPointCloudProvider *virtualProvider = dynamic_cast< QgsVirtualPointCloudProvider * >( pcLayer->dataProvider() ) ) | ||
{ | ||
zMin = virtualProvider->subIndexes()[0].zRange().lower(); | ||
zMax = virtualProvider->subIndexes()[0].zRange().upper(); | ||
Comment on lines
+143
to
+144
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why check against |
||
for ( QgsPointCloudSubIndex subIndex : virtualProvider->subIndexes() ) | ||
{ | ||
const QgsDoubleRange newRange = subIndex.zRange(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While not very probable, |
||
zMin = std::min( zMin, newRange.lower() ); | ||
zMax = std::max( zMax, newRange.upper() ); | ||
} | ||
} | ||
|
||
// try to fetch z range from provider metadata | ||
const double zMin = stats.minimum( QStringLiteral( "Z" ) ); | ||
const double zMax = stats.maximum( QStringLiteral( "Z" ) ); | ||
if ( !std::isnan( zMin ) && !std::isnan( zMax ) ) | ||
{ | ||
return QgsDoubleRange( zMin * mZScale + mZOffset, zMax * mZScale + mZOffset ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not calling
setCameraPose( camPose );
and add a call toupdateCameraFromPose()
in it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setCameraPose( camPose )
already callsupdateCameraFromPose()
, however the issue was that thesetCameraPose( camPose )
would return early ascamPose
was the same and the near & far plane would not be recalculated according to layers