@@ -25,7 +25,8 @@ QgsComposerShape::QgsComposerShape( QgsComposition* composition ): QgsComposerIt
25
25
mShape( Ellipse ),
26
26
mCornerRadius( 0 ),
27
27
mUseSymbolV2( false ), // default to not using SymbolV2 for shapes, to preserve 2.0 api
28
- mShapeStyleSymbol( 0 )
28
+ mShapeStyleSymbol( 0 ),
29
+ mMaxSymbolBleed( 0 )
29
30
{
30
31
setFrameEnabled ( true );
31
32
createDefaultShapeStyleSymbol ();
@@ -36,7 +37,8 @@ QgsComposerShape::QgsComposerShape( qreal x, qreal y, qreal width, qreal height,
36
37
mShape( Ellipse ),
37
38
mCornerRadius( 0 ),
38
39
mUseSymbolV2( false ), // default to not using SymbolV2 for shapes, to preserve 2.0 api
39
- mShapeStyleSymbol( 0 )
40
+ mShapeStyleSymbol( 0 ),
41
+ mMaxSymbolBleed( 0 )
40
42
{
41
43
setSceneRect ( QRectF ( x, y, width, height ) );
42
44
setFrameEnabled ( true );
@@ -58,12 +60,14 @@ void QgsComposerShape::setShapeStyleSymbol( QgsFillSymbolV2* symbol )
58
60
{
59
61
delete mShapeStyleSymbol ;
60
62
mShapeStyleSymbol = symbol;
61
- update ();
62
- emit frameChanged ();
63
+ refreshSymbol ();
63
64
}
64
65
65
66
void QgsComposerShape::refreshSymbol ()
66
67
{
68
+ mMaxSymbolBleed = QgsSymbolLayerV2Utils::estimateMaxSymbolBleed ( mShapeStyleSymbol );
69
+ updateBoundingRect ();
70
+
67
71
update ();
68
72
emit frameChanged ();
69
73
}
@@ -78,6 +82,11 @@ void QgsComposerShape::createDefaultShapeStyleSymbol()
78
82
properties.insert ( " color_border" , " black" );
79
83
properties.insert ( " width_border" , " 0.3" );
80
84
mShapeStyleSymbol = QgsFillSymbolV2::createSimple ( properties );
85
+
86
+ mMaxSymbolBleed = QgsSymbolLayerV2Utils::estimateMaxSymbolBleed ( mShapeStyleSymbol );
87
+ updateBoundingRect ();
88
+
89
+ emit frameChanged ();
81
90
}
82
91
83
92
void QgsComposerShape::paint ( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
@@ -205,13 +214,6 @@ void QgsComposerShape::drawShapeUsingSymbol( QPainter* p )
205
214
206
215
mShapeStyleSymbol ->startRender ( context );
207
216
208
- double maxBleed = QgsSymbolLayerV2Utils::estimateMaxSymbolBleed ( mShapeStyleSymbol );
209
-
210
- // even though we aren't going to use it to draw the shape, set the pen width as 2 * symbol bleed
211
- // so that the item is fully rendered within it's scene rect
212
- // (QGraphicsRectItem considers the pen width when calculating an item's scene rect)
213
- setPen ( QPen ( QBrush ( Qt::NoBrush ), maxBleed * 2.0 ) );
214
-
215
217
// need to render using atlas feature properties?
216
218
if ( mComposition ->atlasComposition ().enabled () && mComposition ->atlasMode () != QgsComposition::AtlasOff )
217
219
{
@@ -253,7 +255,7 @@ void QgsComposerShape::drawBackground( QPainter* p )
253
255
254
256
double QgsComposerShape::estimatedFrameBleed () const
255
257
{
256
- return QgsSymbolLayerV2Utils::estimateMaxSymbolBleed ( mShapeStyleSymbol ) ;
258
+ return mMaxSymbolBleed ;
257
259
}
258
260
259
261
bool QgsComposerShape::writeXML ( QDomElement& elem, QDomDocument & doc ) const
@@ -330,3 +332,19 @@ void QgsComposerShape::setCornerRadius( double radius )
330
332
{
331
333
mCornerRadius = radius;
332
334
}
335
+
336
+ QRectF QgsComposerShape::boundingRect () const
337
+ {
338
+ return mCurrentRectangle ;
339
+ }
340
+
341
+ void QgsComposerShape::updateBoundingRect ()
342
+ {
343
+ QRectF rectangle = rect ();
344
+ rectangle.adjust ( -mMaxSymbolBleed , -mMaxSymbolBleed , mMaxSymbolBleed , mMaxSymbolBleed );
345
+ if ( rectangle != mCurrentRectangle )
346
+ {
347
+ prepareGeometryChange ();
348
+ mCurrentRectangle = rectangle;
349
+ }
350
+ }
0 commit comments