QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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 "moc_qgsmeshrenderermeshsettingswidget.cpp"
18#include <QtGlobal>
19
20#include "qgis.h"
21#include "qgsmeshlayer.h"
22#include "qgscolorbutton.h"
23#include "qgsdoublespinbox.h"
24
26 : QWidget( parent )
27
28{
29 setupUi( this );
30
31 mLineUnitsComboBox->setUnits(
32 {
37 } );
38
39
41 connect( mLineWidthSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
43 connect( mLineUnitsComboBox, &QgsUnitSelectionWidget::changed,
45}
46
48{
49 mMeshType = meshType;
50 mMeshLayer = layer;
51}
52
54{
56 settings.setColor( mColorWidget->color() );
57 settings.setLineWidth( mLineWidthSpinBox->value() );
58 settings.setLineWidthUnit( mLineUnitsComboBox->unit() );
59 return settings;
60}
61
63{
64 if ( !mMeshLayer )
65 return;
66
67 const QgsMeshRendererSettings rendererSettings = mMeshLayer->rendererSettings();
68
70 switch ( mMeshType )
71 {
72 case Native:
73 settings = rendererSettings.nativeMeshSettings();
74 break;
75 case Triangular:
76 settings = rendererSettings.triangularMeshSettings();
77 break;
78 case Edge:
79 settings = rendererSettings.edgeMeshSettings();
80 break;
81 }
82 mColorWidget->setColor( settings.color() );
83 mLineWidthSpinBox->setValue( settings.lineWidth() );
84 mLineUnitsComboBox->setUnit( settings.lineWidthUnit() );
85}
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MetersInMapUnits
Meters value as Map units.
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.
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(Qgis::RenderUnit lineWidthUnit)
Sets units of the width of the mesh frame.
QColor color() const
Returns color used for rendering.
double lineWidth() const
Returns line width used for rendering (in millimeters)
void setLineWidth(double lineWidth)
Sets line width used for rendering (in millimeters)
Qgis::RenderUnit lineWidthUnit() const
Returns units of the width of the mesh frame.
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.
void changed()
Emitted when the selected unit is changed, or the definition of the map unit scale is changed.