Disable clipping planes when outside current extent

This commit is contained in:
Withalion 2025-04-02 13:34:11 +02:00 committed by Martin Dobias
parent a19271cf39
commit 705a2cade7
6 changed files with 35 additions and 0 deletions

View File

@ -212,6 +212,12 @@ Disables OpenGL clipping.
QList<QVector4D> clipPlaneEquations() const;
%Docstring
Returns list of clipping planes if clipping is enabled, otherwise an empty list.
.. versionadded:: 3.44
%End
signals:
void terrainEntityChanged();

View File

@ -212,6 +212,12 @@ Disables OpenGL clipping.
QList<QVector4D> clipPlaneEquations() const;
%Docstring
Returns list of clipping planes if clipping is enabled, otherwise an empty list.
.. versionadded:: 3.44
%End
signals:
void terrainEntityChanged();

View File

@ -297,6 +297,13 @@ class _3D_EXPORT Qgs3DMapScene : public QObject
*/
void removeSceneEntity( Qgs3DMapSceneEntity *entity ) SIP_SKIP;
/**
* Returns list of clipping planes if clipping is enabled, otherwise an empty list.
*
* \since QGIS 3.44
*/
QList<QVector4D> clipPlaneEquations() const { return mClipPlanesEquations; };
#ifndef SIP_RUN
//! Static function for returning open 3D map scenes
static std::function<QMap<QString, Qgs3DMapScene *>()> sOpenScenesFunction;

View File

@ -1180,6 +1180,15 @@ void Qgs3DMapCanvasWidget::setSceneExtent( const QgsRectangle &extent )
if ( !extent.isEmpty() )
mCanvas->mapSettings()->setExtent( extent );
if ( !mapCanvas3D()->scene()->clipPlaneEquations().isEmpty() )
{
if ( !mMapToolClippingPlanes->clippedPolygon().intersects( extent ) )
{
disableClippingPlanes();
mMessageBar->pushInfo( QString(), tr( "Cross-section has been disabled, because it's outside current extent" ) );
}
}
if ( mMapToolPrevious )
mMainCanvas->setMapTool( mMapToolPrevious );
else

View File

@ -186,3 +186,8 @@ void QgsMapToolClippingPlanes::clearHighLightedArea() const
{
mRubberBandPolygon->reset( Qgis::GeometryType::Polygon );
}
QgsGeometry QgsMapToolClippingPlanes::clippedPolygon() const
{
return mRubberBandPolygon->asGeometry();
}

View File

@ -49,6 +49,8 @@ class QgsMapToolClippingPlanes : public QgsMapTool
void clear() const;
//! Removes the tool's rubber band from canvas, which highlights the cross-section.
void clearHighLightedArea() const;
//! Returns the Geometry of clipped area
QgsGeometry clippedPolygon() const;
private:
void clearRubberBand() const;