25 #include <QDomDocument>
26 #include <QDomElement>
27 #include <QFontMetricsF>
50 painter->setPen( QPen( QColor( 0, 0, 0 ) ) );
124 mPen = QPen( QColor( 0, 0, 0 ) );
125 mPen.setWidthF( 1.0 );
127 mBrush.setColor( QColor( 0, 0, 0 ) );
128 mBrush.setStyle( Qt::SolidPattern );
130 mFont.setPointSizeF( 12.0 );
143 double proposedScaleBarLength = composerMapRect.
width() / 4;
144 int powerOf10 = int ( pow( 10.0,
int ( log( proposedScaleBarLength ) / log( 10.0 ) ) ) );
145 int nPow10 = proposedScaleBarLength / powerOf10;
179 posWidthList.clear();
185 posWidthList.push_back( qMakePair( mCurrentXCoord,
mSegmentMillimeters / mNumSegmentsLeft ) );
203 if ( styleName ==
"Single Box" )
207 else if ( styleName ==
"Double Box" )
211 else if ( styleName ==
"Line Ticks Middle" || styleName ==
"Line Ticks Down" || styleName ==
"Line Ticks Up" )
214 if ( styleName ==
"Line Ticks Middle" )
218 else if ( styleName ==
"Line Ticks Down" )
222 else if ( styleName ==
"Line Ticks Up" )
228 else if ( styleName ==
"Numeric" )
277 QDomElement composerScaleBarElem = doc.createElement(
"ComposerScaleBar" );
278 composerScaleBarElem.setAttribute(
"height",
mHeight );
279 composerScaleBarElem.setAttribute(
"labelBarSpace",
mLabelBarSpace );
281 composerScaleBarElem.setAttribute(
"numSegments",
mNumSegments );
286 composerScaleBarElem.setAttribute(
"font",
mFont.toString() );
287 composerScaleBarElem.setAttribute(
"outlineWidth",
mPen.widthF() );
288 composerScaleBarElem.setAttribute(
"unitLabel",
mUnitLabeling );
293 composerScaleBarElem.setAttribute(
"style",
mStyle->
name() );
303 QColor brushColor =
mBrush.color();
304 QDomElement colorElem = doc.createElement(
"BrushColor" );
305 colorElem.setAttribute(
"red", brushColor.red() );
306 colorElem.setAttribute(
"green", brushColor.green() );
307 colorElem.setAttribute(
"blue", brushColor.blue() );
308 composerScaleBarElem.appendChild( colorElem );
310 elem.appendChild( composerScaleBarElem );
311 return _writeXML( composerScaleBarElem, doc );
316 if ( itemElem.isNull() )
321 mHeight = itemElem.attribute(
"height",
"5.0" ).toDouble();
322 mLabelBarSpace = itemElem.attribute(
"labelBarSpace",
"3.0" ).toDouble();
323 mBoxContentSpace = itemElem.attribute(
"boxContentSpace",
"1.0" ).toDouble();
324 mNumSegments = itemElem.attribute(
"numSegments",
"2" ).toInt();
329 mPen.setWidthF( itemElem.attribute(
"outlineWidth",
"1.0" ).toDouble() );
331 QString fontString = itemElem.attribute(
"font",
"" );
332 if ( !fontString.isEmpty() )
334 mFont.fromString( fontString );
340 QString styleString = itemElem.attribute(
"style",
"" );
341 setStyle( tr( styleString.toLocal8Bit().data() ) );
344 int mapId = itemElem.attribute(
"mapId",
"-1" ).toInt();
359 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
360 if ( composerItemList.size() > 0 )
362 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();