22 #include <QGraphicsRectItem>
23 #include <QGraphicsView>
30 setFlag( QGraphicsItem::ItemIsSelectable,
false );
31 setFlag( QGraphicsItem::ItemIsMovable,
false );
40 void QgsPaperGrid::paint( QPainter* painter,
const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
42 Q_UNUSED( itemStyle );
59 painter->setRenderHint( QPainter::Antialiasing,
false );
68 painter->drawLine( QPointF( currentXCoord, 0 ), QPointF( currentXCoord, rect().height() ) );
72 currentYCoord = minYCoord;
75 painter->drawLine( QPointF( 0, currentYCoord ), QPointF( rect().width(), currentYCoord ) );
81 painter->setPen( gridPen );
82 painter->setBrush( QBrush( gridPen.color() ) );
83 double halfCrossLength = 1;
90 QList<QGraphicsView*> viewList = scene()->views();
91 if ( viewList.size() > 0 )
93 QGraphicsView* currentView = viewList.at( 0 );
94 if ( currentView->isVisible() )
97 halfCrossLength = 1 / currentView->transform().m11();
109 currentYCoord = minYCoord;
112 painter->drawLine( QPointF( currentXCoord - halfCrossLength, currentYCoord ), QPointF( currentXCoord + halfCrossLength, currentYCoord ) );
113 painter->drawLine( QPointF( currentXCoord, currentYCoord - halfCrossLength ), QPointF( currentXCoord, currentYCoord + halfCrossLength ) );
131 QgsPaperItem::QgsPaperItem( qreal x, qreal y, qreal width, qreal height,
QgsComposition* composition ):
QgsComposerItem( x, y, width, height, composition, false ),
132 mPageGrid( 0 ), mPageMargin( 0 )
138 mPageGrid( 0 ), mPageMargin( 0 )
148 void QgsPaperItem::paint( QPainter* painter,
const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
150 Q_UNUSED( itemStyle );
158 double dotsPerMM = painter->device()->logicalDpiX() / 25.4;
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->scale( 1 / dotsPerMM, 1 / dotsPerMM );
189 painter->setRenderHint( QPainter::Antialiasing );
195 QList<QPolygonF> rings;
233 Q_UNUSED( itemElem );
242 mPageGrid->setRect( 0, 0, rect().width(), rect().height() );
243 mPageGrid->setPos( pos().x(), pos().y() );
248 setFlag( QGraphicsItem::ItemIsSelectable,
false );
249 setFlag( QGraphicsItem::ItemIsMovable,
false );
255 setPen( QPen( QBrush( Qt::NoBrush ), 4 ) );
void setForceVectorOutput(bool force)
Added in QGIS v1.5.
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 setOutputDpi(int dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
Reimplementation of QCanvasItem::paint.
const QgsMapSettings & mapSettings() const
Return setting of QGIS map canvas.
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
Returns whether the atlas generation is enabled.
void calculatePageMargin()
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
Reimplementation of QCanvasItem::paint.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
The QgsMapSettings class contains configuration for rendering of the map.
void initialize()
Set flags and z-value.
void startRender(QgsRenderContext &context, const QgsFields *fields=0)
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)
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
double snapGridResolution() 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...
QgsAtlasComposition & atlasComposition()
bool writeXML(QDomElement &elem, QDomDocument &doc) const
stores state in Dom element
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