Skip to content
Permalink
Browse files

simple fill: added border style and width

pen style combo box: added "no pen"


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12155 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Nov 17, 2009
1 parent cbce1df commit 82766c5ede6eb585c84e3e9c5af6012edabb4b9f
@@ -6,8 +6,8 @@

#include <QPainter>

QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2(QColor color, QColor borderColor, Qt::BrushStyle style)
: mBrushStyle(style), mBorderColor(borderColor)
QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2(QColor color, Qt::BrushStyle style, QColor borderColor, Qt::PenStyle borderStyle, double borderWidth)
: mBrushStyle(style), mBorderColor(borderColor), mBorderStyle(borderStyle), mBorderWidth(borderWidth)
{
mColor = color;
}
@@ -16,17 +16,23 @@ QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2(QColor color, QColor bord
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create(const QgsStringMap& props)
{
QColor color = DEFAULT_SIMPLEFILL_COLOR;
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR;
Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE;

QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR;
Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE;
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH;

if (props.contains("color"))
color = QgsSymbolLayerV2Utils::decodeColor(props["color"]);
if (props.contains("color_border"))
borderColor = QgsSymbolLayerV2Utils::decodeColor(props["color_border"]);
if (props.contains("style"))
style = QgsSymbolLayerV2Utils::decodeBrushStyle(props["style"]);

return new QgsSimpleFillSymbolLayerV2(color, borderColor, style);
if (props.contains("color_border"))
borderColor = QgsSymbolLayerV2Utils::decodeColor(props["color_border"]);
if (props.contains("style_border"))
borderStyle = QgsSymbolLayerV2Utils::decodePenStyle(props["style_border"]);
if (props.contains("width_border"))
borderWidth = props["width_border"].toDouble();

return new QgsSimpleFillSymbolLayerV2(color, style, borderColor, borderStyle, borderWidth);
}


@@ -39,6 +45,8 @@ void QgsSimpleFillSymbolLayerV2::startRender(QgsRenderContext& context)
{
mBrush = QBrush(mColor, mBrushStyle);
mPen = QPen(mBorderColor);
mPen.setStyle(mBorderStyle);
mPen.setWidthF(mBorderWidth);
}

void QgsSimpleFillSymbolLayerV2::stopRender(QgsRenderContext& context)
@@ -73,12 +81,14 @@ QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const
{
QgsStringMap map;
map["color"] = QgsSymbolLayerV2Utils::encodeColor(mColor);
map["color_border"] = QgsSymbolLayerV2Utils::encodeColor(mBorderColor);
map["style"] = QgsSymbolLayerV2Utils::encodeBrushStyle(mBrushStyle);
map["color_border"] = QgsSymbolLayerV2Utils::encodeColor(mBorderColor);
map["style_border"] = QgsSymbolLayerV2Utils::encodePenStyle(mBorderStyle);
map["width_border"] = QString::number(mBorderWidth);
return map;
}

QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::clone() const
{
return new QgsSimpleFillSymbolLayerV2(mColor, mBorderColor, mBrushStyle);
return new QgsSimpleFillSymbolLayerV2(mColor, mBrushStyle, mBorderColor, mBorderStyle, mBorderWidth);
}
@@ -7,6 +7,8 @@
#define DEFAULT_SIMPLEFILL_COLOR QColor(0,0,255)
#define DEFAULT_SIMPLEFILL_STYLE Qt::SolidPattern
#define DEFAULT_SIMPLEFILL_BORDERCOLOR QColor(0,0,0)
#define DEFAULT_SIMPLEFILL_BORDERSTYLE Qt::SolidLine
#define DEFAULT_SIMPLEFILL_BORDERWIDTH 1.0

#include <QPen>
#include <QBrush>
@@ -15,9 +17,11 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
{
public:
QgsSimpleFillSymbolLayerV2( QColor color = DEFAULT_SIMPLEFILL_COLOR,
Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE,
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR,
Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE );

Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE,
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH );

// static stuff

static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
@@ -42,10 +46,18 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
QColor borderColor() const { return mBorderColor; }
void setBorderColor( QColor borderColor ) { mBorderColor = borderColor; }

Qt::PenStyle borderStyle() const { return mBorderStyle; }
void setBorderStyle( Qt::PenStyle borderStyle ) { mBorderStyle = borderStyle; }

double borderWidth() const { return mBorderWidth; }
void setBorderWidth( double borderWidth ) { mBorderWidth = borderWidth; }

protected:
QBrush mBrush;
Qt::BrushStyle mBrushStyle;
QColor mBorderColor;
Qt::PenStyle mBorderStyle;
double mBorderWidth;
QPen mPen;
};

@@ -31,6 +31,7 @@ QString QgsSymbolLayerV2Utils::encodePenStyle( Qt::PenStyle style )
{
switch ( style )
{
case Qt::NoPen: return "no";
case Qt::SolidLine: return "solid";
case Qt::DashLine: return "dash";
case Qt::DotLine: return "dot";
@@ -42,6 +43,7 @@ QString QgsSymbolLayerV2Utils::encodePenStyle( Qt::PenStyle style )

Qt::PenStyle QgsSymbolLayerV2Utils::decodePenStyle( QString str )
{
if ( str == "no" ) return Qt::NoPen;
if ( str == "solid" ) return Qt::SolidLine;
if ( str == "dash" ) return Qt::DashLine;
if ( str == "dot" ) return Qt::DotLine;
@@ -17,7 +17,8 @@ QgsPenStyleComboBox::QgsPenStyleComboBox(QWidget* parent)
<< qMakePair(Qt::DashLine, QString("Dash Line"))
<< qMakePair(Qt::DotLine, QString("Dot Line"))
<< qMakePair(Qt::DashDotLine, QString("Dash Dot Line"))
<< qMakePair(Qt::DashDotDotLine, QString("Dash Dot Dot Line"));
<< qMakePair(Qt::DashDotDotLine, QString("Dash Dot Dot Line"))
<< qMakePair(Qt::NoPen, QString("No Pen"));

setIconSize(QSize(32,12));

@@ -212,8 +212,10 @@ QgsSimpleFillSymbolLayerV2Widget::QgsSimpleFillSymbolLayerV2Widget(QWidget* pare
setupUi(this);

connect(btnChangeColor, SIGNAL(clicked()), this, SLOT(setColor()));
connect(btnChangeBorderColor, SIGNAL(clicked()), this, SLOT(setBorderColor()));
connect(cboFillStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(setBrushStyle()));
connect(btnChangeBorderColor, SIGNAL(clicked()), this, SLOT(setBorderColor()));
connect(spinBorderWidth, SIGNAL(valueChanged(double)), this, SLOT(borderWidthChanged()));
connect(cboBorderStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(borderStyleChanged()));
}

void QgsSimpleFillSymbolLayerV2Widget::setSymbolLayer(QgsSymbolLayerV2* layer)
@@ -226,8 +228,10 @@ void QgsSimpleFillSymbolLayerV2Widget::setSymbolLayer(QgsSymbolLayerV2* layer)

// set values
btnChangeColor->setColor(mLayer->color());
btnChangeBorderColor->setColor(mLayer->borderColor());
cboFillStyle->setBrushStyle(mLayer->brushStyle());
btnChangeBorderColor->setColor(mLayer->borderColor());
cboBorderStyle->setPenStyle(mLayer->borderStyle());
spinBorderWidth->setValue(mLayer->borderWidth());
}

QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2Widget::symbolLayer()
@@ -261,6 +265,18 @@ void QgsSimpleFillSymbolLayerV2Widget::setBrushStyle()
emit changed();
}

void QgsSimpleFillSymbolLayerV2Widget::borderWidthChanged()
{
mLayer->setBorderWidth(spinBorderWidth->value());
emit changed();
}

void QgsSimpleFillSymbolLayerV2Widget::borderStyleChanged()
{
mLayer->setBorderStyle(cboBorderStyle->penStyle());
emit changed();
}

///////////

QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget(QWidget* parent)
@@ -105,6 +105,8 @@ class GUI_EXPORT QgsSimpleFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
void setColor();
void setBorderColor();
void setBrushStyle();
void borderWidthChanged();
void borderStyleChanged();

protected:
QgsSimpleFillSymbolLayerV2* mLayer;
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>335</width>
<height>154</height>
<height>206</height>
</rect>
</property>
<property name="windowTitle">
@@ -30,7 +30,7 @@
</property>
</widget>
</item>
<item row="0" column="2" rowspan="3">
<item row="0" column="2" rowspan="5">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -47,26 +47,50 @@
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Fill style:</string>
<string>Border color:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsColorButtonV2" name="btnChangeBorderColor">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsBrushStyleComboBox" name="cboFillStyle"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Border color:</string>
<string>Fill style:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsColorButtonV2" name="btnChangeBorderColor">
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Change</string>
<string>Border style:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QgsPenStyleComboBox" name="cboBorderStyle"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Border width:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="spinBorderWidth">
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
@@ -98,11 +122,18 @@
<extends>QPushButton</extends>
<header>qgscolorbutton.h</header>
</customwidget>
<customwidget>
<class>QgsPenStyleComboBox</class>
<extends>QComboBox</extends>
<header>qgspenstylecombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>btnChangeColor</tabstop>
<tabstop>btnChangeBorderColor</tabstop>
<tabstop>cboFillStyle</tabstop>
<tabstop>btnChangeBorderColor</tabstop>
<tabstop>cboBorderStyle</tabstop>
<tabstop>spinBorderWidth</tabstop>
</tabstops>
<resources/>
<connections/>

0 comments on commit 82766c5

Please sign in to comment.
You can’t perform that action at this time.