QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsmeshrenderermeshsettingswidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmeshrenderermeshsettingswidget.cpp
3 ---------------------------------------
4 begin : June 2018
5 copyright : (C) 2018 by Peter Petrik
6 email : zilolv 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
17#include <QtGlobal>
18
19#include "qgis.h"
20#include "qgsmapcanvas.h"
21#include "qgsmeshlayer.h"
22#include "qgsrasterlayer.h"
25#include "qgsmessagelog.h"
26#include "qgscolorbutton.h"
27#include "qgsdoublespinbox.h"
28
30 : QWidget( parent )
31
32{
33 setupUi( this );
34
35 mLineUnitsComboBox->setUnits( QgsUnitTypes::RenderUnitList()
40
41
43 connect( mLineWidthSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
45 connect( mLineUnitsComboBox, &QgsUnitSelectionWidget::changed,
47}
48
50{
51 mMeshType = meshType;
52 mMeshLayer = layer;
53}
54
56{
58 settings.setColor( mColorWidget->color() );
59 settings.setLineWidth( mLineWidthSpinBox->value() );
60 settings.setLineWidthUnit( mLineUnitsComboBox->unit() );
61 return settings;
62}
63
65{
66 if ( !mMeshLayer )
67 return;
68
69 const QgsMeshRendererSettings rendererSettings = mMeshLayer->rendererSettings();
70
72 switch ( mMeshType )
73 {
74 case Native:
75 settings = rendererSettings.nativeMeshSettings();
76 break;
77 case Triangular:
78 settings = rendererSettings.triangularMeshSettings();
79 break;
80 case Edge:
81 settings = rendererSettings.edgeMeshSettings();
82 break;
83 }
84 mColorWidget->setColor( settings.color() );
85 mLineWidthSpinBox->setValue( settings.lineWidth() );
86 mLineUnitsComboBox->setUnit( settings.lineWidthUnit() );
87}
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:100
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
void setLayer(QgsMeshLayer *layer, MeshType meshType)
Associates mesh layer with the widget.
void widgetChanged()
Mesh rendering settings changed.
QgsMeshRendererMeshSettingsWidget(QWidget *parent=nullptr)
A widget to hold the renderer mesh settings for a mesh layer.
QgsMeshRendererMeshSettings settings() const
Returns the mesh rendering settings (native or triangular or edge)
void syncToLayer()
Synchronizes widgets state with associated mesh layer.
Represents a mesh renderer settings for mesh object.
void setLineWidthUnit(const QgsUnitTypes::RenderUnit &lineWidthUnit)
Sets units of the width of the mesh frame.
QColor color() const
Returns color used for rendering.
QgsUnitTypes::RenderUnit lineWidthUnit() const
Returns units of the width of the mesh frame.
double lineWidth() const
Returns line width used for rendering (in millimeters)
void setLineWidth(double lineWidth)
Sets line width used for rendering (in millimeters)
void setColor(const QColor &color)
Sets color used for rendering of the mesh.
Represents all mesh renderer settings.
QgsMeshRendererMeshSettings edgeMeshSettings() const
Returns edge mesh renderer settings.
QgsMeshRendererMeshSettings nativeMeshSettings() const
Returns native mesh renderer settings.
QgsMeshRendererMeshSettings triangularMeshSettings() const
Returns triangular mesh renderer settings.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:240
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:176
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:173
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:171
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169