32 #include <QDomElement>
33 #include <QDomDocument>
48 wkbPtr +=
sizeof( double );
65 unsigned int wkbType, nPoints;
66 wkbPtr >> wkbType >> nPoints;
78 double cw = e.
width() / 10;
double ch = e.
height() / 10;
84 pts.resize( nPoints );
86 QPointF* ptr = pts.data();
87 for (
unsigned int i = 0; i < nPoints; ++i, ++ptr )
91 wkbPtr +=
sizeof( double );
93 *ptr = QPointF( x, y );
103 QPointF* ptr = pts.data();
104 for (
int i = 0; i < pts.size(); ++i, ++ptr )
116 unsigned int wkbType, numRings;
117 wkbPtr >> wkbType >> numRings;
130 double cw = e.
width() / 10;
double ch = e.
height() / 10;
133 for (
unsigned int idx = 0; idx < numRings; idx++ )
135 unsigned int nPoints;
138 QPolygonF poly( nPoints );
141 QPointF* ptr = poly.data();
142 for (
unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr )
146 wkbPtr +=
sizeof( double );
148 *ptr = QPointF( x, y );
155 QRectF ptsRect = poly.boundingRect();
166 for (
int i = 0; i < poly.size(); ++i, ++ptr )
174 holes.append( poly );
197 : mType( type ), mUsingSymbolLevels( false ),
199 mCurrentVertexMarkerSize( 3 )
217 if ( symbol == NULL )
236 QgsDebugMsg(
"point can be drawn only with marker symbol!" );
241 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
253 QgsDebugMsg(
"linestring can be drawn only with line symbol!" );
258 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
260 if ( drawVertexMarker )
270 QgsDebugMsg(
"polygon can be drawn only with fill symbol!" );
274 QList<QPolygonF> holes;
276 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );
278 if ( drawVertexMarker )
288 QgsDebugMsg(
"multi-point can be drawn only with marker symbol!" );
295 const unsigned char* ptr = wkbPtr;
298 for (
unsigned int i = 0; i < num; ++i )
301 ((
QgsMarkerSymbolV2* )symbol )->renderPoint( pt, &feature, context, layer, selected );
314 QgsDebugMsg(
"multi-linestring can be drawn only with line symbol!" );
321 const unsigned char* ptr = wkbPtr;
324 for (
unsigned int i = 0; i < num; ++i )
327 ((
QgsLineSymbolV2* )symbol )->renderPolyline( pts, &feature, context, layer, selected );
329 if ( drawVertexMarker )
340 QgsDebugMsg(
"multi-polygon can be drawn only with fill symbol!" );
347 const unsigned char* ptr = wkbPtr;
349 QList<QPolygonF> holes;
351 for (
unsigned int i = 0; i < num; ++i )
354 ((
QgsFillSymbolV2* )symbol )->renderPolygon( pts, ( holes.count() ? &holes : NULL ), &feature, context, layer, selected );
356 if ( drawVertexMarker )
363 QgsDebugMsg( QString(
"feature %1: unsupported wkb type 0x%2 for rendering" ).arg( feature.
id() ).arg( geom->
wkbType(), 0, 16 ) );
369 return "UNKNOWN RENDERER\n";
377 if ( element.isNull() )
381 QString rendererType = element.attribute(
"type" );
403 QDomElement element = node.toElement();
404 if ( element.isNull() )
408 QDomElement userStyleElem = element.firstChildElement(
"UserStyle" );
409 if ( userStyleElem.isNull() )
412 errorMessage =
"Info: UserStyle element not found.";
417 QDomElement featTypeStyleElem = userStyleElem.firstChildElement(
"FeatureTypeStyle" );
418 if ( featTypeStyleElem.isNull() )
420 errorMessage =
"Info: FeatureTypeStyle element not found.";
427 bool needRuleRenderer =
false;
430 QDomElement ruleElem = featTypeStyleElem.firstChildElement(
"Rule" );
431 while ( !ruleElem.isNull() )
438 QgsDebugMsg(
"more Rule elements found: need a RuleRenderer" );
439 needRuleRenderer =
true;
443 QDomElement ruleChildElem = ruleElem.firstChildElement();
444 while ( !ruleChildElem.isNull() )
447 if ( ruleChildElem.localName() ==
"Filter" ||
448 ruleChildElem.localName() ==
"MinScaleDenominator" ||
449 ruleChildElem.localName() ==
"MaxScaleDenominator" )
451 QgsDebugMsg(
"Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
452 needRuleRenderer =
true;
456 ruleChildElem = ruleChildElem.nextSiblingElement();
459 if ( needRuleRenderer )
464 ruleElem = ruleElem.nextSiblingElement(
"Rule" );
467 QString rendererType;
468 if ( needRuleRenderer )
470 rendererType =
"RuleRenderer";
474 rendererType =
"singleSymbol";
476 QgsDebugMsg( QString(
"Instantiating a '%1' renderer..." ).arg( rendererType ) );
482 errorMessage = QString(
"Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
497 QDomElement userStyleElem = doc.createElement(
"UserStyle" );
499 QDomElement nameElem = doc.createElement(
"se:Name" );
500 nameElem.appendChild( doc.createTextNode( styleName ) );
501 userStyleElem.appendChild( nameElem );
503 QDomElement featureTypeStyleElem = doc.createElement(
"se:FeatureTypeStyle" );
504 toSld( doc, featureTypeStyleElem );
505 userStyleElem.appendChild( featureTypeStyleElem );
507 return userStyleElem;
512 Q_UNUSED( iconSize );
536 Q_UNUSED( scaleDenominator );
546 for ( QgsLegendSymbolList::const_iterator it = lst.begin(); it != lst.end(); ++it, ++i )
568 foreach ( QPointF pt, pts )
574 foreach ( QPointF pt, pts )
579 foreach ( QPolygonF ring, *rings )
581 foreach ( QPointF pt, ring )
591 if ( s ) lst.append( s );
599 if ( s ) lst.append( s );