QGIS API Documentation 3.99.0-Master (26c88405ac0)
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
21#include "qgsdoublevalidator.h"
22#include "qgsfillsymbol.h"
24#include "qgspointcloudlayer.h"
25
26#include "moc_qgspointcloudextentrendererwidget.cpp"
27
29
30QgsPointCloudExtentRendererWidget::QgsPointCloudExtentRendererWidget( QgsPointCloudLayer *layer, QgsStyle *style )
31 : QgsPointCloudRendererWidget( layer, style )
32{
33 setupUi( this );
34
35 mSymbolButton->setSymbolType( Qgis::SymbolType::Fill );
36
37 if ( layer )
38 {
39 setFromRenderer( layer->renderer() );
40 }
41 else
42 {
43 mSymbolButton->setSymbol( QgsPointCloudExtentRenderer::defaultFillSymbol() );
44 }
45
46 connect( mSymbolButton, &QgsSymbolButton::changed, this, &QgsPointCloudExtentRendererWidget::emitWidgetChanged );
47}
48
49QgsPointCloudRendererWidget *QgsPointCloudExtentRendererWidget::create( QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer * )
50{
51 return new QgsPointCloudExtentRendererWidget( layer, style );
52}
53
54QgsPointCloudRenderer *QgsPointCloudExtentRendererWidget::renderer()
55{
56 if ( !mLayer )
57 {
58 return nullptr;
59 }
60
61 auto renderer = std::make_unique<QgsPointCloudExtentRenderer>();
62 renderer->setFillSymbol( mSymbolButton->clonedSymbol<QgsFillSymbol>() );
63 return renderer.release();
64}
65
66void QgsPointCloudExtentRendererWidget::emitWidgetChanged()
67{
68 if ( !mBlockChangedSignal )
69 emit widgetChanged();
70}
71
72void QgsPointCloudExtentRendererWidget::setFromRenderer( const QgsPointCloudRenderer *r )
73{
74 mBlockChangedSignal = true;
75 if ( const QgsPointCloudExtentRenderer *mbcr = dynamic_cast<const QgsPointCloudExtentRenderer *>( r ) )
76 {
77 mSymbolButton->setSymbol( mbcr->fillSymbol()->clone() );
78 }
79 else
80 {
81 mSymbolButton->setSymbol( QgsPointCloudExtentRenderer::defaultFillSymbol() );
82 }
83 mBlockChangedSignal = false;
84}
85
@ Fill
Fill symbol.
Definition qgis.h:613
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.
A database of saved style entities, including symbols, color ramps, text formats and others.
Definition qgsstyle.h:88
void changed()
Emitted when the symbol's settings are changed.