27 mUseSymbolV2( false ),
28 mShapeStyleSymbol( 0 )
38 mUseSymbolV2( false ),
39 mShapeStyleSymbol( 0 )
75 properties.insert(
"color",
"white" );
76 properties.insert(
"style",
"solid" );
77 properties.insert(
"style_border",
"solid" );
78 properties.insert(
"color_border",
"black" );
79 properties.insert(
"width_border",
"0.3" );
85 Q_UNUSED( itemStyle );
111 p->setRenderHint( QPainter::Antialiasing );
116 p->drawEllipse( QRectF( 0, 0 , rect().width(), rect().height() ) );
126 p->drawRect( QRectF( 0, 0 , rect().width(), rect().height() ) );
131 triangle << QPointF( 0, rect().height() );
132 triangle << QPointF( rect().width() , rect().height() );
133 triangle << QPointF( rect().width() / 2.0, 0 );
134 p->drawPolygon( triangle );
143 p->setRenderHint( QPainter::Antialiasing );
158 QList<QPolygonF> rings;
159 QPolygonF shapePolygon;
163 QTransform t = QTransform::fromScale( 100, 100 );
165 QTransform ti = t.inverted();
172 QPainterPath ellipsePath;
173 ellipsePath.addEllipse( QRectF( 0, 0 , rect().width(), rect().height() ) );
174 QPolygonF ellipsePoly = ellipsePath.toFillPolygon( t );
175 shapePolygon = ti.map( ellipsePoly );
183 QPainterPath roundedRectPath;
185 QPolygonF roundedPoly = roundedRectPath.toFillPolygon( t );
186 shapePolygon = ti.map( roundedPoly );
190 shapePolygon = QPolygonF( QRectF( 0, 0, rect().width(), rect().height() ) );
196 shapePolygon << QPointF( 0, rect().height() );
197 shapePolygon << QPointF( rect().width() , rect().height() );
198 shapePolygon << QPointF( rect().width() / 2.0, 0 );
199 shapePolygon << QPointF( 0, rect().height() );
211 setPen( QPen( QBrush( Qt::NoBrush ), maxBleed * 2.0 ) );
235 p->setBrush( Qt::NoBrush );
236 p->setRenderHint( QPainter::Antialiasing,
true );
245 p->setBrush( brush() );
246 p->setPen( Qt::NoPen );
247 p->setRenderHint( QPainter::Antialiasing,
true );
259 QDomElement composerShapeElem = doc.createElement(
"ComposerShape" );
260 composerShapeElem.setAttribute(
"shapeType",
mShape );
261 composerShapeElem.setAttribute(
"cornerRadius",
mCornerRadius );
264 composerShapeElem.appendChild( shapeStyleElem );
266 elem.appendChild( composerShapeElem );
267 return _writeXML( composerShapeElem, doc );
273 mCornerRadius = itemElem.attribute(
"cornerRadius",
"0" ).toDouble();
276 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
277 if ( composerItemList.size() > 0 )
279 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
282 if ( composerItemElem.attribute(
"rotation",
"0" ).toDouble() != 0 )
285 setItemRotation( composerItemElem.attribute(
"rotation",
"0" ).toDouble() );
291 QDomElement shapeStyleSymbolElem = itemElem.firstChildElement(
"symbol" );
292 if ( !shapeStyleSymbolElem.isNull() )
305 properties.insert(
"style",
"solid" );
309 properties.insert(
"style",
"no" );
313 properties.insert(
"style_border",
"solid" );
317 properties.insert(
"style_border",
"no" );
320 properties.insert(
"width_border", QString::number( pen().widthF() ) );
void setShapeStyleSymbol(QgsFillSymbolV2 *symbol)
Sets the QgsFillSymbolV2 used to draw the shape.
QgsComposition::AtlasMode atlasMode() const
Returns the current atlas mode of the composition.
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void drawShapeUsingSymbol(QPainter *p)
Shape mShape
Ellipse, rectangle or triangle.
virtual void drawFrame(QPainter *p)
Draw black frame around item.
static QgsFillSymbolV2 * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
A item that forms part of a map composition.
void createDefaultShapeStyleSymbol()
bool enabled() const
Is the atlas generation enabled ?
bool writeXML(QDomElement &elem, QDomDocument &doc) const
stores state in Dom element
QMap< QString, QString > QgsStringMap
static QString encodeColor(QColor color)
void itemChanged()
Used e.g.
bool _readXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads parameter that are not subclass specific in document.
static QDomElement saveSymbol(QString symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
void frameChanged()
Emitted if the item's frame style changes.
double horizontalViewScaleFactor() const
Returns the zoom factor of the graphics view.
void setScaleFactor(double factor)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
Reimplementation of QCanvasItem::paint - draw on canvas.
virtual void drawSelectionBoxes(QPainter *p)
Draw selection boxes around item.
QgsFillSymbolV2 * mShapeStyleSymbol
void setCornerRadius(double radius)
Sets radius for rounded rectangle corners.
void setUseSymbolV2(bool useSymbolV2)
Controls whether the shape should be drawn using a QgsFillSymbolV2.
int printResolution() const
bool mFrame
True if item fram needs to be painted.
void drawShape(QPainter *p)
void setPainter(QPainter *p)
static double estimateMaxSymbolBleed(QgsSymbolV2 *symbol)
Returns the maximum estimated bleed for the symbol.
virtual double estimatedFrameBleed() const
reimplement estimatedFrameBleed, since frames on shapes are drawn using symbology rather than the ite...
QgsComposition * mComposition
Graphics scene for map printing.
QgsFeature * currentFeature()
Returns the current atlas feature.
virtual void setItemRotation(double r, bool adjustPosition=false)
Sets the item rotation.
void refreshSymbol()
Should be called after the shape's symbol is changed.
Contains information about the context of a rendering operation.
void stopRender(QgsRenderContext &context)
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document.
virtual void drawBackground(QPainter *p)
Draw background.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
bool hasFrame() const
Whether this item has a frame or not.
void startRender(QgsRenderContext &context, const QgsVectorLayer *layer=0)
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
bool hasBackground() const
Whether this item has a Background or not.
QgsAtlasComposition & atlasComposition()
static QgsSymbolV2 * loadSymbol(QDomElement &element)
void setRasterScaleFactor(double factor)
QgsComposition::PlotStyle plotStyle() const
void setFrameEnabled(bool drawFrame)
Set whether this item has a frame drawn around it or not.
bool mBackground
True if item background needs to be painted.
QgsComposerShape(QgsComposition *composition)