QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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 <QtGlobal>
18
19#include "qgis.h"
20#include "qgsmeshlayer.h"
21#include "qgscolorbutton.h"
22#include "qgsdoublespinbox.h"
23
25 : QWidget( parent )
26
27{
28 setupUi( this );
29
30 mLineUnitsComboBox->setUnits(
31 {
36 } );
37
38
40 connect( mLineWidthSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
42 connect( mLineUnitsComboBox, &QgsUnitSelectionWidget::changed,
44}
45
47{
48 mMeshType = meshType;
49 mMeshLayer = layer;
50}
51
53{
55 settings.setColor( mColorWidget->color() );
56 settings.setLineWidth( mLineWidthSpinBox->value() );
57 settings.setLineWidthUnit( mLineUnitsComboBox->unit() );
58 return settings;
59}
60
62{
63 if ( !mMeshLayer )
64 return;
65
66 const QgsMeshRendererSettings rendererSettings = mMeshLayer->rendererSettings();
67
69 switch ( mMeshType )
70 {
71 case Native:
72 settings = rendererSettings.nativeMeshSettings();
73 break;
74 case Triangular:
75 settings = rendererSettings.triangularMeshSettings();
76 break;
77 case Edge:
78 settings = rendererSettings.edgeMeshSettings();
79 break;
80 }
81 mColorWidget->setColor( settings.color() );
82 mLineWidthSpinBox->setValue( settings.lineWidth() );
83 mLineUnitsComboBox->setUnit( settings.lineWidthUnit() );
84}
@ 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.