27#include <QDialogButtonBox>
31#include "moc_qgsmeshlabelingwidget.cpp"
33using namespace Qt::StringLiterals;
39 , mMessageBar( messageBar )
48 connect( mLabelModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsMeshLabelingWidget::labelModeChanged );
62 return qobject_cast<QgsLabelingGui *>( mWidget );
69 mLayer->setLabeling( mOldSettings.release() );
70 mLayer->setLabelsEnabled( mOldLabelsEnabled );
87 QgsMeshLayer *layer = qobject_cast<QgsMeshLayer *>( mapLayer );
89 if ( mLayer->labeling() )
91 mOldSettings.reset( mLayer->labeling()->clone() );
110 Mode mode = ModeNone;
111 if ( mLayer->labelsEnabled() )
115 mode = labeling->provider( mLayer )->labelFaces() ? ModeFaces : ModeVertices;
118 mLabelModeComboBox->setCurrentIndex( mLabelModeComboBox->findData( mode ) );
120 if ( QgsLabelingGui *lg = qobject_cast<QgsLabelingGui *>( mWidget ) )
128 const Mode mode =
static_cast<Mode
>( mLabelModeComboBox->currentData().toInt() );
134 mLayer->setLabelsEnabled(
true );
141 mLayer->setLabelsEnabled(
true );
147 mLayer->setLabelsEnabled(
false );
158 mLayer->triggerRepaint();
161void QgsMeshLabelingWidget::labelModeChanged(
int index )
164 mStackedWidget->removeWidget( mWidget );
172 const Mode mode =
static_cast<Mode
>( mLabelModeComboBox->currentData().toInt() );
182 mSettings = std::make_unique<QgsPalLayerSettings>( labeling->
settings() );
189 QgsSymbolWidgetContext context;
194 QgsLabelingGui *
labelingGui =
new QgsLabelingGui( mLayer, mCanvas, *mSettings,
this, geomType );
195 labelingGui->setLabelMode( QgsLabelingGui::Labels );
196 labelingGui->layout()->setContentsMargins( 0, 0, 0, 0 );
206 mStackedWidget->addWidget( mWidget );
207 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.