16 #ifndef QGSCOMPOSITION_H
17 #define QGSCOMPOSITION_H
22 #include <QDomDocument>
23 #include <QGraphicsScene>
24 #include <QLinkedList>
40 class QGraphicsRectItem;
89 void setPaperSize(
double width,
double height );
92 double paperHeight()
const;
95 double paperWidth()
const;
100 void setNumPages(
int pages );
102 int numPages()
const;
104 void setSnapToGridEnabled(
bool b );
107 void setSnapGridResolution(
double r );
110 void setSnapGridOffsetX(
double offset );
113 void setSnapGridOffsetY(
double offset );
116 void setGridPen(
const QPen& p );
117 const QPen&
gridPen()
const {
return mGridPen;}
119 void setGridStyle( GridStyle s );
135 int pageNumberAt(
const QPointF& position )
const;
140 QList<QgsComposerItem*> selectedComposerItems();
145 QList<const QgsComposerMap*> composerMapItems()
const;
150 template<
class T>
void composerItems( QList<T*>& itemList );
190 void setUseAdvancedEffects(
bool effectsEnabled );
193 void setSelectionTolerance(
double tol );
204 int pixelFontSize(
double pointSize )
const;
207 double pointFontSize(
int pixelSize )
const;
210 bool writeXML( QDomElement& composerElem, QDomDocument& doc );
213 bool readXML(
const QDomElement& compositionElem,
const QDomDocument& doc );
220 bool loadFromTemplate(
const QDomDocument& doc, QMap<QString, QString>* substitutionMap = 0,
bool addUndoCommands =
false );
231 void addItemsFromXML(
const QDomElement& elem,
const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore = 0,
232 bool addUndoCommands =
false, QPointF* pos = 0,
bool pasteInPlace =
false );
240 void raiseSelectedItems();
242 void lowerSelectedItems();
244 void moveSelectedItemsToTop();
246 void moveSelectedItemsToBottom();
250 void alignSelectedItemsLeft();
251 void alignSelectedItemsHCenter();
252 void alignSelectedItemsRight();
253 void alignSelectedItemsTop();
254 void alignSelectedItemsVCenter();
255 void alignSelectedItemsBottom();
262 QPointF snapPointToGrid(
const QPointF& scenePoint )
const;
271 QPointF alignItem(
const QgsComposerItem* item,
double& alignX,
double& alignY,
double dx = 0,
double dy = 0 );
279 QPointF alignPos(
const QPointF& pos,
const QgsComposerItem* excludeItem,
double& alignX,
double& alignY );
282 QGraphicsLineItem* addSnapLine();
284 void removeSnapLine( QGraphicsLineItem* line );
288 QGraphicsLineItem* nearestSnapLine(
bool horizontal,
double x,
double y,
double tolerance, QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >& snappedItems );
290 void setSnapLinesVisible(
bool visible );
301 void cancelCommand();
304 void endMultiFrameCommand();
316 void addComposerMap(
QgsComposerMap* map,
bool setDefaultPreviewStyle =
true );
331 void removeComposerItem(
QgsComposerItem* item,
bool createCommand =
true );
340 void beginPrint( QPrinter& printer );
342 void beginPrintAsPDF( QPrinter& printer,
const QString&
file );
344 void doPrint( QPrinter& printer, QPainter& painter );
347 void print( QPrinter &printer );
350 void exportAsPDF(
const QString&
file );
354 QImage printPageAsRaster(
int page );
358 void renderPage( QPainter* p,
int page );
419 void updateZValues();
423 int boundingRectOfSelectedItems( QRectF& bRect );
430 void updatePaperItems();
432 void removePaperItems();
433 void deleteAndRemoveMultiFrames();
435 static QString encodeStringForXML(
const QString& str );
438 void collectAlignCoordinates( QMap< double, const QgsComposerItem* >& alignCoordsX,
439 QMap< double, const QgsComposerItem* >& alignCoordsY,
const QgsComposerItem* excludeItem );
441 void checkNearestItem(
double checkCoord,
const QMap< double, const QgsComposerItem* >& alignCoords,
double& smallestDiff,
442 double itemCoordOffset,
double& itemCoord,
double& alignCoord )
const;
446 static bool nearestItem(
const QMap< double, const QgsComposerItem* >& coords,
double value,
double& nearestValue );
449 void paperSizeChanged();
450 void nPagesChanged();
479 QList<QGraphicsItem *> graphicsItemList = items();
480 QList<QGraphicsItem *>::iterator itemIt = graphicsItemList.begin();
481 for ( ; itemIt != graphicsItemList.end(); ++itemIt )
483 T* item =
dynamic_cast<T*
>( *itemIt );
486 itemList.push_back( item );
QgsComposition::PlotStyle mPlotStyle
Item representing the paper.
A scale bar item that can be added to a map composition.
QUndoStack * undoStack()
Returns pointer to undo/redo command storage.
double alignmentSnapTolerance() const
double selectionTolerance() const
double mAlignmentSnapTolerance
An item that draws an arrow between to points.
GridStyle
Style to draw the snapping grid.
const QPen & gridPen() const
A item that forms part of a map composition.
QgsMapRenderer * mapRenderer()
Returns pointer to map renderer of qgis map canvas.
bool mPrintAsRaster
Flag if map should be printed as a raster (via QImage).
QList< QgsPaperItem * > mPages
A non GUI class for rendering a map layer set onto a QPainter.
double spaceBetweenPages() const
bool alignmentSnap() const
A composer class that displays svg files or raster format (jpg, png, ...)
void setPrintResolution(int dpi)
int printResolution() const
void setPrintAsRaster(bool enabled)
QSet< QgsComposerMultiFrame * > mMultiFrames
List multiframe objects.
QLinkedList< QgsComposerItem * > mItemZList
Maintains z-Order of items.
QgsMapRenderer * mMapRenderer
Pointer to map renderer of QGIS main map.
Abstract base class for composer entries with the ability to distribute the content to several frames...
QgsComposerItemCommand * mActiveItemCommand
int mPrintResolution
Dpi for printout.
bool printAsRaster() const
Graphics scene for map printing.
bool snapToGridEnabled() const
Object representing map window.
Frame for html, table, text which can be divided onto several frames.
GridStyle gridStyle() const
void setAlignmentSnap(bool s)
double mSpaceBetweenPages
bool mSnapToGrid
Parameters for snap to grid function.
bool useAdvancedEffects() const
Returns true if a composition should use advanced effects such as blend modes.
A composer command class for adding / removing composer items.
double snapGridOffsetY() const
double snapGridOffsetX() const
A table class that displays a vector attribute table.
bool mAlignmentSnap
Parameters for alignment snap.
Undo command to undo/redo all composer item related changes.
A composer items that draws common shapes (ellipse, triangle, rectangle)
double snapGridResolution() const
QList< QGraphicsLineItem * > mSnapLines
Arbitraty snap lines (horizontal and vertical)
void setAlignmentSnapTolerance(double t)
QgsComposerMultiFrameCommand * mActiveMultiFrameCommand
QgsAtlasComposition mAtlasComposition
The atlas composition object.
A label that can be placed onto a map composition.
Class used to render an Atlas, iterating over geometry features.
QgsAtlasComposition & atlasComposition()
void setPlotStyle(QgsComposition::PlotStyle style)
double mSelectionTolerance
Distance tolerance for item selection (in mm)
void composerItems(QList< T * > &itemList)
Return composer items of a specific type.
QgsComposition::PlotStyle plotStyle() const
bool mUseAdvancedEffects
Flag if advanced visual effects such as blend modes should be used.
Represents a vector layer which manages a vector based data sets.
double mSnapGridResolution
A legend that can be placed onto a map composition.