22 #include <QGraphicsRectItem>
29 setFlag( QGraphicsItem::ItemIsSelectable,
false );
30 setFlag( QGraphicsItem::ItemIsMovable,
false );
39 void QgsPaperGrid::paint( QPainter* painter,
const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
41 Q_UNUSED( itemStyle );
58 painter->setRenderHint( QPainter::Antialiasing,
false );
67 painter->drawLine( QPointF( currentXCoord, 0 ), QPointF( currentXCoord, rect().height() ) );
71 currentYCoord = minYCoord;
74 painter->drawLine( QPointF( 0, currentYCoord ), QPointF( rect().width(), currentYCoord ) );
80 painter->setPen( gridPen );
81 painter->setBrush( QBrush( gridPen.color() ) );
82 double halfCrossLength = 1;
89 QList<QGraphicsView*> viewList = scene()->views();
90 if ( viewList.size() > 0 )
92 QGraphicsView* currentView = viewList.at( 0 );
93 if ( currentView->isVisible() )
96 halfCrossLength = 1 / currentView->transform().m11();
108 currentYCoord = minYCoord;
111 painter->drawLine( QPointF( currentXCoord - halfCrossLength, currentYCoord ), QPointF( currentXCoord + halfCrossLength, currentYCoord ) );
112 painter->drawLine( QPointF( currentXCoord, currentYCoord - halfCrossLength ), QPointF( currentXCoord, currentYCoord + halfCrossLength ) );
130 QgsPaperItem::QgsPaperItem( qreal x, qreal y, qreal width, qreal height,
QgsComposition* composition ):
QgsComposerItem( x, y, width, height, composition, false ),
131 mPageGrid( 0 ), mPageMargin( 0 )
137 mPageGrid( 0 ), mPageMargin( 0 )
147 void QgsPaperItem::paint( QPainter* painter,
const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
149 Q_UNUSED( itemStyle );
174 painter->setRenderHint( QPainter::Antialiasing,
false );
177 painter->setBrush( QBrush( QColor( 150, 150, 150 ) ) );
178 painter->setPen( Qt::NoPen );
179 painter->drawRect( QRectF( 1, 1, rect().width() + 1, rect().height() + 1 ) );
182 painter->setBrush( QColor( 215, 215, 215 ) );
183 painter->setPen( QPen( QColor( 100, 100, 100 ) ) );
184 painter->drawRect( QRectF( 0, 0, rect().width(), rect().height() ) );
187 painter->setRenderHint( QPainter::Antialiasing );
192 QList<QPolygonF> rings;
230 Q_UNUSED( itemElem );
239 mPageGrid->setRect( 0, 0, rect().width(), rect().height() );
240 mPageGrid->setPos( pos().x(), pos().y() );
245 setFlag( QGraphicsItem::ItemIsSelectable,
false );
246 setFlag( QGraphicsItem::ItemIsMovable,
false );
252 setPen( QPen( QBrush( Qt::NoBrush ), 4 ) );
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)
QgsFillSymbolV2 * pageStyleSymbol()
Note: added in version 2.1.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
Reimplementation of QCanvasItem::paint.
const QPen & gridPen() const
A item that forms part of a map composition.
QgsPaperGrid(double x, double y, double width, double height, QgsComposition *composition)
bool enabled() const
Is the atlas generation enabled ?
void calculatePageMargin()
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
Reimplementation of QCanvasItem::paint.
void initialize()
Set flags and z-value.
double horizontalViewScaleFactor() const
Returns the zoom factor of the graphics view.
void setScaleFactor(double factor)
int printResolution() const
Item representing a grid.
void setPainter(QPainter *p)
static double estimateMaxSymbolBleed(QgsSymbolV2 *symbol)
Returns the maximum estimated bleed for the symbol.
QgsComposition * mComposition
Graphics scene for map printing.
QgsFeature * currentFeature()
Returns the current atlas feature.
GridStyle gridStyle() const
QgsComposition * mComposition
double snapGridOffsetY() const
Contains information about the context of a rendering operation.
double snapGridOffsetX() const
void stopRender(QgsRenderContext &context)
double snapGridResolution() const
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...
QgsAtlasComposition & atlasComposition()
bool writeXML(QDomElement &elem, QDomDocument &doc) const
stores state in Dom element
void setRasterScaleFactor(double factor)
QgsComposition::PlotStyle plotStyle() const
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 readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document