Skip to content
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

Virtual point clouds - Tile Labels #59726

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

Withalion
Copy link
Contributor

Description

In this PR we add the option to show labels when working with virtual point clouds. The labels even if set are only shown when the bounding boxes of point clouds are visible and if they fit inside. Users can also modify the format of the label text via QgsTextFormatButton next to it.

image

Funded by: Klimadatastyrelsen

@github-actions github-actions bot added this to the 3.42.0 milestone Dec 3, 2024
Copy link

github-actions bot commented Dec 3, 2024

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 67fc2b9)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 383bf91)

src/core/pointcloud/qgspointcloudrenderer.h Outdated Show resolved Hide resolved
src/core/pointcloud/qgspointcloudrenderer.h Outdated Show resolved Hide resolved
src/core/pointcloud/qgspointcloudrenderer.h Outdated Show resolved Hide resolved
src/core/pointcloud/qgspointcloudextentrenderer.cpp Outdated Show resolved Hide resolved
@wonder-sk wonder-sk changed the title Virtual point clouds - Tile Lables Virtual point clouds - Tile Labels Dec 5, 2024
@Withalion Withalion force-pushed the vpc-labels branch 2 times, most recently from 6245123 to 6b7b611 Compare December 5, 2024 13:34
Comment on lines +86 to +94
/**
* Renders the file name label inside extent rectangle
* \param extent QRectF in screen CRS inside which the label will be
* rendered
* \param text QString - file name without suffix
* \param context point cloud rendering context
* \since QGIS 3.42
*/
void renderLabels( const QRectF &extent, const QString &text, QgsPointCloudRenderContext &context ) const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be "renderLabel", since it renders a single label only?

Suggested change
/**
* Renders the file name label inside extent rectangle
* \param extent QRectF in screen CRS inside which the label will be
* rendered
* \param text QString - file name without suffix
* \param context point cloud rendering context
* \since QGIS 3.42
*/
void renderLabels( const QRectF &extent, const QString &text, QgsPointCloudRenderContext &context ) const;
/**
* Renders a label inside the specified extent rectangle.
*
* The label will be rendered centered horizontally and vertically inside \a extent. If the label is too large to fit
* inside this rectangle, it will not be rendered.
*
* \param extent rectangle (in painter coordinates) inside which the label will be
* rendered
* \param text label text to render
* \param context point cloud rendering context
* \since QGIS 3.42
*/
void renderLabel( const QRectF &extent, const QString &text, QgsPointCloudRenderContext &context ) const;

Comment on lines +143 to +144
QStringList labelText;
const QgsTextDocument doc = QgsTextDocument::fromTextAndFormat( labelText << text, labelTextFormat() );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QStringList labelText;
const QgsTextDocument doc = QgsTextDocument::fromTextAndFormat( labelText << text, labelTextFormat() );
const QgsTextDocument doc = QgsTextDocument::fromTextAndFormat( { text }, labelTextFormat() );

// set some better defaults for label format
QgsTextFormat textFormat = mLayer->renderer()->labelTextFormat();
QgsTextBufferSettings settings;
settings.setEnabled( true );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean it's impossible to remove the buffer?

I think instead this should be done in the QgsPointCloudLayerRenderer constructor, so that users CAN manually remove the buffer if they don't want it.

Also the format should default to QgsStyle::defaultStyle()->defaultTextFormat() (again, in QgsPointCloudLayerRenderer constructor)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants