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 btnChangeColorStroke->setAllowOpacity(
true );
76 btnChangeColorStroke->setColorDialogTitle( tr(
"Select Stroke Color" ) );
77 btnChangeColorStroke->setContext( u
"symbology"_s );
78 btnChangeColorStroke->setShowNoColor(
true );
79 btnChangeColorStroke->setNoColorString( tr(
"Transparent Stroke" ) );
81 mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
82 mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
84 spinOffsetX->setClearValue( 0.0 );
85 spinOffsetY->setClearValue( 0.0 );
86 mRotationSpinBox->setClearValue( 0.0 );
88 int size = mShapeListWidget->iconSize().width();
89 size = std::max( 30,
static_cast<int>( std::round(
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 3 ) ) );
90 mShapeListWidget->setGridSize( QSize( size * 1.2, size * 1.2 ) );
91 mShapeListWidget->setIconSize( QSize( size, size ) );
93 const double markerSize = size * 0.8;
107 QListWidgetItem *item =
new QListWidgetItem( icon, QString(), mShapeListWidget );
108 item->setData( Qt::UserRole,
static_cast<int>( shape ) );
113 mShapeListWidget->setMinimumHeight( mShapeListWidget->gridSize().height() * 2.1 );
115 connect( spinOffsetX,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
116 connect( spinOffsetY,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
117 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penJoinStyleChanged );
118 connect( cboCapStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penCapStyleChanged );
123 if ( !layer || layer->
layerType() !=
"EllipseMarker"_L1 )
129 mWidthSpinBox->setValue(
mLayer->symbolWidth() );
130 mHeightSpinBox->setValue(
mLayer->symbolHeight() );
131 mRotationSpinBox->setValue(
mLayer->angle() );
132 mStrokeStyleComboBox->setPenStyle(
mLayer->strokeStyle() );
133 mStrokeWidthSpinBox->setValue(
mLayer->strokeWidth() );
135 btnChangeColorFill->setColor(
mLayer->fillColor() );
138 for (
int i = 0; i < mShapeListWidget->count(); ++i )
142 mShapeListWidget->setCurrentRow( i );
149 blockComboSignals(
true );
150 mSymbolWidthUnitWidget->setUnit(
mLayer->symbolWidthUnit() );
151 mSymbolWidthUnitWidget->setMapUnitScale(
mLayer->symbolWidthMapUnitScale() );
152 mStrokeWidthUnitWidget->setUnit(
mLayer->strokeWidthUnit() );
153 mStrokeWidthUnitWidget->setMapUnitScale(
mLayer->strokeWidthMapUnitScale() );
154 mSymbolHeightUnitWidget->setUnit(
mLayer->symbolHeightUnit() );
155 mSymbolHeightUnitWidget->setMapUnitScale(
mLayer->symbolHeightMapUnitScale() );
156 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
157 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
158 const QPointF offsetPt =
mLayer->offset();
159 spinOffsetX->setValue( offsetPt.x() );
160 spinOffsetY->setValue( offsetPt.y() );
161 mHorizontalAnchorComboBox->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->horizontalAnchorPoint() ) ) );
162 mVerticalAnchorComboBox->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->verticalAnchorPoint() ) ) );
163 cboJoinStyle->setPenJoinStyle(
mLayer->penJoinStyle() );
164 cboCapStyle->setPenCapStyle(
mLayer->penCapStyle() );
165 blockComboSignals(
false );
187void QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged()
197void QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged(
double d )
201 mLayer->setSymbolWidth( d );
206void QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged(
double d )
210 mLayer->setSymbolHeight( d );
215void QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged(
double d )
224void QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged(
int index )
230 mLayer->setStrokeStyle( mStrokeStyleComboBox->penStyle() );
235void QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
239 mLayer->setStrokeWidth( d );
244void QgsEllipseSymbolLayerWidget::btnChangeColorStroke_colorChanged(
const QColor &newColor )
251 mLayer->setStrokeColor( newColor );
255void QgsEllipseSymbolLayerWidget::btnChangeColorFill_colorChanged(
const QColor &newColor )
262 mLayer->setFillColor( newColor );
266void QgsEllipseSymbolLayerWidget::mSymbolWidthUnitWidget_changed()
270 mLayer->setSymbolWidthUnit( mSymbolWidthUnitWidget->unit() );
271 mLayer->setSymbolWidthMapUnitScale( mSymbolWidthUnitWidget->getMapUnitScale() );
276void QgsEllipseSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
280 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
281 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
286void QgsEllipseSymbolLayerWidget::mSymbolHeightUnitWidget_changed()
290 mLayer->setSymbolHeightUnit( mSymbolHeightUnitWidget->unit() );
291 mLayer->setSymbolHeightMapUnitScale( mSymbolHeightUnitWidget->getMapUnitScale() );
296void QgsEllipseSymbolLayerWidget::mOffsetUnitWidget_changed()
300 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
301 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
306void QgsEllipseSymbolLayerWidget::penJoinStyleChanged()
308 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
312void QgsEllipseSymbolLayerWidget::penCapStyleChanged()
314 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
318void QgsEllipseSymbolLayerWidget::blockComboSignals(
bool block )
320 mSymbolWidthUnitWidget->blockSignals( block );
321 mStrokeWidthUnitWidget->blockSignals( block );
322 mSymbolHeightUnitWidget->blockSignals( block );
323 mHorizontalAnchorComboBox->blockSignals( block );
324 mVerticalAnchorComboBox->blockSignals( block );
325 mSymbolWidthUnitWidget->blockSignals( block );
326 mStrokeWidthUnitWidget->blockSignals( block );
327 mSymbolHeightUnitWidget->blockSignals( block );
328 mOffsetUnitWidget->blockSignals( block );
329 cboJoinStyle->blockSignals( block );
330 cboCapStyle->blockSignals( block );
333void QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
342void QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
351void QgsEllipseSymbolLayerWidget::setOffset()
353 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.