22 #include <QDomDocument>
23 #include <QDomElement>
25 #include <QImageReader>
27 #include <QSvgRenderer>
56 int newDpi = ( painter->device()->logicalDpiX() + painter->device()->logicalDpiY() ) / 2;
72 double boundRectWidthMM = boundRect.width() / newDpi * 25.4;
73 double boundRectHeightMM = boundRect.height() / newDpi * 25.4;
76 painter->translate( rect().width() / 2.0, rect().height() / 2.0 );
78 painter->translate( -boundRectWidthMM / 2.0, -boundRectHeightMM / 2.0 );
82 mSVG.render( painter, QRectF( 0, 0, boundRectWidthMM, boundRectHeightMM ) );
86 painter->drawImage( QRectF( 0, 0, boundRectWidthMM, boundRectHeightMM ),
mImage, QRectF( 0, 0,
mImage.width(),
mImage.height() ) );
109 QString sourceFileSuffix = sourceFileInfo.suffix();
110 if ( sourceFileSuffix.compare(
"svg", Qt::CaseInsensitive ) == 0 )
114 if (
mSVG.isValid() )
117 QRect viewBox =
mSVG.viewBox();
129 QImageReader imageReader(
mSourceFile.fileName() );
130 if ( imageReader.read( &
mImage ) )
142 setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), rect().height() ) );
149 double imageToDeviceRatio;
150 if (
mImage.width() / deviceWidth >
mImage.height() / deviceHeight )
152 imageToDeviceRatio = deviceWidth /
mImage.width();
153 double height = imageToDeviceRatio *
mImage.height();
154 return QRectF( 0, 0, deviceWidth, height );
158 imageToDeviceRatio = deviceHeight /
mImage.height();
159 double width = imageToDeviceRatio *
mImage.width();
160 return QRectF( 0, 0, width, deviceHeight );
166 double imageToSvgRatio;
171 return QRectF( 0, 0, width, deviceHeight );
177 return QRectF( 0, 0, deviceWidth, height );
184 double imageToSvgRatio;
189 return QRectF( 0, 0, deviceWidth, height );
195 return QRectF( 0, 0, width, deviceHeight );
205 double newPictureWidth = rectangle.width();
206 double newPictureHeight = rectangle.height();
222 double x = transform().dx() + rect().width() / 2.0 - width / 2.0;
223 double y = transform().dy() + rect().height() / 2.0 - height / 2.0;
236 if ( composerMapId == -1 )
268 QDomElement composerPictureElem = doc.createElement(
"ComposerPicture" );
270 composerPictureElem.setAttribute(
"pictureWidth",
mPictureWidth );
271 composerPictureElem.setAttribute(
"pictureHeight",
mPictureHeight );
274 composerPictureElem.setAttribute(
"mapId", -1 );
282 elem.appendChild( composerPictureElem );
288 if ( itemElem.isNull() )
293 mPictureWidth = itemElem.attribute(
"pictureWidth",
"10" ).toDouble();
294 mPictureHeight = itemElem.attribute(
"pictureHeight",
"10" ).toDouble();
296 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
297 if ( composerItemList.size() > 0 )
299 _readXML( composerItemList.at( 0 ).toElement(), doc );
309 int rotationMapId = itemElem.attribute(
"mapId",
"-1" ).toInt();
310 if ( rotationMapId == -1 )