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