QGIS API Documentation 3.43.0-Master (3ee7834ace6)
qgssymbollayerwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgssymbollayerwidget.cpp - symbol layer widgets
3
4 ---------------------
5 begin : November 2009
6 copyright : (C) 2009 by Martin Dobias
7 email : wonder dot sk at gmail dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
18#include "moc_qgssymbollayerwidget.cpp"
19
20#include "qgslinesymbollayer.h"
22#include "qgsfillsymbollayer.h"
25
26#include "characterwidget.h"
27#include "qgsdashspacedialog.h"
28#include "qgssvgcache.h"
29#include "qgssymbollayerutils.h"
30#include "qgscolorramp.h"
31#include "qgscolorrampbutton.h"
32#include "qgsfontutils.h"
33#include "qgsproperty.h"
34#include "qgsmapcanvas.h"
35#include "qgsapplication.h"
36#include "qgsvectorlayer.h"
40#include "qgsauxiliarystorage.h"
41#include "qgsimagecache.h"
42#include "qgslinesymbol.h"
43#include "qgsmarkersymbol.h"
44#include "qgsfillsymbol.h"
45#include "qgsiconutils.h"
48
49#include <QAbstractButton>
50#include <QButtonGroup>
51#include <QColorDialog>
52#include <QCursor>
53#include <QDir>
54#include <QFileDialog>
55#include <QPainter>
56#include <QStandardItemModel>
57#include <QSvgRenderer>
58#include <QMessageBox>
59#include <QMenu>
60#include <QAction>
61#include <QInputDialog>
62#include <QBuffer>
63#include <QRegularExpression>
64#include <QMovie>
65
67{
68 if ( auto *lExpressionContext = mContext.expressionContext() )
69 return *lExpressionContext;
70
72
74 if ( const QgsSymbolLayer *symbolLayer = const_cast<QgsSymbolLayerWidget *>( this )->symbolLayer() )
75 {
76 //cheat a bit - set the symbol color variable to match the symbol layer's color (when we should really be using the *symbols*
77 //color, but that's not accessible here). 99% of the time these will be the same anyway
79 }
80 expContext << symbolScope;
86 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_count" ), 1, true ) );
87 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_index" ), 1, true ) );
88 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_row" ), 1, true ) );
89 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_column" ), 1, true ) );
90 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_frame" ), 1, true ) );
91
92 // additional scopes
93 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
94 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
95 {
96 expContext.appendScope( new QgsExpressionContextScope( scope ) );
97 }
98
99 //TODO - show actual value
100 expContext.setOriginalValueVariable( QVariant() );
101
102 QStringList highlights;
108 << QStringLiteral( "symbol_layer_count" ) << QStringLiteral( "symbol_layer_index" ) << QStringLiteral( "symbol_frame" );
109
110
111 if ( expContext.hasVariable( QStringLiteral( "zoom_level" ) ) )
112 {
113 highlights << QStringLiteral( "zoom_level" );
114 }
115 if ( expContext.hasVariable( QStringLiteral( "vector_tile_zoom" ) ) )
116 {
117 highlights << QStringLiteral( "vector_tile_zoom" );
118 }
119
120 expContext.setHighlightedVariables( highlights );
121
122 return expContext;
123}
124
126{
127 mContext = context;
128 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
129 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
130 {
131 unitWidget->setMapCanvas( mContext.mapCanvas() );
132 }
133}
134
136{
137 return mContext;
138}
139
141{
142 button->init( static_cast<int>( key ), symbolLayer()->dataDefinedProperties(), QgsSymbolLayer::propertyDefinitions(), mVectorLayer, true );
144 connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolLayerWidget::createAuxiliaryField );
145
147}
148
149void QgsSymbolLayerWidget::createAuxiliaryField()
150{
151 // try to create an auxiliary layer if not yet created
152 if ( !mVectorLayer->auxiliaryLayer() )
153 {
154 QgsNewAuxiliaryLayerDialog dlg( mVectorLayer, this );
155 dlg.exec();
156 }
157
158 // return if still not exists
159 if ( !mVectorLayer->auxiliaryLayer() )
160 return;
161
162 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
163 QgsSymbolLayer::Property key = static_cast<QgsSymbolLayer::Property>( button->propertyKey() );
164 QgsPropertyDefinition def = QgsSymbolLayer::propertyDefinitions()[static_cast<int>( key )];
165
166 // create property in auxiliary storage if necessary
167 if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
168 {
169 QgsNewAuxiliaryFieldDialog dlg( def, mVectorLayer, true, this );
170 if ( dlg.exec() == QDialog::Accepted )
171 def = dlg.propertyDefinition();
172 }
173
174 // return if still not exist
175 if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
176 return;
177
178 // update property with join field name from auxiliary storage
179 QgsProperty property = button->toProperty();
180 property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
181 property.setActive( true );
182 button->updateFieldLists();
183 button->setToProperty( property );
184 symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
185
186 emit changed();
187}
188
190{
191 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
192 const QgsSymbolLayer::Property key = static_cast<QgsSymbolLayer::Property>( button->propertyKey() );
193 symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
194 emit changed();
195}
196
198 : QgsSymbolLayerWidget( parent, vl )
199{
200 mLayer = nullptr;
201
202 setupUi( this );
203 connect( mCustomCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged );
204 connect( mChangePatternButton, &QPushButton::clicked, this, &QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked );
205 connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed );
206 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed );
207 connect( mDashPatternUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed );
208 connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
209 connect( mPatternOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::patternOffsetUnitChanged );
210 connect( mCheckAlignDash, &QCheckBox::toggled, this, [=] {
211 mCheckDashCorners->setEnabled( mCheckAlignDash->isChecked() );
212 if ( !mCheckAlignDash->isChecked() )
213 mCheckDashCorners->setChecked( false );
214
215 if ( mLayer )
216 {
217 mLayer->setAlignDashPattern( mCheckAlignDash->isChecked() );
218 emit changed();
219 }
220 } );
221 connect( mCheckDashCorners, &QCheckBox::toggled, this, [=] {
222 if ( mLayer )
223 {
224 mLayer->setTweakDashPatternOnCorners( mCheckDashCorners->isChecked() );
225 emit changed();
226 }
227 } );
228
235
236 btnChangeColor->setAllowOpacity( true );
237 btnChangeColor->setColorDialogTitle( tr( "Select Line Color" ) );
238 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
239
240 mColorDDBtn->registerLinkedWidget( btnChangeColor );
241
242 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
243 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
244 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
245 connect( mRingFilterComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( int ) {
246 if ( mLayer )
247 {
248 mLayer->setRingFilter( static_cast<QgsLineSymbolLayer::RenderRingFilter>( mRingFilterComboBox->currentData().toInt() ) );
249 emit changed();
250 }
251 } );
252
253 spinOffset->setClearValue( 0.0 );
254 spinPatternOffset->setClearValue( 0.0 );
255
256 mTrimStartDistanceSpin->setClearValue( 0.0 );
257 mTrimDistanceEndSpin->setClearValue( 0.0 );
258
259 //make a temporary symbol for the size assistant preview
260 mAssistantPreviewSymbol.reset( new QgsLineSymbol() );
261
262 if ( vectorLayer() )
263 mPenWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
264
265 connect( spinWidth, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::penWidthChanged );
266 connect( btnChangeColor, &QgsColorButton::colorChanged, this, &QgsSimpleLineSymbolLayerWidget::colorChanged );
267 connect( cboPenStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
268 connect( spinOffset, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::offsetChanged );
269 connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
270 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
271 connect( spinPatternOffset, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::patternOffsetChanged );
272
273 connect( mTrimStartDistanceSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) {
274 if ( !mLayer )
275 return;
276
278 emit changed();
279 } );
280 connect( mTrimDistanceStartUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
281 if ( !mLayer )
282 return;
283
284 mLayer->setTrimDistanceStartUnit( mTrimDistanceStartUnitWidget->unit() );
285 mLayer->setTrimDistanceStartMapUnitScale( mTrimDistanceStartUnitWidget->getMapUnitScale() );
286 emit changed();
287 } );
288 connect( mTrimDistanceEndSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) {
289 if ( !mLayer )
290 return;
291
292 mLayer->setTrimDistanceEnd( value );
293 emit changed();
294 } );
295 connect( mTrimDistanceEndUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
296 if ( !mLayer )
297 return;
298
299 mLayer->setTrimDistanceEndUnit( mTrimDistanceEndUnitWidget->unit() );
300 mLayer->setTrimDistanceEndMapUnitScale( mTrimDistanceEndUnitWidget->getMapUnitScale() );
301 emit changed();
302 } );
303
304
306
307 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol );
308}
309
311
312void QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol()
313{
314 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
315 {
316 mAssistantPreviewSymbol->deleteSymbolLayer( i );
317 }
318 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
320 if ( ddWidth )
321 mAssistantPreviewSymbol->setDataDefinedWidth( ddWidth );
322}
323
324
326{
327 if ( !layer || layer->layerType() != QLatin1String( "SimpleLine" ) )
328 return;
329
330 // layer type is correct, we can do the cast
331 mLayer = static_cast<QgsSimpleLineSymbolLayer *>( layer );
332
333 // set units
334 mPenWidthUnitWidget->blockSignals( true );
335 mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
336 mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
337 mPenWidthUnitWidget->blockSignals( false );
338 mOffsetUnitWidget->blockSignals( true );
339 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
340 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
341 mOffsetUnitWidget->blockSignals( false );
342 mDashPatternUnitWidget->blockSignals( true );
343 mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
344 mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
345 mDashPatternUnitWidget->blockSignals( false );
346
347 whileBlocking( mPatternOffsetUnitWidget )->setUnit( mLayer->dashPatternOffsetUnit() );
348 whileBlocking( mPatternOffsetUnitWidget )->setMapUnitScale( mLayer->dashPatternOffsetMapUnitScale() );
349 whileBlocking( mTrimDistanceStartUnitWidget )->setUnit( mLayer->trimDistanceStartUnit() );
350 whileBlocking( mTrimDistanceStartUnitWidget )->setMapUnitScale( mLayer->trimDistanceStartMapUnitScale() );
351 whileBlocking( mTrimDistanceEndUnitWidget )->setUnit( mLayer->trimDistanceEndUnit() );
352 whileBlocking( mTrimDistanceEndUnitWidget )->setMapUnitScale( mLayer->trimDistanceEndMapUnitScale() );
353
354 // set values
355 spinWidth->blockSignals( true );
356 spinWidth->setValue( mLayer->width() );
357 spinWidth->blockSignals( false );
358 btnChangeColor->blockSignals( true );
359 btnChangeColor->setColor( mLayer->color() );
360 btnChangeColor->blockSignals( false );
361 spinOffset->blockSignals( true );
362 spinOffset->setValue( mLayer->offset() );
363 spinOffset->blockSignals( false );
364 cboPenStyle->blockSignals( true );
365 cboJoinStyle->blockSignals( true );
366 cboCapStyle->blockSignals( true );
367 cboPenStyle->setPenStyle( mLayer->penStyle() );
368 cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
369 cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
370 cboPenStyle->blockSignals( false );
371 cboJoinStyle->blockSignals( false );
372 cboCapStyle->blockSignals( false );
373 whileBlocking( spinPatternOffset )->setValue( mLayer->dashPatternOffset() );
374 whileBlocking( mTrimStartDistanceSpin )->setValue( mLayer->trimDistanceStart() );
375 whileBlocking( mTrimDistanceEndSpin )->setValue( mLayer->trimDistanceEnd() );
376
377 //use a custom dash pattern?
378 const bool useCustomDashPattern = mLayer->useCustomDashPattern();
379 mChangePatternButton->setEnabled( useCustomDashPattern );
380 label_3->setEnabled( !useCustomDashPattern );
381 cboPenStyle->setEnabled( !useCustomDashPattern );
382 mCustomCheckBox->blockSignals( true );
383 mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
384 mCustomCheckBox->blockSignals( false );
385
386 //make sure height of custom dash button looks good under different platforms
387 const QSize size = mChangePatternButton->minimumSizeHint();
388 const int fontHeight = static_cast<int>( Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 1.4 );
389 mChangePatternButton->setMinimumSize( QSize( size.width(), std::max( size.height(), fontHeight ) ) );
390
391 //draw inside polygon?
392 const bool drawInsidePolygon = mLayer->drawInsidePolygon();
393 whileBlocking( mDrawInsideCheckBox )->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
394
395 whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
396
397 whileBlocking( mCheckAlignDash )->setChecked( mLayer->alignDashPattern() );
398 mCheckDashCorners->setEnabled( mLayer->alignDashPattern() );
399 whileBlocking( mCheckDashCorners )->setChecked( mLayer->tweakDashPatternOnCorners() && mLayer->alignDashPattern() );
400
402
413
414 updateAssistantSymbol();
415}
416
421
423{
425
426 switch ( context.symbolType() )
427 {
430 //these settings only have an effect when the symbol layers is part of a fill symbol
431 mDrawInsideCheckBox->hide();
432 mRingFilterComboBox->hide();
433 mRingsLabel->hide();
434 break;
435
438 break;
439 }
440}
441
442void QgsSimpleLineSymbolLayerWidget::penWidthChanged()
443{
444 mLayer->setWidth( spinWidth->value() );
446 emit changed();
447}
448
449void QgsSimpleLineSymbolLayerWidget::colorChanged( const QColor &color )
450{
451 mLayer->setColor( color );
452 emit changed();
453}
454
455void QgsSimpleLineSymbolLayerWidget::penStyleChanged()
456{
457 mLayer->setPenStyle( cboPenStyle->penStyle() );
458 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
459 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
461 emit changed();
462}
463
464void QgsSimpleLineSymbolLayerWidget::offsetChanged()
465{
466 mLayer->setOffset( spinOffset->value() );
468 emit changed();
469}
470
471void QgsSimpleLineSymbolLayerWidget::patternOffsetChanged()
472{
473 mLayer->setDashPatternOffset( spinPatternOffset->value() );
475 emit changed();
476}
477
478void QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged( int state )
479{
480 const bool checked = ( state == Qt::Checked );
481 mChangePatternButton->setEnabled( checked );
482 label_3->setEnabled( !checked );
483 cboPenStyle->setEnabled( !checked );
484
486 emit changed();
487}
488
489void QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked()
490{
492 if ( panel && panel->dockMode() )
493 {
495 widget->setPanelTitle( tr( "Custom Dash Pattern" ) );
496 widget->setUnit( mDashPatternUnitWidget->unit() );
497 connect( widget, &QgsPanelWidget::widgetChanged, this, [this, widget]() {
500 } );
502 panel->openPanel( widget );
503 return;
504 }
505
507 d.setUnit( mDashPatternUnitWidget->unit() );
508 if ( d.exec() == QDialog::Accepted )
509 {
510 mLayer->setCustomDashVector( d.dashDotVector() );
512 emit changed();
513 }
514}
515
516void QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed()
517{
518 if ( mLayer )
519 {
520 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
521 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
523 emit changed();
524 }
525}
526
527void QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed()
528{
529 if ( mLayer )
530 {
531 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
532 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
533 emit changed();
534 }
535}
536
537void QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed()
538{
539 if ( mLayer )
540 {
541 mLayer->setCustomDashPatternUnit( mDashPatternUnitWidget->unit() );
542 mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
544 emit changed();
545 }
546}
547
548void QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
549{
550 const bool checked = ( state == Qt::Checked );
551 mLayer->setDrawInsidePolygon( checked );
552 emit changed();
553}
554
555void QgsSimpleLineSymbolLayerWidget::patternOffsetUnitChanged()
556{
557 if ( mLayer )
558 {
559 mLayer->setDashPatternOffsetUnit( mPatternOffsetUnitWidget->unit() );
560 mLayer->setDashPatternOffsetMapUnitScale( mPatternOffsetUnitWidget->getMapUnitScale() );
562 emit changed();
563 }
564}
565
567{
568 if ( !mLayer )
569 {
570 return;
571 }
572 std::unique_ptr<QgsSimpleLineSymbolLayer> layerCopy( mLayer->clone() );
573 if ( !layerCopy )
574 {
575 return;
576 }
577 const QColor color = qApp->palette().color( QPalette::WindowText );
578 layerCopy->setColor( color );
579 // reset offset, we don't want to show that in the preview
580 layerCopy->setOffset( 0 );
581 layerCopy->setUseCustomDashPattern( true );
582
583 QSize currentIconSize;
584 //icon size is button size with a small margin
585#ifdef Q_OS_WIN
586 currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 6 );
587#else
588 currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 12 );
589#endif
590
591 if ( !currentIconSize.isValid() || currentIconSize.width() <= 0 || currentIconSize.height() <= 0 )
592 {
593 return;
594 }
595
596 //create an icon pixmap
597 const std::unique_ptr<QgsLineSymbol> previewSymbol = std::make_unique<QgsLineSymbol>( QgsSymbolLayerList() << layerCopy.release() );
598 const QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( previewSymbol.get(), currentIconSize, 0, nullptr, QgsScreenProperties( screen() ) );
599 mChangePatternButton->setIconSize( currentIconSize );
600 mChangePatternButton->setIcon( icon );
601
602 // set tooltip
603 // create very large preview image
604 const int width = static_cast<int>( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 23 );
605 const int height = static_cast<int>( width / 1.61803398875 ); // golden ratio
606
607 const QPixmap pm = QgsSymbolLayerUtils::symbolPreviewPixmap( previewSymbol.get(), QSize( width, height ), height / 20, nullptr, false, nullptr, nullptr, QgsScreenProperties( screen() ) );
608 QByteArray data;
609 QBuffer buffer( &data );
610 pm.save( &buffer, "PNG", 100 );
611 mChangePatternButton->setToolTip( QStringLiteral( "<img src='data:image/png;base64, %3' width=\"%4\">" ).arg( QString( data.toBase64() ) ).arg( width ) );
612}
613
615{
616 QgsSymbolLayerWidget::resizeEvent( event );
617 // redraw custom dash pattern icon -- the button size has changed
619}
620
621
623
624
626 : QgsSymbolLayerWidget( parent, vl )
627{
628 mLayer = nullptr;
629
630 setupUi( this );
631
632 mHorizontalAnchorComboBox->addItem( tr( "Left" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Left ) );
633 mHorizontalAnchorComboBox->addItem( tr( "Horizontal Center" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Center ) );
634 mHorizontalAnchorComboBox->addItem( tr( "Right" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Right ) );
635
636 mVerticalAnchorComboBox->addItem( tr( "Top" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Top ) );
637 mVerticalAnchorComboBox->addItem( tr( "Vertical Center" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Center ) );
638 mVerticalAnchorComboBox->addItem( tr( "Bottom" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Bottom ) );
639
640 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
641 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
642 connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
643 connect( mStrokeStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
644 connect( mStrokeWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
645 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
646 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
650
651 btnChangeColorFill->setAllowOpacity( true );
652 btnChangeColorFill->setColorDialogTitle( tr( "Select Fill Color" ) );
653 btnChangeColorFill->setContext( QStringLiteral( "symbology" ) );
654 btnChangeColorFill->setShowNoColor( true );
655 btnChangeColorFill->setNoColorString( tr( "Transparent Fill" ) );
656 btnChangeColorStroke->setAllowOpacity( true );
657 btnChangeColorStroke->setColorDialogTitle( tr( "Select Stroke Color" ) );
658 btnChangeColorStroke->setContext( QStringLiteral( "symbology" ) );
659 btnChangeColorStroke->setShowNoColor( true );
660 btnChangeColorStroke->setNoColorString( tr( "Transparent Stroke" ) );
661
662 mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
663 mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
664
665 spinOffsetX->setClearValue( 0.0 );
666 spinOffsetY->setClearValue( 0.0 );
667 spinAngle->setClearValue( 0.0 );
668
669 //make a temporary symbol for the size assistant preview
670 mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
671
672 if ( vectorLayer() )
673 mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
674
675 int size = lstNames->iconSize().width();
676
677 size = std::max( 30, static_cast<int>( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) );
678
679 lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
680 lstNames->setIconSize( QSize( size, size ) );
681
682 const double markerSize = size * 0.8;
684 for ( const Qgis::MarkerShape shape : shapes )
685 {
686 QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
688 lyr->setColor( QColor( 200, 200, 200 ) );
689 lyr->setStrokeColor( QColor( 0, 0, 0 ) );
690 const QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, Qgis::RenderUnit::Pixels, QSize( size, size ), QgsMapUnitScale(), Qgis::SymbolType::Hybrid, nullptr, QgsScreenProperties( screen() ) );
691 QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
692 item->setData( Qt::UserRole, static_cast<int>( shape ) );
693 item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
694 delete lyr;
695 }
696 // show at least 3 rows
697 lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
698
699 connect( lstNames, &QListWidget::currentRowChanged, this, &QgsSimpleMarkerSymbolLayerWidget::setShape );
702 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged );
703 connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::penCapStyleChanged );
704 connect( spinSize, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setSize );
705 connect( spinAngle, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setAngle );
706 connect( spinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
707 connect( spinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
708 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol );
709}
710
712
714{
715 if ( layer->layerType() != QLatin1String( "SimpleMarker" ) )
716 return;
717
718 // layer type is correct, we can do the cast
719 mLayer = static_cast<QgsSimpleMarkerSymbolLayer *>( layer );
720
721 // set values
722 const Qgis::MarkerShape shape = mLayer->shape();
723 for ( int i = 0; i < lstNames->count(); ++i )
724 {
725 if ( static_cast<Qgis::MarkerShape>( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
726 {
727 lstNames->setCurrentRow( i );
728 break;
729 }
730 }
731 btnChangeColorStroke->blockSignals( true );
732 btnChangeColorStroke->setColor( mLayer->strokeColor() );
733 btnChangeColorStroke->blockSignals( false );
734 btnChangeColorFill->blockSignals( true );
735 btnChangeColorFill->setColor( mLayer->fillColor() );
736 btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
737 btnChangeColorFill->blockSignals( false );
738 spinSize->blockSignals( true );
739 spinSize->setValue( mLayer->size() );
740 spinSize->blockSignals( false );
741 spinAngle->blockSignals( true );
742 spinAngle->setValue( mLayer->angle() );
743 spinAngle->blockSignals( false );
744 mStrokeStyleComboBox->blockSignals( true );
745 mStrokeStyleComboBox->setPenStyle( mLayer->strokeStyle() );
746 mStrokeStyleComboBox->blockSignals( false );
747 mStrokeWidthSpinBox->blockSignals( true );
748 mStrokeWidthSpinBox->setValue( mLayer->strokeWidth() );
749 mStrokeWidthSpinBox->blockSignals( false );
750 cboJoinStyle->blockSignals( true );
751 cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
752 cboJoinStyle->blockSignals( false );
753 cboCapStyle->blockSignals( true );
754 cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
755 cboCapStyle->blockSignals( false );
756
757 // without blocking signals the value gets changed because of slot setOffset()
758 spinOffsetX->blockSignals( true );
759 spinOffsetX->setValue( mLayer->offset().x() );
760 spinOffsetX->blockSignals( false );
761 spinOffsetY->blockSignals( true );
762 spinOffsetY->setValue( mLayer->offset().y() );
763 spinOffsetY->blockSignals( false );
764
765 mSizeUnitWidget->blockSignals( true );
766 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
767 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
768 mSizeUnitWidget->blockSignals( false );
769 mOffsetUnitWidget->blockSignals( true );
770 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
771 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
772 mOffsetUnitWidget->blockSignals( false );
773 mStrokeWidthUnitWidget->blockSignals( true );
774 mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
775 mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
776 mStrokeWidthUnitWidget->blockSignals( false );
777
778 //anchor points
779 mHorizontalAnchorComboBox->blockSignals( true );
780 mVerticalAnchorComboBox->blockSignals( true );
781 mHorizontalAnchorComboBox->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue( mLayer->horizontalAnchorPoint() ) ) );
782 mVerticalAnchorComboBox->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue( mLayer->verticalAnchorPoint() ) ) );
783 mHorizontalAnchorComboBox->blockSignals( false );
784 mVerticalAnchorComboBox->blockSignals( false );
785
798
799 updateAssistantSymbol();
800}
801
806
807void QgsSimpleMarkerSymbolLayerWidget::setShape()
808{
809 mLayer->setShape( static_cast<Qgis::MarkerShape>( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
810 btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
811 emit changed();
812}
813
815{
816 mLayer->setStrokeColor( color );
817 emit changed();
818}
819
821{
822 mLayer->setColor( color );
823 emit changed();
824}
825
826void QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged()
827{
828 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
829 emit changed();
830}
831
832void QgsSimpleMarkerSymbolLayerWidget::penCapStyleChanged()
833{
834 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
835 emit changed();
836}
837
838void QgsSimpleMarkerSymbolLayerWidget::setSize()
839{
840 mLayer->setSize( spinSize->value() );
841 emit changed();
842}
843
844void QgsSimpleMarkerSymbolLayerWidget::setAngle()
845{
846 mLayer->setAngle( spinAngle->value() );
847 emit changed();
848}
849
850void QgsSimpleMarkerSymbolLayerWidget::setOffset()
851{
852 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
853 emit changed();
854}
855
856void QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged( int index )
857{
858 Q_UNUSED( index )
859
860 if ( mLayer )
861 {
862 mLayer->setStrokeStyle( mStrokeStyleComboBox->penStyle() );
863 emit changed();
864 }
865}
866
867void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
868{
869 if ( mLayer )
870 {
872 emit changed();
873 }
874}
875
876void QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
877{
878 if ( mLayer )
879 {
880 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
881 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
882 emit changed();
883 }
884}
885
886void QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
887{
888 if ( mLayer )
889 {
890 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
891 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
892 emit changed();
893 }
894}
895
896void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
897{
898 if ( mLayer )
899 {
900 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
901 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
902 emit changed();
903 }
904}
905
906void QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int )
907{
908 if ( mLayer )
909 {
910 mLayer->setHorizontalAnchorPoint( mHorizontalAnchorComboBox->currentData().value< Qgis::HorizontalAnchorPoint >() );
911 emit changed();
912 }
913}
914
915void QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int )
916{
917 if ( mLayer )
918 {
919 mLayer->setVerticalAnchorPoint( mVerticalAnchorComboBox->currentData().value< Qgis::VerticalAnchorPoint >() );
920 emit changed();
921 }
922}
923
924void QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol()
925{
926 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
927 {
928 mAssistantPreviewSymbol->deleteSymbolLayer( i );
929 }
930 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
932 if ( ddSize )
933 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
934}
935
936
938
940 : QgsSymbolLayerWidget( parent, vl )
941{
942 mLayer = nullptr;
943
944 setupUi( this );
945 connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
946 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed );
949
950 btnChangeColor->setAllowOpacity( true );
951 btnChangeColor->setColorDialogTitle( tr( "Select Fill Color" ) );
952 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
953 btnChangeColor->setShowNoColor( true );
954 btnChangeColor->setNoColorString( tr( "Transparent Fill" ) );
955 btnChangeStrokeColor->setAllowOpacity( true );
956 btnChangeStrokeColor->setColorDialogTitle( tr( "Select Stroke Color" ) );
957 btnChangeStrokeColor->setContext( QStringLiteral( "symbology" ) );
958 btnChangeStrokeColor->setShowNoColor( true );
959 btnChangeStrokeColor->setNoColorString( tr( "Transparent Stroke" ) );
960
961 spinOffsetX->setClearValue( 0.0 );
962 spinOffsetY->setClearValue( 0.0 );
963
965 connect( cboFillStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::setBrushStyle );
967 connect( spinStrokeWidth, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeWidthChanged );
968 connect( cboStrokeStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
969 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
970 connect( spinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
971 connect( spinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
972
973 mFillColorDDBtn->registerLinkedWidget( btnChangeColor );
974 mStrokeColorDDBtn->registerLinkedWidget( btnChangeStrokeColor );
975}
976
978{
979 if ( layer->layerType() != QLatin1String( "SimpleFill" ) )
980 return;
981
982 // layer type is correct, we can do the cast
983 mLayer = static_cast<QgsSimpleFillSymbolLayer *>( layer );
984
985 // set values
986 btnChangeColor->blockSignals( true );
987 btnChangeColor->setColor( mLayer->color() );
988 btnChangeColor->blockSignals( false );
989 cboFillStyle->blockSignals( true );
990 cboFillStyle->setBrushStyle( mLayer->brushStyle() );
991 cboFillStyle->blockSignals( false );
992 btnChangeStrokeColor->blockSignals( true );
993 btnChangeStrokeColor->setColor( mLayer->strokeColor() );
994 btnChangeStrokeColor->blockSignals( false );
995 cboStrokeStyle->blockSignals( true );
996 cboStrokeStyle->setPenStyle( mLayer->strokeStyle() );
997 cboStrokeStyle->blockSignals( false );
998 spinStrokeWidth->blockSignals( true );
999 spinStrokeWidth->setValue( mLayer->strokeWidth() );
1000 spinStrokeWidth->blockSignals( false );
1001 cboJoinStyle->blockSignals( true );
1002 cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
1003 cboJoinStyle->blockSignals( false );
1004 spinOffsetX->blockSignals( true );
1005 spinOffsetX->setValue( mLayer->offset().x() );
1006 spinOffsetX->blockSignals( false );
1007 spinOffsetY->blockSignals( true );
1008 spinOffsetY->setValue( mLayer->offset().y() );
1009 spinOffsetY->blockSignals( false );
1010
1011 mStrokeWidthUnitWidget->blockSignals( true );
1012 mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
1013 mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
1014 mStrokeWidthUnitWidget->blockSignals( false );
1015 mOffsetUnitWidget->blockSignals( true );
1016 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1017 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1018 mOffsetUnitWidget->blockSignals( false );
1019
1027}
1028
1033
1035{
1036 mLayer->setColor( color );
1037 emit changed();
1038}
1039
1041{
1042 mLayer->setStrokeColor( color );
1043 emit changed();
1044}
1045
1046void QgsSimpleFillSymbolLayerWidget::setBrushStyle()
1047{
1048 mLayer->setBrushStyle( cboFillStyle->brushStyle() );
1049 emit changed();
1050}
1051
1052void QgsSimpleFillSymbolLayerWidget::strokeWidthChanged()
1053{
1054 mLayer->setStrokeWidth( spinStrokeWidth->value() );
1055 emit changed();
1056}
1057
1058void QgsSimpleFillSymbolLayerWidget::strokeStyleChanged()
1059{
1060 mLayer->setStrokeStyle( cboStrokeStyle->penStyle() );
1061 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
1062 emit changed();
1063}
1064
1065void QgsSimpleFillSymbolLayerWidget::offsetChanged()
1066{
1067 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1068 emit changed();
1069}
1070
1071void QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
1072{
1073 if ( mLayer )
1074 {
1075 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
1076 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
1077 emit changed();
1078 }
1079}
1080
1081void QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1082{
1083 if ( mLayer )
1084 {
1085 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1086 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1087 emit changed();
1088 }
1089}
1090
1092
1094 : QgsSymbolLayerWidget( parent, vl )
1095{
1096 mLayer = nullptr;
1097
1098 setupUi( this );
1099
1100 mHorizontalAnchorComboBox->addItem( tr( "Left" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Left ) );
1101 mHorizontalAnchorComboBox->addItem( tr( "Horizontal Center" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Center ) );
1102 mHorizontalAnchorComboBox->addItem( tr( "Right" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Right ) );
1103
1104 mVerticalAnchorComboBox->addItem( tr( "Top" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Top ) );
1105 mVerticalAnchorComboBox->addItem( tr( "Vertical Center" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Center ) );
1106 mVerticalAnchorComboBox->addItem( tr( "Bottom" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Bottom ) );
1107
1108 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
1109 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
1110 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
1111 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
1114
1115 spinOffsetX->setClearValue( 0.0 );
1116 spinOffsetY->setClearValue( 0.0 );
1117 spinAngle->setClearValue( 0.0 );
1118
1119 //make a temporary symbol for the size assistant preview
1120 mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
1121
1122 if ( vectorLayer() )
1123 mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
1124
1125 int size = lstNames->iconSize().width();
1126 size = std::max( 30, static_cast<int>( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) );
1127 lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
1128 lstNames->setIconSize( QSize( size, size ) );
1129
1130 const double markerSize = size * 0.8;
1132 for ( const Qgis::MarkerShape shape : shapes )
1133 {
1134 QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
1136 lyr->setColor( QColor( 200, 200, 200 ) );
1137 lyr->setStrokeColor( QColor( 0, 0, 0 ) );
1138 const QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, Qgis::RenderUnit::Pixels, QSize( size, size ), QgsMapUnitScale(), Qgis::SymbolType::Hybrid, nullptr, QgsScreenProperties( screen() ) );
1139 QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
1140 item->setData( Qt::UserRole, static_cast<int>( shape ) );
1141 item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
1142 delete lyr;
1143 }
1144 // show at least 3 rows
1145 lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
1146
1147 connect( lstNames, &QListWidget::currentRowChanged, this, &QgsFilledMarkerSymbolLayerWidget::setShape );
1148 connect( spinSize, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setSize );
1149 connect( spinAngle, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setAngle );
1150 connect( spinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
1151 connect( spinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
1152 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol );
1153}
1154
1156
1158{
1159 if ( layer->layerType() != QLatin1String( "FilledMarker" ) )
1160 return;
1161
1162 // layer type is correct, we can do the cast
1163 mLayer = static_cast<QgsFilledMarkerSymbolLayer *>( layer );
1164
1165 // set values
1166 const Qgis::MarkerShape shape = mLayer->shape();
1167 for ( int i = 0; i < lstNames->count(); ++i )
1168 {
1169 if ( static_cast<Qgis::MarkerShape>( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
1170 {
1171 lstNames->setCurrentRow( i );
1172 break;
1173 }
1174 }
1175 whileBlocking( spinSize )->setValue( mLayer->size() );
1176 whileBlocking( spinAngle )->setValue( mLayer->angle() );
1177 whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
1178 whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
1179
1180 mSizeUnitWidget->blockSignals( true );
1181 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1182 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1183 mSizeUnitWidget->blockSignals( false );
1184 mOffsetUnitWidget->blockSignals( true );
1185 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1186 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1187 mOffsetUnitWidget->blockSignals( false );
1188
1189 //anchor points
1190 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue( mLayer->horizontalAnchorPoint() ) ) );
1191 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue( mLayer->verticalAnchorPoint() ) ) );
1192
1199
1200 updateAssistantSymbol();
1201}
1202
1207
1208void QgsFilledMarkerSymbolLayerWidget::setShape()
1209{
1210 mLayer->setShape( static_cast<Qgis::MarkerShape>( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
1211 emit changed();
1212}
1213
1214void QgsFilledMarkerSymbolLayerWidget::setSize()
1215{
1216 mLayer->setSize( spinSize->value() );
1217 emit changed();
1218}
1219
1220void QgsFilledMarkerSymbolLayerWidget::setAngle()
1221{
1222 mLayer->setAngle( spinAngle->value() );
1223 emit changed();
1224}
1225
1226void QgsFilledMarkerSymbolLayerWidget::setOffset()
1227{
1228 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1229 emit changed();
1230}
1231
1232void QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
1233{
1234 if ( mLayer )
1235 {
1236 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1237 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1238 emit changed();
1239 }
1240}
1241
1242void QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
1243{
1244 if ( mLayer )
1245 {
1246 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1247 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1248 emit changed();
1249 }
1250}
1251
1252void QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int )
1253{
1254 if ( mLayer )
1255 {
1256 mLayer->setHorizontalAnchorPoint( mHorizontalAnchorComboBox->currentData().value<Qgis::HorizontalAnchorPoint>() );
1257 emit changed();
1258 }
1259}
1260
1261void QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int )
1262{
1263 if ( mLayer )
1264 {
1265 mLayer->setVerticalAnchorPoint( mVerticalAnchorComboBox->currentData().value< Qgis::VerticalAnchorPoint >() );
1266 emit changed();
1267 }
1268}
1269
1270void QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol()
1271{
1272 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
1273 {
1274 mAssistantPreviewSymbol->deleteSymbolLayer( i );
1275 }
1276 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1278 if ( ddSize )
1279 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
1280}
1281
1282
1284
1286 : QgsSymbolLayerWidget( parent, vl )
1287{
1288 mLayer = nullptr;
1289
1290 setupUi( this );
1291 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1292 connect( mSpinAngle, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged );
1294
1295 btnColorRamp->setShowGradientOnly( true );
1296
1297 btnChangeColor->setAllowOpacity( true );
1298 btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1299 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1300 btnChangeColor->setShowNoColor( true );
1301 btnChangeColor->setNoColorString( tr( "Transparent" ) );
1302 btnChangeColor2->setAllowOpacity( true );
1303 btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1304 btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1305 btnChangeColor2->setShowNoColor( true );
1306 btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1307
1308 mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1309 mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1310
1311 spinOffsetX->setClearValue( 0.0 );
1312 spinOffsetY->setClearValue( 0.0 );
1313 mSpinAngle->setClearValue( 0.0 );
1314
1318 connect( cboGradientType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientType );
1319 connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setCoordinateMode );
1320 connect( cboGradientSpread, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientSpread );
1321 connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::colorModeChanged );
1322 connect( spinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1323 connect( spinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1324 connect( spinRefPoint1X, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1325 connect( spinRefPoint1Y, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1326 connect( checkRefPoint1Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1327 connect( spinRefPoint2X, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1328 connect( spinRefPoint2Y, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1329 connect( checkRefPoint2Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1330}
1331
1333{
1334 if ( layer->layerType() != QLatin1String( "GradientFill" ) )
1335 return;
1336
1337 // layer type is correct, we can do the cast
1338 mLayer = static_cast<QgsGradientFillSymbolLayer *>( layer );
1339
1340 // set values
1341 btnChangeColor->blockSignals( true );
1342 btnChangeColor->setColor( mLayer->color() );
1343 btnChangeColor->blockSignals( false );
1344 btnChangeColor2->blockSignals( true );
1345 btnChangeColor2->setColor( mLayer->color2() );
1346 btnChangeColor2->blockSignals( false );
1347
1349 {
1350 radioTwoColor->setChecked( true );
1351 btnColorRamp->setEnabled( false );
1352 }
1353 else
1354 {
1355 radioColorRamp->setChecked( true );
1356 btnChangeColor->setEnabled( false );
1357 btnChangeColor2->setEnabled( false );
1358 }
1359
1360 // set source color ramp
1361 if ( mLayer->colorRamp() )
1362 {
1363 btnColorRamp->blockSignals( true );
1364 btnColorRamp->setColorRamp( mLayer->colorRamp() );
1365 btnColorRamp->blockSignals( false );
1366 }
1367
1368 cboGradientType->blockSignals( true );
1369 switch ( mLayer->gradientType() )
1370 {
1372 cboGradientType->setCurrentIndex( 0 );
1373 break;
1375 cboGradientType->setCurrentIndex( 1 );
1376 break;
1378 cboGradientType->setCurrentIndex( 2 );
1379 break;
1380 }
1381 cboGradientType->blockSignals( false );
1382
1383 cboCoordinateMode->blockSignals( true );
1384 switch ( mLayer->coordinateMode() )
1385 {
1387 cboCoordinateMode->setCurrentIndex( 1 );
1388 checkRefPoint1Centroid->setEnabled( false );
1389 checkRefPoint2Centroid->setEnabled( false );
1390 break;
1392 default:
1393 cboCoordinateMode->setCurrentIndex( 0 );
1394 break;
1395 }
1396 cboCoordinateMode->blockSignals( false );
1397
1398 cboGradientSpread->blockSignals( true );
1399 switch ( mLayer->gradientSpread() )
1400 {
1402 cboGradientSpread->setCurrentIndex( 0 );
1403 break;
1405 cboGradientSpread->setCurrentIndex( 1 );
1406 break;
1408 cboGradientSpread->setCurrentIndex( 2 );
1409 break;
1410 }
1411 cboGradientSpread->blockSignals( false );
1412
1413 spinRefPoint1X->blockSignals( true );
1414 spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
1415 spinRefPoint1X->blockSignals( false );
1416 spinRefPoint1Y->blockSignals( true );
1417 spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
1418 spinRefPoint1Y->blockSignals( false );
1419 checkRefPoint1Centroid->blockSignals( true );
1420 checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
1422 {
1423 spinRefPoint1X->setEnabled( false );
1424 spinRefPoint1Y->setEnabled( false );
1425 }
1426 checkRefPoint1Centroid->blockSignals( false );
1427 spinRefPoint2X->blockSignals( true );
1428 spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
1429 spinRefPoint2X->blockSignals( false );
1430 spinRefPoint2Y->blockSignals( true );
1431 spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
1432 spinRefPoint2Y->blockSignals( false );
1433 checkRefPoint2Centroid->blockSignals( true );
1434 checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
1436 {
1437 spinRefPoint2X->setEnabled( false );
1438 spinRefPoint2Y->setEnabled( false );
1439 }
1440 checkRefPoint2Centroid->blockSignals( false );
1441
1442 spinOffsetX->blockSignals( true );
1443 spinOffsetX->setValue( mLayer->offset().x() );
1444 spinOffsetX->blockSignals( false );
1445 spinOffsetY->blockSignals( true );
1446 spinOffsetY->setValue( mLayer->offset().y() );
1447 spinOffsetY->blockSignals( false );
1448 mSpinAngle->blockSignals( true );
1449 mSpinAngle->setValue( mLayer->angle() );
1450 mSpinAngle->blockSignals( false );
1451
1452 mOffsetUnitWidget->blockSignals( true );
1453 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1454 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1455 mOffsetUnitWidget->blockSignals( false );
1456
1470}
1471
1476
1478{
1479 mLayer->setColor( color );
1480 emit changed();
1481}
1482
1484{
1485 mLayer->setColor2( color );
1486 emit changed();
1487}
1488
1489void QgsGradientFillSymbolLayerWidget::colorModeChanged()
1490{
1491 if ( radioTwoColor->isChecked() )
1492 {
1494 }
1495 else
1496 {
1498 }
1499 emit changed();
1500}
1501
1503{
1504 if ( btnColorRamp->isNull() )
1505 return;
1506
1507 mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
1508 emit changed();
1509}
1510
1512{
1513 switch ( index )
1514 {
1515 case 0:
1517 //set sensible default reference points
1518 spinRefPoint1X->setValue( 0.5 );
1519 spinRefPoint1Y->setValue( 0 );
1520 spinRefPoint2X->setValue( 0.5 );
1521 spinRefPoint2Y->setValue( 1 );
1522 break;
1523 case 1:
1525 //set sensible default reference points
1526 spinRefPoint1X->setValue( 0 );
1527 spinRefPoint1Y->setValue( 0 );
1528 spinRefPoint2X->setValue( 1 );
1529 spinRefPoint2Y->setValue( 1 );
1530 break;
1531 case 2:
1533 spinRefPoint1X->setValue( 0.5 );
1534 spinRefPoint1Y->setValue( 0.5 );
1535 spinRefPoint2X->setValue( 1 );
1536 spinRefPoint2Y->setValue( 1 );
1537 break;
1538 }
1539 emit changed();
1540}
1541
1543{
1544 switch ( index )
1545 {
1546 case 0:
1547 //feature coordinate mode
1549 //allow choice of centroid reference positions
1550 checkRefPoint1Centroid->setEnabled( true );
1551 checkRefPoint2Centroid->setEnabled( true );
1552 break;
1553 case 1:
1554 //viewport coordinate mode
1556 //disable choice of centroid reference positions
1557 checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1558 checkRefPoint1Centroid->setEnabled( false );
1559 checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1560 checkRefPoint2Centroid->setEnabled( false );
1561 break;
1562 }
1563
1564 emit changed();
1565}
1566
1568{
1569 switch ( index )
1570 {
1571 case 0:
1573 break;
1574 case 1:
1576 break;
1577 case 2:
1579 break;
1580 }
1581
1582 emit changed();
1583}
1584
1585void QgsGradientFillSymbolLayerWidget::offsetChanged()
1586{
1587 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1588 emit changed();
1589}
1590
1591void QgsGradientFillSymbolLayerWidget::referencePointChanged()
1592{
1593 mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1594 mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1595 mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1596 mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1597 emit changed();
1598}
1599
1600void QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged( double value )
1601{
1602 mLayer->setAngle( value );
1603 emit changed();
1604}
1605
1606void QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1607{
1608 if ( mLayer )
1609 {
1610 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1611 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1612 emit changed();
1613 }
1614}
1615
1617
1619 : QgsSymbolLayerWidget( parent, vl )
1620{
1621 mLayer = nullptr;
1622
1623 setupUi( this );
1624 connect( mSpinBlurRadius, qOverload<int>( &QSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged );
1625 connect( mSpinMaxDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged );
1626 connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed );
1627 connect( mRadioUseWholeShape, &QRadioButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled );
1628 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1629 connect( mIgnoreRingsCheckBox, &QCheckBox::stateChanged, this, &QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged );
1632
1633 QButtonGroup *group1 = new QButtonGroup( this );
1634 group1->addButton( radioColorRamp );
1635 group1->addButton( radioTwoColor );
1636 QButtonGroup *group2 = new QButtonGroup( this );
1637 group2->addButton( mRadioUseMaxDistance );
1638 group2->addButton( mRadioUseWholeShape );
1639 btnChangeColor->setAllowOpacity( true );
1640 btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1641 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1642 btnChangeColor->setShowNoColor( true );
1643 btnChangeColor->setNoColorString( tr( "Transparent" ) );
1644 btnChangeColor2->setAllowOpacity( true );
1645 btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1646 btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1647 btnChangeColor2->setShowNoColor( true );
1648 btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1649
1650 mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1651 mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1652
1653 spinOffsetX->setClearValue( 0.0 );
1654 spinOffsetY->setClearValue( 0.0 );
1655 mSpinMaxDistance->setClearValue( 5.0 );
1656
1657 btnColorRamp->setShowGradientOnly( true );
1658
1659 connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsShapeburstFillSymbolLayerWidget::applyColorRamp );
1660
1663 connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::colorModeChanged );
1664 connect( spinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1665 connect( spinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1666
1667 connect( mBlurSlider, &QAbstractSlider::valueChanged, mSpinBlurRadius, &QSpinBox::setValue );
1668 connect( mSpinBlurRadius, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), mBlurSlider, &QAbstractSlider::setValue );
1669}
1670
1672{
1673 if ( layer->layerType() != QLatin1String( "ShapeburstFill" ) )
1674 return;
1675
1676 // layer type is correct, we can do the cast
1677 mLayer = static_cast<QgsShapeburstFillSymbolLayer *>( layer );
1678
1679 // set values
1680 btnChangeColor->blockSignals( true );
1681 btnChangeColor->setColor( mLayer->color() );
1682 btnChangeColor->blockSignals( false );
1683 btnChangeColor2->blockSignals( true );
1684 btnChangeColor2->setColor( mLayer->color2() );
1685 btnChangeColor2->blockSignals( false );
1686
1688 {
1689 radioTwoColor->setChecked( true );
1690 btnColorRamp->setEnabled( false );
1691 }
1692 else
1693 {
1694 radioColorRamp->setChecked( true );
1695 btnChangeColor->setEnabled( false );
1696 btnChangeColor2->setEnabled( false );
1697 }
1698
1699 mSpinBlurRadius->blockSignals( true );
1700 mBlurSlider->blockSignals( true );
1701 mSpinBlurRadius->setValue( mLayer->blurRadius() );
1702 mBlurSlider->setValue( mLayer->blurRadius() );
1703 mSpinBlurRadius->blockSignals( false );
1704 mBlurSlider->blockSignals( false );
1705
1706 mSpinMaxDistance->blockSignals( true );
1707 mSpinMaxDistance->setValue( mLayer->maxDistance() );
1708 mSpinMaxDistance->blockSignals( false );
1709
1710 mRadioUseWholeShape->blockSignals( true );
1711 mRadioUseMaxDistance->blockSignals( true );
1712 if ( mLayer->useWholeShape() )
1713 {
1714 mRadioUseWholeShape->setChecked( true );
1715 mSpinMaxDistance->setEnabled( false );
1716 mDistanceUnitWidget->setEnabled( false );
1717 }
1718 else
1719 {
1720 mRadioUseMaxDistance->setChecked( true );
1721 mSpinMaxDistance->setEnabled( true );
1722 mDistanceUnitWidget->setEnabled( true );
1723 }
1724 mRadioUseWholeShape->blockSignals( false );
1725 mRadioUseMaxDistance->blockSignals( false );
1726
1727 mDistanceUnitWidget->blockSignals( true );
1728 mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1729 mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1730 mDistanceUnitWidget->blockSignals( false );
1731
1732 mIgnoreRingsCheckBox->blockSignals( true );
1733 mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1734 mIgnoreRingsCheckBox->blockSignals( false );
1735
1736 // set source color ramp
1737 if ( mLayer->colorRamp() )
1738 {
1739 btnColorRamp->blockSignals( true );
1740 btnColorRamp->setColorRamp( mLayer->colorRamp() );
1741 btnColorRamp->blockSignals( false );
1742 }
1743
1744 spinOffsetX->blockSignals( true );
1745 spinOffsetX->setValue( mLayer->offset().x() );
1746 spinOffsetX->blockSignals( false );
1747 spinOffsetY->blockSignals( true );
1748 spinOffsetY->setValue( mLayer->offset().y() );
1749 spinOffsetY->blockSignals( false );
1750 mOffsetUnitWidget->blockSignals( true );
1751 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1752 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1753 mOffsetUnitWidget->blockSignals( false );
1754
1762}
1763
1768
1770{
1771 if ( mLayer )
1772 {
1773 mLayer->setColor( color );
1774 emit changed();
1775 }
1776}
1777
1779{
1780 if ( mLayer )
1781 {
1782 mLayer->setColor2( color );
1783 emit changed();
1784 }
1785}
1786
1787void QgsShapeburstFillSymbolLayerWidget::colorModeChanged()
1788{
1789 if ( !mLayer )
1790 {
1791 return;
1792 }
1793
1794 if ( radioTwoColor->isChecked() )
1795 {
1797 }
1798 else
1799 {
1801 }
1802 emit changed();
1803}
1804
1805void QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged( int value )
1806{
1807 if ( mLayer )
1808 {
1809 mLayer->setBlurRadius( value );
1810 emit changed();
1811 }
1812}
1813
1814void QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged( double value )
1815{
1816 if ( mLayer )
1817 {
1818 mLayer->setMaxDistance( value );
1819 emit changed();
1820 }
1821}
1822
1823void QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed()
1824{
1825 if ( mLayer )
1826 {
1827 mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1828 mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1829 emit changed();
1830 }
1831}
1832
1833void QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled( bool value )
1834{
1835 if ( mLayer )
1836 {
1837 mLayer->setUseWholeShape( value );
1838 mDistanceUnitWidget->setEnabled( !value );
1839 emit changed();
1840 }
1841}
1842
1843void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
1844{
1845 QgsColorRamp *ramp = btnColorRamp->colorRamp();
1846 if ( !ramp )
1847 return;
1848
1849 mLayer->setColorRamp( ramp );
1850 emit changed();
1851}
1852
1853void QgsShapeburstFillSymbolLayerWidget::offsetChanged()
1854{
1855 if ( mLayer )
1856 {
1857 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1858 emit changed();
1859 }
1860}
1861
1862void QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1863{
1864 if ( mLayer )
1865 {
1866 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1867 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1868 emit changed();
1869 }
1870}
1871
1872
1873void QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged( int state )
1874{
1875 const bool checked = ( state == Qt::Checked );
1876 mLayer->setIgnoreRings( checked );
1877 emit changed();
1878}
1879
1881
1883 : QgsSymbolLayerWidget( parent, vl )
1884{
1885 mLayer = nullptr;
1886
1887 setupUi( this );
1888 connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed );
1889 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed );
1890 connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
1891 connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::averageAngleUnitChanged );
1896
1897 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
1898 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
1899 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
1900 connect( mRingFilterComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( int ) {
1901 if ( mLayer )
1902 {
1903 mLayer->setRingFilter( static_cast<QgsLineSymbolLayer::RenderRingFilter>( mRingFilterComboBox->currentData().toInt() ) );
1904 emit changed();
1905 }
1906 } );
1907
1908 spinOffset->setClearValue( 0.0 );
1909 mSpinOffsetAlongLine->setClearValue( 0.0 );
1910 mSpinAverageAngleLength->setClearValue( 4.0 );
1911
1912 connect( spinInterval, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setInterval );
1913 connect( mSpinOffsetAlongLine, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffsetAlongLine );
1914 connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setRotate );
1915 connect( spinOffset, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffset );
1916 connect( mSpinAverageAngleLength, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setAverageAngle );
1917 connect( mCheckInterval, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1918 connect( mCheckVertex, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1919 connect( mCheckVertexLast, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1920 connect( mCheckVertexFirst, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1921 connect( mCheckCentralPoint, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1922 connect( mCheckCurvePoint, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1923 connect( mCheckSegmentCentralPoint, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1924 connect( mCheckPlaceOnEveryPart, &QCheckBox::toggled, this, [=] {
1925 if ( mLayer )
1926 {
1927 mLayer->setPlaceOnEveryPart( mCheckPlaceOnEveryPart->isChecked() );
1928 emit changed();
1929 }
1930 } );
1931}
1932
1934{
1935 if ( layer->layerType() != QLatin1String( "MarkerLine" ) )
1936 return;
1937
1938 // layer type is correct, we can do the cast
1939 mLayer = static_cast<QgsMarkerLineSymbolLayer *>( layer );
1940
1941 // set values
1942 spinInterval->blockSignals( true );
1943 spinInterval->setValue( mLayer->interval() );
1944 spinInterval->blockSignals( false );
1945 mSpinOffsetAlongLine->blockSignals( true );
1946 mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1947 mSpinOffsetAlongLine->blockSignals( false );
1948 chkRotateMarker->blockSignals( true );
1949 chkRotateMarker->setChecked( mLayer->rotateSymbols() );
1950 chkRotateMarker->blockSignals( false );
1951 spinOffset->blockSignals( true );
1952 spinOffset->setValue( mLayer->offset() );
1953 spinOffset->blockSignals( false );
1954
1955 whileBlocking( mCheckInterval )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::Interval );
1959 whileBlocking( mCheckCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CentralPoint );
1960 whileBlocking( mCheckCurvePoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CurvePoint );
1961 whileBlocking( mCheckSegmentCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::SegmentCenter );
1962 whileBlocking( mCheckPlaceOnEveryPart )->setChecked( mLayer->placeOnEveryPart() );
1963
1964 // set units
1965 mIntervalUnitWidget->blockSignals( true );
1966 mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1967 mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1968 mIntervalUnitWidget->blockSignals( false );
1969 mOffsetUnitWidget->blockSignals( true );
1970 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1971 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1972 mOffsetUnitWidget->blockSignals( false );
1973 mOffsetAlongLineUnitWidget->blockSignals( true );
1974 mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1975 mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1976 mOffsetAlongLineUnitWidget->blockSignals( false );
1977
1978 whileBlocking( mAverageAngleUnit )->setUnit( mLayer->averageAngleUnit() );
1979 whileBlocking( mAverageAngleUnit )->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
1980 whileBlocking( mSpinAverageAngleLength )->setValue( mLayer->averageAngleLength() );
1981
1982 whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
1983
1984 setPlacement(); // update gui
1985
1991}
1992
1997
1999{
2001
2002 switch ( context.symbolType() )
2003 {
2006 //these settings only have an effect when the symbol layers is part of a fill symbol
2007 mRingFilterComboBox->hide();
2008 mRingsLabel->hide();
2009 break;
2010
2013 break;
2014 }
2015}
2016
2018{
2019 mLayer->setInterval( val );
2020 emit changed();
2021}
2022
2024{
2025 mLayer->setOffsetAlongLine( val );
2026 emit changed();
2027}
2028
2029void QgsMarkerLineSymbolLayerWidget::setRotate()
2030{
2031 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2032 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2033
2034 mLayer->setRotateSymbols( chkRotateMarker->isChecked() );
2035 emit changed();
2036}
2037
2038void QgsMarkerLineSymbolLayerWidget::setOffset()
2039{
2040 mLayer->setOffset( spinOffset->value() );
2041 emit changed();
2042}
2043
2044void QgsMarkerLineSymbolLayerWidget::setPlacement()
2045{
2046 const bool interval = mCheckInterval->isChecked();
2047 spinInterval->setEnabled( interval );
2048 mSpinOffsetAlongLine->setEnabled( mCheckInterval->isChecked() || mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2049 mOffsetAlongLineUnitWidget->setEnabled( mSpinOffsetAlongLine->isEnabled() );
2050 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2051 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2052 mCheckPlaceOnEveryPart->setEnabled( mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2053
2054 Qgis::MarkerLinePlacements placements;
2055 if ( mCheckInterval->isChecked() )
2057 if ( mCheckVertex->isChecked() )
2059 if ( mCheckVertexLast->isChecked() )
2061 if ( mCheckVertexFirst->isChecked() )
2063 if ( mCheckCurvePoint->isChecked() )
2065 if ( mCheckSegmentCentralPoint->isChecked() )
2067 if ( mCheckCentralPoint->isChecked() )
2069 mLayer->setPlacements( placements );
2070
2071 emit changed();
2072}
2073
2074void QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed()
2075{
2076 if ( mLayer )
2077 {
2078 mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
2079 mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
2080 emit changed();
2081 }
2082}
2083
2084void QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed()
2085{
2086 if ( mLayer )
2087 {
2088 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2089 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2090 emit changed();
2091 }
2092}
2093
2094void QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
2095{
2096 if ( mLayer )
2097 {
2098 mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
2099 mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
2100 }
2101 emit changed();
2102}
2103
2104void QgsMarkerLineSymbolLayerWidget::averageAngleUnitChanged()
2105{
2106 if ( mLayer )
2107 {
2108 mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
2109 mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
2110 }
2111 emit changed();
2112}
2113
2114void QgsMarkerLineSymbolLayerWidget::setAverageAngle( double val )
2115{
2116 if ( mLayer )
2117 {
2119 emit changed();
2120 }
2121}
2122
2123
2125
2127 : QgsSymbolLayerWidget( parent, vl )
2128{
2129 mLayer = nullptr;
2130
2131 setupUi( this );
2132 connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mIntervalUnitWidget_changed );
2133 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mOffsetUnitWidget_changed );
2134 connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
2135 connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::averageAngleUnitChanged );
2136 connect( mHashLengthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::hashLengthUnitWidgetChanged );
2142
2143 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
2144 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
2145 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
2146 connect( mRingFilterComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( int ) {
2147 if ( mLayer )
2148 {
2149 mLayer->setRingFilter( static_cast<QgsLineSymbolLayer::RenderRingFilter>( mRingFilterComboBox->currentData().toInt() ) );
2150 emit changed();
2151 }
2152 } );
2153
2154 spinOffset->setClearValue( 0.0 );
2155 mSpinOffsetAlongLine->setClearValue( 0.0 );
2156 mHashRotationSpinBox->setClearValue( 0 );
2157 mSpinAverageAngleLength->setClearValue( 4.0 );
2158
2159 connect( spinInterval, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setInterval );
2160 connect( mSpinOffsetAlongLine, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setOffsetAlongLine );
2161 connect( mSpinHashLength, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setHashLength );
2162 connect( mHashRotationSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setHashAngle );
2163 connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setRotate );
2164 connect( spinOffset, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setOffset );
2165 connect( mSpinAverageAngleLength, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setAverageAngle );
2166
2167 connect( mCheckInterval, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2168 connect( mCheckVertex, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2169 connect( mCheckVertexLast, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2170 connect( mCheckVertexFirst, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2171 connect( mCheckCentralPoint, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2172 connect( mCheckCurvePoint, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2173 connect( mCheckSegmentCentralPoint, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2174
2175 connect( mCheckPlaceOnEveryPart, &QCheckBox::toggled, this, [=] {
2176 if ( mLayer )
2177 {
2178 mLayer->setPlaceOnEveryPart( mCheckPlaceOnEveryPart->isChecked() );
2179 emit changed();
2180 }
2181 } );
2182}
2183
2185{
2186 if ( layer->layerType() != QLatin1String( "HashLine" ) )
2187 return;
2188
2189 // layer type is correct, we can do the cast
2190 mLayer = static_cast<QgsHashedLineSymbolLayer *>( layer );
2191
2192 // set values
2193 spinInterval->blockSignals( true );
2194 spinInterval->setValue( mLayer->interval() );
2195 spinInterval->blockSignals( false );
2196 mSpinOffsetAlongLine->blockSignals( true );
2197 mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
2198 mSpinOffsetAlongLine->blockSignals( false );
2199 whileBlocking( mSpinHashLength )->setValue( mLayer->hashLength() );
2200 whileBlocking( mHashRotationSpinBox )->setValue( mLayer->hashAngle() );
2201 chkRotateMarker->blockSignals( true );
2202 chkRotateMarker->setChecked( mLayer->rotateSymbols() );
2203 chkRotateMarker->blockSignals( false );
2204 spinOffset->blockSignals( true );
2205 spinOffset->setValue( mLayer->offset() );
2206 spinOffset->blockSignals( false );
2207
2208 whileBlocking( mCheckInterval )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::Interval );
2210 whileBlocking( mCheckVertexFirst )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::FirstVertex || mLayer->placements() & Qgis::MarkerLinePlacement::Vertex );
2211 whileBlocking( mCheckVertexLast )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::LastVertex || mLayer->placements() & Qgis::MarkerLinePlacement::Vertex );
2212 whileBlocking( mCheckCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CentralPoint );
2213 whileBlocking( mCheckCurvePoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CurvePoint );
2214 whileBlocking( mCheckSegmentCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::SegmentCenter );
2215 whileBlocking( mCheckPlaceOnEveryPart )->setChecked( mLayer->placeOnEveryPart() );
2216
2217 // set units
2218 mIntervalUnitWidget->blockSignals( true );
2219 mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
2220 mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
2221 mIntervalUnitWidget->blockSignals( false );
2222 mOffsetUnitWidget->blockSignals( true );
2223 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2224 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2225 mOffsetUnitWidget->blockSignals( false );
2226 mOffsetAlongLineUnitWidget->blockSignals( true );
2227 mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
2228 mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
2229 mOffsetAlongLineUnitWidget->blockSignals( false );
2230 whileBlocking( mAverageAngleUnit )->setUnit( mLayer->averageAngleUnit() );
2231 whileBlocking( mAverageAngleUnit )->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
2232 whileBlocking( mSpinAverageAngleLength )->setValue( mLayer->averageAngleLength() );
2233 whileBlocking( mHashLengthUnitWidget )->setUnit( mLayer->hashLengthUnit() );
2234 whileBlocking( mHashLengthUnitWidget )->setMapUnitScale( mLayer->hashLengthMapUnitScale() );
2235
2236 whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
2237
2238 setPlacement(); // update gui
2239
2247}
2248
2253
2255{
2257
2258 switch ( context.symbolType() )
2259 {
2262 //these settings only have an effect when the symbol layers is part of a fill symbol
2263 mRingFilterComboBox->hide();
2264 mRingsLabel->hide();
2265 break;
2266
2269 break;
2270 }
2271}
2272
2273void QgsHashedLineSymbolLayerWidget::setInterval( double val )
2274{
2275 mLayer->setInterval( val );
2276 emit changed();
2277}
2278
2279void QgsHashedLineSymbolLayerWidget::setOffsetAlongLine( double val )
2280{
2281 mLayer->setOffsetAlongLine( val );
2282 emit changed();
2283}
2284
2285void QgsHashedLineSymbolLayerWidget::setHashLength( double val )
2286{
2287 mLayer->setHashLength( val );
2288 emit changed();
2289}
2290
2291void QgsHashedLineSymbolLayerWidget::setHashAngle( double val )
2292{
2293 mLayer->setHashAngle( val );
2294 emit changed();
2295}
2296
2297void QgsHashedLineSymbolLayerWidget::setRotate()
2298{
2299 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2300 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2301
2302 mLayer->setRotateSymbols( chkRotateMarker->isChecked() );
2303 emit changed();
2304}
2305
2306void QgsHashedLineSymbolLayerWidget::setOffset()
2307{
2308 mLayer->setOffset( spinOffset->value() );
2309 emit changed();
2310}
2311
2312void QgsHashedLineSymbolLayerWidget::setPlacement()
2313{
2314 const bool interval = mCheckInterval->isChecked();
2315 spinInterval->setEnabled( interval );
2316 mSpinOffsetAlongLine->setEnabled( mCheckInterval->isChecked() || mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2317 mOffsetAlongLineUnitWidget->setEnabled( mSpinOffsetAlongLine->isEnabled() );
2318 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2319 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2320 mCheckPlaceOnEveryPart->setEnabled( mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2321
2322 Qgis::MarkerLinePlacements placements;
2323 if ( mCheckInterval->isChecked() )
2325 if ( mCheckVertex->isChecked() )
2327 if ( mCheckVertexLast->isChecked() )
2329 if ( mCheckVertexFirst->isChecked() )
2331 if ( mCheckCurvePoint->isChecked() )
2333 if ( mCheckSegmentCentralPoint->isChecked() )
2335 if ( mCheckCentralPoint->isChecked() )
2337 mLayer->setPlacements( placements );
2338
2339 emit changed();
2340}
2341
2342void QgsHashedLineSymbolLayerWidget::mIntervalUnitWidget_changed()
2343{
2344 if ( mLayer )
2345 {
2346 mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
2347 mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
2348 emit changed();
2349 }
2350}
2351
2352void QgsHashedLineSymbolLayerWidget::mOffsetUnitWidget_changed()
2353{
2354 if ( mLayer )
2355 {
2356 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2357 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2358 emit changed();
2359 }
2360}
2361
2362void QgsHashedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
2363{
2364 if ( mLayer )
2365 {
2366 mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
2367 mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
2368 }
2369 emit changed();
2370}
2371
2372void QgsHashedLineSymbolLayerWidget::hashLengthUnitWidgetChanged()
2373{
2374 if ( mLayer )
2375 {
2376 mLayer->setHashLengthUnit( mHashLengthUnitWidget->unit() );
2377 mLayer->setHashLengthMapUnitScale( mHashLengthUnitWidget->getMapUnitScale() );
2378 }
2379 emit changed();
2380}
2381
2382void QgsHashedLineSymbolLayerWidget::averageAngleUnitChanged()
2383{
2384 if ( mLayer )
2385 {
2386 mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
2387 mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
2388 }
2389 emit changed();
2390}
2391
2392void QgsHashedLineSymbolLayerWidget::setAverageAngle( double val )
2393{
2394 if ( mLayer )
2395 {
2396 mLayer->setAverageAngleLength( val );
2397 emit changed();
2398 }
2399}
2400
2402
2403
2405 : QgsSymbolLayerWidget( parent, vl )
2406{
2407 mLayer = nullptr;
2408
2409 setupUi( this );
2410
2411 mHorizontalAnchorComboBox->addItem( tr( "Left" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Left ) );
2412 mHorizontalAnchorComboBox->addItem( tr( "Horizontal Center" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Center ) );
2413 mHorizontalAnchorComboBox->addItem( tr( "Right" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Right ) );
2414
2415 mVerticalAnchorComboBox->addItem( tr( "Top" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Top ) );
2416 mVerticalAnchorComboBox->addItem( tr( "Vertical Center" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Center ) );
2417 mVerticalAnchorComboBox->addItem( tr( "Bottom" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Bottom ) );
2418
2419 mSvgSelectorWidget->setAllowParameters( true );
2420 mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
2421 mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral( "/UI/lastSVGMarkerDir" ) );
2422 mSvgSelectorWidget->initParametersModel( this, vl );
2423
2424 connect( mSvgSelectorWidget->sourceLineEdit(), &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSvgMarkerSymbolLayerWidget::svgSourceChanged );
2425 connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged );
2426 connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2427 connect( mStrokeWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2428 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
2429 connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
2430 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
2431 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
2432 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
2436 mChangeColorButton->setAllowOpacity( true );
2437 mChangeColorButton->setColorDialogTitle( tr( "Select Fill color" ) );
2438 mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2439 mChangeStrokeColorButton->setAllowOpacity( true );
2440 mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2441 mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2442
2443 mFillColorDDBtn->registerLinkedWidget( mChangeColorButton );
2444 mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2445
2446 spinOffsetX->setClearValue( 0.0 );
2447 spinOffsetY->setClearValue( 0.0 );
2448 spinAngle->setClearValue( 0.0 );
2449
2450 connect( spinWidth, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setWidth );
2451 connect( spinHeight, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setHeight );
2452 connect( mLockAspectRatio, static_cast<void ( QgsRatioLockButton::* )( bool )>( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged );
2453 connect( spinAngle, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setAngle );
2454 connect( spinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2455 connect( spinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2456 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol );
2457
2460
2461 //make a temporary symbol for the size assistant preview
2462 mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
2463
2464 if ( vectorLayer() )
2465 {
2466 mWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
2467 mHeightDDBtn->setSymbol( mAssistantPreviewSymbol );
2468 }
2469}
2470
2472
2473#include <QTime>
2474#include <QAbstractListModel>
2475#include <QPixmapCache>
2476#include <QStyle>
2477
2478
2480{
2481 if ( !layer )
2482 {
2483 return;
2484 }
2485
2486 //activate gui for svg parameters only if supported by the svg file
2487 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2488 QColor defaultFill, defaultStroke;
2489 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2490 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2491 QgsApplication::svgCache()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasStrokeParam, hasDefaultStrokeColor, defaultStroke, hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth, hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2492 mChangeColorButton->setEnabled( hasFillParam );
2493 mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2494 mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2495 mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
2496 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
2497
2498 if ( hasFillParam )
2499 {
2500 QColor fill = layer->fillColor();
2501 const double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2502 if ( hasDefaultFillColor && !skipDefaultColors )
2503 {
2504 fill = defaultFill;
2505 }
2506 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : existingOpacity );
2507 mChangeColorButton->setColor( fill );
2508 }
2509 if ( hasStrokeParam )
2510 {
2511 QColor stroke = layer->strokeColor();
2512 const double existingOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2513 if ( hasDefaultStrokeColor && !skipDefaultColors )
2514 {
2515 stroke = defaultStroke;
2516 }
2517 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : existingOpacity );
2518 mChangeStrokeColorButton->setColor( stroke );
2519 }
2520
2521 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( layer->path() );
2522
2523 mStrokeWidthSpinBox->blockSignals( true );
2524 mStrokeWidthSpinBox->setValue( hasDefaultStrokeWidth ? defaultStrokeWidth : layer->strokeWidth() );
2525 mStrokeWidthSpinBox->blockSignals( false );
2526
2527 const bool preservedAspectRatio = layer->preservedAspectRatio();
2528 spinHeight->blockSignals( true );
2529 if ( preservedAspectRatio )
2530 {
2531 spinHeight->setValue( layer->size() * layer->defaultAspectRatio() );
2532 }
2533 else
2534 {
2535 spinHeight->setValue( layer->size() * layer->fixedAspectRatio() );
2536 }
2537 spinHeight->setEnabled( layer->defaultAspectRatio() > 0.0 );
2538 spinHeight->blockSignals( false );
2539 whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
2540}
2541
2542void QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol()
2543{
2544 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
2545 {
2546 mAssistantPreviewSymbol->deleteSymbolLayer( i );
2547 }
2548 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2550 if ( ddSize )
2551 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
2552}
2553
2554
2556{
2557 if ( !layer )
2558 {
2559 return;
2560 }
2561
2562 if ( layer->layerType() != QLatin1String( "SvgMarker" ) )
2563 return;
2564
2565 // layer type is correct, we can do the cast
2566 mLayer = static_cast<QgsSvgMarkerSymbolLayer *>( layer );
2567
2568 // set values
2569 mSvgSelectorWidget->setSvgPath( mLayer->path() );
2570 mSvgSelectorWidget->setSvgParameters( mLayer->parameters() );
2571
2572 spinWidth->blockSignals( true );
2573 spinWidth->setValue( mLayer->size() );
2574 spinWidth->blockSignals( false );
2575 spinAngle->blockSignals( true );
2576 spinAngle->setValue( mLayer->angle() );
2577 spinAngle->blockSignals( false );
2578
2579 // without blocking signals the value gets changed because of slot setOffset()
2580 spinOffsetX->blockSignals( true );
2581 spinOffsetX->setValue( mLayer->offset().x() );
2582 spinOffsetX->blockSignals( false );
2583 spinOffsetY->blockSignals( true );
2584 spinOffsetY->setValue( mLayer->offset().y() );
2585 spinOffsetY->blockSignals( false );
2586
2587 mSizeUnitWidget->blockSignals( true );
2588 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2589 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2590 mSizeUnitWidget->blockSignals( false );
2591 mStrokeWidthUnitWidget->blockSignals( true );
2592 mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
2593 mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
2594 mStrokeWidthUnitWidget->blockSignals( false );
2595 mOffsetUnitWidget->blockSignals( true );
2596 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2597 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2598 mOffsetUnitWidget->blockSignals( false );
2599
2600 //anchor points
2601 mHorizontalAnchorComboBox->blockSignals( true );
2602 mVerticalAnchorComboBox->blockSignals( true );
2603 mHorizontalAnchorComboBox->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue( mLayer->horizontalAnchorPoint() ) ) );
2604 mVerticalAnchorComboBox->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue( mLayer->verticalAnchorPoint() ) ) );
2605 mHorizontalAnchorComboBox->blockSignals( false );
2606 mVerticalAnchorComboBox->blockSignals( false );
2607
2608 setGuiForSvg( mLayer, true );
2609
2619
2620 registerDataDefinedButton( mSvgSelectorWidget->sourceLineEdit()->propertyOverrideToolButton(), QgsSymbolLayer::Property::Name );
2621
2622 updateAssistantSymbol();
2623}
2624
2629
2631{
2633 mSvgSelectorWidget->sourceLineEdit()->setMessageBar( context.messageBar() );
2634}
2635
2637{
2638 mLayer->setPath( name );
2639 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2640
2642 emit changed();
2643}
2644
2645void QgsSvgMarkerSymbolLayerWidget::setSvgParameters( const QMap<QString, QgsProperty> &parameters )
2646{
2647 mLayer->setParameters( parameters );
2648 whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2649
2651 emit changed();
2652}
2653
2654void QgsSvgMarkerSymbolLayerWidget::setWidth()
2655{
2656 const double defaultAspectRatio = mLayer->defaultAspectRatio();
2657 double fixedAspectRatio = 0.0;
2658 spinHeight->blockSignals( true );
2659 if ( defaultAspectRatio <= 0.0 )
2660 {
2661 spinHeight->setValue( spinWidth->value() );
2662 }
2663 else if ( mLockAspectRatio->locked() )
2664 {
2665 spinHeight->setValue( spinWidth->value() * defaultAspectRatio );
2666 }
2667 else
2668 {
2669 fixedAspectRatio = spinHeight->value() / spinWidth->value();
2670 }
2671 spinHeight->blockSignals( false );
2672 mLayer->setSize( spinWidth->value() );
2673 mLayer->setFixedAspectRatio( fixedAspectRatio );
2674 emit changed();
2675}
2676
2677void QgsSvgMarkerSymbolLayerWidget::setHeight()
2678{
2679 const double defaultAspectRatio = mLayer->defaultAspectRatio();
2680 double fixedAspectRatio = 0.0;
2681 spinWidth->blockSignals( true );
2682 if ( defaultAspectRatio <= 0.0 )
2683 {
2684 spinWidth->setValue( spinHeight->value() );
2685 }
2686 else if ( mLockAspectRatio->locked() )
2687 {
2688 spinWidth->setValue( spinHeight->value() / defaultAspectRatio );
2689 }
2690 else
2691 {
2692 fixedAspectRatio = spinHeight->value() / spinWidth->value();
2693 }
2694 spinWidth->blockSignals( false );
2695 mLayer->setSize( spinWidth->value() );
2696 mLayer->setFixedAspectRatio( fixedAspectRatio );
2697 emit changed();
2698}
2699
2700void QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged( const bool locked )
2701{
2702 //spinHeight->setEnabled( !locked );
2703 const double defaultAspectRatio = mLayer->defaultAspectRatio();
2704 if ( defaultAspectRatio <= 0.0 )
2705 {
2706 whileBlocking( mLockAspectRatio )->setLocked( true );
2707 }
2708 else if ( locked )
2709 {
2711 setWidth();
2712 }
2713 else
2714 {
2715 mLayer->setFixedAspectRatio( spinHeight->value() / spinWidth->value() );
2716 }
2717 //emit changed();
2718}
2719
2720void QgsSvgMarkerSymbolLayerWidget::setAngle()
2721{
2722 mLayer->setAngle( spinAngle->value() );
2723 emit changed();
2724}
2725
2726void QgsSvgMarkerSymbolLayerWidget::setOffset()
2727{
2728 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2729 emit changed();
2730}
2731
2732void QgsSvgMarkerSymbolLayerWidget::svgSourceChanged( const QString &text )
2733{
2734 mLayer->setPath( text );
2736 emit changed();
2737}
2738
2739void QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
2740{
2741 if ( !mLayer )
2742 {
2743 return;
2744 }
2745
2746 mLayer->setFillColor( color );
2747 emit changed();
2748}
2749
2750void QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
2751{
2752 if ( !mLayer )
2753 {
2754 return;
2755 }
2756
2757 mLayer->setStrokeColor( color );
2758 emit changed();
2759}
2760
2761void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
2762{
2763 if ( mLayer )
2764 {
2765 mLayer->setStrokeWidth( d );
2766 emit changed();
2767 }
2768}
2769
2770void QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
2771{
2772 if ( mLayer )
2773 {
2774 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2775 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2776 emit changed();
2777 }
2778}
2779
2780void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
2781{
2782 if ( mLayer )
2783 {
2784 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
2785 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
2786 emit changed();
2787 }
2788}
2789
2790void QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
2791{
2792 if ( mLayer )
2793 {
2794 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2795 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2796 emit changed();
2797 }
2798}
2799
2800void QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int )
2801{
2802 if ( mLayer )
2803 {
2804 mLayer->setHorizontalAnchorPoint( mHorizontalAnchorComboBox->currentData().value< Qgis::HorizontalAnchorPoint >() );
2805 emit changed();
2806 }
2807}
2808
2809void QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int )
2810{
2811 if ( mLayer )
2812 {
2813 mLayer->setVerticalAnchorPoint( mVerticalAnchorComboBox->currentData().value< Qgis::VerticalAnchorPoint >() );
2814 emit changed();
2815 }
2816}
2817
2819
2821 : QgsSymbolLayerWidget( parent, vl )
2822{
2823 mLayer = nullptr;
2824 setupUi( this );
2825
2826 mSvgSelectorWidget->setAllowParameters( true );
2827 mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
2828
2829 connect( mTextureWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged );
2830 connect( mSvgSelectorWidget->sourceLineEdit(), &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSVGFillSymbolLayerWidget::svgSourceChanged );
2831 connect( mRotationSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
2832 connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged );
2833 connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2834 connect( mStrokeWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2835 connect( mTextureWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed );
2836 connect( mSvgStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed );
2839
2840 mRotationSpinBox->setClearValue( 0.0 );
2841
2842 mChangeColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
2843 mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2844 mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2845 mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2846
2847 mFilColorDDBtn->registerLinkedWidget( mChangeColorButton );
2848 mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2849
2850 connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgSelected, this, &QgsSVGFillSymbolLayerWidget::setFile );
2851 connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgParametersChanged, this, &QgsSVGFillSymbolLayerWidget::setSvgParameters );
2852}
2853
2855{
2856 if ( !layer )
2857 {
2858 return;
2859 }
2860
2861 if ( layer->layerType() != QLatin1String( "SVGFill" ) )
2862 {
2863 return;
2864 }
2865
2866 mLayer = dynamic_cast<QgsSVGFillSymbolLayer *>( layer );
2867 if ( mLayer )
2868 {
2869 const double width = mLayer->patternWidth();
2870 mTextureWidthSpinBox->blockSignals( true );
2871 mTextureWidthSpinBox->setValue( width );
2872 mTextureWidthSpinBox->blockSignals( false );
2873 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( mLayer->svgFilePath() );
2874 mRotationSpinBox->blockSignals( true );
2875 mRotationSpinBox->setValue( mLayer->angle() );
2876 mRotationSpinBox->blockSignals( false );
2877 mTextureWidthUnitWidget->blockSignals( true );
2878 mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2879 mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2880 mTextureWidthUnitWidget->blockSignals( false );
2881 mSvgStrokeWidthUnitWidget->blockSignals( true );
2882 mSvgStrokeWidthUnitWidget->setUnit( mLayer->svgStrokeWidthUnit() );
2883 mSvgStrokeWidthUnitWidget->setMapUnitScale( mLayer->svgStrokeWidthMapUnitScale() );
2884 mSvgStrokeWidthUnitWidget->blockSignals( false );
2885 mChangeColorButton->blockSignals( true );
2886 mChangeColorButton->setColor( mLayer->svgFillColor() );
2887 mChangeColorButton->blockSignals( false );
2888 mChangeStrokeColorButton->blockSignals( true );
2889 mChangeStrokeColorButton->setColor( mLayer->svgStrokeColor() );
2890 mChangeStrokeColorButton->blockSignals( false );
2891 mStrokeWidthSpinBox->blockSignals( true );
2892 mStrokeWidthSpinBox->setValue( mLayer->svgStrokeWidth() );
2893 mStrokeWidthSpinBox->blockSignals( false );
2894 }
2895 updateParamGui( false );
2896
2902
2903 registerDataDefinedButton( mSvgSelectorWidget->sourceLineEdit()->propertyOverrideToolButton(), QgsSymbolLayer::Property::File );
2904}
2905
2910
2912{
2914 mSvgSelectorWidget->sourceLineEdit()->setMessageBar( context.messageBar() );
2915}
2916
2917void QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged( double d )
2918{
2919 if ( mLayer )
2920 {
2921 mLayer->setPatternWidth( d );
2922 emit changed();
2923 }
2924}
2925
2926void QgsSVGFillSymbolLayerWidget::svgSourceChanged( const QString &text )
2927{
2928 if ( !mLayer )
2929 {
2930 return;
2931 }
2932
2933 mLayer->setSvgFilePath( text );
2935 emit changed();
2936}
2937
2938void QgsSVGFillSymbolLayerWidget::setFile( const QString &name )
2939{
2940 mLayer->setSvgFilePath( name );
2941 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2942
2944 emit changed();
2945}
2946
2947void QgsSVGFillSymbolLayerWidget::setSvgParameters( const QMap<QString, QgsProperty> &parameters )
2948{
2949 mLayer->setParameters( parameters );
2950 whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2951
2953 emit changed();
2954}
2955
2956
2957void QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
2958{
2959 if ( mLayer )
2960 {
2961 mLayer->setAngle( d );
2962 emit changed();
2963 }
2964}
2965
2967{
2968 //activate gui for svg parameters only if supported by the svg file
2969 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2970 QColor defaultFill, defaultStroke;
2971 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2972 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2973 QgsApplication::svgCache()->containsParams( mSvgSelectorWidget->sourceLineEdit()->source(), hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasStrokeParam, hasDefaultStrokeColor, defaultStroke, hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth, hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2974 if ( resetValues )
2975 {
2976 QColor fill = mChangeColorButton->color();
2977 const double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2978 if ( hasDefaultFillColor )
2979 {
2980 fill = defaultFill;
2981 }
2982 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
2983 mChangeColorButton->setColor( fill );
2984 }
2985 mChangeColorButton->setEnabled( hasFillParam );
2986 mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2987 if ( resetValues )
2988 {
2989 QColor stroke = mChangeStrokeColorButton->color();
2990 const double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2991 if ( hasDefaultStrokeColor )
2992 {
2993 stroke = defaultStroke;
2994 }
2995 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
2996 mChangeStrokeColorButton->setColor( stroke );
2997 }
2998 mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2999 mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
3000 if ( hasDefaultStrokeWidth && resetValues )
3001 {
3002 mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
3003 }
3004 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
3005}
3006
3007void QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
3008{
3009 if ( !mLayer )
3010 {
3011 return;
3012 }
3013
3014 mLayer->setSvgFillColor( color );
3015 emit changed();
3016}
3017
3018void QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
3019{
3020 if ( !mLayer )
3021 {
3022 return;
3023 }
3024
3025 mLayer->setSvgStrokeColor( color );
3026 emit changed();
3027}
3028
3029void QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
3030{
3031 if ( mLayer )
3032 {
3034 emit changed();
3035 }
3036}
3037
3038void QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed()
3039{
3040 if ( mLayer )
3041 {
3042 mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
3043 mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
3044 emit changed();
3045 }
3046}
3047
3048void QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed()
3049{
3050 if ( mLayer )
3051 {
3052 mLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnitWidget->unit() );
3053 mLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthUnitWidget->getMapUnitScale() );
3054 emit changed();
3055 }
3056}
3057
3059
3061 : QgsSymbolLayerWidget( parent, vl )
3062{
3063 setupUi( this );
3064 connect( mAngleSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged );
3065 connect( mDistanceSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged );
3066 connect( mOffsetSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged );
3067 connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed );
3068 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed );
3071 mOffsetSpinBox->setClearValue( 0 );
3072 mAngleSpinBox->setClearValue( 0 );
3073
3074 mCoordinateReferenceComboBox->addItem( tr( "Align Pattern to Feature" ), static_cast<int>( Qgis::SymbolCoordinateReference::Feature ) );
3075 mCoordinateReferenceComboBox->addItem( tr( "Align Pattern to Map Extent" ), static_cast<int>( Qgis::SymbolCoordinateReference::Viewport ) );
3076 connect( mCoordinateReferenceComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=] {
3077 if ( mLayer )
3078 {
3079 mLayer->setCoordinateReference( static_cast<Qgis::SymbolCoordinateReference>( mCoordinateReferenceComboBox->currentData().toInt() ) );
3080 emit changed();
3081 }
3082 } );
3083
3084 mClipModeComboBox->addItem( tr( "Clip During Render Only" ), static_cast<int>( Qgis::LineClipMode::ClipPainterOnly ) );
3085 mClipModeComboBox->addItem( tr( "Clip Lines Before Render" ), static_cast<int>( Qgis::LineClipMode::ClipToIntersection ) );
3086 mClipModeComboBox->addItem( tr( "No Clipping" ), static_cast<int>( Qgis::LineClipMode::NoClipping ) );
3087 connect( mClipModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=] {
3088 if ( mLayer )
3089 {
3090 mLayer->setClipMode( static_cast<Qgis::LineClipMode>( mClipModeComboBox->currentData().toInt() ) );
3091 emit changed();
3092 }
3093 } );
3094}
3095
3097{
3098 if ( layer->layerType() != QLatin1String( "LinePatternFill" ) )
3099 {
3100 return;
3101 }
3102
3103 QgsLinePatternFillSymbolLayer *patternLayer = static_cast<QgsLinePatternFillSymbolLayer *>( layer );
3104 if ( patternLayer )
3105 {
3106 mLayer = patternLayer;
3107 whileBlocking( mAngleSpinBox )->setValue( mLayer->lineAngle() );
3108 whileBlocking( mDistanceSpinBox )->setValue( mLayer->distance() );
3109 whileBlocking( mOffsetSpinBox )->setValue( mLayer->offset() );
3110
3111 //units
3112 mDistanceUnitWidget->blockSignals( true );
3113 mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
3114 mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
3115 mDistanceUnitWidget->blockSignals( false );
3116 mOffsetUnitWidget->blockSignals( true );
3117 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3118 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3119 mOffsetUnitWidget->blockSignals( false );
3120
3121 whileBlocking( mCoordinateReferenceComboBox )->setCurrentIndex( mCoordinateReferenceComboBox->findData( static_cast<int>( mLayer->coordinateReference() ) ) );
3122
3123 whileBlocking( mClipModeComboBox )->setCurrentIndex( mClipModeComboBox->findData( static_cast<int>( mLayer->clipMode() ) ) );
3124 }
3125
3130}
3131
3136
3137void QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged( double d )
3138{
3139 if ( mLayer )
3140 {
3141 mLayer->setLineAngle( d );
3142 emit changed();
3143 }
3144}
3145
3146void QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged( double d )
3147{
3148 if ( mLayer )
3149 {
3150 mLayer->setDistance( d );
3151 emit changed();
3152 }
3153}
3154
3155void QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged( double d )
3156{
3157 if ( mLayer )
3158 {
3159 mLayer->setOffset( d );
3160 emit changed();
3161 }
3162}
3163
3164void QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed()
3165{
3166 if ( mLayer )
3167 {
3168 mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
3169 mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
3170 emit changed();
3171 }
3172}
3173
3174void QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed()
3175{
3176 if ( mLayer )
3177 {
3178 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3179 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3180 emit changed();
3181 }
3182}
3183
3185
3187 : QgsSymbolLayerWidget( parent, vl )
3188{
3189 setupUi( this );
3190 connect( mHorizontalDistanceSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged );
3191 connect( mVerticalDistanceSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged );
3192 connect( mHorizontalDisplacementSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged );
3193 connect( mVerticalDisplacementSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged );
3194 connect( mHorizontalOffsetSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged );
3195 connect( mVerticalOffsetSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged );
3196 connect( mHorizontalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed );
3197 connect( mVerticalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed );
3198 connect( mHorizontalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed );
3199 connect( mVerticalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed );
3200 connect( mHorizontalOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed );
3201 connect( mVerticalOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed );
3208
3209 mClipModeComboBox->addItem( tr( "Clip to Shape" ), static_cast<int>( Qgis::MarkerClipMode::Shape ) );
3210 mClipModeComboBox->addItem( tr( "Marker Centroid Within Shape" ), static_cast<int>( Qgis::MarkerClipMode::CentroidWithin ) );
3211 mClipModeComboBox->addItem( tr( "Marker Completely Within Shape" ), static_cast<int>( Qgis::MarkerClipMode::CompletelyWithin ) );
3212 mClipModeComboBox->addItem( tr( "No Clipping" ), static_cast<int>( Qgis::MarkerClipMode::NoClipping ) );
3213 connect( mClipModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=] {
3214 if ( mLayer )
3215 {
3216 mLayer->setClipMode( static_cast<Qgis::MarkerClipMode>( mClipModeComboBox->currentData().toInt() ) );
3217 emit changed();
3218 }
3219 } );
3220
3221 mCoordinateReferenceComboBox->addItem( tr( "Align Pattern to Feature" ), static_cast<int>( Qgis::SymbolCoordinateReference::Feature ) );
3222 mCoordinateReferenceComboBox->addItem( tr( "Align Pattern to Map Extent" ), static_cast<int>( Qgis::SymbolCoordinateReference::Viewport ) );
3223 connect( mCoordinateReferenceComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=] {
3224 if ( mLayer )
3225 {
3226 mLayer->setCoordinateReference( static_cast<Qgis::SymbolCoordinateReference>( mCoordinateReferenceComboBox->currentData().toInt() ) );
3227 emit changed();
3228 }
3229 } );
3230
3231 mSeedSpinBox->setShowClearButton( true );
3232 mSeedSpinBox->setClearValue( 0 );
3233 mRandomXSpinBox->setClearValue( 0 );
3234 mRandomYSpinBox->setClearValue( 0 );
3235
3238 connect( mRandomXSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double d ) {
3239 if ( mLayer )
3240 {
3242 emit changed();
3243 }
3244 } );
3245 connect( mRandomYSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double d ) {
3246 if ( mLayer )
3247 {
3249 emit changed();
3250 }
3251 } );
3252 connect( mRandomXOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
3253 if ( mLayer )
3254 {
3255 mLayer->setRandomDeviationXUnit( mRandomXOffsetUnitWidget->unit() );
3256 mLayer->setRandomDeviationXMapUnitScale( mRandomXOffsetUnitWidget->getMapUnitScale() );
3257 emit changed();
3258 }
3259 } );
3260 connect( mRandomYOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
3261 if ( mLayer )
3262 {
3263 mLayer->setRandomDeviationYUnit( mRandomYOffsetUnitWidget->unit() );
3264 mLayer->setRandomDeviationYMapUnitScale( mRandomYOffsetUnitWidget->getMapUnitScale() );
3265 emit changed();
3266 }
3267 } );
3268 connect( mSeedSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [=]( int v ) {
3269 if ( mLayer )
3270 {
3271 mLayer->setSeed( v );
3272 emit changed();
3273 }
3274 } );
3275
3276 mAngleSpinBox->setShowClearButton( true );
3277 mAngleSpinBox->setClearValue( 0 );
3278 connect( mAngleSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double d ) {
3279 if ( mLayer )
3280 {
3281 mLayer->setAngle( d );
3282 emit changed();
3283 }
3284 } );
3285}
3286
3288{
3289 if ( !layer || layer->layerType() != QLatin1String( "PointPatternFill" ) )
3290 {
3291 return;
3292 }
3293
3294 mLayer = static_cast<QgsPointPatternFillSymbolLayer *>( layer );
3295 whileBlocking( mHorizontalDistanceSpinBox )->setValue( mLayer->distanceX() );
3296 whileBlocking( mVerticalDistanceSpinBox )->setValue( mLayer->distanceY() );
3297 whileBlocking( mHorizontalDisplacementSpinBox )->setValue( mLayer->displacementX() );
3298 whileBlocking( mVerticalDisplacementSpinBox )->setValue( mLayer->displacementY() );
3299 whileBlocking( mHorizontalOffsetSpinBox )->setValue( mLayer->offsetX() );
3300 whileBlocking( mVerticalOffsetSpinBox )->setValue( mLayer->offsetY() );
3301 whileBlocking( mAngleSpinBox )->setValue( mLayer->angle() );
3302
3303 mHorizontalDistanceUnitWidget->blockSignals( true );
3304 mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
3305 mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
3306 mHorizontalDistanceUnitWidget->blockSignals( false );
3307 mVerticalDistanceUnitWidget->blockSignals( true );
3308 mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
3309 mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
3310 mVerticalDistanceUnitWidget->blockSignals( false );
3311 mHorizontalDisplacementUnitWidget->blockSignals( true );
3312 mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
3313 mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
3314 mHorizontalDisplacementUnitWidget->blockSignals( false );
3315 mVerticalDisplacementUnitWidget->blockSignals( true );
3316 mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
3317 mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
3318 mVerticalDisplacementUnitWidget->blockSignals( false );
3319 mHorizontalOffsetUnitWidget->blockSignals( true );
3320 mHorizontalOffsetUnitWidget->setUnit( mLayer->offsetXUnit() );
3321 mHorizontalOffsetUnitWidget->setMapUnitScale( mLayer->offsetXMapUnitScale() );
3322 mHorizontalOffsetUnitWidget->blockSignals( false );
3323 mVerticalOffsetUnitWidget->blockSignals( true );
3324 mVerticalOffsetUnitWidget->setUnit( mLayer->offsetYUnit() );
3325 mVerticalOffsetUnitWidget->setMapUnitScale( mLayer->offsetYMapUnitScale() );
3326 mVerticalOffsetUnitWidget->blockSignals( false );
3327
3328 whileBlocking( mClipModeComboBox )->setCurrentIndex( mClipModeComboBox->findData( static_cast<int>( mLayer->clipMode() ) ) );
3329 whileBlocking( mCoordinateReferenceComboBox )->setCurrentIndex( mCoordinateReferenceComboBox->findData( static_cast<int>( mLayer->coordinateReference() ) ) );
3330
3331 whileBlocking( mRandomXSpinBox )->setValue( mLayer->maximumRandomDeviationX() );
3332 whileBlocking( mRandomYSpinBox )->setValue( mLayer->maximumRandomDeviationY() );
3333 whileBlocking( mRandomXOffsetUnitWidget )->setUnit( mLayer->randomDeviationXUnit() );
3334 whileBlocking( mRandomXOffsetUnitWidget )->setMapUnitScale( mLayer->randomDeviationXMapUnitScale() );
3335 whileBlocking( mRandomYOffsetUnitWidget )->setUnit( mLayer->randomDeviationYUnit() );
3336 whileBlocking( mRandomYOffsetUnitWidget )->setMapUnitScale( mLayer->randomDeviationYMapUnitScale() );
3337 whileBlocking( mSeedSpinBox )->setValue( mLayer->seed() );
3338
3351}
3352
3357
3358void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged( double d )
3359{
3360 if ( mLayer )
3361 {
3362 mLayer->setDistanceX( d );
3363 emit changed();
3364 }
3365}
3366
3367void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged( double d )
3368{
3369 if ( mLayer )
3370 {
3371 mLayer->setDistanceY( d );
3372 emit changed();
3373 }
3374}
3375
3376void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged( double d )
3377{
3378 if ( mLayer )
3379 {
3381 emit changed();
3382 }
3383}
3384
3385void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged( double d )
3386{
3387 if ( mLayer )
3388 {
3390 emit changed();
3391 }
3392}
3393
3394void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged( double d )
3395{
3396 if ( mLayer )
3397 {
3398 mLayer->setOffsetX( d );
3399 emit changed();
3400 }
3401}
3402
3403void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged( double d )
3404{
3405 if ( mLayer )
3406 {
3407 mLayer->setOffsetY( d );
3408 emit changed();
3409 }
3410}
3411
3412void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed()
3413{
3414 if ( mLayer )
3415 {
3416 mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
3417 mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
3418 emit changed();
3419 }
3420}
3421
3422void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed()
3423{
3424 if ( mLayer )
3425 {
3426 mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
3427 mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
3428 emit changed();
3429 }
3430}
3431
3432void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed()
3433{
3434 if ( mLayer )
3435 {
3436 mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
3437 mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
3438 emit changed();
3439 }
3440}
3441
3442void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed()
3443{
3444 if ( mLayer )
3445 {
3446 mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
3447 mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
3448 emit changed();
3449 }
3450}
3451
3452void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed()
3453{
3454 if ( mLayer )
3455 {
3456 mLayer->setOffsetXUnit( mHorizontalOffsetUnitWidget->unit() );
3457 mLayer->setOffsetXMapUnitScale( mHorizontalOffsetUnitWidget->getMapUnitScale() );
3458 emit changed();
3459 }
3460}
3461
3462void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed()
3463{
3464 if ( mLayer )
3465 {
3466 mLayer->setOffsetYUnit( mVerticalOffsetUnitWidget->unit() );
3467 mLayer->setOffsetYMapUnitScale( mVerticalOffsetUnitWidget->getMapUnitScale() );
3468 emit changed();
3469 }
3470}
3471
3473
3475 : QgsSymbolLayerWidget( parent, vl )
3476{
3477 mLayer = nullptr;
3478
3479 setupUi( this );
3480
3481 mHorizontalAnchorComboBox->addItem( tr( "Left" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Left ) );
3482 mHorizontalAnchorComboBox->addItem( tr( "Horizontal Center" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Center ) );
3483 mHorizontalAnchorComboBox->addItem( tr( "Right" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Right ) );
3484
3485 mVerticalAnchorComboBox->addItem( tr( "Top" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Top ) );
3486 mVerticalAnchorComboBox->addItem( tr( "Vertical Center" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Center ) );
3487 mVerticalAnchorComboBox->addItem( tr( "Bottom on Baseline" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Baseline ) );
3488 mVerticalAnchorComboBox->addItem( tr( "Bottom" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Bottom ) );
3489
3490 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
3491 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
3492 connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
3493 connect( mStrokeWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
3494 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3495 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3499
3501 scrollArea->setWidget( widgetChar );
3502 scrollArea->setVerticalOnly( true );
3503
3504 btnColor->setAllowOpacity( true );
3505 btnColor->setColorDialogTitle( tr( "Select Symbol Fill Color" ) );
3506 btnColor->setContext( QStringLiteral( "symbology" ) );
3507 btnStrokeColor->setAllowOpacity( true );
3508 btnStrokeColor->setColorDialogTitle( tr( "Select Symbol Stroke Color" ) );
3509 btnStrokeColor->setContext( QStringLiteral( "symbology" ) );
3510
3511 mColorDDBtn->registerLinkedWidget( btnColor );
3512 mStrokeColorDDBtn->registerLinkedWidget( btnStrokeColor );
3513
3514 spinOffsetX->setClearValue( 0.0 );
3515 spinOffsetY->setClearValue( 0.0 );
3516 spinAngle->setClearValue( 0.0 );
3517
3518 //make a temporary symbol for the size assistant preview
3519 mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
3520
3521 if ( vectorLayer() )
3522 mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
3523
3524 connect( cboFont, &QFontComboBox::currentFontChanged, this, &QgsFontMarkerSymbolLayerWidget::setFontFamily );
3525 connect( mFontStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged );
3526 connect( spinSize, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setSize );
3527 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3530 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3531 connect( spinAngle, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setAngle );
3532 connect( spinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3533 connect( spinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3535 connect( mCharLineEdit, &QLineEdit::textChanged, this, &QgsFontMarkerSymbolLayerWidget::setCharacterFromText );
3536
3537 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol );
3538}
3539
3541
3543{
3544 if ( layer->layerType() != QLatin1String( "FontMarker" ) )
3545 return;
3546
3547 // layer type is correct, we can do the cast
3548 mLayer = static_cast<QgsFontMarkerSymbolLayer *>( layer );
3549
3551 mRefFont.setStyleName( QgsFontUtils::translateNamedStyle( mLayer->fontStyle() ) );
3552
3553 mFontStyleComboBox->blockSignals( true );
3554 populateFontStyleComboBox();
3555 mFontStyleComboBox->blockSignals( false );
3556
3557 // set values
3558 whileBlocking( cboFont )->setCurrentFont( mRefFont );
3559 whileBlocking( spinSize )->setValue( mLayer->size() );
3560 whileBlocking( btnColor )->setColor( mLayer->color() );
3561 whileBlocking( btnStrokeColor )->setColor( mLayer->strokeColor() );
3562 whileBlocking( mStrokeWidthSpinBox )->setValue( mLayer->strokeWidth() );
3563 whileBlocking( spinAngle )->setValue( mLayer->angle() );
3564
3565 widgetChar->blockSignals( true );
3566 widgetChar->setFont( mRefFont );
3567 if ( mLayer->character().length() == 1 )
3568 {
3569 widgetChar->setCharacter( mLayer->character().at( 0 ) );
3570 }
3571 widgetChar->blockSignals( false );
3572 whileBlocking( mCharLineEdit )->setText( mLayer->character() );
3573 mCharPreview->setFont( mRefFont );
3574
3575 //block
3576 whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
3577 whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
3578
3579 mSizeUnitWidget->blockSignals( true );
3580 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
3581 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
3582 mSizeUnitWidget->blockSignals( false );
3583
3584 mStrokeWidthUnitWidget->blockSignals( true );
3585 mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
3586 mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
3587 mStrokeWidthUnitWidget->blockSignals( false );
3588
3589 mOffsetUnitWidget->blockSignals( true );
3590 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3591 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3592 mOffsetUnitWidget->blockSignals( false );
3593
3594 whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
3595
3596 //anchor points
3597 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue( mLayer->horizontalAnchorPoint() ) ) );
3598 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue( mLayer->verticalAnchorPoint() ) ) );
3599
3612
3613 updateAssistantSymbol();
3614}
3615
3620
3622{
3623 if ( mLayer )
3624 {
3625 mLayer->setFontFamily( font.family() );
3626 QgsFontUtils::setFontFamily( mRefFont, font.family() );
3627 widgetChar->setFont( mRefFont );
3628 mCharPreview->setFont( mRefFont );
3629 populateFontStyleComboBox();
3630 emit changed();
3631 }
3632}
3633
3634void QgsFontMarkerSymbolLayerWidget::setFontStyle( const QString &style )
3635{
3636 if ( mLayer )
3637 {
3638 QgsFontUtils::updateFontViaStyle( mRefFont, style );
3640 widgetChar->setFont( mRefFont );
3641 mCharPreview->setFont( mRefFont );
3642 emit changed();
3643 }
3644}
3645
3647{
3648 mLayer->setColor( color );
3649 emit changed();
3650}
3651
3653{
3654 mLayer->setStrokeColor( color );
3655 emit changed();
3656}
3657
3659{
3660 mLayer->setSize( size );
3661 //widgetChar->updateSize(size);
3662 emit changed();
3663}
3664
3666{
3667 mLayer->setAngle( angle );
3668 emit changed();
3669}
3670
3672{
3673 mCharPreview->setText( text );
3674
3675 if ( text.isEmpty() )
3676 return;
3677
3678 // take the last character of a string for a better experience when users cycle through several characters on their keyboard
3679 QString character = text;
3680 if ( text.contains( QRegularExpression( QStringLiteral( "^0x[0-9a-fA-F]{1,4}$" ) ) ) )
3681 {
3682 bool ok = false;
3683 const unsigned int value = text.toUInt( &ok, 0 );
3684 if ( ok )
3685 {
3686 character = QChar( value );
3687 mCharPreview->setText( character );
3688 }
3689 }
3690
3691 if ( character != mLayer->character() )
3692 {
3693 mLayer->setCharacter( character );
3694 if ( mLayer->character().length() == 1 )
3695 {
3696 whileBlocking( widgetChar )->setCharacter( mLayer->character().at( 0 ) );
3697 }
3698 else
3699 {
3701 }
3702 emit changed();
3703 }
3704}
3705
3707{
3708 if ( mLayer->character().length() > 1 || QGuiApplication::keyboardModifiers() & Qt::ControlModifier )
3709 {
3710 mCharLineEdit->insert( chr );
3711 return;
3712 }
3713
3714 mLayer->setCharacter( chr );
3715 whileBlocking( mCharLineEdit )->setText( chr );
3716 mCharPreview->setText( chr );
3717 emit changed();
3718}
3719
3720void QgsFontMarkerSymbolLayerWidget::setOffset()
3721{
3722 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
3723 emit changed();
3724}
3725
3726void QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged()
3727{
3728 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
3729 emit changed();
3730}
3731
3732void QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
3733{
3734 if ( mLayer )
3735 {
3736 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
3737 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3738 emit changed();
3739 }
3740}
3741
3742void QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
3743{
3744 if ( mLayer )
3745 {
3746 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3747 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3748 emit changed();
3749 }
3750}
3751
3752void QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
3753{
3754 if ( mLayer )
3755 {
3756 mLayer->setStrokeWidthUnit( mSizeUnitWidget->unit() );
3757 mLayer->setStrokeWidthMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3758 emit changed();
3759 }
3760}
3761
3762void QgsFontMarkerSymbolLayerWidget::populateFontStyleComboBox()
3763{
3764 mFontStyleComboBox->clear();
3765 const QStringList styles = mFontDB.styles( mRefFont.family() );
3766 const auto constStyles = styles;
3767 for ( const QString &style : constStyles )
3768 {
3769 mFontStyleComboBox->addItem( style );
3770 }
3771
3772 QString targetStyle = mFontDB.styleString( mRefFont );
3773 if ( !styles.contains( targetStyle ) )
3774 {
3775 const QFont f = QgsFontUtils::createFont( mRefFont.family() );
3776 targetStyle = QFontInfo( f ).styleName();
3777 mRefFont.setStyleName( targetStyle );
3778 }
3779 int curIndx = 0;
3780 const int stylIndx = mFontStyleComboBox->findText( targetStyle );
3781 if ( stylIndx > -1 )
3782 {
3783 curIndx = stylIndx;
3784 }
3785
3786 mFontStyleComboBox->setCurrentIndex( curIndx );
3787}
3788
3789void QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged( int index )
3790{
3791 Q_UNUSED( index );
3792 setFontStyle( mFontStyleComboBox->currentText() );
3793}
3794
3795void QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int )
3796{
3797 if ( mLayer )
3798 {
3799 mLayer->setHorizontalAnchorPoint( mHorizontalAnchorComboBox->currentData().value< Qgis::HorizontalAnchorPoint >() );
3800 emit changed();
3801 }
3802}
3803
3804void QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int )
3805{
3806 if ( mLayer )
3807 {
3808 mLayer->setVerticalAnchorPoint( mVerticalAnchorComboBox->currentData().value< Qgis::VerticalAnchorPoint >() );
3809 emit changed();
3810 }
3811}
3812
3813void QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
3814{
3815 if ( mLayer )
3816 {
3817 mLayer->setStrokeWidth( d );
3818 emit changed();
3819 }
3820}
3821
3822void QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol()
3823{
3824 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
3825 {
3826 mAssistantPreviewSymbol->deleteSymbolLayer( i );
3827 }
3828 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
3830 if ( ddSize )
3831 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
3832}
3833
3835
3836
3838 : QgsSymbolLayerWidget( parent, vl )
3839{
3840 mLayer = nullptr;
3841
3842 setupUi( this );
3843 connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
3844 connect( mDrawAllPartsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged );
3845 connect( mClipPointsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged );
3846 connect( mClipOnCurrentPartOnlyCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged );
3847}
3848
3850{
3851 if ( layer->layerType() != QLatin1String( "CentroidFill" ) )
3852 return;
3853
3854 // layer type is correct, we can do the cast
3855 mLayer = static_cast<QgsCentroidFillSymbolLayer *>( layer );
3856
3857 // set values
3858 whileBlocking( mDrawInsideCheckBox )->setChecked( mLayer->pointOnSurface() );
3859 whileBlocking( mDrawAllPartsCheckBox )->setChecked( mLayer->pointOnAllParts() );
3860 whileBlocking( mClipPointsCheckBox )->setChecked( mLayer->clipPoints() );
3861 whileBlocking( mClipOnCurrentPartOnlyCheckBox )->setChecked( mLayer->clipOnCurrentPartOnly() );
3862}
3863
3868
3869void QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
3870{
3871 mLayer->setPointOnSurface( state == Qt::Checked );
3872 emit changed();
3873}
3874
3875void QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged( int state )
3876{
3877 mLayer->setPointOnAllParts( state == Qt::Checked );
3878 emit changed();
3879}
3880
3881void QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged( int state )
3882{
3883 mLayer->setClipPoints( state == Qt::Checked );
3884 emit changed();
3885}
3886
3887void QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged( int state )
3888{
3889 mLayer->setClipOnCurrentPartOnly( state == Qt::Checked );
3890 emit changed();
3891}
3892
3894
3896 : QgsSymbolLayerWidget( parent, vl )
3897{
3898 mLayer = nullptr;
3899
3900 setupUi( this );
3901
3902 mHorizontalAnchorComboBox->addItem( tr( "Left" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Left ) );
3903 mHorizontalAnchorComboBox->addItem( tr( "Horizontal Center" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Center ) );
3904 mHorizontalAnchorComboBox->addItem( tr( "Right" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Right ) );
3905
3906 mVerticalAnchorComboBox->addItem( tr( "Top" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Top ) );
3907 mVerticalAnchorComboBox->addItem( tr( "Vertical Center" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Center ) );
3908 mVerticalAnchorComboBox->addItem( tr( "Bottom" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Bottom ) );
3909
3910 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
3911
3912 connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterMarkerSymbolLayerWidget::imageSourceChanged );
3913 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
3914 connect( mRotationSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setAngle );
3915 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
3916 connect( mWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setWidth );
3917 connect( mHeightSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setHeight );
3918 connect( mLockAspectRatio, static_cast<void ( QgsRatioLockButton::* )( bool )>( &QgsRatioLockButton::lockChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setLockAspectRatio );
3919
3922
3923 mSpinOffsetX->setClearValue( 0.0 );
3924 mSpinOffsetY->setClearValue( 0.0 );
3925 mRotationSpinBox->setClearValue( 0.0 );
3926
3927 connect( mSpinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3928 connect( mSpinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3929 connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterMarkerSymbolLayerWidget::setOpacity );
3930
3931 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3932 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3933}
3934
3936{
3937 if ( !layer )
3938 {
3939 return;
3940 }
3941
3942 if ( layer->layerType() != QLatin1String( "RasterMarker" ) )
3943 return;
3944
3945 // layer type is correct, we can do the cast
3946 mLayer = static_cast<QgsRasterMarkerSymbolLayer *>( layer );
3947
3948 // set values
3949 whileBlocking( mImageSourceLineEdit )->setSource( mLayer->path() );
3950
3951 whileBlocking( mWidthSpinBox )->setValue( mLayer->size() );
3952 const bool preservedAspectRatio = mLayer->preservedAspectRatio();
3953 mHeightSpinBox->blockSignals( true );
3954 if ( preservedAspectRatio )
3955 {
3956 mHeightSpinBox->setValue( mLayer->size() );
3957 }
3958 else
3959 {
3960 mHeightSpinBox->setValue( mLayer->size() * mLayer->fixedAspectRatio() );
3961 }
3962 mHeightSpinBox->setEnabled( mLayer->defaultAspectRatio() > 0.0 );
3963 mHeightSpinBox->blockSignals( false );
3964 whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
3965
3966 whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
3967 whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
3968
3969 whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
3970 whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
3971
3972 mSizeUnitWidget->blockSignals( true );
3973 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
3974 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
3975 mSizeUnitWidget->blockSignals( false );
3976 mOffsetUnitWidget->blockSignals( true );
3977 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3978 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3979 mOffsetUnitWidget->blockSignals( false );
3980
3981 //anchor points
3982 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue( mLayer->horizontalAnchorPoint() ) ) );
3983 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue( mLayer->verticalAnchorPoint() ) ) );
3984
3993
3994 updatePreviewImage();
3995}
3996
4001
4003{
4005 mImageSourceLineEdit->setMessageBar( context.messageBar() );
4006}
4007
4008void QgsRasterMarkerSymbolLayerWidget::imageSourceChanged( const QString &text )
4009{
4010 mLayer->setPath( text );
4011 updatePreviewImage();
4012 emit changed();
4013}
4014
4015void QgsRasterMarkerSymbolLayerWidget::updatePreviewImage()
4016{
4017 bool fitsInCache = false;
4018 const QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->path(), QSize( 150, 150 ), true, 1.0, fitsInCache );
4019 if ( image.isNull() )
4020 {
4021 mLabelImagePreview->setPixmap( QPixmap() );
4022 return;
4023 }
4024
4025 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4026 previewImage.fill( Qt::transparent );
4027 const QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4028 QPainter p;
4029 p.begin( &previewImage );
4030 //draw a checkerboard background
4031 uchar pixDataRGB[] = { 150, 150, 150, 150, 100, 100, 100, 150, 100, 100, 100, 150, 150, 150, 150, 150 };
4032 const QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4033 const QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4034 QBrush checkerBrush;
4035 checkerBrush.setTexture( pix );
4036 p.fillRect( imageRect, checkerBrush );
4037
4038 if ( mLayer->opacity() < 1.0 )
4039 {
4040 p.setOpacity( mLayer->opacity() );
4041 }
4042
4043 p.drawImage( imageRect.left(), imageRect.top(), image );
4044 p.end();
4045 mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4046}
4047
4048void QgsRasterMarkerSymbolLayerWidget::setWidth()
4049{
4050 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4051 double fixedAspectRatio = 0.0;
4052 mHeightSpinBox->blockSignals( true );
4053 if ( defaultAspectRatio <= 0.0 )
4054 {
4055 mHeightSpinBox->setValue( mWidthSpinBox->value() );
4056 }
4057 else if ( mLockAspectRatio->locked() )
4058 {
4059 mHeightSpinBox->setValue( mWidthSpinBox->value() * defaultAspectRatio );
4060 }
4061 else
4062 {
4063 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4064 }
4065 mHeightSpinBox->blockSignals( false );
4066 mLayer->setSize( mWidthSpinBox->value() );
4067 mLayer->setFixedAspectRatio( fixedAspectRatio );
4068 emit changed();
4069}
4070
4071void QgsRasterMarkerSymbolLayerWidget::setHeight()
4072{
4073 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4074 double fixedAspectRatio = 0.0;
4075 mWidthSpinBox->blockSignals( true );
4076 if ( defaultAspectRatio <= 0.0 )
4077 {
4078 mWidthSpinBox->setValue( mHeightSpinBox->value() );
4079 }
4080 else if ( mLockAspectRatio->locked() )
4081 {
4082 mWidthSpinBox->setValue( mHeightSpinBox->value() / defaultAspectRatio );
4083 }
4084 else
4085 {
4086 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4087 }
4088 mWidthSpinBox->blockSignals( false );
4089 mLayer->setSize( mWidthSpinBox->value() );
4090 mLayer->setFixedAspectRatio( fixedAspectRatio );
4091 emit changed();
4092}
4093
4094void QgsRasterMarkerSymbolLayerWidget::setLockAspectRatio( const bool locked )
4095{
4096 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4097 if ( defaultAspectRatio <= 0.0 )
4098 {
4099 whileBlocking( mLockAspectRatio )->setLocked( true );
4100 }
4101 else if ( locked )
4102 {
4104 setWidth();
4105 }
4106 else
4107 {
4108 mLayer->setFixedAspectRatio( mHeightSpinBox->value() / mWidthSpinBox->value() );
4109 }
4110}
4111
4112void QgsRasterMarkerSymbolLayerWidget::setAngle()
4113{
4114 mLayer->setAngle( mRotationSpinBox->value() );
4115 emit changed();
4116}
4117
4118void QgsRasterMarkerSymbolLayerWidget::setOpacity( double value )
4119{
4120 mLayer->setOpacity( value );
4121 emit changed();
4122 updatePreviewImage();
4123}
4124
4125void QgsRasterMarkerSymbolLayerWidget::setOffset()
4126{
4127 mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4128 emit changed();
4129}
4130
4131void QgsRasterMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
4132{
4133 if ( mLayer )
4134 {
4135 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
4136 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4137 emit changed();
4138 }
4139}
4140
4141void QgsRasterMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
4142{
4143 if ( mLayer )
4144 {
4145 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4146 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4147 emit changed();
4148 }
4149}
4150
4151void QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int )
4152{
4153 if ( mLayer )
4154 {
4155 mLayer->setHorizontalAnchorPoint( mHorizontalAnchorComboBox->currentData().value< Qgis::HorizontalAnchorPoint >() );
4156 emit changed();
4157 }
4158}
4159
4160void QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int )
4161{
4162 if ( mLayer )
4163 {
4164 mLayer->setVerticalAnchorPoint( mVerticalAnchorComboBox->currentData().value< Qgis::VerticalAnchorPoint >() );
4165 emit changed();
4166 }
4167}
4168
4169
4171
4173 : QgsSymbolLayerWidget( parent, vl )
4174{
4175 mLayer = nullptr;
4176
4177 setupUi( this );
4178
4179 mHorizontalAnchorComboBox->addItem( tr( "Left" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Left ) );
4180 mHorizontalAnchorComboBox->addItem( tr( "Horizontal Center" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Center ) );
4181 mHorizontalAnchorComboBox->addItem( tr( "Right" ), QVariant::fromValue( Qgis::HorizontalAnchorPoint::Right ) );
4182
4183 mVerticalAnchorComboBox->addItem( tr( "Top" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Top ) );
4184 mVerticalAnchorComboBox->addItem( tr( "Vertical Center" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Center ) );
4185 mVerticalAnchorComboBox->addItem( tr( "Bottom" ), QVariant::fromValue( Qgis::VerticalAnchorPoint::Bottom ) );
4186
4187 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastAnimatedMarkerImageDir" ) );
4188
4189 connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsAnimatedMarkerSymbolLayerWidget::imageSourceChanged );
4190 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsAnimatedMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
4191 connect( mRotationSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setAngle );
4192 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsAnimatedMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
4193 connect( mWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setWidth );
4194 connect( mHeightSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setHeight );
4195 connect( mLockAspectRatio, static_cast<void ( QgsRatioLockButton::* )( bool )>( &QgsRatioLockButton::lockChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setLockAspectRatio );
4196
4197 mFrameRateSpin->setClearValue( 10 );
4198 mFrameRateSpin->setShowClearButton( true );
4199 connect( mFrameRateSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) {
4200 mLayer->setFrameRate( value );
4201 emit changed();
4202 } );
4203
4206
4207 mSpinOffsetX->setClearValue( 0.0 );
4208 mSpinOffsetY->setClearValue( 0.0 );
4209 mRotationSpinBox->setClearValue( 0.0 );
4210
4211 connect( mSpinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setOffset );
4212 connect( mSpinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setOffset );
4213 connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsAnimatedMarkerSymbolLayerWidget::setOpacity );
4214
4215 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
4216 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
4217}
4218
4220{
4221 if ( !layer )
4222 {
4223 return;
4224 }
4225
4226 if ( layer->layerType() != QLatin1String( "AnimatedMarker" ) )
4227 return;
4228
4229 // layer type is correct, we can do the cast
4230 mLayer = static_cast<QgsAnimatedMarkerSymbolLayer *>( layer );
4231
4232 // set values
4233 whileBlocking( mImageSourceLineEdit )->setSource( mLayer->path() );
4234
4235 const double firstFrameTime = QgsApplication::imageCache()->nextFrameDelay( mLayer->path() );
4236 if ( firstFrameTime > 0 )
4237 {
4238 mFrameRateSpin->setClearValue( 1000 / firstFrameTime );
4239 }
4240 else
4241 {
4242 mFrameRateSpin->setClearValue( 10 );
4243 }
4244
4245 whileBlocking( mWidthSpinBox )->setValue( mLayer->size() );
4246 const bool preservedAspectRatio = mLayer->preservedAspectRatio();
4247 mHeightSpinBox->blockSignals( true );
4248 if ( preservedAspectRatio )
4249 {
4250 mHeightSpinBox->setValue( mLayer->size() );
4251 }
4252 else
4253 {
4254 mHeightSpinBox->setValue( mLayer->size() * mLayer->fixedAspectRatio() );
4255 }
4256 mHeightSpinBox->setEnabled( mLayer->defaultAspectRatio() > 0.0 );
4257 mHeightSpinBox->blockSignals( false );
4258 whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
4259
4260 whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
4261 whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
4262
4263 whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
4264 whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
4265
4266 whileBlocking( mFrameRateSpin )->setValue( mLayer->frameRate() );
4267
4268 mSizeUnitWidget->blockSignals( true );
4269 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
4270 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
4271 mSizeUnitWidget->blockSignals( false );
4272 mOffsetUnitWidget->blockSignals( true );
4273 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
4274 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
4275 mOffsetUnitWidget->blockSignals( false );
4276
4277 //anchor points
4278 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue( mLayer->horizontalAnchorPoint() ) ) );
4279 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue( mLayer->verticalAnchorPoint() ) ) );
4280
4289
4290 updatePreviewImage();
4291}
4292
4297
4299{
4301 mImageSourceLineEdit->setMessageBar( context.messageBar() );
4302}
4303
4304void QgsAnimatedMarkerSymbolLayerWidget::imageSourceChanged( const QString &text )
4305{
4306 mLayer->setPath( text );
4307
4308 const double firstFrameTime = QgsApplication::imageCache()->nextFrameDelay( text );
4309 if ( firstFrameTime > 0 )
4310 {
4311 mFrameRateSpin->setClearValue( 1000 / firstFrameTime );
4312 }
4313 else
4314 {
4315 mFrameRateSpin->setClearValue( 10 );
4316 }
4317 updatePreviewImage();
4318 emit changed();
4319}
4320
4321void QgsAnimatedMarkerSymbolLayerWidget::updatePreviewImage()
4322{
4323 if ( mPreviewMovie )
4324 {
4325 mLabelImagePreview->setMovie( nullptr );
4326 mPreviewMovie->deleteLater();
4327 mPreviewMovie = nullptr;
4328 }
4329
4330 mPreviewMovie = new QMovie( mLayer->path(), QByteArray(), this );
4331 mPreviewMovie->setScaledSize( QSize( 150, 150 ) );
4332 mLabelImagePreview->setMovie( mPreviewMovie );
4333 mPreviewMovie->start();
4334}
4335
4336void QgsAnimatedMarkerSymbolLayerWidget::setWidth()
4337{
4338 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4339 double fixedAspectRatio = 0.0;
4340 mHeightSpinBox->blockSignals( true );
4341 if ( defaultAspectRatio <= 0.0 )
4342 {
4343 mHeightSpinBox->setValue( mWidthSpinBox->value() );
4344 }
4345 else if ( mLockAspectRatio->locked() )
4346 {
4347 mHeightSpinBox->setValue( mWidthSpinBox->value() * defaultAspectRatio );
4348 }
4349 else
4350 {
4351 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4352 }
4353 mHeightSpinBox->blockSignals( false );
4354 mLayer->setSize( mWidthSpinBox->value() );
4355 mLayer->setFixedAspectRatio( fixedAspectRatio );
4356 emit changed();
4357}
4358
4359void QgsAnimatedMarkerSymbolLayerWidget::setHeight()
4360{
4361 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4362 double fixedAspectRatio = 0.0;
4363 mWidthSpinBox->blockSignals( true );
4364 if ( defaultAspectRatio <= 0.0 )
4365 {
4366 mWidthSpinBox->setValue( mHeightSpinBox->value() );
4367 }
4368 else if ( mLockAspectRatio->locked() )
4369 {
4370 mWidthSpinBox->setValue( mHeightSpinBox->value() / defaultAspectRatio );
4371 }
4372 else
4373 {
4374 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4375 }
4376 mWidthSpinBox->blockSignals( false );
4377 mLayer->setSize( mWidthSpinBox->value() );
4378 mLayer->setFixedAspectRatio( fixedAspectRatio );
4379 emit changed();
4380}
4381
4382void QgsAnimatedMarkerSymbolLayerWidget::setLockAspectRatio( const bool locked )
4383{
4384 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4385 if ( defaultAspectRatio <= 0.0 )
4386 {
4387 whileBlocking( mLockAspectRatio )->setLocked( true );
4388 }
4389 else if ( locked )
4390 {
4392 setWidth();
4393 }
4394 else
4395 {
4396 mLayer->setFixedAspectRatio( mHeightSpinBox->value() / mWidthSpinBox->value() );
4397 }
4398}
4399
4400void QgsAnimatedMarkerSymbolLayerWidget::setAngle()
4401{
4402 mLayer->setAngle( mRotationSpinBox->value() );
4403 emit changed();
4404}
4405
4406void QgsAnimatedMarkerSymbolLayerWidget::setOpacity( double value )
4407{
4408 mLayer->setOpacity( value );
4409 emit changed();
4410 updatePreviewImage();
4411}
4412
4413void QgsAnimatedMarkerSymbolLayerWidget::setOffset()
4414{
4415 mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4416 emit changed();
4417}
4418
4419void QgsAnimatedMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
4420{
4421 if ( mLayer )
4422 {
4423 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
4424 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4425 emit changed();
4426 }
4427}
4428
4429void QgsAnimatedMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
4430{
4431 if ( mLayer )
4432 {
4433 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4434 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4435 emit changed();
4436 }
4437}
4438
4439void QgsAnimatedMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int )
4440{
4441 if ( mLayer )
4442 {
4443 mLayer->setHorizontalAnchorPoint( mHorizontalAnchorComboBox->currentData().value< Qgis::HorizontalAnchorPoint >() );
4444 emit changed();
4445 }
4446}
4447
4448void QgsAnimatedMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int )
4449{
4450 if ( mLayer )
4451 {
4452 mLayer->setVerticalAnchorPoint( mVerticalAnchorComboBox->currentData().value< Qgis::VerticalAnchorPoint >() );
4453 emit changed();
4454 }
4455}
4456
4458
4460 : QgsSymbolLayerWidget( parent, vl )
4461{
4462 mLayer = nullptr;
4463 setupUi( this );
4464
4465 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
4466 connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterFillSymbolLayerWidget::imageSourceChanged );
4467
4468 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed );
4469 connect( mRotationSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
4470
4471 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
4472 if ( !mLayer )
4473 {
4474 return;
4475 }
4476 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
4477 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4478 emit changed();
4479 } );
4480 connect( mWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=]( double d ) {
4481 if ( !mLayer )
4482 {
4483 return;
4484 }
4485 mLayer->setWidth( d );
4486 emit changed();
4487 } );
4488
4489 connect( mHeightSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=]( double d ) {
4490 if ( !mLayer )
4491 {
4492 return;
4493 }
4494 mLayer->setHeight( d );
4495 emit changed();
4496 } );
4497
4500
4501 mSpinOffsetX->setClearValue( 0.0 );
4502 mSpinOffsetY->setClearValue( 0.0 );
4503 mRotationSpinBox->setClearValue( 0.0 );
4504
4505 connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterFillSymbolLayerWidget::setCoordinateMode );
4506 connect( mSpinOffsetX, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4507 connect( mSpinOffsetY, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4508 connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterFillSymbolLayerWidget::opacityChanged );
4509}
4510
4511
4513{
4514 if ( !layer )
4515 {
4516 return;
4517 }
4518
4519 if ( layer->layerType() != QLatin1String( "RasterFill" ) )
4520 {
4521 return;
4522 }
4523
4524 mLayer = dynamic_cast<QgsRasterFillSymbolLayer *>( layer );
4525 if ( !mLayer )
4526 {
4527 return;
4528 }
4529
4530 whileBlocking( mImageSourceLineEdit )->setSource( mLayer->imageFilePath() );
4531
4532 cboCoordinateMode->blockSignals( true );
4533 switch ( mLayer->coordinateMode() )
4534 {
4536 cboCoordinateMode->setCurrentIndex( 1 );
4537 break;
4539 default:
4540 cboCoordinateMode->setCurrentIndex( 0 );
4541 break;
4542 }
4543 cboCoordinateMode->blockSignals( false );
4544 whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
4545 whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
4546
4547 whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
4548 whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
4549 mOffsetUnitWidget->blockSignals( true );
4550 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
4551 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
4552 mOffsetUnitWidget->blockSignals( false );
4553
4554 whileBlocking( mWidthSpinBox )->setValue( mLayer->width() );
4555 mSizeUnitWidget->blockSignals( true );
4556 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
4557 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
4558 mSizeUnitWidget->blockSignals( false );
4559
4560 whileBlocking( mHeightSpinBox )->setValue( mLayer->height() );
4561
4562 updatePreviewImage();
4563
4570}
4571
4576
4577void QgsRasterFillSymbolLayerWidget::imageSourceChanged( const QString &text )
4578{
4579 mLayer->setImageFilePath( text );
4580 updatePreviewImage();
4581 emit changed();
4582}
4583
4584void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
4585{
4586 switch ( index )
4587 {
4588 case 0:
4589 //feature coordinate mode
4591 break;
4592 case 1:
4593 //viewport coordinate mode
4595 break;
4596 }
4597
4598 emit changed();
4599}
4600
4601void QgsRasterFillSymbolLayerWidget::opacityChanged( double value )
4602{
4603 if ( !mLayer )
4604 {
4605 return;
4606 }
4607
4608 mLayer->setOpacity( value );
4609 emit changed();
4610 updatePreviewImage();
4611}
4612
4613void QgsRasterFillSymbolLayerWidget::offsetChanged()
4614{
4615 mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4616 emit changed();
4617}
4618
4619void QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed()
4620{
4621 if ( !mLayer )
4622 {
4623 return;
4624 }
4625 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4626 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4627 emit changed();
4628}
4629
4630void QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
4631{
4632 if ( mLayer )
4633 {
4634 mLayer->setAngle( d );
4635 emit changed();
4636 }
4637}
4638
4639void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
4640{
4641 bool fitsInCache = false;
4642 const QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->imageFilePath(), QSize( 150, 150 ), true, 1.0, fitsInCache );
4643 if ( image.isNull() )
4644 {
4645 mLabelImagePreview->setPixmap( QPixmap() );
4646 return;
4647 }
4648
4649 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4650 previewImage.fill( Qt::transparent );
4651 const QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4652 QPainter p;
4653 p.begin( &previewImage );
4654 //draw a checkerboard background
4655 uchar pixDataRGB[] = { 150, 150, 150, 150, 100, 100, 100, 150, 100, 100, 100, 150, 150, 150, 150, 150 };
4656 const QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4657 const QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4658 QBrush checkerBrush;
4659 checkerBrush.setTexture( pix );
4660 p.fillRect( imageRect, checkerBrush );
4661
4662 if ( mLayer->opacity() < 1.0 )
4663 {
4664 p.setOpacity( mLayer->opacity() );
4665 }
4666
4667 p.drawImage( imageRect.left(), imageRect.top(), image );
4668 p.end();
4669 mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4670}
4671
4672//
4673// QgsRasterLineSymbolLayerWidget
4674//
4675
4676
4678 : QgsSymbolLayerWidget( parent, vl )
4679{
4680 mLayer = nullptr;
4681 setupUi( this );
4682
4683 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
4684
4687
4688 connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
4689 if ( mLayer )
4690 {
4691 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
4692 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
4693 emit changed();
4694 }
4695 } );
4696
4697 connect( spinWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=] {
4698 if ( mLayer )
4699 {
4700 mLayer->setWidth( spinWidth->value() );
4701 emit changed();
4702 }
4703 } );
4704
4705 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
4706 if ( mLayer )
4707 {
4708 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4709 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4710 emit changed();
4711 }
4712 } );
4713
4714
4715 spinOffset->setClearValue( 0.0 );
4716 connect( spinOffset, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double val ) {
4717 if ( mLayer )
4718 {
4719 mLayer->setOffset( val );
4720 emit changed();
4721 }
4722 } );
4723
4724 connect( cboCapStyle, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=] {
4725 if ( mLayer )
4726 {
4727 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
4728 emit changed();
4729 }
4730 } );
4731 connect( cboJoinStyle, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=] {
4732 if ( mLayer )
4733 {
4734 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
4735 emit changed();
4736 }
4737 } );
4738
4739 connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterLineSymbolLayerWidget::imageSourceChanged );
4740 connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, [=]( double opacity ) {
4741 if ( mLayer )
4742 {
4743 mLayer->setOpacity( opacity );
4744 updatePreviewImage();
4745 emit changed();
4746 }
4747 } );
4748}
4749
4751{
4752 if ( !layer )
4753 {
4754 return;
4755 }
4756
4757 if ( layer->layerType() != QLatin1String( "RasterLine" ) )
4758 {
4759 return;
4760 }
4761
4762 mLayer = dynamic_cast<QgsRasterLineSymbolLayer *>( layer );
4763 if ( !mLayer )
4764 {
4765 return;
4766 }
4767
4768 whileBlocking( mImageSourceLineEdit )->setSource( mLayer->path() );
4769 whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
4770
4771 whileBlocking( spinWidth )->setValue( mLayer->width() );
4772 whileBlocking( mPenWidthUnitWidget )->setUnit( mLayer->widthUnit() );
4773 whileBlocking( mPenWidthUnitWidget )->setMapUnitScale( mLayer->widthMapUnitScale() );
4774 whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
4775 whileBlocking( cboCapStyle )->setPenCapStyle( mLayer->penCapStyle() );
4776
4777 whileBlocking( mOffsetUnitWidget )->setUnit( mLayer->offsetUnit() );
4778 whileBlocking( mOffsetUnitWidget )->setMapUnitScale( mLayer->offsetMapUnitScale() );
4779 whileBlocking( spinOffset )->setValue( mLayer->offset() );
4780
4781 updatePreviewImage();
4782
4789}
4790
4795
4796void QgsRasterLineSymbolLayerWidget::imageSourceChanged( const QString &text )
4797{
4798 mLayer->setPath( text );
4799 updatePreviewImage();
4800 emit changed();
4801}
4802
4803void QgsRasterLineSymbolLayerWidget::updatePreviewImage()
4804{
4805 bool fitsInCache = false;
4806 const QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->path(), QSize( 150, 150 ), true, 1.0, fitsInCache );
4807 if ( image.isNull() )
4808 {
4809 mLabelImagePreview->setPixmap( QPixmap() );
4810 return;
4811 }
4812
4813 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4814 previewImage.fill( Qt::transparent );
4815 const QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4816 QPainter p;
4817 p.begin( &previewImage );
4818 //draw a checkerboard background
4819 uchar pixDataRGB[] = { 150, 150, 150, 150, 100, 100, 100, 150, 100, 100, 100, 150, 150, 150, 150, 150 };
4820 const QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4821 const QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4822 QBrush checkerBrush;
4823 checkerBrush.setTexture( pix );
4824 p.fillRect( imageRect, checkerBrush );
4825
4826 if ( mLayer->opacity() < 1.0 )
4827 {
4828 p.setOpacity( mLayer->opacity() );
4829 }
4830
4831 p.drawImage( imageRect.left(), imageRect.top(), image );
4832 p.end();
4833 mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4834}
4835
4836
4837//
4838// QgsGeometryGeneratorSymbolLayerWidget
4839//
4840
4842 : QgsSymbolLayerWidget( parent, vl )
4843
4844{
4845 setupUi( this );
4846 modificationExpressionSelector->setMultiLine( true );
4847 modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer *>( vl ) );
4848 modificationExpressionSelector->registerExpressionContextGenerator( this );
4849 cbxGeometryType->addItem( QgsIconUtils::iconPolygon(), tr( "Polygon / MultiPolygon" ), static_cast<int>( Qgis::SymbolType::Fill ) );
4850 cbxGeometryType->addItem( QgsIconUtils::iconLine(), tr( "LineString / MultiLineString" ), static_cast<int>( Qgis::SymbolType::Line ) );
4851 cbxGeometryType->addItem( QgsIconUtils::iconPoint(), tr( "Point / MultiPoint" ), static_cast<int>( Qgis::SymbolType::Marker ) );
4852
4854 mUnitWidget->setShowMapScaleButton( false );
4855
4856 connect( modificationExpressionSelector, &QgsExpressionLineEdit::expressionChanged, this, &QgsGeometryGeneratorSymbolLayerWidget::updateExpression );
4857 connect( cbxGeometryType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType );
4858 connect( mUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
4859 if ( !mBlockSignals )
4860 {
4861 mLayer->setUnits( mUnitWidget->unit() );
4862 emit symbolChanged();
4863 }
4864 } );
4865}
4866
4868{
4869 mBlockSignals++;
4870 mLayer = static_cast<QgsGeometryGeneratorSymbolLayer *>( l );
4871 modificationExpressionSelector->setExpression( mLayer->geometryExpression() );
4872 cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( static_cast<int>( mLayer->symbolType() ) ) );
4873 mUnitWidget->setUnit( mLayer->units() );
4874 mBlockSignals--;
4875}
4876
4881
4882void QgsGeometryGeneratorSymbolLayerWidget::updateExpression( const QString &string )
4883{
4884 mLayer->setGeometryExpression( string );
4885
4886 emit changed();
4887}
4888
4889void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
4890{
4891 // we try to keep the subsymbol, if we can!
4892 std::unique_ptr<QgsSymbol> subSymbol( mLayer->subSymbol()->clone() );
4893
4894 mLayer->setSymbolType( static_cast<Qgis::SymbolType>( cbxGeometryType->currentData().toInt() ) );
4895
4896 switch ( mLayer->symbolType() )
4897 {
4900 break;
4902 {
4903 if ( subSymbol->type() == Qgis::SymbolType::Fill )
4904 {
4905 // going from fill -> line type, so we can copy any LINE symbol layers across
4906 QgsSymbolLayerList layers;
4907 for ( int i = 0; i < subSymbol->symbolLayerCount(); ++i )
4908 {
4909 if ( dynamic_cast<const QgsLineSymbolLayer *>( subSymbol->symbolLayer( i ) ) )
4910 layers << subSymbol->symbolLayer( i )->clone();
4911 }
4912
4913 if ( !layers.empty() )
4914 mLayer->setSubSymbol( new QgsLineSymbol( layers ) );
4915 }
4916 break;
4917 }
4919 if ( subSymbol->type() == Qgis::SymbolType::Line )
4920 {
4921 // going from line -> fill type, so copy ALL line symbol layers across
4922 QgsSymbolLayerList layers;
4923 for ( int i = 0; i < subSymbol->symbolLayerCount(); ++i )
4924 layers << subSymbol->symbolLayer( i )->clone();
4925 mLayer->setSubSymbol( new QgsFillSymbol( layers ) );
4926 }
4927 break;
4928 }
4929
4930 emit symbolChanged();
4931}
4932
4933//
4934// QgsRandomMarkerFillSymbolLayerWidget
4935//
4936
4937
4939 : QgsSymbolLayerWidget( parent, vl )
4940{
4941 setupUi( this );
4942
4943 mCountMethodComboBox->addItem( tr( "Absolute Count" ), static_cast<int>( Qgis::PointCountMethod::Absolute ) );
4944 mCountMethodComboBox->addItem( tr( "Density-based Count" ), static_cast<int>( Qgis::PointCountMethod::DensityBased ) );
4945
4946 mPointCountSpinBox->setShowClearButton( true );
4947 mPointCountSpinBox->setClearValue( 100 );
4948 mSeedSpinBox->setShowClearButton( true );
4949 mSeedSpinBox->setClearValue( 0 );
4950
4951 connect( mCountMethodComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged );
4952 connect( mPointCountSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::countChanged );
4953 connect( mDensityAreaSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged );
4954 connect( mSeedSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::seedChanged );
4955 connect( mClipPointsCheckBox, &QCheckBox::toggled, this, [=]( bool checked ) {
4956 if ( mLayer )
4957 {
4958 mLayer->setClipPoints( checked );
4959 emit changed();
4960 }
4961 } );
4962
4964
4965 connect( mDensityAreaUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRandomMarkerFillSymbolLayerWidget::densityAreaUnitChanged );
4966}
4967
4969{
4970 if ( !layer || layer->layerType() != QLatin1String( "RandomMarkerFill" ) )
4971 {
4972 return;
4973 }
4974
4975 mLayer = static_cast<QgsRandomMarkerFillSymbolLayer *>( layer );
4976 whileBlocking( mPointCountSpinBox )->setValue( mLayer->pointCount() );
4977 whileBlocking( mSeedSpinBox )->setValue( mLayer->seed() );
4978 whileBlocking( mClipPointsCheckBox )->setChecked( mLayer->clipPoints() );
4979
4980 bool showDensityBasedCountWidgets = false;
4981 switch ( mLayer->countMethod() )
4982 {
4984 showDensityBasedCountWidgets = true;
4985 break;
4987 break;
4988 }
4989 mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
4990 mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
4991 mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
4992 mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
4993
4994 whileBlocking( mCountMethodComboBox )->setCurrentIndex( mCountMethodComboBox->findData( static_cast<int>( mLayer->countMethod() ) ) );
4995 whileBlocking( mDensityAreaSpinBox )->setValue( mLayer->densityArea() );
4996 mDensityAreaUnitWidget->blockSignals( true );
4997 mDensityAreaUnitWidget->setUnit( mLayer->densityAreaUnit() );
4998 mDensityAreaUnitWidget->setMapUnitScale( mLayer->densityAreaUnitScale() );
4999 mDensityAreaUnitWidget->blockSignals( false );
5000
5005}
5006
5011
5012void QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged( int )
5013{
5014 bool showDensityBasedCountWidgets = false;
5015 switch ( static_cast<Qgis::PointCountMethod>( mCountMethodComboBox->currentData().toInt() ) )
5016 {
5018 showDensityBasedCountWidgets = true;
5019 break;
5021 break;
5022 }
5023 mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
5024 mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
5025 mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
5026 mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
5027
5028 if ( mLayer )
5029 {
5030 mLayer->setCountMethod( static_cast<Qgis::PointCountMethod>( mCountMethodComboBox->currentData().toInt() ) );
5031 emit changed();
5032 }
5033}
5034
5035void QgsRandomMarkerFillSymbolLayerWidget::countChanged( int d )
5036{
5037 if ( mLayer )
5038 {
5039 mLayer->setPointCount( d );
5040 emit changed();
5041 }
5042}
5043
5044void QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged( double d )
5045{
5046 if ( mLayer )
5047 {
5048 mLayer->setDensityArea( d );
5049 emit changed();
5050 }
5051}
5052
5053void QgsRandomMarkerFillSymbolLayerWidget::densityAreaUnitChanged()
5054{
5055 if ( mLayer )
5056 {
5057 mLayer->setDensityAreaUnit( mDensityAreaUnitWidget->unit() );
5058 mLayer->setDensityAreaUnitScale( mDensityAreaUnitWidget->getMapUnitScale() );
5059 emit changed();
5060 }
5061}
5062
5063void QgsRandomMarkerFillSymbolLayerWidget::seedChanged( int d )
5064{
5065 if ( mLayer )
5066 {
5067 mLayer->setSeed( d );
5068 emit changed();
5069 }
5070}
5071
5072//
5073// QgsGradientLineSymbolLayerWidget
5074//
5075
5077 : QgsSymbolLayerWidget( parent, vl )
5078{
5079 mLayer = nullptr;
5080 setupUi( this );
5081
5082 btnColorRamp->setShowGradientOnly( true );
5083
5084 btnChangeColor->setAllowOpacity( true );
5085 btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
5086 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
5087 btnChangeColor->setShowNoColor( true );
5088 btnChangeColor->setNoColorString( tr( "Transparent" ) );
5089 btnChangeColor2->setAllowOpacity( true );
5090 btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
5091 btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
5092 btnChangeColor2->setShowNoColor( true );
5093 btnChangeColor2->setNoColorString( tr( "Transparent" ) );
5094
5095 mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
5096 mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
5097
5098 connect( btnChangeColor, &QgsColorButton::colorChanged, this, [=]( const QColor &color ) {
5099 if ( mLayer )
5100 {
5101 mLayer->setColor( color );
5102 emit changed();
5103 }
5104 } );
5105 connect( btnChangeColor2, &QgsColorButton::colorChanged, this, [=]( const QColor &color ) {
5106 if ( mLayer )
5107 {
5108 mLayer->setColor2( color );
5109 emit changed();
5110 }
5111 } );
5112 connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, [=] {
5113 if ( btnColorRamp->isNull() )
5114 return;
5115
5116 if ( mLayer )
5117 {
5118 mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
5119 emit changed();
5120 }
5121 } );
5122
5123 connect( radioTwoColor, &QAbstractButton::toggled, this, [=] {
5124 if ( mLayer )
5125 {
5126 if ( radioTwoColor->isChecked() )
5127 {
5128 mLayer->setGradientColorType( Qgis::GradientColorSource::SimpleTwoColor );
5129 btnChangeColor->setEnabled( true );
5130 btnChangeColor2->setEnabled( true );
5131 btnColorRamp->setEnabled( false );
5132 }
5133 else
5134 {
5135 mLayer->setGradientColorType( Qgis::GradientColorSource::ColorRamp );
5136 btnColorRamp->setEnabled( true );
5137 btnChangeColor->setEnabled( false );
5138 btnChangeColor2->setEnabled( false );
5139 }
5140 emit changed();
5141 }
5142 } );
5143
5146
5147 connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
5148 if ( mLayer )
5149 {
5150 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
5151 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
5152 emit changed();
5153 }
5154 } );
5155
5156 connect( spinWidth, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=] {
5157 if ( mLayer )
5158 {
5159 mLayer->setWidth( spinWidth->value() );
5160 emit changed();
5161 }
5162 } );
5163
5164 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
5165 if ( mLayer )
5166 {
5167 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
5168 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
5169 emit changed();
5170 }
5171 } );
5172
5173 spinOffset->setClearValue( 0.0 );
5174 connect( spinOffset, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double val ) {
5175 if ( mLayer )
5176 {
5177 mLayer->setOffset( val );
5178 emit changed();
5179 }
5180 } );
5181
5182 connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [=] {
5183 if ( mLayer )
5184 {
5185 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
5186 emit changed();
5187 }
5188 } );
5189 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [=] {
5190 if ( mLayer )
5191 {
5192 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
5193 emit changed();
5194 }
5195 } );
5196}
5197
5199{
5200 if ( !layer )
5201 {
5202 return;
5203 }
5204
5205 if ( layer->layerType() != QLatin1String( "Lineburst" ) )
5206 {
5207 return;
5208 }
5209
5210 mLayer = dynamic_cast<QgsLineburstSymbolLayer *>( layer );
5211 if ( !mLayer )
5212 {
5213 return;
5214 }
5215
5216 btnChangeColor->blockSignals( true );
5217 btnChangeColor->setColor( mLayer->color() );
5218 btnChangeColor->blockSignals( false );
5219 btnChangeColor2->blockSignals( true );
5220 btnChangeColor2->setColor( mLayer->color2() );
5221 btnChangeColor2->blockSignals( false );
5222
5224 {
5225 radioTwoColor->setChecked( true );
5226 btnColorRamp->setEnabled( false );
5227 }
5228 else
5229 {
5230 radioColorRamp->setChecked( true );
5231 btnChangeColor->setEnabled( false );
5232 btnChangeColor2->setEnabled( false );
5233 }
5234
5235 // set source color ramp
5236 if ( mLayer->colorRamp() )
5237 {
5238 btnColorRamp->blockSignals( true );
5239 btnColorRamp->setColorRamp( mLayer->colorRamp() );
5240 btnColorRamp->blockSignals( false );
5241 }
5242
5243 whileBlocking( spinWidth )->setValue( mLayer->width() );
5244 whileBlocking( mPenWidthUnitWidget )->setUnit( mLayer->widthUnit() );
5245 whileBlocking( mPenWidthUnitWidget )->setMapUnitScale( mLayer->widthMapUnitScale() );
5246
5247 whileBlocking( mOffsetUnitWidget )->setUnit( mLayer->offsetUnit() );
5248 whileBlocking( mOffsetUnitWidget )->setMapUnitScale( mLayer->offsetMapUnitScale() );
5249 whileBlocking( spinOffset )->setValue( mLayer->offset() );
5250
5251 whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
5252 whileBlocking( cboCapStyle )->setPenCapStyle( mLayer->penCapStyle() );
5253
5260}
5261
5266
5267//
5268// QgsFilledLineSymbolLayerWidget
5269//
5270
5272 : QgsSymbolLayerWidget( parent, vl )
5273{
5274 mLayer = nullptr;
5275 setupUi( this );
5276
5279
5280 connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
5281 if ( mLayer )
5282 {
5283 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
5284 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
5285 emit changed();
5286 }
5287 } );
5288
5289 connect( spinWidth, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=] {
5290 if ( mLayer )
5291 {
5292 mLayer->setWidth( spinWidth->value() );
5293 emit changed();
5294 }
5295 } );
5296
5297 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
5298 if ( mLayer )
5299 {
5300 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
5301 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
5302 emit changed();
5303 }
5304 } );
5305
5306 spinOffset->setClearValue( 0.0 );
5307 connect( spinOffset, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double val ) {
5308 if ( mLayer )
5309 {
5310 mLayer->setOffset( val );
5311 emit changed();
5312 }
5313 } );
5314
5315 connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [=] {
5316 if ( mLayer )
5317 {
5318 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
5319 emit changed();
5320 }
5321 } );
5322 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [=] {
5323 if ( mLayer )
5324 {
5325 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
5326 emit changed();
5327 }
5328 } );
5329}
5330
5332
5334{
5335 if ( !layer )
5336 {
5337 return;
5338 }
5339
5340 if ( layer->layerType() != QLatin1String( "FilledLine" ) )
5341 {
5342 return;
5343 }
5344
5345 mLayer = dynamic_cast<QgsFilledLineSymbolLayer *>( layer );
5346 if ( !mLayer )
5347 {
5348 return;
5349 }
5350
5351 whileBlocking( spinWidth )->setValue( mLayer->width() );
5352 whileBlocking( mPenWidthUnitWidget )->setUnit( mLayer->widthUnit() );
5353 whileBlocking( mPenWidthUnitWidget )->setMapUnitScale( mLayer->widthMapUnitScale() );
5354
5355 whileBlocking( mOffsetUnitWidget )->setUnit( mLayer->offsetUnit() );
5356 whileBlocking( mOffsetUnitWidget )->setMapUnitScale( mLayer->offsetMapUnitScale() );
5357 whileBlocking( spinOffset )->setValue( mLayer->offset() );
5358
5359 whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
5360 whileBlocking( cboCapStyle )->setPenCapStyle( mLayer->penCapStyle() );
5361
5366}
5367
5372
5373//
5374// QgsLinearReferencingSymbolLayerWidget
5375//
5376
5378 : QgsSymbolLayerWidget( parent, vl )
5379{
5380 mLayer = nullptr;
5381
5382 setupUi( this );
5383
5384 mComboPlacement->addItem( tr( "Interval (Cartesian 2D Distances)" ), QVariant::fromValue( Qgis::LinearReferencingPlacement::IntervalCartesian2D ) );
5385 mComboPlacement->addItem( tr( "Interval (Z Values)" ), QVariant::fromValue( Qgis::LinearReferencingPlacement::IntervalZ ) );
5386 mComboPlacement->addItem( tr( "Interval (M Values)" ), QVariant::fromValue( Qgis::LinearReferencingPlacement::IntervalM ) );
5387 mComboPlacement->addItem( tr( "On Every Vertex" ), QVariant::fromValue( Qgis::LinearReferencingPlacement::Vertex ) );
5388
5389 mComboQuantity->addItem( tr( "Cartesian 2D Distance" ), QVariant::fromValue( Qgis::LinearReferencingLabelSource::CartesianDistance2D ) );
5390 mComboQuantity->addItem( tr( "Z Values" ), QVariant::fromValue( Qgis::LinearReferencingLabelSource::Z ) );
5391 mComboQuantity->addItem( tr( "M Values" ), QVariant::fromValue( Qgis::LinearReferencingLabelSource::M ) );
5392
5393 mSpinSkipMultiples->setClearValue( 0, tr( "Not set" ) );
5394 mSpinLabelOffsetX->setClearValue( 0 );
5395 mSpinLabelOffsetY->setClearValue( 0 );
5396 mSpinAverageAngleLength->setClearValue( 4.0 );
5399
5400 connect( mComboQuantity, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=] {
5401 if ( mLayer && !mBlockChangesSignal )
5402 {
5403 mLayer->setLabelSource( mComboQuantity->currentData().value<Qgis::LinearReferencingLabelSource>() );
5404 emit changed();
5405 }
5406 } );
5407 connect( mTextFormatButton, &QgsFontButton::changed, this, [=] {
5408 if ( mLayer && !mBlockChangesSignal )
5409 {
5410 mLayer->setTextFormat( mTextFormatButton->textFormat() );
5411 emit changed();
5412 }
5413 } );
5414 connect( spinInterval, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), this, [=] {
5415 if ( mLayer && !mBlockChangesSignal )
5416 {
5417 mLayer->setInterval( spinInterval->value() );
5418 emit changed();
5419 }
5420 } );
5421 connect( mSpinSkipMultiples, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), this, [=] {
5422 if ( mLayer && !mBlockChangesSignal )
5423 {
5424 mLayer->setSkipMultiplesOf( mSpinSkipMultiples->value() );
5425 emit changed();
5426 }
5427 } );
5428 connect( mCheckRotate, &QCheckBox::toggled, this, [=]( bool checked ) {
5429 if ( mLayer && !mBlockChangesSignal )
5430 {
5431 mLayer->setRotateLabels( checked );
5432 emit changed();
5433 }
5434 mSpinAverageAngleLength->setEnabled( checked );
5435 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
5436 } );
5437 connect( mCheckShowMarker, &QCheckBox::toggled, this, [=]( bool checked ) {
5438 if ( mLayer && !mBlockChangesSignal )
5439 {
5440 mLayer->setShowMarker( checked );
5441 emit symbolChanged();
5442 }
5443 } );
5444
5445 connect( mSpinLabelOffsetX, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), this, [=] {
5446 if ( mLayer && !mBlockChangesSignal )
5447 {
5448 mLayer->setLabelOffset( QPointF( mSpinLabelOffsetX->value(), mSpinLabelOffsetY->value() ) );
5449 emit changed();
5450 }
5451 } );
5452 connect( mSpinLabelOffsetY, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), this, [=] {
5453 if ( mLayer && !mBlockChangesSignal )
5454 {
5455 mLayer->setLabelOffset( QPointF( mSpinLabelOffsetX->value(), mSpinLabelOffsetY->value() ) );
5456 emit changed();
5457 }
5458 } );
5459 connect( mLabelOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
5460 if ( mLayer && !mBlockChangesSignal )
5461 {
5462 mLayer->setLabelOffsetUnit( mLabelOffsetUnitWidget->unit() );
5463 mLayer->setLabelOffsetMapUnitScale( mLabelOffsetUnitWidget->getMapUnitScale() );
5464 emit changed();
5465 }
5466 } );
5467
5468 connect( mComboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=] {
5469 if ( mLayer && !mBlockChangesSignal )
5470 {
5471 const Qgis::LinearReferencingPlacement placement = mComboPlacement->currentData().value<Qgis::LinearReferencingPlacement>();
5472 mLayer->setPlacement( placement );
5473 switch ( placement )
5474 {
5478 mIntervalWidget->show();
5479 break;
5481 mIntervalWidget->hide();
5482 break;
5483 }
5484 emit changed();
5485 }
5486 } );
5487
5488 connect( mSpinAverageAngleLength, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), this, [=] {
5489 if ( mLayer && !mBlockChangesSignal )
5490 {
5491 mLayer->setAverageAngleLength( mSpinAverageAngleLength->value() );
5492 emit changed();
5493 }
5494 } );
5495 connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, [=] {
5496 if ( mLayer && !mBlockChangesSignal )
5497 {
5498 mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
5499 mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
5500 emit changed();
5501 }
5502 } );
5503
5504 connect( mNumberFormatPushButton, &QPushButton::clicked, this, &QgsLinearReferencingSymbolLayerWidget::changeNumberFormat );
5505
5506 mTextFormatButton->registerExpressionContextGenerator( this );
5507}
5508
5510
5511
5513{
5514 if ( !layer || layer->layerType() != QLatin1String( "LinearReferencing" ) )
5515 return;
5516
5517 // layer type is correct, we can do the cast
5518 mLayer = qgis::down_cast<QgsLinearReferencingSymbolLayer *>( layer );
5519
5520 mBlockChangesSignal = true;
5521
5522 mComboPlacement->setCurrentIndex( mComboPlacement->findData( QVariant::fromValue( mLayer->placement() ) ) );
5523 switch ( mLayer->placement() )
5524 {
5528 mIntervalWidget->show();
5529 break;
5531 mIntervalWidget->hide();
5532 break;
5533 }
5534
5535 mComboQuantity->setCurrentIndex( mComboQuantity->findData( QVariant::fromValue( mLayer->labelSource() ) ) );
5536
5537 mTextFormatButton->setTextFormat( mLayer->textFormat() );
5538 spinInterval->setValue( mLayer->interval() );
5539 mSpinSkipMultiples->setValue( mLayer->skipMultiplesOf() );
5540 mCheckRotate->setChecked( mLayer->rotateLabels() );
5541 mCheckShowMarker->setChecked( mLayer->showMarker() );
5542 mSpinLabelOffsetX->setValue( mLayer->labelOffset().x() );
5543 mSpinLabelOffsetY->setValue( mLayer->labelOffset().y() );
5544 mLabelOffsetUnitWidget->setUnit( mLayer->labelOffsetUnit() );
5545 mLabelOffsetUnitWidget->setMapUnitScale( mLayer->labelOffsetMapUnitScale() );
5546
5547 mAverageAngleUnit->setUnit( mLayer->averageAngleUnit() );
5548 mAverageAngleUnit->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
5549 mSpinAverageAngleLength->setValue( mLayer->averageAngleLength() );
5550
5551 mSpinAverageAngleLength->setEnabled( mCheckRotate->isChecked() );
5552 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
5553
5558
5559 mBlockChangesSignal = false;
5560}
5561
5566
5568{
5570 mTextFormatButton->setMapCanvas( context.mapCanvas() );
5571 mTextFormatButton->setMessageBar( context.messageBar() );
5572}
5573
5574void QgsLinearReferencingSymbolLayerWidget::changeNumberFormat()
5575{
5577 if ( panel && panel->dockMode() )
5578 {
5580 widget->setPanelTitle( tr( "Number Format" ) );
5581 widget->setFormat( mLayer->numericFormat() );
5582 widget->registerExpressionContextGenerator( this );
5583 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [=] {
5584 if ( !mBlockChangesSignal )
5585 {
5586 mLayer->setNumericFormat( widget->format() );
5587 emit changed();
5588 }
5589 } );
5590 panel->openPanel( widget );
5591 }
5592 else
5593 {
5594 QgsNumericFormatSelectorDialog dialog( this );
5595 dialog.setFormat( mLayer->numericFormat() );
5596 dialog.registerExpressionContextGenerator( this );
5597 if ( dialog.exec() )
5598 {
5599 mLayer->setNumericFormat( dialog.format() );
5600 emit changed();
5601 }
5602 }
5603}
A widget for displaying characters available in a preset font, and allowing users to select an indivi...
void characterSelected(QChar character)
Emitted when a character is selected in the widget.
void setCharacter(QChar character)
Sets the currently selected character in the widget.
void setFont(const QFont &font)
Sets the font to show in the widget.
void clearCharacter()
Clears the currently selected character in the widget.
@ CurvePoint
Place symbols at every virtual curve point in the line (used when rendering curved geometry types onl...
@ InnerVertices
Inner vertices (i.e. all vertices except the first and last vertex)
@ LastVertex
Place symbols on the last vertex in the line.
@ CentralPoint
Place symbols at the mid point of the line.
@ SegmentCenter
Place symbols at the center of every line segment.
@ Vertex
Place symbols on every vertex in the line.
@ Interval
Place symbols at regular intervals.
@ FirstVertex
Place symbols on the first vertex in the line.
MarkerClipMode
Marker clipping modes.
Definition qgis.h:3143
@ CompletelyWithin
Render complete markers wherever the completely fall within the polygon shape.
@ NoClipping
No clipping, render complete markers.
@ Shape
Clip to polygon shape.
@ CentroidWithin
Render complete markers wherever their centroid falls within the polygon shape.
LineClipMode
Line clipping modes.
Definition qgis.h:3157
@ NoClipping
Lines are not clipped, will extend to shape's bounding box.
@ ClipPainterOnly
Applying clipping on the painter only (i.e. line endpoints will coincide with polygon bounding box,...
@ ClipToIntersection
Clip lines to intersection with polygon shape (slower) (i.e. line endpoints will coincide with polygo...
@ ColorRamp
Gradient color ramp.
@ SimpleTwoColor
Simple two color gradient.
@ Repeat
Repeat gradient.
@ Reflect
Reflect gradient.
@ Pad
Pad out gradient using colors at endpoint of gradient.
PointCountMethod
Methods which define the number of points randomly filling a polygon.
Definition qgis.h:3131
@ Absolute
The point count is used as an absolute count of markers.
@ DensityBased
The point count is part of a marker density count.
MarkerShape
Marker shapes.
Definition qgis.h:2974
VerticalAnchorPoint
Marker symbol vertical anchor points.
Definition qgis.h:778
@ Bottom
Align to bottom of symbol.
@ Center
Align to vertical center of symbol.
@ Baseline
Align to baseline of symbol, e.g. font baseline for font marker symbol layers. Treated as Bottom if n...
@ Top
Align to top of symbol.
LinearReferencingPlacement
Defines how/where the labels should be placed in a linear referencing symbol layer.
Definition qgis.h:3043
@ IntervalZ
Place labels at regular intervals, linearly interpolated using Z values.
@ Vertex
Place labels on every vertex in the line.
@ IntervalM
Place labels at regular intervals, linearly interpolated using M values.
@ IntervalCartesian2D
Place labels at regular intervals, using Cartesian distance calculations on a 2D plane.
LinearReferencingLabelSource
Defines what quantity to use for the labels shown in a linear referencing symbol layer.
Definition qgis.h:3057
@ CartesianDistance2D
Distance along line, calculated using Cartesian calculations on a 2D plane.
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size)
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MapUnits
Map units.
@ MetersInMapUnits
Meters value as Map units.
@ Linear
Linear gradient.
@ Conical
Conical (polar) gradient.
@ Radial
Radial (circular) gradient.
SymbolType
Symbol types.
Definition qgis.h:574
@ Marker
Marker symbol.
@ Line
Line symbol.
@ Fill
Fill symbol.
@ Hybrid
Hybrid symbol.
SymbolCoordinateReference
Symbol coordinate reference modes.
Definition qgis.h:3101
@ Feature
Relative to feature/shape being rendered.
@ Viewport
Relative to the whole viewport/output device.
QFlags< MarkerLinePlacement > MarkerLinePlacements
Definition qgis.h:3034
HorizontalAnchorPoint
Marker symbol horizontal anchor points.
Definition qgis.h:764
@ Center
Align to horizontal center of symbol.
@ Right
Align to right side of symbol.
@ Left
Align to left side of symbol.
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition qgis.h:5926
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
void sourceChanged(const QString &source)
Emitted whenever the file source is changed in the widget.
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsAnimatedMarkerSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsAnimatedMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsAnimatedMarkerSymbolLayerWidget.
Animated marker symbol layer class.
void setFrameRate(double rate)
Sets the marker frame rate in frame per second.
double frameRate() const
Returns the marker frame rate in frame per second.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsCentroidFillSymbolLayer * mLayer
QgsCentroidFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsCentroidFillSymbolLayerWidget.
A fill symbol layer which renders a marker symbol at the centroid of a polygon geometry.
void setPointOnAllParts(bool pointOnAllParts)
Sets whether a point is drawn for all parts or only on the biggest part of multi-part features.
void setClipOnCurrentPartOnly(bool clipOnCurrentPartOnly)
Sets whether point markers should be clipped to the current part boundary only.
void setClipPoints(bool clipPoints)
Sets whether point markers should be clipped to the polygon boundary.
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features.
bool clipPoints() const
Returns true if point markers should be clipped to the polygon boundary.
bool clipOnCurrentPartOnly() const
Returns true if point markers should be clipped to the current part boundary only.
void setPointOnSurface(bool pointOnSurface)
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
void colorRampChanged()
Emitted whenever a new color ramp is set for the button.
Abstract base class for color ramps.
A dialog to enter a custom dash space pattern for lines.
A widget to enter a custom dash space pattern for lines.
QVector< qreal > dashDotVector() const
Returns the dash pattern as a list of numbers.
void setUnit(Qgis::RenderUnit unit)
Sets the unit type used for the dash space pattern (used to update interface labels)
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
static const QString EXPR_GEOMETRY_RING_NUM
Inbuilt variable name for geometry ring number variable.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
bool hasVariable(const QString &name) const
Check whether a variable is specified by any scope within the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
double angle() const
Returns the rotation angle of the fill symbol, in degrees clockwise.
void setAngle(double angle)
Sets the rotation angle of the pattern, in degrees clockwise.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
~QgsFilledLineSymbolLayerWidget() override
QgsSymbolLayer * symbolLayer() override
QgsFilledLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsFilledLineSymbolLayerWidget.
void setSymbolLayer(QgsSymbolLayer *layer) override
A line symbol layer type which fills a stroked line with a QgsFillSymbol.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
void setMapUnitScale(const QgsMapUnitScale &scale) override
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
QgsFilledMarkerSymbolLayer * mLayer
QgsSymbolLayer * symbolLayer() override
QgsFilledMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsFilledMarkerSymbolLayerWidget.
void setSymbolLayer(QgsSymbolLayer *layer) override
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
QgsFilledMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void changed()
Emitted when the widget's text format settings are changed.
QgsFontMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsFontMarkerSymbolLayerWidget.
void setCharacter(QChar chr)
Set the font marker character from char.
void setSymbolLayer(QgsSymbolLayer *layer) override
~QgsFontMarkerSymbolLayerWidget() override
QgsSymbolLayer * symbolLayer() override
QgsFontMarkerSymbolLayer * mLayer
void setCharacterFromText(const QString &text)
Set the font marker character from a text string.
void setColorStroke(const QColor &color)
Set stroke color.
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the stroke width unit.
void setStrokeColor(const QColor &color) override
Sets the stroke color for the symbol layer.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
Qgis::RenderUnit strokeWidthUnit() const
Returns the stroke width unit.
double strokeWidth() const
Returns the marker's stroke width.
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
QString fontStyle() const
Returns the font style for the associated font which will be used to render the point.
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point.
void setCharacter(QString chr)
Sets the character(s) used when rendering points.
void setFontFamily(const QString &family)
Sets the font family for the font which will be used to render the point.
void setStrokeWidth(double width)
Set's the marker's stroke width.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
QgsFontMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
Qt::PenJoinStyle penJoinStyle() const
Returns the stroke join style.
QString character() const
Returns the character(s) used when rendering points.
static QString translateNamedStyle(const QString &namedStyle)
Returns the localized named style of a font, if such a translation is available.
static QString untranslateNamedStyle(const QString &namedStyle)
Returns the english named style of a font, if possible.
static QFont createFont(const QString &family, int pointSize=-1, int weight=-1, bool italic=false)
Creates a font with the specified family.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
static void setFontFamily(QFont &font, const QString &family)
Sets the family for a font object.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsGeometryGeneratorSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsGeometryGeneratorSymbolLayerWidget.
A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions.
Qgis::RenderUnit units() const
Returns the unit for the geometry expression.
QString geometryExpression() const
Gets the expression to generate this geometry.
void setUnits(Qgis::RenderUnit units)
Sets the units for the geometry expression.
void setGeometryExpression(const QString &exp)
Set the expression to generate this geometry.
void setSymbolType(Qgis::SymbolType symbolType)
Set the type of symbol which should be created.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
Qgis::SymbolType symbolType() const
Access the symbol type.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsGradientFillSymbolLayer * mLayer
QgsSymbolLayer * symbolLayer() override
void applyColorRamp()
Applies the color ramp passed on by the color ramp button.
QgsGradientFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsGradientFillSymbolLayerWidget.
A fill symbol layer which draws a smooth color gradient over a polygon.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used for the gradient fill.
QColor color2() const
Returns the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoC...
void setGradientSpread(Qgis::GradientSpread gradientSpread)
Sets the gradient spread mode, which controls how the gradient behaves outside of the predefined stop...
Qgis::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
Qgis::SymbolCoordinateReference coordinateMode() const
Returns the coordinate mode for gradient, which controls how the gradient stops are positioned.
bool referencePoint2IsCentroid() const
Returns whether the end point for the gradient is taken from the feature centroid.
void setGradientType(Qgis::GradientType gradientType)
Sets the type of gradient, e.g., linear or radial.
void setReferencePoint2(QPointF referencePoint)
Sets the end point of gradient fill, in the range [0,0] - [1,1].
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the unit for the fill's offset.
void setCoordinateMode(Qgis::SymbolCoordinateReference coordinateMode)
Sets the coordinate mode for gradient, which controls how the gradient stops are positioned.
void setReferencePoint2IsCentroid(bool isCentroid)
Sets whether the end point for the gradient is taken from the feature centroid.
void setReferencePoint1IsCentroid(bool isCentroid)
Sets whether the starting point for the gradient is taken from the feature centroid.
void setOffset(QPointF offset)
Sets an offset by which polygons will be translated during rendering.
void setGradientColorType(Qgis::GradientColorSource gradientColorType)
Sets the gradient color mode, which controls how gradient color stops are created.
QPointF referencePoint1() const
Returns the starting point of gradient fill, in the range [0,0] - [1,1].
Qgis::GradientSpread gradientSpread() const
Returns the gradient spread mode, which controls how the gradient behaves outside of the predefined s...
QgsColorRamp * colorRamp()
Returns the color ramp used for the gradient fill.
void setReferencePoint1(QPointF referencePoint)
Sets the starting point of gradient fill, in the range [0,0] - [1,1].
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
Qgis::GradientColorSource gradientColorType() const
Returns the gradient color mode, which controls how gradient color stops are created.
QPointF offset() const
Returns the offset by which polygons will be translated during rendering.
Qgis::GradientType gradientType() const
Returns the type of gradient, e.g., linear or radial.
bool referencePoint1IsCentroid() const
Returns whether the starting point for the gradient is taken from the feature centroid.
QPointF referencePoint2() const
Returns the end point of gradient fill, in the range [0,0] - [1,1].
void setColor2(const QColor &color2)
Sets the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColo...
QgsHashedLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsHashedLineSymbolLayerWidget.
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
Line symbol layer type which draws repeating line sections along a line feature.
void setHashLength(double length)
Sets the length of hash symbols.
double hashAngle() const
Returns the angle to use when drawing the hashed lines sections, in degrees clockwise.
const QgsMapUnitScale & hashLengthMapUnitScale() const
Returns the map unit scale for the hash length.
void setHashLengthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the hash length.
Qgis::RenderUnit hashLengthUnit() const
Returns the units for the length of hash symbols.
double hashLength() const
Returns the length of hash symbols.
void setHashLengthUnit(Qgis::RenderUnit unit)
Sets the unit for the length of hash symbols.
void setHashAngle(double angle)
Sets the angle to use when drawing the hashed lines sections, in degrees clockwise.
static QIcon iconLine()
Returns an icon representing line geometries.
static QIcon iconPolygon()
Returns an icon representing polygon geometries.
static QIcon iconPoint()
Returns an icon representing point geometries.
int nextFrameDelay(const QString &path, int currentFrame=0, bool blocking=false)
For image formats that support animation, this function returns the number of milliseconds to wait un...
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache, bool blocking=false, double targetDpi=96, int frameNumber=-1, bool *isMissing=nullptr)
Returns the specified path rendered as an image.
Qgis::SymbolCoordinateReference coordinateReference() const
Returns the coordinate reference mode for fill which controls how the top left corner of the image fi...
void setCoordinateReference(Qgis::SymbolCoordinateReference coordinateReference)
Sets the coordinate reference mode for fill which controls how the top left corner of the image fill ...
QgsLinePatternFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsLinePatternFillSymbolLayerWidget.
QgsLinePatternFillSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
A symbol fill consisting of repeated parallel lines.
Qgis::RenderUnit distanceUnit() const
Returns the units for the distance between lines in the fill pattern.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line distance.
Qgis::LineClipMode clipMode() const
Returns the line clipping mode, which defines how lines are clipped at the edges of shapes.
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the pattern's line offset.
void setDistance(double d)
Sets the distance between lines in the fill pattern.
void setClipMode(Qgis::LineClipMode mode)
Sets the line clipping mode, which defines how lines are clipped at the edges of shapes.
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the unit for the line pattern's offset.
const QgsMapUnitScale & distanceMapUnitScale() const
Returns the map unit scale for the pattern's line distance.
void setLineAngle(double a)
Sets the angle for the parallel lines used to fill the symbol.
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
void setDistanceUnit(Qgis::RenderUnit unit)
Sets the unit for the distance between lines in the fill pattern.
double distance() const
Returns the distance between lines in the fill pattern.
void setOffset(double offset)
Sets the offset distance for lines within the fill, which is the distance to offset the parallel line...
Qgis::RenderUnit offsetUnit() const
Returns the units for the line pattern's offset.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line offset.
Abstract base class for line symbol layers.
const QgsMapUnitScale & widthMapUnitScale() const
RenderRingFilter
Options for filtering rings when the line symbol layer is being used to render a polygon's rings.
@ ExteriorRingOnly
Render the exterior ring only.
@ InteriorRingsOnly
Render the interior rings only.
@ AllRings
Render both exterior and interior rings.
virtual void setWidth(double width)
Sets the width of the line symbol layer.
RenderRingFilter ringFilter() const
Returns the line symbol layer's ring filter, which controls which rings are rendered when the line sy...
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
void setOffset(double offset)
Sets the line's offset.
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the unit for the line's offset.
void setWidthUnit(Qgis::RenderUnit unit)
Sets the units for the line's width.
virtual double width() const
Returns the estimated width for the line symbol layer.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the line's offset.
void setRingFilter(QgsLineSymbolLayer::RenderRingFilter filter)
Sets the line symbol layer's ring filter, which controls which rings are rendered when the line symbo...
double offset() const
Returns the line's offset.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the line's offset.
Qgis::RenderUnit offsetUnit() const
Returns the units for the line's offset.
Qgis::RenderUnit widthUnit() const
Returns the units for the line's width.
A line symbol type, for rendering LineString and MultiLineString geometries.
void setSymbolLayer(QgsSymbolLayer *layer) override
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsLinearReferencingSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsLinearReferencingSymbolLayerWidget.
double averageAngleLength() const
Returns the length of line over which the line's direction is averaged when calculating individual la...
void setShowMarker(bool show)
Sets whether a marker symbol should be shown corresponding to the labeled point on line.
void setAverageAngleUnit(Qgis::RenderUnit unit)
Sets the unit for the length over which the line's direction is averaged when calculating individual ...
void setAverageAngleMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the length over which the line's direction is averaged when calculating i...
void setSkipMultiplesOf(double multiple)
Sets the multiple distance to skip labels for.
Qgis::RenderUnit labelOffsetUnit() const
Returns the unit used for the offset between the line and linear referencing labels.
void setLabelOffset(const QPointF &offset)
Sets the offset between the line and linear referencing labels.
QgsTextFormat textFormat() const
Returns the text format used to render the layer.
bool rotateLabels() const
Returns true if the labels and symbols are to be rotated to match their line segment orientation.
bool showMarker() const
Returns true if a marker symbol should be shown corresponding to the labeled point on line.
void setNumericFormat(QgsNumericFormat *format)
Sets the numeric format used to format the labels for the layer.
QgsNumericFormat * numericFormat() const
Returns the numeric format used to format the labels for the layer.
QPointF labelOffset() const
Returns the offset between the line and linear referencing labels.
const QgsMapUnitScale & labelOffsetMapUnitScale() const
Returns the map unit scale used for calculating the offset between the line and linear referencing la...
void setInterval(double interval)
Sets the interval between labels.
void setLabelSource(Qgis::LinearReferencingLabelSource source)
Sets the label source, which dictates what quantity to use for the labels shown.
Qgis::RenderUnit averageAngleUnit() const
Returns the unit for the length over which the line's direction is averaged when calculating individu...
void setRotateLabels(bool rotate)
Sets whether the labels and symbols should be rotated to match their line segment orientation.
void setTextFormat(const QgsTextFormat &format)
Sets the text format used to render the layer.
const QgsMapUnitScale & averageAngleMapUnitScale() const
Returns the map unit scale for the length over which the line's direction is averaged when calculatin...
void setLabelOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset between the line and linear referencing label...
void setLabelOffsetUnit(Qgis::RenderUnit unit)
Sets the unit used for the offset between the line and linear referencing labels.
Qgis::LinearReferencingLabelSource labelSource() const
Returns the label source, which dictates what quantity to use for the labels shown.
double skipMultiplesOf() const
Returns the multiple distance to skip labels for.
void setPlacement(Qgis::LinearReferencingPlacement placement)
Sets the placement mode for the labels.
double interval() const
Returns the interval between labels.
void setAverageAngleLength(double length)
Sets the length of line over which the line's direction is averaged when calculating individual label...
Qgis::LinearReferencingPlacement placement() const
Returns the placement mode for the labels.
QgsLineburstSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsLineburstSymbolLayerWidget.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsLineburstSymbolLayer * mLayer
QgsSymbolLayer * symbolLayer() override
Line symbol layer type which draws a gradient pattern perpendicularly along a line.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used for the gradient line.
QColor color2() const
Returns the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoC...
Qgis::GradientColorSource gradientColorType() const
Returns the gradient color mode, which controls how gradient color stops are created.
void setColor2(const QColor &color2)
Sets the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColo...
QgsColorRamp * colorRamp()
Returns the color ramp used for the gradient line.
Struct for storing maximum and minimum scales for measurements in map units.
QgsMarkerLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsMarkerLineSymbolLayerWidget.
QgsMarkerLineSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbolLayer * symbolLayer() override
Line symbol layer type which draws repeating marker symbols along a line feature.
virtual void setSize(double size)
Sets the symbol size.
void setVerticalAnchorPoint(Qgis::VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's offset.
void setAngle(double angle)
Sets the rotation angle for the marker.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
double size() const
Returns the symbol size.
Qgis::VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
void setHorizontalAnchorPoint(Qgis::HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
Qgis::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
Qgis::HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
Qgis::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's size.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
A marker symbol type, for rendering Point and MultiPoint geometries.
A dialog to create a new auxiliary field.
A dialog to create a new auxiliary layer.
A simple dialog for customizing a numeric format.
A widget which allows choice of numeric formats and the properties of them.
QgsNumericFormat * format() const
Returns a new format object representing the settings currently configured in the widget.
void changed()
Emitted whenever the format configured55 in the widget is changed.
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
void setFormat(const QgsNumericFormat *format)
Sets the format to show in the widget.
void opacityChanged(double opacity)
Emitted when the opacity is changed in the widget, where opacity ranges from 0.0 (transparent) to 1....
Base class for any widget that can be shown as a inline panel.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
void widgetChanged()
Emitted when the widget state changes.
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
bool dockMode()
Returns the dock mode state.
QgsPointPatternFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsPointPatternFillSymbolLayerWidget.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsPointPatternFillSymbolLayer * mLayer
A fill symbol layer which fills polygon shapes with repeating marker symbols.
const QgsMapUnitScale & distanceYMapUnitScale() const
Returns the map unit scale for the vertical distance between points in the pattern.
void setDisplacementX(double d)
Sets the horizontal displacement for odd numbered rows in the pattern.
void setOffsetXUnit(Qgis::RenderUnit unit)
Sets the units for the horizontal offset between rows in the pattern.
Qgis::RenderUnit offsetYUnit() const
Returns the units for the vertical offset for rows in the pattern.
const QgsMapUnitScale & randomDeviationXMapUnitScale() const
Returns the unit scale for the horizontal random deviation of points in the pattern.
void setOffsetX(double offset)
Sets the horizontal offset values for points in the pattern.
double maximumRandomDeviationY() const
Returns the maximum vertical random deviation of points in the pattern.
void setDistanceYUnit(Qgis::RenderUnit unit)
Sets the unit for the vertical distance between points in the pattern.
double distanceX() const
Returns the horizontal distance between rendered markers in the fill.
Qgis::RenderUnit randomDeviationYUnit() const
Returns the units for the vertical random deviation of points in the pattern.
double displacementY() const
Returns the vertical displacement for odd numbered columns in the pattern.
void setDisplacementYUnit(Qgis::RenderUnit unit)
Sets the units for the vertical displacement between rows in the pattern.
void setRandomDeviationYUnit(Qgis::RenderUnit unit)
Sets the unit for the vertical random deviation of points in the pattern.
const QgsMapUnitScale & distanceXMapUnitScale() const
Returns the map unit scale for the horizontal distance between points in the pattern.
void setRandomDeviationYMapUnitScale(const QgsMapUnitScale &scale)
Sets the unit scale for the vertical random deviation of points in the pattern.
unsigned long seed() const
Returns the random number seed to use when randomly shifting points, or 0 if a truly random sequence ...
Qgis::MarkerClipMode clipMode() const
Returns the marker clipping mode, which defines how markers are clipped at the edges of shapes.
void setRandomDeviationXMapUnitScale(const QgsMapUnitScale &scale)
Sets the unit scale for the horizontal random deviation of points in the pattern.
Qgis::RenderUnit distanceXUnit() const
Returns the units for the horizontal distance between points in the pattern.
double offsetY() const
Returns the vertical offset values for points in the pattern.
void setDisplacementY(double d)
Sets the vertical displacement for odd numbered columns in the pattern.
void setMaximumRandomDeviationX(double deviation)
Sets the maximum horizontal random deviation of points in the pattern.
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the vertical displacement between odd numbered columns in the pattern.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setSeed(unsigned long seed)
Sets the random number seed to use when randomly shifting points, or 0 if a truly random sequence wil...
void setOffsetY(double offset)
Sets the vertical offset values for points in the pattern.
const QgsMapUnitScale & offsetXMapUnitScale() const
Returns the unit scale for the horizontal offset for rows in the pattern.
const QgsMapUnitScale & displacementXMapUnitScale() const
Returns the map unit scale for the horizontal displacement between odd numbered rows in the pattern.
const QgsMapUnitScale & offsetYMapUnitScale() const
Returns the unit scale for the vertical offset between rows in the pattern.
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the horizontal distance between points in the pattern.
Qgis::RenderUnit distanceYUnit() const
Returns the units for the vertical distance between points in the pattern.
const QgsMapUnitScale & displacementYMapUnitScale() const
Returns the map unit scale for the vertical displacement between odd numbered columns in the pattern.
void setDistanceXUnit(Qgis::RenderUnit unit)
Sets the unit for the horizontal distance between points in the pattern.
void setOffsetYUnit(Qgis::RenderUnit unit)
Sets the units for the vertical offset for rows in the pattern.
const QgsMapUnitScale & randomDeviationYMapUnitScale() const
Returns the unit scale for the vertical random deviation of points in the pattern.
Qgis::RenderUnit offsetXUnit() const
Returns the units for the horizontal offset for rows in the pattern.
void setOffsetYMapUnitScale(const QgsMapUnitScale &scale)
Sets the unit scale for the vertical offset for rows in the pattern.
void setDistanceY(double d)
Sets the vertical distance between rendered markers in the fill.
Qgis::RenderUnit displacementXUnit() const
Returns the units for the horizontal displacement between rows in the pattern.
Qgis::RenderUnit randomDeviationXUnit() const
Returns the units for the horizontal random deviation of points in the pattern.
void setDisplacementXUnit(Qgis::RenderUnit unit)
Sets the units for the horizontal displacement between rows in the pattern.
void setDistanceX(double d)
Sets the horizontal distance between rendered markers in the fill.
double offsetX() const
Returns the horizontal offset values for points in the pattern.
void setRandomDeviationXUnit(Qgis::RenderUnit unit)
Sets the unit for the horizontal random deviation of points in the pattern.
double maximumRandomDeviationX() const
Returns the maximum horizontal random deviation of points in the pattern.
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the horizontal displacement between odd numbered rows in the pattern.
void setMaximumRandomDeviationY(double deviation)
Sets the maximum vertical random deviation of points in the pattern.
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the vertical distance between points in the pattern.
Qgis::RenderUnit displacementYUnit() const
Returns the units for the vertical displacement between rows in the pattern.
double displacementX() const
Returns the horizontal displacement for odd numbered rows in the pattern.
void setOffsetXMapUnitScale(const QgsMapUnitScale &scale)
Sets the unit scale for the horizontal offset for rows in the pattern.
double distanceY() const
Returns the vertical distance between rendered markers in the fill.
void setClipMode(Qgis::MarkerClipMode mode)
Sets the marker clipping mode, which defines how markers are clipped at the edges of shapes.
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
Definition for a property.
Definition qgsproperty.h:45
A button for controlling property overrides which may apply to a widget.
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
void updateFieldLists()
Updates list of fields.
void changed()
Emitted when property definition changes.
void init(int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
Initialize a newly constructed property button (useful if button was included in a UI layout).
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
int propertyKey() const
Returns the property key linked to the button.
void setToProperty(const QgsProperty &property)
Sets the widget to reflect the current state of a QgsProperty.
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
A store for object properties.
void setField(const QString &field)
Sets the field name the property references.
QgsRandomMarkerFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsRandomMarkerFillSymbolLayerWidget.
void setSymbolLayer(QgsSymbolLayer *layer) override
A fill symbol layer which places markers at random locations within polygons.
int pointCount() const
Returns the count of random points to render in the fill.
unsigned long seed() const
Returns the random number seed to use when generating points, or 0 if a truly random sequence will be...
void setDensityAreaUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the density area.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setCountMethod(Qgis::PointCountMethod method)
Sets the count method used to randomly fill the polygon.
bool clipPoints() const
Returns true if point markers should be clipped to the polygon boundary.
void setClipPoints(bool clipped)
Sets whether point markers should be clipped to the polygon boundary.
void setSeed(unsigned long seed)
Sets the random number seed to use when generating points, or 0 if a truly random sequence will be us...
void setPointCount(int count)
Sets the count of random points to render in the fill.
Qgis::RenderUnit densityAreaUnit() const
Returns the units for the density area.
Qgis::PointCountMethod countMethod() const
Returns the count method used to randomly fill the polygon.
void setDensityAreaUnit(Qgis::RenderUnit unit)
Sets the units for the density area.
const QgsMapUnitScale & densityAreaUnitScale() const
Returns the map scale for the density area.
double densityArea() const
Returns the density area used to count the number of points to randomly fill the polygon.
void setDensityArea(double area)
Sets the density area used to count the number of points to randomly fill the polygon.
QgsRasterFillSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSymbolLayer * symbolLayer() override
QgsRasterFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsRasterFillSymbolLayerWidget.
A class for filling symbols with a repeated raster image.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the image's width and height.
double width() const
Returns the width used for scaling the image used in the fill.
void setOffsetUnit(const Qgis::RenderUnit unit)
Sets the units for the fill's offset.
void setHeight(double height)
Sets the height for scaling the image.
Qgis::SymbolCoordinateReference coordinateMode() const
Coordinate mode for fill.
Qgis::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
double opacity() const
Returns the opacity for the raster image used in the fill.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the unit for the image's width and height.
void setOpacity(double opacity)
Sets the opacity for the raster image used in the fill.
Qgis::RenderUnit sizeUnit() const
Returns the units for the image's width and height.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
QString imageFilePath() const
The path to the raster image used for the fill.
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
double height() const
Returns the height used for scaling the image used in the fill.
void setWidth(double width)
Sets the width for scaling the image used in the fill.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image's width and height.
QPointF offset() const
Returns the offset for the fill.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
void setOffset(QPointF offset)
Sets the offset for the fill.
void setCoordinateMode(Qgis::SymbolCoordinateReference mode)
Set the coordinate mode for fill.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSymbolLayer * symbolLayer() override
QgsRasterLineSymbolLayer * mLayer
QgsRasterLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsRasterLineSymbolLayerWidget.
Line symbol layer type which draws line sections using a raster image file.
double opacity() const
Returns the line opacity.
QString path() const
Returns the raster image path.
void setPath(const QString &path)
Set the raster image path.
void setOpacity(double opacity)
Set the line opacity.
QgsRasterMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsRasterMarkerSymbolLayerWidget.
QgsRasterMarkerSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbolLayer * symbolLayer() override
Raster marker symbol layer class.
void setOpacity(double opacity)
Set the marker opacity.
QString path() const
Returns the marker raster image path.
void setPath(const QString &path)
Set the marker raster image path.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
double opacity() const
Returns the marker opacity.
A cross platform button subclass used to represent a locked / unlocked ratio state.
void lockChanged(bool locked)
Emitted whenever the lock state changes.
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSVGFillSymbolLayer * mLayer
void updateParamGui(bool resetValues=true)
Enables or disables svg fill color, stroke color and stroke width based on whether the svg file suppo...
QgsSVGFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSVGFillSymbolLayerWidget.
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
A class for filling symbols with a repeated SVG file.
void setParameters(const QMap< QString, QgsProperty > &parameters)
Sets the dynamic SVG parameters.
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
void setSvgStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's stroke.
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
void setSvgStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the unit for the stroke width.
Qgis::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
void setSvgFillColor(const QColor &c)
Sets the fill color used for rendering the SVG content.
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern's stroke.
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
void setSvgStrokeWidth(double w)
Sets the stroke width used for rendering the SVG content.
void setPatternWidthUnit(Qgis::RenderUnit unit)
Sets the unit for the width of the SVG images in the pattern.
void setSvgFilePath(const QString &svgPath)
Sets the path to the SVG file to render in the fill.
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
void setSvgStrokeColor(const QColor &c)
Sets the stroke color used for rendering the SVG content.
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern's width.
Qgis::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
void setPatternWidth(double width)
Sets the width to render the SVG content as within the fill (i.e.
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's width.
Stores properties relating to a screen.
QgsShapeburstFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsShapeburstFillSymbolLayerWidget.
QgsShapeburstFillSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
Qgis::RenderUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
QgsColorRamp * colorRamp()
Returns the color ramp used for the shapeburst fill.
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the units used for the offset for the shapeburst fill.
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
void setBlurRadius(int blurRadius)
Sets the blur radius, which controls the amount of blurring applied to the fill.
void setUseWholeShape(bool useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading.
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon's boundary.
void setColor2(const QColor &color2)
Sets the color for the endpoint of the shapeburst fill.
Qgis::RenderUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon's boundary.
QPointF offset() const
Returns the offset for the shapeburst fill.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
const QgsMapUnitScale & offsetMapUnitScale() const
void setDistanceUnit(Qgis::RenderUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
void setColorType(Qgis::GradientColorSource colorType)
Sets the color mode to use for the shapeburst fill.
Qgis::GradientColorSource colorType() const
Returns the color mode used for the shapeburst fill.
const QgsMapUnitScale & distanceMapUnitScale() const
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used to draw the shapeburst fill.
QgsSimpleFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleFillSymbolLayerWidget.
void setStrokeColor(const QColor &color)
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSimpleFillSymbolLayer * mLayer
QgsSymbolLayer * symbolLayer() override
Renders polygons using a single fill and stroke color.
Qgis::RenderUnit strokeWidthUnit() const
Returns the units for the width of the fill's stroke.
Qt::PenJoinStyle penJoinStyle() const
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
void setBrushStyle(Qt::BrushStyle style)
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & strokeWidthMapUnitScale() const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the units for the width of the fill's stroke.
void setPenJoinStyle(Qt::PenJoinStyle style)
Qt::PenStyle strokeStyle() const
void setStrokeWidth(double strokeWidth)
QPointF offset() const
Returns the offset by which polygons will be translated during rendering.
Qgis::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
void setStrokeStyle(Qt::PenStyle strokeStyle)
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the unit for the fill's offset.
void setOffset(QPointF offset)
Sets an offset by which polygons will be translated during rendering.
void setStrokeColor(const QColor &strokeColor) override
Sets the stroke color for the symbol layer.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
Qt::BrushStyle brushStyle() const
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
~QgsSimpleLineSymbolLayerWidget() override
QgsSimpleLineSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSymbolLayer * symbolLayer() override
QgsSimpleLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleLineSymbolLayerWidget.
void resizeEvent(QResizeEvent *event) override
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
void setDrawInsidePolygon(bool drawInsidePolygon)
Sets whether the line should only be drawn inside polygons, and any portion of the line which falls o...
bool tweakDashPatternOnCorners() const
Returns true if dash patterns tweaks should be applied on sharp corners, to ensure that a double-leng...
const QgsMapUnitScale & customDashPatternMapUnitScale() const
Returns the map unit scale for lengths used in the custom dash pattern.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
const QgsMapUnitScale & trimDistanceEndMapUnitScale() const
Returns the map unit scale for the trim distance for the end of the line.
QVector< qreal > customDashVector() const
Returns the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ...
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
const QgsMapUnitScale & trimDistanceStartMapUnitScale() const
Returns the map unit scale for the trim distance for the start of the line.
void setCustomDashPatternMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for lengths used in the custom dash pattern.
void setTrimDistanceEndMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the trim distance for the end of the line.
void setTrimDistanceEnd(double distance)
Sets the trim distance for the end of the line, which dictates a length from the end of the line at w...
double trimDistanceStart() const
Returns the trim distance for the start of the line, which dictates a length from the start of the li...
void setUseCustomDashPattern(bool b)
Sets whether the line uses a custom dash pattern.
void setTweakDashPatternOnCorners(bool enabled)
Sets whether dash patterns tweaks should be applied on sharp corners, to ensure that a double-length ...
Qgis::RenderUnit customDashPatternUnit() const
Returns the units for lengths used in the custom dash pattern.
double trimDistanceEnd() const
Returns the trim distance for the end of the line, which dictates a length from the end of the line a...
Qgis::RenderUnit dashPatternOffsetUnit() const
Returns the units for the dash pattern offset.
const QgsMapUnitScale & dashPatternOffsetMapUnitScale() const
Returns the map unit scale for the dash pattern offset value.
void setCustomDashVector(const QVector< qreal > &vector)
Sets the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ren...
bool useCustomDashPattern() const
Returns true if the line uses a custom dash pattern.
void setDashPatternOffset(double offset)
Sets the dash pattern offset, which dictates how far along the dash pattern the pattern should start ...
void setDashPatternOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the dash pattern offset.
QgsSimpleLineSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setPenStyle(Qt::PenStyle style)
Sets the pen style used to render the line (e.g.
Qt::PenStyle penStyle() const
Returns the pen style used to render the line (e.g.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
double dashPatternOffset() const
Returns the dash pattern offset, which dictates how far along the dash pattern the pattern should sta...
void setAlignDashPattern(bool enabled)
Sets whether dash patterns should be aligned to the start and end of lines, by applying subtle tweaks...
void setTrimDistanceStartMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the trim distance for the start of the line.
Qgis::RenderUnit trimDistanceStartUnit() const
Returns the unit for the trim distance for the start of the line.
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
void setTrimDistanceEndUnit(Qgis::RenderUnit unit)
Sets the unit for the trim distance for the end of the line.
void setDashPatternOffsetUnit(Qgis::RenderUnit unit)
Sets the unit for the dash pattern offset.
bool drawInsidePolygon() const
Returns true if the line should only be drawn inside polygons, and any portion of the line which fall...
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setTrimDistanceStart(double distance)
Sets the trim distance for the start of the line, which dictates a length from the start of the line ...
void setTrimDistanceStartUnit(Qgis::RenderUnit unit)
Sets the unit for the trim distance for the start of the line.
Qgis::RenderUnit trimDistanceEndUnit() const
Returns the unit for the trim distance for the end of the line.
bool alignDashPattern() const
Returns true if dash patterns should be aligned to the start and end of lines, by applying subtle twe...
void setCustomDashPatternUnit(Qgis::RenderUnit unit)
Sets the unit for lengths used in the custom dash pattern.
static QList< Qgis::MarkerShape > availableShapes()
Returns a list of all available shape types.
static bool shapeIsFilled(Qgis::MarkerShape shape)
Returns true if a symbol shape has a fill.
Qgis::MarkerShape shape() const
Returns the shape for the rendered marker symbol.
static QString encodeShape(Qgis::MarkerShape shape)
Encodes a shape to its string representation.
void setShape(Qgis::MarkerShape shape)
Sets the rendered marker shape.
QgsSymbolLayer * symbolLayer() override
void setColorStroke(const QColor &color)
QgsSimpleMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleMarkerSymbolLayerWidget.
QgsSimpleMarkerSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
void setColor(const QColor &color) override
Sets the "representative" color for the symbol layer.
Qt::PenJoinStyle penJoinStyle() const
Returns the marker's stroke join style (e.g., miter, bevel, etc).
void setStrokeWidthUnit(Qgis::RenderUnit u)
Sets the unit for the width of the marker's stroke.
QgsSimpleMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Qt::PenCapStyle penCapStyle() const
Returns the marker's stroke cap style (e.g., flat, round, etc).
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker's stroke.
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc)
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the map scale for the width of the marker's stroke.
QColor fillColor() const override
Returns the fill color for the symbol layer.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the marker's stroke join style (e.g., miter, bevel, etc).
QColor strokeColor() const override
Returns the marker's stroke color.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
Qt::PenStyle strokeStyle() const
Returns the marker's stroke style (e.g., solid, dashed, etc)
Qgis::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker's stroke.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, etc).
double strokeWidth() const
Returns the width of the marker's stroke.
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth, bool blocking=false) const
Tests if an SVG file contains parameters for fill, stroke color, stroke width.
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
void setGuiForSvg(const QgsSvgMarkerSymbolLayer *layer, bool skipDefaultColors=false)
Updates the GUI to reflect the SVG marker symbol layer.
void setSvgPath(const QString &name)
Sets the SVG path.
QgsSvgMarkerSymbolLayer * mLayer
QgsSvgMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSvgMarkerSymbolLayerWidget.
void setSvgParameters(const QMap< QString, QgsProperty > &parameters)
Sets the dynamic SVG parameters.
~QgsSvgMarkerSymbolLayerWidget() override
QgsSvgMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QColor fillColor() const override
Returns the fill color for the symbol layer.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QString path() const
Returns the marker SVG path.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the units for the stroke width.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
void setFillColor(const QColor &color) override
Sets the fill color for the symbol layer.
Qgis::RenderUnit strokeWidthUnit() const
Returns the units for the stroke width.
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
void setParameters(const QMap< QString, QgsProperty > &parameters)
Sets the dynamic SVG parameters.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
void setPath(const QString &path)
Set the marker SVG path.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
void svgParametersChanged(const QMap< QString, QgsProperty > &parameters)
Emitted when the parameters have changed.
void svgSelected(const QString &path)
Emitted when an SVG is selected in the widget.
static QIcon symbolLayerPreviewIcon(const QgsSymbolLayer *layer, Qgis::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::SymbolType parentSymbolType=Qgis::SymbolType::Hybrid, QgsMapLayer *mapLayer=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Draws a symbol layer preview to an icon.
static QPixmap symbolPreviewPixmap(const QgsSymbol *symbol, QSize size, int padding=0, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *shape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Returns a pixmap preview for a color ramp.
static QIcon symbolPreviewIcon(const QgsSymbol *symbol, QSize size, int padding=0, QgsLegendPatchShape *shape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Returns an icon preview for a color ramp.
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key)
Registers a data defined override button.
void changed()
Should be emitted whenever configuration changes happened on this symbol layer configuration.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void symbolChanged()
Should be emitted whenever the sub symbol changed on this symbol layer configuration.
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
virtual QgsSymbolLayer * symbolLayer()=0
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
Property
Data definable properties.
@ SkipMultiples
Skip multiples of.
@ GradientType
Gradient fill type.
@ SecondaryColor
Secondary color (eg for gradient fills)
@ File
Filename, eg for svg files.
@ VerticalAnchor
Vertical anchor point.
@ GradientReference2Y
Gradient reference point 2 y.
@ GradientReference1X
Gradient reference point 1 x.
@ OffsetY
Vertical offset.
@ OffsetX
Horizontal offset.
@ GradientReference1Y
Gradient reference point 1 y.
@ PointCount
Point count.
@ DashPatternOffset
Dash pattern offset,.
@ GradientSpread
Gradient spread mode.
@ OffsetAlongLine
Offset along line.
@ CustomDash
Custom dash pattern.
@ ShapeburstMaxDistance
Shapeburst fill from edge distance.
@ HorizontalAnchor
Horizontal anchor point.
@ StrokeStyle
Stroke style (eg solid, dashed)
@ Name
Name, eg shape name for simple markers.
@ DistanceY
Vertical distance between points.
@ DensityArea
Density area.
@ ClipPoints
Whether markers should be clipped to polygon boundaries.
@ LineClipping
Line clipping mode.
@ ShapeburstIgnoreRings
Shapeburst ignore rings.
@ Character
Character, eg for font marker symbol layers.
@ ShapeburstUseWholeShape
Shapeburst use whole shape.
@ DisplacementX
Horizontal displacement.
@ ShowMarker
Show markers.
@ CoordinateMode
Gradient coordinate mode.
@ FillStyle
Fill style (eg solid, dots)
@ GradientReference2X
Gradient reference point 2 x.
@ StrokeColor
Stroke color.
@ TrimStart
Trim distance from start of line.
@ CapStyle
Line cap style.
@ BlurRadius
Shapeburst blur radius.
@ Placement
Line marker placement.
@ MarkerClipping
Marker clipping mode.
@ RandomSeed
Random number seed.
@ LineAngle
Line angle, or angle of hash lines for hash line symbols.
@ JoinStyle
Line join style.
@ RandomOffsetY
Random offset Y.
@ DisplacementY
Vertical displacement.
@ DistanceX
Horizontal distance between points.
@ AverageAngleLength
Length to average symbol angles over.
@ GradientReference1IsCentroid
Gradient reference point 1 is centroid.
@ Interval
Line marker interval.
@ StrokeWidth
Stroke width.
@ FontFamily
Font family.
@ GradientReference2IsCentroid
Gradient reference point 2 is centroid.
@ LineDistance
Distance between lines, or length of lines for hash line symbols.
@ Offset
Symbol offset.
@ RandomOffsetX
Random offset X.
@ TrimEnd
Trim distance from end of line.
@ Height
Symbol height.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Qgis::SymbolType symbolType() const
Returns the associated symbol type, if the widget is being shown as a subcomponent of a parent symbol...
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
bool rotateSymbols() const
Returns true if the repeating symbols be rotated to match their line segment orientation.
bool placeOnEveryPart() const
Returns true if the placement applies for every part of multi-part feature geometries.
double averageAngleLength() const
Returns the length of line over which the line's direction is averaged when calculating individual sy...
void setMapUnitScale(const QgsMapUnitScale &scale) FINAL
void setRotateSymbols(bool rotate)
Sets whether the repeating symbols should be rotated to match their line segment orientation.
void setIntervalUnit(Qgis::RenderUnit unit)
Sets the units for the interval between symbols.
void setAverageAngleUnit(Qgis::RenderUnit unit)
Sets the unit for the length over which the line's direction is averaged when calculating individual ...
const QgsMapUnitScale & averageAngleMapUnitScale() const
Returns the map unit scale for the length over which the line's direction is averaged when calculatin...
double interval() const
Returns the interval between individual symbols.
void setOffsetAlongLineUnit(Qgis::RenderUnit unit)
Sets the unit used for calculating the offset along line for symbols.
void setAverageAngleMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the length over which the line's direction is averaged when calculating i...
const QgsMapUnitScale & intervalMapUnitScale() const
Returns the map unit scale for the interval between symbols.
double offsetAlongLine() const
Returns the offset along the line for the symbol placement.
Qgis::MarkerLinePlacements placements() const
Returns the placement of the symbols.
void setOffsetAlongLine(double offsetAlongLine)
Sets the the offset along the line for the symbol placement.
Qgis::RenderUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for symbols.
void setInterval(double interval)
Sets the interval between individual symbols.
Qgis::RenderUnit intervalUnit() const
Returns the units for the interval between symbols.
void setPlaceOnEveryPart(bool respect)
Sets whether the placement applies for every part of multi-part feature geometries.
void setPlacements(Qgis::MarkerLinePlacements placements)
Sets the placement of the symbols.
Qgis::RenderUnit averageAngleUnit() const
Returns the unit for the length over which the line's direction is averaged when calculating individu...
const QgsMapUnitScale & offsetAlongLineMapUnitScale() const
Returns the map unit scale used for calculating the offset in map units along line for symbols.
void setIntervalMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the interval between symbols.
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset in map units along line for symbols.
void setAverageAngleLength(double length)
Sets the length of line over which the line's direction is averaged when calculating individual symbo...
A widget displaying a combobox allowing the user to choose between various display units,...
void changed()
Emitted when the selected unit is changed, or the definition of the map unit scale is changed.
QList< Qgis::RenderUnit > RenderUnitList
List of render units.
Represents a vector layer which manages a vector based data sets.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:6123
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition qgssymbol.h:30
Single variable definition for use within a QgsExpressionContextScope.