16 #ifndef QGSCOMPOSITION_H
17 #define QGSCOMPOSITION_H
22 #include <QDomDocument>
23 #include <QGraphicsScene>
24 #include <QLinkedList>
40 class QGraphicsRectItem;
110 void setPaperSize(
double width,
double height );
113 double paperHeight()
const;
116 double paperWidth()
const;
121 void setNumPages(
int pages );
123 int numPages()
const;
133 QPointF positionOnPage(
const QPointF & position )
const;
138 int pageNumberForPoint(
const QPointF & position )
const;
143 void setStatusMessage(
const QString & message );
147 void updateSettings();
149 void setSnapToGridEnabled(
bool b );
152 void setGridVisible(
bool b );
156 void setSnapLinesVisible(
bool visible );
166 void clearSnapLines();
168 void setSnapGridResolution(
double r );
171 void setSnapGridTolerance(
double tolerance );
174 void setSnapGridOffsetX(
double offset );
177 void setSnapGridOffsetY(
double offset );
180 void setGridPen(
const QPen& p );
181 const QPen&
gridPen()
const {
return mGridPen;}
183 void setGridStyle( GridStyle s );
201 int pageNumberAt(
const QPointF& position )
const;
206 QList<QgsComposerItem*> selectedComposerItems();
211 QList<const QgsComposerMap*> composerMapItems()
const;
216 template<
class T>
void composerItems( QList<T*>& itemList );
246 void setPrintResolution(
int dpi );
262 void setUseAdvancedEffects(
bool effectsEnabled );
265 Q_DECL_DEPRECATED
QgsMapRenderer* mapRenderer() {
return mMapRenderer;}
278 int pixelFontSize(
double pointSize )
const;
281 double pointFontSize(
int pixelSize )
const;
284 bool writeXML( QDomElement& composerElem, QDomDocument& doc );
287 bool readXML(
const QDomElement& compositionElem,
const QDomDocument& doc );
294 bool loadFromTemplate(
const QDomDocument& doc, QMap<QString, QString>* substitutionMap = 0,
bool addUndoCommands =
false );
305 void addItemsFromXML(
const QDomElement& elem,
const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore = 0,
306 bool addUndoCommands =
false, QPointF* pos = 0,
bool pasteInPlace =
false );
314 void raiseSelectedItems();
316 void lowerSelectedItems();
318 void moveSelectedItemsToTop();
320 void moveSelectedItemsToBottom();
324 void selectNextByZOrder( ZValueDirection direction );
329 void alignSelectedItemsLeft();
330 void alignSelectedItemsHCenter();
331 void alignSelectedItemsRight();
332 void alignSelectedItemsTop();
333 void alignSelectedItemsVCenter();
334 void alignSelectedItemsBottom();
338 void lockSelectedItems();
340 void unlockAllItems();
350 QPointF snapPointToGrid(
const QPointF& scenePoint )
const;
353 QList< QGraphicsLineItem* >*
snapLines() {
return &mSnapLines;}
361 QGraphicsLineItem* addSnapLine();
363 void removeSnapLine( QGraphicsLineItem* line );
367 QGraphicsLineItem* nearestSnapLine(
bool horizontal,
double x,
double y,
double tolerance, QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >& snappedItems );
378 void cancelCommand();
381 void endMultiFrameCommand();
393 void addComposerMap(
QgsComposerMap* map,
bool setDefaultPreviewStyle =
true );
408 void removeComposerItem(
QgsComposerItem* item,
bool createCommand =
true );
421 void beginPrint( QPrinter& printer );
423 void beginPrintAsPDF( QPrinter& printer,
const QString&
file );
425 void doPrint( QPrinter& printer, QPainter& painter );
430 bool print( QPrinter &printer );
435 bool exportAsPDF(
const QString&
file );
439 QImage printPageAsRaster(
int page );
443 void renderPage( QPainter* p,
int page );
446 void computeWorldFileParameters(
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
451 static void relativeResizeRect( QRectF& rectToResize,
const QRectF& boundsBefore,
const QRectF& boundsAfter );
453 static double relativePosition(
double position,
double beforeMin,
double beforeMax,
double afterMin,
double afterMax );
463 QList< QgsPaperItem* >
pages() {
return mPages; }
501 void createDefaultPageStyleSymbol();
557 QRectF compositionBounds()
const;
560 void updateZValues(
bool addUndoCommands =
true );
564 int boundingRectOfSelectedItems( QRectF& bRect );
573 QPointF minPointFromXml(
const QDomElement& elem )
const;
577 void updatePaperItems();
579 void removePaperItems();
580 void deleteAndRemoveMultiFrames();
582 static QString encodeStringForXML(
const QString& str );
587 void paperSizeChanged();
588 void nPagesChanged();
591 void printResolutionChanged();
617 void refreshItemsTriggered();
620 void statusMsgChanged( QString message );
626 QList<QGraphicsItem *> graphicsItemList = items();
627 QList<QGraphicsItem *>::iterator itemIt = graphicsItemList.begin();
628 for ( ; itemIt != graphicsItemList.end(); ++itemIt )
630 T* item =
dynamic_cast<T*
>( *itemIt );
633 itemList.push_back( item );
QgsComposition::PlotStyle mPlotStyle
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 QgsMapSettings & mapSettings() const
Return setting of QGIS map canvas.
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
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, ...)
The QgsMapSettings class contains configuration for rendering of the map.
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...
QList< QgsPaperItem * > pages()
Return pages in the correct order.
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.
const QgsMapSettings & mMapSettings
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.