47#include <QAbstractButton>
50#include <QButtonGroup>
51#include <QColorDialog>
55#include <QInputDialog>
60#include <QRegularExpression>
61#include <QStandardItemModel>
62#include <QSvgRenderer>
64#include "moc_qgssymbollayerwidget.cpp"
68 if (
auto *lExpressionContext = mContext.expressionContext() )
69 return *lExpressionContext;
80 expContext << symbolScope;
93 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
102 QStringList highlights;
108 << QStringLiteral(
"symbol_layer_count" ) << QStringLiteral(
"symbol_layer_index" ) << QStringLiteral(
"symbol_frame" );
111 if ( expContext.
hasVariable( QStringLiteral(
"zoom_level" ) ) )
113 highlights << QStringLiteral(
"zoom_level" );
115 if ( expContext.
hasVariable( QStringLiteral(
"vector_tile_zoom" ) ) )
117 highlights << QStringLiteral(
"vector_tile_zoom" );
128 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
131 unitWidget->setMapCanvas( mContext.mapCanvas() );
149void QgsSymbolLayerWidget::createAuxiliaryField()
159 if ( !mVectorLayer->auxiliaryLayer() )
162 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
167 if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
169 QgsNewAuxiliaryFieldDialog dlg( def, mVectorLayer,
true,
this );
170 if ( dlg.exec() == QDialog::Accepted )
171 def = dlg.propertyDefinition();
175 if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
181 property.setActive(
true );
203 connect( mCustomCheckBox, &QCheckBox::stateChanged,
this, &QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged );
204 connect( mChangePatternButton, &QPushButton::clicked,
this, &QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked );
208 connect( mDrawInsideCheckBox, &QCheckBox::stateChanged,
this, &QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
210 connect( mCheckAlignDash, &QCheckBox::toggled,
this, [
this] {
211 mCheckDashCorners->setEnabled( mCheckAlignDash->isChecked() );
212 if ( !mCheckAlignDash->isChecked() )
213 mCheckDashCorners->setChecked(
false );
217 mLayer->setAlignDashPattern( mCheckAlignDash->isChecked() );
221 connect( mCheckDashCorners, &QCheckBox::toggled,
this, [
this] {
224 mLayer->setTweakDashPatternOnCorners( mCheckDashCorners->isChecked() );
236 btnChangeColor->setAllowOpacity(
true );
237 btnChangeColor->setColorDialogTitle( tr(
"Select Line Color" ) );
238 btnChangeColor->setContext( QStringLiteral(
"symbology" ) );
240 mColorDDBtn->registerLinkedWidget( btnChangeColor );
245 connect( mRingFilterComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
253 spinOffset->setClearValue( 0.0 );
254 spinPatternOffset->setClearValue( 0.0 );
256 mTrimStartDistanceSpin->setClearValue( 0.0 );
257 mTrimDistanceEndSpin->setClearValue( 0.0 );
260 mAssistantPreviewSymbol = std::make_shared<QgsLineSymbol>();
263 mPenWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
265 connect( spinWidth,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineSymbolLayerWidget::penWidthChanged );
267 connect( cboPenStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
268 connect( spinOffset,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineSymbolLayerWidget::offsetChanged );
269 connect( cboCapStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
270 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
271 connect( spinPatternOffset,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineSymbolLayerWidget::patternOffsetChanged );
273 connect( mTrimStartDistanceSpin,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
277 mLayer->setTrimDistanceStart( value );
284 mLayer->setTrimDistanceStartUnit( mTrimDistanceStartUnitWidget->unit() );
285 mLayer->setTrimDistanceStartMapUnitScale( mTrimDistanceStartUnitWidget->getMapUnitScale() );
288 connect( mTrimDistanceEndSpin,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
292 mLayer->setTrimDistanceEnd( value );
299 mLayer->setTrimDistanceEndUnit( mTrimDistanceEndUnitWidget->unit() );
300 mLayer->setTrimDistanceEndMapUnitScale( mTrimDistanceEndUnitWidget->getMapUnitScale() );
312void QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol()
314 for (
int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
316 mAssistantPreviewSymbol->deleteSymbolLayer( i );
318 mAssistantPreviewSymbol->appendSymbolLayer(
mLayer->clone() );
321 mAssistantPreviewSymbol->setDataDefinedWidth( ddWidth );
327 if ( !layer || layer->
layerType() != QLatin1String(
"SimpleLine" ) )
334 mPenWidthUnitWidget->blockSignals(
true );
335 mPenWidthUnitWidget->setUnit(
mLayer->widthUnit() );
337 mPenWidthUnitWidget->blockSignals(
false );
338 mOffsetUnitWidget->blockSignals(
true );
339 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
340 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
341 mOffsetUnitWidget->blockSignals(
false );
342 mDashPatternUnitWidget->blockSignals(
true );
343 mDashPatternUnitWidget->setUnit(
mLayer->customDashPatternUnit() );
344 mDashPatternUnitWidget->setMapUnitScale(
mLayer->customDashPatternMapUnitScale() );
345 mDashPatternUnitWidget->blockSignals(
false );
348 whileBlocking( mPatternOffsetUnitWidget )->setMapUnitScale(
mLayer->dashPatternOffsetMapUnitScale() );
350 whileBlocking( mTrimDistanceStartUnitWidget )->setMapUnitScale(
mLayer->trimDistanceStartMapUnitScale() );
352 whileBlocking( mTrimDistanceEndUnitWidget )->setMapUnitScale(
mLayer->trimDistanceEndMapUnitScale() );
355 spinWidth->blockSignals(
true );
356 spinWidth->setValue(
mLayer->width() );
357 spinWidth->blockSignals(
false );
358 btnChangeColor->blockSignals(
true );
359 btnChangeColor->setColor(
mLayer->color() );
360 btnChangeColor->blockSignals(
false );
361 spinOffset->blockSignals(
true );
362 spinOffset->setValue(
mLayer->offset() );
363 spinOffset->blockSignals(
false );
364 cboPenStyle->blockSignals(
true );
365 cboJoinStyle->blockSignals(
true );
366 cboCapStyle->blockSignals(
true );
367 cboPenStyle->setPenStyle(
mLayer->penStyle() );
368 cboJoinStyle->setPenJoinStyle(
mLayer->penJoinStyle() );
369 cboCapStyle->setPenCapStyle(
mLayer->penCapStyle() );
370 cboPenStyle->blockSignals(
false );
371 cboJoinStyle->blockSignals(
false );
372 cboCapStyle->blockSignals(
false );
378 const bool useCustomDashPattern =
mLayer->useCustomDashPattern();
379 mChangePatternButton->setEnabled( useCustomDashPattern );
380 label_3->setEnabled( !useCustomDashPattern );
381 cboPenStyle->setEnabled( !useCustomDashPattern );
382 mCustomCheckBox->blockSignals(
true );
383 mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
384 mCustomCheckBox->blockSignals(
false );
387 const QSize size = mChangePatternButton->minimumSizeHint();
389 mChangePatternButton->setMinimumSize( QSize( size.width(), std::max( size.height(), fontHeight ) ) );
392 const bool drawInsidePolygon =
mLayer->drawInsidePolygon();
393 whileBlocking( mDrawInsideCheckBox )->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
395 whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData(
mLayer->ringFilter() ) );
398 mCheckDashCorners->setEnabled(
mLayer->alignDashPattern() );
414 updateAssistantSymbol();
426 switch (
context.symbolType() )
431 mDrawInsideCheckBox->hide();
432 mRingFilterComboBox->hide();
442void QgsSimpleLineSymbolLayerWidget::penWidthChanged()
449void QgsSimpleLineSymbolLayerWidget::colorChanged(
const QColor &color )
451 mLayer->setColor( color );
455void QgsSimpleLineSymbolLayerWidget::penStyleChanged()
457 mLayer->setPenStyle( cboPenStyle->penStyle() );
458 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
459 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
464void QgsSimpleLineSymbolLayerWidget::offsetChanged()
466 mLayer->setOffset( spinOffset->value() );
471void QgsSimpleLineSymbolLayerWidget::patternOffsetChanged()
473 mLayer->setDashPatternOffset( spinPatternOffset->value() );
478void QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged(
int state )
480 const bool checked = ( state == Qt::Checked );
481 mChangePatternButton->setEnabled( checked );
482 label_3->setEnabled( !checked );
483 cboPenStyle->setEnabled( !checked );
485 mLayer->setUseCustomDashPattern( checked );
489void QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked()
494 QgsDashSpaceWidget *widget =
new QgsDashSpaceWidget(
mLayer->customDashVector(), panel );
496 widget->
setUnit( mDashPatternUnitWidget->unit() );
506 QgsDashSpaceDialog d(
mLayer->customDashVector() );
507 d.setUnit( mDashPatternUnitWidget->unit() );
508 if ( d.exec() == QDialog::Accepted )
510 mLayer->setCustomDashVector( d.dashDotVector() );
516void QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed()
520 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
521 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
527void QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed()
531 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
532 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
537void QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed()
541 mLayer->setCustomDashPatternUnit( mDashPatternUnitWidget->unit() );
542 mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
548void QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged(
int state )
550 const bool checked = ( state == Qt::Checked );
551 mLayer->setDrawInsidePolygon( checked );
555void QgsSimpleLineSymbolLayerWidget::patternOffsetUnitChanged()
559 mLayer->setDashPatternOffsetUnit( mPatternOffsetUnitWidget->unit() );
560 mLayer->setDashPatternOffsetMapUnitScale( mPatternOffsetUnitWidget->getMapUnitScale() );
572 std::unique_ptr<QgsSimpleLineSymbolLayer> layerCopy(
mLayer->clone() );
577 const QColor color = qApp->palette().color( QPalette::WindowText );
578 layerCopy->setColor( color );
580 layerCopy->setOffset( 0 );
581 layerCopy->setUseCustomDashPattern(
true );
583 QSize currentIconSize;
586 currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 6 );
588 currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 12 );
591 if ( !currentIconSize.isValid() || currentIconSize.width() <= 0 || currentIconSize.height() <= 0 )
597 const std::unique_ptr<QgsLineSymbol> previewSymbol = std::make_unique<QgsLineSymbol>(
QgsSymbolLayerList() << layerCopy.release() );
599 mChangePatternButton->setIconSize( currentIconSize );
600 mChangePatternButton->setIcon( icon );
604 const int width =
static_cast<int>(
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 23 );
605 const int height =
static_cast<int>( width / 1.61803398875 );
609 QBuffer buffer( &data );
610 pm.save( &buffer,
"PNG", 100 );
611 mChangePatternButton->setToolTip( QStringLiteral(
"<img src='data:image/png;base64, %3' width=\"%4\">" ).arg( QString( data.toBase64() ) ).arg( width ) );
616 QgsSymbolLayerWidget::resizeEvent( event );
643 connect( mStrokeStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
644 connect( mStrokeWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
645 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
646 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
651 btnChangeColorFill->setAllowOpacity(
true );
652 btnChangeColorFill->setColorDialogTitle( tr(
"Select Fill Color" ) );
653 btnChangeColorFill->setContext( QStringLiteral(
"symbology" ) );
654 btnChangeColorFill->setShowNoColor(
true );
655 btnChangeColorFill->setNoColorString( tr(
"Transparent Fill" ) );
656 btnChangeColorStroke->setAllowOpacity(
true );
657 btnChangeColorStroke->setColorDialogTitle( tr(
"Select Stroke Color" ) );
658 btnChangeColorStroke->setContext( QStringLiteral(
"symbology" ) );
659 btnChangeColorStroke->setShowNoColor(
true );
660 btnChangeColorStroke->setNoColorString( tr(
"Transparent Stroke" ) );
662 mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
663 mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
665 spinOffsetX->setClearValue( 0.0 );
666 spinOffsetY->setClearValue( 0.0 );
667 spinAngle->setClearValue( 0.0 );
670 mAssistantPreviewSymbol = std::make_shared<QgsMarkerSymbol>();
673 mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
675 int size = lstNames->iconSize().width();
677 size = std::max( 30,
static_cast<int>( std::round(
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 3 ) ) );
679 lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
680 lstNames->setIconSize( QSize( size, size ) );
682 const double markerSize = size * 0.8;
688 lyr->
setColor( QColor( 200, 200, 200 ) );
691 QListWidgetItem *item =
new QListWidgetItem( icon, QString(), lstNames );
692 item->setData( Qt::UserRole,
static_cast<int>( shape ) );
697 lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
699 connect( lstNames, &QListWidget::currentRowChanged,
this, &QgsSimpleMarkerSymbolLayerWidget::setShape );
702 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged );
703 connect( cboCapStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::penCapStyleChanged );
704 connect( spinSize,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::setSize );
705 connect( spinAngle,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::setAngle );
706 connect( spinOffsetX,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
707 connect( spinOffsetY,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
715 if ( layer->
layerType() != QLatin1String(
"SimpleMarker" ) )
723 for (
int i = 0; i < lstNames->count(); ++i )
725 if (
static_cast<Qgis::MarkerShape>( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
727 lstNames->setCurrentRow( i );
731 btnChangeColorStroke->blockSignals(
true );
732 btnChangeColorStroke->setColor(
mLayer->strokeColor() );
733 btnChangeColorStroke->blockSignals(
false );
734 btnChangeColorFill->blockSignals(
true );
735 btnChangeColorFill->setColor(
mLayer->fillColor() );
737 btnChangeColorFill->blockSignals(
false );
738 spinSize->blockSignals(
true );
739 spinSize->setValue(
mLayer->size() );
740 spinSize->blockSignals(
false );
741 spinAngle->blockSignals(
true );
742 spinAngle->setValue(
mLayer->angle() );
743 spinAngle->blockSignals(
false );
744 mStrokeStyleComboBox->blockSignals(
true );
745 mStrokeStyleComboBox->setPenStyle(
mLayer->strokeStyle() );
746 mStrokeStyleComboBox->blockSignals(
false );
747 mStrokeWidthSpinBox->blockSignals(
true );
748 mStrokeWidthSpinBox->setValue(
mLayer->strokeWidth() );
749 mStrokeWidthSpinBox->blockSignals(
false );
750 cboJoinStyle->blockSignals(
true );
751 cboJoinStyle->setPenJoinStyle(
mLayer->penJoinStyle() );
752 cboJoinStyle->blockSignals(
false );
753 cboCapStyle->blockSignals(
true );
754 cboCapStyle->setPenCapStyle(
mLayer->penCapStyle() );
755 cboCapStyle->blockSignals(
false );
758 spinOffsetX->blockSignals(
true );
759 spinOffsetX->setValue(
mLayer->offset().x() );
760 spinOffsetX->blockSignals(
false );
761 spinOffsetY->blockSignals(
true );
762 spinOffsetY->setValue(
mLayer->offset().y() );
763 spinOffsetY->blockSignals(
false );
765 mSizeUnitWidget->blockSignals(
true );
766 mSizeUnitWidget->setUnit(
mLayer->sizeUnit() );
767 mSizeUnitWidget->setMapUnitScale(
mLayer->sizeMapUnitScale() );
768 mSizeUnitWidget->blockSignals(
false );
769 mOffsetUnitWidget->blockSignals(
true );
770 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
771 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
772 mOffsetUnitWidget->blockSignals(
false );
773 mStrokeWidthUnitWidget->blockSignals(
true );
774 mStrokeWidthUnitWidget->setUnit(
mLayer->strokeWidthUnit() );
775 mStrokeWidthUnitWidget->setMapUnitScale(
mLayer->strokeWidthMapUnitScale() );
776 mStrokeWidthUnitWidget->blockSignals(
false );
779 mHorizontalAnchorComboBox->blockSignals(
true );
780 mVerticalAnchorComboBox->blockSignals(
true );
781 mHorizontalAnchorComboBox->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->horizontalAnchorPoint() ) ) );
782 mVerticalAnchorComboBox->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->verticalAnchorPoint() ) ) );
783 mHorizontalAnchorComboBox->blockSignals(
false );
784 mVerticalAnchorComboBox->blockSignals(
false );
799 updateAssistantSymbol();
807void QgsSimpleMarkerSymbolLayerWidget::setShape()
816 mLayer->setStrokeColor( color );
822 mLayer->setColor( color );
826void QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged()
832void QgsSimpleMarkerSymbolLayerWidget::penCapStyleChanged()
834 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
838void QgsSimpleMarkerSymbolLayerWidget::setSize()
840 mLayer->setSize( spinSize->value() );
844void QgsSimpleMarkerSymbolLayerWidget::setAngle()
846 mLayer->setAngle( spinAngle->value() );
850void QgsSimpleMarkerSymbolLayerWidget::setOffset()
852 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
856void QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged(
int index )
862 mLayer->setStrokeStyle( mStrokeStyleComboBox->penStyle() );
867void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
871 mLayer->setStrokeWidth( d );
876void QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
880 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
881 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
886void QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
890 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
891 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
896void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
900 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
901 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
906void QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
915void QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
924void QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol()
926 for (
int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
928 mAssistantPreviewSymbol->deleteSymbolLayer( i );
930 mAssistantPreviewSymbol->appendSymbolLayer(
mLayer->clone() );
933 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
950 btnChangeColor->setAllowOpacity(
true );
951 btnChangeColor->setColorDialogTitle( tr(
"Select Fill Color" ) );
952 btnChangeColor->setContext( QStringLiteral(
"symbology" ) );
953 btnChangeColor->setShowNoColor(
true );
954 btnChangeColor->setNoColorString( tr(
"Transparent Fill" ) );
955 btnChangeStrokeColor->setAllowOpacity(
true );
956 btnChangeStrokeColor->setColorDialogTitle( tr(
"Select Stroke Color" ) );
957 btnChangeStrokeColor->setContext( QStringLiteral(
"symbology" ) );
958 btnChangeStrokeColor->setShowNoColor(
true );
959 btnChangeStrokeColor->setNoColorString( tr(
"Transparent Stroke" ) );
961 spinOffsetX->setClearValue( 0.0 );
962 spinOffsetY->setClearValue( 0.0 );
965 connect( cboFillStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleFillSymbolLayerWidget::setBrushStyle );
967 connect( spinStrokeWidth,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleFillSymbolLayerWidget::strokeWidthChanged );
968 connect( cboStrokeStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
969 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
970 connect( spinOffsetX,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
971 connect( spinOffsetY,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
973 mFillColorDDBtn->registerLinkedWidget( btnChangeColor );
974 mStrokeColorDDBtn->registerLinkedWidget( btnChangeStrokeColor );
979 if ( layer->
layerType() != QLatin1String(
"SimpleFill" ) )
986 btnChangeColor->blockSignals(
true );
988 btnChangeColor->blockSignals(
false );
989 cboFillStyle->blockSignals(
true );
990 cboFillStyle->setBrushStyle(
mLayer->brushStyle() );
991 cboFillStyle->blockSignals(
false );
992 btnChangeStrokeColor->blockSignals(
true );
993 btnChangeStrokeColor->setColor(
mLayer->strokeColor() );
994 btnChangeStrokeColor->blockSignals(
false );
995 cboStrokeStyle->blockSignals(
true );
996 cboStrokeStyle->setPenStyle(
mLayer->strokeStyle() );
997 cboStrokeStyle->blockSignals(
false );
998 spinStrokeWidth->blockSignals(
true );
999 spinStrokeWidth->setValue(
mLayer->strokeWidth() );
1000 spinStrokeWidth->blockSignals(
false );
1001 cboJoinStyle->blockSignals(
true );
1002 cboJoinStyle->setPenJoinStyle(
mLayer->penJoinStyle() );
1003 cboJoinStyle->blockSignals(
false );
1004 spinOffsetX->blockSignals(
true );
1005 spinOffsetX->setValue(
mLayer->offset().x() );
1006 spinOffsetX->blockSignals(
false );
1007 spinOffsetY->blockSignals(
true );
1008 spinOffsetY->setValue(
mLayer->offset().y() );
1009 spinOffsetY->blockSignals(
false );
1011 mStrokeWidthUnitWidget->blockSignals(
true );
1012 mStrokeWidthUnitWidget->setUnit(
mLayer->strokeWidthUnit() );
1013 mStrokeWidthUnitWidget->setMapUnitScale(
mLayer->strokeWidthMapUnitScale() );
1014 mStrokeWidthUnitWidget->blockSignals(
false );
1015 mOffsetUnitWidget->blockSignals(
true );
1016 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
1017 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
1018 mOffsetUnitWidget->blockSignals(
false );
1036 mLayer->setColor( color );
1042 mLayer->setStrokeColor( color );
1046void QgsSimpleFillSymbolLayerWidget::setBrushStyle()
1052void QgsSimpleFillSymbolLayerWidget::strokeWidthChanged()
1054 mLayer->setStrokeWidth( spinStrokeWidth->value() );
1058void QgsSimpleFillSymbolLayerWidget::strokeStyleChanged()
1060 mLayer->setStrokeStyle( cboStrokeStyle->penStyle() );
1061 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
1065void QgsSimpleFillSymbolLayerWidget::offsetChanged()
1067 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1071void QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
1075 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
1076 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
1081void QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1085 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1086 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1110 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
1111 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
1115 spinOffsetX->setClearValue( 0.0 );
1116 spinOffsetY->setClearValue( 0.0 );
1117 spinAngle->setClearValue( 0.0 );
1120 mAssistantPreviewSymbol = std::make_shared<QgsMarkerSymbol>();
1123 mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
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 ) );
1130 const double markerSize = size * 0.8;
1136 lyr->
setColor( QColor( 200, 200, 200 ) );
1139 QListWidgetItem *item =
new QListWidgetItem( icon, QString(), lstNames );
1140 item->setData( Qt::UserRole,
static_cast<int>( shape ) );
1145 lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
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 );
1159 if ( layer->
layerType() != QLatin1String(
"FilledMarker" ) )
1167 for (
int i = 0; i < lstNames->count(); ++i )
1169 if (
static_cast<Qgis::MarkerShape>( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
1171 lstNames->setCurrentRow( i );
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 );
1190 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->horizontalAnchorPoint() ) ) );
1191 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->verticalAnchorPoint() ) ) );
1200 updateAssistantSymbol();
1208void QgsFilledMarkerSymbolLayerWidget::setShape()
1214void QgsFilledMarkerSymbolLayerWidget::setSize()
1216 mLayer->setSize( spinSize->value() );
1220void QgsFilledMarkerSymbolLayerWidget::setAngle()
1222 mLayer->setAngle( spinAngle->value() );
1226void QgsFilledMarkerSymbolLayerWidget::setOffset()
1228 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1232void QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
1236 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1237 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1242void QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
1246 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1247 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1252void QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
1261void QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
1270void QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol()
1272 for (
int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
1274 mAssistantPreviewSymbol->deleteSymbolLayer( i );
1276 mAssistantPreviewSymbol->appendSymbolLayer(
mLayer->clone() );
1279 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
1292 connect( mSpinAngle,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged );
1295 btnColorRamp->setShowGradientOnly(
true );
1297 btnChangeColor->setAllowOpacity(
true );
1298 btnChangeColor->setColorDialogTitle( tr(
"Select Gradient Color" ) );
1299 btnChangeColor->setContext( QStringLiteral(
"symbology" ) );
1300 btnChangeColor->setShowNoColor(
true );
1301 btnChangeColor->setNoColorString( tr(
"Transparent" ) );
1302 btnChangeColor2->setAllowOpacity(
true );
1303 btnChangeColor2->setColorDialogTitle( tr(
"Select Gradient Color" ) );
1304 btnChangeColor2->setContext( QStringLiteral(
"symbology" ) );
1305 btnChangeColor2->setShowNoColor(
true );
1306 btnChangeColor2->setNoColorString( tr(
"Transparent" ) );
1308 mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1309 mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1311 spinOffsetX->setClearValue( 0.0 );
1312 spinOffsetY->setClearValue( 0.0 );
1313 mSpinAngle->setClearValue( 0.0 );
1321 connect( radioTwoColor, &QAbstractButton::toggled,
this, &QgsGradientFillSymbolLayerWidget::colorModeChanged );
1322 connect( spinOffsetX,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1323 connect( spinOffsetY,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1324 connect( spinRefPoint1X,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1325 connect( spinRefPoint1Y,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1326 connect( checkRefPoint1Centroid, &QAbstractButton::toggled,
this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1327 connect( spinRefPoint2X,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1328 connect( spinRefPoint2Y,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1329 connect( checkRefPoint2Centroid, &QAbstractButton::toggled,
this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1334 if ( layer->
layerType() != QLatin1String(
"GradientFill" ) )
1341 btnChangeColor->blockSignals(
true );
1343 btnChangeColor->blockSignals(
false );
1344 btnChangeColor2->blockSignals(
true );
1345 btnChangeColor2->setColor(
mLayer->color2() );
1346 btnChangeColor2->blockSignals(
false );
1350 radioTwoColor->setChecked(
true );
1351 btnColorRamp->setEnabled(
false );
1355 radioColorRamp->setChecked(
true );
1356 btnChangeColor->setEnabled(
false );
1357 btnChangeColor2->setEnabled(
false );
1361 if (
mLayer->colorRamp() )
1363 btnColorRamp->blockSignals(
true );
1364 btnColorRamp->setColorRamp(
mLayer->colorRamp() );
1365 btnColorRamp->blockSignals(
false );
1368 cboGradientType->blockSignals(
true );
1369 switch (
mLayer->gradientType() )
1372 cboGradientType->setCurrentIndex( 0 );
1375 cboGradientType->setCurrentIndex( 1 );
1378 cboGradientType->setCurrentIndex( 2 );
1381 cboGradientType->blockSignals(
false );
1383 cboCoordinateMode->blockSignals(
true );
1384 switch (
mLayer->coordinateMode() )
1387 cboCoordinateMode->setCurrentIndex( 1 );
1388 checkRefPoint1Centroid->setEnabled(
false );
1389 checkRefPoint2Centroid->setEnabled(
false );
1393 cboCoordinateMode->setCurrentIndex( 0 );
1396 cboCoordinateMode->blockSignals(
false );
1398 cboGradientSpread->blockSignals(
true );
1399 switch (
mLayer->gradientSpread() )
1402 cboGradientSpread->setCurrentIndex( 0 );
1405 cboGradientSpread->setCurrentIndex( 1 );
1408 cboGradientSpread->setCurrentIndex( 2 );
1411 cboGradientSpread->blockSignals(
false );
1413 spinRefPoint1X->blockSignals(
true );
1414 spinRefPoint1X->setValue(
mLayer->referencePoint1().x() );
1415 spinRefPoint1X->blockSignals(
false );
1416 spinRefPoint1Y->blockSignals(
true );
1417 spinRefPoint1Y->setValue(
mLayer->referencePoint1().y() );
1418 spinRefPoint1Y->blockSignals(
false );
1419 checkRefPoint1Centroid->blockSignals(
true );
1420 checkRefPoint1Centroid->setChecked(
mLayer->referencePoint1IsCentroid() );
1421 if (
mLayer->referencePoint1IsCentroid() )
1423 spinRefPoint1X->setEnabled(
false );
1424 spinRefPoint1Y->setEnabled(
false );
1426 checkRefPoint1Centroid->blockSignals(
false );
1427 spinRefPoint2X->blockSignals(
true );
1428 spinRefPoint2X->setValue(
mLayer->referencePoint2().x() );
1429 spinRefPoint2X->blockSignals(
false );
1430 spinRefPoint2Y->blockSignals(
true );
1431 spinRefPoint2Y->setValue(
mLayer->referencePoint2().y() );
1432 spinRefPoint2Y->blockSignals(
false );
1433 checkRefPoint2Centroid->blockSignals(
true );
1434 checkRefPoint2Centroid->setChecked(
mLayer->referencePoint2IsCentroid() );
1435 if (
mLayer->referencePoint2IsCentroid() )
1437 spinRefPoint2X->setEnabled(
false );
1438 spinRefPoint2Y->setEnabled(
false );
1440 checkRefPoint2Centroid->blockSignals(
false );
1442 spinOffsetX->blockSignals(
true );
1443 spinOffsetX->setValue(
mLayer->offset().x() );
1444 spinOffsetX->blockSignals(
false );
1445 spinOffsetY->blockSignals(
true );
1446 spinOffsetY->setValue(
mLayer->offset().y() );
1447 spinOffsetY->blockSignals(
false );
1448 mSpinAngle->blockSignals(
true );
1449 mSpinAngle->setValue(
mLayer->angle() );
1450 mSpinAngle->blockSignals(
false );
1452 mOffsetUnitWidget->blockSignals(
true );
1453 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
1454 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
1455 mOffsetUnitWidget->blockSignals(
false );
1479 mLayer->setColor( color );
1485 mLayer->setColor2( color );
1489void QgsGradientFillSymbolLayerWidget::colorModeChanged()
1491 if ( radioTwoColor->isChecked() )
1504 if ( btnColorRamp->isNull() )
1507 mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
1518 spinRefPoint1X->setValue( 0.5 );
1519 spinRefPoint1Y->setValue( 0 );
1520 spinRefPoint2X->setValue( 0.5 );
1521 spinRefPoint2Y->setValue( 1 );
1526 spinRefPoint1X->setValue( 0 );
1527 spinRefPoint1Y->setValue( 0 );
1528 spinRefPoint2X->setValue( 1 );
1529 spinRefPoint2Y->setValue( 1 );
1533 spinRefPoint1X->setValue( 0.5 );
1534 spinRefPoint1Y->setValue( 0.5 );
1535 spinRefPoint2X->setValue( 1 );
1536 spinRefPoint2Y->setValue( 1 );
1550 checkRefPoint1Centroid->setEnabled(
true );
1551 checkRefPoint2Centroid->setEnabled(
true );
1557 checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1558 checkRefPoint1Centroid->setEnabled(
false );
1559 checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1560 checkRefPoint2Centroid->setEnabled(
false );
1585void QgsGradientFillSymbolLayerWidget::offsetChanged()
1587 mLayer->
setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1591void QgsGradientFillSymbolLayerWidget::referencePointChanged()
1593 mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1594 mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1595 mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1596 mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1600void QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged(
double value )
1602 mLayer->setAngle( value );
1606void QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1610 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1611 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1624 connect( mSpinBlurRadius, qOverload<int>( &QSpinBox::valueChanged ),
this, &QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged );
1625 connect( mSpinMaxDistance, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged );
1627 connect( mRadioUseWholeShape, &QRadioButton::toggled,
this, &QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled );
1629 connect( mIgnoreRingsCheckBox, &QCheckBox::stateChanged,
this, &QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged );
1633 QButtonGroup *group1 =
new QButtonGroup(
this );
1634 group1->addButton( radioColorRamp );
1635 group1->addButton( radioTwoColor );
1636 QButtonGroup *group2 =
new QButtonGroup(
this );
1637 group2->addButton( mRadioUseMaxDistance );
1638 group2->addButton( mRadioUseWholeShape );
1639 btnChangeColor->setAllowOpacity(
true );
1640 btnChangeColor->setColorDialogTitle( tr(
"Select Gradient Color" ) );
1641 btnChangeColor->setContext( QStringLiteral(
"symbology" ) );
1642 btnChangeColor->setShowNoColor(
true );
1643 btnChangeColor->setNoColorString( tr(
"Transparent" ) );
1644 btnChangeColor2->setAllowOpacity(
true );
1645 btnChangeColor2->setColorDialogTitle( tr(
"Select Gradient Color" ) );
1646 btnChangeColor2->setContext( QStringLiteral(
"symbology" ) );
1647 btnChangeColor2->setShowNoColor(
true );
1648 btnChangeColor2->setNoColorString( tr(
"Transparent" ) );
1650 mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1651 mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1653 spinOffsetX->setClearValue( 0.0 );
1654 spinOffsetY->setClearValue( 0.0 );
1655 mSpinMaxDistance->setClearValue( 5.0 );
1657 btnColorRamp->setShowGradientOnly(
true );
1663 connect( radioTwoColor, &QAbstractButton::toggled,
this, &QgsShapeburstFillSymbolLayerWidget::colorModeChanged );
1664 connect( spinOffsetX,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1665 connect( spinOffsetY,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1667 connect( mBlurSlider, &QAbstractSlider::valueChanged, mSpinBlurRadius, &QSpinBox::setValue );
1668 connect( mSpinBlurRadius,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ), mBlurSlider, &QAbstractSlider::setValue );
1673 if ( layer->
layerType() != QLatin1String(
"ShapeburstFill" ) )
1680 btnChangeColor->blockSignals(
true );
1682 btnChangeColor->blockSignals(
false );
1683 btnChangeColor2->blockSignals(
true );
1684 btnChangeColor2->setColor(
mLayer->color2() );
1685 btnChangeColor2->blockSignals(
false );
1689 radioTwoColor->setChecked(
true );
1690 btnColorRamp->setEnabled(
false );
1694 radioColorRamp->setChecked(
true );
1695 btnChangeColor->setEnabled(
false );
1696 btnChangeColor2->setEnabled(
false );
1699 mSpinBlurRadius->blockSignals(
true );
1700 mBlurSlider->blockSignals(
true );
1701 mSpinBlurRadius->setValue(
mLayer->blurRadius() );
1702 mBlurSlider->setValue(
mLayer->blurRadius() );
1703 mSpinBlurRadius->blockSignals(
false );
1704 mBlurSlider->blockSignals(
false );
1706 mSpinMaxDistance->blockSignals(
true );
1707 mSpinMaxDistance->setValue(
mLayer->maxDistance() );
1708 mSpinMaxDistance->blockSignals(
false );
1710 mRadioUseWholeShape->blockSignals(
true );
1711 mRadioUseMaxDistance->blockSignals(
true );
1712 if (
mLayer->useWholeShape() )
1714 mRadioUseWholeShape->setChecked(
true );
1715 mSpinMaxDistance->setEnabled(
false );
1716 mDistanceUnitWidget->setEnabled(
false );
1720 mRadioUseMaxDistance->setChecked(
true );
1721 mSpinMaxDistance->setEnabled(
true );
1722 mDistanceUnitWidget->setEnabled(
true );
1724 mRadioUseWholeShape->blockSignals(
false );
1725 mRadioUseMaxDistance->blockSignals(
false );
1727 mDistanceUnitWidget->blockSignals(
true );
1728 mDistanceUnitWidget->setUnit(
mLayer->distanceUnit() );
1729 mDistanceUnitWidget->setMapUnitScale(
mLayer->distanceMapUnitScale() );
1730 mDistanceUnitWidget->blockSignals(
false );
1732 mIgnoreRingsCheckBox->blockSignals(
true );
1733 mIgnoreRingsCheckBox->setCheckState(
mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1734 mIgnoreRingsCheckBox->blockSignals(
false );
1737 if (
mLayer->colorRamp() )
1739 btnColorRamp->blockSignals(
true );
1740 btnColorRamp->setColorRamp(
mLayer->colorRamp() );
1741 btnColorRamp->blockSignals(
false );
1744 spinOffsetX->blockSignals(
true );
1745 spinOffsetX->setValue(
mLayer->offset().x() );
1746 spinOffsetX->blockSignals(
false );
1747 spinOffsetY->blockSignals(
true );
1748 spinOffsetY->setValue(
mLayer->offset().y() );
1749 spinOffsetY->blockSignals(
false );
1750 mOffsetUnitWidget->blockSignals(
true );
1751 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
1752 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
1753 mOffsetUnitWidget->blockSignals(
false );
1773 mLayer->setColor( color );
1782 mLayer->setColor2( color );
1787void QgsShapeburstFillSymbolLayerWidget::colorModeChanged()
1794 if ( radioTwoColor->isChecked() )
1805void QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged(
int value )
1809 mLayer->setBlurRadius( value );
1814void QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged(
double value )
1818 mLayer->setMaxDistance( value );
1823void QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed()
1827 mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1828 mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1833void QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled(
bool value )
1837 mLayer->setUseWholeShape( value );
1838 mDistanceUnitWidget->setEnabled( !value );
1843void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
1845 QgsColorRamp *ramp = btnColorRamp->colorRamp();
1849 mLayer->setColorRamp( ramp );
1853void QgsShapeburstFillSymbolLayerWidget::offsetChanged()
1857 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1862void QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1866 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1867 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1873void QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged(
int state )
1875 const bool checked = ( state == Qt::Checked );
1876 mLayer->setIgnoreRings( checked );
1884 , mSymbolType( symbolType )
1891 connect( mOffsetAlongLineUnitWidget, &
QgsUnitSelectionWidget::changed,
this, &QgsTemplatedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
1901 connect( mRingFilterComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
1909 spinOffset->setClearValue( 0.0 );
1910 mSpinOffsetAlongLine->setClearValue( 0.0 );
1911 mHashRotationSpinBox->setClearValue( 0 );
1912 mSpinAverageAngleLength->setClearValue( 4.0 );
1916 connect( mSpinHashLength,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTemplatedLineSymbolLayerWidget::setHashLength );
1917 connect( mHashRotationSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTemplatedLineSymbolLayerWidget::setHashAngle );
1918 connect( chkRotateMarker, &QAbstractButton::clicked,
this, &QgsTemplatedLineSymbolLayerWidget::setRotate );
1919 connect( spinOffset,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTemplatedLineSymbolLayerWidget::setOffset );
1920 connect( mSpinAverageAngleLength,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsTemplatedLineSymbolLayerWidget::setAverageAngle );
1922 connect( mCheckInterval, &QCheckBox::toggled,
this, &QgsTemplatedLineSymbolLayerWidget::setPlacement );
1923 connect( mCheckVertex, &QCheckBox::toggled,
this, &QgsTemplatedLineSymbolLayerWidget::setPlacement );
1924 connect( mCheckVertexLast, &QCheckBox::toggled,
this, &QgsTemplatedLineSymbolLayerWidget::setPlacement );
1925 connect( mCheckVertexFirst, &QCheckBox::toggled,
this, &QgsTemplatedLineSymbolLayerWidget::setPlacement );
1926 connect( mCheckCentralPoint, &QCheckBox::toggled,
this, &QgsTemplatedLineSymbolLayerWidget::setPlacement );
1927 connect( mCheckCurvePoint, &QCheckBox::toggled,
this, &QgsTemplatedLineSymbolLayerWidget::setPlacement );
1928 connect( mCheckSegmentCentralPoint, &QCheckBox::toggled,
this, &QgsTemplatedLineSymbolLayerWidget::setPlacement );
1930 connect( mCheckPlaceOnEveryPart, &QCheckBox::toggled,
this, [
this] {
1933 mLayer->setPlaceOnEveryPart( mCheckPlaceOnEveryPart->isChecked() );
1939 switch ( mSymbolType )
1945 mPlacementLabel->setText( tr(
"Hash placement" ) );
1946 chkRotateMarker->setText( tr(
"Rotate hash to follow line direction" ) );
1947 mHashLengthLabel->setVisible(
true );
1948 mSpinHashLength->setVisible(
true );
1949 mHashLengthUnitWidget->setVisible(
true );
1950 mHashLengthDDBtn->setVisible(
true );
1951 mHashRotationLabel->setVisible(
true );
1952 mHashRotationSpinBox->setVisible(
true );
1953 mHashRotationDDBtn->setVisible(
true );
1958 mPlacementLabel->setText( tr(
"Marker placement" ) );
1959 chkRotateMarker->setText( tr(
"Rotate marker to follow line direction" ) );
1960 mHashLengthLabel->setVisible(
false );
1961 mSpinHashLength->setVisible(
false );
1962 mHashLengthUnitWidget->setVisible(
false );
1963 mHashLengthDDBtn->setVisible(
false );
1964 mHashRotationLabel->setVisible(
false );
1965 mHashRotationSpinBox->setVisible(
false );
1966 mHashRotationDDBtn->setVisible(
false );
1972 switch ( mSymbolType )
1975 if ( layer->
layerType() != QLatin1String(
"HashLine" ) )
1980 if ( layer->
layerType() != QLatin1String(
"MarkerLine" ) )
1988 spinInterval->blockSignals(
true );
1989 spinInterval->setValue( mLayer->interval() );
1990 spinInterval->blockSignals(
false );
1991 mSpinOffsetAlongLine->blockSignals(
true );
1992 mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1993 mSpinOffsetAlongLine->blockSignals(
false );
1995 chkRotateMarker->blockSignals(
true );
1996 chkRotateMarker->setChecked( mLayer->rotateSymbols() );
1997 chkRotateMarker->blockSignals(
false );
1998 spinOffset->blockSignals(
true );
1999 spinOffset->setValue( mLayer->offset() );
2000 spinOffset->blockSignals(
false );
2009 whileBlocking( mCheckPlaceOnEveryPart )->setChecked( mLayer->placeOnEveryPart() );
2012 mIntervalUnitWidget->blockSignals(
true );
2013 mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
2014 mIntervalUnitWidget->
setMapUnitScale( mLayer->intervalMapUnitScale() );
2015 mIntervalUnitWidget->blockSignals(
false );
2016 mOffsetUnitWidget->blockSignals(
true );
2017 mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2018 mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2019 mOffsetUnitWidget->blockSignals(
false );
2020 mOffsetAlongLineUnitWidget->blockSignals(
true );
2021 mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
2022 mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
2023 mOffsetAlongLineUnitWidget->blockSignals(
false );
2024 whileBlocking( mAverageAngleUnit )->setUnit( mLayer->averageAngleUnit() );
2025 whileBlocking( mAverageAngleUnit )->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
2026 whileBlocking( mSpinAverageAngleLength )->setValue( mLayer->averageAngleLength() );
2028 switch ( mSymbolType )
2046 whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
2066 switch (
context.symbolType() )
2071 mRingFilterComboBox->hide();
2072 mRingsLabel->hide();
2083 mLayer->setInterval( val );
2089 mLayer->setOffsetAlongLine( val );
2093void QgsTemplatedLineSymbolLayerWidget::setHashLength(
double val )
2095 switch ( mSymbolType )
2110void QgsTemplatedLineSymbolLayerWidget::setHashAngle(
double val )
2115 switch ( mSymbolType )
2119 QgsHashedLineSymbolLayer *hashLayer =
static_cast<QgsHashedLineSymbolLayer *
>( mLayer );
2130void QgsTemplatedLineSymbolLayerWidget::setRotate()
2132 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2133 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2135 mLayer->setRotateSymbols( chkRotateMarker->isChecked() );
2139void QgsTemplatedLineSymbolLayerWidget::setOffset()
2141 mLayer->setOffset( spinOffset->value() );
2145void QgsTemplatedLineSymbolLayerWidget::setPlacement()
2147 const bool interval = mCheckInterval->isChecked();
2148 spinInterval->setEnabled( interval );
2149 mSpinOffsetAlongLine->setEnabled( mCheckInterval->isChecked() || mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2150 mOffsetAlongLineUnitWidget->setEnabled( mSpinOffsetAlongLine->isEnabled() );
2151 mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( mCheckInterval->isChecked() || mCheckCentralPoint->isChecked() ) );
2152 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2153 mCheckPlaceOnEveryPart->setEnabled( mCheckVertexLast->isChecked() || mCheckVertexFirst->isChecked() );
2156 if ( mCheckInterval->isChecked() )
2158 if ( mCheckVertex->isChecked() )
2160 if ( mCheckVertexLast->isChecked() )
2162 if ( mCheckVertexFirst->isChecked() )
2164 if ( mCheckCurvePoint->isChecked() )
2166 if ( mCheckSegmentCentralPoint->isChecked() )
2168 if ( mCheckCentralPoint->isChecked() )
2170 mLayer->setPlacements( placements );
2175void QgsTemplatedLineSymbolLayerWidget::mIntervalUnitWidget_changed()
2179 mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
2180 mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
2185void QgsTemplatedLineSymbolLayerWidget::mOffsetUnitWidget_changed()
2189 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2190 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2195void QgsTemplatedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
2199 mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
2200 mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
2205void QgsTemplatedLineSymbolLayerWidget::hashLengthUnitWidgetChanged()
2210 switch ( mSymbolType )
2214 QgsHashedLineSymbolLayer *hashLayer =
static_cast<QgsHashedLineSymbolLayer *
>( mLayer );
2226void QgsTemplatedLineSymbolLayerWidget::averageAngleUnitChanged()
2230 mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
2231 mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
2236void QgsTemplatedLineSymbolLayerWidget::setAverageAngle(
double val )
2240 mLayer->setAverageAngleLength( val );
2277 mSvgSelectorWidget->setAllowParameters(
true );
2278 mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible(
true );
2279 mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral(
"/UI/lastSVGMarkerDir" ) );
2280 mSvgSelectorWidget->initParametersModel(
this, vl );
2284 connect( mChangeStrokeColorButton, &
QgsColorButton::colorChanged,
this, &QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2285 connect( mStrokeWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2289 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
2290 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
2294 mChangeColorButton->setAllowOpacity(
true );
2295 mChangeColorButton->setColorDialogTitle( tr(
"Select Fill color" ) );
2296 mChangeColorButton->setContext( QStringLiteral(
"symbology" ) );
2297 mChangeStrokeColorButton->setAllowOpacity(
true );
2298 mChangeStrokeColorButton->setColorDialogTitle( tr(
"Select Stroke Color" ) );
2299 mChangeStrokeColorButton->setContext( QStringLiteral(
"symbology" ) );
2301 mFillColorDDBtn->registerLinkedWidget( mChangeColorButton );
2302 mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2304 spinOffsetX->setClearValue( 0.0 );
2305 spinOffsetY->setClearValue( 0.0 );
2306 spinAngle->setClearValue( 0.0 );
2308 connect( spinWidth,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSvgMarkerSymbolLayerWidget::setWidth );
2309 connect( spinHeight,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSvgMarkerSymbolLayerWidget::setHeight );
2311 connect( spinAngle,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSvgMarkerSymbolLayerWidget::setAngle );
2312 connect( spinOffsetX,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2313 connect( spinOffsetY,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2320 mAssistantPreviewSymbol = std::make_shared<QgsMarkerSymbol>();
2324 mWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
2325 mHeightDDBtn->setSymbol( mAssistantPreviewSymbol );
2332#include <QAbstractListModel>
2333#include <QPixmapCache>
2346 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2347 QColor defaultFill, defaultStroke;
2348 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2349 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2350 QgsApplication::svgCache()->
containsParams( layer->
path(), hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasStrokeParam, hasDefaultStrokeColor, defaultStroke, hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth, hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2351 mChangeColorButton->setEnabled( hasFillParam );
2352 mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2353 mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2354 mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
2355 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
2360 const double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2361 if ( hasDefaultFillColor && !skipDefaultColors )
2365 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : existingOpacity );
2366 mChangeColorButton->setColor( fill );
2368 if ( hasStrokeParam )
2371 const double existingOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2372 if ( hasDefaultStrokeColor && !skipDefaultColors )
2374 stroke = defaultStroke;
2376 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : existingOpacity );
2377 mChangeStrokeColorButton->setColor( stroke );
2380 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( layer->
path() );
2382 mStrokeWidthSpinBox->blockSignals(
true );
2383 mStrokeWidthSpinBox->setValue( hasDefaultStrokeWidth ? defaultStrokeWidth : layer->
strokeWidth() );
2384 mStrokeWidthSpinBox->blockSignals(
false );
2387 spinHeight->blockSignals(
true );
2388 if ( preservedAspectRatio )
2397 spinHeight->blockSignals(
false );
2398 whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
2401void QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol()
2403 for (
int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
2405 mAssistantPreviewSymbol->deleteSymbolLayer( i );
2407 mAssistantPreviewSymbol->appendSymbolLayer(
mLayer->clone() );
2410 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
2421 if ( layer->
layerType() != QLatin1String(
"SvgMarker" ) )
2428 mSvgSelectorWidget->setSvgPath(
mLayer->path() );
2429 mSvgSelectorWidget->setSvgParameters(
mLayer->parameters() );
2431 spinWidth->blockSignals(
true );
2432 spinWidth->setValue(
mLayer->size() );
2433 spinWidth->blockSignals(
false );
2434 spinAngle->blockSignals(
true );
2435 spinAngle->setValue(
mLayer->angle() );
2436 spinAngle->blockSignals(
false );
2439 spinOffsetX->blockSignals(
true );
2440 spinOffsetX->setValue(
mLayer->offset().x() );
2441 spinOffsetX->blockSignals(
false );
2442 spinOffsetY->blockSignals(
true );
2443 spinOffsetY->setValue(
mLayer->offset().y() );
2444 spinOffsetY->blockSignals(
false );
2446 mSizeUnitWidget->blockSignals(
true );
2447 mSizeUnitWidget->setUnit(
mLayer->sizeUnit() );
2449 mSizeUnitWidget->blockSignals(
false );
2450 mStrokeWidthUnitWidget->blockSignals(
true );
2451 mStrokeWidthUnitWidget->setUnit(
mLayer->strokeWidthUnit() );
2452 mStrokeWidthUnitWidget->setMapUnitScale(
mLayer->strokeWidthMapUnitScale() );
2453 mStrokeWidthUnitWidget->blockSignals(
false );
2454 mOffsetUnitWidget->blockSignals(
true );
2455 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
2456 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
2457 mOffsetUnitWidget->blockSignals(
false );
2460 mHorizontalAnchorComboBox->blockSignals(
true );
2461 mVerticalAnchorComboBox->blockSignals(
true );
2462 mHorizontalAnchorComboBox->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->horizontalAnchorPoint() ) ) );
2463 mVerticalAnchorComboBox->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->verticalAnchorPoint() ) ) );
2464 mHorizontalAnchorComboBox->blockSignals(
false );
2465 mVerticalAnchorComboBox->blockSignals(
false );
2481 updateAssistantSymbol();
2492 mSvgSelectorWidget->sourceLineEdit()->setMessageBar(
context.messageBar() );
2498 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2506 mLayer->setParameters( parameters );
2507 whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2513void QgsSvgMarkerSymbolLayerWidget::setWidth()
2516 double fixedAspectRatio = 0.0;
2517 spinHeight->blockSignals(
true );
2518 if ( defaultAspectRatio <= 0.0 )
2520 spinHeight->setValue( spinWidth->value() );
2522 else if ( mLockAspectRatio->locked() )
2524 spinHeight->setValue( spinWidth->value() * defaultAspectRatio );
2528 fixedAspectRatio = spinHeight->value() / spinWidth->value();
2530 spinHeight->blockSignals(
false );
2531 mLayer->setSize( spinWidth->value() );
2532 mLayer->setFixedAspectRatio( fixedAspectRatio );
2536void QgsSvgMarkerSymbolLayerWidget::setHeight()
2538 const double defaultAspectRatio =
mLayer->defaultAspectRatio();
2539 double fixedAspectRatio = 0.0;
2540 spinWidth->blockSignals(
true );
2541 if ( defaultAspectRatio <= 0.0 )
2543 spinWidth->setValue( spinHeight->value() );
2545 else if ( mLockAspectRatio->locked() )
2547 spinWidth->setValue( spinHeight->value() / defaultAspectRatio );
2551 fixedAspectRatio = spinHeight->value() / spinWidth->value();
2553 spinWidth->blockSignals(
false );
2554 mLayer->setSize( spinWidth->value() );
2555 mLayer->setFixedAspectRatio( fixedAspectRatio );
2559void QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged(
const bool locked )
2562 const double defaultAspectRatio =
mLayer->defaultAspectRatio();
2563 if ( defaultAspectRatio <= 0.0 )
2569 mLayer->setFixedAspectRatio( 0.0 );
2574 mLayer->setFixedAspectRatio( spinHeight->value() / spinWidth->value() );
2579void QgsSvgMarkerSymbolLayerWidget::setAngle()
2581 mLayer->setAngle( spinAngle->value() );
2585void QgsSvgMarkerSymbolLayerWidget::setOffset()
2587 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2591void QgsSvgMarkerSymbolLayerWidget::svgSourceChanged(
const QString &text )
2598void QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged(
const QColor &color )
2605 mLayer->setFillColor( color );
2609void QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged(
const QColor &color )
2616 mLayer->setStrokeColor( color );
2620void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
2624 mLayer->setStrokeWidth( d );
2629void QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
2633 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2634 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2639void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
2643 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
2644 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
2649void QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
2653 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2654 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2659void QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
2668void QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
2685 mSvgSelectorWidget->setAllowParameters(
true );
2686 mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible(
true );
2688 connect( mTextureWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged );
2690 connect( mRotationSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
2692 connect( mChangeStrokeColorButton, &
QgsColorButton::colorChanged,
this, &QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2693 connect( mStrokeWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2699 mRotationSpinBox->setClearValue( 0.0 );
2701 mChangeColorButton->setColorDialogTitle( tr(
"Select Fill Color" ) );
2702 mChangeColorButton->setContext( QStringLiteral(
"symbology" ) );
2703 mChangeStrokeColorButton->setColorDialogTitle( tr(
"Select Stroke Color" ) );
2704 mChangeStrokeColorButton->setContext( QStringLiteral(
"symbology" ) );
2706 mFilColorDDBtn->registerLinkedWidget( mChangeColorButton );
2707 mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2720 if ( layer->
layerType() != QLatin1String(
"SVGFill" ) )
2728 const double width =
mLayer->patternWidth();
2729 mTextureWidthSpinBox->blockSignals(
true );
2730 mTextureWidthSpinBox->setValue( width );
2731 mTextureWidthSpinBox->blockSignals(
false );
2732 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource(
mLayer->svgFilePath() );
2733 mRotationSpinBox->blockSignals(
true );
2734 mRotationSpinBox->setValue(
mLayer->angle() );
2735 mRotationSpinBox->blockSignals(
false );
2736 mTextureWidthUnitWidget->blockSignals(
true );
2737 mTextureWidthUnitWidget->setUnit(
mLayer->patternWidthUnit() );
2738 mTextureWidthUnitWidget->setMapUnitScale(
mLayer->patternWidthMapUnitScale() );
2739 mTextureWidthUnitWidget->blockSignals(
false );
2740 mSvgStrokeWidthUnitWidget->blockSignals(
true );
2741 mSvgStrokeWidthUnitWidget->setUnit(
mLayer->svgStrokeWidthUnit() );
2742 mSvgStrokeWidthUnitWidget->setMapUnitScale(
mLayer->svgStrokeWidthMapUnitScale() );
2743 mSvgStrokeWidthUnitWidget->blockSignals(
false );
2744 mChangeColorButton->blockSignals(
true );
2745 mChangeColorButton->setColor(
mLayer->svgFillColor() );
2746 mChangeColorButton->blockSignals(
false );
2747 mChangeStrokeColorButton->blockSignals(
true );
2748 mChangeStrokeColorButton->setColor(
mLayer->svgStrokeColor() );
2749 mChangeStrokeColorButton->blockSignals(
false );
2750 mStrokeWidthSpinBox->blockSignals(
true );
2751 mStrokeWidthSpinBox->setValue(
mLayer->svgStrokeWidth() );
2752 mStrokeWidthSpinBox->blockSignals(
false );
2773 mSvgSelectorWidget->sourceLineEdit()->setMessageBar(
context.messageBar() );
2776void QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged(
double d )
2785void QgsSVGFillSymbolLayerWidget::svgSourceChanged(
const QString &text )
2792 mLayer->setSvgFilePath( text );
2797void QgsSVGFillSymbolLayerWidget::setFile(
const QString &name )
2799 mLayer->setSvgFilePath( name );
2800 whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2806void QgsSVGFillSymbolLayerWidget::setSvgParameters(
const QMap<QString, QgsProperty> ¶meters )
2808 mLayer->setParameters( parameters );
2809 whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2816void QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged(
double d )
2828 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2829 QColor defaultFill, defaultStroke;
2830 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2831 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2832 QgsApplication::svgCache()->
containsParams( mSvgSelectorWidget->sourceLineEdit()->source(), hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasStrokeParam, hasDefaultStrokeColor, defaultStroke, hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth, hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2835 QColor fill = mChangeColorButton->color();
2836 const double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2837 if ( hasDefaultFillColor )
2841 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
2842 mChangeColorButton->setColor( fill );
2844 mChangeColorButton->setEnabled( hasFillParam );
2845 mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2848 QColor stroke = mChangeStrokeColorButton->color();
2849 const double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2850 if ( hasDefaultStrokeColor )
2852 stroke = defaultStroke;
2854 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
2855 mChangeStrokeColorButton->setColor( stroke );
2857 mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2858 mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
2859 if ( hasDefaultStrokeWidth && resetValues )
2861 mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
2863 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
2866void QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged(
const QColor &color )
2873 mLayer->setSvgFillColor( color );
2877void QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged(
const QColor &color )
2884 mLayer->setSvgStrokeColor( color );
2888void QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
2892 mLayer->setSvgStrokeWidth( d );
2897void QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed()
2901 mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2902 mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2907void QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed()
2911 mLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnitWidget->unit() );
2912 mLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthUnitWidget->getMapUnitScale() );
2923 connect( mAngleSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged );
2924 connect( mDistanceSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged );
2925 connect( mOffsetSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged );
2930 mOffsetSpinBox->setClearValue( 0 );
2931 mAngleSpinBox->setClearValue( 0 );
2935 connect( mCoordinateReferenceComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2946 connect( mClipModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
2957 if ( layer->
layerType() != QLatin1String(
"LinePatternFill" ) )
2971 mDistanceUnitWidget->blockSignals(
true );
2972 mDistanceUnitWidget->setUnit(
mLayer->distanceUnit() );
2974 mDistanceUnitWidget->blockSignals(
false );
2975 mOffsetUnitWidget->blockSignals(
true );
2976 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
2977 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
2978 mOffsetUnitWidget->blockSignals(
false );
2980 whileBlocking( mCoordinateReferenceComboBox )->setCurrentIndex( mCoordinateReferenceComboBox->findData(
static_cast<int>(
mLayer->coordinateReference() ) ) );
2982 whileBlocking( mClipModeComboBox )->setCurrentIndex( mClipModeComboBox->findData(
static_cast<int>(
mLayer->clipMode() ) ) );
2996void QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged(
double d )
3005void QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged(
double d )
3009 mLayer->setDistance( d );
3014void QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged(
double d )
3023void QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed()
3027 mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
3028 mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
3033void QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed()
3037 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3038 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3049 connect( mHorizontalDistanceSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged );
3050 connect( mVerticalDistanceSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged );
3051 connect( mHorizontalDisplacementSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged );
3052 connect( mVerticalDisplacementSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged );
3053 connect( mHorizontalOffsetSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged );
3054 connect( mVerticalOffsetSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged );
3055 connect( mHorizontalDistanceUnitWidget, &
QgsUnitSelectionWidget::changed,
this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed );
3056 connect( mVerticalDistanceUnitWidget, &
QgsUnitSelectionWidget::changed,
this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed );
3057 connect( mHorizontalDisplacementUnitWidget, &
QgsUnitSelectionWidget::changed,
this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed );
3058 connect( mVerticalDisplacementUnitWidget, &
QgsUnitSelectionWidget::changed,
this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed );
3059 connect( mHorizontalOffsetUnitWidget, &
QgsUnitSelectionWidget::changed,
this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed );
3060 connect( mVerticalOffsetUnitWidget, &
QgsUnitSelectionWidget::changed,
this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed );
3072 connect( mClipModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
3082 connect( mCoordinateReferenceComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
3090 mSeedSpinBox->setShowClearButton(
true );
3091 mSeedSpinBox->setClearValue( 0 );
3092 mRandomXSpinBox->setClearValue( 0 );
3093 mRandomYSpinBox->setClearValue( 0 );
3097 connect( mRandomXSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double d ) {
3100 mLayer->setMaximumRandomDeviationX( d );
3104 connect( mRandomYSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double d ) {
3107 mLayer->setMaximumRandomDeviationY( d );
3114 mLayer->setRandomDeviationXUnit( mRandomXOffsetUnitWidget->unit() );
3115 mLayer->setRandomDeviationXMapUnitScale( mRandomXOffsetUnitWidget->getMapUnitScale() );
3122 mLayer->setRandomDeviationYUnit( mRandomYOffsetUnitWidget->unit() );
3123 mLayer->setRandomDeviationYMapUnitScale( mRandomYOffsetUnitWidget->getMapUnitScale() );
3127 connect( mSeedSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int v ) {
3135 mAngleSpinBox->setShowClearButton(
true );
3136 mAngleSpinBox->setClearValue( 0 );
3137 connect( mAngleSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double d ) {
3148 if ( !layer || layer->
layerType() != QLatin1String(
"PointPatternFill" ) )
3162 mHorizontalDistanceUnitWidget->blockSignals(
true );
3163 mHorizontalDistanceUnitWidget->setUnit(
mLayer->distanceXUnit() );
3165 mHorizontalDistanceUnitWidget->blockSignals(
false );
3166 mVerticalDistanceUnitWidget->blockSignals(
true );
3167 mVerticalDistanceUnitWidget->setUnit(
mLayer->distanceYUnit() );
3168 mVerticalDistanceUnitWidget->setMapUnitScale(
mLayer->distanceYMapUnitScale() );
3169 mVerticalDistanceUnitWidget->blockSignals(
false );
3170 mHorizontalDisplacementUnitWidget->blockSignals(
true );
3171 mHorizontalDisplacementUnitWidget->setUnit(
mLayer->displacementXUnit() );
3172 mHorizontalDisplacementUnitWidget->setMapUnitScale(
mLayer->displacementXMapUnitScale() );
3173 mHorizontalDisplacementUnitWidget->blockSignals(
false );
3174 mVerticalDisplacementUnitWidget->blockSignals(
true );
3175 mVerticalDisplacementUnitWidget->setUnit(
mLayer->displacementYUnit() );
3176 mVerticalDisplacementUnitWidget->setMapUnitScale(
mLayer->displacementYMapUnitScale() );
3177 mVerticalDisplacementUnitWidget->blockSignals(
false );
3178 mHorizontalOffsetUnitWidget->blockSignals(
true );
3179 mHorizontalOffsetUnitWidget->setUnit(
mLayer->offsetXUnit() );
3180 mHorizontalOffsetUnitWidget->setMapUnitScale(
mLayer->offsetXMapUnitScale() );
3181 mHorizontalOffsetUnitWidget->blockSignals(
false );
3182 mVerticalOffsetUnitWidget->blockSignals(
true );
3183 mVerticalOffsetUnitWidget->setUnit(
mLayer->offsetYUnit() );
3184 mVerticalOffsetUnitWidget->setMapUnitScale(
mLayer->offsetYMapUnitScale() );
3185 mVerticalOffsetUnitWidget->blockSignals(
false );
3187 whileBlocking( mClipModeComboBox )->setCurrentIndex( mClipModeComboBox->findData(
static_cast<int>(
mLayer->clipMode() ) ) );
3188 whileBlocking( mCoordinateReferenceComboBox )->setCurrentIndex( mCoordinateReferenceComboBox->findData(
static_cast<int>(
mLayer->coordinateReference() ) ) );
3193 whileBlocking( mRandomXOffsetUnitWidget )->setMapUnitScale(
mLayer->randomDeviationXMapUnitScale() );
3195 whileBlocking( mRandomYOffsetUnitWidget )->setMapUnitScale(
mLayer->randomDeviationYMapUnitScale() );
3217void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged(
double d )
3226void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged(
double d )
3230 mLayer->setDistanceY( d );
3235void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged(
double d )
3239 mLayer->setDisplacementX( d );
3244void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged(
double d )
3248 mLayer->setDisplacementY( d );
3253void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged(
double d )
3262void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged(
double d )
3271void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed()
3275 mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
3276 mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
3281void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed()
3285 mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
3286 mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
3291void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed()
3295 mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
3296 mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
3301void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed()
3305 mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
3306 mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
3311void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed()
3315 mLayer->setOffsetXUnit( mHorizontalOffsetUnitWidget->unit() );
3316 mLayer->setOffsetXMapUnitScale( mHorizontalOffsetUnitWidget->getMapUnitScale() );
3321void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed()
3325 mLayer->setOffsetYUnit( mVerticalOffsetUnitWidget->unit() );
3326 mLayer->setOffsetYMapUnitScale( mVerticalOffsetUnitWidget->getMapUnitScale() );
3352 connect( mStrokeWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
3353 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3354 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3361 scrollArea->setVerticalOnly(
true );
3363 btnColor->setAllowOpacity(
true );
3364 btnColor->setColorDialogTitle( tr(
"Select Symbol Fill Color" ) );
3365 btnColor->setContext( QStringLiteral(
"symbology" ) );
3366 btnStrokeColor->setAllowOpacity(
true );
3367 btnStrokeColor->setColorDialogTitle( tr(
"Select Symbol Stroke Color" ) );
3368 btnStrokeColor->setContext( QStringLiteral(
"symbology" ) );
3370 mColorDDBtn->registerLinkedWidget( btnColor );
3371 mStrokeColorDDBtn->registerLinkedWidget( btnStrokeColor );
3373 spinOffsetX->setClearValue( 0.0 );
3374 spinOffsetY->setClearValue( 0.0 );
3375 spinAngle->setClearValue( 0.0 );
3378 mAssistantPreviewSymbol = std::make_shared<QgsMarkerSymbol>();
3381 mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
3384 connect( mFontStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged );
3386 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3389 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3391 connect( spinOffsetX,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3392 connect( spinOffsetY,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3403 if ( layer->
layerType() != QLatin1String(
"FontMarker" ) )
3412 mFontStyleComboBox->blockSignals(
true );
3413 populateFontStyleComboBox();
3414 mFontStyleComboBox->blockSignals(
false );
3426 if (
mLayer->character().length() == 1 )
3432 mCharPreview->setFont( mRefFont );
3438 mSizeUnitWidget->blockSignals(
true );
3439 mSizeUnitWidget->setUnit(
mLayer->sizeUnit() );
3440 mSizeUnitWidget->setMapUnitScale(
mLayer->sizeMapUnitScale() );
3441 mSizeUnitWidget->blockSignals(
false );
3443 mStrokeWidthUnitWidget->blockSignals(
true );
3444 mStrokeWidthUnitWidget->setUnit(
mLayer->strokeWidthUnit() );
3445 mStrokeWidthUnitWidget->setMapUnitScale(
mLayer->strokeWidthMapUnitScale() );
3446 mStrokeWidthUnitWidget->blockSignals(
false );
3448 mOffsetUnitWidget->blockSignals(
true );
3449 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
3450 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
3451 mOffsetUnitWidget->blockSignals(
false );
3456 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->horizontalAnchorPoint() ) ) );
3457 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->verticalAnchorPoint() ) ) );
3472 updateAssistantSymbol();
3484 mLayer->setFontFamily( font.family() );
3487 mCharPreview->setFont( mRefFont );
3488 populateFontStyleComboBox();
3493void QgsFontMarkerSymbolLayerWidget::setFontStyle(
const QString &style )
3500 mCharPreview->setFont( mRefFont );
3507 mLayer->setColor( color );
3513 mLayer->setStrokeColor( color );
3526 mLayer->setAngle( angle );
3532 mCharPreview->setText( text );
3534 if ( text.isEmpty() )
3538 QString character = text;
3539 if ( text.contains( QRegularExpression( QStringLiteral(
"^0x[0-9a-fA-F]{1,4}$" ) ) ) )
3542 const unsigned int value = text.toUInt( &ok, 0 );
3545 character = QChar( value );
3546 mCharPreview->setText( character );
3550 if ( character !=
mLayer->character() )
3552 mLayer->setCharacter( character );
3553 if (
mLayer->character().length() == 1 )
3567 if (
mLayer->character().length() > 1 || QGuiApplication::keyboardModifiers() & Qt::ControlModifier )
3569 mCharLineEdit->insert( chr );
3573 mLayer->setCharacter( chr );
3575 mCharPreview->setText( chr );
3579void QgsFontMarkerSymbolLayerWidget::setOffset()
3581 mLayer->
setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
3585void QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged()
3587 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
3591void QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
3595 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
3596 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3601void QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
3605 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3606 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3611void QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
3615 mLayer->setStrokeWidthUnit( mSizeUnitWidget->unit() );
3616 mLayer->setStrokeWidthMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3621void QgsFontMarkerSymbolLayerWidget::populateFontStyleComboBox()
3623 mFontStyleComboBox->clear();
3624 const QStringList styles = mFontDB.styles( mRefFont.family() );
3625 const auto constStyles = styles;
3626 for (
const QString &style : constStyles )
3628 mFontStyleComboBox->addItem( style );
3631 QString targetStyle = mFontDB.styleString( mRefFont );
3632 if ( !styles.contains( targetStyle ) )
3635 targetStyle = QFontInfo( f ).styleName();
3636 mRefFont.setStyleName( targetStyle );
3639 const int stylIndx = mFontStyleComboBox->findText( targetStyle );
3640 if ( stylIndx > -1 )
3645 mFontStyleComboBox->setCurrentIndex( curIndx );
3648void QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged(
int index )
3651 setFontStyle( mFontStyleComboBox->currentText() );
3654void QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
3663void QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
3672void QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
3676 mLayer->setStrokeWidth( d );
3681void QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol()
3683 for (
int i = mAssistantPreviewSymbol->symbolLayerCount() - 1; i >= 0; --i )
3685 mAssistantPreviewSymbol->deleteSymbolLayer( i );
3687 mAssistantPreviewSymbol->appendSymbolLayer(
mLayer->clone() );
3690 mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
3702 connect( mDrawInsideCheckBox, &QCheckBox::stateChanged,
this, &QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
3703 connect( mDrawAllPartsCheckBox, &QCheckBox::stateChanged,
this, &QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged );
3704 connect( mClipPointsCheckBox, &QCheckBox::stateChanged,
this, &QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged );
3705 connect( mClipOnCurrentPartOnlyCheckBox, &QCheckBox::stateChanged,
this, &QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged );
3710 if ( layer->
layerType() != QLatin1String(
"CentroidFill" ) )
3720 whileBlocking( mClipOnCurrentPartOnlyCheckBox )->setChecked(
mLayer->clipOnCurrentPartOnly() );
3728void QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged(
int state )
3734void QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged(
int state )
3736 mLayer->setPointOnAllParts( state == Qt::Checked );
3740void QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged(
int state )
3742 mLayer->setClipPoints( state == Qt::Checked );
3746void QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged(
int state )
3748 mLayer->setClipOnCurrentPartOnly( state == Qt::Checked );
3769 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral(
"/UI/lastRasterMarkerImageDir" ) );
3773 connect( mRotationSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMarkerSymbolLayerWidget::setAngle );
3775 connect( mWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMarkerSymbolLayerWidget::setWidth );
3776 connect( mHeightSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMarkerSymbolLayerWidget::setHeight );
3782 mSpinOffsetX->setClearValue( 0.0 );
3783 mSpinOffsetY->setClearValue( 0.0 );
3784 mRotationSpinBox->setClearValue( 0.0 );
3786 connect( mSpinOffsetX,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3787 connect( mSpinOffsetY,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3790 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3791 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3801 if ( layer->
layerType() != QLatin1String(
"RasterMarker" ) )
3811 const bool preservedAspectRatio =
mLayer->preservedAspectRatio();
3812 mHeightSpinBox->blockSignals(
true );
3813 if ( preservedAspectRatio )
3815 mHeightSpinBox->setValue(
mLayer->size() );
3819 mHeightSpinBox->setValue(
mLayer->size() *
mLayer->fixedAspectRatio() );
3821 mHeightSpinBox->setEnabled(
mLayer->defaultAspectRatio() > 0.0 );
3822 mHeightSpinBox->blockSignals(
false );
3823 whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
3831 mSizeUnitWidget->blockSignals(
true );
3832 mSizeUnitWidget->setUnit(
mLayer->sizeUnit() );
3833 mSizeUnitWidget->setMapUnitScale(
mLayer->sizeMapUnitScale() );
3834 mSizeUnitWidget->blockSignals(
false );
3835 mOffsetUnitWidget->blockSignals(
true );
3836 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
3837 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
3838 mOffsetUnitWidget->blockSignals(
false );
3841 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->horizontalAnchorPoint() ) ) );
3842 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->verticalAnchorPoint() ) ) );
3853 updatePreviewImage();
3864 mImageSourceLineEdit->setMessageBar(
context.messageBar() );
3867void QgsRasterMarkerSymbolLayerWidget::imageSourceChanged(
const QString &text )
3870 updatePreviewImage();
3874void QgsRasterMarkerSymbolLayerWidget::updatePreviewImage()
3876 bool fitsInCache =
false;
3878 if ( image.isNull() )
3880 mLabelImagePreview->setPixmap( QPixmap() );
3884 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
3885 previewImage.fill( Qt::transparent );
3886 const QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
3888 p.begin( &previewImage );
3890 uchar pixDataRGB[] = { 150, 150, 150, 150, 100, 100, 100, 150, 100, 100, 100, 150, 150, 150, 150, 150 };
3891 const QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
3892 const QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
3893 QBrush checkerBrush;
3894 checkerBrush.setTexture( pix );
3895 p.fillRect( imageRect, checkerBrush );
3897 if (
mLayer->opacity() < 1.0 )
3899 p.setOpacity(
mLayer->opacity() );
3902 p.drawImage( imageRect.left(), imageRect.top(), image );
3904 mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
3907void QgsRasterMarkerSymbolLayerWidget::setWidth()
3909 const double defaultAspectRatio =
mLayer->defaultAspectRatio();
3910 double fixedAspectRatio = 0.0;
3911 mHeightSpinBox->blockSignals(
true );
3912 if ( defaultAspectRatio <= 0.0 )
3914 mHeightSpinBox->setValue( mWidthSpinBox->value() );
3916 else if ( mLockAspectRatio->locked() )
3918 mHeightSpinBox->setValue( mWidthSpinBox->value() * defaultAspectRatio );
3922 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
3924 mHeightSpinBox->blockSignals(
false );
3925 mLayer->setSize( mWidthSpinBox->value() );
3926 mLayer->setFixedAspectRatio( fixedAspectRatio );
3930void QgsRasterMarkerSymbolLayerWidget::setHeight()
3932 const double defaultAspectRatio =
mLayer->defaultAspectRatio();
3933 double fixedAspectRatio = 0.0;
3934 mWidthSpinBox->blockSignals(
true );
3935 if ( defaultAspectRatio <= 0.0 )
3937 mWidthSpinBox->setValue( mHeightSpinBox->value() );
3939 else if ( mLockAspectRatio->locked() )
3941 mWidthSpinBox->setValue( mHeightSpinBox->value() / defaultAspectRatio );
3945 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
3947 mWidthSpinBox->blockSignals(
false );
3948 mLayer->setSize( mWidthSpinBox->value() );
3949 mLayer->setFixedAspectRatio( fixedAspectRatio );
3953void QgsRasterMarkerSymbolLayerWidget::setLockAspectRatio(
const bool locked )
3955 const double defaultAspectRatio =
mLayer->defaultAspectRatio();
3956 if ( defaultAspectRatio <= 0.0 )
3962 mLayer->setFixedAspectRatio( 0.0 );
3967 mLayer->setFixedAspectRatio( mHeightSpinBox->value() / mWidthSpinBox->value() );
3971void QgsRasterMarkerSymbolLayerWidget::setAngle()
3973 mLayer->setAngle( mRotationSpinBox->value() );
3977void QgsRasterMarkerSymbolLayerWidget::setOpacity(
double value )
3979 mLayer->setOpacity( value );
3981 updatePreviewImage();
3984void QgsRasterMarkerSymbolLayerWidget::setOffset()
3986 mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
3990void QgsRasterMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
3994 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
3995 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4000void QgsRasterMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
4004 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4005 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4010void QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
4019void QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
4046 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral(
"/UI/lastAnimatedMarkerImageDir" ) );
4050 connect( mRotationSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnimatedMarkerSymbolLayerWidget::setAngle );
4052 connect( mWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnimatedMarkerSymbolLayerWidget::setWidth );
4053 connect( mHeightSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnimatedMarkerSymbolLayerWidget::setHeight );
4056 mFrameRateSpin->setClearValue( 10 );
4057 mFrameRateSpin->setShowClearButton(
true );
4058 connect( mFrameRateSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double value ) {
4059 mLayer->setFrameRate( value );
4066 mSpinOffsetX->setClearValue( 0.0 );
4067 mSpinOffsetY->setClearValue( 0.0 );
4068 mRotationSpinBox->setClearValue( 0.0 );
4070 connect( mSpinOffsetX,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnimatedMarkerSymbolLayerWidget::setOffset );
4071 connect( mSpinOffsetY,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnimatedMarkerSymbolLayerWidget::setOffset );
4074 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsAnimatedMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
4075 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsAnimatedMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
4085 if ( layer->
layerType() != QLatin1String(
"AnimatedMarker" ) )
4095 if ( firstFrameTime > 0 )
4097 mFrameRateSpin->setClearValue( 1000 / firstFrameTime );
4101 mFrameRateSpin->setClearValue( 10 );
4105 const bool preservedAspectRatio =
mLayer->preservedAspectRatio();
4106 mHeightSpinBox->blockSignals(
true );
4107 if ( preservedAspectRatio )
4109 mHeightSpinBox->setValue(
mLayer->size() );
4113 mHeightSpinBox->setValue(
mLayer->size() *
mLayer->fixedAspectRatio() );
4115 mHeightSpinBox->setEnabled(
mLayer->defaultAspectRatio() > 0.0 );
4116 mHeightSpinBox->blockSignals(
false );
4117 whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
4127 mSizeUnitWidget->blockSignals(
true );
4128 mSizeUnitWidget->setUnit(
mLayer->sizeUnit() );
4129 mSizeUnitWidget->setMapUnitScale(
mLayer->sizeMapUnitScale() );
4130 mSizeUnitWidget->blockSignals(
false );
4131 mOffsetUnitWidget->blockSignals(
true );
4132 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
4133 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
4134 mOffsetUnitWidget->blockSignals(
false );
4137 whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->horizontalAnchorPoint() ) ) );
4138 whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->verticalAnchorPoint() ) ) );
4149 updatePreviewImage();
4160 mImageSourceLineEdit->setMessageBar(
context.messageBar() );
4163void QgsAnimatedMarkerSymbolLayerWidget::imageSourceChanged(
const QString &text )
4168 if ( firstFrameTime > 0 )
4170 mFrameRateSpin->setClearValue( 1000 / firstFrameTime );
4174 mFrameRateSpin->setClearValue( 10 );
4176 updatePreviewImage();
4180void QgsAnimatedMarkerSymbolLayerWidget::updatePreviewImage()
4182 if ( mPreviewMovie )
4184 mLabelImagePreview->setMovie(
nullptr );
4185 mPreviewMovie->deleteLater();
4186 mPreviewMovie =
nullptr;
4189 mPreviewMovie =
new QMovie(
mLayer->path(), QByteArray(),
this );
4190 mPreviewMovie->setScaledSize( QSize( 150, 150 ) );
4191 mLabelImagePreview->setMovie( mPreviewMovie );
4192 mPreviewMovie->start();
4195void QgsAnimatedMarkerSymbolLayerWidget::setWidth()
4197 const double defaultAspectRatio =
mLayer->defaultAspectRatio();
4198 double fixedAspectRatio = 0.0;
4199 mHeightSpinBox->blockSignals(
true );
4200 if ( defaultAspectRatio <= 0.0 )
4202 mHeightSpinBox->setValue( mWidthSpinBox->value() );
4204 else if ( mLockAspectRatio->locked() )
4206 mHeightSpinBox->setValue( mWidthSpinBox->value() * defaultAspectRatio );
4210 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4212 mHeightSpinBox->blockSignals(
false );
4213 mLayer->setSize( mWidthSpinBox->value() );
4214 mLayer->setFixedAspectRatio( fixedAspectRatio );
4218void QgsAnimatedMarkerSymbolLayerWidget::setHeight()
4220 const double defaultAspectRatio =
mLayer->defaultAspectRatio();
4221 double fixedAspectRatio = 0.0;
4222 mWidthSpinBox->blockSignals(
true );
4223 if ( defaultAspectRatio <= 0.0 )
4225 mWidthSpinBox->setValue( mHeightSpinBox->value() );
4227 else if ( mLockAspectRatio->locked() )
4229 mWidthSpinBox->setValue( mHeightSpinBox->value() / defaultAspectRatio );
4233 fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
4235 mWidthSpinBox->blockSignals(
false );
4236 mLayer->setSize( mWidthSpinBox->value() );
4237 mLayer->setFixedAspectRatio( fixedAspectRatio );
4241void QgsAnimatedMarkerSymbolLayerWidget::setLockAspectRatio(
const bool locked )
4243 const double defaultAspectRatio =
mLayer->defaultAspectRatio();
4244 if ( defaultAspectRatio <= 0.0 )
4250 mLayer->setFixedAspectRatio( 0.0 );
4255 mLayer->setFixedAspectRatio( mHeightSpinBox->value() / mWidthSpinBox->value() );
4259void QgsAnimatedMarkerSymbolLayerWidget::setAngle()
4261 mLayer->setAngle( mRotationSpinBox->value() );
4265void QgsAnimatedMarkerSymbolLayerWidget::setOpacity(
double value )
4267 mLayer->setOpacity( value );
4269 updatePreviewImage();
4272void QgsAnimatedMarkerSymbolLayerWidget::setOffset()
4274 mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4278void QgsAnimatedMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
4282 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
4283 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4288void QgsAnimatedMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
4292 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4293 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4298void QgsAnimatedMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
4307void QgsAnimatedMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
4324 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral(
"/UI/lastRasterMarkerImageDir" ) );
4328 connect( mRotationSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
4335 mLayer->setSizeUnit( mSizeUnitWidget->unit() );
4336 mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4339 connect( mWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double d ) {
4348 connect( mHeightSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double d ) {
4360 mSpinOffsetX->setClearValue( 0.0 );
4361 mSpinOffsetY->setClearValue( 0.0 );
4362 mRotationSpinBox->setClearValue( 0.0 );
4364 connect( cboCoordinateMode,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterFillSymbolLayerWidget::setCoordinateMode );
4365 connect( mSpinOffsetX,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4366 connect( mSpinOffsetY,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4378 if ( layer->
layerType() != QLatin1String(
"RasterFill" ) )
4391 cboCoordinateMode->blockSignals(
true );
4392 switch (
mLayer->coordinateMode() )
4395 cboCoordinateMode->setCurrentIndex( 1 );
4399 cboCoordinateMode->setCurrentIndex( 0 );
4402 cboCoordinateMode->blockSignals(
false );
4408 mOffsetUnitWidget->blockSignals(
true );
4409 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
4410 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
4411 mOffsetUnitWidget->blockSignals(
false );
4414 mSizeUnitWidget->blockSignals(
true );
4415 mSizeUnitWidget->setUnit(
mLayer->sizeUnit() );
4416 mSizeUnitWidget->setMapUnitScale(
mLayer->sizeMapUnitScale() );
4417 mSizeUnitWidget->blockSignals(
false );
4421 updatePreviewImage();
4436void QgsRasterFillSymbolLayerWidget::imageSourceChanged(
const QString &text )
4439 updatePreviewImage();
4443void QgsRasterFillSymbolLayerWidget::setCoordinateMode(
int index )
4460void QgsRasterFillSymbolLayerWidget::opacityChanged(
double value )
4467 mLayer->setOpacity( value );
4469 updatePreviewImage();
4472void QgsRasterFillSymbolLayerWidget::offsetChanged()
4474 mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4478void QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed()
4484 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4485 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4489void QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged(
double d )
4498void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
4500 bool fitsInCache =
false;
4502 if ( image.isNull() )
4504 mLabelImagePreview->setPixmap( QPixmap() );
4508 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4509 previewImage.fill( Qt::transparent );
4510 const QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4512 p.begin( &previewImage );
4514 uchar pixDataRGB[] = { 150, 150, 150, 150, 100, 100, 100, 150, 100, 100, 100, 150, 150, 150, 150, 150 };
4515 const QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4516 const QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4517 QBrush checkerBrush;
4518 checkerBrush.setTexture( pix );
4519 p.fillRect( imageRect, checkerBrush );
4521 if (
mLayer->opacity() < 1.0 )
4523 p.setOpacity(
mLayer->opacity() );
4526 p.drawImage( imageRect.left(), imageRect.top(), image );
4528 mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4542 mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral(
"/UI/lastRasterMarkerImageDir" ) );
4550 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
4551 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
4556 connect( spinWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this] {
4559 mLayer->setWidth( spinWidth->value() );
4567 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4568 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4574 spinOffset->setClearValue( 0.0 );
4575 connect( spinOffset, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double val ) {
4578 mLayer->setOffset( val );
4583 connect( cboCapStyle, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
4586 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
4590 connect( cboJoinStyle, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
4593 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
4602 mLayer->setOpacity( opacity );
4603 updatePreviewImage();
4616 if ( layer->
layerType() != QLatin1String(
"RasterLine" ) )
4640 updatePreviewImage();
4655void QgsRasterLineSymbolLayerWidget::imageSourceChanged(
const QString &text )
4658 updatePreviewImage();
4662void QgsRasterLineSymbolLayerWidget::updatePreviewImage()
4664 bool fitsInCache =
false;
4666 if ( image.isNull() )
4668 mLabelImagePreview->setPixmap( QPixmap() );
4672 QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4673 previewImage.fill( Qt::transparent );
4674 const QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4676 p.begin( &previewImage );
4678 uchar pixDataRGB[] = { 150, 150, 150, 150, 100, 100, 100, 150, 100, 100, 100, 150, 150, 150, 150, 150 };
4679 const QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4680 const QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4681 QBrush checkerBrush;
4682 checkerBrush.setTexture( pix );
4683 p.fillRect( imageRect, checkerBrush );
4685 if (
mLayer->opacity() < 1.0 )
4687 p.setOpacity(
mLayer->opacity() );
4690 p.drawImage( imageRect.left(), imageRect.top(), image );
4692 mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4705 modificationExpressionSelector->setMultiLine(
true );
4706 modificationExpressionSelector->setLayer(
const_cast<QgsVectorLayer *
>( vl ) );
4707 modificationExpressionSelector->registerExpressionContextGenerator(
this );
4713 mUnitWidget->setShowMapScaleButton(
false );
4716 connect( cbxGeometryType,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType );
4718 if ( !mBlockSignals )
4720 mLayer->setUnits( mUnitWidget->unit() );
4730 modificationExpressionSelector->setExpression( mLayer->geometryExpression() );
4731 cbxGeometryType->setCurrentIndex( cbxGeometryType->findData(
static_cast<int>( mLayer->symbolType() ) ) );
4732 mUnitWidget->setUnit( mLayer->units() );
4741void QgsGeometryGeneratorSymbolLayerWidget::updateExpression(
const QString &
string )
4748void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
4751 std::unique_ptr<QgsSymbol> subSymbol( mLayer->subSymbol()->clone() );
4753 mLayer->setSymbolType(
static_cast<Qgis::SymbolType>( cbxGeometryType->currentData().toInt() ) );
4755 switch ( mLayer->symbolType() )
4766 for (
int i = 0; i < subSymbol->symbolLayerCount(); ++i )
4768 if (
dynamic_cast<const QgsLineSymbolLayer *
>( subSymbol->symbolLayer( i ) ) )
4769 layers << subSymbol->symbolLayer( i )->clone();
4772 if ( !layers.empty() )
4773 mLayer->setSubSymbol(
new QgsLineSymbol( layers ) );
4782 for (
int i = 0; i < subSymbol->symbolLayerCount(); ++i )
4783 layers << subSymbol->symbolLayer( i )->clone();
4784 mLayer->setSubSymbol(
new QgsFillSymbol( layers ) );
4805 mPointCountSpinBox->setShowClearButton(
true );
4806 mPointCountSpinBox->setClearValue( 100 );
4807 mSeedSpinBox->setShowClearButton(
true );
4808 mSeedSpinBox->setClearValue( 0 );
4810 connect( mCountMethodComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged );
4811 connect( mPointCountSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsRandomMarkerFillSymbolLayerWidget::countChanged );
4812 connect( mDensityAreaSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged );
4813 connect( mSeedSpinBox,
static_cast<void ( QSpinBox::* )(
int )
>( &QSpinBox::valueChanged ),
this, &QgsRandomMarkerFillSymbolLayerWidget::seedChanged );
4814 connect( mClipPointsCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
4817 mLayer->setClipPoints( checked );
4829 if ( !layer || layer->
layerType() != QLatin1String(
"RandomMarkerFill" ) )
4835 whileBlocking( mPointCountSpinBox )->setValue( mLayer->pointCount() );
4837 whileBlocking( mClipPointsCheckBox )->setChecked( mLayer->clipPoints() );
4839 bool showDensityBasedCountWidgets =
false;
4840 switch ( mLayer->countMethod() )
4843 showDensityBasedCountWidgets =
true;
4848 mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
4849 mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
4850 mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
4851 mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
4853 whileBlocking( mCountMethodComboBox )->setCurrentIndex( mCountMethodComboBox->findData(
static_cast<int>( mLayer->countMethod() ) ) );
4854 whileBlocking( mDensityAreaSpinBox )->setValue( mLayer->densityArea() );
4855 mDensityAreaUnitWidget->blockSignals(
true );
4856 mDensityAreaUnitWidget->setUnit( mLayer->densityAreaUnit() );
4857 mDensityAreaUnitWidget->
setMapUnitScale( mLayer->densityAreaUnitScale() );
4858 mDensityAreaUnitWidget->blockSignals(
false );
4871void QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged(
int )
4873 bool showDensityBasedCountWidgets =
false;
4877 showDensityBasedCountWidgets =
true;
4882 mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
4883 mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
4884 mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
4885 mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
4889 mLayer->setCountMethod(
static_cast<Qgis::PointCountMethod>( mCountMethodComboBox->currentData().toInt() ) );
4894void QgsRandomMarkerFillSymbolLayerWidget::countChanged(
int d )
4898 mLayer->setPointCount( d );
4903void QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged(
double d )
4907 mLayer->setDensityArea( d );
4912void QgsRandomMarkerFillSymbolLayerWidget::densityAreaUnitChanged()
4916 mLayer->setDensityAreaUnit( mDensityAreaUnitWidget->unit() );
4917 mLayer->setDensityAreaUnitScale( mDensityAreaUnitWidget->getMapUnitScale() );
4922void QgsRandomMarkerFillSymbolLayerWidget::seedChanged(
int d )
4926 mLayer->setSeed( d );
4941 btnColorRamp->setShowGradientOnly(
true );
4943 btnChangeColor->setAllowOpacity(
true );
4944 btnChangeColor->setColorDialogTitle( tr(
"Select Gradient Color" ) );
4945 btnChangeColor->setContext( QStringLiteral(
"symbology" ) );
4946 btnChangeColor->setShowNoColor(
true );
4947 btnChangeColor->setNoColorString( tr(
"Transparent" ) );
4948 btnChangeColor2->setAllowOpacity(
true );
4949 btnChangeColor2->setColorDialogTitle( tr(
"Select Gradient Color" ) );
4950 btnChangeColor2->setContext( QStringLiteral(
"symbology" ) );
4951 btnChangeColor2->setShowNoColor(
true );
4952 btnChangeColor2->setNoColorString( tr(
"Transparent" ) );
4954 mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
4955 mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
4960 mLayer->setColor( color );
4967 mLayer->setColor2( color );
4972 if ( btnColorRamp->isNull() )
4977 mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
4982 connect( radioTwoColor, &QAbstractButton::toggled,
this, [
this] {
4985 if ( radioTwoColor->isChecked() )
4988 btnChangeColor->setEnabled(
true );
4989 btnChangeColor2->setEnabled(
true );
4990 btnColorRamp->setEnabled(
false );
4995 btnColorRamp->setEnabled(
true );
4996 btnChangeColor->setEnabled(
false );
4997 btnChangeColor2->setEnabled(
false );
5009 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
5010 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
5015 connect( spinWidth,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [
this] {
5018 mLayer->setWidth( spinWidth->value() );
5026 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
5027 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
5032 spinOffset->setClearValue( 0.0 );
5033 connect( spinOffset, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double val ) {
5036 mLayer->setOffset( val );
5041 connect( cboCapStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this] {
5044 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
5048 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this] {
5051 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
5064 if ( layer->
layerType() != QLatin1String(
"Lineburst" ) )
5075 btnChangeColor->blockSignals(
true );
5077 btnChangeColor->blockSignals(
false );
5078 btnChangeColor2->blockSignals(
true );
5079 btnChangeColor2->setColor(
mLayer->color2() );
5080 btnChangeColor2->blockSignals(
false );
5084 radioTwoColor->setChecked(
true );
5085 btnColorRamp->setEnabled(
false );
5089 radioColorRamp->setChecked(
true );
5090 btnChangeColor->setEnabled(
false );
5091 btnChangeColor2->setEnabled(
false );
5095 if (
mLayer->colorRamp() )
5097 btnColorRamp->blockSignals(
true );
5098 btnColorRamp->setColorRamp(
mLayer->colorRamp() );
5099 btnColorRamp->blockSignals(
false );
5142 mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
5143 mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
5148 connect( spinWidth,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [
this] {
5151 mLayer->setWidth( spinWidth->value() );
5159 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
5160 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
5165 spinOffset->setClearValue( 0.0 );
5166 connect( spinOffset, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double val ) {
5169 mLayer->setOffset( val );
5174 connect( cboCapStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this] {
5177 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
5181 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [
this] {
5184 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
5199 if ( layer->
layerType() != QLatin1String(
"FilledLine" ) )
5211 whileBlocking( mPenWidthUnitWidget )->setUnit( mLayer->widthUnit() );
5214 whileBlocking( mOffsetUnitWidget )->setUnit( mLayer->offsetUnit() );
5215 whileBlocking( mOffsetUnitWidget )->setMapUnitScale( mLayer->offsetMapUnitScale() );
5218 whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
5219 whileBlocking( cboCapStyle )->setPenCapStyle( mLayer->penCapStyle() );
5252 mSpinSkipMultiples->setClearValue( 0, tr(
"Not set" ) );
5253 mSpinLabelOffsetX->setClearValue( 0 );
5254 mSpinLabelOffsetY->setClearValue( 0 );
5255 mSpinAverageAngleLength->setClearValue( 4.0 );
5259 connect( mComboQuantity, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
5260 if ( mLayer && !mBlockChangesSignal )
5267 if ( mLayer && !mBlockChangesSignal )
5269 mLayer->setTextFormat( mTextFormatButton->textFormat() );
5273 connect( spinInterval, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] {
5274 if ( mLayer && !mBlockChangesSignal )
5276 mLayer->setInterval( spinInterval->value() );
5280 connect( mSpinSkipMultiples, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] {
5281 if ( mLayer && !mBlockChangesSignal )
5283 mLayer->setSkipMultiplesOf( mSpinSkipMultiples->value() );
5287 connect( mCheckRotate, &QCheckBox::toggled,
this, [
this](
bool checked ) {
5288 if ( mLayer && !mBlockChangesSignal )
5290 mLayer->setRotateLabels( checked );
5293 mSpinAverageAngleLength->setEnabled( checked );
5294 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
5296 connect( mCheckShowMarker, &QCheckBox::toggled,
this, [
this](
bool checked ) {
5297 if ( mLayer && !mBlockChangesSignal )
5299 mLayer->setShowMarker( checked );
5304 connect( mSpinLabelOffsetX, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] {
5305 if ( mLayer && !mBlockChangesSignal )
5307 mLayer->setLabelOffset( QPointF( mSpinLabelOffsetX->value(), mSpinLabelOffsetY->value() ) );
5311 connect( mSpinLabelOffsetY, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] {
5312 if ( mLayer && !mBlockChangesSignal )
5314 mLayer->setLabelOffset( QPointF( mSpinLabelOffsetX->value(), mSpinLabelOffsetY->value() ) );
5319 if ( mLayer && !mBlockChangesSignal )
5321 mLayer->setLabelOffsetUnit( mLabelOffsetUnitWidget->unit() );
5322 mLayer->setLabelOffsetMapUnitScale( mLabelOffsetUnitWidget->getMapUnitScale() );
5327 connect( mComboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
5328 if ( mLayer && !mBlockChangesSignal )
5331 mLayer->setPlacement( placement );
5332 switch ( placement )
5337 mIntervalWidget->show();
5340 mIntervalWidget->hide();
5347 connect( mSpinAverageAngleLength, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] {
5348 if ( mLayer && !mBlockChangesSignal )
5350 mLayer->setAverageAngleLength( mSpinAverageAngleLength->value() );
5355 if ( mLayer && !mBlockChangesSignal )
5357 mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
5358 mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
5363 connect( mNumberFormatPushButton, &QPushButton::clicked,
this, &QgsLinearReferencingSymbolLayerWidget::changeNumberFormat );
5365 mTextFormatButton->registerExpressionContextGenerator(
this );
5373 if ( !layer || layer->
layerType() != QLatin1String(
"LinearReferencing" ) )
5377 mLayer = qgis::down_cast<QgsLinearReferencingSymbolLayer *>( layer );
5379 mBlockChangesSignal =
true;
5381 mComboPlacement->setCurrentIndex( mComboPlacement->findData( QVariant::fromValue( mLayer->placement() ) ) );
5382 switch ( mLayer->placement() )
5387 mIntervalWidget->show();
5390 mIntervalWidget->hide();
5394 mComboQuantity->setCurrentIndex( mComboQuantity->findData( QVariant::fromValue( mLayer->labelSource() ) ) );
5396 mTextFormatButton->setTextFormat( mLayer->textFormat() );
5397 spinInterval->setValue( mLayer->interval() );
5398 mSpinSkipMultiples->setValue( mLayer->skipMultiplesOf() );
5399 mCheckRotate->setChecked( mLayer->rotateLabels() );
5400 mCheckShowMarker->setChecked( mLayer->showMarker() );
5401 mSpinLabelOffsetX->setValue( mLayer->labelOffset().x() );
5402 mSpinLabelOffsetY->setValue( mLayer->labelOffset().y() );
5403 mLabelOffsetUnitWidget->setUnit( mLayer->labelOffsetUnit() );
5404 mLabelOffsetUnitWidget->setMapUnitScale( mLayer->labelOffsetMapUnitScale() );
5406 mAverageAngleUnit->setUnit( mLayer->averageAngleUnit() );
5407 mAverageAngleUnit->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
5408 mSpinAverageAngleLength->setValue( mLayer->averageAngleLength() );
5410 mSpinAverageAngleLength->setEnabled( mCheckRotate->isChecked() );
5411 mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
5418 mBlockChangesSignal =
false;
5429 mTextFormatButton->setMapCanvas(
context.mapCanvas() );
5430 mTextFormatButton->setMessageBar(
context.messageBar() );
5433void QgsLinearReferencingSymbolLayerWidget::changeNumberFormat()
5443 if ( !mBlockChangesSignal )
5453 QgsNumericFormatSelectorDialog dialog(
this );
5454 dialog.setFormat( mLayer->numericFormat() );
5455 dialog.registerExpressionContextGenerator(
this );
5456 if ( dialog.exec() )
5458 mLayer->setNumericFormat( dialog.format() );
@ CurvePoint
Place symbols at every virtual curve point in the line (used when rendering curved geometry types onl...
@ InnerVertices
Inner vertices (i.e. all vertices except the first and last vertex).
@ LastVertex
Place symbols on the last vertex in the line.
@ CentralPoint
Place symbols at the mid point of the line.
@ SegmentCenter
Place symbols at the center of every line segment.
@ Vertex
Place symbols on every vertex in the line.
@ Interval
Place symbols at regular intervals.
@ FirstVertex
Place symbols on the first vertex in the line.
MarkerClipMode
Marker clipping modes.
@ 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.
@ 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.
@ 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.
@ Absolute
The point count is used as an absolute count of markers.
@ DensityBased
The point count is part of a marker density count.
MarkerShape
Marker shapes.
VerticalAnchorPoint
Marker symbol vertical anchor points.
@ Bottom
Align to bottom of symbol.
@ Center
Align to vertical center of symbol.
@ Baseline
Align to baseline of symbol, e.g. font baseline for font marker symbol layers. Treated as Bottom if n...
@ Top
Align to top of symbol.
LinearReferencingPlacement
Defines how/where the labels should be placed in a linear referencing symbol layer.
@ IntervalZ
Place labels at regular intervals, linearly interpolated using Z values.
@ Vertex
Place labels on every vertex in the line.
@ IntervalM
Place labels at regular intervals, linearly interpolated using M values.
@ IntervalCartesian2D
Place labels at regular intervals, using Cartesian distance calculations on a 2D plane.
LinearReferencingLabelSource
Defines what quantity to use for the labels shown in a linear referencing symbol layer.
@ CartesianDistance2D
Distance along line, calculated using Cartesian calculations on a 2D plane.
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size).
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes).
@ MetersInMapUnits
Meters value as Map units.
@ Conical
Conical (polar) gradient.
@ Radial
Radial (circular) gradient.
SymbolCoordinateReference
Symbol coordinate reference modes.
@ Feature
Relative to feature/shape being rendered.
@ Viewport
Relative to the whole viewport/output device.
QFlags< MarkerLinePlacement > MarkerLinePlacements
HorizontalAnchorPoint
Marker symbol horizontal anchor points.
@ Center
Align to horizontal center of symbol.
@ Right
Align to right side of symbol.
@ Left
Align to left side of symbol.
static const double UI_SCALE_FACTOR
UI scaling factor.
void sourceChanged(const QString &source)
Emitted whenever the file source is changed in the widget.
Animated marker symbol layer class.
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.
A fill symbol layer which renders a marker symbol at the centroid of a polygon geometry.
void setPointOnSurface(bool pointOnSurface)
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.
A line symbol layer type which fills a stroked line with a QgsFillSymbol.
void setMapUnitScale(const QgsMapUnitScale &scale) override
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
A marker symbol layer which displays characters rendered using a font.
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
static QString translateNamedStyle(const QString &namedStyle)
Returns the localized named style of a font, if such a translation is available.
static QString untranslateNamedStyle(const QString &namedStyle)
Returns the english named style of a font, if possible.
static QFont createFont(const QString &family, int pointSize=-1, int weight=-1, bool italic=false)
Creates a font with the specified family.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
static void setFontFamily(QFont &font, const QString &family)
Sets the family for a font object.
A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions.
void setGeometryExpression(const QString &exp)
Set the expression to generate this geometry.
A fill symbol layer which draws a smooth color gradient over a polygon.
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.
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.
A symbol fill consisting of repeated parallel lines.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setLineAngle(double a)
Sets the angle for the parallel lines used to fill the symbol.
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.
void setNumericFormat(QgsNumericFormat *format)
Sets the numeric format used to format the labels for the layer.
QgsNumericFormat * numericFormat() const
Returns the numeric format used to format the labels for the layer.
Line symbol layer type which draws a gradient pattern perpendicularly along a line.
Struct for storing maximum and minimum scales for measurements in map units.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
double size() const
Returns the symbol size.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's size.
A dialog to create a new auxiliary layer.
A fill symbol layer which fills polygon shapes with repeating marker symbols.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setDistanceX(double d)
Sets the horizontal distance between rendered markers in the fill.
void setField(const QString &field)
Sets the field name the property references.
A fill symbol layer which places markers at random locations within polygons.
void setMapUnitScale(const QgsMapUnitScale &scale) override
A fill symbol layer which fills polygons with a repeated raster image.
void setOpacity(double opacity)
Sets the opacity for the raster image used in the fill.
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
Line symbol layer type which draws line sections using a raster image file.
void setPath(const QString &path)
Set the raster image path.
void setOpacity(double opacity)
Set the line opacity.
Raster marker symbol layer class.
void setPath(const QString &path)
Set the marker raster image path.
A fill symbol layer which fills polygons with a repeated SVG file.
void setPatternWidth(double width)
Sets the width to render the SVG content as within the fill (i.e.
Stores properties relating to a screen.
A fill symbol layer which applies a gradient from the outer edges of a symbol to the inside.
Renders polygons using a single fill and stroke color.
void setBrushStyle(Qt::BrushStyle style)
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
void setMapUnitScale(const QgsMapUnitScale &scale) override
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.
Simple marker symbol layer, consisting of a rendered shape with solid fill color and a stroke.
void setColor(const QColor &color) override
Sets the "representative" color for the symbol layer.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the marker's stroke join style (e.g., miter, bevel, etc).
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
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.
A marker symbol layer which renders an SVG graphic.
QColor fillColor() const override
Returns the fill color for the symbol layer.
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.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
void setMapUnitScale(const QgsMapUnitScale &scale) override
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
double strokeWidth() const
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
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.
Abstract base class for symbol layers.
Property
Data definable properties.
@ SkipMultiples
Skip multiples of.
@ GradientType
Gradient fill type.
@ SecondaryColor
Secondary color (eg for gradient fills).
@ File
Filename, eg for svg files.
@ VerticalAnchor
Vertical anchor point.
@ GradientReference2Y
Gradient reference point 2 y.
@ GradientReference1X
Gradient reference point 1 x.
@ OffsetY
Vertical offset.
@ OffsetX
Horizontal offset.
@ GradientReference1Y
Gradient reference point 1 y.
@ DashPatternOffset
Dash pattern offset,.
@ GradientSpread
Gradient spread mode.
@ OffsetAlongLine
Offset along line.
@ CustomDash
Custom dash pattern.
@ ShapeburstMaxDistance
Shapeburst fill from edge distance.
@ HorizontalAnchor
Horizontal anchor point.
@ StrokeStyle
Stroke style (eg solid, dashed).
@ Name
Name, eg shape name for simple markers.
@ DistanceY
Vertical distance between points.
@ DensityArea
Density area.
@ ClipPoints
Whether markers should be clipped to polygon boundaries.
@ LineClipping
Line clipping mode.
@ ShapeburstIgnoreRings
Shapeburst ignore rings.
@ Character
Character, eg for font marker symbol layers.
@ ShapeburstUseWholeShape
Shapeburst use whole shape.
@ DisplacementX
Horizontal displacement.
@ ShowMarker
Show markers.
@ CoordinateMode
Gradient coordinate mode.
@ FillStyle
Fill style (eg solid, dots).
@ GradientReference2X
Gradient reference point 2 x.
@ StrokeColor
Stroke color.
@ TrimStart
Trim distance from start of line.
@ CapStyle
Line cap style.
@ BlurRadius
Shapeburst blur radius.
@ Placement
Line marker placement.
@ MarkerClipping
Marker clipping mode.
@ RandomSeed
Random number seed.
@ LineAngle
Line angle, or angle of hash lines for hash line symbols.
@ JoinStyle
Line join style.
@ RandomOffsetY
Random offset Y.
@ DisplacementY
Vertical displacement.
@ DistanceX
Horizontal distance between points.
@ AverageAngleLength
Length to average symbol angles over.
@ GradientReference1IsCentroid
Gradient reference point 1 is centroid.
@ Interval
Line marker interval.
@ StrokeWidth
Stroke width.
@ GradientReference2IsCentroid
Gradient reference point 2 is centroid.
@ LineDistance
Distance between lines, or length of lines for hash line symbols.
@ RandomOffsetX
Random offset X.
@ TrimEnd
Trim distance from end of line.
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.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Base class for templated line symbols, e.g.
void setMapUnitScale(const QgsMapUnitScale &scale) final
QList< Qgis::RenderUnit > RenderUnitList
List of render units.
Represents a vector layer which manages a vector based dataset.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
QList< QgsSymbolLayer * > QgsSymbolLayerList
Single variable definition for use within a QgsExpressionContextScope.