331 changes: 331 additions & 0 deletions src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
#include "qgsellipsesymbollayerv2.h"
#include "qgsfeature.h"
#include "qgsrendercontext.h"
#include <QPainter>
#include <QSet>

QgsEllipseSymbolLayerV2::QgsEllipseSymbolLayerV2(): mSymbolName( "circle" ), mSymbolWidth( 4 ), mSymbolHeight( 3 ),
mFillColor( Qt::black ), mOutlineColor( Qt::white ), mOutlineWidth( 0 )
{
mPen.setColor( mOutlineColor );
mPen.setWidth( 1.0 );
mPen.setJoinStyle( Qt::MiterJoin );
mBrush.setColor( mFillColor );
mBrush.setStyle( Qt::SolidPattern );

mAngle = 0;
mWidthField.first = -1;
mHeightField.first = -1;
mRotationField.first = -1;
mOutlineWidthField.first = -1;
mFillColorField.first = -1;
mOutlineColorField.first = -1;
mSymbolNameField.first = -1;
}

QgsEllipseSymbolLayerV2::~QgsEllipseSymbolLayerV2()
{
}

QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& properties )
{
QgsEllipseSymbolLayerV2* layer = new QgsEllipseSymbolLayerV2();
if ( properties.contains( "symbol_name" ) )
{
layer->setSymbolName( properties[ "symbol_name" ] );
}
if ( properties.contains( "symbol_width" ) )
{
layer->setSymbolWidth( properties["symbol_width"].toDouble() );
}
if ( properties.contains( "symbol_height" ) )
{
layer->setSymbolHeight( properties["symbol_height"].toDouble() );
}
if ( properties.contains( "angle" ) )
{
layer->setAngle( properties["angle"].toDouble() );
}
if ( properties.contains( "outline_width" ) )
{
layer->setOutlineWidth( properties["outline_width"].toDouble() );
}
if ( properties.contains( "fill_color" ) )
{
layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["fill_color"] ) );
}
if ( properties.contains( "outline_color" ) )
{
layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["outline_color"] ) );
}

//data defined properties
if ( properties.contains( "height_index" ) && properties.contains( "height_field" ) )
{
layer->setHeightField( properties["height_index"].toInt(), properties["height_field"] );
}
if ( properties.contains( "width_index" ) && properties.contains( "width_field" ) )
{
layer->setWidthField( properties["width_index"].toInt(), properties["width_field"] );
}
if ( properties.contains( "rotation_index" ) && properties.contains( "rotation_field" ) )
{
layer->setRotationField( properties["rotation_index"].toInt(), properties["rotation_field"] );
}
if ( properties.contains( "outline_width_index" ) && properties.contains( "outline_width_field" ) )
{
layer->setOutlineWidthField( properties["outline_width_index"].toInt(), properties["outline_width_field"] );
}
if ( properties.contains( "fill_color_index" ) && properties.contains( "fill_color_field" ) )
{
layer->setFillColorField( properties["fill_color_index"].toInt(), properties["fill_color_field"] );
}
if ( properties.contains( "outline_color_index" ) && properties.contains( "outline_color_field" ) )
{
layer->setOutlineColorField( properties["outline_color_index"].toInt(), properties["outline_color_field"] );
}
if ( properties.contains( "symbol_name_index" ) && properties.contains( "symbol_name_field" ) )
{
layer->setSymbolNameField( properties["symbol_name_index"].toInt(), properties["symbol_name_field"] );
}

return layer;
}

void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
const QgsFeature* f = context.feature();

if ( f )
{
if ( mOutlineWidthField.first != -1 )
{
double width = context.outputLineWidth( f->attributeMap()[mOutlineWidthField.first].toDouble() );
mPen.setWidth( width );
}
if ( mFillColorField.first != -1 )
{
mBrush.setColor( QColor( f->attributeMap()[mFillColorField.first].toString() ) );
}
if ( mOutlineColorField.first != -1 )
{
mPen.setColor( QColor( f->attributeMap()[mOutlineColorField.first].toString() ) );
}

if ( mWidthField.first != -1 || mHeightField.first != -1 || mSymbolNameField.first != -1 )
{
QString symbolName = ( mSymbolNameField.first == -1 ) ? mSymbolName : f->attributeMap()[mSymbolNameField.first].toString();
preparePath( symbolName, context, f );
}
}

QPainter* p = context.renderContext().painter();
if ( !p )
{
return;
}

//priority for rotation: 1. data defined, 2. symbol layer rotation (mAngle)
double rotation = 0.0;
if ( f && mRotationField.first != -1 )
{
rotation = f->attributeMap()[mRotationField.first].toDouble();
}
else if ( !doubleNear( mAngle, 0.0 ) )
{
rotation = mAngle;
}

QMatrix transform;
transform.translate( point.x(), point.y() );
if ( !doubleNear( rotation, 0.0 ) )
{
transform.rotate( rotation );
}

p->setPen( mPen );
p->setBrush( mBrush );
p->drawPath( transform.map( mPainterPath ) );
}

QString QgsEllipseSymbolLayerV2::layerType() const
{
return "EllipseMarker";
}

void QgsEllipseSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
if ( !context.feature() || !hasDataDefinedProperty() )
{
preparePath( mSymbolName, context );
}
mPen.setColor( mOutlineColor );
mPen.setWidth( context.outputLineWidth( mOutlineWidth ) );
mBrush.setColor( mFillColor );
}

void QgsEllipseSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
{
}

QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::clone() const
{
return QgsEllipseSymbolLayerV2::create( properties() );
}

QgsStringMap QgsEllipseSymbolLayerV2::properties() const
{
QgsStringMap map;
map["symbol_name"] = mSymbolName;
map["symbol_width"] = QString::number( mSymbolWidth );
map["width_index"] = QString::number( mWidthField.first );
map["width_field"] = mWidthField.second;
map["symbol_height"] = QString::number( mSymbolHeight );
map["height_index"] = QString::number( mHeightField.first );
map["height_field"] = mHeightField.second;
map["angle"] = QString::number( mAngle );
map["rotation_index"] = QString::number( mRotationField.first );
map["rotation_field"] = mRotationField.second;
map["outline_width"] = QString::number( mOutlineWidth );
map["outline_width_index"] = QString::number( mOutlineWidthField.first );
map["outline_width_field"] = mOutlineWidthField.second;
map["fill_color"] = QgsSymbolLayerV2Utils::encodeColor( mFillColor );
map["fill_color_index"] = QString::number( mFillColorField.first );
map["fill_color_field"] = mFillColorField.second;
map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor );
map["outline_color_index"] = QString::number( mOutlineColorField.first );
map["outline_color_field"] = mOutlineColorField.second;
map["symbol_name_index"] = QString::number( mSymbolNameField.first );
map["symbol_name_field"] = mSymbolNameField.second;
return map;
}

bool QgsEllipseSymbolLayerV2::hasDataDefinedProperty() const
{
return ( mWidthField.first != -1 || mHeightField.first != -1 || mOutlineWidthField.first != -1
|| mFillColorField.first != -1 || mOutlineColorField.first != -1 );
}

void QgsEllipseSymbolLayerV2::preparePath( const QString& symbolName, QgsSymbolV2RenderContext& context, const QgsFeature* f )
{
mPainterPath = QPainterPath();

double width = 0;
if ( f && mWidthField.first != -1 )
{
width = context.outputLineWidth( f->attributeMap()[mWidthField.first].toDouble() );
}
else
{
width = context.outputLineWidth( mSymbolWidth );
}

double height = 0;
if ( f && mHeightField.first != -1 )
{
height = context.outputLineWidth( f->attributeMap()[mHeightField.first].toDouble() );
}
else
{
height = context.outputLineWidth( mSymbolHeight );
}

if ( symbolName == "circle" )
{
mPainterPath.addEllipse( QRectF( -width / 2.0, -height / 2.0, width, height ) );
}
else if ( symbolName == "rectangle" )
{
mPainterPath.addRect( QRectF( -width / 2.0, -height / 2.0, width, height ) );
}
else if ( symbolName == "cross" )
{
mPainterPath.moveTo( 0, -height / 2.0 );
mPainterPath.lineTo( 0, height / 2.0 );
mPainterPath.moveTo( -width / 2.0, 0 );
mPainterPath.lineTo( width / 2.0, 0 );
}
else if ( symbolName == "triangle" )
{
mPainterPath.moveTo( 0, -height / 2.0 );
mPainterPath.lineTo( -width / 2.0, height / 2.0 );
mPainterPath.lineTo( width / 2.0, height / 2.0 );
mPainterPath.lineTo( 0, -height / 2.0 );
}
}

QSet<QString> QgsEllipseSymbolLayerV2::usedAttributes() const
{
QSet<QString> dataDefinedAttributes;
if ( mWidthField.first != -1 )
{
dataDefinedAttributes.insert( mWidthField.second );
}
if ( mHeightField.first != -1 )
{
dataDefinedAttributes.insert( mHeightField.second );
}
if ( mRotationField.first != -1 )
{
dataDefinedAttributes.insert( mRotationField.second );
}
if ( mOutlineWidthField.first != -1 )
{
dataDefinedAttributes.insert( mOutlineWidthField.second );
}
if ( mFillColorField.first != -1 )
{
dataDefinedAttributes.insert( mFillColorField.second );
}
if ( mOutlineColorField.first != -1 )
{
dataDefinedAttributes.insert( mOutlineColorField.second );
}
if ( mSymbolNameField.first != -1 )
{
dataDefinedAttributes.insert( mSymbolNameField.second );
}
return dataDefinedAttributes;
}

void QgsEllipseSymbolLayerV2::setSymbolNameField( int index, const QString& field )
{
mSymbolNameField.first = index;
mSymbolNameField.second = field;
}

void QgsEllipseSymbolLayerV2::setWidthField( int index, const QString& field )
{
mWidthField.first = index;
mWidthField.second = field;
}

void QgsEllipseSymbolLayerV2::setHeightField( int index, const QString& field )
{
mHeightField.first = index;
mHeightField.second = field;
}

void QgsEllipseSymbolLayerV2::setRotationField( int index, const QString& field )
{
mRotationField.first = index;
mRotationField.second = field;
}

void QgsEllipseSymbolLayerV2::setOutlineWidthField( int index, const QString& field )
{
mOutlineWidthField.first = index;
mOutlineWidthField.second = field;
}

void QgsEllipseSymbolLayerV2::setFillColorField( int index, const QString& field )
{
mFillColorField.first = index;
mFillColorField.second = field;
}

void QgsEllipseSymbolLayerV2::setOutlineColorField( int index, const QString& field )
{
mOutlineColorField.first = index;
mOutlineColorField.second = field;
}
100 changes: 100 additions & 0 deletions src/core/symbology-ng/qgsellipsesymbollayerv2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#ifndef QGSELLIPSESYMBOLLAYERV2_H
#define QGSELLIPSESYMBOLLAYERV2_H

#include "qgsmarkersymbollayerv2.h"
#include <QPainterPath>

/**A symbol layer for rendering objects with major and minor axis (e.g. ellipse, rectangle )*/
class CORE_EXPORT QgsEllipseSymbolLayerV2: public QgsMarkerSymbolLayerV2
{
public:
QgsEllipseSymbolLayerV2();
~QgsEllipseSymbolLayerV2();

static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );

void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
QString layerType() const;
void startRender( QgsSymbolV2RenderContext& context );
void stopRender( QgsSymbolV2RenderContext& context );
QgsSymbolLayerV2* clone() const;
QgsStringMap properties() const;

void setSymbolName( const QString& name ){ mSymbolName = name; }
QString symbolName() const{ return mSymbolName; }

void setSymbolNameField( int index, const QString& field );
const QPair<int, QString>& symbolNameField() const { return mSymbolNameField; }

void setSymbolWidth( double w ){ mSymbolWidth = w; }
double symbolWidth() const { return mSymbolWidth; }

void setWidthField( int index, const QString& field );
const QPair<int, QString>& widthField() const { return mWidthField; }

void setSymbolHeight( double h ){ mSymbolHeight = h; }
double symbolHeight() const { return mSymbolHeight; }

void setHeightField( int index, const QString& field );
const QPair<int, QString>& heightField() const { return mHeightField; }

void setRotationField( int index, const QString& field );
const QPair<int, QString>& rotationField() const { return mRotationField; }

void setOutlineWidth( double w ){ mOutlineWidth = w; }
double outlineWidth() const { return mOutlineWidth; }

void setOutlineWidthField( int index, const QString& field );
const QPair<int, QString>& outlineWidthField() const { return mOutlineWidthField; }

void setFillColor( const QColor& c ){ mFillColor = c;}
QColor fillColor() const { return mFillColor; }

void setFillColorField( int index, const QString& field );
const QPair<int, QString>& fillColorField() const { return mFillColorField; }

void setOutlineColor( const QColor& c ){ mOutlineColor = c; }
QColor outlineColor() const { return mOutlineColor; }

void setOutlineColorField( int index, const QString& field );
const QPair<int, QString>& outlineColorField() const { return mOutlineColorField; }

QSet<QString> usedAttributes() const;

private:
QString mSymbolName;
double mSymbolWidth;
double mSymbolHeight;
QColor mFillColor;
QColor mOutlineColor;
double mOutlineWidth;

/**Take width from attribute (-1 if fixed width)*/
QPair<int, QString> mWidthField;
/**Take height from attribute (-1 if fixed height)*/
QPair<int, QString> mHeightField;
/**Take symbol rotation from attribute (-1 if fixed rotation)*/
QPair<int, QString> mRotationField;
/**Take outline width from attribute (-1 if fixed outline width)*/
QPair<int, QString> mOutlineWidthField;
/**Take fill color from attribute (-1 if fixed fill color)*/
QPair<int, QString> mFillColorField;
/**Take outline color from attribute (-1 if fixed outline color)*/
QPair<int, QString> mOutlineColorField;
/**Take shape name from attribute (-1 if fixed shape type)*/
QPair<int, QString> mSymbolNameField;

QPainterPath mPainterPath;

QPen mPen;
QBrush mBrush;

/**Setup mPainterPath
@param feature to render (0 if no data defined rendering)*/
void preparePath( const QString& symbolName, QgsSymbolV2RenderContext& context, const QgsFeature* f = 0 );

/**True if this symbol layer uses a data defined property*/
bool hasDataDefinedProperty() const;
};

#endif // QGSELLIPSESYMBOLLAYERV2_H
6 changes: 3 additions & 3 deletions src/core/symbology-ng/qgsfillsymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ void QgsSVGFillSymbolLayer::renderPolygon( const QPolygonF& points, QList<QPolyg
_renderPolygon( p, points, rings );
if ( mOutline )
{
mOutline->renderPolyline( points, context.renderContext(), -1, selectFillBorder && context.selected() );
mOutline->renderPolyline( points, context.feature(), context.renderContext(), -1, selectFillBorder && context.selected() );
if ( rings )
{
QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
for ( ; ringIt != rings->constEnd(); ++ringIt )
{
mOutline->renderPolyline( *ringIt, context.renderContext(), -1, selectFillBorder && context.selected() );
mOutline->renderPolyline( *ringIt, context.feature(), context.renderContext(), -1, selectFillBorder && context.selected() );
}
}
}
Expand Down Expand Up @@ -416,7 +416,7 @@ void QgsCentroidFillSymbolLayerV2::renderPolygon( const QPolygonF& points, QList
cx /= sum;
cy /= sum;

mMarker->renderPoint( QPointF( cx, cy ), context.renderContext(), -1, context.selected() );
mMarker->renderPoint( QPointF( cx, cy ), context.feature(), context.renderContext(), -1, context.selected() );
}

QgsStringMap QgsCentroidFillSymbolLayerV2::properties() const
Expand Down
25 changes: 20 additions & 5 deletions src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,28 @@ void QgsGraduatedSymbolRendererV2::stopRender( QgsRenderContext& context )

QList<QString> QgsGraduatedSymbolRendererV2::usedAttributes()
{
QList<QString> lst;
lst.append( mAttrName );
QSet<QString> attributes;
attributes.insert( mAttrName );
if ( !mRotationField.isEmpty() )
lst.append( mRotationField );
{
attributes.insert( mRotationField );
}
if ( !mSizeScaleField.isEmpty() )
lst.append( mSizeScaleField );
return lst;
{
attributes.insert( mSizeScaleField );
}

QgsSymbolV2* symbol = 0;
QgsRangeList::const_iterator range_it = mRanges.constBegin();
for ( ; range_it != mRanges.constEnd(); ++range_it )
{
symbol = range_it->symbol();
if ( symbol )
{
attributes.unite( symbol->usedAttributes() );
}
}
return attributes.toList();
}

bool QgsGraduatedSymbolRendererV2::updateRangeSymbol( int rangeIndex, QgsSymbolV2* symbol )
Expand Down
8 changes: 4 additions & 4 deletions src/core/symbology-ng/qgslinesymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void QgsMarkerLineSymbolLayerV2::renderPolylineInterval( const QPolygonF& points
// draw first marker
if ( first )
{
mMarker->renderPoint( lastPt, rc, -1, context.selected() );
mMarker->renderPoint( lastPt, context.feature(), rc, -1, context.selected() );
first = false;
}

Expand All @@ -365,7 +365,7 @@ void QgsMarkerLineSymbolLayerV2::renderPolylineInterval( const QPolygonF& points
// "c" is 1 for regular point or in interval (0,1] for begin of line segment
lastPt += c * diff;
lengthLeft -= painterUnitInterval;
mMarker->renderPoint( lastPt, rc, -1, context.selected() );
mMarker->renderPoint( lastPt, context.feature(), rc, -1, context.selected() );
c = 1; // reset c (if wasn't 1 already)
}

Expand Down Expand Up @@ -474,7 +474,7 @@ void QgsMarkerLineSymbolLayerV2::renderPolylineVertex( const QPolygonF& points,
mMarker->setAngle( origAngle + angle * 180 / M_PI );
}

mMarker->renderPoint( points.at( i ), rc, -1, context.selected() );
mMarker->renderPoint( points.at( i ), context.feature(), rc, -1, context.selected() );
}

// restore original rotation
Expand Down Expand Up @@ -521,7 +521,7 @@ void QgsMarkerLineSymbolLayerV2::renderPolylineCentral( const QPolygonF& points,
double origAngle = mMarker->angle();
if ( mRotateMarker )
mMarker->setAngle( origAngle + l.angle() * 180 / M_PI );
mMarker->renderPoint( pt, context.renderContext(), -1, context.selected() );
mMarker->renderPoint( pt, context.feature(), context.renderContext(), -1, context.selected() );
if ( mRotateMarker )
mMarker->setAngle( origAngle );
}
Expand Down
12 changes: 6 additions & 6 deletions src/core/symbology-ng/qgsrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext&
}
QPointF pt;
_getPoint( pt, context, geom->asWkb() );
(( QgsMarkerSymbolV2* )symbol )->renderPoint( pt, context, layer, selected );
(( QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );

//if ( drawVertexMarker )
// renderVertexMarker( pt, context );
Expand All @@ -219,7 +219,7 @@ void QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext&
}
QPolygonF pts;
_getLineString( pts, context, geom->asWkb() );
(( QgsLineSymbolV2* )symbol )->renderPolyline( pts, context, layer, selected );
(( QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );

if ( drawVertexMarker )
renderVertexMarkerPolyline( pts, context );
Expand All @@ -237,7 +237,7 @@ void QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext&
QPolygonF pts;
QList<QPolygonF> holes;
_getPolygon( pts, holes, context, geom->asWkb() );
(( QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), context, layer, selected );
(( QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );

if ( drawVertexMarker )
renderVertexMarkerPolygon( pts, ( holes.count() ? &holes : NULL ), context );
Expand All @@ -261,7 +261,7 @@ void QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext&
for ( unsigned int i = 0; i < num; ++i )
{
ptr = _getPoint( pt, context, ptr );
(( QgsMarkerSymbolV2* )symbol )->renderPoint( pt, context, layer, selected );
(( QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );

//if ( drawVertexMarker )
// renderVertexMarker( pt, context );
Expand All @@ -286,7 +286,7 @@ void QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext&
for ( unsigned int i = 0; i < num; ++i )
{
ptr = _getLineString( pts, context, ptr );
(( QgsLineSymbolV2* )symbol )->renderPolyline( pts, context, layer, selected );
(( QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );

if ( drawVertexMarker )
renderVertexMarkerPolyline( pts, context );
Expand All @@ -312,7 +312,7 @@ void QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext&
for ( unsigned int i = 0; i < num; ++i )
{
ptr = _getPolygon( pts, holes, context, ptr );
(( QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), context, layer, selected );
(( QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );

if ( drawVertexMarker )
renderVertexMarkerPolygon( pts, ( holes.count() ? &holes : NULL ), context );
Expand Down
4 changes: 4 additions & 0 deletions src/core/symbology-ng/qgsrulebasedrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ QList<QString> QgsRuleBasedRendererV2::usedAttributes()
{
Rule& rule = *it;
attrs.unite( rule.needsFields().toSet() );
if ( rule.symbol() )
{
attrs.unite( rule.symbol()->usedAttributes() );
}
}
return attrs.values();
}
Expand Down
16 changes: 12 additions & 4 deletions src/core/symbology-ng/qgssinglesymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,20 @@ void QgsSingleSymbolRendererV2::stopRender( QgsRenderContext& context )

QList<QString> QgsSingleSymbolRendererV2::usedAttributes()
{
QList<QString> lst;
QSet<QString> attributes;
if( mSymbol )
{
attributes.unite( mSymbol->usedAttributes() );
}
if ( !mRotationField.isEmpty() )
lst.append( mRotationField );
{
attributes.insert( mRotationField );
}
if ( !mSizeScaleField.isEmpty() )
lst.append( mSizeScaleField );
return lst;
{
attributes.insert( mSizeScaleField );
}
return attributes.toList();
}

QgsSymbolV2* QgsSingleSymbolRendererV2::symbol() const
Expand Down
7 changes: 6 additions & 1 deletion src/core/symbology-ng/qgssymbollayerv2.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#ifndef QGSSYMBOLLAYERV2_H
#define QGSSYMBOLLAYERV2_H

#include <QMap>


#include <QColor>
#include <QMap>
#include <QPointF>
#include <QSet>

#include "qgssymbolv2.h"

Expand Down Expand Up @@ -52,6 +54,9 @@ class CORE_EXPORT QgsSymbolLayerV2
void setRenderingPass( int renderingPass ) { mRenderingPass = renderingPass; }
int renderingPass() const { return mRenderingPass; }

// symbol layers normally only use additional attributes to provide data defined settings
virtual QSet<QString> usedAttributes() const { return QSet<QString>(); }

protected:
QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false )
: mType( type ), mLocked( locked ), mRenderingPass( 0 ) {}
Expand Down
3 changes: 3 additions & 0 deletions src/core/symbology-ng/qgssymbollayerv2registry.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include "qgssymbollayerv2registry.h"

#include "qgsellipsesymbollayerv2.h"
#include "qgsmarkersymbollayerv2.h"
#include "qgslinesymbollayerv2.h"
#include "qgsfillsymbollayerv2.h"
Expand All @@ -23,6 +24,8 @@ QgsSymbolLayerV2Registry::QgsSymbolLayerV2Registry()
QgsSvgMarkerSymbolLayerV2::create ) );
addSymbolLayerType( new QgsSymbolLayerV2Metadata( "FontMarker", QObject::tr( "Font marker" ), QgsSymbolV2::Marker,
QgsFontMarkerSymbolLayerV2::create ) );
addSymbolLayerType( new QgsSymbolLayerV2Metadata( "EllipseMarker", QObject::tr("Ellipse marker"), QgsSymbolV2::Marker,
QgsEllipseSymbolLayerV2::create ) );

addSymbolLayerType( new QgsSymbolLayerV2Metadata( "SimpleFill", QObject::tr( "Simple fill" ), QgsSymbolV2::Fill,
QgsSimpleFillSymbolLayerV2::create ) );
Expand Down
8 changes: 5 additions & 3 deletions src/core/symbology-ng/qgssymbollayerv2registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "qgssymbolv2.h"
#include "qgssymbollayerv2.h"

class QgsVectorLayer;

/**
Stores metadata about one symbol layer class.
Expand All @@ -24,7 +26,7 @@ class CORE_EXPORT QgsSymbolLayerV2AbstractMetadata
/** create a symbol layer of this type given the map of properties. */
virtual QgsSymbolLayerV2* createSymbolLayer( const QgsStringMap& map ) = 0;
/** create widget for symbol layer of this type. Can return NULL if there's no GUI */
virtual QgsSymbolLayerV2Widget* createSymbolLayerWidget() { return NULL; }
virtual QgsSymbolLayerV2Widget* createSymbolLayerWidget( const QgsVectorLayer* vl ) { return NULL; }

protected:
QString mName;
Expand All @@ -33,7 +35,7 @@ class CORE_EXPORT QgsSymbolLayerV2AbstractMetadata
};

typedef QgsSymbolLayerV2*( *QgsSymbolLayerV2CreateFunc )( const QgsStringMap& );
typedef QgsSymbolLayerV2Widget*( *QgsSymbolLayerV2WidgetFunc )();
typedef QgsSymbolLayerV2Widget*( *QgsSymbolLayerV2WidgetFunc )( const QgsVectorLayer* );

/**
Convenience metadata class that uses static functions to create symbol layer and its widget.
Expand All @@ -53,7 +55,7 @@ class CORE_EXPORT QgsSymbolLayerV2Metadata : public QgsSymbolLayerV2AbstractMeta
void setWidgetFunction( QgsSymbolLayerV2WidgetFunc f ) { mWidgetFunc = f; }

virtual QgsSymbolLayerV2* createSymbolLayer( const QgsStringMap& map ) { return mCreateFunc ? mCreateFunc( map ) : NULL; }
virtual QgsSymbolLayerV2Widget* createSymbolLayerWidget() { return mWidgetFunc ? mWidgetFunc() : NULL; }
virtual QgsSymbolLayerV2Widget* createSymbolLayerWidget( const QgsVectorLayer* vl ) { return mWidgetFunc ? mWidgetFunc( vl ) : NULL; }

protected:
QgsSymbolLayerV2CreateFunc mCreateFunc;
Expand Down
36 changes: 25 additions & 11 deletions src/core/symbology-ng/qgssymbolv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,17 @@ QImage QgsSymbolV2::bigSymbolPreviewImage()
{
QPolygonF poly;
poly << QPointF( 0, 50 ) << QPointF( 99, 50 );
static_cast<QgsLineSymbolV2*>( this )->renderPolyline( poly, context );
static_cast<QgsLineSymbolV2*>( this )->renderPolyline( poly, 0, context );
}
else if ( mType == QgsSymbolV2::Fill )
{
QPolygonF polygon;
polygon << QPointF( 20, 20 ) << QPointF( 80, 20 ) << QPointF( 80, 80 ) << QPointF( 20, 80 ) << QPointF( 20, 20 );
static_cast<QgsFillSymbolV2*>( this )->renderPolygon( polygon, NULL, context );
static_cast<QgsFillSymbolV2*>( this )->renderPolygon( polygon, NULL, 0, context );
}
else // marker
{
static_cast<QgsMarkerSymbolV2*>( this )->renderPoint( QPointF( 50, 50 ), context );
static_cast<QgsMarkerSymbolV2*>( this )->renderPoint( QPointF( 50, 50 ), 0, context );
}

stopRender( context );
Expand Down Expand Up @@ -265,10 +265,24 @@ QgsSymbolLayerV2List QgsSymbolV2::cloneLayers() const
return lst;
}

QSet<QString> QgsSymbolV2::usedAttributes() const
{
QSet<QString> attributes;
QgsSymbolLayerV2List::const_iterator sIt = mLayers.constBegin();
for(; sIt != mLayers.constEnd(); ++sIt )
{
if( *sIt )
{
attributes.unite( (*sIt)->usedAttributes() );
}
}
return attributes;
}

////////////////////

QgsSymbolV2RenderContext::QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u, qreal alpha, bool selected, int renderHints )
: mRenderContext( c ), mOutputUnit( u ), mAlpha( alpha ), mSelected( selected ), mRenderHints( renderHints )
QgsSymbolV2RenderContext::QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u, qreal alpha, bool selected, int renderHints, const QgsFeature* f )
: mRenderContext( c ), mOutputUnit( u ), mAlpha( alpha ), mSelected( selected ), mRenderHints( renderHints ), mFeature( f )
{

}
Expand Down Expand Up @@ -402,9 +416,9 @@ double QgsMarkerSymbolV2::size()
return maxSize;
}

void QgsMarkerSymbolV2::renderPoint( const QPointF& point, QgsRenderContext& context, int layer, bool selected )
void QgsMarkerSymbolV2::renderPoint( const QPointF& point, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
{
QgsSymbolV2RenderContext symbolContext( context, mOutputUnit, mAlpha, selected, mRenderHints );
QgsSymbolV2RenderContext symbolContext( context, mOutputUnit, mAlpha, selected, mRenderHints, f );
if ( layer != -1 )
{
if ( layer >= 0 && layer < mLayers.count() )
Expand Down Expand Up @@ -471,9 +485,9 @@ double QgsLineSymbolV2::width()
return maxWidth;
}

void QgsLineSymbolV2::renderPolyline( const QPolygonF& points, QgsRenderContext& context, int layer, bool selected )
void QgsLineSymbolV2::renderPolyline( const QPolygonF& points, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
{
QgsSymbolV2RenderContext symbolContext( context, mOutputUnit, mAlpha, selected, mRenderHints );
QgsSymbolV2RenderContext symbolContext( context, mOutputUnit, mAlpha, selected, mRenderHints, f );
if ( layer != -1 )
{
if ( layer >= 0 && layer < mLayers.count() )
Expand Down Expand Up @@ -507,9 +521,9 @@ QgsFillSymbolV2::QgsFillSymbolV2( QgsSymbolLayerV2List layers )
mLayers.append( new QgsSimpleFillSymbolLayerV2() );
}

void QgsFillSymbolV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context, int layer, bool selected )
void QgsFillSymbolV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
{
QgsSymbolV2RenderContext symbolContext( context, mOutputUnit, mAlpha, selected, mRenderHints );
QgsSymbolV2RenderContext symbolContext( context, mOutputUnit, mAlpha, selected, mRenderHints, f );
if ( layer != -1 )
{
if ( layer >= 0 && layer < mLayers.count() )
Expand Down
15 changes: 11 additions & 4 deletions src/core/symbology-ng/qgssymbolv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class QPointF;
class QPolygonF;
//class

class QgsFeature;
class QgsSymbolLayerV2;
class QgsRenderContext;

Expand Down Expand Up @@ -98,6 +99,8 @@ class CORE_EXPORT QgsSymbolV2
//! @note added in 1.5
int renderHints() { return mRenderHints; }

QSet<QString> usedAttributes() const;

protected:
QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers ); // can't be instantiated

Expand All @@ -124,7 +127,7 @@ class CORE_EXPORT QgsSymbolV2
class CORE_EXPORT QgsSymbolV2RenderContext
{
public:
QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u , qreal alpha = 1.0, bool selected = false, int renderHints = 0 );
QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u , qreal alpha = 1.0, bool selected = false, int renderHints = 0, const QgsFeature* f = 0 );
~QgsSymbolV2RenderContext();

QgsRenderContext& renderContext() { return mRenderContext; }
Expand All @@ -144,6 +147,9 @@ class CORE_EXPORT QgsSymbolV2RenderContext
//! @note added in 1.5
void setRenderHints( int hints ) { mRenderHints = hints; }

void setFeature( const QgsFeature* f ){ mFeature = f; }
const QgsFeature* feature() const { return mFeature; }

// Color used for selections
static QColor selectionColor();

Expand All @@ -159,6 +165,7 @@ class CORE_EXPORT QgsSymbolV2RenderContext
qreal mAlpha;
bool mSelected;
int mRenderHints;
const QgsFeature* mFeature; //current feature
};


Expand All @@ -184,7 +191,7 @@ class CORE_EXPORT QgsMarkerSymbolV2 : public QgsSymbolV2
void setSize( double size );
double size();

void renderPoint( const QPointF& point, QgsRenderContext& context, int layer = -1, bool selected = false );
void renderPoint( const QPointF& point, const QgsFeature* f, QgsRenderContext& context, int layer = -1, bool selected = false );

virtual QgsSymbolV2* clone() const;
};
Expand All @@ -205,7 +212,7 @@ class CORE_EXPORT QgsLineSymbolV2 : public QgsSymbolV2
void setWidth( double width );
double width();

void renderPolyline( const QPolygonF& points, QgsRenderContext& context, int layer = -1, bool selected = false );
void renderPolyline( const QPolygonF& points, const QgsFeature* f, QgsRenderContext& context, int layer = -1, bool selected = false );

virtual QgsSymbolV2* clone() const;
};
Expand All @@ -223,7 +230,7 @@ class CORE_EXPORT QgsFillSymbolV2 : public QgsSymbolV2

QgsFillSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );
void setAngle( double angle );
void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context, int layer = -1, bool selected = false );
void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, const QgsFeature* f, QgsRenderContext& context, int layer = -1, bool selected = false );

virtual QgsSymbolV2* clone() const;
};
Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ symbology-ng/qgsvectorrandomcolorrampv2dialog.cpp
symbology-ng/qgsvectorcolorbrewercolorrampv2dialog.cpp
symbology-ng/characterwidget.cpp
symbology-ng/qgsstylev2exportimportdialog.cpp
symbology-ng/qgsellipsesymbollayerv2widget.cpp

attributetable/qgsattributetablemodel.cpp
attributetable/qgsattributetablememorymodel.cpp
Expand Down Expand Up @@ -93,6 +94,7 @@ symbology-ng/characterwidget.h
symbology-ng/qgspenstylecombobox.h
symbology-ng/qgsbrushstylecombobox.h
symbology-ng/qgsstylev2exportimportdialog.h
symbology-ng/qgsellipsesymbollayerv2widget.h

attributetable/qgsattributetableview.h
attributetable/qgsattributetablemodel.h
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsannotationitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void QgsAnnotationItem::drawMarkerSymbol( QPainter* p )
if ( mMarkerSymbol )
{
mMarkerSymbol->startRender( renderContext );
mMarkerSymbol->renderPoint( QPointF( 0, 0 ), renderContext );
mMarkerSymbol->renderPoint( QPointF( 0, 0 ), 0, renderContext );
mMarkerSymbol->stopRender( renderContext );
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ QgsFeatureRendererV2* QgsCategorizedSymbolRendererV2Widget::renderer()

void QgsCategorizedSymbolRendererV2Widget::changeCategorizedSymbol()
{
QgsSymbolV2SelectorDialog dlg( mCategorizedSymbol, mStyle, this );
QgsSymbolV2SelectorDialog dlg( mCategorizedSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
return;

Expand Down Expand Up @@ -207,7 +207,7 @@ void QgsCategorizedSymbolRendererV2Widget::changeCategorySymbol()
int catIdx = mRenderer->categoryIndexForValue( k );
QgsSymbolV2* newSymbol = mRenderer->categories()[catIdx].symbol()->clone();

QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, this );
QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
{
delete newSymbol;
Expand Down
278 changes: 278 additions & 0 deletions src/gui/symbology-ng/qgsellipsesymbollayerv2widget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
#include "qgsellipsesymbollayerv2widget.h"
#include "qgsellipsesymbollayerv2.h"
#include "qgsmaplayerregistry.h"
#include "qgsvectorlayer.h"
#include <QColorDialog>

QgsEllipseSymbolLayerV2Widget::QgsEllipseSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent ): QgsSymbolLayerV2Widget( parent, vl )
{
setupUi( this );
QStringList names;
names << "circle" << "rectangle" << "cross" << "triangle";
QSize iconSize = mShapeListWidget->iconSize();

QStringList::const_iterator nameIt = names.constBegin();
for(; nameIt != names.constEnd(); ++nameIt )
{
QgsEllipseSymbolLayerV2* lyr = new QgsEllipseSymbolLayerV2();
lyr->setSymbolName( *nameIt );
lyr->setOutlineColor( QColor( 0, 0, 0 ) );
lyr->setFillColor( QColor( 200, 200, 200 ) );
lyr->setSymbolWidth(4);
lyr->setSymbolHeight(2);
QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( lyr, QgsSymbolV2::MM, iconSize );
QListWidgetItem* item = new QListWidgetItem( icon, "", mShapeListWidget );
item->setToolTip( *nameIt );
item->setData( Qt::UserRole, *nameIt );
delete lyr;
}

blockComboSignals( true );
fillDataDefinedComboBoxes();
blockComboSignals( false );
}

void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
{
if( layer->layerType() != "EllipseMarker" )
{
return;
}

mLayer = static_cast<QgsEllipseSymbolLayerV2*>( layer );
mWidthSpinBox->setValue( mLayer->symbolWidth() );
mHeightSpinBox->setValue( mLayer->symbolHeight() );
mRotationSpinBox->setValue( mLayer->angle() );
mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );

QList<QListWidgetItem *> symbolItemList = mShapeListWidget->findItems( mLayer->symbolName(), Qt::MatchExactly );
if( symbolItemList.size() > 0 )
{
mShapeListWidget->setCurrentItem( symbolItemList.at( 0 ) );
}

//set combo entries to current values
blockComboSignals( true );
if( mLayer )
{
if( mLayer->widthField().first != -1 )
{
mDDSymbolWidthComboBox->setCurrentIndex( mDDSymbolWidthComboBox->findText( mLayer->widthField().second ) );
}
if( mLayer->heightField().first != -1 )
{
mDDSymbolHeightComboBox->setCurrentIndex( mDDSymbolHeightComboBox->findText( mLayer->heightField().second ) );
}
if( mLayer->rotationField().first != -1 )
{
mDDRotationComboBox->setCurrentIndex( mDDRotationComboBox->findText( mLayer->rotationField().second ) );
}
if( mLayer->outlineWidthField().first != -1 )
{
mDDOutlineWidthComboBox->setCurrentIndex( mDDOutlineWidthComboBox->findText( mLayer->outlineWidthField().second ) );
}
if( mLayer->fillColorField().first != -1 )
{
mDDFillColorComboBox->setCurrentIndex( mDDFillColorComboBox->findText( mLayer->fillColorField().second ) );
}
if( mLayer->outlineColorField().first != -1 )
{
mDDOutlineColorComboBox->setCurrentIndex( mDDOutlineColorComboBox->findText( mLayer->outlineColorField().second ) );
}
if( mLayer->symbolNameField().first != -1 )
{
mDDShapeComboBox->setCurrentIndex( mDDShapeComboBox->findText( mLayer->symbolNameField().second ) );
}
}
blockComboSignals( false );
}

QgsSymbolLayerV2* QgsEllipseSymbolLayerV2Widget::symbolLayer()
{
return mLayer;
}

void QgsEllipseSymbolLayerV2Widget::on_mShapeListWidget_itemSelectionChanged()
{
if( mLayer )
{
QListWidgetItem* item = mShapeListWidget->currentItem();
if( item )
{
mLayer->setSymbolName( item->data( Qt::UserRole ).toString() );
emit changed();
}
}
}

void QgsEllipseSymbolLayerV2Widget::on_mWidthSpinBox_valueChanged( double d )
{
if( mLayer )
{
mLayer->setSymbolWidth( d );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mHeightSpinBox_valueChanged( double d )
{
if( mLayer )
{
mLayer->setSymbolHeight( d );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mRotationSpinBox_valueChanged( double d )
{
if( mLayer )
{
mLayer->setAngle( d );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mOutlineWidthSpinBox_valueChanged( double d )
{
if( mLayer )
{
mLayer->setOutlineWidth( d );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_btnChangeColorBorder_clicked()
{
if( mLayer )
{
QColor newColor = QColorDialog::getColor( mLayer->outlineColor() );
if( newColor.isValid() )
{
mLayer->setOutlineColor( newColor );
emit changed();
}
}
}

void QgsEllipseSymbolLayerV2Widget::on_btnChangeColorFill_clicked()
{
if( mLayer )
{
QColor newColor = QColorDialog::getColor( mLayer->fillColor() );
if( newColor.isValid() )
{
mLayer->setFillColor( newColor );
emit changed();
}
}
}

void QgsEllipseSymbolLayerV2Widget::fillDataDefinedComboBoxes()
{
mDDSymbolWidthComboBox->clear();
mDDSymbolWidthComboBox->addItem( "", -1 );
mDDSymbolHeightComboBox->clear();
mDDSymbolHeightComboBox->addItem( "", -1 );
mDDRotationComboBox->clear();
mDDRotationComboBox->addItem( "", -1 );
mDDOutlineWidthComboBox->clear();
mDDOutlineWidthComboBox->addItem( "", -1 );
mDDFillColorComboBox->clear();
mDDFillColorComboBox->addItem( "", -1 );
mDDOutlineColorComboBox->clear();
mDDOutlineColorComboBox->addItem( "", -1 );
mDDShapeComboBox->clear();
mDDShapeComboBox->addItem( "", -1 );

if( mVectorLayer )
{
const QgsFieldMap& fm =mVectorLayer->pendingFields();
QgsFieldMap::const_iterator fieldIt = fm.constBegin();
for(; fieldIt != fm.constEnd(); ++fieldIt )
{
QString fieldName = fieldIt.value().name();
int index = fieldIt.key();

mDDSymbolWidthComboBox->addItem( fieldName, index );
mDDSymbolHeightComboBox->addItem( fieldName, index );
mDDRotationComboBox->addItem( fieldName, index );
mDDOutlineWidthComboBox->addItem( fieldName, index );
mDDFillColorComboBox->addItem( fieldName, index );
mDDOutlineColorComboBox->addItem( fieldName, index );
mDDShapeComboBox->addItem( fieldName, index );
}
}
}

void QgsEllipseSymbolLayerV2Widget::on_mDDSymbolWidthComboBox_currentIndexChanged( int idx )
{
if( mLayer )
{
mLayer->setWidthField( mDDSymbolWidthComboBox->itemData( idx ).toInt(), mDDSymbolWidthComboBox->itemText( idx ) );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mDDSymbolHeightComboBox_currentIndexChanged( int idx )
{
if( mLayer )
{
mLayer->setHeightField( mDDSymbolHeightComboBox->itemData( idx ).toInt(), mDDSymbolHeightComboBox->itemText( idx ));
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mDDRotationComboBox_currentIndexChanged( int idx )
{
if( mLayer )
{
mLayer->setRotationField( mDDRotationComboBox->itemData( idx ).toInt(), mDDRotationComboBox->itemText( idx ) );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mDDOutlineWidthComboBox_currentIndexChanged( int idx )
{
if( mLayer )
{
mLayer->setOutlineWidthField( mDDOutlineWidthComboBox->itemData( idx ).toInt(), mDDOutlineWidthComboBox->itemText( idx ) );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mDDFillColorComboBox_currentIndexChanged( int idx )
{
if( mLayer )
{
mLayer->setFillColorField( mDDFillColorComboBox->itemData( idx ).toInt(), mDDFillColorComboBox->itemText( idx ) );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mDDOutlineColorComboBox_currentIndexChanged( int idx )
{
if( mLayer )
{
mLayer->setOutlineColorField( mDDOutlineColorComboBox->itemData( idx ).toInt(), mDDOutlineColorComboBox->itemText( idx ) );
emit changed();
}
}

void QgsEllipseSymbolLayerV2Widget::on_mDDShapeComboBox_currentIndexChanged( int idx )
{
if( mLayer )
{
mLayer->setSymbolNameField( mDDShapeComboBox->itemData( idx ).toInt(), mDDShapeComboBox->itemText( idx ) );
}
}

void QgsEllipseSymbolLayerV2Widget::blockComboSignals( bool block )
{
mDDSymbolWidthComboBox->blockSignals( block );
mDDSymbolHeightComboBox->blockSignals( block );
mDDRotationComboBox->blockSignals( block );
mDDOutlineWidthComboBox->blockSignals( block );
mDDFillColorComboBox->blockSignals( block );
mDDOutlineColorComboBox->blockSignals( block);
mDDShapeComboBox->blockSignals( block );
}
48 changes: 48 additions & 0 deletions src/gui/symbology-ng/qgsellipsesymbollayerv2widget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef QGSELLIPSESYMBOLLAYERV2WIDGET_H
#define QGSELLIPSESYMBOLLAYERV2WIDGET_H

#include "ui_widget_ellipse.h"
#include "qgssymbollayerv2widget.h"

class QgsEllipseSymbolLayerV2;

class GUI_EXPORT QgsEllipseSymbolLayerV2Widget: public QgsSymbolLayerV2Widget, private Ui::WidgetEllipseBase
{
Q_OBJECT

public:
QgsEllipseSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = 0 );

static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsEllipseSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
virtual QgsSymbolLayerV2* symbolLayer();

protected:
QgsEllipseSymbolLayerV2* mLayer;

private:
void blockComboSignals( bool block );
//insert available attributes for data defined symbolisation
void fillDataDefinedComboBoxes();

private slots:
void on_mShapeListWidget_itemSelectionChanged();
void on_mWidthSpinBox_valueChanged( double d );
void on_mHeightSpinBox_valueChanged( double d );
void on_mRotationSpinBox_valueChanged( double d );
void on_mOutlineWidthSpinBox_valueChanged( double d );
void on_btnChangeColorBorder_clicked();
void on_btnChangeColorFill_clicked();

void on_mDDSymbolWidthComboBox_currentIndexChanged( int idx );
void on_mDDSymbolHeightComboBox_currentIndexChanged( int idx );
void on_mDDRotationComboBox_currentIndexChanged( int idx );
void on_mDDOutlineWidthComboBox_currentIndexChanged( int idx );
void on_mDDFillColorComboBox_currentIndexChanged( int idx );
void on_mDDOutlineColorComboBox_currentIndexChanged( int idx );
void on_mDDShapeComboBox_currentIndexChanged( int idx );
};

#endif // QGSELLIPSESYMBOLLAYERV2WIDGET_H
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()

void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol()
{
QgsSymbolV2SelectorDialog dlg( mGraduatedSymbol, mStyle, this );
QgsSymbolV2SelectorDialog dlg( mGraduatedSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
return;

Expand Down Expand Up @@ -275,7 +275,7 @@ void QgsGraduatedSymbolRendererV2Widget::changeRangeSymbol( int rangeIdx )
{
QgsSymbolV2* newSymbol = mRenderer->ranges()[rangeIdx].symbol()->clone();

QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, this );
QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
{
delete newSymbol;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ QgsRendererRulePropsDialog::QgsRendererRulePropsDialog( const QgsRuleBasedRender
spinMaxScale->setValue( rule.scaleMaxDenom() );
}

QgsSymbolV2SelectorDialog* symbolSel = new QgsSymbolV2SelectorDialog( mRule.symbol(), style, this, true );
QgsSymbolV2SelectorDialog* symbolSel = new QgsSymbolV2SelectorDialog( mRule.symbol(), style, mLayer, this, true );
QVBoxLayout* l = new QVBoxLayout;
l->addWidget( symbolSel );
groupSymbol->setLayout( l );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology-ng/qgssinglesymbolrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ QgsSingleSymbolRendererV2Widget::QgsSingleSymbolRendererV2Widget( QgsVectorLayer
mSingleSymbol = mRenderer->symbol()->clone();

// setup ui
mSelector = new QgsSymbolV2SelectorDialog( mSingleSymbol, mStyle, NULL, true );
mSelector = new QgsSymbolV2SelectorDialog( mSingleSymbol, mStyle, mLayer, NULL, true );
connect( mSelector, SIGNAL( symbolModified() ), this, SLOT( changeSingleSymbol() ) );

QVBoxLayout* layout = new QVBoxLayout;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ bool QgsStyleV2ManagerDialog::addSymbol()
}

// get symbol design
QgsSymbolV2PropertiesDialog dlg( symbol, this );
QgsSymbolV2PropertiesDialog dlg( symbol, 0, this );
if ( dlg.exec() == 0 )
{
delete symbol;
Expand Down Expand Up @@ -384,7 +384,7 @@ bool QgsStyleV2ManagerDialog::editSymbol()
QgsSymbolV2* symbol = mStyle->symbol( symbolName );

// let the user edit the symbol and update list when done
QgsSymbolV2PropertiesDialog dlg( symbol, this );
QgsSymbolV2PropertiesDialog dlg( symbol, 0, this );
if ( dlg.exec() == 0 )
{
delete symbol;
Expand Down
40 changes: 20 additions & 20 deletions src/gui/symbology-ng/qgssymbollayerv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@



QgsSimpleLineSymbolLayerV2Widget::QgsSimpleLineSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsSimpleLineSymbolLayerV2Widget::QgsSimpleLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -161,8 +161,8 @@ void QgsSimpleLineSymbolLayerV2Widget::updatePatternIcon()
///////////


QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -289,8 +289,8 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setOffset()

///////////

QgsSimpleFillSymbolLayerV2Widget::QgsSimpleFillSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsSimpleFillSymbolLayerV2Widget::QgsSimpleFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -392,8 +392,8 @@ void QgsSimpleFillSymbolLayerV2Widget::offsetChanged()

///////////

QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget(const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -449,7 +449,7 @@ void QgsMarkerLineSymbolLayerV2Widget::setInterval( double val )

void QgsMarkerLineSymbolLayerV2Widget::setMarker()
{
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), this );
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), mVectorLayer, this );
if ( dlg.exec() == 0 )
return;
updateMarker();
Expand Down Expand Up @@ -498,8 +498,8 @@ void QgsMarkerLineSymbolLayerV2Widget::setPlacement()
///////////


QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -738,8 +738,8 @@ void QgsSvgMarkerSymbolLayerV2Widget::on_mBorderWidthSpinBox_valueChanged( doubl

///////////////

QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -794,7 +794,7 @@ void QgsLineDecorationSymbolLayerV2Widget::penWidthChanged()

#include <QFileDialog>

QgsSVGFillSymbolLayerWidget::QgsSVGFillSymbolLayerWidget( QWidget* parent ): QgsSymbolLayerV2Widget( parent )
QgsSVGFillSymbolLayerWidget::QgsSVGFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent ): QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = 0;
setupUi( this );
Expand Down Expand Up @@ -880,7 +880,7 @@ void QgsSVGFillSymbolLayerWidget::insertIcons()

void QgsSVGFillSymbolLayerWidget::on_mChangeOutlinePushButton_clicked()
{
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), this );
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), mVectorLayer, this );
if ( dlg.exec() == QDialog::Rejected )
{
return;
Expand Down Expand Up @@ -910,8 +910,8 @@ void QgsSVGFillSymbolLayerWidget::updateOutlineIcon()

/////////////

QgsFontMarkerSymbolLayerV2Widget::QgsFontMarkerSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsFontMarkerSymbolLayerV2Widget::QgsFontMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -1011,8 +1011,8 @@ void QgsFontMarkerSymbolLayerV2Widget::setOffset()
///////////////


QgsCentroidFillSymbolLayerV2Widget::QgsCentroidFillSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsCentroidFillSymbolLayerV2Widget::QgsCentroidFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -1040,7 +1040,7 @@ QgsSymbolLayerV2* QgsCentroidFillSymbolLayerV2Widget::symbolLayer()

void QgsCentroidFillSymbolLayerV2Widget::setMarker()
{
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), this );
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), mVectorLayer, this );
if ( dlg.exec() == 0 )
return;
updateMarker();
Expand Down
42 changes: 23 additions & 19 deletions src/gui/symbology-ng/qgssymbollayerv2widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
#include <QWidget>

class QgsSymbolLayerV2;
class QgsVectorLayer;


class GUI_EXPORT QgsSymbolLayerV2Widget : public QWidget
{
Q_OBJECT

public:
QgsSymbolLayerV2Widget( QWidget* parent ) : QWidget( parent ) {}
QgsSymbolLayerV2Widget( QWidget* parent, const QgsVectorLayer* vl = 0 ) : QWidget( parent ), mVectorLayer( vl ) {}
virtual ~QgsSymbolLayerV2Widget() {}

virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) = 0;
virtual QgsSymbolLayerV2* symbolLayer() = 0;

protected:
const QgsVectorLayer* mVectorLayer;

signals:
void changed();
};
Expand All @@ -33,9 +37,9 @@ class GUI_EXPORT QgsSimpleLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
Q_OBJECT

public:
QgsSimpleLineSymbolLayerV2Widget( QWidget* parent = NULL );
QgsSimpleLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSimpleLineSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSimpleLineSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -68,9 +72,9 @@ class GUI_EXPORT QgsSimpleMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Wid
Q_OBJECT

public:
QgsSimpleMarkerSymbolLayerV2Widget( QWidget* parent = NULL );
QgsSimpleMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSimpleMarkerSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSimpleMarkerSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -99,9 +103,9 @@ class GUI_EXPORT QgsSimpleFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
Q_OBJECT

public:
QgsSimpleFillSymbolLayerV2Widget( QWidget* parent = NULL );
QgsSimpleFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSimpleFillSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSimpleFillSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -131,9 +135,9 @@ class GUI_EXPORT QgsMarkerLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
Q_OBJECT

public:
QgsMarkerLineSymbolLayerV2Widget( QWidget* parent = NULL );
QgsMarkerLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsMarkerLineSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsMarkerLineSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -166,9 +170,9 @@ class GUI_EXPORT QgsSvgMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget
Q_OBJECT

public:
QgsSvgMarkerSymbolLayerV2Widget( QWidget* parent = NULL );
QgsSvgMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSvgMarkerSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSvgMarkerSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -206,9 +210,9 @@ class GUI_EXPORT QgsLineDecorationSymbolLayerV2Widget : public QgsSymbolLayerV2W
Q_OBJECT

public:
QgsLineDecorationSymbolLayerV2Widget( QWidget* parent = NULL );
QgsLineDecorationSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsLineDecorationSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsLineDecorationSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand All @@ -233,9 +237,9 @@ class GUI_EXPORT QgsSVGFillSymbolLayerWidget : public QgsSymbolLayerV2Widget, pr
Q_OBJECT

public:
QgsSVGFillSymbolLayerWidget( QWidget* parent = NULL );
QgsSVGFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSVGFillSymbolLayerWidget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSVGFillSymbolLayerWidget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -270,9 +274,9 @@ class GUI_EXPORT QgsFontMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
Q_OBJECT

public:
QgsFontMarkerSymbolLayerV2Widget( QWidget* parent = NULL );
QgsFontMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsFontMarkerSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsFontMarkerSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -303,9 +307,9 @@ class GUI_EXPORT QgsCentroidFillSymbolLayerV2Widget : public QgsSymbolLayerV2Wid
Q_OBJECT

public:
QgsCentroidFillSymbolLayerV2Widget( QWidget* parent = NULL );
QgsCentroidFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsCentroidFillSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsCentroidFillSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down
8 changes: 5 additions & 3 deletions src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "qgslogger.h"

#include "qgssymbollayerv2widget.h"
#include "qgsellipsesymbollayerv2widget.h"
#include "qgssymbolv2.h" //for the unit


Expand Down Expand Up @@ -90,6 +91,7 @@ static void _initWidgetFunctions()
_initWidgetFunction( "SimpleMarker", QgsSimpleMarkerSymbolLayerV2Widget::create );
_initWidgetFunction( "SvgMarker", QgsSvgMarkerSymbolLayerV2Widget::create );
_initWidgetFunction( "FontMarker", QgsFontMarkerSymbolLayerV2Widget::create );
_initWidgetFunction( "EllipseMarker", QgsEllipseSymbolLayerV2Widget::create );

_initWidgetFunction( "SimpleFill", QgsSimpleFillSymbolLayerV2Widget::create );
_initWidgetFunction( "SVGFill", QgsSVGFillSymbolLayerWidget::create );
Expand All @@ -101,8 +103,8 @@ static void _initWidgetFunctions()

//////////

QgsSymbolV2PropertiesDialog::QgsSymbolV2PropertiesDialog( QgsSymbolV2* symbol, QWidget* parent )
: QDialog( parent ), mSymbol( symbol )
QgsSymbolV2PropertiesDialog::QgsSymbolV2PropertiesDialog( QgsSymbolV2* symbol, const QgsVectorLayer* vl, QWidget* parent )
: QDialog( parent ), mSymbol( symbol ), mVectorLayer( vl )
{
setupUi( this );

Expand Down Expand Up @@ -247,7 +249,7 @@ void QgsSymbolV2PropertiesDialog::loadPropertyWidgets()
if ( am == NULL ) // check whether the metadata is assigned
continue;

QgsSymbolLayerV2Widget* w = am->createSymbolLayerWidget();
QgsSymbolLayerV2Widget* w = am->createSymbolLayerWidget( mVectorLayer );
if ( w == NULL ) // check whether the function returns correct widget
continue;

Expand Down
5 changes: 4 additions & 1 deletion src/gui/symbology-ng/qgssymbolv2propertiesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class QgsSymbolV2;
class QgsSymbolLayerV2;
class QgsSymbolLayerV2Widget;
class QgsVectorLayer;

class SymbolLayerItem;

Expand All @@ -18,7 +19,7 @@ class GUI_EXPORT QgsSymbolV2PropertiesDialog : public QDialog, private Ui::DlgSy
Q_OBJECT

public:
QgsSymbolV2PropertiesDialog( QgsSymbolV2* symbol, QWidget* parent = NULL );
QgsSymbolV2PropertiesDialog( QgsSymbolV2* symbol, const QgsVectorLayer* vl, QWidget* parent = NULL );


public slots:
Expand Down Expand Up @@ -64,6 +65,8 @@ class GUI_EXPORT QgsSymbolV2PropertiesDialog : public QDialog, private Ui::DlgSy
QgsSymbolV2* mSymbol;

QMap<QString, QgsSymbolLayerV2Widget*> mWidgets;

const QgsVectorLayer* mVectorLayer;
};

#endif
6 changes: 3 additions & 3 deletions src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include <QKeyEvent>
#include <QMenu>

QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, QWidget* parent, bool embedded )
: QDialog( parent ), mAdvancedMenu( NULL )
QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent, bool embedded )
: QDialog( parent ), mAdvancedMenu( NULL ), mVectorLayer( vl )
{
mStyle = style;
mSymbol = symbol;
Expand Down Expand Up @@ -162,7 +162,7 @@ void QgsSymbolV2SelectorDialog::updateSymbolInfo()

void QgsSymbolV2SelectorDialog::changeSymbolProperties()
{
QgsSymbolV2PropertiesDialog dlg( mSymbol, this );
QgsSymbolV2PropertiesDialog dlg( mSymbol, mVectorLayer, this );
if ( !dlg.exec() )
return;

Expand Down
4 changes: 3 additions & 1 deletion src/gui/symbology-ng/qgssymbolv2selectordialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class QgsStyleV2;
class QgsSymbolV2;
class QgsVectorLayer;

class QMenu;

Expand All @@ -16,7 +17,7 @@ class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymb
Q_OBJECT

public:
QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, QWidget* parent = NULL, bool embedded = false );
QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent = NULL, bool embedded = false );

//! return menu for "advanced" button - create it if doesn't exist and show the advanced button
QMenu* advancedMenu();
Expand Down Expand Up @@ -54,6 +55,7 @@ class GUI_EXPORT QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymb
QgsStyleV2* mStyle;
QgsSymbolV2* mSymbol;
QMenu* mAdvancedMenu;
const QgsVectorLayer* mVectorLayer;
};

#endif
27 changes: 27 additions & 0 deletions src/mapserver/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,33 @@ QMap<QString, QString> QgsWMSServer::applyRequestedLayerFilters( const QStringLi
}
mMapRenderer->setExtent( filterExtent );
}

//No BBOX parameter in request. We use the union of the filtered layer
//to provide the functionality of zooming to selected records via (enhanced) WMS.
if( mMapRenderer && mMapRenderer->extent().isEmpty() )
{
QgsRectangle filterExtent;
QMap<QString, QString>::const_iterator filterIt = filterMap.constBegin();
for(; filterIt != filterMap.constEnd(); ++filterIt )
{
QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance()->mapLayer( filterIt.key() );
if( !mapLayer )
{
continue;
}

QgsRectangle layerExtent = mapLayer->extent();
if( filterExtent.isEmpty() )
{
filterExtent = layerExtent;
}
else
{
filterExtent.combineExtentWith( &layerExtent );
}
}
mMapRenderer->setExtent( filterExtent );
}
}
return filterMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void QgsPointDisplacementRenderer::renderFeature( QgsFeature& feature, QgsRender
{
if ( mCenterSymbol )
{
mCenterSymbol->renderPoint( pt, context, layer, selected );
mCenterSymbol->renderPoint( pt, &feature, context, layer, selected );
}
else
{
Expand All @@ -174,7 +174,7 @@ void QgsPointDisplacementRenderer::renderFeature( QgsFeature& feature, QgsRender
}

//draw symbols on the circle
drawSymbols( context, symbolList, symbolPositions, selected );
drawSymbols( feature, context, symbolList, symbolPositions, selected );
//and also the labels
drawLabels( pt, symbolContext, labelPositions, labelAttributeList );
}
Expand Down Expand Up @@ -511,15 +511,15 @@ void QgsPointDisplacementRenderer::drawCircle( double radiusPainterUnits, QgsSym
p->drawArc( QRectF( centerPoint.x() - radiusPainterUnits, centerPoint.y() - radiusPainterUnits, 2 * radiusPainterUnits, 2 * radiusPainterUnits ), 0, 5760 );
}

void QgsPointDisplacementRenderer::drawSymbols( QgsRenderContext& context, const QList<QgsMarkerSymbolV2*>& symbolList, const QList<QPointF>& symbolPositions, bool selected )
void QgsPointDisplacementRenderer::drawSymbols( QgsFeature& f, QgsRenderContext& context, const QList<QgsMarkerSymbolV2*>& symbolList, const QList<QPointF>& symbolPositions, bool selected )
{
QList<QPointF>::const_iterator symbolPosIt = symbolPositions.constBegin();
QList<QgsMarkerSymbolV2*>::const_iterator symbolIt = symbolList.constBegin();
for ( ; symbolPosIt != symbolPositions.constEnd() && symbolIt != symbolList.constEnd(); ++symbolPosIt, ++symbolIt )
{
if ( *symbolIt )
{
( *symbolIt )->renderPoint( *symbolPosIt, context, -1, selected );
( *symbolIt )->renderPoint( *symbolPosIt, &f, context, -1, selected );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class QgsPointDisplacementRenderer: public QgsFeatureRendererV2
//helper functions
void calculateSymbolAndLabelPositions( const QPointF& centerPoint, int nPosition, double radius, double symbolDiagonal, QList<QPointF>& symbolPositions, QList<QPointF>& labelShifts ) const;
void drawCircle( double radiusPainterUnits, QgsSymbolV2RenderContext& context, const QPointF& centerPoint, int nSymbols );
void drawSymbols( QgsRenderContext& context, const QList<QgsMarkerSymbolV2*>& symbolList, const QList<QPointF>& symbolPositions, bool selected = false );
void drawSymbols( QgsFeature& f, QgsRenderContext& context, const QList<QgsMarkerSymbolV2*>& symbolList, const QList<QPointF>& symbolPositions, bool selected = false );
void drawLabels( const QPointF& centerPoint, QgsSymbolV2RenderContext& context, const QList<QPointF>& labelShifts, const QStringList& labelList );
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void QgsPointDisplacementRendererWidget::on_mCenterSymbolPushButton_clicked()
return;
}
QgsMarkerSymbolV2* markerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( mRenderer->centerSymbol()->clone() );
QgsSymbolV2SelectorDialog dlg( markerSymbol, QgsStyleV2::defaultStyle(), this );
QgsSymbolV2SelectorDialog dlg( markerSymbol, QgsStyleV2::defaultStyle(), mLayer, this );
if ( dlg.exec() == QDialog::Rejected )
{
delete markerSymbol;
Expand Down
248 changes: 248 additions & 0 deletions src/ui/symbollayer/widget_ellipse.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WidgetEllipseBase</class>
<widget class="QWidget" name="WidgetEllipseBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>336</width>
<height>326</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Settings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Border color</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsColorButtonV2" name="btnChangeColorBorder">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Fill color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsColorButtonV2" name="btnChangeColorFill">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mSymbolWidthLabel">
<property name="text">
<string>Symbol width</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="mWidthSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mOutlineWidthLabel">
<property name="text">
<string>Outline width</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="mSymbolHeightLabel">
<property name="text">
<string>Symbol height</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="mHeightSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QListWidget" name="mShapeListWidget">
<property name="dragDropMode">
<enum>QAbstractItemView::DropOnly</enum>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="spacing">
<number>4</number>
</property>
<property name="gridSize">
<size>
<width>30</width>
<height>24</height>
</size>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="selectionRectVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="mRotationSpinBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="mRotationLabel">
<property name="text">
<string>Rotation</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Data defined settings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="mDdSymbolWidthLabel">
<property name="text">
<string>Symbol width</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="mDDSymbolWidthComboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mDdSymbolHeightLabel">
<property name="text">
<string>Symbol height</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="mDDSymbolHeightComboBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mDDOutlineWidthLabel">
<property name="text">
<string>Outline width</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="mDDOutlineWidthComboBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="mDDFillColorLabel">
<property name="text">
<string>Fill color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="mDDFillColorComboBox"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="mDDOutlineLabel">
<property name="text">
<string>Outline color</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="mDDOutlineColorComboBox"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="mDDShapeLabel">
<property name="text">
<string>Shape</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="mDDShapeComboBox"/>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="mDDRotationComboBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mDDRotationLabel">
<property name="text">
<string>Rotation</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsColorButtonV2</class>
<extends>QPushButton</extends>
<header>qgscolorbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>