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