30 , mBlendMode( QPainter::CompositionMode_SourceOver )
34 createDefaultFrameSymbol();
37 QgsComposerMapOverview::QgsComposerMapOverview()
41 , mBlendMode( QPainter::CompositionMode_SourceOver )
47 void QgsComposerMapOverview::createDefaultFrameSymbol()
51 properties.insert(
"color",
"255,0,0,255" );
52 properties.insert(
"style",
"solid" );
53 properties.insert(
"style_border",
"no" );
75 if ( !overviewFrameMap )
86 QPolygonF intersectExtent = thisExtent.intersected( otherExtent );
89 double dotsPerMM = painter->device()->logicalDpiX() / 25.4;
102 painter->setCompositionMode( mBlendMode );
104 painter->scale( 1 / dotsPerMM, 1 / dotsPerMM );
105 painter->setRenderHint( QPainter::Antialiasing );
111 QTransform mapTransform;
112 QPolygonF thisRectPoly = QPolygonF( QRectF( 0, 0, dotsPerMM *
mComposerMap->rect().width(), dotsPerMM *
mComposerMap->rect().height() ) );
115 thisRectPoly.pop_back();
116 thisExtent.pop_back();
119 QTransform::quadToQuad( thisExtent, thisRectPoly, mapTransform );
120 QPolygonF intersectPolygon;
121 intersectPolygon = mapTransform.map( intersectExtent );
123 QList<QPolygonF> rings;
127 mFrameSymbol->
renderPolygon( intersectPolygon, &rings, 0, context );;
133 QPolygonF outerPolygon;
134 outerPolygon << QPointF( 0, 0 )
135 << QPointF(
mComposerMap->rect().width() * dotsPerMM, 0 )
137 << QPointF( 0,
mComposerMap->rect().height() * dotsPerMM )
141 rings.append( intersectPolygon );
142 mFrameSymbol->
renderPolygon( outerPolygon, &rings, 0, context );
157 QDomElement overviewFrameElem = doc.createElement(
"ComposerMapOverview" );
159 overviewFrameElem.setAttribute(
"frameMap", mFrameMapId );
161 overviewFrameElem.setAttribute(
"inverted", mInverted );
162 overviewFrameElem.setAttribute(
"centered", mCentered );
165 overviewFrameElem.appendChild( frameStyleElem );
168 elem.appendChild( overviewFrameElem );
175 if ( itemElem.isNull() )
182 setFrameMap( itemElem.attribute(
"frameMap",
"-1" ).toInt() );
184 mInverted = ( itemElem.attribute(
"inverted",
"0" ) !=
"0" );
185 mCentered = ( itemElem.attribute(
"centered",
"0" ) !=
"0" );
187 QDomElement frameStyleElem = itemElem.firstChildElement(
"symbol" );
188 if ( !frameStyleElem.isNull() )
191 mFrameSymbol = QgsSymbolLayerV2Utils::loadSymbol<QgsFillSymbolV2>( frameStyleElem );
198 return mBlendMode != QPainter::CompositionMode_SourceOver;
203 if ( mFrameMapId == mapId )
243 mFrameSymbol = symbol;
275 if ( !overviewFrameMap )
285 center.
y() - extent.
height() / 2,
365 QList< QgsComposerMapOverview* > list;
366 QList< QgsComposerMapItem* >::const_iterator it =
mItems.begin();
367 for ( ; it !=
mItems.end(); ++it )
372 list.append( overview );
383 QDomNodeList mapOverviewNodeList = elem.elementsByTagName(
"ComposerMapOverview" );
384 for (
int i = 0; i < mapOverviewNodeList.size(); ++i )
386 QDomElement mapOverviewElem = mapOverviewNodeList.at( i ).toElement();
388 mapOverview->
readXML( mapOverviewElem, doc );
389 mItems.append( mapOverview );