22 #include <QDomElement>
26 : placement( AroundPoint )
27 , placementFlags( OnLine )
51 priority = elem.attribute(
"priority" ).toInt();
52 obstacle = elem.attribute(
"obstacle" ).toInt();
53 dist = elem.attribute(
"dist" ).toDouble();
54 xPosColumn = elem.attribute(
"xPosColumn" ).toInt();
55 yPosColumn = elem.attribute(
"yPosColumn" ).toInt();
62 QDomElement diagramLayerElem = doc.createElement(
"DiagramLayerSettings" );
63 diagramLayerElem.setAttribute(
"placement",
placement );
64 diagramLayerElem.setAttribute(
"linePlacementFlags",
placementFlags );
65 diagramLayerElem.setAttribute(
"priority",
priority );
66 diagramLayerElem.setAttribute(
"obstacle",
obstacle );
67 diagramLayerElem.setAttribute(
"dist", QString::number(
dist ) );
68 diagramLayerElem.setAttribute(
"xPosColumn",
xPosColumn );
69 diagramLayerElem.setAttribute(
"yPosColumn",
yPosColumn );
70 layerElem.appendChild( diagramLayerElem );
77 font.fromString( elem.attribute(
"font" ) );
79 backgroundColor.setAlpha( elem.attribute(
"backgroundAlpha" ).toInt() );
80 size.setWidth( elem.attribute(
"width" ).toDouble() );
81 size.setHeight( elem.attribute(
"height" ).toDouble() );
82 transparency = elem.attribute(
"transparency",
"0" ).toInt();
83 penColor.setNamedColor( elem.attribute(
"penColor" ) );
84 int penAlpha = elem.attribute(
"penAlpha",
"255" ).toInt();
86 penWidth = elem.attribute(
"penWidth" ).toDouble();
92 if ( elem.attribute(
"sizeType" ) ==
"MM" )
102 if ( elem.attribute(
"labelPlacementMethod" ) ==
"Height" )
112 if ( elem.attribute(
"diagramOrientation" ) ==
"Left" )
116 else if ( elem.attribute(
"diagramOrientation" ) ==
"Right" )
120 else if ( elem.attribute(
"diagramOrientation" ) ==
"Down" )
130 if ( elem.attribute(
"scaleDependency" ) ==
"Diameter" )
139 barWidth = elem.attribute(
"barWidth" ).toDouble();
141 angleOffset = elem.attribute(
"angleOffset" ).toInt();
143 minimumSize = elem.attribute(
"minimumSize" ).toDouble();
147 QDomNodeList attributes = elem.elementsByTagName(
"attribute" );
149 if ( attributes.length() > 0 )
151 for ( uint i = 0; i < attributes.length(); i++ )
153 QDomElement attrElem = attributes.at( i ).toElement();
154 QColor newColor( attrElem.attribute(
"color" ) );
164 QStringList colorList = elem.attribute(
"colors" ).split(
"/" );
165 QStringList::const_iterator colorIt = colorList.constBegin();
166 for ( ; colorIt != colorList.constEnd(); ++colorIt )
168 QColor newColor( *colorIt );
175 QStringList catList = elem.attribute(
"categories" ).split(
"/" );
176 QStringList::const_iterator catIt = catList.constBegin();
177 for ( ; catIt != catList.constEnd(); ++catIt )
188 QDomElement categoryElem = doc.createElement(
"DiagramCategory" );
189 categoryElem.setAttribute(
"font",
font.toString() );
190 categoryElem.setAttribute(
"backgroundColor",
backgroundColor.name() );
191 categoryElem.setAttribute(
"backgroundAlpha",
backgroundColor.alpha() );
192 categoryElem.setAttribute(
"width", QString::number(
size.width() ) );
193 categoryElem.setAttribute(
"height", QString::number(
size.height() ) );
194 categoryElem.setAttribute(
"penColor",
penColor.name() );
195 categoryElem.setAttribute(
"penAlpha",
penColor.alpha() );
196 categoryElem.setAttribute(
"penWidth", QString::number(
penWidth ) );
197 categoryElem.setAttribute(
"minScaleDenominator", QString::number(
minScaleDenominator ) );
198 categoryElem.setAttribute(
"maxScaleDenominator", QString::number(
maxScaleDenominator ) );
199 categoryElem.setAttribute(
"transparency", QString::number(
transparency ) );
204 categoryElem.setAttribute(
"sizeType",
"MM" );
208 categoryElem.setAttribute(
"sizeType",
"MapUnits" );
214 categoryElem.setAttribute(
"labelPlacementMethod",
"Height" );
218 categoryElem.setAttribute(
"labelPlacementMethod",
"XHeight" );
223 categoryElem.setAttribute(
"scaleDependency",
"Area" );
227 categoryElem.setAttribute(
"scaleDependency",
"Diameter" );
234 categoryElem.setAttribute(
"diagramOrientation",
"Left" );
238 categoryElem.setAttribute(
"diagramOrientation",
"Right" );
242 categoryElem.setAttribute(
"diagramOrientation",
"Down" );
246 categoryElem.setAttribute(
"diagramOrientation",
"Up" );
250 categoryElem.setAttribute(
"diagramOrientation",
"Up" );
254 categoryElem.setAttribute(
"barWidth", QString::number(
barWidth ) );
255 categoryElem.setAttribute(
"minimumSize", QString::number(
minimumSize ) );
256 categoryElem.setAttribute(
"angleOffset", QString::number(
angleOffset ) );
260 for (
int i = 0; i < nCats; ++i )
262 QDomElement attributeElem = doc.createElement(
"attribute" );
265 attributeElem.setAttribute(
"color",
categoryColors.at( i ).name() );
266 categoryElem.appendChild( attributeElem );
269 rendererElem.appendChild( categoryElem );
289 : mDiagram( other.mDiagram ? other.mDiagram->clone() : 0 )
327 if ( !size.isValid() )
333 size.rwidth() *= pixelToMap;
334 size.rheight() *= pixelToMap;
341 QPaintDevice* device = painter->device();
344 return device->logicalDpiX();
355 QString diagramType = elem.attribute(
"diagramType" );
356 if ( diagramType ==
"Pie" )
360 else if ( diagramType ==
"Text" )
364 else if ( diagramType ==
"Histogram" )
412 QList<QgsDiagramSettings> settingsList;
413 settingsList.push_back( mSettings );
419 QDomElement categoryElem = elem.firstChildElement(
"DiagramCategory" );
420 if ( categoryElem.isNull() )
425 mSettings.
readXML( categoryElem, layer );
431 QDomElement rendererElem = doc.createElement(
"SingleCategoryDiagramRenderer" );
432 mSettings.
writeXML( rendererElem, doc, layer );
434 layerElem.appendChild( rendererElem );
454 QList<QgsDiagramSettings> settingsList;
455 settingsList.push_back( mSettings );
478 mInterpolationSettings.
lowerValue = elem.attribute(
"lowerValue" ).toDouble();
479 mInterpolationSettings.
upperValue = elem.attribute(
"upperValue" ).toDouble();
480 mInterpolationSettings.
lowerSize.setWidth( elem.attribute(
"lowerWidth" ).toDouble() );
481 mInterpolationSettings.
lowerSize.setHeight( elem.attribute(
"lowerHeight" ).toDouble() );
482 mInterpolationSettings.
upperSize.setWidth( elem.attribute(
"upperWidth" ).toDouble() );
483 mInterpolationSettings.
upperSize.setHeight( elem.attribute(
"upperHeight" ).toDouble() );
493 QDomElement settingsElem = elem.firstChildElement(
"DiagramCategory" );
494 if ( !settingsElem.isNull() )
496 mSettings.
readXML( settingsElem, layer );
503 QDomElement rendererElem = doc.createElement(
"LinearlyInterpolatedDiagramRenderer" );
504 rendererElem.setAttribute(
"lowerValue", QString::number( mInterpolationSettings.
lowerValue ) );
505 rendererElem.setAttribute(
"upperValue", QString::number( mInterpolationSettings.
upperValue ) );
506 rendererElem.setAttribute(
"lowerWidth", QString::number( mInterpolationSettings.
lowerSize.width() ) );
507 rendererElem.setAttribute(
"lowerHeight", QString::number( mInterpolationSettings.
lowerSize.height() ) );
508 rendererElem.setAttribute(
"upperWidth", QString::number( mInterpolationSettings.
upperSize.width() ) );
509 rendererElem.setAttribute(
"upperHeight", QString::number( mInterpolationSettings.
upperSize.height() ) );
518 mSettings.
writeXML( rendererElem, doc, layer );
520 layerElem.appendChild( rendererElem );