22 #include <QDomDocument>
23 #include <QDomElement>
25 #include <QImageReader>
27 #include <QSvgRenderer>
48 Q_UNUSED( itemStyle );
65 painter->translate( rect().width() / 2.0, rect().height() / 2.0 );
67 painter->translate( -boundRectWidthMM / 2.0, -boundRectHeightMM / 2.0 );
71 mSVG.render( painter, QRectF( 0, 0, boundRectWidthMM, boundRectHeightMM ) );
75 painter->drawImage( QRectF( 0, 0, boundRectWidthMM, boundRectHeightMM ),
mImage, QRectF( 0, 0,
mImage.width(),
mImage.height() ) );
98 QString sourceFileSuffix = sourceFileInfo.suffix();
99 if ( sourceFileSuffix.compare(
"svg", Qt::CaseInsensitive ) == 0 )
103 if (
mSVG.isValid() )
106 QRect viewBox =
mSVG.viewBox();
118 QImageReader imageReader(
mSourceFile.fileName() );
119 if ( imageReader.read( &
mImage ) )
131 setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
138 double imageToDeviceRatio;
139 if (
mImage.width() / deviceWidth >
mImage.height() / deviceHeight )
141 imageToDeviceRatio = deviceWidth /
mImage.width();
142 double height = imageToDeviceRatio *
mImage.height();
143 return QRectF( 0, 0, deviceWidth, height );
147 imageToDeviceRatio = deviceHeight /
mImage.height();
148 double width = imageToDeviceRatio *
mImage.width();
149 return QRectF( 0, 0, width, deviceHeight );
155 double imageToSvgRatio;
160 return QRectF( 0, 0, width, deviceHeight );
166 return QRectF( 0, 0, deviceWidth, height );
182 return QSizeF( 0, 0 );
189 double imageToSvgRatio;
194 return QRectF( 0, 0, deviceWidth, height );
200 return QRectF( 0, 0, width, deviceHeight );
245 if ( composerMapId == -1 )
261 QObject::connect( map, SIGNAL( mapRotationChanged(
double ) ),
this, SLOT(
setPictureRotation(
double ) ) );
278 QDomElement composerPictureElem = doc.createElement(
"ComposerPicture" );
280 composerPictureElem.setAttribute(
"pictureWidth", QString::number(
mPictureWidth ) );
281 composerPictureElem.setAttribute(
"pictureHeight", QString::number(
mPictureHeight ) );
284 composerPictureElem.setAttribute(
"pictureRotation", QString::number(
mPictureRotation ) );
287 composerPictureElem.setAttribute(
"mapId", -1 );
295 elem.appendChild( composerPictureElem );
301 if ( itemElem.isNull() )
306 mPictureWidth = itemElem.attribute(
"pictureWidth",
"10" ).toDouble();
307 mPictureHeight = itemElem.attribute(
"pictureHeight",
"10" ).toDouble();
309 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
310 if ( composerItemList.size() > 0 )
312 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
314 if ( composerItemElem.attribute(
"rotation",
"0" ).toDouble() != 0 )
317 mPictureRotation = composerItemElem.attribute(
"rotation",
"0" ).toDouble();
329 if ( itemElem.attribute(
"pictureRotation",
"0" ).toDouble() != 0 )
335 int rotationMapId = itemElem.attribute(
"mapId",
"-1" ).toInt();
336 if ( rotationMapId == -1 )
345 QObject::disconnect(
mRotationMap, SIGNAL( mapRotationChanged(
double ) ),
this, SLOT(
setRotation(
double ) ) );