QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsellipsesymbollayerv2.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsellipsesymbollayerv2.cpp
3  ---------------------
4  begin : June 2011
5  copyright : (C) 2011 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
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  ***************************************************************************/
16 #include "qgsdxfexport.h"
17 #include "qgsexpression.h"
18 #include "qgsfeature.h"
19 #include "qgsrendercontext.h"
20 #include "qgsvectorlayer.h"
21 #include "qgslogger.h"
22 
23 #include <QPainter>
24 #include <QSet>
25 #include <QDomDocument>
26 #include <QDomElement>
27 
28 QgsEllipseSymbolLayerV2::QgsEllipseSymbolLayerV2(): mSymbolName( "circle" ), mSymbolWidth( 4 ), mSymbolWidthUnit( QgsSymbolV2::MM ), mSymbolHeight( 3 ),
29  mSymbolHeightUnit( QgsSymbolV2::MM ), mFillColor( Qt::white ), mOutlineColor( Qt::black ), mOutlineStyle( Qt::SolidLine ), mOutlineWidth( 0 ), mOutlineWidthUnit( QgsSymbolV2::MM )
30 {
31  mPen.setColor( mOutlineColor );
32  mPen.setStyle( mOutlineStyle );
33  mPen.setWidth( 1.0 );
34  mPen.setJoinStyle( Qt::MiterJoin );
35  mBrush.setColor( mFillColor );
36  mBrush.setStyle( Qt::SolidPattern );
37  mOffset = QPointF( 0, 0 );
38 
39  mAngle = 0;
40 }
41 
43 {
44 }
45 
47 {
49  if ( properties.contains( "symbol_name" ) )
50  {
51  layer->setSymbolName( properties[ "symbol_name" ] );
52  }
53  if ( properties.contains( "symbol_width" ) )
54  {
55  layer->setSymbolWidth( properties["symbol_width"].toDouble() );
56  }
57  if ( properties.contains( "symbol_width_unit" ) )
58  {
59  layer->setSymbolWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_width_unit"] ) );
60  }
61  if ( properties.contains( "symbol_height" ) )
62  {
63  layer->setSymbolHeight( properties["symbol_height"].toDouble() );
64  }
65  if ( properties.contains( "symbol_height_unit" ) )
66  {
67  layer->setSymbolHeightUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_height_unit"] ) );
68  }
69  if ( properties.contains( "angle" ) )
70  {
71  layer->setAngle( properties["angle"].toDouble() );
72  }
73  if ( properties.contains( "outline_style" ) )
74  {
75  layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["outline_style"] ) );
76  }
77  if ( properties.contains( "outline_width" ) )
78  {
79  layer->setOutlineWidth( properties["outline_width"].toDouble() );
80  }
81  if ( properties.contains( "outline_width_unit" ) )
82  {
83  layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) );
84  }
85  if ( properties.contains( "fill_color" ) )
86  {
87  layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["fill_color"] ) );
88  }
89  if ( properties.contains( "outline_color" ) )
90  {
91  layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["outline_color"] ) );
92  }
93  if ( properties.contains( "offset" ) )
94  {
95  layer->setOffset( QgsSymbolLayerV2Utils::decodePoint( properties["offset"] ) );
96  }
97  if ( properties.contains( "offset_unit" ) )
98  {
99  layer->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["offset_unit"] ) );
100  }
101  if ( properties.contains( "horizontal_anchor_point" ) )
102  {
103  layer->setHorizontalAnchorPoint( QgsMarkerSymbolLayerV2::HorizontalAnchorPoint( properties[ "horizontal_anchor_point" ].toInt() ) );
104  }
105  if ( properties.contains( "vertical_anchor_point" ) )
106  {
107  layer->setVerticalAnchorPoint( QgsMarkerSymbolLayerV2::VerticalAnchorPoint( properties[ "vertical_anchor_point" ].toInt() ) );
108  }
109 
110  //data defined properties
111  if ( properties.contains( "width_expression" ) )
112  {
113  layer->setDataDefinedProperty( "width", properties["width_expression"] );
114  }
115  if ( properties.contains( "height_expression" ) )
116  {
117  layer->setDataDefinedProperty( "height", properties["height_expression"] );
118  }
119  if ( properties.contains( "rotation_expression" ) )
120  {
121  layer->setDataDefinedProperty( "rotation", properties["rotation_expression"] );
122  }
123  if ( properties.contains( "outline_width_expression" ) )
124  {
125  layer->setDataDefinedProperty( "outline_width", properties[ "outline_width_expression" ] );
126  }
127  if ( properties.contains( "fill_color_expression" ) )
128  {
129  layer->setDataDefinedProperty( "fill_color", properties["fill_color_expression"] );
130  }
131  if ( properties.contains( "outline_color_expression" ) )
132  {
133  layer->setDataDefinedProperty( "outline_color", properties["outline_color_expression"] );
134  }
135  if ( properties.contains( "symbol_name_expression" ) )
136  {
137  layer->setDataDefinedProperty( "symbol_name", properties["symbol_name_expression"] );
138  }
139  if ( properties.contains( "offset_expression" ) )
140  {
141  layer->setDataDefinedProperty( "offset", properties["offset_expression"] );
142  }
143  if ( properties.contains( "horizontal_anchor_point_expression" ) )
144  {
145  layer->setDataDefinedProperty( "horizontal_anchor_point", properties[ "horizontal_anchor_point_expression" ] );
146  }
147  if ( properties.contains( "vertical_anchor_point_expression" ) )
148  {
149  layer->setDataDefinedProperty( "vertical_anchor_point", properties[ "vertical_anchor_point_expression" ] );
150  }
151 
152  //compatibility with old project file format
153  if ( !properties["width_field"].isEmpty() )
154  {
155  layer->setDataDefinedProperty( "width", properties["width_field"] );
156  }
157  if ( !properties["height_field"].isEmpty() )
158  {
159  layer->setDataDefinedProperty( "height", properties["height_field"] );
160  }
161  if ( !properties["rotation_field"].isEmpty() )
162  {
163  layer->setDataDefinedProperty( "rotation", properties["rotation_field"] );
164  }
165  if ( !properties["outline_width_field"].isEmpty() )
166  {
167  layer->setDataDefinedProperty( "outline_width", properties[ "outline_width_field" ] );
168  }
169  if ( !properties["fill_color_field"].isEmpty() )
170  {
171  layer->setDataDefinedProperty( "fill_color", properties["fill_color_field"] );
172  }
173  if ( !properties["outline_color_field"].isEmpty() )
174  {
175  layer->setDataDefinedProperty( "outline_color", properties["outline_color_field"] );
176  }
177  if ( !properties["symbol_name_field"].isEmpty() )
178  {
179  layer->setDataDefinedProperty( "symbol_name", properties["symbol_name_field"] );
180  }
181 
182  return layer;
183 }
184 
186 {
187  QgsExpression* outlineWidthExpression = expression( "outline_width" );
188  QgsExpression* fillColorExpression = expression( "fill_color" );
189  QgsExpression* outlineColorExpression = expression( "outline_color" );
190  QgsExpression* widthExpression = expression( "width" );
191  QgsExpression* heightExpression = expression( "height" );
192  QgsExpression* symbolNameExpression = expression( "symbol_name" );
193  QgsExpression* rotationExpression = expression( "rotation" );
194 
195  if ( outlineWidthExpression )
196  {
197  double width = outlineWidthExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
199  mPen.setWidthF( width );
200  }
201  if ( fillColorExpression )
202  {
203  QString colorString = fillColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
204  mBrush.setColor( QColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ) );
205  }
206  if ( outlineColorExpression )
207  {
208  QString colorString = outlineColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
209  mPen.setColor( QColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ) );
210  }
211  if ( widthExpression || heightExpression || symbolNameExpression )
212  {
213  QString symbolName = mSymbolName;
214  if ( symbolNameExpression )
215  {
216  symbolName = symbolNameExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
217  }
218  preparePath( symbolName, context, context.feature() );
219  }
220 
221  //offset
222  double offsetX = 0;
223  double offsetY = 0;
225  QPointF off( offsetX, offsetY );
226 
227  QPainter* p = context.renderContext().painter();
228  if ( !p )
229  {
230  return;
231  }
232 
233  //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
234  double rotation = 0.0;
235  if ( rotationExpression )
236  {
237  rotation = rotationExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
238  }
239  else if ( !qgsDoubleNear( mAngle, 0.0 ) )
240  {
241  rotation = mAngle;
242  }
243  if ( rotation )
244  off = _rotatedOffset( off, rotation );
245 
246  QMatrix transform;
247  transform.translate( point.x() + off.x(), point.y() + off.y() );
248  if ( !qgsDoubleNear( rotation, 0.0 ) )
249  {
250  transform.rotate( rotation );
251  }
252 
253  p->setPen( mPen );
254  p->setBrush( mBrush );
255  p->drawPath( transform.map( mPainterPath ) );
256 }
257 
259 {
260  return "EllipseMarker";
261 }
262 
264 {
265  if ( !context.feature() || !hasDataDefinedProperty() )
266  {
267  preparePath( mSymbolName, context );
268  }
269  mPen.setColor( mOutlineColor );
270  mPen.setStyle( mOutlineStyle );
272  mBrush.setColor( mFillColor );
273  prepareExpressions( context.layer(), context.renderContext().rendererScale() );
274 }
275 
277 {
278 }
279 
281 {
283 }
284 
285 void QgsEllipseSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
286 {
287  QDomElement symbolizerElem = doc.createElement( "se:PointSymbolizer" );
288  if ( !props.value( "uom", "" ).isEmpty() )
289  symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) );
290  element.appendChild( symbolizerElem );
291 
292  // <Geometry>
293  QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) );
294 
295  writeSldMarker( doc, symbolizerElem, props );
296 }
297 
298 void QgsEllipseSymbolLayerV2::writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
299 {
300  // <Graphic>
301  QDomElement graphicElem = doc.createElement( "se:Graphic" );
302  element.appendChild( graphicElem );
303 
305 
306  // store w/h factor in a <VendorOption>
307  double widthHeightFactor = mSymbolWidth / mSymbolHeight;
308  QDomElement factorElem = QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "widthHeightFactor", QString::number( widthHeightFactor ) );
309  graphicElem.appendChild( factorElem );
310 
311  // <Rotation>
312  const QgsExpression* rotationExpression = dataDefinedProperty( "rotation" );
313  QString angleFunc = props.value( "angle", "" );
314  if ( angleFunc.isEmpty() ) // symbol has no angle set
315  {
316 
317  if ( rotationExpression )
318  angleFunc = rotationExpression->expression();
319  else if ( !qgsDoubleNear( mAngle, 0.0 ) )
320  angleFunc = QString::number( mAngle );
321  }
322  else if ( rotationExpression )
323  {
324  // the symbol has an angle and the symbol layer have a rotation
325  // property set
326  angleFunc = QString( "%1 + %2" ).arg( angleFunc ).arg( rotationExpression->expression() );
327  }
328  else if ( !qgsDoubleNear( mAngle, 0.0 ) )
329  {
330  // both the symbol and the symbol layer have angle value set
331  bool ok;
332  double angle = angleFunc.toDouble( &ok );
333  if ( !ok )
334  {
335  // its a string (probably a property name or a function)
336  angleFunc = QString( "%1 + %2" ).arg( angleFunc ).arg( mAngle );
337  }
338  else if ( !qgsDoubleNear( angle + mAngle, 0.0 ) )
339  {
340  // it's a double value
341  angleFunc = QString::number( angle + mAngle );
342  }
343  }
344  QgsSymbolLayerV2Utils::createRotationElement( doc, graphicElem, angleFunc );
345 }
346 
348 {
349  QgsDebugMsg( "Entered." );
350 
351  QDomElement graphicElem = element.firstChildElement( "Graphic" );
352  if ( graphicElem.isNull() )
353  return NULL;
354 
355  QString name = "circle";
356  QColor fillColor, borderColor;
357  double borderWidth, size;
358  double widthHeightFactor = 1.0;
359  Qt::PenStyle borderStyle;
360 
361  QgsStringMap vendorOptions = QgsSymbolLayerV2Utils::getVendorOptionList( graphicElem );
362  for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
363  {
364  if ( it.key() == "widthHeightFactor" )
365  {
366  bool ok;
367  double v = it.value().toDouble( &ok );
368  if ( ok && !qgsDoubleNear( v, 0.0 ) && v > 0 )
369  widthHeightFactor = v;
370  }
371  }
372 
373  if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderStyle, borderWidth, size ) )
374  return NULL;
375 
376  double angle = 0.0;
377  QString angleFunc;
378  if ( QgsSymbolLayerV2Utils::rotationFromSldElement( graphicElem, angleFunc ) )
379  {
380  bool ok;
381  double d = angleFunc.toDouble( &ok );
382  if ( ok )
383  angle = d;
384  }
385 
387  m->setSymbolName( name );
388  m->setFillColor( fillColor );
389  m->setOutlineColor( borderColor );
390  m->setOutlineStyle( borderStyle );
391  m->setOutlineWidth( borderWidth );
392  m->setSymbolWidth( size );
393  m->setSymbolHeight( size / widthHeightFactor );
394  m->setAngle( angle );
395  return m;
396 }
397 
399 {
400  QgsStringMap map;
401  map["symbol_name"] = mSymbolName;
402  map["symbol_width"] = QString::number( mSymbolWidth );
403  map["symbol_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSymbolWidthUnit );
404  map["symbol_height"] = QString::number( mSymbolHeight );
405  map["symbol_height_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSymbolHeightUnit );
406  map["angle"] = QString::number( mAngle );
407  map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mOutlineStyle );
408  map["outline_width"] = QString::number( mOutlineWidth );
409  map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
410  map["fill_color"] = QgsSymbolLayerV2Utils::encodeColor( mFillColor );
411  map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor );
412  map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
414  map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint );
415  map["vertical_anchor_point"] = QString::number( mVerticalAnchorPoint );
417  return map;
418 }
419 
421 {
422  return ( dataDefinedProperty( "width" ) || dataDefinedProperty( "height" ) || dataDefinedProperty( "rotation" )
423  || dataDefinedProperty( "outline_width" ) || dataDefinedProperty( "fill_color" ) || dataDefinedProperty( "outline_color" )
424  || dataDefinedProperty( "symbol_name" ) || dataDefinedProperty( "offset" ) );
425 }
426 
427 void QgsEllipseSymbolLayerV2::preparePath( const QString& symbolName, QgsSymbolV2RenderContext& context, const QgsFeature* f )
428 {
429  mPainterPath = QPainterPath();
430  const QgsRenderContext& ct = context.renderContext();
431 
432  double width = 0;
433 
434  QgsExpression* widthExpression = expression( "width" );
435  if ( widthExpression ) //1. priority: data defined setting on symbol layer level
436  {
437  width = widthExpression->evaluate( const_cast<QgsFeature*>( f ) ).toDouble();
438  }
439  else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
440  {
441  width = mSize;
442  }
443  else //3. priority: global width setting
444  {
445  width = mSymbolWidth;
446  }
448 
449  double height = 0;
450  QgsExpression* heightExpression = expression( "height" );
451  if ( heightExpression ) //1. priority: data defined setting on symbol layer level
452  {
453  height = heightExpression->evaluate( const_cast<QgsFeature*>( f ) ).toDouble();
454  }
455  else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
456  {
457  height = mSize;
458  }
459  else //3. priority: global height setting
460  {
461  height = mSymbolHeight;
462  }
464 
465  if ( symbolName == "circle" )
466  {
467  mPainterPath.addEllipse( QRectF( -width / 2.0, -height / 2.0, width, height ) );
468  }
469  else if ( symbolName == "rectangle" )
470  {
471  mPainterPath.addRect( QRectF( -width / 2.0, -height / 2.0, width, height ) );
472  }
473  else if ( symbolName == "cross" )
474  {
475  mPainterPath.moveTo( 0, -height / 2.0 );
476  mPainterPath.lineTo( 0, height / 2.0 );
477  mPainterPath.moveTo( -width / 2.0, 0 );
478  mPainterPath.lineTo( width / 2.0, 0 );
479  }
480  else if ( symbolName == "triangle" )
481  {
482  mPainterPath.moveTo( 0, -height / 2.0 );
483  mPainterPath.lineTo( -width / 2.0, height / 2.0 );
484  mPainterPath.lineTo( width / 2.0, height / 2.0 );
485  mPainterPath.lineTo( 0, -height / 2.0 );
486  }
487 }
488 
490 {
491  mSymbolWidthUnit = unit;
492  mSymbolHeightUnit = unit;
493  mOutlineWidthUnit = unit;
494 }
495 
497 {
499  if ( mSymbolHeightUnit != unit || mOutlineWidthUnit != unit )
500  {
501  return QgsSymbolV2::Mixed;
502  }
503  return unit;
504 }
505 
506 bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift ) const
507 {
508  //width
509  double symbolWidth = mSymbolWidth;
510  QgsExpression* widthExpression = expression( "width" );
511  if ( widthExpression ) //1. priority: data defined setting on symbol layer level
512  {
513  symbolWidth = widthExpression->evaluate( const_cast<QgsFeature*>( f ) ).toDouble();
514  }
515  else if ( context->renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
516  {
517  symbolWidth = mSize;
518  }
520  {
521  symbolWidth *= mmMapUnitScaleFactor;
522  }
523 
524  //height
525  double symbolHeight = mSymbolHeight;
526  QgsExpression* heightExpression = expression( "height" );
527  if ( heightExpression ) //1. priority: data defined setting on symbol layer level
528  {
529  symbolHeight = heightExpression->evaluate( const_cast<QgsFeature*>( f ) ).toDouble();
530  }
531  else if ( context->renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
532  {
533  symbolHeight = mSize;
534  }
536  {
537  symbolHeight *= mmMapUnitScaleFactor;
538  }
539 
540  //outline width
541  double outlineWidth = mOutlineWidth;
542  QgsExpression* outlineWidthExpression = expression( "outline_width" );
543  if ( outlineWidthExpression )
544  {
545  outlineWidth = outlineWidthExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toDouble();
546  }
548  {
549  outlineWidth *= outlineWidth;
550  }
551 
552  //color
553  QColor c = mFillColor;
554  QgsExpression* fillColorExpression = expression( "fill_color" );
555  if ( fillColorExpression )
556  {
557  c = QColor( fillColorExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toString() );
558  }
559  int colorIndex = e.closestColorMatch( c.rgb() );
560 
561  //symbol name
562  QString symbolName = mSymbolName;
563  QgsExpression* symbolNameExpression = expression( "symbol_name" );
564  if ( symbolNameExpression )
565  {
566  QgsExpression* symbolNameExpression = expression( "symbol_name" );
567  symbolName = symbolNameExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toString();
568  }
569 
570  //offset
571  double offsetX = 0;
572  double offsetY = 0;
573  markerOffset( *context, offsetX, offsetY );
574  QPointF off( offsetX, offsetY );
575 
576  //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
577  double rotation = 0.0;
578  QgsExpression* rotationExpression = expression( "rotation" );
579  if ( rotationExpression )
580  {
581  rotation = rotationExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toDouble();
582  }
583  else if ( !qgsDoubleNear( mAngle, 0.0 ) )
584  {
585  rotation = mAngle;
586  }
587  rotation = -rotation; //rotation in Qt is counterclockwise
588  if ( rotation )
589  off = _rotatedOffset( off, rotation );
590 
591  QTransform t;
592  t.translate( shift.x() + offsetX, shift.y() + offsetY );
593 
594  if ( rotation != 0 )
595  t.rotate( rotation );
596 
597  double halfWidth = symbolWidth / 2.0;
598  double halfHeight = symbolHeight / 2.0;
599 
600  if ( symbolName == "circle" )
601  {
602  //soon...
603  }
604  else if ( symbolName == "rectangle" )
605  {
606  QPointF pt1( t.map( QPointF( -halfWidth, -halfHeight ) ) );
607  QPointF pt2( t.map( QPointF( halfWidth, -halfHeight ) ) );
608  QPointF pt3( t.map( QPointF( -halfWidth, halfHeight ) ) );
609  QPointF pt4( t.map( QPointF( halfWidth, halfHeight ) ) );
610  e.writeSolid( layerName, colorIndex, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
611  return true;
612  }
613  else if ( symbolName == "cross" )
614  {
615  QgsPolyline line1( 2 );
616  QPointF pt1( t.map( QPointF( -halfWidth, 0 ) ) );
617  QPointF pt2( t.map( QPointF( halfWidth, 0 ) ) );
618  line1[0] = QgsPoint( pt1.x(), pt1.y() );
619  line1[1] = QgsPoint( pt2.x(), pt2.y() );
620  e.writePolyline( line1, layerName, "CONTINUOUS", colorIndex, outlineWidth, false );
621  QgsPolyline line2( 2 );
622  QPointF pt3( t.map( QPointF( 0, halfHeight ) ) );
623  // QPointF pt4( t.map( QPointF( 0, -halfHeight ) ) );
624  line2[0] = QgsPoint( pt3.x(), pt3.y() );
625  line2[1] = QgsPoint( pt3.x(), pt3.y() );
626  e.writePolyline( line2, layerName, "CONTINUOUS", colorIndex, outlineWidth, false );
627  return true;
628  }
629  else if ( symbolName == "triangle" )
630  {
631  QPointF pt1( t.map( QPointF( -halfWidth, -halfHeight ) ) );
632  QPointF pt2( t.map( QPointF( halfWidth, -halfHeight ) ) );
633  QPointF pt3( t.map( QPointF( 0, halfHeight ) ) );
634  QPointF pt4( t.map( QPointF( 0, halfHeight ) ) );
635  e.writeSolid( layerName, colorIndex, QgsPoint( pt1.x(), pt1.y() ), QgsPoint( pt2.x(), pt2.y() ), QgsPoint( pt3.x(), pt3.y() ), QgsPoint( pt4.x(), pt4.y() ) );
636  return true;
637  }
638 
639  return false; //soon...
640 }