QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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"
24 #include "qgsrasterminmaxorigin.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 }
qgscolorbutton.h
qgsrasterminmaxorigin.h
qgsmeshrenderermeshsettingswidget.h
qgsrasterlayer.h
qgsdoublespinbox.h
QgsMeshRendererSettings
Represents all mesh renderer settings.
Definition: qgsmeshrenderersettings.h:590
qgsmapcanvas.h
QgsMeshRendererMeshSettings
Represents a mesh renderer settings for mesh object.
Definition: qgsmeshrenderersettings.h:41
QgsMeshRendererMeshSettings::color
QColor color() const
Returns color used for rendering.
Definition: qgsmeshrenderersettings.cpp:42
QgsMeshRendererMeshSettingsWidget::Triangular
@ Triangular
Definition: qgsmeshrenderermeshsettingswidget.h:46
QgsMeshRendererMeshSettings::lineWidthUnit
QgsUnitTypes::RenderUnit lineWidthUnit() const
Returns units of the width of the mesh frame.
Definition: qgsmeshrenderersettings.cpp:52
QgsMeshRendererMeshSettings::lineWidth
double lineWidth() const
Returns line width used for rendering (in millimeters)
Definition: qgsmeshrenderersettings.cpp:32
QgsUnitTypes::RenderPoints
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:173
QgsMeshRendererMeshSettings::setColor
void setColor(const QColor &color)
Sets color used for rendering of the mesh.
Definition: qgsmeshrenderersettings.cpp:47
QgsMeshRendererMeshSettingsWidget::syncToLayer
void syncToLayer()
Synchronizes widgets state with associated mesh layer.
Definition: qgsmeshrenderermeshsettingswidget.cpp:64
qgis.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsColorButton::colorChanged
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
QgsMeshLayer::rendererSettings
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
Definition: qgsmeshlayer.cpp:344
QgsMeshRendererMeshSettings::setLineWidth
void setLineWidth(double lineWidth)
Sets line width used for rendering (in millimeters)
Definition: qgsmeshrenderersettings.cpp:37
QgsMeshRendererMeshSettingsWidget::setLayer
void setLayer(QgsMeshLayer *layer, MeshType meshType)
Associates mesh layer with the widget.
Definition: qgsmeshrenderermeshsettingswidget.cpp:49
QgsMeshRendererMeshSettingsWidget::widgetChanged
void widgetChanged()
Mesh rendering settings changed.
QgsMeshLayer
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:98
QgsUnitSelectionWidget::changed
void changed()
QgsMeshRendererMeshSettingsWidget::QgsMeshRendererMeshSettingsWidget
QgsMeshRendererMeshSettingsWidget(QWidget *parent=nullptr)
A widget to hold the renderer mesh settings for a mesh layer.
Definition: qgsmeshrenderermeshsettingswidget.cpp:29
QgsMeshRendererSettings::nativeMeshSettings
QgsMeshRendererMeshSettings nativeMeshSettings() const
Returns native mesh renderer settings.
Definition: qgsmeshrenderersettings.h:602
QgsMeshRendererSettings::triangularMeshSettings
QgsMeshRendererMeshSettings triangularMeshSettings() const
Returns triangular mesh renderer settings.
Definition: qgsmeshrenderersettings.h:607
QgsMeshRendererMeshSettings::setLineWidthUnit
void setLineWidthUnit(const QgsUnitTypes::RenderUnit &lineWidthUnit)
Sets units of the width of the mesh frame.
Definition: qgsmeshrenderersettings.cpp:57
QgsUnitTypes::RenderPixels
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:171
qgsmeshlayer.h
QgsMeshRendererSettings::edgeMeshSettings
QgsMeshRendererMeshSettings edgeMeshSettings() const
Returns edge mesh renderer settings.
Definition: qgsmeshrenderersettings.h:615
qgsrasterminmaxwidget.h
QgsMeshRendererMeshSettingsWidget::MeshType
MeshType
Definition: qgsmeshrenderermeshsettingswidget.h:43
QgsUnitTypes::RenderMetersInMapUnits
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:176
QgsMeshRendererMeshSettingsWidget::Edge
@ Edge
Definition: qgsmeshrenderermeshsettingswidget.h:47
QgsMeshRendererMeshSettingsWidget::settings
QgsMeshRendererMeshSettings settings() const
Returns the mesh rendering settings (native or triangular or edge)
Definition: qgsmeshrenderermeshsettingswidget.cpp:55
QgsUnitTypes::RenderUnitList
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:240
QgsMeshRendererMeshSettingsWidget::Native
@ Native
Definition: qgsmeshrenderermeshsettingswidget.h:45
qgsmessagelog.h