18 #include <QColorDialog> 25 connect( mShapeListWidget, &QListWidget::itemSelectionChanged,
this, &QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged );
26 connect( mWidthSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged );
27 connect( mHeightSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged );
28 connect( mRotationSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged );
29 connect( mStrokeStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
30 connect( mStrokeWidthSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
37 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
38 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
49 btnChangeColorFill->setAllowOpacity(
true );
50 btnChangeColorFill->setColorDialogTitle( tr(
"Select Fill Color" ) );
51 btnChangeColorFill->setContext( QStringLiteral(
"symbology" ) );
52 btnChangeColorFill->setShowNoColor(
true );
53 btnChangeColorFill->setNoColorString( tr(
"Transparent Fill" ) );
54 btnChangeColorStroke->setAllowOpacity(
true );
55 btnChangeColorStroke->setColorDialogTitle( tr(
"Select Stroke Color" ) );
56 btnChangeColorStroke->setContext( QStringLiteral(
"symbology" ) );
57 btnChangeColorStroke->setShowNoColor(
true );
58 btnChangeColorStroke->setNoColorString( tr(
"Transparent Stroke" ) );
60 spinOffsetX->setClearValue( 0.0 );
61 spinOffsetY->setClearValue( 0.0 );
62 mRotationSpinBox->setClearValue( 0.0 );
65 names << QStringLiteral(
"circle" ) << QStringLiteral(
"rectangle" ) << QStringLiteral(
"diamond" ) << QStringLiteral(
"cross" ) << QStringLiteral(
"triangle" ) << QStringLiteral(
"right_half_triangle" ) << QStringLiteral(
"left_half_triangle" ) << QStringLiteral(
"semi_circle" );
67 int size = mShapeListWidget->iconSize().width();
68 size = std::max( 30, static_cast< int >( std::round(
Qgis::UI_SCALE_FACTOR * fontMetrics().width( QStringLiteral(
"XXX" ) ) ) ) );
69 mShapeListWidget->setGridSize( QSize( size * 1.2, size * 1.2 ) );
70 mShapeListWidget->setIconSize( QSize( size, size ) );
72 double markerSize = size * 0.8;
73 Q_FOREACH (
const QString &name, names )
84 QListWidgetItem *item =
new QListWidgetItem( icon, QString(), mShapeListWidget );
85 item->setToolTip( name );
86 item->setData( Qt::UserRole, name );
90 mShapeListWidget->setMinimumHeight( mShapeListWidget->gridSize().height() * 2.1 );
92 connect( spinOffsetX, static_cast <
void (
QgsDoubleSpinBox::* )(
double ) > ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
93 connect( spinOffsetY, static_cast <
void (
QgsDoubleSpinBox::* )(
double ) > ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
94 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penJoinStyleChanged );
99 if ( !layer || layer->
layerType() != QLatin1String(
"EllipseMarker" ) )
113 QList<QListWidgetItem *> symbolItemList = mShapeListWidget->findItems(
mLayer->
symbolName(), Qt::MatchExactly );
114 if ( !symbolItemList.isEmpty() )
116 mShapeListWidget->setCurrentItem( symbolItemList.at( 0 ) );
120 blockComboSignals(
true );
130 spinOffsetX->setValue( offsetPt.x() );
131 spinOffsetY->setValue( offsetPt.y() );
135 blockComboSignals(
false );
157 void QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged()
161 QListWidgetItem *item = mShapeListWidget->currentItem();
170 void QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged(
double d )
179 void QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged(
double d )
188 void QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged(
double d )
197 void QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged(
int index )
208 void QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
217 void QgsEllipseSymbolLayerWidget::btnChangeColorStroke_colorChanged(
const QColor &newColor )
228 void QgsEllipseSymbolLayerWidget::btnChangeColorFill_colorChanged(
const QColor &newColor )
239 void QgsEllipseSymbolLayerWidget::mSymbolWidthUnitWidget_changed()
249 void QgsEllipseSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
259 void QgsEllipseSymbolLayerWidget::mSymbolHeightUnitWidget_changed()
269 void QgsEllipseSymbolLayerWidget::mOffsetUnitWidget_changed()
279 void QgsEllipseSymbolLayerWidget::penJoinStyleChanged()
285 void QgsEllipseSymbolLayerWidget::blockComboSignals(
bool block )
287 mSymbolWidthUnitWidget->blockSignals( block );
288 mStrokeWidthUnitWidget->blockSignals( block );
289 mSymbolHeightUnitWidget->blockSignals( block );
290 mHorizontalAnchorComboBox->blockSignals( block );
291 mVerticalAnchorComboBox->blockSignals( block );
292 mSymbolWidthUnitWidget->blockSignals( block );
293 mStrokeWidthUnitWidget->blockSignals( block );
294 mSymbolHeightUnitWidget->blockSignals( block );
295 mOffsetUnitWidget->blockSignals( block );
296 cboJoinStyle->blockSignals( block );
299 void QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int index )
308 void QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int index )
317 void QgsEllipseSymbolLayerWidget::setOffset()
319 mLayer->
setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
const QgsMapUnitScale & strokeWidthMapUnitScale() const
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
Meters value as Map units.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenJoinStyle penJoinStyle() const
Gets stroke join style.
static const double UI_SCALE_FACTOR
UI scaling factor.
void setFillColor(const QColor &c) override
Set fill color.
QgsUnitTypes::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
double symbolWidth() const
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
void setSymbolWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's width.
QColor strokeColor() const override
Gets stroke color.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Name, eg shape name for simple markers.
void setStrokeWidth(double w)
static QIcon symbolLayerPreviewIcon(QgsSymbolLayer *layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
Draws a symbol layer preview to an icon.
virtual void setColor(const QColor &color)
The fill color.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
A symbol layer for rendering objects with major and minor axis (e.g.
void setSymbolName(const QString &name)
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
double symbolHeight() const
points (e.g., for font sizes)
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
HorizontalAnchorPoint
Symbol horizontal anchor points.
QString symbolName() const
double strokeWidth() const
VerticalAnchorPoint
Symbol vertical anchor points.
void setSymbolHeightUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's height.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
const QgsMapUnitScale & symbolHeightMapUnitScale() const
Stroke style (eg solid, dashed)
void setStrokeStyle(Qt::PenStyle strokeStyle)
void setStrokeColor(const QColor &c) override
Set stroke color.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
void setSymbolHeight(double h)
Qt::PenStyle strokeStyle() const
const QgsMapUnitScale & symbolWidthMapUnitScale() const
void setAngle(double angle)
Sets the rotation angle for the marker.
QColor fillColor() const override
Gets fill color.
QgsUnitTypes::RenderUnit symbolHeightUnit() const
Returns the units for the symbol's height.
void setSymbolWidth(double w)
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
Represents a vector layer which manages a vector based data sets.
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
virtual QString layerType() const =0
Returns a string that represents this layer type.