16 #ifndef QGSCOMPOSITION_H
17 #define QGSCOMPOSITION_H
22 #include <QDomDocument>
23 #include <QGraphicsScene>
24 #include <QLinkedList>
40 class QGraphicsRectItem;
105 void setPaperSize(
double width,
double height );
108 double paperHeight()
const;
111 double paperWidth()
const;
116 void setNumPages(
int pages );
118 int numPages()
const;
128 QPointF positionOnPage(
const QPointF & position )
const;
133 int pageNumberForPoint(
const QPointF & position )
const;
138 void setStatusMessage(
const QString & message );
142 void updateSettings();
144 void setSnapToGridEnabled(
bool b );
147 void setGridVisible(
bool b );
151 void setSnapLinesVisible(
bool visible );
161 void clearSnapLines();
163 void setSnapGridResolution(
double r );
166 void setSnapGridTolerance(
double tolerance );
169 void setSnapGridOffsetX(
double offset );
172 void setSnapGridOffsetY(
double offset );
175 void setGridPen(
const QPen& p );
176 const QPen&
gridPen()
const {
return mGridPen;}
178 void setGridStyle( GridStyle s );
196 int pageNumberAt(
const QPointF& position )
const;
201 QList<QgsComposerItem*> selectedComposerItems();
206 QList<const QgsComposerMap*> composerMapItems()
const;
211 template<
class T>
void composerItems( QList<T*>& itemList );
257 void setUseAdvancedEffects(
bool effectsEnabled );
268 int pixelFontSize(
double pointSize )
const;
271 double pointFontSize(
int pixelSize )
const;
274 bool writeXML( QDomElement& composerElem, QDomDocument& doc );
277 bool readXML(
const QDomElement& compositionElem,
const QDomDocument& doc );
284 bool loadFromTemplate(
const QDomDocument& doc, QMap<QString, QString>* substitutionMap = 0,
bool addUndoCommands =
false );
295 void addItemsFromXML(
const QDomElement& elem,
const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore = 0,
296 bool addUndoCommands =
false, QPointF* pos = 0,
bool pasteInPlace =
false );
304 void raiseSelectedItems();
306 void lowerSelectedItems();
308 void moveSelectedItemsToTop();
310 void moveSelectedItemsToBottom();
314 void selectNextByZOrder( ZValueDirection direction );
319 void alignSelectedItemsLeft();
320 void alignSelectedItemsHCenter();
321 void alignSelectedItemsRight();
322 void alignSelectedItemsTop();
323 void alignSelectedItemsVCenter();
324 void alignSelectedItemsBottom();
328 void lockSelectedItems();
330 void unlockAllItems();
340 QPointF snapPointToGrid(
const QPointF& scenePoint )
const;
343 QList< QGraphicsLineItem* >*
snapLines() {
return &mSnapLines;}
351 QGraphicsLineItem* addSnapLine();
353 void removeSnapLine( QGraphicsLineItem* line );
357 QGraphicsLineItem* nearestSnapLine(
bool horizontal,
double x,
double y,
double tolerance, QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >& snappedItems );
368 void cancelCommand();
371 void endMultiFrameCommand();
383 void addComposerMap(
QgsComposerMap* map,
bool setDefaultPreviewStyle =
true );
398 void removeComposerItem(
QgsComposerItem* item,
bool createCommand =
true );
411 void beginPrint( QPrinter& printer );
413 void beginPrintAsPDF( QPrinter& printer,
const QString&
file );
415 void doPrint( QPrinter& printer, QPainter& painter );
418 void print( QPrinter &printer );
421 void exportAsPDF(
const QString&
file );
425 QImage printPageAsRaster(
int page );
429 void renderPage( QPainter* p,
int page );
432 void computeWorldFileParameters(
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
437 static void relativeResizeRect( QRectF& rectToResize,
const QRectF& boundsBefore,
const QRectF& boundsAfter );
439 static double relativePosition(
double position,
double beforeMin,
double beforeMax,
double afterMin,
double afterMax );
465 void createDefaultPageStyleSymbol();
521 QRectF compositionBounds()
const;
524 void updateZValues(
bool addUndoCommands =
true );
528 int boundingRectOfSelectedItems( QRectF& bRect );
537 QPointF minPointFromXml(
const QDomElement& elem )
const;
541 void updatePaperItems();
543 void removePaperItems();
544 void deleteAndRemoveMultiFrames();
546 static QString encodeStringForXML(
const QString& str );
551 void paperSizeChanged();
552 void nPagesChanged();
578 void statusMsgChanged( QString message );
584 QList<QGraphicsItem *> graphicsItemList = items();
585 QList<QGraphicsItem *>::iterator itemIt = graphicsItemList.begin();
586 for ( ; itemIt != graphicsItemList.end(); ++itemIt )
588 T* item =
dynamic_cast<T*
>( *itemIt );
591 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.
QgsComposition::AtlasMode atlasMode() const
Returns the current atlas mode of the composition.
double alignmentSnapTolerance() const
bool snapLinesVisible() const
QgsFillSymbolV2 * pageStyleSymbol()
Note: added in version 2.1.
double mAlignmentSnapTolerance
An item that draws an arrow between to points.
double mSnapGridTolerance
void setGenerateWorldFile(bool enabled)
GridStyle
Style to draw the snapping grid.
const QPen & gridPen() const
QgsComposerMouseHandles * selectionHandles()
Returns pointer to selection handles.
bool smartGuidesEnabled() const
A item that forms part of a map composition.
double snapGridTolerance() const
QgsMapRenderer * mapRenderer()
Returns pointer to map renderer of qgis map canvas.
bool preventCursorChange()
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)
bool mGenerateWorldFile
Flag if a world file should be generated on raster export.
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
void setWorldFileMap(QgsComposerMap *map)
QgsComposerMap * worldFileMap() 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.
QgsComposerMouseHandles * mSelectionHandles
GridStyle gridStyle() const
void setAlignmentSnap(bool s)
double mSpaceBetweenPages
bool mSnapToGrid
Parameters for snap to grid function.
bool mPreventCursorChange
void setPreventCursorChange(bool preventChange)
If true, prevents any mouse cursor changes by the composition or by any composer items Used by QgsCom...
bool useAdvancedEffects() const
Returns true if a composition should use advanced effects such as blend modes.
QgsComposition::AtlasMode mAtlasMode
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)
void setSmartGuidesEnabled(bool b)
QgsComposerMap * mWorldFileMap
Composer map to use for the world file generation.
double snapGridResolution() const
AtlasMode
Composition atlas modes.
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)
Handles drawing of selection outlines and mouse handles.
void composerItems(QList< T * > &itemList)
Return composer items of a specific type.
bool generateWorldFile() const
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.
QgsFillSymbolV2 * mPageStyleSymbol
Drawing style for page.
QList< QGraphicsLineItem * > * snapLines()
Returns pointer to snap lines collection.