QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgssymbolv2.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolv2.cpp
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgssymbolv2.h"
17 #include "qgssymbollayerv2.h"
18 
19 #include "qgslinesymbollayerv2.h"
20 #include "qgsmarkersymbollayerv2.h"
21 #include "qgsfillsymbollayerv2.h"
22 
23 #include "qgslogger.h"
24 #include "qgsrendercontext.h" // for bigSymbolPreview
25 
26 #include "qgsproject.h"
27 #include "qgsstylev2.h"
28 
29 #include <QColor>
30 #include <QImage>
31 #include <QPainter>
32 #include <QSize>
33 
34 #include <cmath>
35 
37  : mType( type ), mLayers( layers ), mAlpha( 1.0 ), mRenderHints( 0 ), mLayer( NULL )
38 {
39 
40  // check they're all correct symbol layers
41  for ( int i = 0; i < mLayers.count(); i++ )
42  {
43  if ( mLayers[i] == NULL )
44  {
45  mLayers.removeAt( i-- );
46  }
47  else if ( !isSymbolLayerCompatible( mLayers[i]->type() ) )
48  {
49  delete mLayers[i];
50  mLayers.removeAt( i-- );
51  }
52  }
53 
54 }
55 
57 {
58  // delete all symbol layers (we own them, so it's okay)
59  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
60  delete *it;
61 }
62 
64 {
66 
67  QgsSymbolLayerV2List::const_iterator it = mLayers.constBegin();
68  for ( ; it != mLayers.constEnd(); ++it )
69  {
70  if ( it == mLayers.constBegin() )
71  {
72  unit = ( *it )->outputUnit();
73  }
74  else
75  {
76  if (( *it )->outputUnit() != unit )
77  {
78  return QgsSymbolV2::Mixed;
79  }
80  }
81  }
82 
83  return unit;
84 }
85 
87 {
88  QgsSymbolLayerV2List::iterator it = mLayers.begin();
89  for ( ; it != mLayers.end(); ++it )
90  {
91  ( *it )->setOutputUnit( u );
92  }
93 }
94 
96 {
97  QgsSymbolV2* s = 0;
98 
99  // override global default if project has a default for this type
100  QString defaultSymbol;
101  switch ( geomType )
102  {
103  case QGis::Point :
104  defaultSymbol = QgsProject::instance()->readEntry( "DefaultStyles", "/Marker", "" );
105  break;
106  case QGis::Line :
107  defaultSymbol = QgsProject::instance()->readEntry( "DefaultStyles", "/Line", "" );
108  break;
109  case QGis::Polygon :
110  defaultSymbol = QgsProject::instance()->readEntry( "DefaultStyles", "/Fill", "" );
111  break;
112  default: defaultSymbol = ""; break;
113  }
114  if ( defaultSymbol != "" )
115  s = QgsStyleV2::defaultStyle()->symbol( defaultSymbol );
116 
117  // if no default found for this type, get global default (as previously)
118  if ( ! s )
119  {
120  switch ( geomType )
121  {
122  case QGis::Point: s = new QgsMarkerSymbolV2(); break;
123  case QGis::Line: s = new QgsLineSymbolV2(); break;
124  case QGis::Polygon: s = new QgsFillSymbolV2(); break;
125  default: QgsDebugMsg( "unknown layer's geometry type" ); return NULL;
126  }
127  }
128 
129  // set alpha transparency
130  s->setAlpha( QgsProject::instance()->readDoubleEntry( "DefaultStyles", "/AlphaInt", 255 ) / 255.0 );
131 
132  // set random color, it project prefs allow
133  if ( defaultSymbol == "" ||
134  QgsProject::instance()->readBoolEntry( "DefaultStyles", "/RandomColors", true ) )
135  {
136  s->setColor( QColor::fromHsv( rand() % 360, 64 + rand() % 192, 128 + rand() % 128 ) );
137  }
138 
139  return s;
140 }
141 
143 {
144  if ( layer < 0 || layer >= mLayers.count() )
145  return NULL;
146 
147  return mLayers[layer];
148 }
149 
150 
152 {
153  // fill symbol can contain also line symbol layers for drawing of outlines
154  if ( mType == Fill && t == Line )
155  return true;
156 
157  return mType == t;
158 }
159 
160 
162 {
163  if ( index < 0 || index > mLayers.count() ) // can be added also after the last index
164  return false;
165  if ( layer == NULL || !isSymbolLayerCompatible( layer->type() ) )
166  return false;
167 
168  mLayers.insert( index, layer );
169  return true;
170 }
171 
172 
174 {
175  if ( layer == NULL || !isSymbolLayerCompatible( layer->type() ) )
176  return false;
177 
178  mLayers.append( layer );
179  return true;
180 }
181 
182 
184 {
185  if ( index < 0 || index >= mLayers.count() )
186  return false;
187 
188  delete mLayers[index];
189  mLayers.removeAt( index );
190  return true;
191 }
192 
193 
195 {
196  if ( index < 0 || index >= mLayers.count() )
197  return NULL;
198 
199  return mLayers.takeAt( index );
200 }
201 
202 
204 {
205  if ( index < 0 || index >= mLayers.count() )
206  return false;
207  if ( layer == NULL || !isSymbolLayerCompatible( layer->type() ) )
208  return false;
209 
210  delete mLayers[index]; // first delete the original layer
211  mLayers[index] = layer; // set new layer
212  return true;
213 }
214 
215 
216 void QgsSymbolV2::startRender( QgsRenderContext& context, const QgsFields* fields )
217 {
218  QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints, 0, fields );
219 
220 
221  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
222  ( *it )->startRender( symbolContext );
223 }
224 
226 {
227  QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints );
228 
229  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
230  ( *it )->stopRender( symbolContext );
231 
232  mLayer = NULL;
233 }
234 
235 void QgsSymbolV2::setColor( const QColor& color )
236 {
237  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
238  {
239  if ( !( *it )->isLocked() )
240  ( *it )->setColor( color );
241  }
242 }
243 
244 QColor QgsSymbolV2::color() const
245 {
246  for ( QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it )
247  {
248  // return color of the first unlocked layer
249  if ( !( *it )->isLocked() )
250  return ( *it )->color();
251  }
252  return QColor( 0, 0, 0 );
253 }
254 
255 void QgsSymbolV2::drawPreviewIcon( QPainter* painter, QSize size )
256 {
258  QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints );
259 
260  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
261  {
262  if ( mType == Fill && ( *it )->type() == Line )
263  {
264  // line symbol layer would normally draw just a line
265  // so we override this case to force it to draw a polygon outline
267 
268  // from QgsFillSymbolLayerV2::drawPreviewIcon()
269  QPolygonF poly = QRectF( QPointF( 0, 0 ), QPointF( size.width() - 1, size.height() - 1 ) );
270  lsl->startRender( symbolContext );
271  lsl->renderPolygonOutline( poly, NULL, symbolContext );
272  lsl->stopRender( symbolContext );
273  }
274  else
275  ( *it )->drawPreviewIcon( symbolContext, size );
276  }
277 }
278 
279 
281 {
282  QImage preview( QSize( 100, 100 ), QImage::Format_ARGB32_Premultiplied );
283  preview.fill( 0 );
284 
285  QPainter p( &preview );
286  p.setRenderHint( QPainter::Antialiasing );
287  p.translate( 0.5, 0.5 ); // shift by half a pixel to avoid blurring due antialising
288 
289  if ( mType == QgsSymbolV2::Marker )
290  {
291  p.setPen( QPen( Qt::gray ) );
292  p.drawLine( 0, 50, 100, 50 );
293  p.drawLine( 50, 0, 50, 100 );
294  }
295 
297  startRender( context );
298 
299  if ( mType == QgsSymbolV2::Line )
300  {
301  QPolygonF poly;
302  poly << QPointF( 0, 50 ) << QPointF( 99, 50 );
303  static_cast<QgsLineSymbolV2*>( this )->renderPolyline( poly, 0, context );
304  }
305  else if ( mType == QgsSymbolV2::Fill )
306  {
307  QPolygonF polygon;
308  polygon << QPointF( 20, 20 ) << QPointF( 80, 20 ) << QPointF( 80, 80 ) << QPointF( 20, 80 ) << QPointF( 20, 20 );
309  static_cast<QgsFillSymbolV2*>( this )->renderPolygon( polygon, NULL, 0, context );
310  }
311  else // marker
312  {
313  static_cast<QgsMarkerSymbolV2*>( this )->renderPoint( QPointF( 50, 50 ), 0, context );
314  }
315 
316  stopRender( context );
317  return preview;
318 }
319 
320 
321 QString QgsSymbolV2::dump() const
322 {
323  QString t;
324  switch ( type() )
325  {
326  case QgsSymbolV2::Marker: t = "MARKER"; break;
327  case QgsSymbolV2::Line: t = "LINE"; break;
328  case QgsSymbolV2::Fill: t = "FILL"; break;
329  default: Q_ASSERT( 0 && "unknown symbol type" );
330  }
331  QString s = QString( "%1 SYMBOL (%2 layers) color %3" ).arg( t ).arg( mLayers.count() ).arg( QgsSymbolLayerV2Utils::encodeColor( color() ) );
332 
333  for ( QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it )
334  {
335  // TODO:
336  }
337  return s;
338 }
339 
340 void QgsSymbolV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
341 {
342  props[ "alpha" ] = QString::number( alpha() );
343  double scaleFactor = 1.0;
344  props[ "uom" ] = QgsSymbolLayerV2Utils::encodeSldUom( outputUnit(), &scaleFactor );
345  props[ "uomScale" ] = scaleFactor != 1 ? QString::number( scaleFactor ) : "";
346 
347  for ( QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it )
348  {
349  ( *it )->toSld( doc, element, props );
350  }
351 }
352 
354 {
356  for ( QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it )
357  {
358  QgsSymbolLayerV2* layer = ( *it )->clone();
359  layer->setLocked(( *it )->isLocked() );
360  layer->setRenderingPass(( *it )->renderingPass() );
361  lst.append( layer );
362  }
363  return lst;
364 }
365 
366 QSet<QString> QgsSymbolV2::usedAttributes() const
367 {
368  QSet<QString> attributes;
369  QgsSymbolLayerV2List::const_iterator sIt = mLayers.constBegin();
370  for ( ; sIt != mLayers.constEnd(); ++sIt )
371  {
372  if ( *sIt )
373  {
374  attributes.unite(( *sIt )->usedAttributes() );
375  }
376  }
377  return attributes;
378 }
379 
381 
382 
383 QgsSymbolV2RenderContext::QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u, qreal alpha, bool selected, int renderHints, const QgsFeature* f, const QgsFields* fields )
384  : mRenderContext( c ), mOutputUnit( u ), mAlpha( alpha ), mSelected( selected ), mRenderHints( renderHints ), mFeature( f ), mFields( fields )
385 {
386 
387 }
388 
390 {
391 
392 }
393 
394 
395 double QgsSymbolV2RenderContext::outputLineWidth( double width ) const
396 {
398 }
399 
401 {
403 }
404 
406 {
407  // This is just a dummy implementation of assignment.
408  // sip 4.7 generates a piece of code that needs this function to exist.
409  // It's not generated automatically by the compiler because of
410  // mRenderContext member which is a reference (and thus can't be changed).
411  Q_ASSERT( false );
412  return *this;
413 }
414 
416 
418 {
420  if ( sl == NULL )
421  return NULL;
422 
423  QgsSymbolLayerV2List layers;
424  layers.append( sl );
425  return new QgsMarkerSymbolV2( layers );
426 }
427 
429 {
431  if ( sl == NULL )
432  return NULL;
433 
434  QgsSymbolLayerV2List layers;
435  layers.append( sl );
436  return new QgsLineSymbolV2( layers );
437 }
438 
440 {
442  if ( sl == NULL )
443  return NULL;
444 
445  QgsSymbolLayerV2List layers;
446  layers.append( sl );
447  return new QgsFillSymbolV2( layers );
448 }
449 
451 
452 
454  : QgsSymbolV2( Marker, layers )
455 {
456  if ( mLayers.count() == 0 )
457  mLayers.append( new QgsSimpleMarkerSymbolLayerV2() );
458 }
459 
460 void QgsMarkerSymbolV2::setAngle( double ang )
461 {
462  double origAngle = angle();
463  double angleDiff = ang - origAngle;
464  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
465  {
467  layer->setAngle( layer->angle() + angleDiff );
468  }
469 }
470 
472 {
473  QgsSymbolLayerV2List::const_iterator it = mLayers.begin();
474 
475  if ( it == mLayers.end() )
476  return 0;
477 
478  // return angle of the first symbol layer
479  const QgsMarkerSymbolLayerV2* layer = static_cast<const QgsMarkerSymbolLayerV2 *>( *it );
480  return layer->angle();
481 }
482 
484 {
485  double origSize = size();
486 
487  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
488  {
489  QgsMarkerSymbolLayerV2* layer = static_cast<QgsMarkerSymbolLayerV2*>( *it );
490  if ( layer->size() == origSize )
491  layer->setSize( s );
492  else
493  {
494  // proportionally scale size
495  if ( origSize != 0 )
496  layer->setSize( layer->size() * s / origSize );
497  }
498  }
499 }
500 
502 {
503  // return size of the largest symbol
504  double maxSize = 0;
505  for ( QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it )
506  {
507  const QgsMarkerSymbolLayerV2* layer = static_cast<const QgsMarkerSymbolLayerV2 *>( *it );
508  double lsize = layer->size();
509  if ( lsize > maxSize )
510  maxSize = lsize;
511  }
512  return maxSize;
513 }
514 
515 
517 {
518  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
519  {
520  QgsMarkerSymbolLayerV2* layer = static_cast<QgsMarkerSymbolLayerV2*>( *it );
521  layer->setScaleMethod( scaleMethod );
522  }
523 }
524 
526 {
527  QgsSymbolLayerV2List::const_iterator it = mLayers.begin();
528 
529  if ( it == mLayers.end() )
530  return DEFAULT_SCALE_METHOD;
531 
532  // return scale method of the first symbol layer
533  const QgsMarkerSymbolLayerV2* layer = static_cast<const QgsMarkerSymbolLayerV2 *>( *it );
534  return layer->scaleMethod();
535 }
536 
537 void QgsMarkerSymbolV2::renderPoint( const QPointF& point, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
538 {
539  QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f );
540 
541  if ( layer != -1 )
542  {
543  if ( layer >= 0 && layer < mLayers.count() )
544  (( QgsMarkerSymbolLayerV2* ) mLayers[layer] )->renderPoint( point, symbolContext );
545  return;
546  }
547 
548  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
549  {
551  layer->renderPoint( point, symbolContext );
552  }
553 }
554 
556 {
557  QgsSymbolV2* cloneSymbol = new QgsMarkerSymbolV2( cloneLayers() );
558  cloneSymbol->setAlpha( mAlpha );
559  return cloneSymbol;
560 }
561 
562 
564 // LINE
565 
567  : QgsSymbolV2( Line, layers )
568 {
569  if ( mLayers.count() == 0 )
570  mLayers.append( new QgsSimpleLineSymbolLayerV2() );
571 }
572 
574 {
575  double origWidth = width();
576 
577  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
578  {
580  if ( layer->width() == origWidth )
581  {
582  layer->setWidth( w );
583  }
584  else
585  {
586  // proportionally scale the width
587  if ( origWidth != 0 )
588  layer->setWidth( layer->width() * w / origWidth );
589  }
590  }
591 }
592 
594 {
595  double maxWidth = 0;
596  for ( QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it )
597  {
598  const QgsLineSymbolLayerV2* layer = ( const QgsLineSymbolLayerV2* ) * it;
599  double width = layer->width();
600  if ( width > maxWidth )
601  maxWidth = width;
602  }
603  return maxWidth;
604 }
605 
606 void QgsLineSymbolV2::renderPolyline( const QPolygonF& points, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
607 {
608  QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f );
609 
610  if ( layer != -1 )
611  {
612  if ( layer >= 0 && layer < mLayers.count() )
613  (( QgsLineSymbolLayerV2* ) mLayers[layer] )->renderPolyline( points, symbolContext );
614  return;
615  }
616 
617  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
618  {
619  QgsLineSymbolLayerV2* layer = ( QgsLineSymbolLayerV2* ) * it;
620  layer->renderPolyline( points, symbolContext );
621  }
622 }
623 
624 
626 {
627  QgsSymbolV2* cloneSymbol = new QgsLineSymbolV2( cloneLayers() );
628  cloneSymbol->setAlpha( mAlpha );
629  return cloneSymbol;
630 }
631 
633 // FILL
634 
636  : QgsSymbolV2( Fill, layers )
637 {
638  if ( mLayers.count() == 0 )
639  mLayers.append( new QgsSimpleFillSymbolLayerV2() );
640 }
641 
642 void QgsFillSymbolV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
643 {
644  QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f );
645 
646  if ( layer != -1 )
647  {
648  if ( layer >= 0 && layer < mLayers.count() )
649  {
650  QgsSymbolV2::SymbolType layertype = mLayers.at( layer )->type();
651  if ( layertype == QgsSymbolV2::Fill )
652  (( QgsFillSymbolLayerV2* ) mLayers[layer] )->renderPolygon( points, rings, symbolContext );
653  else if ( layertype == QgsSymbolV2::Line )
654  (( QgsLineSymbolLayerV2* ) mLayers[layer] )->renderPolygonOutline( points, rings, symbolContext );
655  }
656  return;
657  }
658 
659  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
660  {
661  QgsSymbolV2::SymbolType layertype = ( *it )->type();
662  if ( layertype == QgsSymbolV2::Fill )
663  {
664  QgsFillSymbolLayerV2* layer = ( QgsFillSymbolLayerV2* ) * it;
665  layer->renderPolygon( points, rings, symbolContext );
666  }
667  else if ( layertype == QgsSymbolV2::Line )
668  {
669  QgsLineSymbolLayerV2* layer = ( QgsLineSymbolLayerV2* ) * it;
670  layer->renderPolygonOutline( points, rings, symbolContext );
671  }
672  }
673 }
674 
675 
677 {
678  QgsSymbolV2* cloneSymbol = new QgsFillSymbolV2( cloneLayers() );
679  cloneSymbol->setAlpha( mAlpha );
680  return cloneSymbol;
681 }
682 
684 {
685  for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
686  {
688  layer->setAngle( angle );
689  }
690 }
void setLocked(bool locked)
bool deleteSymbolLayer(int index)
delete symbol layer at specified index
static unsigned index
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
static QgsMarkerSymbolV2 * createSimple(const QgsStringMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
QgsSymbolV2(SymbolType type, QgsSymbolLayerV2List layers)
Definition: qgssymbolv2.cpp:36
GeometryType
Definition: qgis.h:155
virtual double width() const
const QgsVectorLayer * mLayer
Definition: qgssymbolv2.h:153
SymbolType type() const
Definition: qgssymbolv2.h:78
QSet< QString > usedAttributes() const
#define QgsDebugMsg(str)
Definition: qgslogger.h:36
void drawPreviewIcon(QPainter *painter, QSize size)
static QString encodeSldUom(QgsSymbolV2::OutputUnit unit, double *scaleFactor)
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QgsFillSymbolV2(QgsSymbolLayerV2List layers=QgsSymbolLayerV2List())
static QgsFillSymbolV2 * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
bool changeSymbolLayer(int index, QgsSymbolLayerV2 *layer)
delete layer at specified index and set a new one
ScaleMethod scaleMethod()
Container of fields for a vector layer.
Definition: qgsfield.h:164
virtual void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)=0
QgsSymbolV2 * symbol(QString name)
return a NEW copy of symbol
Definition: qgsstylev2.cpp:164
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:114
SymbolType mType
Definition: qgssymbolv2.h:145
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
QMap< QString, QString > QgsStringMap
Definition: qgis.h:416
void setWidth(double width)
void setAngle(double angle)
const QgsVectorLayer * layer() const
Definition: qgssymbolv2.h:133
virtual void startRender(QgsSymbolV2RenderContext &context)=0
static QString encodeColor(QColor color)
void setColor(const QColor &color)
static QgsRenderContext createRenderContext(QPainter *p)
Creates a render context for a pixel based device.
QgsSymbolLayerV2List mLayers
Definition: qgssymbolv2.h:146
QgsSymbolLayerV2List cloneLayers() const
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
append symbol layer at the end of the list
virtual void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context)=0
QgsLineSymbolV2(QgsSymbolLayerV2List layers=QgsSymbolLayerV2List())
void startRender(QgsRenderContext &context, const QgsFields *fields=0)
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
Definition: qgssymbolv2.h:121
static QgsLineSymbolV2 * createSimple(const QgsStringMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties. ...
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
void setRenderingPass(int renderingPass)
#define DEFAULT_SCALE_METHOD
virtual void setWidth(double width)
static QgsStyleV2 * defaultStyle()
return default application-wide style
Definition: qgsstylev2.cpp:51
void renderPolyline(const QPolygonF &points, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void setAngle(double angle)
void setAngle(double angle)
void setSize(double size)
static double pixelSizeScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u)
Returns scale factor painter units -> pixel dimensions.
qreal mAlpha
Symbol opacity (in the range 0 - 1)
Definition: qgssymbolv2.h:149
QgsSymbolV2RenderContext & operator=(const QgsSymbolV2RenderContext &)
virtual void renderPolygonOutline(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
void renderPoint(const QPointF &point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
QgsSymbolV2::ScaleMethod scaleMethod() const
QgsSymbolV2::SymbolType type() const
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
virtual ~QgsSymbolV2()
Definition: qgssymbolv2.cpp:56
virtual void renderPolyline(const QPolygonF &points, QgsSymbolV2RenderContext &context)=0
virtual QgsSymbolV2 * clone() const
bool isSymbolLayerCompatible(SymbolType t)
check whether a symbol layer type can be used within the symbol (marker-marker, line-line, fill-fill/line)
QgsMarkerSymbolV2(QgsSymbolLayerV2List layers=QgsSymbolLayerV2List())
Contains information about the context of a rendering operation.
QString readEntry(const QString &scope, const QString &key, const QString &def=QString::null, bool *ok=0) const
void stopRender(QgsRenderContext &context)
bool insertSymbolLayer(int index, QgsSymbolLayerV2 *layer)
insert symbol layer to specified index
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
Definition: qgssymbolv2.cpp:95
virtual QgsSymbolV2 * clone() const
QList< QgsSymbolLayerV2 * > QgsSymbolLayerV2List
Definition: qgssymbolv2.h:38
static QgsProject * instance()
access to canonical QgsProject instance
Definition: qgsproject.cpp:362
QgsRenderContext & mRenderContext
Definition: qgssymbolv2.h:201
QgsSymbolV2::OutputUnit outputUnit() const
Definition: qgssymbolv2.cpp:63
static double lineWidthScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u)
Returns the line width scale factor depending on the unit and the paint device.
QgsSymbolV2RenderContext(QgsRenderContext &c, QgsSymbolV2::OutputUnit u, qreal alpha=1.0, bool selected=false, int renderHints=0, const QgsFeature *f=0, const QgsFields *=0)
virtual QgsSymbolV2 * clone() const
QgsSymbolLayerV2 * takeSymbolLayer(int index)
remove symbol layer from the list and return pointer to it
double outputPixelSize(double size) const
double outputLineWidth(double width) const
QgsSymbolLayerV2 * symbolLayer(int layer)
QString dump() const
void setSize(double size)
void setAngle(double angle)
double size
Definition: qgssvgcache.cpp:77
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
QgsSymbolV2::OutputUnit mOutputUnit
Definition: qgssymbolv2.h:202
void setOutputUnit(QgsSymbolV2::OutputUnit u)
Definition: qgssymbolv2.cpp:86
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
Definition: qgssymbolv2.h:123
QImage bigSymbolPreviewImage()
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
QColor color() const
int mRenderHints
Definition: qgssymbolv2.h:151