16 #ifndef QGSCOMPOSITION_H
17 #define QGSCOMPOSITION_H
21 #include <QDomDocument>
22 #include <QGraphicsScene>
23 #include <QLinkedList>
129 void setPaperSize(
double width,
double height,
130 bool keepRelativeItemPosition =
true );
137 double paperHeight()
const;
144 double paperWidth()
const;
159 void resizePageToContents(
double marginTop = 0.0,
double marginRight = 0.0,
160 double marginBottom = 0.0,
double marginLeft = 0.0 );
172 void setResizeToContentsMargins(
double marginTop,
double marginRight,
173 double marginBottom,
double marginLeft );
185 void resizeToContentsMargins(
double& marginTop,
double& marginRight,
186 double& marginBottom,
double& marginLeft )
const;
197 void setNumPages(
const int pages );
203 int numPages()
const;
214 bool pageIsEmpty(
const int page )
const;
223 bool shouldExportPage(
const int page )
const;
238 int pageNumberForPoint(
const QPointF & position )
const;
243 void setStatusMessage(
const QString & message );
248 void updateSettings();
250 void setSnapToGridEnabled(
const bool b );
253 void setGridVisible(
const bool b );
257 void setSnapLinesVisible(
const bool visible );
273 void setPagesVisible(
bool visible );
284 void clearSnapLines();
286 void setSnapGridResolution(
const double r );
289 void setSnapGridOffsetX(
const double offset );
292 void setSnapGridOffsetY(
const double offset );
295 void setGridPen(
const QPen& p );
298 void setGridStyle(
const GridStyle s );
354 void setBoundingBoxesVisible(
const bool boundsVisible );
382 int pageNumberAt(
const QPointF& position )
const;
402 template<
class T>
void composerItems(
QList<T*>& itemList );
410 template<
class T>
void composerItemsOnPage(
QList<T*>& itemList,
const int pageNumber )
const;
437 void setPrintResolution(
const int dpi );
451 void setUseAdvancedEffects(
const bool effectsEnabled );
454 Q_DECL_DEPRECATED
QgsMapRenderer* mapRenderer() {
return mMapRenderer; }
468 Q_DECL_DEPRECATED
int pixelFontSize(
double pointSize )
const;
473 Q_DECL_DEPRECATED
double pointFontSize(
int pixelSize )
const;
490 bool addUndoCommands =
false,
const bool clearComposition =
true );
502 bool addUndoCommands =
false,
QPointF* pos = 0,
bool pasteInPlace =
false );
510 void raiseSelectedItems();
514 void lowerSelectedItems();
517 void moveSelectedItemsToTop();
520 void moveSelectedItemsToBottom();
525 void selectNextByZOrder(
const ZValueDirection direction );
530 void alignSelectedItemsLeft();
531 void alignSelectedItemsHCenter();
532 void alignSelectedItemsRight();
533 void alignSelectedItemsTop();
534 void alignSelectedItemsVCenter();
535 void alignSelectedItemsBottom();
539 void lockSelectedItems();
541 void unlockAllItems();
599 void cancelCommand();
602 void endMultiFrameCommand();
604 void cancelMultiFrameCommand();
616 void addComposerMap(
QgsComposerMap* map,
const bool setDefaultPreviewStyle =
true );
633 void removeComposerItem(
QgsComposerItem* item,
const bool createCommand =
true,
const bool removeGroupItems =
true );
646 void beginPrint(
QPrinter& printer,
const bool evaluateDDPageSize =
false );
655 void doPrint(
QPrinter& printer,
QPainter& painter,
bool startNewPage =
false );
660 bool print(
QPrinter &printer,
const bool evaluateDDPageSize =
false );
665 bool exportAsPDF(
const QString& file );
678 QImage printPageAsRaster(
int page,
const QSize& imageSize =
QSize(),
int dpi = 0 );
701 void renderPage(
QPainter* p,
int page );
716 void computeWorldFileParameters(
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
728 void computeWorldFileParameters(
const QRectF& exportRegion,
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
735 Q_DECL_DEPRECATED
static void relativeResizeRect(
QRectF& rectToResize,
const QRectF& boundsBefore,
const QRectF& boundsAfter );
740 Q_DECL_DEPRECATED
static double relativePosition(
double position,
double beforeMin,
double beforeMax,
double afterMin,
double afterMax );
810 void removeCustomProperty(
const QString &key );
825 QRectF pageItemBounds(
int pageNumber,
bool visibleOnly =
false )
const;
831 QRectF compositionBounds(
bool ignorePages =
false,
double margin = 0.0 )
const;
857 void setAllUnselected();
888 double mSpaceBetweenPages;
892 void createDefaultPageStyleSymbol();
898 int mPrintResolution;
904 bool mGenerateWorldFile;
909 bool mUseAdvancedEffects;
914 double mSnapGridResolution;
915 double mSnapGridOffsetX;
916 double mSnapGridOffsetY;
918 GridStyle mGridStyle;
929 double mResizeToContentsMarginTop;
930 double mResizeToContentsMarginRight;
931 double mResizeToContentsMarginBottom;
932 double mResizeToContentsMarginLeft;
934 bool mBoundingBoxesVisible;
948 bool mPreventCursorChange;
962 void updateZValues(
const bool addUndoCommands =
true );
966 int boundingRectOfSelectedItems(
QRectF& bRect );
979 void updatePaperItems();
981 void removePaperItems();
982 void deleteAndRemoveMultiFrames();
1041 bool ddPageSizeActive()
const;
1045 void prepareAllDataDefinedExpressions();
1048 void paperSizeChanged();
1049 void nPagesChanged();
1052 void printResolutionChanged();
1080 void refreshItemsTriggered();
1083 void statusMsgChanged(
QString message );
1094 for ( ; itemIt != graphicsItemList.
end(); ++itemIt )
1096 T* item =
dynamic_cast<T*
>( *itemIt );
1109 for ( ; itemIt != graphicsItemList.
end(); ++itemIt )
1111 T* item =
dynamic_cast<T*
>( *itemIt );
void setSnapTolerance(const int snapTolerance)
Sets the snap tolerance to use when automatically snapping items during movement and resizing to guid...
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.
bool snapLinesVisible() const
bool boundingBoxesVisible() const
Returns whether selection bounding boxes should be shown in the composition.
A base class for objects which belong to a map composition.
QgsFillSymbolV2 * pageStyleSymbol()
Note: added in version 2.1.
void setPrintAsRaster(const bool enabled)
A container class for data source field mapping or expression.
An item that draws an arrow between to points.
void push_back(const T &value)
QgsComposerModel * itemsModel()
Returns the items model attached to the composition.
QList< QGraphicsItem * > items() const
void setPlotStyle(const QgsComposition::PlotStyle style)
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.
Q_DECL_DEPRECATED double snapGridTolerance() const
Returns the snap tolerance to use when automatically snapping items during movement and resizing to t...
bool preventCursorChange() const
Container of fields for a vector layer.
A container for grouping several QgsComposerItems.
DataDefinedProperty
Data defined properties for different item types.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
A non GUI class for rendering a map layer set onto a QPainter.
double spaceBetweenPages() const
Returns the vertical space between pages in a composer view.
bool alignmentSnap() const
A table that displays attributes from a vector layer.
void composerItemsOnPage(QList< T * > &itemList, const int pageNumber) const
Return composer items of a specific type on a specified page.
A composer class that displays svg files or raster format (jpg, png, ...)
The QgsMapSettings class contains configuration for rendering of the map.
Q_DECL_DEPRECATED void sortZList()
Sorts the zList.
int itemPageNumber(const QgsComposerItem *) const
Returns on which page number (0-based) is displayed an item.
void setPreventCursorChange(const bool preventChange)
If true, prevents any mouse cursor changes by the composition or by any composer items Used by QgsCom...
int printResolution() const
GridStyle
Style to draw the snapping grid.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Abstract base class for composer items with the ability to distribute the content to several frames (...
A class to display a table in the print composer, and allow the table to span over multiple frames...
void setAlignmentSnap(const bool s)
bool printAsRaster() const
void setWorldFileMap(QgsComposerMap *map)
QgsComposerMap * worldFileMap() const
Graphics scene for map printing.
bool snapToGridEnabled() const
Object representing map window.
Frame item for a composer multiframe item.
void setGenerateWorldFile(const bool enabled)
GridStyle gridStyle() const
A model for items attached to a composition.
AtlasMode
Composition atlas modes.
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.
Q_DECL_DEPRECATED void setSnapGridTolerance(double tolerance)
Sets the snap tolerance to use when automatically snapping items during movement and resizing to the ...
A composer command class for adding / removing composer items.
double snapGridOffsetY() const
bool pagesVisible() const
Returns whether the page items are be visible in the composition.
double snapGridOffsetX() const
A table class that displays a vector attribute table.
Undo command to undo/redo all composer item related changes.
int snapTolerance() const
Returns the snap tolerance to use when automatically snapping items during movement and resizing to g...
A composer items that draws common shapes (ellipse, triangle, rectangle)
double snapGridResolution() const
Q_DECL_DEPRECATED double alignmentSnapTolerance() const
Returns the snap tolerance to use when automatically snapping items during movement and resizing to g...
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
void setSmartGuidesEnabled(const bool b)
A label that can be placed onto a map composition.
Class used to render an Atlas, iterating over geometry features.
QgsAtlasComposition & atlasComposition()
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
Represents a vector layer which manages a vector based data sets.
A legend that can be placed onto a map composition.
Q_DECL_DEPRECATED void setAlignmentSnapTolerance(double t)
Sets the snap tolerance to use when automatically snapping items during movement and resizing to guid...
QList< QGraphicsLineItem * > * snapLines()
Returns pointer to snap lines collection.