QGIS API Documentation 3.41.0-Master (cea29feecf2)
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(
36 }
37 );
38
39
41 connect( mLineWidthSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), this, &QgsMeshRendererMeshSettingsWidget::widgetChanged );
43}
44
46{
47 mMeshType = meshType;
48 mMeshLayer = layer;
49}
50
52{
54 settings.setColor( mColorWidget->color() );
55 settings.setLineWidth( mLineWidthSpinBox->value() );
56 settings.setLineWidthUnit( mLineUnitsComboBox->unit() );
57 return settings;
58}
59
61{
62 if ( !mMeshLayer )
63 return;
64
65 const QgsMeshRendererSettings rendererSettings = mMeshLayer->rendererSettings();
66
68 switch ( mMeshType )
69 {
70 case Native:
71 settings = rendererSettings.nativeMeshSettings();
72 break;
73 case Triangular:
74 settings = rendererSettings.triangularMeshSettings();
75 break;
76 case Edge:
77 settings = rendererSettings.edgeMeshSettings();
78 break;
79 }
80 mColorWidget->setColor( settings.color() );
81 mLineWidthSpinBox->setValue( settings.lineWidth() );
82 mLineUnitsComboBox->setUnit( settings.lineWidthUnit() );
83}
@ 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.