[FEATURE] add outline settings to font markers

This commit is contained in:
nirvn 2016-04-20 11:20:24 +07:00
parent 90613ca5d3
commit 9735c13e33
12 changed files with 400 additions and 44 deletions

View File

@ -221,6 +221,41 @@ class QgsFontMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
QChar character() const;
void setCharacter( QChar ch );
/** Get outline color.
* @note added in 2.16 */
QColor outlineColor() const;
/** Set outline color.
* @note added in 2.16 */
void setOutlineColor( const QColor& color );
/** Get outline width.
* @note added in 2.16 */
double outlineWidth() const;
/** Set outline width.
* @note added in 2.16 */
void setOutlineWidth( double width );
/** Get outline width unit.
* @note added in 2.16 */
QgsSymbolV2::OutputUnit outlineWidthUnit() const;
/** Set outline width unit.
* @note added in 2.16 */
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
/** Get outline width map unit scale.
* @note added in 2.16 */
const QgsMapUnitScale& outlineWidthMapUnitScale() const;
/** Set outline width map unit scale.
* @note added in 2.16 */
void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale );
/** Get outline join style.
* @note added in 2.16 */
Qt::PenJoinStyle penJoinStyle() const;
/** Set outline join style.
* @note added in 2.16 */
void setPenJoinStyle( Qt::PenJoinStyle style );
QRectF bounds( QPointF point, QgsSymbolV2RenderContext& context );
};

View File

@ -408,12 +408,18 @@ class QgsFontMarkerSymbolLayerV2Widget : QgsSymbolLayerV2Widget
public slots:
void setFontFamily( const QFont& font );
void setColor( const QColor& color );
/** Set outline color.
* @note added in 2.16 */
void setColorBorder( const QColor& color );
void setSize( double size );
void setAngle( double angle );
void setCharacter( QChar chr );
void setOffset();
void on_mSizeUnitWidget_changed();
void on_mOffsetUnitWidget_changed();
void on_mBorderWidthUnitWidget_changed();
void on_mBorderWidthSpinBox_valueChanged( double d );
void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
};

View File

@ -1983,6 +1983,10 @@ QgsFontMarkerSymbolLayerV2::QgsFontMarkerSymbolLayerV2( const QString& fontFamil
mSizeUnit = QgsSymbolV2::MM;
mOffset = QPointF( 0, 0 );
mOffsetUnit = QgsSymbolV2::MM;
mOutlineColor = DEFAULT_FONTMARKER_BORDERCOLOR;
mOutlineWidth = 0.0;
mOutlineWidthUnit = QgsSymbolV2::MM;
mPenJoinStyle = DEFAULT_FONTMARKER_JOINSTYLE;
}
QgsFontMarkerSymbolLayerV2::~QgsFontMarkerSymbolLayerV2()
@ -2010,6 +2014,11 @@ QgsSymbolLayerV2* QgsFontMarkerSymbolLayerV2::create( const QgsStringMap& props
angle = props["angle"].toDouble();
QgsFontMarkerSymbolLayerV2* m = new QgsFontMarkerSymbolLayerV2( fontFamily, chr, pointSize, color, angle );
if ( props.contains( "outline_color" ) )
m->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( props["outline_color"] ) );
if ( props.contains( "outline_width" ) )
m->setOutlineWidth( props["outline_width"].toDouble() );
if ( props.contains( "offset" ) )
m->setOffset( QgsSymbolLayerV2Utils::decodePoint( props["offset"] ) );
if ( props.contains( "offset_unit" ) )
@ -2020,14 +2029,16 @@ QgsSymbolLayerV2* QgsFontMarkerSymbolLayerV2::create( const QgsStringMap& props
m->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["size_unit"] ) );
if ( props.contains( "size_map_unit_scale" ) )
m->setSizeMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["size_map_unit_scale"] ) );
if ( props.contains( "outline_width_unit" ) )
m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) );
if ( props.contains( "outline_width_map_unit_scale" ) )
m->setOutlineWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["outline_width_map_unit_scale"] ) );
if ( props.contains( "joinstyle" ) )
m->setPenJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( props["joinstyle"] ) );
if ( props.contains( "horizontal_anchor_point" ) )
{
m->setHorizontalAnchorPoint( QgsMarkerSymbolLayerV2::HorizontalAnchorPoint( props[ "horizontal_anchor_point" ].toInt() ) );
}
if ( props.contains( "vertical_anchor_point" ) )
{
m->setVerticalAnchorPoint( QgsMarkerSymbolLayerV2::VerticalAnchorPoint( props[ "vertical_anchor_point" ].toInt() ) );
}
m->restoreDataDefinedProperties( props );
@ -2041,6 +2052,17 @@ QString QgsFontMarkerSymbolLayerV2::layerType() const
void QgsFontMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
QColor brushColor = mColor;
QColor penColor = mOutlineColor;
brushColor.setAlphaF( mColor.alphaF() * context.alpha() );
penColor.setAlphaF( mOutlineColor.alphaF() * context.alpha() );
mBrush = QBrush( brushColor );
mPen = QPen( penColor );
mPen.setJoinStyle( mPenJoinStyle );
mPen.setWidthF( QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), mOutlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale ) );
mFont = QFont( mFontFamily );
mFont.setPixelSize( QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), mSize, mSizeUnit, mSizeMapUnitScale ) );
delete mFontMetrics;
@ -2152,20 +2174,63 @@ void QgsFontMarkerSymbolLayerV2::renderPoint( QPointF point, QgsSymbolV2RenderCo
if ( !p )
return;
QColor penColor = mColor;
QTransform transform;
bool ok;
QColor brushColor = mColor;
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR ) )
{
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR, context, QVariant(), &ok ).toString();
if ( ok )
brushColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
}
brushColor = context.selected() ? context.renderContext().selectionColor() : brushColor;
brushColor.setAlphaF( brushColor.alphaF() * context.alpha() );
mBrush.setColor( brushColor );
QColor penColor = mOutlineColor;
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR_BORDER ) )
{
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ) );
QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_COLOR_BORDER, context, QVariant(), &ok ).toString();
if ( ok )
penColor = QgsSymbolLayerV2Utils::decodeColor( colorString );
}
penColor = context.selected() ? context.renderContext().selectionColor() : penColor;
penColor.setAlphaF( penColor.alphaF() * context.alpha() );
p->setPen( penColor );
p->setFont( mFont );
double penWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), mOutlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale );
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) )
{
context.setOriginalValueVariable( mOutlineWidth );
double outlineWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, context, QVariant(), &ok ).toDouble();
if ( ok )
{
penWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), outlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale );
}
}
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_JOIN_STYLE ) )
{
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle ) );
QString style = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_JOIN_STYLE, context, QVariant(), &ok ).toString();
if ( ok )
{
mPen.setJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( style ) );
}
}
p->setBrush( mBrush );
if ( !qgsDoubleNear( penWidth, 0.0 ) )
{
mPen.setColor( penColor );
mPen.setWidthF( penWidth );
p->setPen( mPen );
}
else
{
p->setPen( Qt::NoPen );
}
p->save();
QPointF chrOffset = mChrOffset;
@ -2179,18 +2244,20 @@ void QgsFontMarkerSymbolLayerV2::renderPoint( QPointF point, QgsSymbolV2RenderCo
double angle = 0;
calculateOffsetAndRotation( context, sizeToRender, hasDataDefinedRotation, offset, angle );
p->translate( point + offset );
transform.translate( point.x() + offset.x(), point.y() + offset.y() );
if ( !qgsDoubleNear( angle, 0.0 ) )
transform.rotate( angle );
if ( !qgsDoubleNear( sizeToRender, mOrigSize ) )
{
double s = sizeToRender / mOrigSize;
p->scale( s, s );
transform.scale( s, s );
}
if ( !qgsDoubleNear( angle, 0 ) )
p->rotate( angle );
p->drawText( -chrOffset, charToRender );
QPainterPath path;
path.addText( -chrOffset.x(), -chrOffset.y(), mFont, charToRender );
p->drawPath( transform.map( path ) );
p->restore();
}
@ -2203,6 +2270,10 @@ QgsStringMap QgsFontMarkerSymbolLayerV2::properties() const
props["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSizeUnit );
props["size_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSizeMapUnitScale );
props["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
props["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor );
props["outline_width"] = QString::number( mOutlineWidth );
props["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
props["outline_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale );
props["angle"] = QString::number( mAngle );
props["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
props["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );
@ -2219,6 +2290,11 @@ QgsStringMap QgsFontMarkerSymbolLayerV2::properties() const
QgsFontMarkerSymbolLayerV2* QgsFontMarkerSymbolLayerV2::clone() const
{
QgsFontMarkerSymbolLayerV2* m = new QgsFontMarkerSymbolLayerV2( mFontFamily, mChr, mSize, mColor, mAngle );
m->setOutlineColor( mOutlineColor );
m->setOutlineWidth( mOutlineWidth );
m->setOutlineWidthUnit( mOutlineWidthUnit );
m->setOutlineWidthMapUnitScale( mOutlineWidthMapUnitScale );
m->setPenJoinStyle( mPenJoinStyle );
m->setOffset( mOffset );
m->setOffsetUnit( mOffsetUnit );
m->setOffsetMapUnitScale( mOffsetMapUnitScale );

View File

@ -260,6 +260,8 @@ class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
#define DEFAULT_FONTMARKER_CHR QChar('A')
#define DEFAULT_FONTMARKER_SIZE POINT2MM(12)
#define DEFAULT_FONTMARKER_COLOR QColor(Qt::black)
#define DEFAULT_FONTMARKER_BORDERCOLOR QColor(Qt::white)
#define DEFAULT_FONTMARKER_JOINSTYLE Qt::MiterJoin
#define DEFAULT_FONTMARKER_ANGLE 0
class CORE_EXPORT QgsFontMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
@ -302,6 +304,41 @@ class CORE_EXPORT QgsFontMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
QChar character() const { return mChr; }
void setCharacter( QChar ch ) { mChr = ch; }
/** Get outline color.
* @note added in 2.16 */
QColor outlineColor() const override { return mOutlineColor; }
/** Set outline color.
* @note added in 2.16 */
void setOutlineColor( const QColor& color ) override { mOutlineColor = color; }
/** Get outline width.
* @note added in 2.16 */
double outlineWidth() const { return mOutlineWidth; }
/** Set outline width.
* @note added in 2.16 */
void setOutlineWidth( double width ) { mOutlineWidth = width; }
/** Get outline width unit.
* @note added in 2.16 */
QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
/** Set outline width unit.
* @note added in 2.16 */
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
/** Get outline width map unit scale.
* @note added in 2.16 */
const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
/** Set outline width map unit scale.
* @note added in 2.16 */
void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
/** Get outline join style.
* @note added in 2.16 */
Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
/** Set outline join style.
* @note added in 2.16 */
void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
QRectF bounds( QPointF point, QgsSymbolV2RenderContext& context ) override;
protected:
@ -317,6 +354,15 @@ class CORE_EXPORT QgsFontMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
private:
QColor mOutlineColor;
double mOutlineWidth;
QgsSymbolV2::OutputUnit mOutlineWidthUnit;
QgsMapUnitScale mOutlineWidthMapUnitScale;
Qt::PenJoinStyle mPenJoinStyle;
QPen mPen;
QBrush mBrush;
QString characterToRender( QgsSymbolV2RenderContext& context, QPointF& charOffset, double& charWidth );
void calculateOffsetAndRotation( QgsSymbolV2RenderContext& context, double scaledSize, bool& hasDataDefinedRotation, QPointF& offset, double& angle ) const;
double calculateSize( QgsSymbolV2RenderContext& context );

View File

@ -2493,13 +2493,17 @@ QgsFontMarkerSymbolLayerV2Widget::QgsFontMarkerSymbolLayerV2Widget( const QgsVec
setupUi( this );
mSizeUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
widgetChar = new CharacterWidget;
scrollArea->setWidget( widgetChar );
btnColor->setAllowAlpha( true );
btnColor->setColorDialogTitle( tr( "Select symbol color" ) );
btnColor->setColorDialogTitle( tr( "Select symbol fill color" ) );
btnColor->setContext( "symbology" );
btnBorderColor->setAllowAlpha( true );
btnBorderColor->setColorDialogTitle( tr( "Select symbol outline color" ) );
btnBorderColor->setContext( "symbology" );
spinOffsetX->setClearValue( 0.0 );
spinOffsetY->setClearValue( 0.0 );
@ -2512,7 +2516,10 @@ QgsFontMarkerSymbolLayerV2Widget::QgsFontMarkerSymbolLayerV2Widget( const QgsVec
connect( cboFont, SIGNAL( currentFontChanged( const QFont & ) ), this, SLOT( setFontFamily( const QFont& ) ) );
connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize( double ) ) );
connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penJoinStyleChanged() ) );
connect( btnColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor( const QColor& ) ) );
connect( btnBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColorBorder( const QColor& ) ) );
connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penJoinStyleChanged() ) );
connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle( double ) ) );
connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
@ -2535,18 +2542,12 @@ void QgsFontMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
QFont layerFont( mLayer->fontFamily() );
// set values
cboFont->blockSignals( true );
cboFont->setCurrentFont( layerFont );
cboFont->blockSignals( false );
spinSize->blockSignals( true );
spinSize->setValue( mLayer->size() );
spinSize->blockSignals( false );
btnColor->blockSignals( true );
btnColor->setColor( mLayer->color() );
btnColor->blockSignals( false );
spinAngle->blockSignals( true );
spinAngle->setValue( mLayer->angle() );
spinAngle->blockSignals( false );
whileBlocking( cboFont )->setCurrentFont( layerFont );
whileBlocking( spinSize )->setValue( mLayer->size() );
whileBlocking( btnColor )->setColor( mLayer->color() );
whileBlocking( btnBorderColor )->setColor( mLayer->outlineColor() );
whileBlocking( mBorderWidthSpinBox )->setValue( mLayer->outlineWidth() );
whileBlocking( spinAngle )->setValue( mLayer->angle() );
widgetChar->blockSignals( true );
widgetChar->updateFont( layerFont );
@ -2554,34 +2555,36 @@ void QgsFontMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
widgetChar->blockSignals( false );
//block
spinOffsetX->blockSignals( true );
spinOffsetX->setValue( mLayer->offset().x() );
spinOffsetX->blockSignals( false );
spinOffsetY->blockSignals( true );
spinOffsetY->setValue( mLayer->offset().y() );
spinOffsetY->blockSignals( false );
whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
mSizeUnitWidget->blockSignals( true );
mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
mSizeUnitWidget->blockSignals( false );
mBorderWidthUnitWidget->blockSignals( true );
mBorderWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
mBorderWidthUnitWidget->setMapUnitScale( mLayer->outlineWidthMapUnitScale() );
mBorderWidthUnitWidget->blockSignals( false );
mOffsetUnitWidget->blockSignals( true );
mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
mOffsetUnitWidget->blockSignals( false );
whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
//anchor points
mHorizontalAnchorComboBox->blockSignals( true );
mVerticalAnchorComboBox->blockSignals( true );
mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
mHorizontalAnchorComboBox->blockSignals( false );
mVerticalAnchorComboBox->blockSignals( false );
whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
registerDataDefinedButton( mSizeDDBtn, "size", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
registerDataDefinedButton( mRotationDDBtn, "angle", QgsDataDefinedButton::Double, QgsDataDefinedButton::double180RotDesc() );
registerDataDefinedButton( mColorDDBtn, "color", QgsDataDefinedButton::String, QgsDataDefinedButton::colorAlphaDesc() );
registerDataDefinedButton( mBorderColorDDBtn, "color_border", QgsDataDefinedButton::String, QgsDataDefinedButton::colorAlphaDesc() );
registerDataDefinedButton( mBorderWidthDDBtn, "outline_width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
registerDataDefinedButton( mJoinStyleDDBtn, "join_style", QgsDataDefinedButton::String, QgsDataDefinedButton::penJoinStyleDesc() );
registerDataDefinedButton( mOffsetDDBtn, "offset", QgsDataDefinedButton::String, QgsDataDefinedButton::doubleXYDesc() );
registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
registerDataDefinedButton( mVerticalAnchorDDBtn, "vertical_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::verticalAnchorDesc() );
@ -2608,6 +2611,12 @@ void QgsFontMarkerSymbolLayerV2Widget::setColor( const QColor& color )
emit changed();
}
void QgsFontMarkerSymbolLayerV2Widget::setColorBorder( const QColor& color )
{
mLayer->setOutlineColor( color );
emit changed();
}
void QgsFontMarkerSymbolLayerV2Widget::setSize( double size )
{
mLayer->setSize( size );
@ -2633,6 +2642,12 @@ void QgsFontMarkerSymbolLayerV2Widget::setOffset()
emit changed();
}
void QgsFontMarkerSymbolLayerV2Widget::penJoinStyleChanged()
{
mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
emit changed();
}
void QgsFontMarkerSymbolLayerV2Widget::on_mSizeUnitWidget_changed()
{
if ( mLayer )
@ -2653,6 +2668,16 @@ void QgsFontMarkerSymbolLayerV2Widget::on_mOffsetUnitWidget_changed()
}
}
void QgsFontMarkerSymbolLayerV2Widget::on_mBorderWidthUnitWidget_changed()
{
if ( mLayer )
{
mLayer->setOutlineWidthUnit( mSizeUnitWidget->unit() );
mLayer->setOutlineWidthMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
emit changed();
}
}
void QgsFontMarkerSymbolLayerV2Widget::on_mHorizontalAnchorComboBox_currentIndexChanged( int index )
{
if ( mLayer )
@ -2671,6 +2696,15 @@ void QgsFontMarkerSymbolLayerV2Widget::on_mVerticalAnchorComboBox_currentIndexCh
}
}
void QgsFontMarkerSymbolLayerV2Widget::on_mBorderWidthSpinBox_valueChanged( double d )
{
if ( mLayer )
{
mLayer->setOutlineWidth( d );
emit changed();
}
}
void QgsFontMarkerSymbolLayerV2Widget::updateAssistantSymbol()
{
for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )

View File

@ -572,12 +572,18 @@ class GUI_EXPORT QgsFontMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
public slots:
void setFontFamily( const QFont& font );
void setColor( const QColor& color );
/** Set outline color.
* @note added in 2.16 */
void setColorBorder( const QColor& color );
void setSize( double size );
void setAngle( double angle );
void setCharacter( QChar chr );
void setOffset();
void on_mSizeUnitWidget_changed();
void on_mOffsetUnitWidget_changed();
void on_mBorderWidthUnitWidget_changed();
void on_mBorderWidthSpinBox_valueChanged( double d );
void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
@ -587,6 +593,7 @@ class GUI_EXPORT QgsFontMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
private slots:
void penJoinStyleChanged();
void updateAssistantSymbol();
private:

View File

@ -18,6 +18,13 @@
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Fill</string>
</property>
</widget>
</item>
<item>
<widget class="QgsColorButtonV2" name="btnColor">
<property name="minimumSize">
@ -44,6 +51,45 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Outline</string>
</property>
</widget>
</item>
<item>
<widget class="QgsColorButtonV2" name="btnBorderColor">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QgsDataDefinedButton" name="mBorderColorDDBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -98,21 +144,101 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Join style</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QgsPenJoinStyleComboBox" name="cboJoinStyle"/>
</item>
<item>
<widget class="QgsDataDefinedButton" name="mJoinStyleDDBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="mBorderWidthLabel">
<property name="text">
<string>Outline width</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QgsDoubleSpinBox" name="mBorderWidthSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText">
<string>No outline</string>
</property>
<property name="decimals">
<number>6</number>
</property>
<property name="maximum">
<double>999999999.999999046325684</double>
</property>
<property name="singleStep">
<double>0.200000000000000</double>
</property>
<property name="value">
<double>0.200000000000000</double>
</property>
<property name="showClearButton" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QgsDataDefinedButton" name="mBorderWidthDDBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QgsUnitSelectionWidget" name="mBorderWidthUnitWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Offset X,Y</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Rotation</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QLabel" name="mAnchorPointLabel">
<property name="text">
<string>Anchor point</string>
@ -136,7 +262,7 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QgsDoubleSpinBox" name="spinOffsetX">
@ -198,7 +324,7 @@
</item>
</layout>
</item>
<item row="5" column="1">
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QComboBox" name="mHorizontalAnchorComboBox">
@ -261,7 +387,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QgsDoubleSpinBox" name="spinAngle">
@ -353,13 +479,26 @@
<extends>QToolButton</extends>
<header>qgsdatadefinedbutton.h</header>
</customwidget>
<customwidget>
<class>QgsPenJoinStyleComboBox</class>
<extends>QComboBox</extends>
<header>qgspenstylecombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cboFont</tabstop>
<tabstop>btnColor</tabstop>
<tabstop>mColorDDBtn</tabstop>
<tabstop>btnBorderColor</tabstop>
<tabstop>mBorderColorDDBtn</tabstop>
<tabstop>spinSize</tabstop>
<tabstop>mSizeDDBtn</tabstop>
<tabstop>mSizeUnitWidget</tabstop>
<tabstop>cboJoinStyle</tabstop>
<tabstop>mJoinStyleDDBtn</tabstop>
<tabstop>mBorderWidthSpinBox</tabstop>
<tabstop>mBorderWidthDDBtn</tabstop>
<tabstop>mBorderWidthUnitWidget</tabstop>
<tabstop>spinAngle</tabstop>
<tabstop>mRotationDDBtn</tabstop>
<tabstop>spinOffsetX</tabstop>

View File

@ -60,6 +60,7 @@ class TestQgsFontMarkerSymbol : public QObject
void cleanup() {} // will be called after every testfunction.
void fontMarkerSymbol();
void fontMarkerSymbolOutline();
void bounds();
private:
@ -141,6 +142,17 @@ void TestQgsFontMarkerSymbol::fontMarkerSymbol()
QVERIFY( imageCheck( "fontmarker" ) );
}
void TestQgsFontMarkerSymbol::fontMarkerSymbolOutline()
{
mFontMarkerLayer->setColor( Qt::blue );
QFont font = QgsFontUtils::getStandardTestFont( "Bold" );
mFontMarkerLayer->setFontFamily( font.family() );
mFontMarkerLayer->setCharacter( 'A' );
mFontMarkerLayer->setSize( 30 );
mFontMarkerLayer->setOutlineWidth( 3.5 );
QVERIFY( imageCheck( "fontmarker_outline" ) );
}
void TestQgsFontMarkerSymbol::bounds()
{
mFontMarkerLayer->setColor( Qt::blue );
@ -149,6 +161,7 @@ void TestQgsFontMarkerSymbol::bounds()
//use a narrow character to test that width is correctly calculated
mFontMarkerLayer->setCharacter( 'l' );
mFontMarkerLayer->setSize( 12 );
mFontMarkerLayer->setOutlineWidth( 0 );
mFontMarkerLayer->setDataDefinedProperty( "size", new QgsDataDefined( true, true, "min(\"importance\" * 4.47214, 7.07106)" ) );
mMapSettings.setFlag( QgsMapSettings::DrawSymbolBounds, true );

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB