[QGIS Commit] r12755 - in trunk/qgis: python/core
src/core/symbology-ng src/gui/symbology-ng src/ui src/ui/symbollayer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu Jan 14 11:18:14 EST 2010
Author: mhugent
Date: 2010-01-14 11:18:13 -0500 (Thu, 14 Jan 2010)
New Revision: 12755
Modified:
trunk/qgis/python/core/symbology-ng-core.sip
trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.cpp
trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.h
trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp
trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h
trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.h
trunk/qgis/src/core/symbology-ng/qgssymbollayerv2.cpp
trunk/qgis/src/core/symbology-ng/qgssymbollayerv2.h
trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp
trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.h
trunk/qgis/src/core/symbology-ng/qgssymbolv2.cpp
trunk/qgis/src/core/symbology-ng/qgssymbolv2.h
trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp
trunk/qgis/src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp
trunk/qgis/src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
trunk/qgis/src/gui/symbology-ng/qgssymbolv2selectordialog.h
trunk/qgis/src/ui/qgssymbolv2selectordialogbase.ui
trunk/qgis/src/ui/symbollayer/widget_markerline.ui
trunk/qgis/src/ui/symbollayer/widget_simplefill.ui
trunk/qgis/src/ui/symbollayer/widget_simpleline.ui
trunk/qgis/src/ui/symbollayer/widget_simplemarker.ui
trunk/qgis/src/ui/symbollayer/widget_svgmarker.ui
Log:
[FEATURE]: choice between mm and map units for new symbology. Scaling to use new symbology in print composer as well
Modified: trunk/qgis/python/core/symbology-ng-core.sip
===================================================================
--- trunk/qgis/python/core/symbology-ng-core.sip 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/python/core/symbology-ng-core.sip 2010-01-14 16:18:13 UTC (rev 12755)
@@ -350,14 +350,14 @@
virtual QString layerType() const = 0;
- virtual void startRender(QgsRenderContext& context) = 0;
- virtual void stopRender(QgsRenderContext& context) = 0;
+ virtual void startRender(QgsSymbolV2RenderContext& context) = 0;
+ virtual void stopRender(QgsSymbolV2RenderContext& context) = 0;
virtual QgsSymbolLayerV2* clone() const = 0 /Factory/;
virtual QgsStringMap properties() const = 0;
- virtual void drawPreviewIcon(QPainter* painter, QSize size) = 0;
+ virtual void drawPreviewIcon(QgsSymbolV2RenderContext& context, QSize size) = 0;
virtual QgsSymbolV2* subSymbol();
virtual bool setSubSymbol(QgsSymbolV2* symbol /Transfer/);
@@ -385,9 +385,9 @@
%End
public:
- virtual void renderPoint(const QPointF& point, QgsRenderContext& context) = 0;
+ virtual void renderPoint(const QPointF& point, QgsSymbolV2RenderContext& context) = 0;
- void drawPreviewIcon(QPainter* painter, QSize size);
+ void drawPreviewIcon(QgsSymbolV2RenderContext& context, QSize size);
void setAngle(double angle);
double angle() const;
@@ -407,12 +407,12 @@
%End
public:
- virtual void renderPolyline(const QPolygonF& points, QgsRenderContext& context) = 0;
+ virtual void renderPolyline(const QPolygonF& points, QgsSymbolV2RenderContext& context) = 0;
void setWidth(double width);
double width() const;
- void drawPreviewIcon(QPainter* painter, QSize size);
+ void drawPreviewIcon(QgsSymbolV2RenderContext& context, QSize size);
protected:
QgsLineSymbolLayerV2(bool locked = false);
@@ -426,9 +426,9 @@
%End
public:
- virtual void renderPolygon(const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context) = 0;
+ virtual void renderPolygon(const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context) = 0;
- void drawPreviewIcon(QPainter* painter, QSize size);
+ void drawPreviewIcon(QgsSymbolV2RenderContext& context, QSize size);
protected:
QgsFillSymbolLayerV2(bool locked = false);
@@ -437,7 +437,26 @@
///////////////
+class QgsSymbolV2RenderContext
+{
+%TypeHeaderCode
+#include <qgssymbolv2.h>
+%End
+ public:
+ QgsSymbolV2RenderContext( QgsRenderContext* c, QgsSymbolV2::OutputUnit u);
+ ~QgsSymbolV2RenderContext();
+
+ QgsRenderContext* renderContext();
+ void setRenderContext( QgsRenderContext* c );
+
+ QgsSymbolV2::OutputUnit outputUnit() const;
+ void setOutputUnit( QgsSymbolV2::OutputUnit u );
+};
+
+///////////////
+
+
typedef QList<QgsSymbolLayerV2*> QgsSymbolLayerV2List;
class QgsSymbolV2
@@ -458,6 +477,12 @@
public:
+ enum OutputUnit
+ {
+ MM,
+ MapUnit
+ };
+
enum SymbolType
{
Marker,
@@ -508,6 +533,9 @@
virtual QgsSymbolV2* clone() const = 0 /Factory/;
+ OutputUnit outputUnit() const;
+ void setOutputUnit( OutputUnit u );
+
protected:
QgsSymbolV2(SymbolType type, QgsSymbolLayerV2List layers /Transfer/); // can't be instantiated
Modified: trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.cpp 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.cpp 2010-01-14 16:18:13 UTC (rev 12755)
@@ -41,21 +41,31 @@
return "SimpleFill";
}
-void QgsSimpleFillSymbolLayerV2::startRender( QgsRenderContext& context )
+void QgsSimpleFillSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
mBrush = QBrush( mColor, mBrushStyle );
mPen = QPen( mBorderColor );
mPen.setStyle( mBorderStyle );
- mPen.setWidthF( mBorderWidth );
+ mPen.setWidthF( mBorderWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), context.outputUnit() ) );
}
-void QgsSimpleFillSymbolLayerV2::stopRender( QgsRenderContext& context )
+void QgsSimpleFillSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
{
}
-void QgsSimpleFillSymbolLayerV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context )
+void QgsSimpleFillSymbolLayerV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context )
{
- QPainter* p = context.painter();
+ QgsRenderContext* rc = context.renderContext();
+ if ( !rc )
+ {
+ return;
+ }
+ QPainter* p = rc->painter();
+ if ( !p )
+ {
+ return;
+ }
+
p->setBrush( mBrush );
p->setPen( mPen );
Modified: trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.h 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgsfillsymbollayerv2.h 2010-01-14 16:18:13 UTC (rev 12755)
@@ -30,11 +30,11 @@
QString layerType() const;
- void startRender( QgsRenderContext& context );
+ void startRender( QgsSymbolV2RenderContext& context );
- void stopRender( QgsRenderContext& context );
+ void stopRender( QgsSymbolV2RenderContext& context );
- void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context );
+ void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
Modified: trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.cpp 2010-01-14 16:18:13 UTC (rev 12755)
@@ -47,29 +47,40 @@
}
-void QgsSimpleLineSymbolLayerV2::startRender( QgsRenderContext& context )
+void QgsSimpleLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
mPen.setColor( mColor );
- mPen.setWidth( mWidth );
+ mPen.setWidthF( mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), context.outputUnit() ) );
mPen.setStyle( mPenStyle );
mPen.setJoinStyle( mPenJoinStyle );
mPen.setCapStyle( mPenCapStyle );
}
-void QgsSimpleLineSymbolLayerV2::stopRender( QgsRenderContext& context )
+void QgsSimpleLineSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
{
}
-void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsRenderContext& context )
+void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
- context.painter()->setPen( mPen );
+ QgsRenderContext* rc = context.renderContext();
+ if ( !rc )
+ {
+ return;
+ }
+ QPainter* p = rc->painter();
+ if ( !p )
+ {
+ return;
+ }
+
+ p->setPen( mPen );
if ( mOffset == 0 )
{
- context.painter()->drawPolyline( points );
+ p->drawPolyline( points );
}
else
{
- context.painter()->drawPolyline( ::offsetLine( points, mOffset ) );
+ p->drawPolyline( ::offsetLine( points, mOffset ) );
}
}
@@ -200,20 +211,32 @@
mColor = color;
}
-void QgsMarkerLineSymbolLayerV2::startRender( QgsRenderContext& context )
+void QgsMarkerLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
// if being rotated, it gets initialized with every line segment
if ( !mRotateMarker )
- mMarker->startRender( context );
+ {
+ QgsRenderContext* rc = context.renderContext();
+ if ( rc )
+ {
+ mMarker->startRender( *rc );
+ }
+ }
}
-void QgsMarkerLineSymbolLayerV2::stopRender( QgsRenderContext& context )
+void QgsMarkerLineSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
{
if ( !mRotateMarker )
- mMarker->stopRender( context );
+ {
+ QgsRenderContext* rc = context.renderContext();
+ if ( rc )
+ {
+ mMarker->stopRender( *rc );
+ }
+ }
}
-void QgsMarkerLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsRenderContext& context )
+void QgsMarkerLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
if ( mOffset == 0 )
{
@@ -221,18 +244,26 @@
}
else
{
- QPolygonF points2 = ::offsetLine( points, mOffset );
+ QPolygonF points2 = ::offsetLine( points, mOffset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), context.outputUnit() ) );
renderPolylineNoOffset( points2, context );
}
}
-void QgsMarkerLineSymbolLayerV2::renderPolylineNoOffset( const QPolygonF& points, QgsRenderContext& context )
+void QgsMarkerLineSymbolLayerV2::renderPolylineNoOffset( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
QPointF lastPt = points[0];
double lengthLeft = 0; // how much is left until next marker
bool first = true;
double origAngle = mMarker->angle();
+ double painterUnitInterval = mInterval * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), context.outputUnit() );
+
+ QgsRenderContext* rc = context.renderContext();
+ if ( !rc )
+ {
+ return;
+ }
+
for ( int i = 1; i < points.count(); ++i )
{
const QPointF& pt = points[i];
@@ -242,11 +273,11 @@
// for each line, find out dx and dy, and length
MyLine l( lastPt, pt );
- QPointF diff = l.diffForInterval( mInterval );
+ QPointF diff = l.diffForInterval( painterUnitInterval );
// if there's some length left from previous line
// use only the rest for the first point in new line segment
- double c = 1 - lengthLeft / mInterval;
+ double c = 1 - lengthLeft / painterUnitInterval;
lengthLeft += l.length();
@@ -254,30 +285,30 @@
if ( mRotateMarker )
{
mMarker->setAngle( origAngle + ( l.angle() * 180 / M_PI ) );
- mMarker->startRender( context );
+ mMarker->startRender( *rc );
}
// draw first marker
if ( first )
{
- mMarker->renderPoint( lastPt, context );
+ mMarker->renderPoint( lastPt, *rc );
first = false;
}
// while we're not at the end of line segment, draw!
- while ( lengthLeft > mInterval )
+ while ( lengthLeft > painterUnitInterval )
{
// "c" is 1 for regular point or in interval (0,1] for begin of line segment
lastPt += c * diff;
- lengthLeft -= mInterval;
- mMarker->renderPoint( lastPt, context );
+ lengthLeft -= painterUnitInterval;
+ mMarker->renderPoint( lastPt, *rc );
c = 1; // reset c (if wasn't 1 already)
}
lastPt = pt;
if ( mRotateMarker )
- mMarker->stopRender( context );
+ mMarker->stopRender( *rc );
}
// restore original rotation
@@ -347,12 +378,12 @@
return "LineDecoration";
}
-void QgsLineDecorationSymbolLayerV2::startRender( QgsRenderContext& context )
+void QgsLineDecorationSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
mPen.setColor( mColor );
}
-void QgsLineDecorationSymbolLayerV2::stopRender( QgsRenderContext& context )
+void QgsLineDecorationSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
{
}
@@ -369,10 +400,21 @@
return atan( t ) + ( y2 >= y1 ? M_PI : 0 ); // atan is positive / negative
}
-void QgsLineDecorationSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsRenderContext& context )
+void QgsLineDecorationSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
// draw arrow at the end of line
+ QgsRenderContext* rc = context.renderContext();
+ if ( !rc )
+ {
+ return;
+ }
+ QPainter* p = rc->painter();
+ if ( !p )
+ {
+ return;
+ }
+
int cnt = points.count();
QPointF p1 = points.at( cnt - 2 );
QPointF p2 = points.at( cnt - 1 );
@@ -385,9 +427,9 @@
QPointF p2_1 = p2 - QPointF( size * cos( angle1 ), size * sin( angle1 ) );
QPointF p2_2 = p2 - QPointF( size * cos( angle2 ), size * sin( angle2 ) );
- context.painter()->setPen( mPen );
- context.painter()->drawLine( p2, p2_1 );
- context.painter()->drawLine( p2, p2_2 );
+ p->setPen( mPen );
+ p->drawLine( p2, p2_1 );
+ p->drawLine( p2, p2_2 );
}
QgsStringMap QgsLineDecorationSymbolLayerV2::properties() const
Modified: trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgslinesymbollayerv2.h 2010-01-14 16:18:13 UTC (rev 12755)
@@ -28,11 +28,11 @@
QString layerType() const;
- void startRender( QgsRenderContext& context );
+ void startRender( QgsSymbolV2RenderContext& context );
- void stopRender( QgsRenderContext& context );
+ void stopRender( QgsSymbolV2RenderContext& context );
- void renderPolyline( const QPolygonF& points, QgsRenderContext& context );
+ void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
@@ -81,11 +81,11 @@
QString layerType() const;
- void startRender( QgsRenderContext& context );
+ void startRender( QgsSymbolV2RenderContext& context );
- void stopRender( QgsRenderContext& context );
+ void stopRender( QgsSymbolV2RenderContext& context );
- void renderPolyline( const QPolygonF& points, QgsRenderContext& context );
+ void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
@@ -109,7 +109,7 @@
protected:
- void renderPolylineNoOffset( const QPolygonF& points, QgsRenderContext& context );
+ void renderPolylineNoOffset( const QPolygonF& points, QgsSymbolV2RenderContext& context );
bool mRotateMarker;
double mInterval;
@@ -136,11 +136,11 @@
QString layerType() const;
- void startRender( QgsRenderContext& context );
+ void startRender( QgsSymbolV2RenderContext& context );
- void stopRender( QgsRenderContext& context );
+ void stopRender( QgsSymbolV2RenderContext& context );
- void renderPolyline( const QPolygonF& points, QgsRenderContext& context );
+ void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
Modified: trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp 2010-01-14 16:18:13 UTC (rev 12755)
@@ -63,14 +63,16 @@
return "SimpleMarker";
}
-void QgsSimpleMarkerSymbolLayerV2::startRender( QgsRenderContext& context )
+void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
mBrush = QBrush( mColor );
mPen = QPen( mBorderColor );
+ mPen.setWidthF( mPen.widthF() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), context.outputUnit() ) );
mPolygon.clear();
- double half = mSize / 2.0;
+ double scaledSize = mSize * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( context.renderContext(), context.outputUnit() );
+ double half = scaledSize / 2.0;
if ( mName == "rectangle" )
{
@@ -157,8 +159,8 @@
// TODO: decide whether to use QImage or QPixmap - based on the render context
// calculate necessary image size for the cache
- int pw = (( mPen.width() == 0 ? 1 : mPen.width() ) + 1 ) / 2 * 2; // make even (round up); handle cosmetic pen
- int imageSize = (( int ) mSize + pw ) / 2 * 2 + 1; // make image width, height odd; account for pen width
+ double pw = (( mPen.widthF() == 0 ? 1 : mPen.widthF() ) + 1 ) / 2 * 2; // make even (round up); handle cosmetic pen
+ int imageSize = (( int ) scaledSize + pw ) / 2 * 2 + 1; // make image width, height odd; account for pen width
double center = (( double ) imageSize / 2 ) + 0.5; // add 1/2 pixel for proper rounding when the figure's coordinates are added
@@ -171,17 +173,27 @@
p.setBrush( mBrush );
p.setPen( mPen );
p.translate( QPointF( center, center ) );
- drawMarker( &p );
+ drawMarker( &p, context );
p.end();
}
-void QgsSimpleMarkerSymbolLayerV2::stopRender( QgsRenderContext& context )
+void QgsSimpleMarkerSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
{
}
-void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsRenderContext& context )
+void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
- QPainter* p = context.painter();
+ QgsRenderContext* rc = context.renderContext();
+ if ( !rc )
+ {
+ return;
+ }
+ QPainter* p = rc->painter();
+ if ( !p )
+ {
+ return;
+ }
+
//p->setBrush(mBrush);
//p->setPen(mPen);
@@ -189,10 +201,11 @@
//p->translate(point);
//drawMarker(p);
- double s = mCache.width();
- //if (mCache.isValid())
- p->drawImage( point + QPointF( -s / 2.0, -s / 2.0 ) + mOffset, mCache );
-
+ //mCache.save("/home/marco/tmp/marker.png", "PNG");
+ double s = mCache.width() / context.renderContext()->rasterScaleFactor();
+ p->drawImage( QRectF( point.x() - s / 2.0 + mOffset.x() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), context.outputUnit() ), \
+ point.y() - s / 2.0 + mOffset.y() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), context.outputUnit() ), \
+ s, s ), mCache );
//p->restore();
}
@@ -216,7 +229,7 @@
return m;
}
-void QgsSimpleMarkerSymbolLayerV2::drawMarker( QPainter* p )
+void QgsSimpleMarkerSymbolLayerV2::drawMarker( QPainter* p, QgsSymbolV2RenderContext& context )
{
if ( mPolygon.count() != 0 )
{
@@ -224,7 +237,8 @@
}
else
{
- double half = mSize / 2.0;
+ double scaledSize = mSize * QgsSymbolLayerV2Utils::pixelSizeScaleFactor( context.renderContext(), context.outputUnit() );
+ double half = scaledSize / 2.0;
// TODO: rotate
if ( mName == "circle" )
@@ -283,24 +297,51 @@
return "SvgMarker";
}
-void QgsSvgMarkerSymbolLayerV2::startRender( QgsRenderContext& context )
+void QgsSvgMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
- QRectF rect( QPointF( -mSize / 2.0, -mSize / 2.0 ), QSizeF( mSize, mSize ) );
+ double pictureSize = 0;
+ QgsRenderContext* rc = context.renderContext();
+ if ( !rc )
+ {
+ return;
+ }
+
+ if ( rc->painter() && rc->painter()->device() )
+ {
+ //correct QPictures DPI correction
+ pictureSize = mSize * QgsSymbolLayerV2Utils::lineWidthScaleFactor( rc, context.outputUnit() ) \
+ / rc->painter()->device()->logicalDpiX() * mPicture.logicalDpiX();
+ }
+ else
+ {
+ pictureSize = mSize * QgsSymbolLayerV2Utils::lineWidthScaleFactor( rc, context.outputUnit() );
+ }
+ QRectF rect( QPointF( -pictureSize / 2.0, -pictureSize / 2.0 ), QSizeF( pictureSize, pictureSize ) );
QSvgRenderer renderer( mPath );
QPainter painter( &mPicture );
renderer.render( &painter, rect );
}
-void QgsSvgMarkerSymbolLayerV2::stopRender( QgsRenderContext& context )
+void QgsSvgMarkerSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
{
}
-void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsRenderContext& context )
+void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
- QPainter* p = context.painter();
+ QgsRenderContext* rc = context.renderContext();
+ if ( !rc )
+ {
+ return;
+ }
+ QPainter* p = rc->painter();
+ if ( !p )
+ {
+ return;
+ }
+
p->save();
- p->translate( point + mOffset );
+ p->translate( point + mOffset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( rc, context.outputUnit() ) );
if ( mAngle != 0 )
p->rotate( mAngle );
Modified: trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.h 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgsmarkersymbollayerv2.h 2010-01-14 16:18:13 UTC (rev 12755)
@@ -32,11 +32,11 @@
QString layerType() const;
- void startRender( QgsRenderContext& context );
+ void startRender( QgsSymbolV2RenderContext& context );
- void stopRender( QgsRenderContext& context );
+ void stopRender( QgsSymbolV2RenderContext& context );
- void renderPoint( const QPointF& point, QgsRenderContext& context );
+ void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
@@ -50,7 +50,7 @@
protected:
- void drawMarker( QPainter* p );
+ void drawMarker( QPainter* p, QgsSymbolV2RenderContext& context );
QColor mBorderColor;
QPen mPen;
@@ -90,11 +90,11 @@
QString layerType() const;
- void startRender( QgsRenderContext& context );
+ void startRender( QgsSymbolV2RenderContext& context );
- void stopRender( QgsRenderContext& context );
+ void stopRender( QgsSymbolV2RenderContext& context );
- void renderPoint( const QPointF& point, QgsRenderContext& context );
+ void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
Modified: trunk/qgis/src/core/symbology-ng/qgssymbollayerv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbollayerv2.cpp 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgssymbollayerv2.cpp 2010-01-14 16:18:13 UTC (rev 12755)
@@ -7,6 +7,8 @@
#include <QPointF>
#include <QPolygonF>
+
+
QgsMarkerSymbolLayerV2::QgsMarkerSymbolLayerV2( bool locked )
: QgsSymbolLayerV2( QgsSymbolV2::Marker, locked )
{
@@ -22,39 +24,28 @@
{
}
-
-void QgsMarkerSymbolLayerV2::drawPreviewIcon( QPainter* painter, QSize size )
+void QgsMarkerSymbolLayerV2::drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size )
{
- QgsRenderContext context;
- context.setPainter( painter );
-
startRender( context );
renderPoint( QPointF( size.width() / 2, size.height() / 2 ), context );
stopRender( context );
}
-void QgsLineSymbolLayerV2::drawPreviewIcon( QPainter* painter, QSize size )
+void QgsLineSymbolLayerV2::drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size )
{
QPolygonF points;
// we're adding 0.5 to get rid of blurred preview:
// drawing antialiased lines of width 1 at (x,0)-(x,100) creates 2px line
points << QPointF( 0, size.height() / 2 + 0.5 ) << QPointF( size.width(), size.height() / 2 + 0.5 );
- QgsRenderContext context;
- context.setPainter( painter );
-
startRender( context );
renderPolyline( points, context );
stopRender( context );
}
-void QgsFillSymbolLayerV2::drawPreviewIcon( QPainter* painter, QSize size )
+void QgsFillSymbolLayerV2::drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size )
{
QPolygonF poly = QRectF( QPointF( 0, 0 ), QPointF( size.width() - 1, size.height() - 1 ) );
-
- QgsRenderContext context;
- context.setPainter( painter );
-
startRender( context );
renderPolygon( poly, NULL, context );
stopRender( context );
Modified: trunk/qgis/src/core/symbology-ng/qgssymbollayerv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbollayerv2.h 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgssymbollayerv2.h 2010-01-14 16:18:13 UTC (rev 12755)
@@ -31,14 +31,14 @@
virtual QString layerType() const = 0;
- virtual void startRender( QgsRenderContext& context ) = 0;
- virtual void stopRender( QgsRenderContext& context ) = 0;
+ virtual void startRender( QgsSymbolV2RenderContext& context ) = 0;
+ virtual void stopRender( QgsSymbolV2RenderContext& context ) = 0;
virtual QgsSymbolLayerV2* clone() const = 0;
virtual QgsStringMap properties() const = 0;
- virtual void drawPreviewIcon( QPainter* painter, QSize size ) = 0;
+ virtual void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) = 0;
virtual QgsSymbolV2* subSymbol() { return NULL; }
// set layer's subsymbol. takes ownership of the passed symbol
@@ -68,9 +68,9 @@
class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2
{
public:
- virtual void renderPoint( const QPointF& point, QgsRenderContext& context ) = 0;
+ virtual void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) = 0;
- void drawPreviewIcon( QPainter* painter, QSize size );
+ void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
void setAngle( double angle ) { mAngle = angle; }
double angle() const { return mAngle; }
@@ -92,12 +92,12 @@
class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
{
public:
- virtual void renderPolyline( const QPolygonF& points, QgsRenderContext& context ) = 0;
+ virtual void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) = 0;
void setWidth( double width ) { mWidth = width; }
double width() const { return mWidth; }
- void drawPreviewIcon( QPainter* painter, QSize size );
+ void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
protected:
QgsLineSymbolLayerV2( bool locked = false );
@@ -108,9 +108,9 @@
class CORE_EXPORT QgsFillSymbolLayerV2 : public QgsSymbolLayerV2
{
public:
- virtual void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context ) = 0;
+ virtual void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) = 0;
- void drawPreviewIcon( QPainter* painter, QSize size );
+ void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
protected:
QgsFillSymbolLayerV2( bool locked = false );
Modified: trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.cpp 2010-01-14 16:18:13 UTC (rev 12755)
@@ -7,6 +7,7 @@
#include "qgsvectorcolorrampv2.h"
#include "qgslogger.h"
+#include "qgsrendercontext.h"
#include <QColor>
#include <QDomNode>
@@ -165,14 +166,17 @@
}
-QIcon QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( QgsSymbolLayerV2* layer, QSize size )
+QIcon QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( QgsSymbolLayerV2* layer, QgsSymbolV2::OutputUnit u, QSize size )
{
QPixmap pixmap( size );
QPainter painter;
painter.begin( &pixmap );
painter.setRenderHint( QPainter::Antialiasing );
painter.eraseRect( QRect( QPoint( 0, 0 ), size ) );
- layer->drawPreviewIcon( &painter, size );
+ QgsRenderContext renderContext;
+ renderContext.setPainter( &painter );
+ QgsSymbolV2RenderContext symbolContext( &renderContext, u );
+ layer->drawPreviewIcon( symbolContext, size );
painter.end();
return QIcon( pixmap );
}
@@ -339,17 +343,30 @@
}
QString symbolType = element.attribute( "type" );
+ QString unitString = element.attribute( "outputUnit", "MM" );
+
+ QgsSymbolV2* symbol = 0;
if ( symbolType == "line" )
- return new QgsLineSymbolV2( layers );
+ symbol = new QgsLineSymbolV2( layers );
else if ( symbolType == "fill" )
- return new QgsFillSymbolV2( layers );
+ symbol = new QgsFillSymbolV2( layers );
else if ( symbolType == "marker" )
- return new QgsMarkerSymbolV2( layers );
+ symbol = new QgsMarkerSymbolV2( layers );
else
{
QgsDebugMsg( "unknown symbol type " + symbolType );
return NULL;
}
+
+ if ( unitString == "MM" )
+ {
+ symbol->setOutputUnit( QgsSymbolV2::MM );
+ }
+ else
+ {
+ symbol->setOutputUnit( QgsSymbolV2::MapUnit );
+ }
+ return symbol;
}
QgsSymbolLayerV2* QgsSymbolLayerV2Utils::loadSymbolLayer( QDomElement& element )
@@ -392,7 +409,12 @@
QDomElement symEl = doc.createElement( "symbol" );
symEl.setAttribute( "type", _nameForSymbolType( symbol->type() ) );
symEl.setAttribute( "name", name );
-
+ QString unitString = "MM";
+ if ( symbol->outputUnit() == QgsSymbolV2::MapUnit )
+ {
+ unitString = "MapUnit";
+ }
+ symEl.setAttribute( "outputUnit", unitString );
QgsDebugMsg( "num layers " + QString::number( symbol->symbolLayerCount() ) );
for ( int i = 0; i < symbol->symbolLayerCount(); i++ )
{
@@ -589,3 +611,45 @@
QgsSymbolLayerV2Utils::saveProperties( ramp->properties(), doc, rampEl );
return rampEl;
}
+
+double QgsSymbolLayerV2Utils::lineWidthScaleFactor( QgsRenderContext* c, QgsSymbolV2::OutputUnit u )
+{
+ if ( !c )
+ {
+ return 1.0;
+ }
+
+ if ( u == QgsSymbolV2::MM )
+ {
+ return c->scaleFactor();
+ }
+ else //QgsSymbol::MapUnit
+ {
+ double mup = c->mapToPixel().mapUnitsPerPixel();
+ if ( mup > 0 )
+ {
+ return 1.0 / mup;
+ }
+ else
+ {
+ return 1.0;
+ }
+ }
+}
+
+double QgsSymbolLayerV2Utils::pixelSizeScaleFactor( QgsRenderContext* c, QgsSymbolV2::OutputUnit u )
+{
+ if ( !c )
+ {
+ return 1.0;
+ }
+
+ if ( u == QgsSymbolV2::MM )
+ {
+ return ( c->scaleFactor() * c->rasterScaleFactor() );
+ }
+ else //QgsSymbol::MapUnit
+ {
+ return c->rasterScaleFactor() / c->mapToPixel().mapUnitsPerPixel();
+ }
+}
Modified: trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.h 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgssymbollayerv2utils.h 2010-01-14 16:18:13 UTC (rev 12755)
@@ -5,6 +5,7 @@
#include <QMap>
#include <Qt>
+#include "qgssymbolv2.h"
class QgsSymbolV2;
class QgsSymbolLayerV2;
@@ -44,7 +45,7 @@
static QPointF decodePoint( QString str );
static QIcon symbolPreviewIcon( QgsSymbolV2* symbol, QSize size );
- static QIcon symbolLayerPreviewIcon( QgsSymbolLayerV2* layer, QSize size );
+ static QIcon symbolLayerPreviewIcon( QgsSymbolLayerV2* layer, QgsSymbolV2::OutputUnit u, QSize size );
static QIcon colorRampPreviewIcon( QgsVectorColorRampV2* ramp, QSize size );
static QPixmap symbolPreviewPixmap( QgsSymbolV2* symbol, QSize size );
@@ -64,6 +65,11 @@
static QgsVectorColorRampV2* loadColorRamp( QDomElement& element );
static QDomElement saveColorRamp( QString name, QgsVectorColorRampV2* ramp, QDomDocument& doc );
+
+ /**Returns the line width scale factor depending on the unit and the paint device*/
+ static double lineWidthScaleFactor( QgsRenderContext* c, QgsSymbolV2::OutputUnit u );
+ /**Returns scale factor painter units -> pixel dimensions*/
+ static double pixelSizeScaleFactor( QgsRenderContext* c, QgsSymbolV2::OutputUnit u );
};
class QPolygonF;
Modified: trunk/qgis/src/core/symbology-ng/qgssymbolv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbolv2.cpp 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgssymbolv2.cpp 2010-01-14 16:18:13 UTC (rev 12755)
@@ -17,7 +17,7 @@
#include <cmath>
QgsSymbolV2::QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers )
- : mType( type ), mLayers( layers )
+ : mType( type ), mLayers( layers ), mOutputUnit( MM )
{
// check they're all correct symbol layers
@@ -126,14 +126,16 @@
void QgsSymbolV2::startRender( QgsRenderContext& context )
{
+ QgsSymbolV2RenderContext symbolContext( &context, mOutputUnit );
for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
- ( *it )->startRender( context );
+ ( *it )->startRender( symbolContext );
}
void QgsSymbolV2::stopRender( QgsRenderContext& context )
{
+ QgsSymbolV2RenderContext symbolContext( &context, mOutputUnit );
for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
- ( *it )->stopRender( context );
+ ( *it )->stopRender( symbolContext );
}
void QgsSymbolV2::setColor( const QColor& color )
@@ -158,9 +160,12 @@
void QgsSymbolV2::drawPreviewIcon( QPainter* painter, QSize size )
{
+ QgsRenderContext context;
+ context.setPainter( painter );
+ QgsSymbolV2RenderContext symbolContext( &context, mOutputUnit );
for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
{
- ( *it )->drawPreviewIcon( painter, size );
+ ( *it )->drawPreviewIcon( symbolContext, size );
}
}
@@ -240,7 +245,19 @@
return lst;
}
+////////////////////
+QgsSymbolV2RenderContext::QgsSymbolV2RenderContext( QgsRenderContext* c, QgsSymbolV2::OutputUnit u ): mRenderContext( c ), mOutputUnit( u )
+{
+
+}
+
+QgsSymbolV2RenderContext::~QgsSymbolV2RenderContext()
+{
+
+}
+
+
///////////////////
@@ -306,23 +323,26 @@
void QgsMarkerSymbolV2::renderPoint( const QPointF& point, QgsRenderContext& context, int layer )
{
+ QgsSymbolV2RenderContext symbolContext( &context, mOutputUnit );
if ( layer != -1 )
{
if ( layer >= 0 && layer < mLayers.count() )
- (( QgsMarkerSymbolLayerV2* ) mLayers[layer] )->renderPoint( point, context );
+ (( QgsMarkerSymbolLayerV2* ) mLayers[layer] )->renderPoint( point, symbolContext );
return;
}
for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
{
QgsMarkerSymbolLayerV2* layer = ( QgsMarkerSymbolLayerV2* ) * it;
- layer->renderPoint( point, context );
+ layer->renderPoint( point, symbolContext );
}
}
QgsSymbolV2* QgsMarkerSymbolV2::clone() const
{
- return new QgsMarkerSymbolV2( cloneLayers() );
+ QgsSymbolV2* cloneSymbol = new QgsMarkerSymbolV2( cloneLayers() );
+ cloneSymbol->setOutputUnit( mOutputUnit );
+ return cloneSymbol;
}
@@ -371,24 +391,27 @@
void QgsLineSymbolV2::renderPolyline( const QPolygonF& points, QgsRenderContext& context, int layer )
{
+ QgsSymbolV2RenderContext symbolContext( &context, mOutputUnit );
if ( layer != -1 )
{
if ( layer >= 0 && layer < mLayers.count() )
- (( QgsLineSymbolLayerV2* ) mLayers[layer] )->renderPolyline( points, context );
+ (( QgsLineSymbolLayerV2* ) mLayers[layer] )->renderPolyline( points, symbolContext );
return;
}
for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
{
QgsLineSymbolLayerV2* layer = ( QgsLineSymbolLayerV2* ) * it;
- layer->renderPolyline( points, context );
+ layer->renderPolyline( points, symbolContext );
}
}
QgsSymbolV2* QgsLineSymbolV2::clone() const
{
- return new QgsLineSymbolV2( cloneLayers() );
+ QgsSymbolV2* cloneSymbol = new QgsLineSymbolV2( cloneLayers() );
+ cloneSymbol->setOutputUnit( mOutputUnit );
+ return cloneSymbol;
}
///////////////////
@@ -403,22 +426,25 @@
void QgsFillSymbolV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context, int layer )
{
+ QgsSymbolV2RenderContext symbolContext( &context, mOutputUnit );
if ( layer != -1 )
{
if ( layer >= 0 && layer < mLayers.count() )
- (( QgsFillSymbolLayerV2* ) mLayers[layer] )->renderPolygon( points, rings, context );
+ (( QgsFillSymbolLayerV2* ) mLayers[layer] )->renderPolygon( points, rings, symbolContext );
return;
}
for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
{
QgsFillSymbolLayerV2* layer = ( QgsFillSymbolLayerV2* ) * it;
- layer->renderPolygon( points, rings, context );
+ layer->renderPolygon( points, rings, symbolContext );
}
}
QgsSymbolV2* QgsFillSymbolV2::clone() const
{
- return new QgsFillSymbolV2( cloneLayers() );
+ QgsSymbolV2* cloneSymbol = new QgsFillSymbolV2( cloneLayers() );
+ cloneSymbol->setOutputUnit( mOutputUnit );
+ return cloneSymbol;
}
Modified: trunk/qgis/src/core/symbology-ng/qgssymbolv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbolv2.h 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/core/symbology-ng/qgssymbolv2.h 2010-01-14 16:18:13 UTC (rev 12755)
@@ -22,6 +22,12 @@
{
public:
+ enum OutputUnit
+ {
+ MM,
+ MapUnit
+ };
+
enum SymbolType
{
Marker,
@@ -72,6 +78,9 @@
virtual QgsSymbolV2* clone() const = 0;
+ OutputUnit outputUnit() const { return mOutputUnit; }
+ void setOutputUnit( OutputUnit u ) { mOutputUnit = u; }
+
protected:
QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers ); // can't be instantiated
@@ -79,10 +88,31 @@
SymbolType mType;
QgsSymbolLayerV2List mLayers;
+
+ OutputUnit mOutputUnit;
};
+///////////////////////
+class CORE_EXPORT QgsSymbolV2RenderContext
+{
+ public:
+ QgsSymbolV2RenderContext( QgsRenderContext* c, QgsSymbolV2::OutputUnit u );
+ ~QgsSymbolV2RenderContext();
+ QgsRenderContext* renderContext() { return mRenderContext; }
+ void setRenderContext( QgsRenderContext* c ) { mRenderContext = c;}
+
+ QgsSymbolV2::OutputUnit outputUnit() const { return mOutputUnit; }
+ void setOutputUnit( QgsSymbolV2::OutputUnit u ) { mOutputUnit = u; }
+
+ private:
+ QgsRenderContext* mRenderContext;
+ QgsSymbolV2::OutputUnit mOutputUnit;
+};
+
+
+
//////////////////////
Modified: trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/gui/symbology-ng/qgssymbollayerv2widget.cpp 2010-01-14 16:18:13 UTC (rev 12755)
@@ -105,7 +105,7 @@
for ( int i = 0; i < names.count(); ++i )
{
QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
- QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( lyr, size );
+ QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( lyr, QgsSymbolV2::MM, size ); //todo: unit needs to be a parameter
QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
item->setData( Qt::UserRole, names[i] );
delete lyr;
Modified: trunk/qgis/src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp 2010-01-14 16:18:13 UTC (rev 12755)
@@ -12,6 +12,7 @@
#include "qgsapplication.h"
#include "qgssymbollayerv2widget.h"
+#include "qgssymbolv2.h" //for the unit
static const int SymbolLayerItemType = QStandardItem::UserType + 1;
@@ -31,7 +32,7 @@
void updatePreview()
{
- QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( mLayer, QSize( 16, 16 ) );
+ QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( mLayer, QgsSymbolV2::MM, QSize( 16, 16 ) ); //todo: make unit a parameter
setIcon( icon );
}
@@ -335,7 +336,7 @@
void QgsSymbolV2PropertiesDialog::moveLayerDown()
{
- moveLayerByOffset( +1 );
+ moveLayerByOffset( + 1 );
}
void QgsSymbolV2PropertiesDialog::moveLayerUp()
Modified: trunk/qgis/src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgssymbolv2selectordialog.cpp 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/gui/symbology-ng/qgssymbolv2selectordialog.cpp 2010-01-14 16:18:13 UTC (rev 12755)
@@ -41,6 +41,20 @@
updateSymbolPreview();
updateSymbolInfo();
+ //output unit
+ mSymbolUnitComboBox->blockSignals( true );
+ mSymbolUnitComboBox->addItem( tr( "Millimeter" ) );
+ mSymbolUnitComboBox->addItem( tr( "Map unit" ) );
+ if ( mSymbol && mSymbol->outputUnit() == QgsSymbolV2::MM )
+ {
+ mSymbolUnitComboBox->setCurrentIndex( mSymbolUnitComboBox->findText( tr( "Millimeter" ) ) );
+ }
+ else
+ {
+ mSymbolUnitComboBox->setCurrentIndex( mSymbolUnitComboBox->findText( tr( "Map unit" ) ) );
+ }
+ mSymbolUnitComboBox->blockSignals( false );
+
// select correct page in stacked widget
// there's a correspondence between symbol type number and page numbering => exploit it!
stackedWidget->setCurrentIndex( symbol->type() );
@@ -224,3 +238,21 @@
QDialog::keyPressEvent( e );
}
}
+
+void QgsSymbolV2SelectorDialog::on_mSymbolUnitComboBox_currentIndexChanged( const QString & text )
+{
+ if ( !mSymbol )
+ {
+ return;
+ }
+ if ( text == tr( "Millimeter" ) )
+ {
+ mSymbol->setOutputUnit( QgsSymbolV2::MM );
+ }
+ else //map unit
+ {
+ mSymbol->setOutputUnit( QgsSymbolV2::MapUnit );
+ }
+ updateSymbolPreview();
+ emit symbolModified();
+}
Modified: trunk/qgis/src/gui/symbology-ng/qgssymbolv2selectordialog.h
===================================================================
--- trunk/qgis/src/gui/symbology-ng/qgssymbolv2selectordialog.h 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/gui/symbology-ng/qgssymbolv2selectordialog.h 2010-01-14 16:18:13 UTC (rev 12755)
@@ -33,6 +33,7 @@
void setMarkerSize( double size );
void setLineWidth( double width );
void addSymbolToStyle();
+ void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
signals:
void symbolModified();
Modified: trunk/qgis/src/ui/qgssymbolv2selectordialogbase.ui
===================================================================
--- trunk/qgis/src/ui/qgssymbolv2selectordialogbase.ui 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/ui/qgssymbolv2selectordialogbase.ui 2010-01-14 16:18:13 UTC (rev 12755)
@@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
- <width>452</width>
+ <width>331</width>
<height>404</height>
</rect>
</property>
<property name="windowTitle">
<string>Symbol selector</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="lblPreview">
@@ -164,7 +164,7 @@
</item>
</layout>
</item>
- <item>
+ <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnSymbolProperties">
@@ -195,14 +195,28 @@
</item>
</layout>
</item>
- <item>
+ <item row="2" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="mSymbolUnitLabel">
+ <property name="text">
+ <string>Symbol Unit:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="mSymbolUnitComboBox"/>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Symbols from style:</string>
</property>
</widget>
</item>
- <item>
+ <item row="4" column="0">
<widget class="QListView" name="viewSymbols">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -230,7 +244,7 @@
</property>
</widget>
</item>
- <item>
+ <item row="5" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Modified: trunk/qgis/src/ui/symbollayer/widget_markerline.ui
===================================================================
--- trunk/qgis/src/ui/symbollayer/widget_markerline.ui 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/ui/symbollayer/widget_markerline.ui 2010-01-14 16:18:13 UTC (rev 12755)
@@ -73,8 +73,11 @@
<number>1</number>
</property>
<property name="minimum">
- <double>-100.000000000000000</double>
+ <double>-100000.000000000000000</double>
</property>
+ <property name="maximum">
+ <double>100000.000000000000000</double>
+ </property>
</widget>
</item>
<item row="1" column="1">
@@ -82,6 +85,9 @@
<property name="decimals">
<number>1</number>
</property>
+ <property name="maximum">
+ <double>100000.000000000000000</double>
+ </property>
<property name="value">
<double>1.000000000000000</double>
</property>
Modified: trunk/qgis/src/ui/symbollayer/widget_simplefill.ui
===================================================================
--- trunk/qgis/src/ui/symbollayer/widget_simplefill.ui 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/ui/symbollayer/widget_simplefill.ui 2010-01-14 16:18:13 UTC (rev 12755)
@@ -92,6 +92,9 @@
<property name="decimals">
<number>1</number>
</property>
+ <property name="maximum">
+ <double>100000.000000000000000</double>
+ </property>
</widget>
</item>
</layout>
@@ -113,11 +116,6 @@
</widget>
<customwidgets>
<customwidget>
- <class>QgsBrushStyleComboBox</class>
- <extends>QComboBox</extends>
- <header>qgsbrushstylecombobox.h</header>
- </customwidget>
- <customwidget>
<class>QgsColorButtonV2</class>
<extends>QPushButton</extends>
<header>qgscolorbutton.h</header>
@@ -127,6 +125,11 @@
<extends>QComboBox</extends>
<header>qgspenstylecombobox.h</header>
</customwidget>
+ <customwidget>
+ <class>QgsBrushStyleComboBox</class>
+ <extends>QComboBox</extends>
+ <header>qgsbrushstylecombobox.h</header>
+ </customwidget>
</customwidgets>
<tabstops>
<tabstop>btnChangeColor</tabstop>
Modified: trunk/qgis/src/ui/symbollayer/widget_simpleline.ui
===================================================================
--- trunk/qgis/src/ui/symbollayer/widget_simpleline.ui 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/ui/symbollayer/widget_simpleline.ui 2010-01-14 16:18:13 UTC (rev 12755)
@@ -85,8 +85,11 @@
<number>1</number>
</property>
<property name="minimum">
- <double>-100.000000000000000</double>
+ <double>-100000.000000000000000</double>
</property>
+ <property name="maximum">
+ <double>100000.000000000000000</double>
+ </property>
</widget>
</item>
<item row="1" column="1">
@@ -103,6 +106,9 @@
<property name="decimals">
<number>1</number>
</property>
+ <property name="maximum">
+ <double>100000.000000000000000</double>
+ </property>
<property name="value">
<double>1.000000000000000</double>
</property>
@@ -167,6 +173,11 @@
</widget>
<customwidgets>
<customwidget>
+ <class>QgsColorButtonV2</class>
+ <extends>QPushButton</extends>
+ <header>qgscolorbutton.h</header>
+ </customwidget>
+ <customwidget>
<class>QgsPenStyleComboBox</class>
<extends>QComboBox</extends>
<header>qgspenstylecombobox.h</header>
@@ -181,11 +192,6 @@
<extends>QComboBox</extends>
<header>qgspenstylecombobox.h</header>
</customwidget>
- <customwidget>
- <class>QgsColorButtonV2</class>
- <extends>QPushButton</extends>
- <header>qgscolorbutton.h</header>
- </customwidget>
</customwidgets>
<resources/>
<connections/>
Modified: trunk/qgis/src/ui/symbollayer/widget_simplemarker.ui
===================================================================
--- trunk/qgis/src/ui/symbollayer/widget_simplemarker.ui 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/ui/symbollayer/widget_simplemarker.ui 2010-01-14 16:18:13 UTC (rev 12755)
@@ -123,6 +123,9 @@
<property name="decimals">
<number>1</number>
</property>
+ <property name="maximum">
+ <double>100000.000000000000000</double>
+ </property>
<property name="value">
<double>1.000000000000000</double>
</property>
Modified: trunk/qgis/src/ui/symbollayer/widget_svgmarker.ui
===================================================================
--- trunk/qgis/src/ui/symbollayer/widget_svgmarker.ui 2010-01-13 17:00:20 UTC (rev 12754)
+++ trunk/qgis/src/ui/symbollayer/widget_svgmarker.ui 2010-01-14 16:18:13 UTC (rev 12755)
@@ -70,8 +70,11 @@
<number>1</number>
</property>
<property name="minimum">
- <double>-100.000000000000000</double>
+ <double>-100000.000000000000000</double>
</property>
+ <property name="maximum">
+ <double>100000.000000000000000</double>
+ </property>
</widget>
</item>
<item>
@@ -80,8 +83,11 @@
<number>1</number>
</property>
<property name="minimum">
- <double>-100.000000000000000</double>
+ <double>-100000.000000000000000</double>
</property>
+ <property name="maximum">
+ <double>100000.000000000000000</double>
+ </property>
</widget>
</item>
</layout>
@@ -104,6 +110,9 @@
<property name="decimals">
<number>1</number>
</property>
+ <property name="maximum">
+ <double>100000.000000000000000</double>
+ </property>
<property name="value">
<double>1.000000000000000</double>
</property>
More information about the QGIS-commit
mailing list