19 #include <QColorDialog>
26 connect( mShapeListWidget, &QListWidget::itemSelectionChanged,
this, &QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged );
27 connect( mWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged );
28 connect( mHeightSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged );
29 connect( mRotationSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged );
30 connect( mStrokeStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
31 connect( mStrokeWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
38 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
39 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
50 btnChangeColorFill->setAllowOpacity(
true );
51 btnChangeColorFill->setColorDialogTitle( tr(
"Select Fill Color" ) );
52 btnChangeColorFill->setContext( QStringLiteral(
"symbology" ) );
53 btnChangeColorFill->setShowNoColor(
true );
54 btnChangeColorFill->setNoColorString( tr(
"Transparent Fill" ) );
55 btnChangeColorStroke->setAllowOpacity(
true );
56 btnChangeColorStroke->setColorDialogTitle( tr(
"Select Stroke Color" ) );
57 btnChangeColorStroke->setContext( QStringLiteral(
"symbology" ) );
58 btnChangeColorStroke->setShowNoColor(
true );
59 btnChangeColorStroke->setNoColorString( tr(
"Transparent Stroke" ) );
61 mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
62 mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
64 spinOffsetX->setClearValue( 0.0 );
65 spinOffsetY->setClearValue( 0.0 );
66 mRotationSpinBox->setClearValue( 0.0 );
68 int size = mShapeListWidget->iconSize().width();
69 size = std::max( 30,
static_cast< int >( std::round(
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 3 ) ) );
70 mShapeListWidget->setGridSize( QSize( size * 1.2, size * 1.2 ) );
71 mShapeListWidget->setIconSize( QSize( size, size ) );
73 double markerSize = size * 0.8;
86 QListWidgetItem *item =
new QListWidgetItem( icon, QString(), mShapeListWidget );
87 item->setData( Qt::UserRole,
static_cast< int >( shape ) );
92 mShapeListWidget->setMinimumHeight( mShapeListWidget->gridSize().height() * 2.1 );
94 connect( spinOffsetX,
static_cast < void (
QgsDoubleSpinBox::* )(
double )
> ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
95 connect( spinOffsetY,
static_cast < void (
QgsDoubleSpinBox::* )(
double )
> ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
96 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penJoinStyleChanged );
97 connect( cboCapStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penCapStyleChanged );
102 if ( !layer || layer->
layerType() != QLatin1String(
"EllipseMarker" ) )
117 for (
int i = 0; i < mShapeListWidget->count(); ++i )
121 mShapeListWidget->setCurrentRow( i );
128 blockComboSignals(
true );
138 spinOffsetX->setValue( offsetPt.x() );
139 spinOffsetY->setValue( offsetPt.y() );
144 blockComboSignals(
false );
167 void QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged()
177 void QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged(
double d )
186 void QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged(
double d )
195 void QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged(
double d )
204 void QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged(
int index )
215 void QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
224 void QgsEllipseSymbolLayerWidget::btnChangeColorStroke_colorChanged(
const QColor &newColor )
235 void QgsEllipseSymbolLayerWidget::btnChangeColorFill_colorChanged(
const QColor &newColor )
246 void QgsEllipseSymbolLayerWidget::mSymbolWidthUnitWidget_changed()
256 void QgsEllipseSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
266 void QgsEllipseSymbolLayerWidget::mSymbolHeightUnitWidget_changed()
276 void QgsEllipseSymbolLayerWidget::mOffsetUnitWidget_changed()
286 void QgsEllipseSymbolLayerWidget::penJoinStyleChanged()
292 void QgsEllipseSymbolLayerWidget::penCapStyleChanged()
298 void QgsEllipseSymbolLayerWidget::blockComboSignals(
bool block )
300 mSymbolWidthUnitWidget->blockSignals( block );
301 mStrokeWidthUnitWidget->blockSignals( block );
302 mSymbolHeightUnitWidget->blockSignals( block );
303 mHorizontalAnchorComboBox->blockSignals( block );
304 mVerticalAnchorComboBox->blockSignals( block );
305 mSymbolWidthUnitWidget->blockSignals( block );
306 mStrokeWidthUnitWidget->blockSignals( block );
307 mSymbolHeightUnitWidget->blockSignals( block );
308 mOffsetUnitWidget->blockSignals( block );
309 cboJoinStyle->blockSignals( block );
310 cboCapStyle->blockSignals( block );
313 void QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int index )
322 void QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int index )
331 void QgsEllipseSymbolLayerWidget::setOffset()
333 mLayer->
setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
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)
const QgsMapUnitScale & symbolHeightMapUnitScale() const
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & strokeWidthMapUnitScale() const
void setSymbolWidth(double w)
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
double strokeWidth() const
void setStrokeColor(const QColor &c) override
Set stroke color.
void setStrokeStyle(Qt::PenStyle strokeStyle)
Shape
Marker symbol shapes.
QgsUnitTypes::RenderUnit symbolHeightUnit() const
Returns the units for the symbol's height.
QColor fillColor() const override
Gets fill color.
QgsEllipseSymbolLayer::Shape shape() const
Returns the shape for the rendered ellipse marker symbol.
void setFillColor(const QColor &c) override
Set fill color.
void setShape(QgsEllipseSymbolLayer::Shape shape)
Sets the rendered ellipse marker shape.
static QList< QgsEllipseSymbolLayer::Shape > availableShapes()
Returns a list of all available shape types.
QgsUnitTypes::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
Qt::PenStyle strokeStyle() const
static QString encodeShape(QgsEllipseSymbolLayer::Shape shape)
Encodes a shape to its string representation.
double symbolWidth() const
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QColor strokeColor() const override
Gets stroke color.
void setSymbolWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's width.
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 setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
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)
void setSymbolHeightUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's height.
const QgsMapUnitScale & symbolWidthMapUnitScale() const
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
HorizontalAnchorPoint
Symbol horizontal anchor points.
void setAngle(double angle)
Sets the rotation angle for the marker.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
VerticalAnchorPoint
Symbol vertical anchor points.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
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.
static QIcon symbolLayerPreviewIcon(const QgsSymbolLayer *layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
Draws a symbol layer preview to an icon.
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
@ PropertyHorizontalAnchor
Horizontal anchor point.
@ PropertyCapStyle
Line cap style.
@ PropertyAngle
Symbol angle.
@ PropertyVerticalAnchor
Vertical anchor point.
@ PropertyJoinStyle
Line join style.
@ PropertyOffset
Symbol offset.
@ PropertyStrokeWidth
Stroke width.
@ PropertyFillColor
Fill color.
@ PropertyHeight
Symbol height.
@ PropertyName
Name, eg shape name for simple markers.
@ PropertyStrokeColor
Stroke color.
@ PropertyWidth
Symbol width.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void setColor(const QColor &color)
The fill color.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderPoints
Points (e.g., for font sizes)
@ RenderMillimeters
Millimeters.
@ RenderMapUnits
Map units.
Represents a vector layer which manages a vector based data sets.