Skip to content
Permalink
Browse files

Changed line width to be double, fixed width retrieval from symbol, p…

…roportional scaling of symbol layers when settings size/width.

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11064 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jul 14, 2009
1 parent 45ae45f commit 9ae3ae2af86bf58c73fda242ad5ae72405c16e5b
@@ -315,8 +315,8 @@ class QgsLineSymbolLayerV2 : QgsSymbolLayerV2
public:
virtual void renderPolyline(const QPolygonF& points, QgsRenderContext& context) = 0;

void setWidth(int width);
int width() const;
void setWidth(double width);
double width() const;

void drawPreviewIcon(QPainter* painter, QSize size);

@@ -450,8 +450,8 @@ class QgsLineSymbolV2 : QgsSymbolV2
public:
QgsLineSymbolV2(QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List());

void setWidth(int width);
int width();
void setWidth(double width);
double width();

void renderPolyline(const QPolygonF& points, QgsRenderContext& context, int layer = -1);

@@ -86,7 +86,7 @@ public slots:
void setSymbolFromStyle(const QModelIndex & index);
void setSymbolColor();
void setMarkerAngle(double angle);
void setMarkerSize(int size);
void setLineWidth(int width);
void setMarkerSize(double size);
void setLineWidth(double width);

};
@@ -8,7 +8,7 @@

#include <cmath>

QgsSimpleLineSymbolLayerV2::QgsSimpleLineSymbolLayerV2(QColor color, int width, Qt::PenStyle penStyle)
QgsSimpleLineSymbolLayerV2::QgsSimpleLineSymbolLayerV2(QColor color, double width, Qt::PenStyle penStyle)
: mPenStyle(penStyle), mOffset(0)
{
mColor = color;
@@ -19,13 +19,13 @@ QgsSimpleLineSymbolLayerV2::QgsSimpleLineSymbolLayerV2(QColor color, int width,
QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::create(const QgsStringMap& props)
{
QColor color = DEFAULT_SIMPLELINE_COLOR;
int width = DEFAULT_SIMPLELINE_WIDTH;
double width = DEFAULT_SIMPLELINE_WIDTH;
Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE;

if (props.contains("color"))
color = QgsSymbolLayerV2Utils::decodeColor(props["color"]);
if (props.contains("width"))
width = props["width"].toInt();
width = props["width"].toDouble();
if (props.contains("penstyle"))
penStyle = QgsSymbolLayerV2Utils::decodePenStyle(props["penstyle"]);

@@ -15,7 +15,7 @@ class QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2
{
public:
QgsSimpleLineSymbolLayerV2(QColor color = DEFAULT_SIMPLELINE_COLOR,
int width = DEFAULT_SIMPLELINE_WIDTH,
double width = DEFAULT_SIMPLELINE_WIDTH,
Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE);

// static stuff
@@ -89,15 +89,15 @@ class QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
public:
virtual void renderPolyline(const QPolygonF& points, QgsRenderContext& context) = 0;

void setWidth(int width) { mWidth = width; }
int width() const { return mWidth; }
void setWidth(double width) { mWidth = width; }
double width() const { return mWidth; }

void drawPreviewIcon(QPainter* painter, QSize size);

protected:
QgsLineSymbolLayerV2(bool locked = false);

int mWidth;
double mWidth;
};

class QgsFillSymbolLayerV2 : public QgsSymbolLayerV2
@@ -252,13 +252,21 @@ double QgsMarkerSymbolV2::angle()
return 0;
}

void QgsMarkerSymbolV2::setSize(double size)
void QgsMarkerSymbolV2::setSize(double s)
{
// TODO: proportionally set size of layers
double origSize = size();

for (QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it)
{
QgsMarkerSymbolLayerV2* layer = (QgsMarkerSymbolLayerV2*) *it;
layer->setSize(size);
if (layer->size() == origSize)
layer->setSize(s);
else
{
// proportionally scale size
if (origSize != 0)
layer->setSize(layer->size() * s / origSize);
}
}
}

@@ -308,24 +316,34 @@ QgsLineSymbolV2::QgsLineSymbolV2(QgsSymbolLayerV2List layers)
mLayers.append(new QgsSimpleLineSymbolLayerV2());
}

void QgsLineSymbolV2::setWidth(int width)
void QgsLineSymbolV2::setWidth(double w)
{
// TODO: proportionally set width of layers
double origWidth = width();

for (QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it)
{
QgsLineSymbolLayerV2* layer = (QgsLineSymbolLayerV2*) *it;
layer->setWidth(width);
if (layer->width() == origWidth)
{
layer->setWidth(w);
}
else
{
// proportionally scale the width
if (origWidth != 0)
layer->setWidth( layer->width() * w / origWidth );
}
}
}

int QgsLineSymbolV2::width()
double QgsLineSymbolV2::width()
{
int maxWidth = 0;
double maxWidth = 0;
for (QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it)
{
const QgsLineSymbolLayerV2* layer = (const QgsLineSymbolLayerV2*) *it;
int width = layer->width();
if (maxWidth > width)
double width = layer->width();
if (width > maxWidth)
maxWidth = width;
}
return maxWidth;
@@ -106,8 +106,8 @@ class QgsLineSymbolV2 : public QgsSymbolV2
public:
QgsLineSymbolV2(QgsSymbolLayerV2List layers = QgsSymbolLayerV2List());

void setWidth(int width);
int width();
void setWidth(double width);
double width();

void renderPolyline(const QPolygonF& points, QgsRenderContext& context, int layer = -1);

@@ -32,7 +32,7 @@ QgsSimpleLineSymbolLayerV2Widget::QgsSimpleLineSymbolLayerV2Widget(QWidget* pare

setupUi(this);

connect(spinWidth, SIGNAL(valueChanged(int)), this, SLOT(penWidthChanged()));
connect(spinWidth, SIGNAL(valueChanged(double)), this, SLOT(penWidthChanged()));
connect(btnChangeColor, SIGNAL(clicked()), this, SLOT(colorChanged()));
connect(cboPenStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(penStyleChanged()));
connect(spinOffset, SIGNAL(valueChanged(double)), this, SLOT(offsetChanged()));
@@ -114,7 +114,7 @@ QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget(QWidget*
connect(lstNames, SIGNAL(currentRowChanged(int)), this, SLOT(setName()));
connect(btnChangeColorBorder, SIGNAL(clicked()), this, SLOT(setColorBorder()));
connect(btnChangeColorFill, SIGNAL(clicked()), this, SLOT(setColorFill()));
connect(spinSize, SIGNAL(valueChanged(int)), this, SLOT(setSize()));
connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(setSize()));
connect(spinAngle, SIGNAL(valueChanged(double)), this, SLOT(setAngle()));
connect(spinOffsetX, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
connect(spinOffsetY, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
@@ -270,7 +270,7 @@ QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget(QWidget* pare

setupUi(this);

connect(spinInterval, SIGNAL(valueChanged(int)), this, SLOT(setInterval(int)));
connect(spinInterval, SIGNAL(valueChanged(double)), this, SLOT(setInterval(double)));
connect(btnChangeMarker, SIGNAL(clicked()), this, SLOT(setMarker()));
connect(chkRotateMarker, SIGNAL(clicked()), this, SLOT(setRotate()));
connect(spinOffset, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
@@ -296,7 +296,7 @@ QgsSymbolLayerV2* QgsMarkerLineSymbolLayerV2Widget::symbolLayer()
return mLayer;
}

void QgsMarkerLineSymbolLayerV2Widget::setInterval(int val)
void QgsMarkerLineSymbolLayerV2Widget::setInterval(double val)
{
mLayer->setInterval(val);
emit changed();
@@ -345,7 +345,7 @@ QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget(QWidget* parent
populateList();

connect(viewImages->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(setName(const QModelIndex&)));
connect(spinSize, SIGNAL(valueChanged(int)), this, SLOT(setSize()));
connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(setSize()));
connect(spinAngle, SIGNAL(valueChanged(double)), this, SLOT(setAngle()));
connect(spinOffsetX, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
connect(spinOffsetY, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
@@ -131,7 +131,7 @@ class QgsMarkerLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private

public slots:

void setInterval(int val);
void setInterval(double val);
void setMarker();
void setRotate();
void setOffset();
@@ -36,8 +36,8 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsSty

connect(btnSetColor, SIGNAL(clicked()), this, SLOT(setSymbolColor()));
connect(spinAngle, SIGNAL(valueChanged(double)), this, SLOT(setMarkerAngle(double)));
connect(spinSize, SIGNAL(valueChanged(int)), this, SLOT(setMarkerSize(int)));
connect(spinWidth, SIGNAL(valueChanged(int)), this, SLOT(setLineWidth(int)));
connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(setMarkerSize(double)));
connect(spinWidth, SIGNAL(valueChanged(double)), this, SLOT(setLineWidth(double)));

}

@@ -154,7 +154,7 @@ void QgsSymbolV2SelectorDialog::setMarkerAngle(double angle)
updateSymbolPreview();
}

void QgsSymbolV2SelectorDialog::setMarkerSize(int size)
void QgsSymbolV2SelectorDialog::setMarkerSize(double size)
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>(mSymbol);
if (markerSymbol->size() == size)
@@ -163,7 +163,7 @@ void QgsSymbolV2SelectorDialog::setMarkerSize(int size)
updateSymbolPreview();
}

void QgsSymbolV2SelectorDialog::setLineWidth(int width)
void QgsSymbolV2SelectorDialog::setLineWidth(double width)
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>(mSymbol);
if (lineSymbol->width() == width)
@@ -28,8 +28,8 @@ public slots:
void setSymbolFromStyle(const QModelIndex & index);
void setSymbolColor();
void setMarkerAngle(double angle);
void setMarkerSize(int size);
void setLineWidth(int width);
void setMarkerSize(double size);
void setLineWidth(double width);

protected:
QgsStyleV2* mStyle;
@@ -95,7 +95,7 @@
<item row="0" column="2">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="pageSingleSymbol">
<layout class="QGridLayout">
@@ -394,7 +394,11 @@
</layout>
</item>
<item>
<widget class="QTreeView" name="viewGraduated"/>
<widget class="QTreeView" name="viewGraduated">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">

0 comments on commit 9ae3ae2

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