QGIS API Documentation 3.39.0-Master (d85f3c2a281)
Loading...
Searching...
No Matches
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
19#include "qgslinesymbollayer.h"
21#include "qgsfillsymbollayer.h"
24
25#include "characterwidget.h"
26#include "qgsdashspacedialog.h"
27#include "qgssvgcache.h"
28#include "qgssymbollayerutils.h"
29#include "qgscolorramp.h"
30#include "qgscolorrampbutton.h"
31#include "qgsfontutils.h"
32#include "qgsproperty.h"
33#include "qgsmapcanvas.h"
34#include "qgsapplication.h"
35#include "qgsvectorlayer.h"
39#include "qgsauxiliarystorage.h"
40#include "qgsimagecache.h"
41#include "qgslinesymbol.h"
42#include "qgsmarkersymbol.h"
43#include "qgsfillsymbol.h"
44#include "qgsiconutils.h"
47
48#include <QAbstractButton>
49#include <QButtonGroup>
50#include <QColorDialog>
51#include <QCursor>
52#include <QDir>
53#include <QFileDialog>
54#include <QPainter>
55#include <QStandardItemModel>
56#include <QSvgRenderer>
57#include <QMessageBox>
58#include <QMenu>
59#include <QAction>
60#include <QInputDialog>
61#include <QBuffer>
62#include <QRegularExpression>
63#include <QMovie>
64
66{
67 if ( auto *lExpressionContext = mContext.expressionContext() )
68 return *lExpressionContext;
69
71
73 if ( const QgsSymbolLayer *symbolLayer = const_cast< QgsSymbolLayerWidget * >( this )->symbolLayer() )
74 {
75 //cheat a bit - set the symbol color variable to match the symbol layer's color (when we should really be using the *symbols*
76 //color, but that's not accessible here). 99% of the time these will be the same anyway
78 }
79 expContext << symbolScope;
85 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_count" ), 1, true ) );
86 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_index" ), 1, true ) );
87 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_row" ), 1, true ) );
88 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_column" ), 1, true ) );
89 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_frame" ), 1, true ) );
90
91 // additional scopes
92 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
93 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
94 {
95 expContext.appendScope( new QgsExpressionContextScope( scope ) );
96 }
97
98 //TODO - show actual value
99 expContext.setOriginalValueVariable( QVariant() );
100
101 QStringList highlights;
107 << QStringLiteral( "symbol_layer_count" ) << QStringLiteral( "symbol_layer_index" ) << QStringLiteral( "symbol_frame" );
108
109
110 if ( expContext.hasVariable( QStringLiteral( "zoom_level" ) ) )
111 {
112 highlights << QStringLiteral( "zoom_level" );
113 }
114 if ( expContext.hasVariable( QStringLiteral( "vector_tile_zoom" ) ) )
115 {
116 highlights << QStringLiteral( "vector_tile_zoom" );
117 }
118
119 expContext.setHighlightedVariables( highlights );
120
121 return expContext;
122}
123
125{
126 mContext = context;
127 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
128 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
129 {
130 unitWidget->setMapCanvas( mContext.mapCanvas() );
131 }
132}
133
135{
136 return mContext;
137}
138
140{
141 button->init( static_cast< int >( key ), symbolLayer()->dataDefinedProperties(), QgsSymbolLayer::propertyDefinitions(), mVectorLayer, true );
143 connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolLayerWidget::createAuxiliaryField );
144
146}
147
148void QgsSymbolLayerWidget::createAuxiliaryField()
149{
150 // try to create an auxiliary layer if not yet created
151 if ( !mVectorLayer->auxiliaryLayer() )
152 {
153 QgsNewAuxiliaryLayerDialog dlg( mVectorLayer, this );
154 dlg.exec();
155 }
156
157 // return if still not exists
158 if ( !mVectorLayer->auxiliaryLayer() )
159 return;
160
161 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
162 QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
163 QgsPropertyDefinition def = QgsSymbolLayer::propertyDefinitions()[static_cast< int >( key )];
164
165 // create property in auxiliary storage if necessary
166 if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
167 {
168 QgsNewAuxiliaryFieldDialog dlg( def, mVectorLayer, true, this );
169 if ( dlg.exec() == QDialog::Accepted )
170 def = dlg.propertyDefinition();
171 }
172
173 // return if still not exist
174 if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
175 return;
176
177 // update property with join field name from auxiliary storage
178 QgsProperty property = button->toProperty();
179 property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
180 property.setActive( true );
181 button->updateFieldLists();
182 button->setToProperty( property );
183 symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
184
185 emit changed();
186}
187
189{
190 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
191 const QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
192 symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
193 emit changed();
194}
195
197 : QgsSymbolLayerWidget( parent, vl )
198{
199 mLayer = nullptr;
200
201 setupUi( this );
202 connect( mCustomCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged );
203 connect( mChangePatternButton, &QPushButton::clicked, this, &QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked );
204 connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed );
205 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed );
206 connect( mDashPatternUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed );
207 connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
208 connect( mPatternOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::patternOffsetUnitChanged );
209 connect( mCheckAlignDash, &QCheckBox::toggled, this, [ = ]
210 {
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 {
223 if ( mLayer )
224 {
225 mLayer->setTweakDashPatternOnCorners( mCheckDashCorners->isChecked() );
226 emit changed();
227 }
228 } );
229
242
243 btnChangeColor->setAllowOpacity( true );
244 btnChangeColor->setColorDialogTitle( tr( "Select Line Color" ) );
245 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
246
247 mColorDDBtn->registerLinkedWidget( btnChangeColor );
248
249 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
250 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
251 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
252 connect( mRingFilterComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
253 {
254 if ( mLayer )
255 {
256 mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
257 emit changed();
258 }
259 } );
260
261 spinOffset->setClearValue( 0.0 );
262 spinPatternOffset->setClearValue( 0.0 );
263
264 mTrimStartDistanceSpin->setClearValue( 0.0 );
265 mTrimDistanceEndSpin->setClearValue( 0.0 );
266
267 //make a temporary symbol for the size assistant preview
268 mAssistantPreviewSymbol.reset( new QgsLineSymbol() );
269
270 if ( vectorLayer() )
271 mPenWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
272
273 connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::penWidthChanged );
274 connect( btnChangeColor, &QgsColorButton::colorChanged, this, &QgsSimpleLineSymbolLayerWidget::colorChanged );
275 connect( cboPenStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
276 connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::offsetChanged );
277 connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
278 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
279 connect( spinPatternOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::patternOffsetChanged );
280
281 connect( mTrimStartDistanceSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
282 {
283 if ( !mLayer )
284 return;
285
287 emit changed();
288 } );
289 connect( mTrimDistanceStartUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
290 {
291 if ( !mLayer )
292 return;
293
294 mLayer->setTrimDistanceStartUnit( mTrimDistanceStartUnitWidget->unit() );
295 mLayer->setTrimDistanceStartMapUnitScale( mTrimDistanceStartUnitWidget->getMapUnitScale() );
296 emit changed();
297 } );
298 connect( mTrimDistanceEndSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
299 {
300 if ( !mLayer )
301 return;
302
303 mLayer->setTrimDistanceEnd( value );
304 emit changed();
305 } );
306 connect( mTrimDistanceEndUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
307 {
308 if ( !mLayer )
309 return;
310
311 mLayer->setTrimDistanceEndUnit( mTrimDistanceEndUnitWidget->unit() );
312 mLayer->setTrimDistanceEndMapUnitScale( mTrimDistanceEndUnitWidget->getMapUnitScale() );
313 emit changed();
314 } );
315
316
318
319 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol );
320}
321
323
324void QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol()
325{
326 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
327 {
328 mAssistantPreviewSymbol->deleteSymbolLayer( i );
329 }
330 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
332 if ( ddWidth )
333 mAssistantPreviewSymbol->setDataDefinedWidth( ddWidth );
334}
335
336
338{
339 if ( !layer || layer->layerType() != QLatin1String( "SimpleLine" ) )
340 return;
341
342 // layer type is correct, we can do the cast
343 mLayer = static_cast<QgsSimpleLineSymbolLayer *>( layer );
344
345 // set units
346 mPenWidthUnitWidget->blockSignals( true );
347 mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
348 mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
349 mPenWidthUnitWidget->blockSignals( false );
350 mOffsetUnitWidget->blockSignals( true );
351 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
352 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
353 mOffsetUnitWidget->blockSignals( false );
354 mDashPatternUnitWidget->blockSignals( true );
355 mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
356 mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
357 mDashPatternUnitWidget->blockSignals( false );
358
359 whileBlocking( mPatternOffsetUnitWidget )->setUnit( mLayer->dashPatternOffsetUnit() );
360 whileBlocking( mPatternOffsetUnitWidget )->setMapUnitScale( mLayer->dashPatternOffsetMapUnitScale() );
361 whileBlocking( mTrimDistanceStartUnitWidget )->setUnit( mLayer->trimDistanceStartUnit() );
362 whileBlocking( mTrimDistanceStartUnitWidget )->setMapUnitScale( mLayer->trimDistanceStartMapUnitScale() );
363 whileBlocking( mTrimDistanceEndUnitWidget )->setUnit( mLayer->trimDistanceEndUnit() );
364 whileBlocking( mTrimDistanceEndUnitWidget )->setMapUnitScale( mLayer->trimDistanceEndMapUnitScale() );
365
366 // set values
367 spinWidth->blockSignals( true );
368 spinWidth->setValue( mLayer->width() );
369 spinWidth->blockSignals( false );
370 btnChangeColor->blockSignals( true );
371 btnChangeColor->setColor( mLayer->color() );
372 btnChangeColor->blockSignals( false );
373 spinOffset->blockSignals( true );
374 spinOffset->setValue( mLayer->offset() );
375 spinOffset->blockSignals( false );
376 cboPenStyle->blockSignals( true );
377 cboJoinStyle->blockSignals( true );
378 cboCapStyle->blockSignals( true );
379 cboPenStyle->setPenStyle( mLayer->penStyle() );
380 cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
381 cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
382 cboPenStyle->blockSignals( false );
383 cboJoinStyle->blockSignals( false );
384 cboCapStyle->blockSignals( false );
385 whileBlocking( spinPatternOffset )->setValue( mLayer->dashPatternOffset() );
386 whileBlocking( mTrimStartDistanceSpin )->setValue( mLayer->trimDistanceStart() );
387 whileBlocking( mTrimDistanceEndSpin )->setValue( mLayer->trimDistanceEnd() );
388
389 //use a custom dash pattern?
390 const bool useCustomDashPattern = mLayer->useCustomDashPattern();
391 mChangePatternButton->setEnabled( useCustomDashPattern );
392 label_3->setEnabled( !useCustomDashPattern );
393 cboPenStyle->setEnabled( !useCustomDashPattern );
394 mCustomCheckBox->blockSignals( true );
395 mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
396 mCustomCheckBox->blockSignals( false );
397
398 //make sure height of custom dash button looks good under different platforms
399 const QSize size = mChangePatternButton->minimumSizeHint();
400 const int fontHeight = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 1.4 );
401 mChangePatternButton->setMinimumSize( QSize( size.width(), std::max( size.height(), fontHeight ) ) );
402
403 //draw inside polygon?
404 const bool drawInsidePolygon = mLayer->drawInsidePolygon();
405 whileBlocking( mDrawInsideCheckBox )->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
406
407 whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
408
409 whileBlocking( mCheckAlignDash )->setChecked( mLayer->alignDashPattern() );
410 mCheckDashCorners->setEnabled( mLayer->alignDashPattern() );
411 whileBlocking( mCheckDashCorners )->setChecked( mLayer->tweakDashPatternOnCorners() && mLayer->alignDashPattern() );
412
414
425
426 updateAssistantSymbol();
427}
428
433
435{
437
438 switch ( context.symbolType() )
439 {
442 //these settings only have an effect when the symbol layers is part of a fill symbol
443 mDrawInsideCheckBox->hide();
444 mRingFilterComboBox->hide();
445 mRingsLabel->hide();
446 break;
447
450 break;
451 }
452}
453
454void QgsSimpleLineSymbolLayerWidget::penWidthChanged()
455{
456 mLayer->setWidth( spinWidth->value() );
458 emit changed();
459}
460
461void QgsSimpleLineSymbolLayerWidget::colorChanged( const QColor &color )
462{
463 mLayer->setColor( color );
464 emit changed();
465}
466
467void QgsSimpleLineSymbolLayerWidget::penStyleChanged()
468{
469 mLayer->setPenStyle( cboPenStyle->penStyle() );
470 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
471 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
473 emit changed();
474}
475
476void QgsSimpleLineSymbolLayerWidget::offsetChanged()
477{
478 mLayer->setOffset( spinOffset->value() );
480 emit changed();
481}
482
483void QgsSimpleLineSymbolLayerWidget::patternOffsetChanged()
484{
485 mLayer->setDashPatternOffset( spinPatternOffset->value() );
487 emit changed();
488}
489
490void QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged( int state )
491{
492 const bool checked = ( state == Qt::Checked );
493 mChangePatternButton->setEnabled( checked );
494 label_3->setEnabled( !checked );
495 cboPenStyle->setEnabled( !checked );
496
498 emit changed();
499}
500
501void QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked()
502{
504 if ( panel && panel->dockMode() )
505 {
507 widget->setPanelTitle( tr( "Custom Dash Pattern" ) );
508 widget->setUnit( mDashPatternUnitWidget->unit() );
509 connect( widget, &QgsPanelWidget::widgetChanged, this, [ this, widget ]()
510 {
513 } );
515 panel->openPanel( widget );
516 return;
517 }
518
520 d.setUnit( mDashPatternUnitWidget->unit() );
521 if ( d.exec() == QDialog::Accepted )
522 {
523 mLayer->setCustomDashVector( d.dashDotVector() );
525 emit changed();
526 }
527}
528
529void QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed()
530{
531 if ( mLayer )
532 {
533 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
534 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
536 emit changed();
537 }
538}
539
540void QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed()
541{
542 if ( mLayer )
543 {
544 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
545 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
546 emit changed();
547 }
548}
549
550void QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed()
551{
552 if ( mLayer )
553 {
554 mLayer->setCustomDashPatternUnit( mDashPatternUnitWidget->unit() );
555 mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
557 emit changed();
558 }
559}
560
561void QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
562{
563 const bool checked = ( state == Qt::Checked );
564 mLayer->setDrawInsidePolygon( checked );
565 emit changed();
566}
567
568void QgsSimpleLineSymbolLayerWidget::patternOffsetUnitChanged()
569{
570 if ( mLayer )
571 {
572 mLayer->setDashPatternOffsetUnit( mPatternOffsetUnitWidget->unit() );
573 mLayer->setDashPatternOffsetMapUnitScale( mPatternOffsetUnitWidget->getMapUnitScale() );
575 emit changed();
576 }
577}
578
580{
581 if ( !mLayer )
582 {
583 return;
584 }
585 std::unique_ptr< QgsSimpleLineSymbolLayer > layerCopy( mLayer->clone() );
586 if ( !layerCopy )
587 {
588 return;
589 }
590 const QColor color = qApp->palette().color( QPalette::WindowText );
591 layerCopy->setColor( color );
592 // reset offset, we don't want to show that in the preview
593 layerCopy->setOffset( 0 );
594 layerCopy->setUseCustomDashPattern( true );
595
596 QSize currentIconSize;
597 //icon size is button size with a small margin
598#ifdef Q_OS_WIN
599 currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 6 );
600#else
601 currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 12 );
602#endif
603
604 if ( !currentIconSize.isValid() || currentIconSize.width() <= 0 || currentIconSize.height() <= 0 )
605 {
606 return;
607 }
608
609 //create an icon pixmap
610 const std::unique_ptr< QgsLineSymbol > previewSymbol = std::make_unique< QgsLineSymbol >( QgsSymbolLayerList() << layerCopy.release() );
611 const QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( previewSymbol.get(), currentIconSize, 0, nullptr, QgsScreenProperties( screen() ) );
612 mChangePatternButton->setIconSize( currentIconSize );
613 mChangePatternButton->setIcon( icon );
614
615 // set tooltip
616 // create very large preview image
617 const int width = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 23 );
618 const int height = static_cast< int >( width / 1.61803398875 ); // golden ratio
619
620 const QPixmap pm = QgsSymbolLayerUtils::symbolPreviewPixmap( previewSymbol.get(), QSize( width, height ), height / 20, nullptr, false, nullptr, nullptr, QgsScreenProperties( screen() ) );
621 QByteArray data;
622 QBuffer buffer( &data );
623 pm.save( &buffer, "PNG", 100 );
624 mChangePatternButton->setToolTip( QStringLiteral( "<img src='data:image/png;base64, %3' width=\"%4\">" ).arg( QString( data.toBase64() ) ).arg( width ) );
625}
626
628{
629 QgsSymbolLayerWidget::resizeEvent( event );
630 // redraw custom dash pattern icon -- the button size has changed
632}
633
634
636
637
639 : QgsSymbolLayerWidget( parent, vl )
640{
641 mLayer = nullptr;
642
643 setupUi( this );
644 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
645 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
646 connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
647 connect( mStrokeStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
648 connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
649 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
650 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
657
658 btnChangeColorFill->setAllowOpacity( true );
659 btnChangeColorFill->setColorDialogTitle( tr( "Select Fill Color" ) );
660 btnChangeColorFill->setContext( QStringLiteral( "symbology" ) );
661 btnChangeColorFill->setShowNoColor( true );
662 btnChangeColorFill->setNoColorString( tr( "Transparent Fill" ) );
663 btnChangeColorStroke->setAllowOpacity( true );
664 btnChangeColorStroke->setColorDialogTitle( tr( "Select Stroke Color" ) );
665 btnChangeColorStroke->setContext( QStringLiteral( "symbology" ) );
666 btnChangeColorStroke->setShowNoColor( true );
667 btnChangeColorStroke->setNoColorString( tr( "Transparent Stroke" ) );
668
669 mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
670 mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
671
672 spinOffsetX->setClearValue( 0.0 );
673 spinOffsetY->setClearValue( 0.0 );
674 spinAngle->setClearValue( 0.0 );
675
676 //make a temporary symbol for the size assistant preview
677 mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
678
679 if ( vectorLayer() )
680 mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
681
682 int size = lstNames->iconSize().width();
683
684 size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) );
685
686 lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
687 lstNames->setIconSize( QSize( size, size ) );
688
689 const double markerSize = size * 0.8;
691 for ( const Qgis::MarkerShape shape : shapes )
692 {
693 QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
695 lyr->setColor( QColor( 200, 200, 200 ) );
696 lyr->setStrokeColor( QColor( 0, 0, 0 ) );
697 const QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, Qgis::RenderUnit::Pixels, QSize( size, size ), QgsMapUnitScale(), Qgis::SymbolType::Hybrid, nullptr, QgsScreenProperties( screen() ) );
698 QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
699 item->setData( Qt::UserRole, static_cast< int >( shape ) );
700 item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
701 delete lyr;
702 }
703 // show at least 3 rows
704 lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
705
706 connect( lstNames, &QListWidget::currentRowChanged, this, &QgsSimpleMarkerSymbolLayerWidget::setShape );
709 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged );
710 connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::penCapStyleChanged );
711 connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setSize );
712 connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setAngle );
713 connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
714 connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
715 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol );
716}
717
719
721{
722 if ( layer->layerType() != QLatin1String( "SimpleMarker" ) )
723 return;
724
725 // layer type is correct, we can do the cast
726 mLayer = static_cast<QgsSimpleMarkerSymbolLayer *>( layer );
727
728 // set values
729 const Qgis::MarkerShape shape = mLayer->shape();
730 for ( int i = 0; i < lstNames->count(); ++i )
731 {
732 if ( static_cast< Qgis::MarkerShape >( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
733 {
734 lstNames->setCurrentRow( i );
735 break;
736 }
737 }
738 btnChangeColorStroke->blockSignals( true );
739 btnChangeColorStroke->setColor( mLayer->strokeColor() );
740 btnChangeColorStroke->blockSignals( false );
741 btnChangeColorFill->blockSignals( true );
742 btnChangeColorFill->setColor( mLayer->fillColor() );
743 btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
744 btnChangeColorFill->blockSignals( false );
745 spinSize->blockSignals( true );
746 spinSize->setValue( mLayer->size() );
747 spinSize->blockSignals( false );
748 spinAngle->blockSignals( true );
749 spinAngle->setValue( mLayer->angle() );
750 spinAngle->blockSignals( false );
751 mStrokeStyleComboBox->blockSignals( true );
752 mStrokeStyleComboBox->setPenStyle( mLayer->strokeStyle() );
753 mStrokeStyleComboBox->blockSignals( false );
754 mStrokeWidthSpinBox->blockSignals( true );
755 mStrokeWidthSpinBox->setValue( mLayer->strokeWidth() );
756 mStrokeWidthSpinBox->blockSignals( false );
757 cboJoinStyle->blockSignals( true );
758 cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
759 cboJoinStyle->blockSignals( false );
760 cboCapStyle->blockSignals( true );
761 cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
762 cboCapStyle->blockSignals( false );
763
764 // without blocking signals the value gets changed because of slot setOffset()
765 spinOffsetX->blockSignals( true );
766 spinOffsetX->setValue( mLayer->offset().x() );
767 spinOffsetX->blockSignals( false );
768 spinOffsetY->blockSignals( true );
769 spinOffsetY->setValue( mLayer->offset().y() );
770 spinOffsetY->blockSignals( false );
771
772 mSizeUnitWidget->blockSignals( true );
773 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
774 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
775 mSizeUnitWidget->blockSignals( false );
776 mOffsetUnitWidget->blockSignals( true );
777 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
778 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
779 mOffsetUnitWidget->blockSignals( false );
780 mStrokeWidthUnitWidget->blockSignals( true );
781 mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
782 mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
783 mStrokeWidthUnitWidget->blockSignals( false );
784
785 //anchor points
786 mHorizontalAnchorComboBox->blockSignals( true );
787 mVerticalAnchorComboBox->blockSignals( true );
788 mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
789 mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
790 mHorizontalAnchorComboBox->blockSignals( false );
791 mVerticalAnchorComboBox->blockSignals( false );
792
805
806 updateAssistantSymbol();
807}
808
813
814void QgsSimpleMarkerSymbolLayerWidget::setShape()
815{
816 mLayer->setShape( static_cast< Qgis::MarkerShape >( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
817 btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
818 emit changed();
819}
820
822{
823 mLayer->setStrokeColor( color );
824 emit changed();
825}
826
828{
829 mLayer->setColor( color );
830 emit changed();
831}
832
833void QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged()
834{
835 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
836 emit changed();
837}
838
839void QgsSimpleMarkerSymbolLayerWidget::penCapStyleChanged()
840{
841 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
842 emit changed();
843}
844
845void QgsSimpleMarkerSymbolLayerWidget::setSize()
846{
847 mLayer->setSize( spinSize->value() );
848 emit changed();
849}
850
851void QgsSimpleMarkerSymbolLayerWidget::setAngle()
852{
853 mLayer->setAngle( spinAngle->value() );
854 emit changed();
855}
856
857void QgsSimpleMarkerSymbolLayerWidget::setOffset()
858{
859 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
860 emit changed();
861}
862
863void QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged( int index )
864{
865 Q_UNUSED( index )
866
867 if ( mLayer )
868 {
869 mLayer->setStrokeStyle( mStrokeStyleComboBox->penStyle() );
870 emit changed();
871 }
872}
873
874void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
875{
876 if ( mLayer )
877 {
879 emit changed();
880 }
881}
882
883void QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
884{
885 if ( mLayer )
886 {
887 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
888 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
889 emit changed();
890 }
891}
892
893void QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
894{
895 if ( mLayer )
896 {
897 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
898 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
899 emit changed();
900 }
901}
902
903void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
904{
905 if ( mLayer )
906 {
907 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
908 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
909 emit changed();
910 }
911}
912
913void QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
914{
915 if ( mLayer )
916 {
918 emit changed();
919 }
920}
921
922void QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
923{
924 if ( mLayer )
925 {
927 emit changed();
928 }
929}
930
931void QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol()
932{
933 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
934 {
935 mAssistantPreviewSymbol->deleteSymbolLayer( i );
936 }
937 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
939 if ( ddSize )
940 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
941}
942
943
945
947 : QgsSymbolLayerWidget( parent, vl )
948{
949 mLayer = nullptr;
950
951 setupUi( this );
952 connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
953 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed );
958
959 btnChangeColor->setAllowOpacity( true );
960 btnChangeColor->setColorDialogTitle( tr( "Select Fill Color" ) );
961 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
962 btnChangeColor->setShowNoColor( true );
963 btnChangeColor->setNoColorString( tr( "Transparent Fill" ) );
964 btnChangeStrokeColor->setAllowOpacity( true );
965 btnChangeStrokeColor->setColorDialogTitle( tr( "Select Stroke Color" ) );
966 btnChangeStrokeColor->setContext( QStringLiteral( "symbology" ) );
967 btnChangeStrokeColor->setShowNoColor( true );
968 btnChangeStrokeColor->setNoColorString( tr( "Transparent Stroke" ) );
969
970 spinOffsetX->setClearValue( 0.0 );
971 spinOffsetY->setClearValue( 0.0 );
972
974 connect( cboFillStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::setBrushStyle );
976 connect( spinStrokeWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeWidthChanged );
977 connect( cboStrokeStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
978 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
979 connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
980 connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
981
982 mFillColorDDBtn->registerLinkedWidget( btnChangeColor );
983 mStrokeColorDDBtn->registerLinkedWidget( btnChangeStrokeColor );
984}
985
987{
988 if ( layer->layerType() != QLatin1String( "SimpleFill" ) )
989 return;
990
991 // layer type is correct, we can do the cast
992 mLayer = static_cast<QgsSimpleFillSymbolLayer *>( layer );
993
994 // set values
995 btnChangeColor->blockSignals( true );
996 btnChangeColor->setColor( mLayer->color() );
997 btnChangeColor->blockSignals( false );
998 cboFillStyle->blockSignals( true );
999 cboFillStyle->setBrushStyle( mLayer->brushStyle() );
1000 cboFillStyle->blockSignals( false );
1001 btnChangeStrokeColor->blockSignals( true );
1002 btnChangeStrokeColor->setColor( mLayer->strokeColor() );
1003 btnChangeStrokeColor->blockSignals( false );
1004 cboStrokeStyle->blockSignals( true );
1005 cboStrokeStyle->setPenStyle( mLayer->strokeStyle() );
1006 cboStrokeStyle->blockSignals( false );
1007 spinStrokeWidth->blockSignals( true );
1008 spinStrokeWidth->setValue( mLayer->strokeWidth() );
1009 spinStrokeWidth->blockSignals( false );
1010 cboJoinStyle->blockSignals( true );
1011 cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
1012 cboJoinStyle->blockSignals( false );
1013 spinOffsetX->blockSignals( true );
1014 spinOffsetX->setValue( mLayer->offset().x() );
1015 spinOffsetX->blockSignals( false );
1016 spinOffsetY->blockSignals( true );
1017 spinOffsetY->setValue( mLayer->offset().y() );
1018 spinOffsetY->blockSignals( false );
1019
1020 mStrokeWidthUnitWidget->blockSignals( true );
1021 mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
1022 mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
1023 mStrokeWidthUnitWidget->blockSignals( false );
1024 mOffsetUnitWidget->blockSignals( true );
1025 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1026 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1027 mOffsetUnitWidget->blockSignals( false );
1028
1036}
1037
1042
1044{
1045 mLayer->setColor( color );
1046 emit changed();
1047}
1048
1050{
1051 mLayer->setStrokeColor( color );
1052 emit changed();
1053}
1054
1055void QgsSimpleFillSymbolLayerWidget::setBrushStyle()
1056{
1057 mLayer->setBrushStyle( cboFillStyle->brushStyle() );
1058 emit changed();
1059}
1060
1061void QgsSimpleFillSymbolLayerWidget::strokeWidthChanged()
1062{
1063 mLayer->setStrokeWidth( spinStrokeWidth->value() );
1064 emit changed();
1065}
1066
1067void QgsSimpleFillSymbolLayerWidget::strokeStyleChanged()
1068{
1069 mLayer->setStrokeStyle( cboStrokeStyle->penStyle() );
1070 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
1071 emit changed();
1072}
1073
1074void QgsSimpleFillSymbolLayerWidget::offsetChanged()
1075{
1076 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1077 emit changed();
1078}
1079
1080void QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
1081{
1082 if ( mLayer )
1083 {
1084 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
1085 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
1086 emit changed();
1087 }
1088}
1089
1090void QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1091{
1092 if ( mLayer )
1093 {
1094 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1095 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1096 emit changed();
1097 }
1098}
1099
1101
1103 : QgsSymbolLayerWidget( parent, vl )
1104{
1105 mLayer = nullptr;
1106
1107 setupUi( this );
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 );
1116
1117 spinOffsetX->setClearValue( 0.0 );
1118 spinOffsetY->setClearValue( 0.0 );
1119 spinAngle->setClearValue( 0.0 );
1120
1121 //make a temporary symbol for the size assistant preview
1122 mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
1123
1124 if ( vectorLayer() )
1125 mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
1126
1127 int size = lstNames->iconSize().width();
1128 size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) );
1129 lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
1130 lstNames->setIconSize( QSize( size, size ) );
1131
1132 const double markerSize = size * 0.8;
1134 for ( const Qgis::MarkerShape shape : shapes )
1135 {
1136 QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
1138 lyr->setColor( QColor( 200, 200, 200 ) );
1139 lyr->setStrokeColor( QColor( 0, 0, 0 ) );
1140 const QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, Qgis::RenderUnit::Pixels, QSize( size, size ), QgsMapUnitScale(), Qgis::SymbolType::Hybrid, nullptr, QgsScreenProperties( screen() ) );
1141 QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
1142 item->setData( Qt::UserRole, static_cast< int >( shape ) );
1143 item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
1144 delete lyr;
1145 }
1146 // show at least 3 rows
1147 lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
1148
1149 connect( lstNames, &QListWidget::currentRowChanged, this, &QgsFilledMarkerSymbolLayerWidget::setShape );
1150 connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setSize );
1151 connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setAngle );
1152 connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
1153 connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
1154 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol );
1155}
1156
1158
1160{
1161 if ( layer->layerType() != QLatin1String( "FilledMarker" ) )
1162 return;
1163
1164 // layer type is correct, we can do the cast
1165 mLayer = static_cast<QgsFilledMarkerSymbolLayer *>( layer );
1166
1167 // set values
1168 const Qgis::MarkerShape shape = mLayer->shape();
1169 for ( int i = 0; i < lstNames->count(); ++i )
1170 {
1171 if ( static_cast< Qgis::MarkerShape >( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
1172 {
1173 lstNames->setCurrentRow( i );
1174 break;
1175 }
1176 }
1177 whileBlocking( spinSize )->setValue( mLayer->size() );
1178 whileBlocking( spinAngle )->setValue( mLayer->angle() );
1179 whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
1180 whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
1181
1182 mSizeUnitWidget->blockSignals( true );
1183 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1184 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1185 mSizeUnitWidget->blockSignals( false );
1186 mOffsetUnitWidget->blockSignals( true );
1187 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1188 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1189 mOffsetUnitWidget->blockSignals( false );
1190
1191 //anchor points
1192 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1193 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
1194
1201
1202 updateAssistantSymbol();
1203}
1204
1209
1210void QgsFilledMarkerSymbolLayerWidget::setShape()
1211{
1212 mLayer->setShape( static_cast< Qgis::MarkerShape >( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
1213 emit changed();
1214}
1215
1216void QgsFilledMarkerSymbolLayerWidget::setSize()
1217{
1218 mLayer->setSize( spinSize->value() );
1219 emit changed();
1220}
1221
1222void QgsFilledMarkerSymbolLayerWidget::setAngle()
1223{
1224 mLayer->setAngle( spinAngle->value() );
1225 emit changed();
1226}
1227
1228void QgsFilledMarkerSymbolLayerWidget::setOffset()
1229{
1230 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1231 emit changed();
1232}
1233
1234void QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
1235{
1236 if ( mLayer )
1237 {
1238 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1239 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1240 emit changed();
1241 }
1242}
1243
1244void QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
1245{
1246 if ( mLayer )
1247 {
1248 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1249 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1250 emit changed();
1251 }
1252}
1253
1254void QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
1255{
1256 if ( mLayer )
1257 {
1259 emit changed();
1260 }
1261}
1262
1263void QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
1264{
1265 if ( mLayer )
1266 {
1268 emit changed();
1269 }
1270}
1271
1272void QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol()
1273{
1274 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1275 {
1276 mAssistantPreviewSymbol->deleteSymbolLayer( i );
1277 }
1278 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1280 if ( ddSize )
1281 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
1282}
1283
1284
1286
1288 : QgsSymbolLayerWidget( parent, vl )
1289{
1290 mLayer = nullptr;
1291
1292 setupUi( this );
1293 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1294 connect( mSpinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged );
1297
1298 btnColorRamp->setShowGradientOnly( true );
1299
1300 btnChangeColor->setAllowOpacity( true );
1301 btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1302 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1303 btnChangeColor->setShowNoColor( true );
1304 btnChangeColor->setNoColorString( tr( "Transparent" ) );
1305 btnChangeColor2->setAllowOpacity( true );
1306 btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1307 btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1308 btnChangeColor2->setShowNoColor( true );
1309 btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1310
1311 mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1312 mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1313
1314 spinOffsetX->setClearValue( 0.0 );
1315 spinOffsetY->setClearValue( 0.0 );
1316 mSpinAngle->setClearValue( 0.0 );
1317
1321 connect( cboGradientType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientType );
1322 connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setCoordinateMode );
1323 connect( cboGradientSpread, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientSpread );
1324 connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::colorModeChanged );
1325 connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1326 connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1327 connect( spinRefPoint1X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1328 connect( spinRefPoint1Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1329 connect( checkRefPoint1Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1330 connect( spinRefPoint2X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1331 connect( spinRefPoint2Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1332 connect( checkRefPoint2Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1333}
1334
1336{
1337 if ( layer->layerType() != QLatin1String( "GradientFill" ) )
1338 return;
1339
1340 // layer type is correct, we can do the cast
1341 mLayer = static_cast<QgsGradientFillSymbolLayer *>( layer );
1342
1343 // set values
1344 btnChangeColor->blockSignals( true );
1345 btnChangeColor->setColor( mLayer->color() );
1346 btnChangeColor->blockSignals( false );
1347 btnChangeColor2->blockSignals( true );
1348 btnChangeColor2->setColor( mLayer->color2() );
1349 btnChangeColor2->blockSignals( false );
1350
1352 {
1353 radioTwoColor->setChecked( true );
1354 btnColorRamp->setEnabled( false );
1355 }
1356 else
1357 {
1358 radioColorRamp->setChecked( true );
1359 btnChangeColor->setEnabled( false );
1360 btnChangeColor2->setEnabled( false );
1361 }
1362
1363 // set source color ramp
1364 if ( mLayer->colorRamp() )
1365 {
1366 btnColorRamp->blockSignals( true );
1367 btnColorRamp->setColorRamp( mLayer->colorRamp() );
1368 btnColorRamp->blockSignals( false );
1369 }
1370
1371 cboGradientType->blockSignals( true );
1372 switch ( mLayer->gradientType() )
1373 {
1375 cboGradientType->setCurrentIndex( 0 );
1376 break;
1378 cboGradientType->setCurrentIndex( 1 );
1379 break;
1381 cboGradientType->setCurrentIndex( 2 );
1382 break;
1383 }
1384 cboGradientType->blockSignals( false );
1385
1386 cboCoordinateMode->blockSignals( true );
1387 switch ( mLayer->coordinateMode() )
1388 {
1390 cboCoordinateMode->setCurrentIndex( 1 );
1391 checkRefPoint1Centroid->setEnabled( false );
1392 checkRefPoint2Centroid->setEnabled( false );
1393 break;
1395 default:
1396 cboCoordinateMode->setCurrentIndex( 0 );
1397 break;
1398 }
1399 cboCoordinateMode->blockSignals( false );
1400
1401 cboGradientSpread->blockSignals( true );
1402 switch ( mLayer->gradientSpread() )
1403 {
1405 cboGradientSpread->setCurrentIndex( 0 );
1406 break;
1408 cboGradientSpread->setCurrentIndex( 1 );
1409 break;
1411 cboGradientSpread->setCurrentIndex( 2 );
1412 break;
1413 }
1414 cboGradientSpread->blockSignals( false );
1415
1416 spinRefPoint1X->blockSignals( true );
1417 spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
1418 spinRefPoint1X->blockSignals( false );
1419 spinRefPoint1Y->blockSignals( true );
1420 spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
1421 spinRefPoint1Y->blockSignals( false );
1422 checkRefPoint1Centroid->blockSignals( true );
1423 checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
1425 {
1426 spinRefPoint1X->setEnabled( false );
1427 spinRefPoint1Y->setEnabled( false );
1428 }
1429 checkRefPoint1Centroid->blockSignals( false );
1430 spinRefPoint2X->blockSignals( true );
1431 spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
1432 spinRefPoint2X->blockSignals( false );
1433 spinRefPoint2Y->blockSignals( true );
1434 spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
1435 spinRefPoint2Y->blockSignals( false );
1436 checkRefPoint2Centroid->blockSignals( true );
1437 checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
1439 {
1440 spinRefPoint2X->setEnabled( false );
1441 spinRefPoint2Y->setEnabled( false );
1442 }
1443 checkRefPoint2Centroid->blockSignals( false );
1444
1445 spinOffsetX->blockSignals( true );
1446 spinOffsetX->setValue( mLayer->offset().x() );
1447 spinOffsetX->blockSignals( false );
1448 spinOffsetY->blockSignals( true );
1449 spinOffsetY->setValue( mLayer->offset().y() );
1450 spinOffsetY->blockSignals( false );
1451 mSpinAngle->blockSignals( true );
1452 mSpinAngle->setValue( mLayer->angle() );
1453 mSpinAngle->blockSignals( false );
1454
1455 mOffsetUnitWidget->blockSignals( true );
1456 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1457 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1458 mOffsetUnitWidget->blockSignals( false );
1459
1473}
1474
1479
1481{
1482 mLayer->setColor( color );
1483 emit changed();
1484}
1485
1487{
1488 mLayer->setColor2( color );
1489 emit changed();
1490}
1491
1492void QgsGradientFillSymbolLayerWidget::colorModeChanged()
1493{
1494 if ( radioTwoColor->isChecked() )
1495 {
1497 }
1498 else
1499 {
1501 }
1502 emit changed();
1503}
1504
1506{
1507 if ( btnColorRamp->isNull() )
1508 return;
1509
1510 mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
1511 emit changed();
1512}
1513
1515{
1516 switch ( index )
1517 {
1518 case 0:
1520 //set sensible default reference points
1521 spinRefPoint1X->setValue( 0.5 );
1522 spinRefPoint1Y->setValue( 0 );
1523 spinRefPoint2X->setValue( 0.5 );
1524 spinRefPoint2Y->setValue( 1 );
1525 break;
1526 case 1:
1528 //set sensible default reference points
1529 spinRefPoint1X->setValue( 0 );
1530 spinRefPoint1Y->setValue( 0 );
1531 spinRefPoint2X->setValue( 1 );
1532 spinRefPoint2Y->setValue( 1 );
1533 break;
1534 case 2:
1536 spinRefPoint1X->setValue( 0.5 );
1537 spinRefPoint1Y->setValue( 0.5 );
1538 spinRefPoint2X->setValue( 1 );
1539 spinRefPoint2Y->setValue( 1 );
1540 break;
1541 }
1542 emit changed();
1543}
1544
1546{
1547
1548 switch ( index )
1549 {
1550 case 0:
1551 //feature coordinate mode
1553 //allow choice of centroid reference positions
1554 checkRefPoint1Centroid->setEnabled( true );
1555 checkRefPoint2Centroid->setEnabled( true );
1556 break;
1557 case 1:
1558 //viewport coordinate mode
1560 //disable choice of centroid reference positions
1561 checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1562 checkRefPoint1Centroid->setEnabled( false );
1563 checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1564 checkRefPoint2Centroid->setEnabled( false );
1565 break;
1566 }
1567
1568 emit changed();
1569}
1570
1572{
1573 switch ( index )
1574 {
1575 case 0:
1577 break;
1578 case 1:
1580 break;
1581 case 2:
1583 break;
1584 }
1585
1586 emit changed();
1587}
1588
1589void QgsGradientFillSymbolLayerWidget::offsetChanged()
1590{
1591 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1592 emit changed();
1593}
1594
1595void QgsGradientFillSymbolLayerWidget::referencePointChanged()
1596{
1597 mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1598 mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1599 mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1600 mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1601 emit changed();
1602}
1603
1604void QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged( double value )
1605{
1606 mLayer->setAngle( value );
1607 emit changed();
1608}
1609
1610void QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1611{
1612 if ( mLayer )
1613 {
1614 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1615 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1616 emit changed();
1617 }
1618}
1619
1621
1623 : QgsSymbolLayerWidget( parent, vl )
1624{
1625 mLayer = nullptr;
1626
1627 setupUi( this );
1628 connect( mSpinBlurRadius, qOverload< int >( &QSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged );
1629 connect( mSpinMaxDistance, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged );
1630 connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed );
1631 connect( mRadioUseWholeShape, &QRadioButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled );
1632 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1633 connect( mIgnoreRingsCheckBox, &QCheckBox::stateChanged, this, &QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged );
1638
1639 QButtonGroup *group1 = new QButtonGroup( this );
1640 group1->addButton( radioColorRamp );
1641 group1->addButton( radioTwoColor );
1642 QButtonGroup *group2 = new QButtonGroup( this );
1643 group2->addButton( mRadioUseMaxDistance );
1644 group2->addButton( mRadioUseWholeShape );
1645 btnChangeColor->setAllowOpacity( true );
1646 btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1647 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1648 btnChangeColor->setShowNoColor( true );
1649 btnChangeColor->setNoColorString( tr( "Transparent" ) );
1650 btnChangeColor2->setAllowOpacity( true );
1651 btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1652 btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1653 btnChangeColor2->setShowNoColor( true );
1654 btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1655
1656 mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1657 mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1658
1659 spinOffsetX->setClearValue( 0.0 );
1660 spinOffsetY->setClearValue( 0.0 );
1661 mSpinMaxDistance->setClearValue( 5.0 );
1662
1663 btnColorRamp->setShowGradientOnly( true );
1664
1665 connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsShapeburstFillSymbolLayerWidget::applyColorRamp );
1666
1669 connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::colorModeChanged );
1670 connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1671 connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1672
1673 connect( mBlurSlider, &QAbstractSlider::valueChanged, mSpinBlurRadius, &QSpinBox::setValue );
1674 connect( mSpinBlurRadius, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mBlurSlider, &QAbstractSlider::setValue );
1675}
1676
1678{
1679 if ( layer->layerType() != QLatin1String( "ShapeburstFill" ) )
1680 return;
1681
1682 // layer type is correct, we can do the cast
1683 mLayer = static_cast<QgsShapeburstFillSymbolLayer *>( layer );
1684
1685 // set values
1686 btnChangeColor->blockSignals( true );
1687 btnChangeColor->setColor( mLayer->color() );
1688 btnChangeColor->blockSignals( false );
1689 btnChangeColor2->blockSignals( true );
1690 btnChangeColor2->setColor( mLayer->color2() );
1691 btnChangeColor2->blockSignals( false );
1692
1694 {
1695 radioTwoColor->setChecked( true );
1696 btnColorRamp->setEnabled( false );
1697 }
1698 else
1699 {
1700 radioColorRamp->setChecked( true );
1701 btnChangeColor->setEnabled( false );
1702 btnChangeColor2->setEnabled( false );
1703 }
1704
1705 mSpinBlurRadius->blockSignals( true );
1706 mBlurSlider->blockSignals( true );
1707 mSpinBlurRadius->setValue( mLayer->blurRadius() );
1708 mBlurSlider->setValue( mLayer->blurRadius() );
1709 mSpinBlurRadius->blockSignals( false );
1710 mBlurSlider->blockSignals( false );
1711
1712 mSpinMaxDistance->blockSignals( true );
1713 mSpinMaxDistance->setValue( mLayer->maxDistance() );
1714 mSpinMaxDistance->blockSignals( false );
1715
1716 mRadioUseWholeShape->blockSignals( true );
1717 mRadioUseMaxDistance->blockSignals( true );
1718 if ( mLayer->useWholeShape() )
1719 {
1720 mRadioUseWholeShape->setChecked( true );
1721 mSpinMaxDistance->setEnabled( false );
1722 mDistanceUnitWidget->setEnabled( false );
1723 }
1724 else
1725 {
1726 mRadioUseMaxDistance->setChecked( true );
1727 mSpinMaxDistance->setEnabled( true );
1728 mDistanceUnitWidget->setEnabled( true );
1729 }
1730 mRadioUseWholeShape->blockSignals( false );
1731 mRadioUseMaxDistance->blockSignals( false );
1732
1733 mDistanceUnitWidget->blockSignals( true );
1734 mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1735 mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1736 mDistanceUnitWidget->blockSignals( false );
1737
1738 mIgnoreRingsCheckBox->blockSignals( true );
1739 mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1740 mIgnoreRingsCheckBox->blockSignals( false );
1741
1742 // set source color ramp
1743 if ( mLayer->colorRamp() )
1744 {
1745 btnColorRamp->blockSignals( true );
1746 btnColorRamp->setColorRamp( mLayer->colorRamp() );
1747 btnColorRamp->blockSignals( false );
1748 }
1749
1750 spinOffsetX->blockSignals( true );
1751 spinOffsetX->setValue( mLayer->offset().x() );
1752 spinOffsetX->blockSignals( false );
1753 spinOffsetY->blockSignals( true );
1754 spinOffsetY->setValue( mLayer->offset().y() );
1755 spinOffsetY->blockSignals( false );
1756 mOffsetUnitWidget->blockSignals( true );
1757 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1758 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1759 mOffsetUnitWidget->blockSignals( false );
1760
1768}
1769
1774
1776{
1777 if ( mLayer )
1778 {
1779 mLayer->setColor( color );
1780 emit changed();
1781 }
1782}
1783
1785{
1786 if ( mLayer )
1787 {
1788 mLayer->setColor2( color );
1789 emit changed();
1790 }
1791}
1792
1793void QgsShapeburstFillSymbolLayerWidget::colorModeChanged()
1794{
1795 if ( !mLayer )
1796 {
1797 return;
1798 }
1799
1800 if ( radioTwoColor->isChecked() )
1801 {
1803 }
1804 else
1805 {
1807 }
1808 emit changed();
1809}
1810
1811void QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged( int value )
1812{
1813 if ( mLayer )
1814 {
1815 mLayer->setBlurRadius( value );
1816 emit changed();
1817 }
1818}
1819
1820void QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged( double value )
1821{
1822 if ( mLayer )
1823 {
1824 mLayer->setMaxDistance( value );
1825 emit changed();
1826 }
1827}
1828
1829void QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed()
1830{
1831 if ( mLayer )
1832 {
1833 mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1834 mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1835 emit changed();
1836 }
1837}
1838
1839void QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled( bool value )
1840{
1841 if ( mLayer )
1842 {
1843 mLayer->setUseWholeShape( value );
1844 mDistanceUnitWidget->setEnabled( !value );
1845 emit changed();
1846 }
1847}
1848
1849void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
1850{
1851 QgsColorRamp *ramp = btnColorRamp->colorRamp();
1852 if ( !ramp )
1853 return;
1854
1855 mLayer->setColorRamp( ramp );
1856 emit changed();
1857}
1858
1859void QgsShapeburstFillSymbolLayerWidget::offsetChanged()
1860{
1861 if ( mLayer )
1862 {
1863 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1864 emit changed();
1865 }
1866}
1867
1868void QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1869{
1870 if ( mLayer )
1871 {
1872 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1873 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1874 emit changed();
1875 }
1876}
1877
1878
1879void QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged( int state )
1880{
1881 const bool checked = ( state == Qt::Checked );
1882 mLayer->setIgnoreRings( checked );
1883 emit changed();
1884}
1885
1887
1889 : QgsSymbolLayerWidget( parent, vl )
1890{
1891 mLayer = nullptr;
1892
1893 setupUi( this );
1894 connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed );
1895 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed );
1896 connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
1897 connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::averageAngleUnitChanged );
1906
1907 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
1908 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
1909 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
1910 connect( mRingFilterComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
1911 {
1912 if ( mLayer )
1913 {
1914 mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
1915 emit changed();
1916 }
1917 } );
1918
1919 spinOffset->setClearValue( 0.0 );
1920 mSpinOffsetAlongLine->setClearValue( 0.0 );
1921 mSpinAverageAngleLength->setClearValue( 4.0 );
1922
1923 connect( spinInterval, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setInterval );
1924 connect( mSpinOffsetAlongLine, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffsetAlongLine );
1925 connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setRotate );
1926 connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffset );
1927 connect( mSpinAverageAngleLength, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setAverageAngle );
1928 connect( mCheckInterval, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1929 connect( mCheckVertex, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1930 connect( mCheckVertexLast, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1931 connect( mCheckVertexFirst, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1932 connect( mCheckCentralPoint, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1933 connect( mCheckCurvePoint, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1934 connect( mCheckSegmentCentralPoint, &QCheckBox::toggled, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1935 connect( mCheckPlaceOnEveryPart, &QCheckBox::toggled, this, [ = ]
1936 {
1937 if ( mLayer )
1938 {
1939 mLayer->setPlaceOnEveryPart( mCheckPlaceOnEveryPart->isChecked() );
1940 emit changed();
1941 }
1942 } );
1943}
1944
1946{
1947 if ( layer->layerType() != QLatin1String( "MarkerLine" ) )
1948 return;
1949
1950 // layer type is correct, we can do the cast
1951 mLayer = static_cast<QgsMarkerLineSymbolLayer *>( layer );
1952
1953 // set values
1954 spinInterval->blockSignals( true );
1955 spinInterval->setValue( mLayer->interval() );
1956 spinInterval->blockSignals( false );
1957 mSpinOffsetAlongLine->blockSignals( true );
1958 mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1959 mSpinOffsetAlongLine->blockSignals( false );
1960 chkRotateMarker->blockSignals( true );
1961 chkRotateMarker->setChecked( mLayer->rotateSymbols() );
1962 chkRotateMarker->blockSignals( false );
1963 spinOffset->blockSignals( true );
1964 spinOffset->setValue( mLayer->offset() );
1965 spinOffset->blockSignals( false );
1966
1967 whileBlocking( mCheckInterval )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::Interval );
1970 whileBlocking( mCheckVertexFirst )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::FirstVertex
1972 whileBlocking( mCheckVertexLast )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::LastVertex
1974 whileBlocking( mCheckCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CentralPoint );
1975 whileBlocking( mCheckCurvePoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CurvePoint );
1976 whileBlocking( mCheckSegmentCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::SegmentCenter );
1977 whileBlocking( mCheckPlaceOnEveryPart )->setChecked( mLayer->placeOnEveryPart() );
1978
1979 // set units
1980 mIntervalUnitWidget->blockSignals( true );
1981 mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1982 mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1983 mIntervalUnitWidget->blockSignals( false );
1984 mOffsetUnitWidget->blockSignals( true );
1985 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1986 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1987 mOffsetUnitWidget->blockSignals( false );
1988 mOffsetAlongLineUnitWidget->blockSignals( true );
1989 mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1990 mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1991 mOffsetAlongLineUnitWidget->blockSignals( false );
1992
1993 whileBlocking( mAverageAngleUnit )->setUnit( mLayer->averageAngleUnit() );
1994 whileBlocking( mAverageAngleUnit )->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
1995 whileBlocking( mSpinAverageAngleLength )->setValue( mLayer->averageAngleLength() );
1996
1997 whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
1998
1999 setPlacement(); // update gui
2000
2006}
2007
2012
2014{
2016
2017 switch ( context.symbolType() )
2018 {
2021 //these settings only have an effect when the symbol layers is part of a fill symbol
2022 mRingFilterComboBox->hide();
2023 mRingsLabel->hide();
2024 break;
2025
2028 break;
2029 }
2030}
2031
2033{
2034 mLayer->setInterval( val );
2035 emit changed();
2036}
2037
2039{
2040 mLayer->setOffsetAlongLine( val );
2041 emit changed();
2042}
2043
2044void QgsMarkerLineSymbolLayerWidget::setRotate()
2045{
2046 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2047 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2048
2049 mLayer->setRotateSymbols( chkRotateMarker->isChecked() );
2050 emit changed();
2051}
2052
2053void QgsMarkerLineSymbolLayerWidget::setOffset()
2054{
2055 mLayer->setOffset( spinOffset->value() );
2056 emit changed();
2057}
2058
2059void QgsMarkerLineSymbolLayerWidget::setPlacement()
2060{
2061 const bool interval = mCheckInterval->isChecked();
2062 spinInterval->setEnabled( interval );
2063 mSpinOffsetAlongLine->setEnabled( mCheckInterval->isChecked() || mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2064 mOffsetAlongLineUnitWidget->setEnabled( mSpinOffsetAlongLine->isEnabled() );
2065 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2066 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2067 mCheckPlaceOnEveryPart->setEnabled( mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2068
2069 Qgis::MarkerLinePlacements placements;
2070 if ( mCheckInterval->isChecked() )
2072 if ( mCheckVertex->isChecked() )
2074 if ( mCheckVertexLast->isChecked() )
2076 if ( mCheckVertexFirst->isChecked() )
2078 if ( mCheckCurvePoint->isChecked() )
2080 if ( mCheckSegmentCentralPoint->isChecked() )
2082 if ( mCheckCentralPoint->isChecked() )
2084 mLayer->setPlacements( placements );
2085
2086 emit changed();
2087}
2088
2089void QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed()
2090{
2091 if ( mLayer )
2092 {
2093 mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
2094 mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
2095 emit changed();
2096 }
2097}
2098
2099void QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed()
2100{
2101 if ( mLayer )
2102 {
2103 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2104 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2105 emit changed();
2106 }
2107}
2108
2109void QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
2110{
2111 if ( mLayer )
2112 {
2113 mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
2114 mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
2115 }
2116 emit changed();
2117}
2118
2119void QgsMarkerLineSymbolLayerWidget::averageAngleUnitChanged()
2120{
2121 if ( mLayer )
2122 {
2123 mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
2124 mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
2125 }
2126 emit changed();
2127}
2128
2129void QgsMarkerLineSymbolLayerWidget::setAverageAngle( double val )
2130{
2131 if ( mLayer )
2132 {
2134 emit changed();
2135 }
2136}
2137
2138
2140
2142 : QgsSymbolLayerWidget( parent, vl )
2143{
2144 mLayer = nullptr;
2145
2146 setupUi( this );
2147 connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mIntervalUnitWidget_changed );
2148 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mOffsetUnitWidget_changed );
2149 connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
2150 connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::averageAngleUnitChanged );
2151 connect( mHashLengthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::hashLengthUnitWidgetChanged );
2162
2163 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
2164 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
2165 mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
2166 connect( mRingFilterComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
2167 {
2168 if ( mLayer )
2169 {
2170 mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
2171 emit changed();
2172 }
2173 } );
2174
2175 spinOffset->setClearValue( 0.0 );
2176 mSpinOffsetAlongLine->setClearValue( 0.0 );
2177 mHashRotationSpinBox->setClearValue( 0 );
2178 mSpinAverageAngleLength->setClearValue( 4.0 );
2179
2180 connect( spinInterval, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setInterval );
2181 connect( mSpinOffsetAlongLine, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setOffsetAlongLine );
2182 connect( mSpinHashLength, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setHashLength );
2183 connect( mHashRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setHashAngle );
2184 connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setRotate );
2185 connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setOffset );
2186 connect( mSpinAverageAngleLength, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setAverageAngle );
2187
2188 connect( mCheckInterval, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2189 connect( mCheckVertex, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2190 connect( mCheckVertexLast, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2191 connect( mCheckVertexFirst, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2192 connect( mCheckCentralPoint, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2193 connect( mCheckCurvePoint, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2194 connect( mCheckSegmentCentralPoint, &QCheckBox::toggled, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2195
2196 connect( mCheckPlaceOnEveryPart, &QCheckBox::toggled, this, [ = ]
2197 {
2198 if ( mLayer )
2199 {
2200 mLayer->setPlaceOnEveryPart( mCheckPlaceOnEveryPart->isChecked() );
2201 emit changed();
2202 }
2203 } );
2204}
2205
2207{
2208 if ( layer->layerType() != QLatin1String( "HashLine" ) )
2209 return;
2210
2211 // layer type is correct, we can do the cast
2212 mLayer = static_cast<QgsHashedLineSymbolLayer *>( layer );
2213
2214 // set values
2215 spinInterval->blockSignals( true );
2216 spinInterval->setValue( mLayer->interval() );
2217 spinInterval->blockSignals( false );
2218 mSpinOffsetAlongLine->blockSignals( true );
2219 mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
2220 mSpinOffsetAlongLine->blockSignals( false );
2221 whileBlocking( mSpinHashLength )->setValue( mLayer->hashLength() );
2222 whileBlocking( mHashRotationSpinBox )->setValue( mLayer->hashAngle() );
2223 chkRotateMarker->blockSignals( true );
2224 chkRotateMarker->setChecked( mLayer->rotateSymbols() );
2225 chkRotateMarker->blockSignals( false );
2226 spinOffset->blockSignals( true );
2227 spinOffset->setValue( mLayer->offset() );
2228 spinOffset->blockSignals( false );
2229
2230 whileBlocking( mCheckInterval )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::Interval );
2231 whileBlocking( mCheckVertex )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::InnerVertices
2233 whileBlocking( mCheckVertexFirst )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::FirstVertex
2235 whileBlocking( mCheckVertexLast )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::LastVertex
2237 whileBlocking( mCheckCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CentralPoint );
2238 whileBlocking( mCheckCurvePoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::CurvePoint );
2239 whileBlocking( mCheckSegmentCentralPoint )->setChecked( mLayer->placements() & Qgis::MarkerLinePlacement::SegmentCenter );
2240 whileBlocking( mCheckPlaceOnEveryPart )->setChecked( mLayer->placeOnEveryPart() );
2241
2242 // set units
2243 mIntervalUnitWidget->blockSignals( true );
2244 mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
2245 mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
2246 mIntervalUnitWidget->blockSignals( false );
2247 mOffsetUnitWidget->blockSignals( true );
2248 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2249 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2250 mOffsetUnitWidget->blockSignals( false );
2251 mOffsetAlongLineUnitWidget->blockSignals( true );
2252 mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
2253 mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
2254 mOffsetAlongLineUnitWidget->blockSignals( false );
2255 whileBlocking( mAverageAngleUnit )->setUnit( mLayer->averageAngleUnit() );
2256 whileBlocking( mAverageAngleUnit )->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
2257 whileBlocking( mSpinAverageAngleLength )->setValue( mLayer->averageAngleLength() );
2258 whileBlocking( mHashLengthUnitWidget )->setUnit( mLayer->hashLengthUnit() );
2259 whileBlocking( mHashLengthUnitWidget )->setMapUnitScale( mLayer->hashLengthMapUnitScale() );
2260
2261 whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
2262
2263 setPlacement(); // update gui
2264
2272}
2273
2278
2280{
2282
2283 switch ( context.symbolType() )
2284 {
2287 //these settings only have an effect when the symbol layers is part of a fill symbol
2288 mRingFilterComboBox->hide();
2289 mRingsLabel->hide();
2290 break;
2291
2294 break;
2295 }
2296}
2297
2298void QgsHashedLineSymbolLayerWidget::setInterval( double val )
2299{
2300 mLayer->setInterval( val );
2301 emit changed();
2302}
2303
2304void QgsHashedLineSymbolLayerWidget::setOffsetAlongLine( double val )
2305{
2306 mLayer->setOffsetAlongLine( val );
2307 emit changed();
2308}
2309
2310void QgsHashedLineSymbolLayerWidget::setHashLength( double val )
2311{
2312 mLayer->setHashLength( val );
2313 emit changed();
2314}
2315
2316void QgsHashedLineSymbolLayerWidget::setHashAngle( double val )
2317{
2318 mLayer->setHashAngle( val );
2319 emit changed();
2320}
2321
2322void QgsHashedLineSymbolLayerWidget::setRotate()
2323{
2324 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2325 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2326
2327 mLayer->setRotateSymbols( chkRotateMarker->isChecked() );
2328 emit changed();
2329}
2330
2331void QgsHashedLineSymbolLayerWidget::setOffset()
2332{
2333 mLayer->setOffset( spinOffset->value() );
2334 emit changed();
2335}
2336
2337void QgsHashedLineSymbolLayerWidget::setPlacement()
2338{
2339 const bool interval = mCheckInterval->isChecked();
2340 spinInterval->setEnabled( interval );
2341 mSpinOffsetAlongLine->setEnabled( mCheckInterval->isChecked() || mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2342 mOffsetAlongLineUnitWidget->setEnabled( mSpinOffsetAlongLine->isEnabled() );
2343 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2344 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2345 mCheckPlaceOnEveryPart->setEnabled( mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2346
2347 Qgis::MarkerLinePlacements placements;
2348 if ( mCheckInterval->isChecked() )
2350 if ( mCheckVertex->isChecked() )
2352 if ( mCheckVertexLast->isChecked() )
2354 if ( mCheckVertexFirst->isChecked() )
2356 if ( mCheckCurvePoint->isChecked() )
2358 if ( mCheckSegmentCentralPoint->isChecked() )
2360 if ( mCheckCentralPoint->isChecked() )
2362 mLayer->setPlacements( placements );
2363
2364 emit changed();
2365}
2366
2367void QgsHashedLineSymbolLayerWidget::mIntervalUnitWidget_changed()
2368{
2369 if ( mLayer )
2370 {
2371 mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
2372 mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
2373 emit changed();
2374 }
2375}
2376
2377void QgsHashedLineSymbolLayerWidget::mOffsetUnitWidget_changed()
2378{
2379 if ( mLayer )
2380 {
2381 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2382 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2383 emit changed();
2384 }
2385}
2386
2387void QgsHashedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
2388{
2389 if ( mLayer )
2390 {
2391 mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
2392 mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
2393 }
2394 emit changed();
2395}
2396
2397void QgsHashedLineSymbolLayerWidget::hashLengthUnitWidgetChanged()
2398{
2399 if ( mLayer )
2400 {
2401 mLayer->setHashLengthUnit( mHashLengthUnitWidget->unit() );
2402 mLayer->setHashLengthMapUnitScale( mHashLengthUnitWidget->getMapUnitScale() );
2403 }
2404 emit changed();
2405}
2406
2407void QgsHashedLineSymbolLayerWidget::averageAngleUnitChanged()
2408{
2409 if ( mLayer )
2410 {
2411 mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
2412 mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
2413 }
2414 emit changed();
2415}
2416
2417void QgsHashedLineSymbolLayerWidget::setAverageAngle( double val )
2418{
2419 if ( mLayer )
2420 {
2421 mLayer->setAverageAngleLength( val );
2422 emit changed();
2423 }
2424}
2425
2427
2428
2430 : QgsSymbolLayerWidget( parent, vl )
2431{
2432 mLayer = nullptr;
2433
2434 setupUi( this );
2435
2436 mSvgSelectorWidget->setAllowParameters( true );
2437 mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
2438 mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral( "/UI/lastSVGMarkerDir" ) );
2439 mSvgSelectorWidget->initParametersModel( this, vl );
2440
2441 connect( mSvgSelectorWidget->sourceLineEdit(), &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSvgMarkerSymbolLayerWidget::svgSourceChanged );
2442 connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged );
2443 connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2444 connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2445 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
2446 connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
2447 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
2448 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
2449 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
2456 mChangeColorButton->setAllowOpacity( true );
2457 mChangeColorButton->setColorDialogTitle( tr( "Select Fill color" ) );
2458 mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2459 mChangeStrokeColorButton->setAllowOpacity( true );
2460 mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2461 mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2462
2463 mFillColorDDBtn->registerLinkedWidget( mChangeColorButton );
2464 mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2465
2466 spinOffsetX->setClearValue( 0.0 );
2467 spinOffsetY->setClearValue( 0.0 );
2468 spinAngle->setClearValue( 0.0 );
2469
2470 connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setWidth );
2471 connect( spinHeight, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setHeight );
2472 connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged );
2473 connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setAngle );
2474 connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2475 connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2476 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol );
2477
2480
2481 //make a temporary symbol for the size assistant preview
2482 mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
2483
2484 if ( vectorLayer() )
2485 {
2486 mWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
2487 mHeightDDBtn->setSymbol( mAssistantPreviewSymbol );
2488 }
2489}
2490
2492
2493#include <QTime>
2494#include <QAbstractListModel>
2495#include <QPixmapCache>
2496#include <QStyle>
2497
2498
2499
2500
2502{
2503 if ( !layer )
2504 {
2505 return;
2506 }
2507
2508 //activate gui for svg parameters only if supported by the svg file
2509 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2510 QColor defaultFill, defaultStroke;
2511 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2512 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2513 QgsApplication::svgCache()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill,
2514 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2515 hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
2516 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2517 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2518 mChangeColorButton->setEnabled( hasFillParam );
2519 mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2520 mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2521 mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
2522 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
2523
2524 if ( hasFillParam )
2525 {
2526 QColor fill = layer->fillColor();
2527 const double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2528 if ( hasDefaultFillColor && !skipDefaultColors )
2529 {
2530 fill = defaultFill;
2531 }
2532 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : existingOpacity );
2533 mChangeColorButton->setColor( fill );
2534 }
2535 if ( hasStrokeParam )
2536 {
2537 QColor stroke = layer->strokeColor();
2538 const double existingOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2539 if ( hasDefaultStrokeColor && !skipDefaultColors )
2540 {
2541 stroke = defaultStroke;
2542 }
2543 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : existingOpacity );
2544 mChangeStrokeColorButton->setColor( stroke );
2545 }
2546
2547 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( layer->path() );
2548
2549 mStrokeWidthSpinBox->blockSignals( true );
2550 mStrokeWidthSpinBox->setValue( hasDefaultStrokeWidth ? defaultStrokeWidth : layer->strokeWidth() );
2551 mStrokeWidthSpinBox->blockSignals( false );
2552
2553 const bool preservedAspectRatio = layer->preservedAspectRatio();
2554 spinHeight->blockSignals( true );
2555 if ( preservedAspectRatio )
2556 {
2557 spinHeight->setValue( layer->size() * layer->defaultAspectRatio() );
2558 }
2559 else
2560 {
2561 spinHeight->setValue( layer->size() * layer->fixedAspectRatio() );
2562 }
2563 spinHeight->setEnabled( layer->defaultAspectRatio() > 0.0 );
2564 spinHeight->blockSignals( false );
2565 whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
2566}
2567
2568void QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol()
2569{
2570 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2571 {
2572 mAssistantPreviewSymbol->deleteSymbolLayer( i );
2573 }
2574 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2576 if ( ddSize )
2577 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
2578}
2579
2580
2582{
2583 if ( !layer )
2584 {
2585 return;
2586 }
2587
2588 if ( layer->layerType() != QLatin1String( "SvgMarker" ) )
2589 return;
2590
2591 // layer type is correct, we can do the cast
2592 mLayer = static_cast<QgsSvgMarkerSymbolLayer *>( layer );
2593
2594 // set values
2595 mSvgSelectorWidget->setSvgPath( mLayer->path() );
2596 mSvgSelectorWidget->setSvgParameters( mLayer->parameters() );
2597
2598 spinWidth->blockSignals( true );
2599 spinWidth->setValue( mLayer->size() );
2600 spinWidth->blockSignals( false );
2601 spinAngle->blockSignals( true );
2602 spinAngle->setValue( mLayer->angle() );
2603 spinAngle->blockSignals( false );
2604
2605 // without blocking signals the value gets changed because of slot setOffset()
2606 spinOffsetX->blockSignals( true );
2607 spinOffsetX->setValue( mLayer->offset().x() );
2608 spinOffsetX->blockSignals( false );
2609 spinOffsetY->blockSignals( true );
2610 spinOffsetY->setValue( mLayer->offset().y() );
2611 spinOffsetY->blockSignals( false );
2612
2613 mSizeUnitWidget->blockSignals( true );
2614 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2615 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2616 mSizeUnitWidget->blockSignals( false );
2617 mStrokeWidthUnitWidget->blockSignals( true );
2618 mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
2619 mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
2620 mStrokeWidthUnitWidget->blockSignals( false );
2621 mOffsetUnitWidget->blockSignals( true );
2622 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2623 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2624 mOffsetUnitWidget->blockSignals( false );
2625
2626 //anchor points
2627 mHorizontalAnchorComboBox->blockSignals( true );
2628 mVerticalAnchorComboBox->blockSignals( true );
2629 mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2630 mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2631 mHorizontalAnchorComboBox->blockSignals( false );
2632 mVerticalAnchorComboBox->blockSignals( false );
2633
2634 setGuiForSvg( mLayer, true );
2635
2645
2646 registerDataDefinedButton( mSvgSelectorWidget->sourceLineEdit()->propertyOverrideToolButton(), QgsSymbolLayer::Property::Name );
2647
2648 updateAssistantSymbol();
2649}
2650
2655
2657{
2659 mSvgSelectorWidget->sourceLineEdit()->setMessageBar( context.messageBar() );
2660}
2661
2663{
2664 mLayer->setPath( name );
2665 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2666
2668 emit changed();
2669}
2670
2671void QgsSvgMarkerSymbolLayerWidget::setSvgParameters( const QMap<QString, QgsProperty> &parameters )
2672{
2673 mLayer->setParameters( parameters );
2674 whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2675
2677 emit changed();
2678}
2679
2680void QgsSvgMarkerSymbolLayerWidget::setWidth()
2681{
2682 const double defaultAspectRatio = mLayer->defaultAspectRatio();
2683 double fixedAspectRatio = 0.0;
2684 spinHeight->blockSignals( true );
2685 if ( defaultAspectRatio <= 0.0 )
2686 {
2687 spinHeight->setValue( spinWidth->value() );
2688 }
2689 else if ( mLockAspectRatio->locked() )
2690 {
2691 spinHeight->setValue( spinWidth->value() * defaultAspectRatio );
2692 }
2693 else
2694 {
2695 fixedAspectRatio = spinHeight->value() / spinWidth->value();
2696 }
2697 spinHeight->blockSignals( false );
2698 mLayer->setSize( spinWidth->value() );
2699 mLayer->setFixedAspectRatio( fixedAspectRatio );
2700 emit changed();
2701}
2702
2703void QgsSvgMarkerSymbolLayerWidget::setHeight()
2704{
2705 const double defaultAspectRatio = mLayer->defaultAspectRatio();
2706 double fixedAspectRatio = 0.0;
2707 spinWidth->blockSignals( true );
2708 if ( defaultAspectRatio <= 0.0 )
2709 {
2710 spinWidth->setValue( spinHeight->value() );
2711 }
2712 else if ( mLockAspectRatio->locked() )
2713 {
2714 spinWidth->setValue( spinHeight->value() / defaultAspectRatio );
2715 }
2716 else
2717 {
2718 fixedAspectRatio = spinHeight->value() / spinWidth->value();
2719 }
2720 spinWidth->blockSignals( false );
2721 mLayer->setSize( spinWidth->value() );
2722 mLayer->setFixedAspectRatio( fixedAspectRatio );
2723 emit changed();
2724}
2725
2726void QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged( const bool locked )
2727{
2728 //spinHeight->setEnabled( !locked );
2729 const double defaultAspectRatio = mLayer->defaultAspectRatio();
2730 if ( defaultAspectRatio <= 0.0 )
2731 {
2732 whileBlocking( mLockAspectRatio )->setLocked( true );
2733 }
2734 else if ( locked )
2735 {
2737 setWidth();
2738 }
2739 else
2740 {
2741 mLayer->setFixedAspectRatio( spinHeight->value() / spinWidth->value() );
2742 }
2743 //emit changed();
2744}
2745
2746void QgsSvgMarkerSymbolLayerWidget::setAngle()
2747{
2748 mLayer->setAngle( spinAngle->value() );
2749 emit changed();
2750}
2751
2752void QgsSvgMarkerSymbolLayerWidget::setOffset()
2753{
2754 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2755 emit changed();
2756}
2757
2758void QgsSvgMarkerSymbolLayerWidget::svgSourceChanged( const QString &text )
2759{
2760 mLayer->setPath( text );
2762 emit changed();
2763}
2764
2765void QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
2766{
2767 if ( !mLayer )
2768 {
2769 return;
2770 }
2771
2772 mLayer->setFillColor( color );
2773 emit changed();
2774}
2775
2776void QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
2777{
2778 if ( !mLayer )
2779 {
2780 return;
2781 }
2782
2783 mLayer->setStrokeColor( color );
2784 emit changed();
2785}
2786
2787void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
2788{
2789 if ( mLayer )
2790 {
2791 mLayer->setStrokeWidth( d );
2792 emit changed();
2793 }
2794}
2795
2796void QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
2797{
2798 if ( mLayer )
2799 {
2800 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2801 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2802 emit changed();
2803 }
2804}
2805
2806void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
2807{
2808 if ( mLayer )
2809 {
2810 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
2811 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
2812 emit changed();
2813 }
2814}
2815
2816void QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
2817{
2818 if ( mLayer )
2819 {
2820 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2821 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2822 emit changed();
2823 }
2824}
2825
2826void QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
2827{
2828 if ( mLayer )
2829 {
2831 emit changed();
2832 }
2833}
2834
2835void QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
2836{
2837 if ( mLayer )
2838 {
2840 emit changed();
2841 }
2842}
2843
2845
2847{
2848 mLayer = nullptr;
2849 setupUi( this );
2850
2851 mSvgSelectorWidget->setAllowParameters( true );
2852 mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
2853
2854 connect( mTextureWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged );
2855 connect( mSvgSelectorWidget->sourceLineEdit(), &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSVGFillSymbolLayerWidget::svgSourceChanged );
2856 connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
2857 connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged );
2858 connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2859 connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2860 connect( mTextureWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed );
2861 connect( mSvgStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed );
2866
2867 mRotationSpinBox->setClearValue( 0.0 );
2868
2869 mChangeColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
2870 mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2871 mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2872 mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2873
2874 mFilColorDDBtn->registerLinkedWidget( mChangeColorButton );
2875 mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2876
2877 connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgSelected, this, &QgsSVGFillSymbolLayerWidget::setFile );
2878 connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgParametersChanged, this, &QgsSVGFillSymbolLayerWidget::setSvgParameters );
2879}
2880
2882{
2883 if ( !layer )
2884 {
2885 return;
2886 }
2887
2888 if ( layer->layerType() != QLatin1String( "SVGFill" ) )
2889 {
2890 return;
2891 }
2892
2893 mLayer = dynamic_cast<QgsSVGFillSymbolLayer *>( layer );
2894 if ( mLayer )
2895 {
2896 const double width = mLayer->patternWidth();
2897 mTextureWidthSpinBox->blockSignals( true );
2898 mTextureWidthSpinBox->setValue( width );
2899 mTextureWidthSpinBox->blockSignals( false );
2900 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( mLayer->svgFilePath() );
2901 mRotationSpinBox->blockSignals( true );
2902 mRotationSpinBox->setValue( mLayer->angle() );
2903 mRotationSpinBox->blockSignals( false );
2904 mTextureWidthUnitWidget->blockSignals( true );
2905 mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2906 mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2907 mTextureWidthUnitWidget->blockSignals( false );
2908 mSvgStrokeWidthUnitWidget->blockSignals( true );
2909 mSvgStrokeWidthUnitWidget->setUnit( mLayer->svgStrokeWidthUnit() );
2910 mSvgStrokeWidthUnitWidget->setMapUnitScale( mLayer->svgStrokeWidthMapUnitScale() );
2911 mSvgStrokeWidthUnitWidget->blockSignals( false );
2912 mChangeColorButton->blockSignals( true );
2913 mChangeColorButton->setColor( mLayer->svgFillColor() );
2914 mChangeColorButton->blockSignals( false );
2915 mChangeStrokeColorButton->blockSignals( true );
2916 mChangeStrokeColorButton->setColor( mLayer->svgStrokeColor() );
2917 mChangeStrokeColorButton->blockSignals( false );
2918 mStrokeWidthSpinBox->blockSignals( true );
2919 mStrokeWidthSpinBox->setValue( mLayer->svgStrokeWidth() );
2920 mStrokeWidthSpinBox->blockSignals( false );
2921 }
2922 updateParamGui( false );
2923
2929
2930 registerDataDefinedButton( mSvgSelectorWidget->sourceLineEdit()->propertyOverrideToolButton(), QgsSymbolLayer::Property::File );
2931}
2932
2937
2939{
2941 mSvgSelectorWidget->sourceLineEdit()->setMessageBar( context.messageBar() );
2942}
2943
2944void QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged( double d )
2945{
2946 if ( mLayer )
2947 {
2948 mLayer->setPatternWidth( d );
2949 emit changed();
2950 }
2951}
2952
2953void QgsSVGFillSymbolLayerWidget::svgSourceChanged( const QString &text )
2954{
2955 if ( !mLayer )
2956 {
2957 return;
2958 }
2959
2960 mLayer->setSvgFilePath( text );
2962 emit changed();
2963}
2964
2965void QgsSVGFillSymbolLayerWidget::setFile( const QString &name )
2966{
2967 mLayer->setSvgFilePath( name );
2968 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2969
2971 emit changed();
2972}
2973
2974void QgsSVGFillSymbolLayerWidget::setSvgParameters( const QMap<QString, QgsProperty> &parameters )
2975{
2976 mLayer->setParameters( parameters );
2977 whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2978
2980 emit changed();
2981}
2982
2983
2984void QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
2985{
2986 if ( mLayer )
2987 {
2988 mLayer->setAngle( d );
2989 emit changed();
2990 }
2991}
2992
2994{
2995 //activate gui for svg parameters only if supported by the svg file
2996 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2997 QColor defaultFill, defaultStroke;
2998 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2999 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
3000 QgsApplication::svgCache()->containsParams( mSvgSelectorWidget->sourceLineEdit()->source(), hasFillParam, hasDefaultFillColor, defaultFill,
3001 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
3002 hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
3003 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
3004 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
3005 if ( resetValues )
3006 {
3007 QColor fill = mChangeColorButton->color();
3008 const double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
3009 if ( hasDefaultFillColor )
3010 {
3011 fill = defaultFill;
3012 }
3013 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
3014 mChangeColorButton->setColor( fill );
3015 }
3016 mChangeColorButton->setEnabled( hasFillParam );
3017 mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
3018 if ( resetValues )
3019 {
3020 QColor stroke = mChangeStrokeColorButton->color();
3021 const double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
3022 if ( hasDefaultStrokeColor )
3023 {
3024 stroke = defaultStroke;
3025 }
3026 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
3027 mChangeStrokeColorButton->setColor( stroke );
3028 }
3029 mChangeStrokeColorButton->setEnabled( hasStrokeParam );
3030 mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
3031 if ( hasDefaultStrokeWidth && resetValues )
3032 {
3033 mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
3034 }
3035 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
3036}
3037
3038void QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
3039{
3040 if ( !mLayer )
3041 {
3042 return;
3043 }
3044
3045 mLayer->setSvgFillColor( color );
3046 emit changed();
3047}
3048
3049void QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
3050{
3051 if ( !mLayer )
3052 {
3053 return;
3054 }
3055
3056 mLayer->setSvgStrokeColor( color );
3057 emit changed();
3058}
3059
3060void QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
3061{
3062 if ( mLayer )
3063 {
3065 emit changed();
3066 }
3067}
3068
3069void QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed()
3070{
3071 if ( mLayer )
3072 {
3073 mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
3074 mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
3075 emit changed();
3076 }
3077}
3078
3079void QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed()
3080{
3081 if ( mLayer )
3082 {
3083 mLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnitWidget->unit() );
3084 mLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthUnitWidget->getMapUnitScale() );
3085 emit changed();
3086 }
3087}
3088
3090
3092 QgsSymbolLayerWidget( parent, vl )
3093{
3094 setupUi( this );
3095 connect( mAngleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged );
3096 connect( mDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged );
3097 connect( mOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged );
3098 connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed );
3099 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed );
3104 mOffsetSpinBox->setClearValue( 0 );
3105 mAngleSpinBox->setClearValue( 0 );
3106
3107 mCoordinateReferenceComboBox->addItem( tr( "Align Pattern to Feature" ), static_cast< int >( Qgis::SymbolCoordinateReference::Feature ) );
3108 mCoordinateReferenceComboBox->addItem( tr( "Align Pattern to Map Extent" ), static_cast< int >( Qgis::SymbolCoordinateReference::Viewport ) );
3109 connect( mCoordinateReferenceComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]
3110 {
3111 if ( mLayer )
3112 {
3113 mLayer->setCoordinateReference( static_cast< Qgis::SymbolCoordinateReference >( mCoordinateReferenceComboBox->currentData().toInt() ) );
3114 emit changed();
3115 }
3116 } );
3117
3118 mClipModeComboBox->addItem( tr( "Clip During Render Only" ), static_cast< int >( Qgis::LineClipMode::ClipPainterOnly ) );
3119 mClipModeComboBox->addItem( tr( "Clip Lines Before Render" ), static_cast< int >( Qgis::LineClipMode::ClipToIntersection ) );
3120 mClipModeComboBox->addItem( tr( "No Clipping" ), static_cast< int >( Qgis::LineClipMode::NoClipping ) );
3121 connect( mClipModeComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]
3122 {
3123 if ( mLayer )
3124 {
3125 mLayer->setClipMode( static_cast< Qgis::LineClipMode >( mClipModeComboBox->currentData().toInt() ) );
3126 emit changed();
3127 }
3128 } );
3129
3130}
3131
3133{
3134 if ( layer->layerType() != QLatin1String( "LinePatternFill" ) )
3135 {
3136 return;
3137 }
3138
3139 QgsLinePatternFillSymbolLayer *patternLayer = static_cast<QgsLinePatternFillSymbolLayer *>( layer );
3140 if ( patternLayer )
3141 {
3142 mLayer = patternLayer;
3143 whileBlocking( mAngleSpinBox )->setValue( mLayer->lineAngle() );
3144 whileBlocking( mDistanceSpinBox )->setValue( mLayer->distance() );
3145 whileBlocking( mOffsetSpinBox )->setValue( mLayer->offset() );
3146
3147 //units
3148 mDistanceUnitWidget->blockSignals( true );
3149 mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
3150 mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
3151 mDistanceUnitWidget->blockSignals( false );
3152 mOffsetUnitWidget->blockSignals( true );
3153 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3154 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3155 mOffsetUnitWidget->blockSignals( false );
3156
3157 whileBlocking( mCoordinateReferenceComboBox )->setCurrentIndex( mCoordinateReferenceComboBox->findData( static_cast< int >( mLayer->coordinateReference() ) ) );
3158
3159 whileBlocking( mClipModeComboBox )->setCurrentIndex( mClipModeComboBox->findData( static_cast< int >( mLayer->clipMode() ) ) );
3160 }
3161
3166}
3167
3172
3173void QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged( double d )
3174{
3175 if ( mLayer )
3176 {
3177 mLayer->setLineAngle( d );
3178 emit changed();
3179 }
3180}
3181
3182void QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged( double d )
3183{
3184 if ( mLayer )
3185 {
3186 mLayer->setDistance( d );
3187 emit changed();
3188 }
3189}
3190
3191void QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged( double d )
3192{
3193 if ( mLayer )
3194 {
3195 mLayer->setOffset( d );
3196 emit changed();
3197 }
3198}
3199
3200void QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed()
3201{
3202 if ( mLayer )
3203 {
3204 mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
3205 mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
3206 emit changed();
3207 }
3208}
3209
3210void QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed()
3211{
3212 if ( mLayer )
3213 {
3214 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3215 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3216 emit changed();
3217 }
3218}
3219
3221
3223 QgsSymbolLayerWidget( parent, vl )
3224{
3225 setupUi( this );
3226 connect( mHorizontalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged );
3227 connect( mVerticalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged );
3228 connect( mHorizontalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged );
3229 connect( mVerticalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged );
3230 connect( mHorizontalOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged );
3231 connect( mVerticalOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged );
3232 connect( mHorizontalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed );
3233 connect( mVerticalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed );
3234 connect( mHorizontalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed );
3235 connect( mVerticalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed );
3236 connect( mHorizontalOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed );
3237 connect( mVerticalOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed );
3250
3251 mClipModeComboBox->addItem( tr( "Clip to Shape" ), static_cast< int >( Qgis::MarkerClipMode::Shape ) );
3252 mClipModeComboBox->addItem( tr( "Marker Centroid Within Shape" ), static_cast< int >( Qgis::MarkerClipMode::CentroidWithin ) );
3253 mClipModeComboBox->addItem( tr( "Marker Completely Within Shape" ), static_cast< int >( Qgis::MarkerClipMode::CompletelyWithin ) );
3254 mClipModeComboBox->addItem( tr( "No Clipping" ), static_cast< int >( Qgis::MarkerClipMode::NoClipping ) );
3255 connect( mClipModeComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]
3256 {
3257 if ( mLayer )
3258 {
3259 mLayer->setClipMode( static_cast< Qgis::MarkerClipMode >( mClipModeComboBox->currentData().toInt() ) );
3260 emit changed();
3261 }
3262 } );
3263
3264 mCoordinateReferenceComboBox->addItem( tr( "Align Pattern to Feature" ), static_cast< int >( Qgis::SymbolCoordinateReference::Feature ) );
3265 mCoordinateReferenceComboBox->addItem( tr( "Align Pattern to Map Extent" ), static_cast< int >( Qgis::SymbolCoordinateReference::Viewport ) );
3266 connect( mCoordinateReferenceComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]
3267 {
3268 if ( mLayer )
3269 {
3270 mLayer->setCoordinateReference( static_cast< Qgis::SymbolCoordinateReference >( mCoordinateReferenceComboBox->currentData().toInt() ) );
3271 emit changed();
3272 }
3273 } );
3274
3275 mSeedSpinBox->setShowClearButton( true );
3276 mSeedSpinBox->setClearValue( 0 );
3277 mRandomXSpinBox->setClearValue( 0 );
3278 mRandomYSpinBox->setClearValue( 0 );
3279
3284 connect( mRandomXSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double d )
3285 {
3286 if ( mLayer )
3287 {
3289 emit changed();
3290 }
3291 } );
3292 connect( mRandomYSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double d )
3293 {
3294 if ( mLayer )
3295 {
3297 emit changed();
3298 }
3299 } );
3300 connect( mRandomXOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
3301 {
3302 if ( mLayer )
3303 {
3304 mLayer->setRandomDeviationXUnit( mRandomXOffsetUnitWidget->unit() );
3305 mLayer->setRandomDeviationXMapUnitScale( mRandomXOffsetUnitWidget->getMapUnitScale() );
3306 emit changed();
3307 }
3308 } );
3309 connect( mRandomYOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
3310 {
3311 if ( mLayer )
3312 {
3313 mLayer->setRandomDeviationYUnit( mRandomYOffsetUnitWidget->unit() );
3314 mLayer->setRandomDeviationYMapUnitScale( mRandomYOffsetUnitWidget->getMapUnitScale() );
3315 emit changed();
3316 }
3317 } );
3318 connect( mSeedSpinBox, qOverload< int > ( &QSpinBox::valueChanged ), this, [ = ]( int v )
3319 {
3320 if ( mLayer )
3321 {
3322 mLayer->setSeed( v );
3323 emit changed();
3324 }
3325 } );
3326
3327 mAngleSpinBox->setShowClearButton( true );
3328 mAngleSpinBox->setClearValue( 0 );
3329 connect( mAngleSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double d )
3330 {
3331 if ( mLayer )
3332 {
3333 mLayer->setAngle( d );
3334 emit changed();
3335 }
3336 } );
3337}
3338
3340{
3341 if ( !layer || layer->layerType() != QLatin1String( "PointPatternFill" ) )
3342 {
3343 return;
3344 }
3345
3346 mLayer = static_cast<QgsPointPatternFillSymbolLayer *>( layer );
3347 whileBlocking( mHorizontalDistanceSpinBox )->setValue( mLayer->distanceX() );
3348 whileBlocking( mVerticalDistanceSpinBox )->setValue( mLayer->distanceY() );
3349 whileBlocking( mHorizontalDisplacementSpinBox )->setValue( mLayer->displacementX() );
3350 whileBlocking( mVerticalDisplacementSpinBox )->setValue( mLayer->displacementY() );
3351 whileBlocking( mHorizontalOffsetSpinBox )->setValue( mLayer->offsetX() );
3352 whileBlocking( mVerticalOffsetSpinBox )->setValue( mLayer->offsetY() );
3353 whileBlocking( mAngleSpinBox )->setValue( mLayer->angle() );
3354
3355 mHorizontalDistanceUnitWidget->blockSignals( true );
3356 mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
3357 mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
3358 mHorizontalDistanceUnitWidget->blockSignals( false );
3359 mVerticalDistanceUnitWidget->blockSignals( true );
3360 mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
3361 mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
3362 mVerticalDistanceUnitWidget->blockSignals( false );
3363 mHorizontalDisplacementUnitWidget->blockSignals( true );
3364 mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
3365 mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
3366 mHorizontalDisplacementUnitWidget->blockSignals( false );
3367 mVerticalDisplacementUnitWidget->blockSignals( true );
3368 mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
3369 mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
3370 mVerticalDisplacementUnitWidget->blockSignals( false );
3371 mHorizontalOffsetUnitWidget->blockSignals( true );
3372 mHorizontalOffsetUnitWidget->setUnit( mLayer->offsetXUnit() );
3373 mHorizontalOffsetUnitWidget->setMapUnitScale( mLayer->offsetXMapUnitScale() );
3374 mHorizontalOffsetUnitWidget->blockSignals( false );
3375 mVerticalOffsetUnitWidget->blockSignals( true );
3376 mVerticalOffsetUnitWidget->setUnit( mLayer->offsetYUnit() );
3377 mVerticalOffsetUnitWidget->setMapUnitScale( mLayer->offsetYMapUnitScale() );
3378 mVerticalOffsetUnitWidget->blockSignals( false );
3379
3380 whileBlocking( mClipModeComboBox )->setCurrentIndex( mClipModeComboBox->findData( static_cast< int >( mLayer->clipMode() ) ) );
3381 whileBlocking( mCoordinateReferenceComboBox )->setCurrentIndex( mCoordinateReferenceComboBox->findData( static_cast< int >( mLayer->coordinateReference() ) ) );
3382
3383 whileBlocking( mRandomXSpinBox )->setValue( mLayer->maximumRandomDeviationX() );
3384 whileBlocking( mRandomYSpinBox )->setValue( mLayer->maximumRandomDeviationY() );
3385 whileBlocking( mRandomXOffsetUnitWidget )->setUnit( mLayer->randomDeviationXUnit() );
3386 whileBlocking( mRandomXOffsetUnitWidget )->setMapUnitScale( mLayer->randomDeviationXMapUnitScale() );
3387 whileBlocking( mRandomYOffsetUnitWidget )->setUnit( mLayer->randomDeviationYUnit() );
3388 whileBlocking( mRandomYOffsetUnitWidget )->setMapUnitScale( mLayer->randomDeviationYMapUnitScale() );
3389 whileBlocking( mSeedSpinBox )->setValue( mLayer->seed() );
3390
3403}
3404
3409
3410void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged( double d )
3411{
3412 if ( mLayer )
3413 {
3414 mLayer->setDistanceX( d );
3415 emit changed();
3416 }
3417}
3418
3419void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged( double d )
3420{
3421 if ( mLayer )
3422 {
3423 mLayer->setDistanceY( d );
3424 emit changed();
3425 }
3426}
3427
3428void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged( double d )
3429{
3430 if ( mLayer )
3431 {
3433 emit changed();
3434 }
3435}
3436
3437void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged( double d )
3438{
3439 if ( mLayer )
3440 {
3442 emit changed();
3443 }
3444}
3445
3446void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged( double d )
3447{
3448 if ( mLayer )
3449 {
3450 mLayer->setOffsetX( d );
3451 emit changed();
3452 }
3453}
3454
3455void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged( double d )
3456{
3457 if ( mLayer )
3458 {
3459 mLayer->setOffsetY( d );
3460 emit changed();
3461 }
3462}
3463
3464void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed()
3465{
3466 if ( mLayer )
3467 {
3468 mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
3469 mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
3470 emit changed();
3471 }
3472}
3473
3474void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed()
3475{
3476 if ( mLayer )
3477 {
3478 mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
3479 mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
3480 emit changed();
3481 }
3482}
3483
3484void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed()
3485{
3486 if ( mLayer )
3487 {
3488 mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
3489 mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
3490 emit changed();
3491 }
3492}
3493
3494void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed()
3495{
3496 if ( mLayer )
3497 {
3498 mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
3499 mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
3500 emit changed();
3501 }
3502}
3503
3504void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed()
3505{
3506 if ( mLayer )
3507 {
3508 mLayer->setOffsetXUnit( mHorizontalOffsetUnitWidget->unit() );
3509 mLayer->setOffsetXMapUnitScale( mHorizontalOffsetUnitWidget->getMapUnitScale() );
3510 emit changed();
3511 }
3512}
3513
3514void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed()
3515{
3516 if ( mLayer )
3517 {
3518 mLayer->setOffsetYUnit( mVerticalOffsetUnitWidget->unit() );
3519 mLayer->setOffsetYMapUnitScale( mVerticalOffsetUnitWidget->getMapUnitScale() );
3520 emit changed();
3521 }
3522}
3523
3525
3527 : QgsSymbolLayerWidget( parent, vl )
3528{
3529 mLayer = nullptr;
3530
3531 setupUi( this );
3532 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
3533 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
3534 connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
3535 connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
3536 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3537 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3544
3546 scrollArea->setWidget( widgetChar );
3547 scrollArea->setVerticalOnly( true );
3548
3549 btnColor->setAllowOpacity( true );
3550 btnColor->setColorDialogTitle( tr( "Select Symbol Fill Color" ) );
3551 btnColor->setContext( QStringLiteral( "symbology" ) );
3552 btnStrokeColor->setAllowOpacity( true );
3553 btnStrokeColor->setColorDialogTitle( tr( "Select Symbol Stroke Color" ) );
3554 btnStrokeColor->setContext( QStringLiteral( "symbology" ) );
3555
3556 mColorDDBtn->registerLinkedWidget( btnColor );
3557 mStrokeColorDDBtn->registerLinkedWidget( btnStrokeColor );
3558
3559 spinOffsetX->setClearValue( 0.0 );
3560 spinOffsetY->setClearValue( 0.0 );
3561 spinAngle->setClearValue( 0.0 );
3562
3563 //make a temporary symbol for the size assistant preview
3564 mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
3565
3566 if ( vectorLayer() )
3567 mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
3568
3569 connect( cboFont, &QFontComboBox::currentFontChanged, this, &QgsFontMarkerSymbolLayerWidget::setFontFamily );
3570 connect( mFontStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged );
3571 connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setSize );
3572 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3575 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3576 connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setAngle );
3577 connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3578 connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3580 connect( mCharLineEdit, &QLineEdit::textChanged, this, &QgsFontMarkerSymbolLayerWidget::setCharacterFromText );
3581
3582 connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol );
3583}
3584
3586
3588{
3589 if ( layer->layerType() != QLatin1String( "FontMarker" ) )
3590 return;
3591
3592 // layer type is correct, we can do the cast
3593 mLayer = static_cast<QgsFontMarkerSymbolLayer *>( layer );
3594
3596 mRefFont.setStyleName( QgsFontUtils::translateNamedStyle( mLayer->fontStyle() ) );
3597
3598 mFontStyleComboBox->blockSignals( true );
3599 populateFontStyleComboBox();
3600 mFontStyleComboBox->blockSignals( false );
3601
3602 // set values
3603 whileBlocking( cboFont )->setCurrentFont( mRefFont );
3604 whileBlocking( spinSize )->setValue( mLayer->size() );
3605 whileBlocking( btnColor )->setColor( mLayer->color() );
3606 whileBlocking( btnStrokeColor )->setColor( mLayer->strokeColor() );
3607 whileBlocking( mStrokeWidthSpinBox )->setValue( mLayer->strokeWidth() );
3608 whileBlocking( spinAngle )->setValue( mLayer->angle() );
3609
3610 widgetChar->blockSignals( true );
3611 widgetChar->setFont( mRefFont );
3612 if ( mLayer->character().length() == 1 )
3613 {
3614 widgetChar->setCharacter( mLayer->character().at( 0 ) );
3615 }
3616 widgetChar->blockSignals( false );
3617 whileBlocking( mCharLineEdit )->setText( mLayer->character() );
3618 mCharPreview->setFont( mRefFont );
3619
3620 //block
3621 whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
3622 whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
3623
3624 mSizeUnitWidget->blockSignals( true );
3625 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
3626 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
3627 mSizeUnitWidget->blockSignals( false );
3628
3629 mStrokeWidthUnitWidget->blockSignals( true );
3630 mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
3631 mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
3632 mStrokeWidthUnitWidget->blockSignals( false );
3633
3634 mOffsetUnitWidget->blockSignals( true );
3635 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3636 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3637 mOffsetUnitWidget->blockSignals( false );
3638
3639 whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
3640
3641 //anchor points
3642 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
3643 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
3644
3657
3658 updateAssistantSymbol();
3659}
3660
3665
3667{
3668 if ( mLayer )
3669 {
3670 mLayer->setFontFamily( font.family() );
3671 QgsFontUtils::setFontFamily( mRefFont, font.family() );
3672 widgetChar->setFont( mRefFont );
3673 mCharPreview->setFont( mRefFont );
3674 populateFontStyleComboBox();
3675 emit changed();
3676 }
3677}
3678
3679void QgsFontMarkerSymbolLayerWidget::setFontStyle( const QString &style )
3680{
3681 if ( mLayer )
3682 {
3683 QgsFontUtils::updateFontViaStyle( mRefFont, style );
3685 widgetChar->setFont( mRefFont );
3686 mCharPreview->setFont( mRefFont );
3687 emit changed();
3688 }
3689}
3690
3692{
3693 mLayer->setColor( color );
3694 emit changed();
3695}
3696
3698{
3699 mLayer->setStrokeColor( color );
3700 emit changed();
3701}
3702
3704{
3705 mLayer->setSize( size );
3706 //widgetChar->updateSize(size);
3707 emit changed();
3708}
3709
3711{
3712 mLayer->setAngle( angle );
3713 emit changed();
3714}
3715
3717{
3718 mCharPreview->setText( text );
3719
3720 if ( text.isEmpty() )
3721 return;
3722
3723 // take the last character of a string for a better experience when users cycle through several characters on their keyboard
3724 QString character = text;
3725 if ( text.contains( QRegularExpression( QStringLiteral( "^0x[0-9a-fA-F]{1,4}$" ) ) ) )
3726 {
3727 bool ok = false;
3728 const unsigned int value = text.toUInt( &ok, 0 );
3729 if ( ok )
3730 {
3731 character = QChar( value );
3732 mCharPreview->setText( character );
3733 }
3734 }
3735
3736 if ( character != mLayer->character() )
3737 {
3738 mLayer->setCharacter( character );
3739 if ( mLayer->character().length() == 1 )
3740 {
3741 whileBlocking( widgetChar )->setCharacter( mLayer->character().at( 0 ) );
3742 }
3743 else
3744 {
3746 }
3747 emit changed();
3748 }
3749}
3750
3752{
3753 if ( mLayer->character().length() > 1 || QGuiApplication::keyboardModifiers() & Qt::ControlModifier )
3754 {
3755 mCharLineEdit->insert( chr );
3756 return;
3757 }
3758
3759 mLayer->setCharacter( chr );
3760 whileBlocking( mCharLineEdit )->setText( chr );
3761 mCharPreview->setText( chr );
3762 emit changed();
3763}
3764
3765void QgsFontMarkerSymbolLayerWidget::setOffset()
3766{
3767 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
3768 emit changed();
3769}
3770
3771void QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged()
3772{
3773 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
3774 emit changed();
3775}
3776
3777void QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
3778{
3779 if ( mLayer )
3780 {
3781 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
3782 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3783 emit changed();
3784 }
3785}
3786
3787void QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
3788{
3789 if ( mLayer )
3790 {
3791 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3792 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3793 emit changed();
3794 }
3795}
3796
3797void QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
3798{
3799 if ( mLayer )
3800 {
3801 mLayer->setStrokeWidthUnit( mSizeUnitWidget->unit() );
3802 mLayer->setStrokeWidthMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3803 emit changed();
3804 }
3805}
3806
3807void QgsFontMarkerSymbolLayerWidget::populateFontStyleComboBox()
3808{
3809 mFontStyleComboBox->clear();
3810 const QStringList styles = mFontDB.styles( mRefFont.family() );
3811 const auto constStyles = styles;
3812 for ( const QString &style : constStyles )
3813 {
3814 mFontStyleComboBox->addItem( style );
3815 }
3816
3817 QString targetStyle = mFontDB.styleString( mRefFont );
3818 if ( !styles.contains( targetStyle ) )
3819 {
3820 const QFont f = QgsFontUtils::createFont( mRefFont.family() );
3821 targetStyle = QFontInfo( f ).styleName();
3822 mRefFont.setStyleName( targetStyle );
3823 }
3824 int curIndx = 0;
3825 const int stylIndx = mFontStyleComboBox->findText( targetStyle );
3826 if ( stylIndx > -1 )
3827 {
3828 curIndx = stylIndx;
3829 }
3830
3831 mFontStyleComboBox->setCurrentIndex( curIndx );
3832}
3833
3834void QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged( int index )
3835{
3836 Q_UNUSED( index );
3837 setFontStyle( mFontStyleComboBox->currentText() );
3838}
3839
3840void QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
3841{
3842 if ( mLayer )
3843 {
3845 emit changed();
3846 }
3847}
3848
3849void QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
3850{
3851 if ( mLayer )
3852 {
3854 emit changed();
3855 }
3856}
3857
3858void QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
3859{
3860 if ( mLayer )
3861 {
3862 mLayer->setStrokeWidth( d );
3863 emit changed();
3864 }
3865}
3866
3867void QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol()
3868{
3869 for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
3870 {
3871 mAssistantPreviewSymbol->deleteSymbolLayer( i );
3872 }
3873 mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
3875 if ( ddSize )
3876 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
3877}
3878
3880
3881
3883 : QgsSymbolLayerWidget( parent, vl )
3884{
3885 mLayer = nullptr;
3886
3887 setupUi( this );
3888 connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
3889 connect( mDrawAllPartsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged );
3890 connect( mClipPointsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged );
3891 connect( mClipOnCurrentPartOnlyCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged );
3892}
3893
3895{
3896 if ( layer->layerType() != QLatin1String( "CentroidFill" ) )
3897 return;
3898
3899 // layer type is correct, we can do the cast
3900 mLayer = static_cast<QgsCentroidFillSymbolLayer *>( layer );
3901
3902 // set values
3903 whileBlocking( mDrawInsideCheckBox )->setChecked( mLayer->pointOnSurface() );
3904 whileBlocking( mDrawAllPartsCheckBox )->setChecked( mLayer->pointOnAllParts() );
3905 whileBlocking( mClipPointsCheckBox )->setChecked( mLayer->clipPoints() );
3906 whileBlocking( mClipOnCurrentPartOnlyCheckBox )->setChecked( mLayer->clipOnCurrentPartOnly() );
3907}
3908
3913
3914void QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
3915{
3916 mLayer->setPointOnSurface( state == Qt::Checked );
3917 emit changed();
3918}
3919
3920void QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged( int state )
3921{
3922 mLayer->setPointOnAllParts( state == Qt::Checked );
3923 emit changed();
3924}
3925
3926void QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged( int state )
3927{
3928 mLayer->setClipPoints( state == Qt::Checked );
3929 emit changed();
3930}
3931
3932void QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged( int state )
3933{
3934 mLayer->setClipOnCurrentPartOnly( state == Qt::Checked );
3935 emit changed();
3936}
3937
3939
3941 : QgsSymbolLayerWidget( parent, vl )
3942{
3943 mLayer = nullptr;
3944
3945 setupUi( this );
3946
3947 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
3948
3949 connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterMarkerSymbolLayerWidget::imageSourceChanged );
3950 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
3951 connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setAngle );
3952 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
3953 connect( mWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setWidth );
3954 connect( mHeightSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setHeight );
3955 connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setLockAspectRatio );
3956
3961
3962 mSpinOffsetX->setClearValue( 0.0 );
3963 mSpinOffsetY->setClearValue( 0.0 );
3964 mRotationSpinBox->setClearValue( 0.0 );
3965
3966 connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3967 connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3968 connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterMarkerSymbolLayerWidget::setOpacity );
3969
3970 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3971 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3972}
3973
3975{
3976 if ( !layer )
3977 {
3978 return;
3979 }
3980
3981 if ( layer->layerType() != QLatin1String( "RasterMarker" ) )
3982 return;
3983
3984 // layer type is correct, we can do the cast
3985 mLayer = static_cast<QgsRasterMarkerSymbolLayer *>( layer );
3986
3987 // set values
3988 whileBlocking( mImageSourceLineEdit )->setSource( mLayer->path() );
3989
3990 whileBlocking( mWidthSpinBox )->setValue( mLayer->size() );
3991 const bool preservedAspectRatio = mLayer->preservedAspectRatio();
3992 mHeightSpinBox->blockSignals( true );
3993 if ( preservedAspectRatio )
3994 {
3995 mHeightSpinBox->setValue( mLayer->size() );
3996 }
3997 else
3998 {
3999 mHeightSpinBox->setValue( mLayer->size() * mLayer->fixedAspectRatio() );
4000 }
4001 mHeightSpinBox->setEnabled( mLayer->defaultAspectRatio() > 0.0 );
4002 mHeightSpinBox->blockSignals( false );
4003 whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
4004
4005 whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
4006 whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
4007
4008 whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
4009 whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
4010
4011 mSizeUnitWidget->blockSignals( true );
4012 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
4013 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
4014 mSizeUnitWidget->blockSignals( false );
4015 mOffsetUnitWidget->blockSignals( true );
4016 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
4017 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
4018 mOffsetUnitWidget->blockSignals( false );
4019
4020 //anchor points
4021 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
4022 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
4023
4032
4033 updatePreviewImage();
4034}
4035
4040
4042{
4044 mImageSourceLineEdit->setMessageBar( context.messageBar() );
4045}
4046
4047void QgsRasterMarkerSymbolLayerWidget::imageSourceChanged( const QString &text )
4048{
4049 mLayer->setPath( text );
4050 updatePreviewImage();
4051 emit changed();
4052}
4053
4054void QgsRasterMarkerSymbolLayerWidget::updatePreviewImage()
4055{
4056 bool fitsInCache = false;
4057 const QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->path(), QSize( 150, 150 ), true, 1.0, fitsInCache );
4058 if ( image.isNull() )
4059 {
4060 mLabelImagePreview->setPixmap( QPixmap() );
4061 return;
4062 }
4063
4064 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4065 previewImage.fill( Qt::transparent );
4066 const QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4067 QPainter p;
4068 p.begin( &previewImage );
4069 //draw a checkerboard background
4070 uchar pixDataRGB[] = { 150, 150, 150, 150,
4071 100, 100, 100, 150,
4072 100, 100, 100, 150,
4073 150, 150, 150, 150
4074 };
4075 const QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4076 const QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4077 QBrush checkerBrush;
4078 checkerBrush.setTexture( pix );
4079 p.fillRect( imageRect, checkerBrush );
4080
4081 if ( mLayer->opacity() < 1.0 )
4082 {
4083 p.setOpacity( mLayer->opacity() );
4084 }
4085
4086 p.drawImage( imageRect.left(), imageRect.top(), image );
4087 p.end();
4088 mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4089}
4090
4091void QgsRasterMarkerSymbolLayerWidget::setWidth()
4092{
4093 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4094 double fixedAspectRatio = 0.0;
4095 mHeightSpinBox->blockSignals( true );
4096 if ( defaultAspectRatio <= 0.0 )
4097 {
4098 mHeightSpinBox->setValue( mWidthSpinBox->value() );
4099 }
4100 else if ( mLockAspectRatio->locked() )
4101 {
4102 mHeightSpinBox->setValue( mWidthSpinBox->value() * defaultAspectRatio );
4103 }
4104 else
4105 {
4106 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4107 }
4108 mHeightSpinBox->blockSignals( false );
4109 mLayer->setSize( mWidthSpinBox->value() );
4110 mLayer->setFixedAspectRatio( fixedAspectRatio );
4111 emit changed();
4112}
4113
4114void QgsRasterMarkerSymbolLayerWidget::setHeight()
4115{
4116 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4117 double fixedAspectRatio = 0.0;
4118 mWidthSpinBox->blockSignals( true );
4119 if ( defaultAspectRatio <= 0.0 )
4120 {
4121 mWidthSpinBox->setValue( mHeightSpinBox->value() );
4122 }
4123 else if ( mLockAspectRatio->locked() )
4124 {
4125 mWidthSpinBox->setValue( mHeightSpinBox->value() / defaultAspectRatio );
4126 }
4127 else
4128 {
4129 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4130 }
4131 mWidthSpinBox->blockSignals( false );
4132 mLayer->setSize( mWidthSpinBox->value() );
4133 mLayer->setFixedAspectRatio( fixedAspectRatio );
4134 emit changed();
4135}
4136
4137void QgsRasterMarkerSymbolLayerWidget::setLockAspectRatio( const bool locked )
4138{
4139 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4140 if ( defaultAspectRatio <= 0.0 )
4141 {
4142 whileBlocking( mLockAspectRatio )->setLocked( true );
4143 }
4144 else if ( locked )
4145 {
4147 setWidth();
4148 }
4149 else
4150 {
4151 mLayer->setFixedAspectRatio( mHeightSpinBox->value() / mWidthSpinBox->value() );
4152 }
4153}
4154
4155void QgsRasterMarkerSymbolLayerWidget::setAngle()
4156{
4157 mLayer->setAngle( mRotationSpinBox->value() );
4158 emit changed();
4159}
4160
4161void QgsRasterMarkerSymbolLayerWidget::setOpacity( double value )
4162{
4163 mLayer->setOpacity( value );
4164 emit changed();
4165 updatePreviewImage();
4166}
4167
4168void QgsRasterMarkerSymbolLayerWidget::setOffset()
4169{
4170 mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4171 emit changed();
4172}
4173
4174void QgsRasterMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
4175{
4176 if ( mLayer )
4177 {
4178 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
4179 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4180 emit changed();
4181 }
4182}
4183
4184void QgsRasterMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
4185{
4186 if ( mLayer )
4187 {
4188 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4189 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4190 emit changed();
4191 }
4192}
4193
4194void QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
4195{
4196 if ( mLayer )
4197 {
4199 emit changed();
4200 }
4201}
4202
4203void QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
4204{
4205 if ( mLayer )
4206 {
4208 emit changed();
4209 }
4210}
4211
4212
4214
4216 : QgsSymbolLayerWidget( parent, vl )
4217{
4218 mLayer = nullptr;
4219
4220 setupUi( this );
4221
4222 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastAnimatedMarkerImageDir" ) );
4223
4224 connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsAnimatedMarkerSymbolLayerWidget::imageSourceChanged );
4225 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsAnimatedMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
4226 connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setAngle );
4227 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsAnimatedMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
4228 connect( mWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setWidth );
4229 connect( mHeightSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setHeight );
4230 connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setLockAspectRatio );
4231
4232 mFrameRateSpin->setClearValue( 10 );
4233 mFrameRateSpin->setShowClearButton( true );
4234 connect( mFrameRateSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
4235 {
4236 mLayer->setFrameRate( value );
4237 emit changed();
4238 } );
4239
4244
4245 mSpinOffsetX->setClearValue( 0.0 );
4246 mSpinOffsetY->setClearValue( 0.0 );
4247 mRotationSpinBox->setClearValue( 0.0 );
4248
4249 connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setOffset );
4250 connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::setOffset );
4251 connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsAnimatedMarkerSymbolLayerWidget::setOpacity );
4252
4253 connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
4254 connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsAnimatedMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
4255}
4256
4258{
4259 if ( !layer )
4260 {
4261 return;
4262 }
4263
4264 if ( layer->layerType() != QLatin1String( "AnimatedMarker" ) )
4265 return;
4266
4267 // layer type is correct, we can do the cast
4268 mLayer = static_cast<QgsAnimatedMarkerSymbolLayer *>( layer );
4269
4270 // set values
4271 whileBlocking( mImageSourceLineEdit )->setSource( mLayer->path() );
4272
4273 const double firstFrameTime = QgsApplication::imageCache()->nextFrameDelay( mLayer->path() );
4274 if ( firstFrameTime > 0 )
4275 {
4276 mFrameRateSpin->setClearValue( 1000 / firstFrameTime );
4277 }
4278 else
4279 {
4280 mFrameRateSpin->setClearValue( 10 );
4281 }
4282
4283 whileBlocking( mWidthSpinBox )->setValue( mLayer->size() );
4284 const bool preservedAspectRatio = mLayer->preservedAspectRatio();
4285 mHeightSpinBox->blockSignals( true );
4286 if ( preservedAspectRatio )
4287 {
4288 mHeightSpinBox->setValue( mLayer->size() );
4289 }
4290 else
4291 {
4292 mHeightSpinBox->setValue( mLayer->size() * mLayer->fixedAspectRatio() );
4293 }
4294 mHeightSpinBox->setEnabled( mLayer->defaultAspectRatio() > 0.0 );
4295 mHeightSpinBox->blockSignals( false );
4296 whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
4297
4298 whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
4299 whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
4300
4301 whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
4302 whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
4303
4304 whileBlocking( mFrameRateSpin )->setValue( mLayer->frameRate() );
4305
4306 mSizeUnitWidget->blockSignals( true );
4307 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
4308 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
4309 mSizeUnitWidget->blockSignals( false );
4310 mOffsetUnitWidget->blockSignals( true );
4311 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
4312 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
4313 mOffsetUnitWidget->blockSignals( false );
4314
4315 //anchor points
4316 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
4317 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
4318
4327
4328 updatePreviewImage();
4329}
4330
4335
4337{
4339 mImageSourceLineEdit->setMessageBar( context.messageBar() );
4340}
4341
4342void QgsAnimatedMarkerSymbolLayerWidget::imageSourceChanged( const QString &text )
4343{
4344 mLayer->setPath( text );
4345
4346 const double firstFrameTime = QgsApplication::imageCache()->nextFrameDelay( text );
4347 if ( firstFrameTime > 0 )
4348 {
4349 mFrameRateSpin->setClearValue( 1000 / firstFrameTime );
4350 }
4351 else
4352 {
4353 mFrameRateSpin->setClearValue( 10 );
4354 }
4355 updatePreviewImage();
4356 emit changed();
4357}
4358
4359void QgsAnimatedMarkerSymbolLayerWidget::updatePreviewImage()
4360{
4361 if ( mPreviewMovie )
4362 {
4363 mLabelImagePreview->setMovie( nullptr );
4364 mPreviewMovie->deleteLater();
4365 mPreviewMovie = nullptr;
4366 }
4367
4368 mPreviewMovie = new QMovie( mLayer->path(), QByteArray(), this );
4369 mPreviewMovie->setScaledSize( QSize( 150, 150 ) );
4370 mLabelImagePreview->setMovie( mPreviewMovie );
4371 mPreviewMovie->start();
4372}
4373
4374void QgsAnimatedMarkerSymbolLayerWidget::setWidth()
4375{
4376 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4377 double fixedAspectRatio = 0.0;
4378 mHeightSpinBox->blockSignals( true );
4379 if ( defaultAspectRatio <= 0.0 )
4380 {
4381 mHeightSpinBox->setValue( mWidthSpinBox->value() );
4382 }
4383 else if ( mLockAspectRatio->locked() )
4384 {
4385 mHeightSpinBox->setValue( mWidthSpinBox->value() * defaultAspectRatio );
4386 }
4387 else
4388 {
4389 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4390 }
4391 mHeightSpinBox->blockSignals( false );
4392 mLayer->setSize( mWidthSpinBox->value() );
4393 mLayer->setFixedAspectRatio( fixedAspectRatio );
4394 emit changed();
4395}
4396
4397void QgsAnimatedMarkerSymbolLayerWidget::setHeight()
4398{
4399 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4400 double fixedAspectRatio = 0.0;
4401 mWidthSpinBox->blockSignals( true );
4402 if ( defaultAspectRatio <= 0.0 )
4403 {
4404 mWidthSpinBox->setValue( mHeightSpinBox->value() );
4405 }
4406 else if ( mLockAspectRatio->locked() )
4407 {
4408 mWidthSpinBox->setValue( mHeightSpinBox->value() / defaultAspectRatio );
4409 }
4410 else
4411 {
4412 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4413 }
4414 mWidthSpinBox->blockSignals( false );
4415 mLayer->setSize( mWidthSpinBox->value() );
4416 mLayer->setFixedAspectRatio( fixedAspectRatio );
4417 emit changed();
4418}
4419
4420void QgsAnimatedMarkerSymbolLayerWidget::setLockAspectRatio( const bool locked )
4421{
4422 const double defaultAspectRatio = mLayer->defaultAspectRatio();
4423 if ( defaultAspectRatio <= 0.0 )
4424 {
4425 whileBlocking( mLockAspectRatio )->setLocked( true );
4426 }
4427 else if ( locked )
4428 {
4430 setWidth();
4431 }
4432 else
4433 {
4434 mLayer->setFixedAspectRatio( mHeightSpinBox->value() / mWidthSpinBox->value() );
4435 }
4436}
4437
4438void QgsAnimatedMarkerSymbolLayerWidget::setAngle()
4439{
4440 mLayer->setAngle( mRotationSpinBox->value() );
4441 emit changed();
4442}
4443
4444void QgsAnimatedMarkerSymbolLayerWidget::setOpacity( double value )
4445{
4446 mLayer->setOpacity( value );
4447 emit changed();
4448 updatePreviewImage();
4449}
4450
4451void QgsAnimatedMarkerSymbolLayerWidget::setOffset()
4452{
4453 mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4454 emit changed();
4455}
4456
4457void QgsAnimatedMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
4458{
4459 if ( mLayer )
4460 {
4461 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
4462 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4463 emit changed();
4464 }
4465}
4466
4467void QgsAnimatedMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
4468{
4469 if ( mLayer )
4470 {
4471 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4472 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4473 emit changed();
4474 }
4475}
4476
4477void QgsAnimatedMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
4478{
4479 if ( mLayer )
4480 {
4482 emit changed();
4483 }
4484}
4485
4486void QgsAnimatedMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
4487{
4488 if ( mLayer )
4489 {
4491 emit changed();
4492 }
4493}
4494
4496
4498 : QgsSymbolLayerWidget( parent, vl )
4499{
4500 mLayer = nullptr;
4501 setupUi( this );
4502
4503 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
4504 connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterFillSymbolLayerWidget::imageSourceChanged );
4505
4506 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed );
4507 connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
4508
4509 connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
4510 {
4511 if ( !mLayer )
4512 {
4513 return;
4514 }
4515 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
4516 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4517 emit changed();
4518 }
4519 );
4520 connect( mWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]( double d )
4521 {
4522 if ( !mLayer )
4523 {
4524 return;
4525 }
4526 mLayer->setWidth( d );
4527 emit changed();
4528 } );
4529
4530 connect( mHeightSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]( double d )
4531 {
4532 if ( !mLayer )
4533 {
4534 return;
4535 }
4536 mLayer->setHeight( d );
4537 emit changed();
4538 } );
4539
4544
4545 mSpinOffsetX->setClearValue( 0.0 );
4546 mSpinOffsetY->setClearValue( 0.0 );
4547 mRotationSpinBox->setClearValue( 0.0 );
4548
4549 connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterFillSymbolLayerWidget::setCoordinateMode );
4550 connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4551 connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4552 connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterFillSymbolLayerWidget::opacityChanged );
4553}
4554
4555
4557{
4558 if ( !layer )
4559 {
4560 return;
4561 }
4562
4563 if ( layer->layerType() != QLatin1String( "RasterFill" ) )
4564 {
4565 return;
4566 }
4567
4568 mLayer = dynamic_cast<QgsRasterFillSymbolLayer *>( layer );
4569 if ( !mLayer )
4570 {
4571 return;
4572 }
4573
4574 whileBlocking( mImageSourceLineEdit )->setSource( mLayer->imageFilePath() );
4575
4576 cboCoordinateMode->blockSignals( true );
4577 switch ( mLayer->coordinateMode() )
4578 {
4580 cboCoordinateMode->setCurrentIndex( 1 );
4581 break;
4583 default:
4584 cboCoordinateMode->setCurrentIndex( 0 );
4585 break;
4586 }
4587 cboCoordinateMode->blockSignals( false );
4588 whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
4589 whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
4590
4591 whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
4592 whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
4593 mOffsetUnitWidget->blockSignals( true );
4594 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
4595 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
4596 mOffsetUnitWidget->blockSignals( false );
4597
4598 whileBlocking( mWidthSpinBox )->setValue( mLayer->width() );
4599 mSizeUnitWidget->blockSignals( true );
4600 mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
4601 mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
4602 mSizeUnitWidget->blockSignals( false );
4603
4604 whileBlocking( mHeightSpinBox )->setValue( mLayer->height() );
4605
4606 updatePreviewImage();
4607
4614}
4615
4620
4621void QgsRasterFillSymbolLayerWidget::imageSourceChanged( const QString &text )
4622{
4623 mLayer->setImageFilePath( text );
4624 updatePreviewImage();
4625 emit changed();
4626}
4627
4628void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
4629{
4630 switch ( index )
4631 {
4632 case 0:
4633 //feature coordinate mode
4635 break;
4636 case 1:
4637 //viewport coordinate mode
4639 break;
4640 }
4641
4642 emit changed();
4643}
4644
4645void QgsRasterFillSymbolLayerWidget::opacityChanged( double value )
4646{
4647 if ( !mLayer )
4648 {
4649 return;
4650 }
4651
4652 mLayer->setOpacity( value );
4653 emit changed();
4654 updatePreviewImage();
4655}
4656
4657void QgsRasterFillSymbolLayerWidget::offsetChanged()
4658{
4659 mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4660 emit changed();
4661}
4662
4663void QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed()
4664{
4665 if ( !mLayer )
4666 {
4667 return;
4668 }
4669 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4670 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4671 emit changed();
4672}
4673
4674void QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
4675{
4676 if ( mLayer )
4677 {
4678 mLayer->setAngle( d );
4679 emit changed();
4680 }
4681}
4682
4683void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
4684{
4685 bool fitsInCache = false;
4686 const QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->imageFilePath(), QSize( 150, 150 ), true, 1.0, fitsInCache );
4687 if ( image.isNull() )
4688 {
4689 mLabelImagePreview->setPixmap( QPixmap() );
4690 return;
4691 }
4692
4693 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4694 previewImage.fill( Qt::transparent );
4695 const QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4696 QPainter p;
4697 p.begin( &previewImage );
4698 //draw a checkerboard background
4699 uchar pixDataRGB[] = { 150, 150, 150, 150,
4700 100, 100, 100, 150,
4701 100, 100, 100, 150,
4702 150, 150, 150, 150
4703 };
4704 const QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4705 const QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4706 QBrush checkerBrush;
4707 checkerBrush.setTexture( pix );
4708 p.fillRect( imageRect, checkerBrush );
4709
4710 if ( mLayer->opacity() < 1.0 )
4711 {
4712 p.setOpacity( mLayer->opacity() );
4713 }
4714
4715 p.drawImage( imageRect.left(), imageRect.top(), image );
4716 p.end();
4717 mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4718}
4719
4720//
4721// QgsRasterLineSymbolLayerWidget
4722//
4723
4724
4726 : QgsSymbolLayerWidget( parent, vl )
4727{
4728 mLayer = nullptr;
4729 setupUi( this );
4730
4731 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
4732
4737
4738 connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
4739 {
4740 if ( mLayer )
4741 {
4742 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
4743 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
4744 emit changed();
4745 }
4746 } );
4747
4748 connect( spinWidth, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]
4749 {
4750 if ( mLayer )
4751 {
4752 mLayer->setWidth( spinWidth->value() );
4753 emit changed();
4754 }
4755 } );
4756
4757 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
4758 {
4759 if ( mLayer )
4760 {
4761 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4762 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4763 emit changed();
4764 }
4765 } );
4766
4767
4768 spinOffset->setClearValue( 0.0 );
4769 connect( spinOffset, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double val )
4770 {
4771 if ( mLayer )
4772 {
4773 mLayer->setOffset( val );
4774 emit changed();
4775 }
4776 } );
4777
4778 connect( cboCapStyle, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]
4779 {
4780 if ( mLayer )
4781 {
4782 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
4783 emit changed();
4784 }
4785 } );
4786 connect( cboJoinStyle, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]
4787 {
4788 if ( mLayer )
4789 {
4790 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
4791 emit changed();
4792 }
4793 } );
4794
4795 connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterLineSymbolLayerWidget::imageSourceChanged );
4796 connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, [ = ]( double opacity )
4797 {
4798 if ( mLayer )
4799 {
4800 mLayer->setOpacity( opacity );
4801 updatePreviewImage();
4802 emit changed();
4803 }
4804 } );
4805}
4806
4808{
4809 if ( !layer )
4810 {
4811 return;
4812 }
4813
4814 if ( layer->layerType() != QLatin1String( "RasterLine" ) )
4815 {
4816 return;
4817 }
4818
4819 mLayer = dynamic_cast<QgsRasterLineSymbolLayer *>( layer );
4820 if ( !mLayer )
4821 {
4822 return;
4823 }
4824
4825 whileBlocking( mImageSourceLineEdit )->setSource( mLayer->path() );
4826 whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
4827
4828 whileBlocking( spinWidth )->setValue( mLayer->width() );
4829 whileBlocking( mPenWidthUnitWidget )->setUnit( mLayer->widthUnit() );
4830 whileBlocking( mPenWidthUnitWidget )->setMapUnitScale( mLayer->widthMapUnitScale() );
4831 whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
4832 whileBlocking( cboCapStyle )->setPenCapStyle( mLayer->penCapStyle() );
4833
4834 whileBlocking( mOffsetUnitWidget )->setUnit( mLayer->offsetUnit() );
4835 whileBlocking( mOffsetUnitWidget )->setMapUnitScale( mLayer->offsetMapUnitScale() );
4836 whileBlocking( spinOffset )->setValue( mLayer->offset() );
4837
4838 updatePreviewImage();
4839
4846}
4847
4852
4853void QgsRasterLineSymbolLayerWidget::imageSourceChanged( const QString &text )
4854{
4855 mLayer->setPath( text );
4856 updatePreviewImage();
4857 emit changed();
4858}
4859
4860void QgsRasterLineSymbolLayerWidget::updatePreviewImage()
4861{
4862 bool fitsInCache = false;
4863 const QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->path(), QSize( 150, 150 ), true, 1.0, fitsInCache );
4864 if ( image.isNull() )
4865 {
4866 mLabelImagePreview->setPixmap( QPixmap() );
4867 return;
4868 }
4869
4870 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4871 previewImage.fill( Qt::transparent );
4872 const QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4873 QPainter p;
4874 p.begin( &previewImage );
4875 //draw a checkerboard background
4876 uchar pixDataRGB[] = { 150, 150, 150, 150,
4877 100, 100, 100, 150,
4878 100, 100, 100, 150,
4879 150, 150, 150, 150
4880 };
4881 const QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4882 const QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4883 QBrush checkerBrush;
4884 checkerBrush.setTexture( pix );
4885 p.fillRect( imageRect, checkerBrush );
4886
4887 if ( mLayer->opacity() < 1.0 )
4888 {
4889 p.setOpacity( mLayer->opacity() );
4890 }
4891
4892 p.drawImage( imageRect.left(), imageRect.top(), image );
4893 p.end();
4894 mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4895}
4896
4897
4898
4899//
4900// QgsGeometryGeneratorSymbolLayerWidget
4901//
4902
4904 : QgsSymbolLayerWidget( parent, vl )
4905
4906{
4907 setupUi( this );
4908 modificationExpressionSelector->setMultiLine( true );
4909 modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer *>( vl ) );
4910 modificationExpressionSelector->registerExpressionContextGenerator( this );
4911 cbxGeometryType->addItem( QgsIconUtils::iconPolygon(), tr( "Polygon / MultiPolygon" ), static_cast< int >( Qgis::SymbolType::Fill ) );
4912 cbxGeometryType->addItem( QgsIconUtils::iconLine(), tr( "LineString / MultiLineString" ), static_cast< int >( Qgis::SymbolType::Line ) );
4913 cbxGeometryType->addItem( QgsIconUtils::iconPoint(), tr( "Point / MultiPoint" ), static_cast< int >( Qgis::SymbolType::Marker ) );
4914
4915 mUnitWidget->setUnits( {Qgis::RenderUnit::Millimeters,
4920 } );
4921 mUnitWidget->setShowMapScaleButton( false );
4922
4923 connect( modificationExpressionSelector, &QgsExpressionLineEdit::expressionChanged, this, &QgsGeometryGeneratorSymbolLayerWidget::updateExpression );
4924 connect( cbxGeometryType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType );
4925 connect( mUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
4926 {
4927 if ( !mBlockSignals )
4928 {
4929 mLayer->setUnits( mUnitWidget->unit() );
4930 emit symbolChanged();
4931 }
4932 } );
4933}
4934
4936{
4937 mBlockSignals++;
4938 mLayer = static_cast<QgsGeometryGeneratorSymbolLayer *>( l );
4939 modificationExpressionSelector->setExpression( mLayer->geometryExpression() );
4940 cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( static_cast< int >( mLayer->symbolType() ) ) );
4941 mUnitWidget->setUnit( mLayer->units() );
4942 mBlockSignals--;
4943}
4944
4949
4950void QgsGeometryGeneratorSymbolLayerWidget::updateExpression( const QString &string )
4951{
4952 mLayer->setGeometryExpression( string );
4953
4954 emit changed();
4955}
4956
4957void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
4958{
4959 // we try to keep the subsymbol, if we can!
4960 std::unique_ptr< QgsSymbol > subSymbol( mLayer->subSymbol()->clone() );
4961
4962 mLayer->setSymbolType( static_cast<Qgis::SymbolType>( cbxGeometryType->currentData().toInt() ) );
4963
4964 switch ( mLayer->symbolType() )
4965 {
4968 break;
4970 {
4971 if ( subSymbol->type() == Qgis::SymbolType::Fill )
4972 {
4973 // going from fill -> line type, so we can copy any LINE symbol layers across
4974 QgsSymbolLayerList layers;
4975 for ( int i = 0; i < subSymbol->symbolLayerCount(); ++i )
4976 {
4977 if ( dynamic_cast< const QgsLineSymbolLayer * >( subSymbol->symbolLayer( i ) ) )
4978 layers << subSymbol->symbolLayer( i )->clone();
4979 }
4980
4981 if ( !layers.empty() )
4982 mLayer->setSubSymbol( new QgsLineSymbol( layers ) );
4983 }
4984 break;
4985 }
4987 if ( subSymbol->type() == Qgis::SymbolType::Line )
4988 {
4989 // going from line -> fill type, so copy ALL line symbol layers across
4990 QgsSymbolLayerList layers;
4991 for ( int i = 0; i < subSymbol->symbolLayerCount(); ++i )
4992 layers << subSymbol->symbolLayer( i )->clone();
4993 mLayer->setSubSymbol( new QgsFillSymbol( layers ) );
4994 }
4995 break;
4996 }
4997
4998 emit symbolChanged();
4999}
5000
5001//
5002// QgsRandomMarkerFillSymbolLayerWidget
5003//
5004
5005
5007 QgsSymbolLayerWidget( parent, vl )
5008{
5009 setupUi( this );
5010
5011 mCountMethodComboBox->addItem( tr( "Absolute Count" ), static_cast< int >( Qgis::PointCountMethod::Absolute ) );
5012 mCountMethodComboBox->addItem( tr( "Density-based Count" ), static_cast< int >( Qgis::PointCountMethod::DensityBased ) );
5013
5014 mPointCountSpinBox->setShowClearButton( true );
5015 mPointCountSpinBox->setClearValue( 100 );
5016 mSeedSpinBox->setShowClearButton( true );
5017 mSeedSpinBox->setClearValue( 0 );
5018
5019 connect( mCountMethodComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged );
5020 connect( mPointCountSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::countChanged );
5021 connect( mDensityAreaSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged );
5022 connect( mSeedSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::seedChanged );
5023 connect( mClipPointsCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
5024 {
5025 if ( mLayer )
5026 {
5027 mLayer->setClipPoints( checked );
5028 emit changed();
5029 }
5030 } );
5031
5034
5035 connect( mDensityAreaUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRandomMarkerFillSymbolLayerWidget::densityAreaUnitChanged );
5036}
5037
5039{
5040 if ( !layer || layer->layerType() != QLatin1String( "RandomMarkerFill" ) )
5041 {
5042 return;
5043 }
5044
5045 mLayer = static_cast<QgsRandomMarkerFillSymbolLayer *>( layer );
5046 whileBlocking( mPointCountSpinBox )->setValue( mLayer->pointCount() );
5047 whileBlocking( mSeedSpinBox )->setValue( mLayer->seed() );
5048 whileBlocking( mClipPointsCheckBox )->setChecked( mLayer->clipPoints() );
5049
5050 bool showDensityBasedCountWidgets = false;
5051 switch ( mLayer->countMethod() )
5052 {
5054 showDensityBasedCountWidgets = true;
5055 break;
5057 break;
5058 }
5059 mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
5060 mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
5061 mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
5062 mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
5063
5064 whileBlocking( mCountMethodComboBox )->setCurrentIndex( mCountMethodComboBox->findData( static_cast< int >( mLayer->countMethod() ) ) );
5065 whileBlocking( mDensityAreaSpinBox )->setValue( mLayer->densityArea() );
5066 mDensityAreaUnitWidget->blockSignals( true );
5067 mDensityAreaUnitWidget->setUnit( mLayer->densityAreaUnit() );
5068 mDensityAreaUnitWidget->setMapUnitScale( mLayer->densityAreaUnitScale() );
5069 mDensityAreaUnitWidget->blockSignals( false );
5070
5075}
5076
5081
5082void QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged( int )
5083{
5084
5085 bool showDensityBasedCountWidgets = false;
5086 switch ( static_cast< Qgis::PointCountMethod >( mCountMethodComboBox->currentData().toInt() ) )
5087 {
5089 showDensityBasedCountWidgets = true;
5090 break;
5092 break;
5093 }
5094 mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
5095 mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
5096 mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
5097 mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
5098
5099 if ( mLayer )
5100 {
5101 mLayer->setCountMethod( static_cast< Qgis::PointCountMethod >( mCountMethodComboBox->currentData().toInt() ) );
5102 emit changed();
5103 }
5104}
5105
5106void QgsRandomMarkerFillSymbolLayerWidget::countChanged( int d )
5107{
5108 if ( mLayer )
5109 {
5110 mLayer->setPointCount( d );
5111 emit changed();
5112 }
5113}
5114
5115void QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged( double d )
5116{
5117 if ( mLayer )
5118 {
5119 mLayer->setDensityArea( d );
5120 emit changed();
5121 }
5122}
5123
5124void QgsRandomMarkerFillSymbolLayerWidget::densityAreaUnitChanged()
5125{
5126 if ( mLayer )
5127 {
5128 mLayer->setDensityAreaUnit( mDensityAreaUnitWidget->unit() );
5129 mLayer->setDensityAreaUnitScale( mDensityAreaUnitWidget->getMapUnitScale() );
5130 emit changed();
5131 }
5132}
5133
5134void QgsRandomMarkerFillSymbolLayerWidget::seedChanged( int d )
5135{
5136 if ( mLayer )
5137 {
5138 mLayer->setSeed( d );
5139 emit changed();
5140 }
5141}
5142
5143//
5144// QgsGradientLineSymbolLayerWidget
5145//
5146
5148 : QgsSymbolLayerWidget( parent, vl )
5149{
5150 mLayer = nullptr;
5151 setupUi( this );
5152
5153 btnColorRamp->setShowGradientOnly( true );
5154
5155 btnChangeColor->setAllowOpacity( true );
5156 btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
5157 btnChangeColor->setContext( QStringLiteral( "symbology" ) );
5158 btnChangeColor->setShowNoColor( true );
5159 btnChangeColor->setNoColorString( tr( "Transparent" ) );
5160 btnChangeColor2->setAllowOpacity( true );
5161 btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
5162 btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
5163 btnChangeColor2->setShowNoColor( true );
5164 btnChangeColor2->setNoColorString( tr( "Transparent" ) );
5165
5166 mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
5167 mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
5168
5169 connect( btnChangeColor, &QgsColorButton::colorChanged, this, [ = ]( const QColor & color )
5170 {
5171 if ( mLayer )
5172 {
5173 mLayer->setColor( color );
5174 emit changed();
5175 }
5176 } );
5177 connect( btnChangeColor2, &QgsColorButton::colorChanged, this, [ = ]( const QColor & color )
5178 {
5179 if ( mLayer )
5180 {
5181 mLayer->setColor2( color );
5182 emit changed();
5183 }
5184 } );
5185 connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, [ = ]
5186 {
5187 if ( btnColorRamp->isNull() )
5188 return;
5189
5190 if ( mLayer )
5191 {
5192 mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
5193 emit changed();
5194 }
5195 } );
5196
5197 connect( radioTwoColor, &QAbstractButton::toggled, this, [ = ]
5198 {
5199 if ( mLayer )
5200 {
5201 if ( radioTwoColor->isChecked() )
5202 {
5203 mLayer->setGradientColorType( Qgis::GradientColorSource::SimpleTwoColor );
5204 btnChangeColor->setEnabled( true );
5205 btnChangeColor2->setEnabled( true );
5206 btnColorRamp->setEnabled( false );
5207 }
5208 else
5209 {
5210 mLayer->setGradientColorType( Qgis::GradientColorSource::ColorRamp );
5211 btnColorRamp->setEnabled( true );
5212 btnChangeColor->setEnabled( false );
5213 btnChangeColor2->setEnabled( false );
5214 }
5215 emit changed();
5216 }
5217 } );
5218
5223
5224 connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
5225 {
5226 if ( mLayer )
5227 {
5228 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
5229 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
5230 emit changed();
5231 }
5232 } );
5233
5234 connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]
5235 {
5236 if ( mLayer )
5237 {
5238 mLayer->setWidth( spinWidth->value() );
5239 emit changed();
5240 }
5241 } );
5242
5243 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
5244 {
5245 if ( mLayer )
5246 {
5247 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
5248 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
5249 emit changed();
5250 }
5251 } );
5252
5253 spinOffset->setClearValue( 0.0 );
5254 connect( spinOffset, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double val )
5255 {
5256 if ( mLayer )
5257 {
5258 mLayer->setOffset( val );
5259 emit changed();
5260 }
5261 } );
5262
5263 connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]
5264 {
5265 if ( mLayer )
5266 {
5267 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
5268 emit changed();
5269 }
5270 } );
5271 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]
5272 {
5273 if ( mLayer )
5274 {
5275 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
5276 emit changed();
5277 }
5278 } );
5279}
5280
5282{
5283 if ( !layer )
5284 {
5285 return;
5286 }
5287
5288 if ( layer->layerType() != QLatin1String( "Lineburst" ) )
5289 {
5290 return;
5291 }
5292
5293 mLayer = dynamic_cast<QgsLineburstSymbolLayer *>( layer );
5294 if ( !mLayer )
5295 {
5296 return;
5297 }
5298
5299 btnChangeColor->blockSignals( true );
5300 btnChangeColor->setColor( mLayer->color() );
5301 btnChangeColor->blockSignals( false );
5302 btnChangeColor2->blockSignals( true );
5303 btnChangeColor2->setColor( mLayer->color2() );
5304 btnChangeColor2->blockSignals( false );
5305
5307 {
5308 radioTwoColor->setChecked( true );
5309 btnColorRamp->setEnabled( false );
5310 }
5311 else
5312 {
5313 radioColorRamp->setChecked( true );
5314 btnChangeColor->setEnabled( false );
5315 btnChangeColor2->setEnabled( false );
5316 }
5317
5318 // set source color ramp
5319 if ( mLayer->colorRamp() )
5320 {
5321 btnColorRamp->blockSignals( true );
5322 btnColorRamp->setColorRamp( mLayer->colorRamp() );
5323 btnColorRamp->blockSignals( false );
5324 }
5325
5326 whileBlocking( spinWidth )->setValue( mLayer->width() );
5327 whileBlocking( mPenWidthUnitWidget )->setUnit( mLayer->widthUnit() );
5328 whileBlocking( mPenWidthUnitWidget )->setMapUnitScale( mLayer->widthMapUnitScale() );
5329
5330 whileBlocking( mOffsetUnitWidget )->setUnit( mLayer->offsetUnit() );
5331 whileBlocking( mOffsetUnitWidget )->setMapUnitScale( mLayer->offsetMapUnitScale() );
5332 whileBlocking( spinOffset )->setValue( mLayer->offset() );
5333
5334 whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
5335 whileBlocking( cboCapStyle )->setPenCapStyle( mLayer->penCapStyle() );
5336
5343}
5344
5349
5350//
5351// QgsFilledLineSymbolLayerWidget
5352//
5353
5355 : QgsSymbolLayerWidget( parent, vl )
5356{
5357 mLayer = nullptr;
5358 setupUi( this );
5359
5364
5365 connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
5366 {
5367 if ( mLayer )
5368 {
5369 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
5370 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
5371 emit changed();
5372 }
5373 } );
5374
5375 connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]
5376 {
5377 if ( mLayer )
5378 {
5379 mLayer->setWidth( spinWidth->value() );
5380 emit changed();
5381 }
5382 } );
5383
5384 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
5385 {
5386 if ( mLayer )
5387 {
5388 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
5389 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
5390 emit changed();
5391 }
5392 } );
5393
5394 spinOffset->setClearValue( 0.0 );
5395 connect( spinOffset, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double val )
5396 {
5397 if ( mLayer )
5398 {
5399 mLayer->setOffset( val );
5400 emit changed();
5401 }
5402 } );
5403
5404 connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]
5405 {
5406 if ( mLayer )
5407 {
5408 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
5409 emit changed();
5410 }
5411 } );
5412 connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]
5413 {
5414 if ( mLayer )
5415 {
5416 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
5417 emit changed();
5418 }
5419 } );
5420}
5421
5423
5425{
5426 if ( !layer )
5427 {
5428 return;
5429 }
5430
5431 if ( layer->layerType() != QLatin1String( "FilledLine" ) )
5432 {
5433 return;
5434 }
5435
5436 mLayer = dynamic_cast<QgsFilledLineSymbolLayer *>( layer );
5437 if ( !mLayer )
5438 {
5439 return;
5440 }
5441
5442 whileBlocking( spinWidth )->setValue( mLayer->width() );
5443 whileBlocking( mPenWidthUnitWidget )->setUnit( mLayer->widthUnit() );
5444 whileBlocking( mPenWidthUnitWidget )->setMapUnitScale( mLayer->widthMapUnitScale() );
5445
5446 whileBlocking( mOffsetUnitWidget )->setUnit( mLayer->offsetUnit() );
5447 whileBlocking( mOffsetUnitWidget )->setMapUnitScale( mLayer->offsetMapUnitScale() );
5448 whileBlocking( spinOffset )->setValue( mLayer->offset() );
5449
5450 whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
5451 whileBlocking( cboCapStyle )->setPenCapStyle( mLayer->penCapStyle() );
5452
5457}
5458
5463
5464//
5465// QgsLinearReferencingSymbolLayerWidget
5466//
5467
5469 : QgsSymbolLayerWidget( parent, vl )
5470{
5471 mLayer = nullptr;
5472
5473 setupUi( this );
5474
5475 mComboPlacement->addItem( tr( "Interval (Cartesian 2D Distances)" ), QVariant::fromValue( Qgis::LinearReferencingPlacement::IntervalCartesian2D ) );
5476 mComboPlacement->addItem( tr( "Interval (Z Values)" ), QVariant::fromValue( Qgis::LinearReferencingPlacement::IntervalZ ) );
5477 mComboPlacement->addItem( tr( "Interval (M Values)" ), QVariant::fromValue( Qgis::LinearReferencingPlacement::IntervalM ) );
5478 mComboPlacement->addItem( tr( "On Every Vertex" ), QVariant::fromValue( Qgis::LinearReferencingPlacement::Vertex ) );
5479
5480 mComboQuantity->addItem( tr( "Cartesian 2D Distance" ), QVariant::fromValue( Qgis::LinearReferencingLabelSource::CartesianDistance2D ) );
5481 mComboQuantity->addItem( tr( "Z Values" ), QVariant::fromValue( Qgis::LinearReferencingLabelSource::Z ) );
5482 mComboQuantity->addItem( tr( "M Values" ), QVariant::fromValue( Qgis::LinearReferencingLabelSource::M ) );
5483
5484 mSpinSkipMultiples->setClearValue( 0, tr( "Not set" ) );
5485 mSpinLabelOffsetX->setClearValue( 0 );
5486 mSpinLabelOffsetY->setClearValue( 0 );
5487 mSpinAverageAngleLength->setClearValue( 4.0 );
5492
5493 connect( mComboQuantity, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]
5494 {
5495 if ( mLayer && !mBlockChangesSignal )
5496 {
5497 mLayer->setLabelSource( mComboQuantity->currentData().value< Qgis::LinearReferencingLabelSource >() );
5498 emit changed();
5499 }
5500 } );
5501 connect( mTextFormatButton, &QgsFontButton::changed, this, [ = ]
5502 {
5503 if ( mLayer && !mBlockChangesSignal )
5504 {
5505 mLayer->setTextFormat( mTextFormatButton->textFormat() );
5506 emit changed();
5507 }
5508 } );
5509 connect( spinInterval, qOverload< double >( &QgsDoubleSpinBox::valueChanged ), this, [ = ]
5510 {
5511 if ( mLayer && !mBlockChangesSignal )
5512 {
5513 mLayer->setInterval( spinInterval->value() );
5514 emit changed();
5515 }
5516 } );
5517 connect( mSpinSkipMultiples, qOverload< double >( &QgsDoubleSpinBox::valueChanged ), this, [ = ]
5518 {
5519 if ( mLayer && !mBlockChangesSignal )
5520 {
5521 mLayer->setSkipMultiplesOf( mSpinSkipMultiples->value() );
5522 emit changed();
5523 }
5524 } );
5525 connect( mCheckRotate, &QCheckBox::toggled, this, [ = ]( bool checked )
5526 {
5527 if ( mLayer && !mBlockChangesSignal )
5528 {
5529 mLayer->setRotateLabels( checked );
5530 emit changed();
5531 }
5532 mSpinAverageAngleLength->setEnabled( checked );
5533 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
5534 } );
5535 connect( mCheckShowMarker, &QCheckBox::toggled, this, [ = ]( bool checked )
5536 {
5537 if ( mLayer && !mBlockChangesSignal )
5538 {
5539 mLayer->setShowMarker( checked );
5540 emit symbolChanged();
5541 }
5542 } );
5543
5544 connect( mSpinLabelOffsetX, qOverload< double >( &QgsDoubleSpinBox::valueChanged ), this, [ = ]
5545 {
5546 if ( mLayer && !mBlockChangesSignal )
5547 {
5548 mLayer->setLabelOffset( QPointF( mSpinLabelOffsetX->value(), mSpinLabelOffsetY->value() ) );
5549 emit changed();
5550 }
5551 } );
5552 connect( mSpinLabelOffsetY, qOverload< double >( &QgsDoubleSpinBox::valueChanged ), this, [ = ]
5553 {
5554 if ( mLayer && !mBlockChangesSignal )
5555 {
5556 mLayer->setLabelOffset( QPointF( mSpinLabelOffsetX->value(), mSpinLabelOffsetY->value() ) );
5557 emit changed();
5558 }
5559 } );
5560 connect( mLabelOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
5561 {
5562 if ( mLayer && !mBlockChangesSignal )
5563 {
5564 mLayer->setLabelOffsetUnit( mLabelOffsetUnitWidget->unit() );
5565 mLayer->setLabelOffsetMapUnitScale( mLabelOffsetUnitWidget->getMapUnitScale() );
5566 emit changed();
5567 }
5568 } );
5569
5570 connect( mComboPlacement, qOverload< int>( &QComboBox::currentIndexChanged ), this, [ = ]
5571 {
5572 if ( mLayer && !mBlockChangesSignal )
5573 {
5574 const Qgis::LinearReferencingPlacement placement = mComboPlacement->currentData().value< Qgis::LinearReferencingPlacement >();
5575 mLayer->setPlacement( placement );
5576 switch ( placement )
5577 {
5581 mIntervalWidget->show();
5582 break;
5584 mIntervalWidget->hide();
5585 break;
5586 }
5587 emit changed();
5588 }
5589 } );
5590
5591 connect( mSpinAverageAngleLength, qOverload< double >( &QgsDoubleSpinBox::valueChanged ), this, [ = ]
5592 {
5593 if ( mLayer && !mBlockChangesSignal )
5594 {
5595 mLayer->setAverageAngleLength( mSpinAverageAngleLength->value() );
5596 emit changed();
5597 }
5598 } );
5599 connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, [ = ]
5600 {
5601 if ( mLayer && !mBlockChangesSignal )
5602 {
5603 mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
5604 mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
5605 emit changed();
5606 }
5607 } );
5608
5609 connect( mNumberFormatPushButton, &QPushButton::clicked, this, &QgsLinearReferencingSymbolLayerWidget::changeNumberFormat );
5610
5611 mTextFormatButton->registerExpressionContextGenerator( this );
5612}
5613
5615
5616
5618{
5619 if ( !layer || layer->layerType() != QLatin1String( "LinearReferencing" ) )
5620 return;
5621
5622 // layer type is correct, we can do the cast
5623 mLayer = qgis::down_cast<QgsLinearReferencingSymbolLayer *>( layer );
5624
5625 mBlockChangesSignal = true;
5626
5627 mComboPlacement->setCurrentIndex( mComboPlacement->findData( QVariant::fromValue( mLayer->placement() ) ) );
5628 switch ( mLayer->placement() )
5629 {
5633 mIntervalWidget->show();
5634 break;
5636 mIntervalWidget->hide();
5637 break;
5638 }
5639
5640 mComboQuantity->setCurrentIndex( mComboQuantity->findData( QVariant::fromValue( mLayer->labelSource() ) ) );
5641
5642 mTextFormatButton->setTextFormat( mLayer->textFormat() );
5643 spinInterval->setValue( mLayer->interval() );
5644 mSpinSkipMultiples->setValue( mLayer->skipMultiplesOf() );
5645 mCheckRotate->setChecked( mLayer->rotateLabels() );
5646 mCheckShowMarker->setChecked( mLayer->showMarker() );
5647 mSpinLabelOffsetX->setValue( mLayer->labelOffset().x() );
5648 mSpinLabelOffsetY->setValue( mLayer->labelOffset().y() );
5649 mLabelOffsetUnitWidget->setUnit( mLayer->labelOffsetUnit() );
5650 mLabelOffsetUnitWidget->setMapUnitScale( mLayer->labelOffsetMapUnitScale() );
5651
5652 mAverageAngleUnit->setUnit( mLayer->averageAngleUnit() );
5653 mAverageAngleUnit->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
5654 mSpinAverageAngleLength->setValue( mLayer->averageAngleLength() );
5655
5656 mSpinAverageAngleLength->setEnabled( mCheckRotate->isChecked() );
5657 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
5658
5663
5664 mBlockChangesSignal = false;
5665}
5666
5671
5673{
5675 mTextFormatButton->setMapCanvas( context.mapCanvas() );
5676 mTextFormatButton->setMessageBar( context.messageBar() );
5677}
5678
5679void QgsLinearReferencingSymbolLayerWidget::changeNumberFormat()
5680{
5682 if ( panel && panel->dockMode() )
5683 {
5685 widget->setPanelTitle( tr( "Number Format" ) );
5686 widget->setFormat( mLayer->numericFormat() );
5687 widget->registerExpressionContextGenerator( this );
5688 connect( widget, &QgsNumericFormatSelectorWidget::changed, this, [ = ]
5689 {
5690 if ( !mBlockChangesSignal )
5691 {
5692 mLayer->setNumericFormat( widget->format() );
5693 emit changed();
5694 }
5695 } );
5696 panel->openPanel( widget );
5697 }
5698 else
5699 {
5700 QgsNumericFormatSelectorDialog dialog( this );
5701 dialog.setFormat( mLayer->numericFormat() );
5702 dialog.registerExpressionContextGenerator( this );
5703 if ( dialog.exec() )
5704 {
5705 mLayer->setNumericFormat( dialog.format() );
5706 emit changed();
5707 }
5708 }
5709}
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:3016
@ 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:3030
@ 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:3004
@ 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:2847
LinearReferencingPlacement
Defines how/where the labels should be placed in a linear referencing symbol layer.
Definition qgis.h:2916
@ 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:2930
@ 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:2974
@ Feature
Relative to feature/shape being rendered.
@ Viewport
Relative to the whole viewport/output device.
QFlags< MarkerLinePlacement > MarkerLinePlacements
Definition qgis.h:2907
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition qgis.h:5568
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.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
HorizontalAnchorPoint
Symbol horizontal anchor points.
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's offset.
void setAngle(double angle)
Sets the rotation angle for the marker.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
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.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
Qgis::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
Qgis::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's size.
VerticalAnchorPoint
Symbol vertical anchor points.
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:5761
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition qgssymbol.h:30
Single variable definition for use within a QgsExpressionContextScope.