21#include <QColorDialog>
23#include "moc_qgsellipsesymbollayerwidget.cpp"
39 connect( mShapeListWidget, &QListWidget::itemSelectionChanged,
this, &QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged );
40 connect( mWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged );
41 connect( mHeightSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged );
42 connect( mRotationSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged );
43 connect( mStrokeStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
44 connect( mStrokeWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
51 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
52 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
59 btnChangeColorFill->setAllowOpacity(
true );
60 btnChangeColorFill->setColorDialogTitle( tr(
"Select Fill Color" ) );
61 btnChangeColorFill->setContext( QStringLiteral(
"symbology" ) );
62 btnChangeColorFill->setShowNoColor(
true );
63 btnChangeColorFill->setNoColorString( tr(
"Transparent Fill" ) );
64 btnChangeColorStroke->setAllowOpacity(
true );
65 btnChangeColorStroke->setColorDialogTitle( tr(
"Select Stroke Color" ) );
66 btnChangeColorStroke->setContext( QStringLiteral(
"symbology" ) );
67 btnChangeColorStroke->setShowNoColor(
true );
68 btnChangeColorStroke->setNoColorString( tr(
"Transparent Stroke" ) );
70 mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
71 mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
73 spinOffsetX->setClearValue( 0.0 );
74 spinOffsetY->setClearValue( 0.0 );
75 mRotationSpinBox->setClearValue( 0.0 );
77 int size = mShapeListWidget->iconSize().width();
78 size = std::max( 30,
static_cast<int>( std::round(
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 3 ) ) );
79 mShapeListWidget->setGridSize( QSize( size * 1.2, size * 1.2 ) );
80 mShapeListWidget->setIconSize( QSize( size, size ) );
82 const double markerSize = size * 0.8;
95 QListWidgetItem *item =
new QListWidgetItem( icon, QString(), mShapeListWidget );
96 item->setData( Qt::UserRole,
static_cast<int>( shape ) );
101 mShapeListWidget->setMinimumHeight( mShapeListWidget->gridSize().height() * 2.1 );
103 connect( spinOffsetX,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
104 connect( spinOffsetY,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
105 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penJoinStyleChanged );
106 connect( cboCapStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penCapStyleChanged );
111 if ( !layer || layer->
layerType() != QLatin1String(
"EllipseMarker" ) )
117 mWidthSpinBox->setValue(
mLayer->symbolWidth() );
118 mHeightSpinBox->setValue(
mLayer->symbolHeight() );
119 mRotationSpinBox->setValue(
mLayer->angle() );
120 mStrokeStyleComboBox->setPenStyle(
mLayer->strokeStyle() );
121 mStrokeWidthSpinBox->setValue(
mLayer->strokeWidth() );
123 btnChangeColorFill->setColor(
mLayer->fillColor() );
126 for (
int i = 0; i < mShapeListWidget->count(); ++i )
130 mShapeListWidget->setCurrentRow( i );
137 blockComboSignals(
true );
138 mSymbolWidthUnitWidget->setUnit(
mLayer->symbolWidthUnit() );
139 mSymbolWidthUnitWidget->setMapUnitScale(
mLayer->symbolWidthMapUnitScale() );
140 mStrokeWidthUnitWidget->setUnit(
mLayer->strokeWidthUnit() );
141 mStrokeWidthUnitWidget->setMapUnitScale(
mLayer->strokeWidthMapUnitScale() );
142 mSymbolHeightUnitWidget->setUnit(
mLayer->symbolHeightUnit() );
143 mSymbolHeightUnitWidget->setMapUnitScale(
mLayer->symbolHeightMapUnitScale() );
144 mOffsetUnitWidget->setUnit(
mLayer->offsetUnit() );
145 mOffsetUnitWidget->setMapUnitScale(
mLayer->offsetMapUnitScale() );
146 const QPointF offsetPt =
mLayer->offset();
147 spinOffsetX->setValue( offsetPt.x() );
148 spinOffsetY->setValue( offsetPt.y() );
149 mHorizontalAnchorComboBox->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->horizontalAnchorPoint() ) ) );
150 mVerticalAnchorComboBox->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->verticalAnchorPoint() ) ) );
151 cboJoinStyle->setPenJoinStyle(
mLayer->penJoinStyle() );
152 cboCapStyle->setPenCapStyle(
mLayer->penCapStyle() );
153 blockComboSignals(
false );
175void QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged()
185void QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged(
double d )
189 mLayer->setSymbolWidth( d );
194void QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged(
double d )
198 mLayer->setSymbolHeight( d );
203void QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged(
double d )
212void QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged(
int index )
218 mLayer->setStrokeStyle( mStrokeStyleComboBox->penStyle() );
223void QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
227 mLayer->setStrokeWidth( d );
232void QgsEllipseSymbolLayerWidget::btnChangeColorStroke_colorChanged(
const QColor &newColor )
239 mLayer->setStrokeColor( newColor );
243void QgsEllipseSymbolLayerWidget::btnChangeColorFill_colorChanged(
const QColor &newColor )
250 mLayer->setFillColor( newColor );
254void QgsEllipseSymbolLayerWidget::mSymbolWidthUnitWidget_changed()
258 mLayer->setSymbolWidthUnit( mSymbolWidthUnitWidget->unit() );
259 mLayer->setSymbolWidthMapUnitScale( mSymbolWidthUnitWidget->getMapUnitScale() );
264void QgsEllipseSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
268 mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
269 mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
274void QgsEllipseSymbolLayerWidget::mSymbolHeightUnitWidget_changed()
278 mLayer->setSymbolHeightUnit( mSymbolHeightUnitWidget->unit() );
279 mLayer->setSymbolHeightMapUnitScale( mSymbolHeightUnitWidget->getMapUnitScale() );
284void QgsEllipseSymbolLayerWidget::mOffsetUnitWidget_changed()
288 mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
289 mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
294void QgsEllipseSymbolLayerWidget::penJoinStyleChanged()
296 mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
300void QgsEllipseSymbolLayerWidget::penCapStyleChanged()
302 mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
306void QgsEllipseSymbolLayerWidget::blockComboSignals(
bool block )
308 mSymbolWidthUnitWidget->blockSignals( block );
309 mStrokeWidthUnitWidget->blockSignals( block );
310 mSymbolHeightUnitWidget->blockSignals( block );
311 mHorizontalAnchorComboBox->blockSignals( block );
312 mVerticalAnchorComboBox->blockSignals( block );
313 mSymbolWidthUnitWidget->blockSignals( block );
314 mStrokeWidthUnitWidget->blockSignals( block );
315 mSymbolHeightUnitWidget->blockSignals( block );
316 mOffsetUnitWidget->blockSignals( block );
317 cboJoinStyle->blockSignals( block );
318 cboCapStyle->blockSignals( block );
321void QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
330void QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
339void QgsEllipseSymbolLayerWidget::setOffset()
341 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.