21#include <QColorDialog>
24#include "moc_qgsellipsesymbollayerwidget.cpp"
26using namespace Qt::StringLiterals;
42 connect( mShapeListWidget, &QListWidget::itemSelectionChanged,
this, &QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged );
43 connect( mWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged );
44 connect( mHeightSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged );
45 connect( mRotationSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged );
46 connect( mStrokeStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
47 connect( mStrokeWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
54 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
55 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
57 mSymbolWidthUnitWidget->setUnits(
60 mSymbolHeightUnitWidget->setUnits(
63 mStrokeWidthUnitWidget->setUnits(
66 mOffsetUnitWidget->setUnits(
70 btnChangeColorFill->setAllowOpacity(
true );
71 btnChangeColorFill->setColorDialogTitle( tr(
"Select Fill Color" ) );
72 btnChangeColorFill->setContext( u
"symbology"_s );
73 btnChangeColorFill->setShowNoColor(
true );
74 btnChangeColorFill->setNoColorString( tr(
"Transparent Fill" ) );
75 btnChangeColorFill->setOpaqueColorString( tr(
"Opaque Fill" ) );
76 btnChangeColorStroke->setAllowOpacity(
true );
77 btnChangeColorStroke->setColorDialogTitle( tr(
"Select Stroke Color" ) );
78 btnChangeColorStroke->setContext( u
"symbology"_s );
79 btnChangeColorStroke->setShowNoColor(
true );
80 btnChangeColorStroke->setNoColorString( tr(
"Transparent Stroke" ) );
81 btnChangeColorStroke->setOpaqueColorString( tr(
"Opaque Stroke" ) );
83 mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
84 mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
86 spinOffsetX->setClearValue( 0.0 );
87 spinOffsetY->setClearValue( 0.0 );
88 mRotationSpinBox->setClearValue( 0.0 );
90 int size = mShapeListWidget->iconSize().width();
91 size = std::max( 30,
static_cast<int>( std::round(
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 3 ) ) );
92 mShapeListWidget->setGridSize( QSize( size * 1.2, size * 1.2 ) );
93 mShapeListWidget->setIconSize( QSize( size, size ) );
95 const double markerSize = size * 0.8;
109 QListWidgetItem *item =
new QListWidgetItem( icon, QString(), mShapeListWidget );
110 item->setData( Qt::UserRole,
static_cast<int>( shape ) );
115 mShapeListWidget->setMinimumHeight( mShapeListWidget->gridSize().height() * 2.1 );
117 connect( spinOffsetX,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
118 connect( spinOffsetY,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
119 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penJoinStyleChanged );
120 connect( cboCapStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penCapStyleChanged );
125 if ( !layer || layer->
layerType() !=
"EllipseMarker"_L1 )
131 mWidthSpinBox->setValue(
mLayer->symbolWidth() );
132 mHeightSpinBox->setValue(
mLayer->symbolHeight() );
133 mRotationSpinBox->setValue(
mLayer->angle() );
134 mStrokeStyleComboBox->setPenStyle(
mLayer->strokeStyle() );
135 mStrokeWidthSpinBox->setValue(
mLayer->strokeWidth() );
137 btnChangeColorFill->setColor(
mLayer->fillColor() );
140 for (
int i = 0; i < mShapeListWidget->count(); ++i )
144 mShapeListWidget->setCurrentRow( i );
151 blockComboSignals(
true );
152 mSymbolWidthUnitWidget->setUnit(
mLayer->symbolWidthUnit() );
153 mSymbolWidthUnitWidget->setMapUnitScale(
mLayer->symbolWidthMapUnitScale() );
154 mStrokeWidthUnitWidget->setUnit(
mLayer->strokeWidthUnit() );
155 mStrokeWidthUnitWidget->setMapUnitScale(
mLayer->strokeWidthMapUnitScale() );
156 mSymbolHeightUnitWidget->setUnit(
mLayer->symbolHeightUnit() );
157 mSymbolHeightUnitWidget->setMapUnitScale(
mLayer->symbolHeightMapUnitScale() );
158 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
159 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
160 const QPointF offsetPt =
mLayer->offset();
161 spinOffsetX->setValue( offsetPt.x() );
162 spinOffsetY->setValue( offsetPt.y() );
163 mHorizontalAnchorComboBox->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->horizontalAnchorPoint() ) ) );
164 mVerticalAnchorComboBox->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->verticalAnchorPoint() ) ) );
165 cboJoinStyle->setPenJoinStyle(
mLayer->penJoinStyle() );
166 cboCapStyle->setPenCapStyle(
mLayer->penCapStyle() );
167 blockComboSignals(
false );
189void QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged()
199void QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged(
double d )
203 mLayer->setSymbolWidth( d );
208void QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged(
double d )
212 mLayer->setSymbolHeight( d );
217void QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged(
double d )
226void QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged(
int index )
232 mLayer->setStrokeStyle( mStrokeStyleComboBox->penStyle() );
237void QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
241 mLayer->setStrokeWidth( d );
246void QgsEllipseSymbolLayerWidget::btnChangeColorStroke_colorChanged(
const QColor &newColor )
253 mLayer->setStrokeColor( newColor );
257void QgsEllipseSymbolLayerWidget::btnChangeColorFill_colorChanged(
const QColor &newColor )
264 mLayer->setFillColor( newColor );
268void QgsEllipseSymbolLayerWidget::mSymbolWidthUnitWidget_changed()
272 mLayer->setSymbolWidthUnit( mSymbolWidthUnitWidget->unit() );
273 mLayer->setSymbolWidthMapUnitScale( mSymbolWidthUnitWidget->getMapUnitScale() );
278void QgsEllipseSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
282 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
283 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
288void QgsEllipseSymbolLayerWidget::mSymbolHeightUnitWidget_changed()
292 mLayer->setSymbolHeightUnit( mSymbolHeightUnitWidget->unit() );
293 mLayer->setSymbolHeightMapUnitScale( mSymbolHeightUnitWidget->getMapUnitScale() );
298void QgsEllipseSymbolLayerWidget::mOffsetUnitWidget_changed()
302 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
303 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
308void QgsEllipseSymbolLayerWidget::penJoinStyleChanged()
310 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
314void QgsEllipseSymbolLayerWidget::penCapStyleChanged()
316 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
320void QgsEllipseSymbolLayerWidget::blockComboSignals(
bool block )
322 mSymbolWidthUnitWidget->blockSignals( block );
323 mStrokeWidthUnitWidget->blockSignals( block );
324 mSymbolHeightUnitWidget->blockSignals( block );
325 mHorizontalAnchorComboBox->blockSignals( block );
326 mVerticalAnchorComboBox->blockSignals( block );
327 mSymbolWidthUnitWidget->blockSignals( block );
328 mStrokeWidthUnitWidget->blockSignals( block );
329 mSymbolHeightUnitWidget->blockSignals( block );
330 mOffsetUnitWidget->blockSignals( block );
331 cboJoinStyle->blockSignals( block );
332 cboCapStyle->blockSignals( block );
335void QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
344void QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
353void QgsEllipseSymbolLayerWidget::setOffset()
355 mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
VerticalAnchorPoint
Marker symbol vertical anchor points.
@ Bottom
Align to bottom of symbol.
@ Center
Align to vertical center of symbol.
@ Top
Align to top of symbol.
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes).
@ MetersInMapUnits
Meters value as Map units.
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.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
A symbol layer for rendering objects with major and minor axis (e.g.
void setSymbolWidth(double w)
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
Shape
Marker symbol shapes.
QgsEllipseSymbolLayer::Shape shape() const
Returns the shape for the rendered ellipse marker symbol.
void setFillColor(const QColor &c) override
Sets the fill color for the symbol layer.
void setShape(QgsEllipseSymbolLayer::Shape shape)
Sets the rendered ellipse marker shape.
static QList< QgsEllipseSymbolLayer::Shape > availableShapes()
Returns a list of all available shape types.
static QString encodeShape(QgsEllipseSymbolLayer::Shape shape)
Encodes a shape to its string representation.
void setSymbolHeightUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's height.
static bool shapeIsFilled(const QgsEllipseSymbolLayer::Shape &shape)
Returns true if a shape has a fill.
void setSymbolWidthUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's width.
void setSymbolHeight(double h)
Struct for storing maximum and minimum scales for measurements in map units.
Stores properties relating to a screen.
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.
Abstract base class for symbol layers.
@ VerticalAnchor
Vertical anchor point.
@ HorizontalAnchor
Horizontal anchor point.
@ StrokeStyle
Stroke style (eg solid, dashed).
@ Name
Name, eg shape name for simple markers.
@ StrokeColor
Stroke color.
@ CapStyle
Line cap style.
@ JoinStyle
Line join style.
@ StrokeWidth
Stroke width.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
Represents a vector layer which manages a vector based dataset.