QGIS API Documentation 3.41.0-Master (57ec4277f5e)
Loading...
Searching...
No Matches
qgspointcloudextentrendererwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloudextentrendererwidget.cpp
3 ---------------------
4 begin : December 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19#include "moc_qgspointcloudextentrendererwidget.cpp"
21#include "qgspointcloudlayer.h"
23#include "qgsdoublevalidator.h"
24#include "qgsfillsymbol.h"
25
27
28QgsPointCloudExtentRendererWidget::QgsPointCloudExtentRendererWidget( QgsPointCloudLayer *layer, QgsStyle *style )
29 : QgsPointCloudRendererWidget( layer, style )
30{
31 setupUi( this );
32
33 mSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
34
35 if ( layer )
36 {
37 setFromRenderer( layer->renderer() );
38 }
39 else
40 {
41 mSymbolButton->setSymbol( QgsPointCloudExtentRenderer::defaultFillSymbol() );
42 }
43
44 connect( mSymbolButton, &QgsSymbolButton::changed, this, &QgsPointCloudExtentRendererWidget::emitWidgetChanged );
45}
46
47QgsPointCloudRendererWidget *QgsPointCloudExtentRendererWidget::create( QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer * )
48{
49 return new QgsPointCloudExtentRendererWidget( layer, style );
50}
51
52QgsPointCloudRenderer *QgsPointCloudExtentRendererWidget::renderer()
53{
54 if ( !mLayer )
55 {
56 return nullptr;
57 }
58
59 std::unique_ptr<QgsPointCloudExtentRenderer> renderer = std::make_unique<QgsPointCloudExtentRenderer>();
60 renderer->setFillSymbol( mSymbolButton->clonedSymbol<QgsFillSymbol>() );
61 return renderer.release();
62}
63
64void QgsPointCloudExtentRendererWidget::emitWidgetChanged()
65{
66 if ( !mBlockChangedSignal )
67 emit widgetChanged();
68}
69
70void QgsPointCloudExtentRendererWidget::setFromRenderer( const QgsPointCloudRenderer *r )
71{
72 mBlockChangedSignal = true;
73 if ( const QgsPointCloudExtentRenderer *mbcr = dynamic_cast<const QgsPointCloudExtentRenderer *>( r ) )
74 {
75 mSymbolButton->setSymbol( mbcr->fillSymbol()->clone() );
76 }
77 else
78 {
79 mSymbolButton->setSymbol( QgsPointCloudExtentRenderer::defaultFillSymbol() );
80 }
81 mBlockChangedSignal = false;
82}
83
@ Fill
Fill symbol.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A renderer for 2d visualisation of point clouds which shows the dataset's extents using a fill symbol...
static QgsFillSymbol * defaultFillSymbol()
Returns a new instance of the default fill symbol to use for showing point cloud extents.
Represents a map layer supporting display of point clouds.
QgsPointCloudRenderer * renderer()
Returns the 2D renderer for the point cloud.
Base class for point cloud 2D renderer settings widgets.
Abstract base class for 2d point cloud renderers.
void changed()
Emitted when the symbol's settings are changed.