-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
base: master
Are you sure you want to change the base?
Conversation
🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
* \note This class takes ownership of textFormat | ||
* \since QGIS 3.42 | ||
*/ | ||
void setLabelTextFormat( QgsTextFormat *textFormat SIP_TRANSFER ) { mLabelTextFormat.reset( textFormat ); } |
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.
QgsTextFormat is implicitly shared -- it's cheap to make copies of this, so should always be passed/stored by value:
void setLabelTextFormat( QgsTextFormat *textFormat SIP_TRANSFER ) { mLabelTextFormat.reset( textFormat ); } | |
void setLabelTextFormat( const QgsTextFormat & format ) { mLabelTextFormat = format; } |
* \note This function doesn't release the ownership of QgsTextFormat | ||
* \since QGIS 3.42 | ||
*/ | ||
QgsTextFormat *labelTextFormat() const { return mLabelTextFormat.get(); } |
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.
QgsTextFormat *labelTextFormat() const { return mLabelTextFormat.get(); } | |
QgsTextFormat labelTextFormat() const { return mLabelTextFormat; } |
@@ -813,6 +840,9 @@ class CORE_EXPORT QgsPointCloudRenderer | |||
bool mHorizontalTriangleFilter = false; | |||
double mHorizontalTriangleFilterThreshold = 5.0; | |||
Qgis::RenderUnit mHorizontalTriangleFilterUnit = Qgis::RenderUnit::Millimeters; | |||
|
|||
bool mShowLabels = false; | |||
std::unique_ptr<QgsTextFormat> mLabelTextFormat = nullptr; |
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.
std::unique_ptr<QgsTextFormat> mLabelTextFormat = nullptr; | |
QgsTextFormat mLabelTextFormat; |
const double textWidth = QgsTextRenderer::textWidth( context.renderContext(), labelTextFormat() ? *labelTextFormat() : QgsTextFormat(), QStringList() << text ); | ||
if ( textWidth < extent.width() ) | ||
{ | ||
QgsTextRenderer::drawText( extent, 0, Qgis::TextHorizontalAlignment::Center, QStringList() << text, context.renderContext(), labelTextFormat() ? *labelTextFormat() : QgsTextFormat(), true, Qgis::TextVerticalAlignment::VerticalCenter ); | ||
} |
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.
This is a little inefficient, because QgsTextRender::textWidth requires parsing the text and determining document metrics and then this will be repeated in ::drawText.
Try the approach used here https://github.com/qgis/QGIS/blob/master/src/app/decorations/qgsdecorationgrid.cpp#L305-L308 and https://github.com/qgis/QGIS/blob/master/src/app/decorations/qgsdecorationgrid.cpp#L374 instead. That will parse the document and calculate metrics once upfront, and then reuse in the drawing.
It's considerably faster this way if you're drawing a lot of text
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.
Okay I didn't know about this limitation, the current version implements it.
<item> | ||
<widget class="QCheckBox" name="mLabels"> | ||
<property name="text"> | ||
<string>Show Tile Labels</string> |
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.
Checkbox text should be sentence case:
<string>Show Tile Labels</string> | |
<string>Show tile labels</string> |
6245123
to
6b7b611
Compare
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.Funded by: Klimadatastyrelsen