QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
raster
qgsrastercontourrendererwidget.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsrastercontourrendererwidget.cpp
3
--------------------------------------
4
Date : March 2020
5
Copyright : (C) 2020 by Martin Dobias
6
Email : wonder dot sk at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#include "
qgsrastercontourrendererwidget.h
"
17
18
#include "
qgslinesymbol.h
"
19
#include "
qgsrastercontourrenderer.h
"
20
#include "
qgsrasterlayer.h
"
21
22
#include "moc_qgsrastercontourrendererwidget.cpp"
23
24
QgsRasterContourRendererWidget::QgsRasterContourRendererWidget
(
QgsRasterLayer
*layer,
const
QgsRectangle
&extent )
25
:
QgsRasterRendererWidget
( layer, extent )
26
{
27
setupUi(
this
);
28
29
mContourSymbolButton->setSymbolType(
Qgis::SymbolType::Line
);
30
mIndexContourSymbolButton->setSymbolType(
Qgis::SymbolType::Line
);
31
32
mInputBandComboBox->setLayer(
mRasterLayer
);
33
34
if
( !
mRasterLayer
)
35
{
36
return
;
37
}
38
QgsRasterDataProvider
*provider =
mRasterLayer
->dataProvider();
39
if
( !provider )
40
{
41
return
;
42
}
43
44
const
QgsRasterContourRenderer
*rcr =
dynamic_cast<
const
QgsRasterContourRenderer
*
>
(
mRasterLayer
->renderer() );
45
if
( rcr )
46
{
47
mInputBandComboBox->setBand( rcr->
inputBand
() );
48
mContourIntervalSpinBox->setValue( rcr->
contourInterval
() );
49
mIndexContourIntervalSpinBox->setValue( rcr->
contourIndexInterval
() );
50
mDownscaleSpinBox->setValue( rcr->
downscale
() );
51
if
( rcr->
contourSymbol
() )
52
mContourSymbolButton->setSymbol( rcr->
contourSymbol
()->
clone
() );
53
if
( rcr->
contourIndexSymbol
() )
54
mIndexContourSymbolButton->setSymbol( rcr->
contourIndexSymbol
()->
clone
() );
55
}
56
57
connect( mInputBandComboBox, &
QgsRasterBandComboBox::bandChanged
,
this
, &
QgsRasterRendererWidget::widgetChanged
);
58
connect( mContourIntervalSpinBox,
static_cast<
void
( QDoubleSpinBox::* )(
double
)
>
( &QDoubleSpinBox::valueChanged ),
this
, &
QgsRasterRendererWidget::widgetChanged
);
59
connect( mIndexContourIntervalSpinBox,
static_cast<
void
( QDoubleSpinBox::* )(
double
)
>
( &QDoubleSpinBox::valueChanged ),
this
, &
QgsRasterRendererWidget::widgetChanged
);
60
connect( mDownscaleSpinBox,
static_cast<
void
( QDoubleSpinBox::* )(
double
)
>
( &QDoubleSpinBox::valueChanged ),
this
, &
QgsRasterRendererWidget::widgetChanged
);
61
connect( mContourSymbolButton, &
QgsSymbolButton::changed
,
this
, &
QgsRasterRendererWidget::widgetChanged
);
62
connect( mIndexContourSymbolButton, &
QgsSymbolButton::changed
,
this
, &
QgsRasterRendererWidget::widgetChanged
);
63
}
64
65
QgsRasterRenderer
*
QgsRasterContourRendererWidget::renderer
()
66
{
67
if
( !
mRasterLayer
)
68
{
69
return
nullptr
;
70
}
71
QgsRasterDataProvider
*provider =
mRasterLayer
->dataProvider();
72
if
( !provider )
73
{
74
return
nullptr
;
75
}
76
77
QgsRasterContourRenderer
*
renderer
=
new
QgsRasterContourRenderer
( provider );
78
renderer
->setInputBand( mInputBandComboBox->currentBand() );
79
renderer
->setContourInterval( mContourIntervalSpinBox->value() );
80
renderer
->setContourIndexInterval( mIndexContourIntervalSpinBox->value() );
81
renderer
->setDownscale( mDownscaleSpinBox->value() );
82
renderer
->setContourSymbol( mContourSymbolButton->clonedSymbol<
QgsLineSymbol
>() );
83
renderer
->setContourIndexSymbol( mIndexContourSymbolButton->clonedSymbol<
QgsLineSymbol
>() );
84
return
renderer
;
85
}
Qgis::SymbolType::Line
@ Line
Line symbol.
Definition
qgis.h:673
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition
qgslinesymbol.h:30
QgsLineSymbol::clone
QgsLineSymbol * clone() const override
Returns a deep copy of this symbol.
Definition
qgslinesymbol.cpp:305
QgsRasterBandComboBox::bandChanged
void bandChanged(int band)
Emitted when the currently selected band changes.
QgsRasterContourRendererWidget::renderer
QgsRasterRenderer * renderer() override
Creates a new renderer, using the properties defined in the widget.
Definition
qgsrastercontourrendererwidget.cpp:65
QgsRasterContourRendererWidget::QgsRasterContourRendererWidget
QgsRasterContourRendererWidget(QgsRasterLayer *layer, const QgsRectangle &extent=QgsRectangle())
Constructor for QgsRasterContourRendererWidget.
Definition
qgsrastercontourrendererwidget.cpp:24
QgsRasterContourRenderer
Raster renderer that generates contours on the fly for a source raster band.
Definition
qgsrastercontourrenderer.h:31
QgsRasterContourRenderer::inputBand
int inputBand() const override
Returns the input band for the renderer, or -1 if no input band is available.
Definition
qgsrastercontourrenderer.cpp:242
QgsRasterContourRenderer::contourIndexSymbol
QgsLineSymbol * contourIndexSymbol() const
Returns the symbol of index contour lines.
Definition
qgsrastercontourrenderer.h:73
QgsRasterContourRenderer::downscale
double downscale() const
Returns by how much the renderer will scale down the request to the data provider.
Definition
qgsrastercontourrenderer.h:83
QgsRasterContourRenderer::contourSymbol
QgsLineSymbol * contourSymbol() const
Returns the symbol used for contour lines.
Definition
qgsrastercontourrenderer.h:63
QgsRasterContourRenderer::contourInterval
double contourInterval() const
Returns the interval of contour lines generation.
Definition
qgsrastercontourrenderer.h:58
QgsRasterContourRenderer::contourIndexInterval
double contourIndexInterval() const
Returns the interval of index contour lines (index contour lines are typical further apart and with a...
Definition
qgsrastercontourrenderer.h:68
QgsRasterDataProvider
Base class for raster data providers.
Definition
qgsrasterdataprovider.h:94
QgsRasterLayer
Represents a raster layer.
Definition
qgsrasterlayer.h:82
QgsRasterRendererWidget::mRasterLayer
QgsRasterLayer * mRasterLayer
Definition
qgsrasterrendererwidget.h:150
QgsRasterRendererWidget::QgsRasterRendererWidget
QgsRasterRendererWidget(QgsRasterLayer *layer, const QgsRectangle &extent)
Constructor for QgsRasterRendererWidget.
Definition
qgsrasterrendererwidget.h:51
QgsRasterRendererWidget::widgetChanged
void widgetChanged()
Emitted when something on the widget has changed.
QgsRasterRenderer
Raster renderer pipe that applies colors to a raster.
Definition
qgsrasterrenderer.h:42
QgsRectangle
A rectangle specified with double values.
Definition
qgsrectangle.h:47
QgsSymbolButton::changed
void changed()
Emitted when the symbol's settings are changed.
qgslinesymbol.h
qgsrastercontourrenderer.h
qgsrastercontourrendererwidget.h
qgsrasterlayer.h
Generated on
for QGIS API Documentation by
1.17.0