Skip to content

Commit

Permalink
Add unit tests & fix some review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Withalion committed Jan 7, 2025
1 parent 409972d commit dd61bf4
Show file tree
Hide file tree
Showing 10 changed files with 974 additions and 37 deletions.
30 changes: 15 additions & 15 deletions python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11088,21 +11088,6 @@
# --
Qgis.MouseHandlesAction.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render just point cloud extends when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render extent polygons over overview point cloud"
Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options

.. versionadded:: 3.42

* ``RenderExtents``: Render just point cloud extends when zoomed out
* ``RenderOverview``: Render overview point cloud when zoomed out
* ``RenderOverviewAndExtents``: Render extent polygons over overview point cloud

"""
# --
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
# monkey patching scoped based enum
Qgis.MeshRangeLimit.NotSet.__doc__ = "User defined"
Qgis.MeshRangeLimit.MinimumMaximum.__doc__ = "Real min-max values"
Qgis.MeshRangeLimit.__doc__ = """Describes the limits used to compute mesh ranges (min/max values).
Expand Down Expand Up @@ -11131,6 +11116,21 @@
# --
Qgis.MeshRangeExtent.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render only point cloud extents when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render point cloud extents over overview point cloud"
Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options

.. versionadded:: 3.42

* ``RenderExtents``: Render only point cloud extents when zoomed out
* ``RenderOverview``: Render overview point cloud when zoomed out
* ``RenderOverviewAndExtents``: Render point cloud extents over overview point cloud

"""
# --
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudAccessType.Local.__doc__ = "Local means the source is a local file on the machine"
Qgis.PointCloudAccessType.Remote.__doc__ = "Remote means it's loaded through a protocol like HTTP"
Qgis.PointCloudAccessType.__doc__ = """The access type of the data, local is for local files and remote for remote files (over HTTP).
Expand Down
32 changes: 15 additions & 17 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10998,23 +10998,6 @@
# --
Qgis.MouseHandlesAction.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render just point cloud extends when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render extent polygons over overview point cloud"
Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options

.. versionadded:: 3.42

* ``RenderExtents``: Render just point cloud extends when zoomed out
* ``RenderOverview``: Render overview point cloud when zoomed out
* ``RenderOverviewAndExtents``: Render extent polygons over overview point cloud

"""
# --
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
# --
Qgis.MouseHandlesAction.baseClass = Qgis
# monkey patching scoped based enum
Qgis.MeshRangeLimit.NotSet.__doc__ = "User defined"
Qgis.MeshRangeLimit.MinimumMaximum.__doc__ = "Real min-max values"
Qgis.MeshRangeLimit.__doc__ = """Describes the limits used to compute mesh ranges (min/max values).
Expand Down Expand Up @@ -11043,6 +11026,21 @@
# --
Qgis.MeshRangeExtent.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render only point cloud extents when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render point cloud extents over overview point cloud"
Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options

.. versionadded:: 3.42

* ``RenderExtents``: Render only point cloud extents when zoomed out
* ``RenderOverview``: Render overview point cloud when zoomed out
* ``RenderOverviewAndExtents``: Render point cloud extents over overview point cloud

"""
# --
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudAccessType.Local.__doc__ = "Local means the source is a local file on the machine"
Qgis.PointCloudAccessType.Remote.__doc__ = "Remote means it's loaded through a protocol like HTTP"
Qgis.PointCloudAccessType.__doc__ = """The access type of the data, local is for local files and remote for remote files (over HTTP).
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgis.h
Original file line number Diff line number Diff line change
Expand Up @@ -5740,9 +5740,9 @@ class CORE_EXPORT Qgis
*/
enum class PointCloudZoomOutRenderBehavior : int
{
RenderExtents, //!< Render just point cloud extends when zoomed out
RenderExtents, //!< Render only point cloud extents when zoomed out
RenderOverview, //!< Render overview point cloud when zoomed out
RenderOverviewAndExtents //!< Render extent polygons over overview point cloud
RenderOverviewAndExtents //!< Render point cloud extents over overview point cloud
};
Q_ENUM( PointCloudZoomOutRenderBehavior )

Expand Down
5 changes: 3 additions & 2 deletions src/gui/pointcloud/qgspointcloudrendererpropertieswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ QgsPointCloudRendererPropertiesWidget::QgsPointCloudRendererPropertiesWidget( Qg
if ( !mLayer->dataProvider()->subIndexes().isEmpty() )
{
mLabelOptions->setDialogTitle( tr( "Customize label text" ) );
mLabelOptions->setText( tr( "Label format" ) );
connect( mLabels, &QCheckBox::stateChanged, this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
connect( mLabelOptions, &QgsFontButton::changed, this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
mZoomOutOptions->addItem( tr( "Show Extents Only" ), QVariant::fromValue( Qgis::PointCloudZoomOutRenderBehavior::RenderExtents ) );
Expand All @@ -146,8 +147,8 @@ QgsPointCloudRendererPropertiesWidget::QgsPointCloudRendererPropertiesWidget( Qg
mZoomOutOptions->setEnabled( false );
}

connect( mZoomOutOptions, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int currentZoomOutOption ) {
switch ( static_cast<Qgis::PointCloudZoomOutRenderBehavior>( currentZoomOutOption ) )
connect( mZoomOutOptions, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
switch ( mZoomOutOptions->currentData().value<Qgis::PointCloudZoomOutRenderBehavior>() )
{
case Qgis::PointCloudZoomOutRenderBehavior::RenderOverview:
mLabels->setEnabled( false );
Expand Down
2 changes: 1 addition & 1 deletion tests/src/app/testqgsidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ void TestQgsIdentify::identifyPointCloud()
void TestQgsIdentify::identifyVirtualPointCloud()
{
#ifdef HAVE_COPC
std::unique_ptr<QgsPointCloudLayer> pointCloud = std::make_unique<QgsPointCloudLayer>( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/virtual/sunshine-coast/combined.vpc", QStringLiteral( "pointcloud" ), QStringLiteral( "vpc" ) );
std::unique_ptr<QgsPointCloudLayer> pointCloud = std::make_unique<QgsPointCloudLayer>( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/virtual/sunshine-coast/new-combined.vpc", QStringLiteral( "pointcloud" ), QStringLiteral( "vpc" ) );
QVERIFY( pointCloud->isValid() );
pointCloud->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ) );
QCOMPARE( pointCloud->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:28356" ) );
Expand Down
61 changes: 61 additions & 0 deletions tests/src/python/test_qgspointcloudclassifiedrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,67 @@ def testRenderTriangles(self):
)
)

@unittest.skipIf(
"vpc" not in QgsProviderRegistry.instance().providerList(),
"VPC provider not available",
)
def testOverviewRender(self):
layer = QgsPointCloudLayer(
unitTestDataPath()
+ "/point_clouds/virtual/sunshine-coast/new-combined.vpc",
"test",
"vpc",
)
self.assertTrue(layer.isValid())

layer.setRenderer(layer.dataProvider().createRenderer())

layer.renderer().setPointSize(2)
layer.renderer().setPointSizeUnit(QgsUnitTypes.RenderUnit.RenderMillimeters)

mapsettings = QgsMapSettings()
mapsettings.setOutputSize(QSize(400, 400))
mapsettings.setOutputDpi(96)
mapsettings.setDestinationCrs(layer.crs())
mapsettings.setExtent(QgsRectangle(498061, 7050991, 498069, 7050999))
mapsettings.setLayers([layer])

self.assertTrue(
self.render_map_settings_check(
"classified_render_overview", "classified_render_overview", mapsettings
)
)

@unittest.skipIf(
"vpc" not in QgsProviderRegistry.instance().providerList(),
"VPC provider not available",
)
def testExtentsRender(self):
layer = QgsPointCloudLayer(
unitTestDataPath() + "/point_clouds/virtual/sunshine-coast/combined.vpc",
"test",
"vpc",
)
self.assertTrue(layer.isValid())

layer.setRenderer(layer.dataProvider().createRenderer())

layer.renderer().setPointSize(2)
layer.renderer().setPointSizeUnit(QgsUnitTypes.RenderUnit.RenderMillimeters)

mapsettings = QgsMapSettings()
mapsettings.setOutputSize(QSize(400, 400))
mapsettings.setOutputDpi(96)
mapsettings.setDestinationCrs(layer.crs())
mapsettings.setExtent(QgsRectangle(498061, 7050991, 498069, 7050999))
mapsettings.setLayers([layer])

self.assertTrue(
self.render_map_settings_check(
"classified_render_extents", "classified_render_extents", mapsettings
)
)


if __name__ == "__main__":
unittest.main()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading

0 comments on commit dd61bf4

Please sign in to comment.