27#include <QDialogButtonBox>
30#include "moc_qgsmeshlabelingwidget.cpp"
36 , mMessageBar( messageBar )
42 mLabelModeComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"labelingSingle.svg" ) ), tr(
"Labels on Vertices" ), ModeVertices );
43 mLabelModeComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"labelingSingle.svg" ) ), tr(
"Labels on Faces" ), ModeFaces );
45 connect( mLabelModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsMeshLabelingWidget::labelModeChanged );
59 return qobject_cast<QgsLabelingGui *>( mWidget );
66 mLayer->setLabeling( mOldSettings.release() );
67 mLayer->setLabelsEnabled( mOldLabelsEnabled );
84 QgsMeshLayer *layer = qobject_cast<QgsMeshLayer *>( mapLayer );
86 if ( mLayer->labeling() )
88 mOldSettings.reset( mLayer->labeling()->clone() );
107 Mode mode = ModeNone;
108 if ( mLayer->labelsEnabled() )
112 mode = labeling->provider( mLayer )->labelFaces() ? ModeFaces : ModeVertices;
115 mLabelModeComboBox->setCurrentIndex( mLabelModeComboBox->findData( mode ) );
117 if ( QgsLabelingGui *lg = qobject_cast<QgsLabelingGui *>( mWidget ) )
125 const Mode mode =
static_cast<Mode
>( mLabelModeComboBox->currentData().toInt() );
131 mLayer->setLabelsEnabled(
true );
138 mLayer->setLabelsEnabled(
true );
144 mLayer->setLabelsEnabled(
false );
155 mLayer->triggerRepaint();
158void QgsMeshLabelingWidget::labelModeChanged(
int index )
161 mStackedWidget->removeWidget( mWidget );
169 const Mode mode =
static_cast<Mode
>( mLabelModeComboBox->currentData().toInt() );
179 mSettings = std::make_unique<QgsPalLayerSettings>( labeling->
settings() );
186 QgsSymbolWidgetContext context;
191 QgsLabelingGui *
labelingGui =
new QgsLabelingGui( mLayer, mCanvas, *mSettings,
this, geomType );
192 labelingGui->setLabelMode( QgsLabelingGui::Labels );
193 labelingGui->layout()->setContentsMargins( 0, 0, 0, 0 );
203 mStackedWidget->addWidget( mWidget );
204 mStackedWidget->setCurrentWidget( mWidget );
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
@ Mesh
Mesh layer. Added in QGIS 3.2.
static QgsPalLayerSettings defaultSettingsForLayer(const QgsMeshLayer *layer)
Returns the default layer settings to use for the specified mesh layer.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Basic implementation of the labeling interface for mesh layers.
QgsPalLayerSettings settings(const QString &providerId=QString()) const override
Gets associated label settings.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
A bar for displaying non-blocking messages to the user.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setDirty(bool b=true)
Flag the project as dirty (modified).
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.