16#include "moc_qgsellipsesymbollayerwidget.cpp"
20#include <QColorDialog>
36 connect( mShapeListWidget, &QListWidget::itemSelectionChanged,
this, &QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged );
37 connect( mWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged );
38 connect( mHeightSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged );
39 connect( mRotationSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged );
40 connect( mStrokeStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
41 connect( mStrokeWidthSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
48 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
49 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
56 btnChangeColorFill->setAllowOpacity(
true );
57 btnChangeColorFill->setColorDialogTitle( tr(
"Select Fill Color" ) );
58 btnChangeColorFill->setContext( QStringLiteral(
"symbology" ) );
59 btnChangeColorFill->setShowNoColor(
true );
60 btnChangeColorFill->setNoColorString( tr(
"Transparent Fill" ) );
61 btnChangeColorStroke->setAllowOpacity(
true );
62 btnChangeColorStroke->setColorDialogTitle( tr(
"Select Stroke Color" ) );
63 btnChangeColorStroke->setContext( QStringLiteral(
"symbology" ) );
64 btnChangeColorStroke->setShowNoColor(
true );
65 btnChangeColorStroke->setNoColorString( tr(
"Transparent Stroke" ) );
67 mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
68 mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
70 spinOffsetX->setClearValue( 0.0 );
71 spinOffsetY->setClearValue( 0.0 );
72 mRotationSpinBox->setClearValue( 0.0 );
74 int size = mShapeListWidget->iconSize().width();
75 size = std::max( 30,
static_cast<int>( std::round(
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 3 ) ) );
76 mShapeListWidget->setGridSize( QSize( size * 1.2, size * 1.2 ) );
77 mShapeListWidget->setIconSize( QSize( size, size ) );
79 const double markerSize = size * 0.8;
92 QListWidgetItem *item =
new QListWidgetItem( icon, QString(), mShapeListWidget );
93 item->setData( Qt::UserRole,
static_cast<int>( shape ) );
98 mShapeListWidget->setMinimumHeight( mShapeListWidget->gridSize().height() * 2.1 );
100 connect( spinOffsetX,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
101 connect( spinOffsetY,
static_cast<void (
QgsDoubleSpinBox::* )(
double )
>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
102 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penJoinStyleChanged );
103 connect( cboCapStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penCapStyleChanged );
108 if ( !layer || layer->
layerType() != QLatin1String(
"EllipseMarker" ) )
123 for (
int i = 0; i < mShapeListWidget->count(); ++i )
127 mShapeListWidget->setCurrentRow( i );
134 blockComboSignals(
true );
144 spinOffsetX->setValue( offsetPt.x() );
145 spinOffsetY->setValue( offsetPt.y() );
146 mHorizontalAnchorComboBox->setCurrentIndex( mHorizontalAnchorComboBox->findData( QVariant::fromValue(
mLayer->
horizontalAnchorPoint() ) ) );
147 mVerticalAnchorComboBox->setCurrentIndex( mVerticalAnchorComboBox->findData( QVariant::fromValue(
mLayer->
verticalAnchorPoint() ) ) );
150 blockComboSignals(
false );
172void QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged()
182void QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged(
double d )
191void QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged(
double d )
200void QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged(
double d )
209void QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged(
int index )
220void QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
229void QgsEllipseSymbolLayerWidget::btnChangeColorStroke_colorChanged(
const QColor &newColor )
240void QgsEllipseSymbolLayerWidget::btnChangeColorFill_colorChanged(
const QColor &newColor )
251void QgsEllipseSymbolLayerWidget::mSymbolWidthUnitWidget_changed()
261void QgsEllipseSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
271void QgsEllipseSymbolLayerWidget::mSymbolHeightUnitWidget_changed()
281void QgsEllipseSymbolLayerWidget::mOffsetUnitWidget_changed()
291void QgsEllipseSymbolLayerWidget::penJoinStyleChanged()
297void QgsEllipseSymbolLayerWidget::penCapStyleChanged()
303void QgsEllipseSymbolLayerWidget::blockComboSignals(
bool block )
305 mSymbolWidthUnitWidget->blockSignals( block );
306 mStrokeWidthUnitWidget->blockSignals( block );
307 mSymbolHeightUnitWidget->blockSignals( block );
308 mHorizontalAnchorComboBox->blockSignals( block );
309 mVerticalAnchorComboBox->blockSignals( block );
310 mSymbolWidthUnitWidget->blockSignals( block );
311 mStrokeWidthUnitWidget->blockSignals( block );
312 mSymbolHeightUnitWidget->blockSignals( block );
313 mOffsetUnitWidget->blockSignals( block );
314 cboJoinStyle->blockSignals( block );
315 cboCapStyle->blockSignals( block );
318void QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int )
327void QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int )
336void QgsEllipseSymbolLayerWidget::setOffset()
338 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 setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, etc).
void setStrokeWidth(double w)
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
Qgis::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Qgis::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
void setSymbolWidth(double w)
double strokeWidth() const
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
void setStrokeStyle(Qt::PenStyle strokeStyle)
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's stroke width.
Shape
Marker symbol shapes.
QColor fillColor() const override
Returns the fill color for the symbol layer.
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.
const QgsMapUnitScale & symbolHeightMapUnitScale() const
Qt::PenStyle strokeStyle() const
const QgsMapUnitScale & symbolWidthMapUnitScale() const
static QString encodeShape(QgsEllipseSymbolLayer::Shape shape)
Encodes a shape to its string representation.
double symbolWidth() const
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
void setSymbolHeightUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's height.
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
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.
Qgis::RenderUnit symbolHeightUnit() const
Returns the units for the symbol's height.
Qt::PenJoinStyle penJoinStyle() const
Gets stroke join style.
Qt::PenCapStyle penCapStyle() const
Returns the marker's stroke cap style (e.g., flat, round, etc).
double symbolHeight() const
void setSymbolHeight(double h)
Struct for storing maximum and minimum scales for measurements in map units.
void setVerticalAnchorPoint(Qgis::VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's offset.
void setAngle(double angle)
Sets the rotation angle for the marker.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
Qgis::VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
void setHorizontalAnchorPoint(Qgis::HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
Qgis::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
Qgis::HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
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.
@ 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 data sets.