16 #ifndef QGSCOMPOSITION_H 17 #define QGSCOMPOSITION_H 21 #include <QDomDocument> 22 #include <QGraphicsScene> 23 #include <QLinkedList> 131 void setPaperSize(
double width,
double height,
132 bool keepRelativeItemPosition =
true );
139 double paperHeight()
const;
146 double paperWidth()
const;
161 void resizePageToContents(
double marginTop = 0.0,
double marginRight = 0.0,
162 double marginBottom = 0.0,
double marginLeft = 0.0 );
174 void setResizeToContentsMargins(
double marginTop,
double marginRight,
175 double marginBottom,
double marginLeft );
187 void resizeToContentsMargins(
double& marginTop,
double& marginRight,
188 double& marginBottom,
double& marginLeft )
const;
199 void setNumPages(
const int pages );
205 int numPages()
const;
216 bool pageIsEmpty(
const int page )
const;
225 bool shouldExportPage(
const int page )
const;
240 int pageNumberForPoint(
QPointF position )
const;
245 void setStatusMessage(
const QString & message );
250 void updateSettings();
252 void setSnapToGridEnabled(
const bool b );
255 void setGridVisible(
const bool b );
259 void setSnapLinesVisible(
const bool visible );
275 void setPagesVisible(
bool visible );
286 void clearSnapLines();
288 void setSnapGridResolution(
const double r );
291 void setSnapGridOffsetX(
const double offset );
294 void setSnapGridOffsetY(
const double offset );
297 void setGridPen(
const QPen& p );
356 void setBoundingBoxesVisible(
const bool boundsVisible );
384 int pageNumberAt(
QPointF position )
const;
404 template<
class T>
void composerItems(
QList<T*>& itemList );
412 template<
class T>
void composerItemsOnPage(
QList<T*>& itemList,
const int pageNumber )
const;
440 void setPrintResolution(
const int dpi );
478 void setUseAdvancedEffects(
const bool effectsEnabled );
481 Q_DECL_DEPRECATED
QgsMapRenderer* mapRenderer() {
return mMapRenderer; }
495 Q_DECL_DEPRECATED
int pixelFontSize(
double pointSize )
const;
500 Q_DECL_DEPRECATED
double pointFontSize(
int pixelSize )
const;
517 bool addUndoCommands =
false,
const bool clearComposition =
true );
529 bool addUndoCommands =
false,
QPointF* pos =
nullptr,
bool pasteInPlace =
false );
537 void raiseSelectedItems();
541 void lowerSelectedItems();
544 void moveSelectedItemsToTop();
547 void moveSelectedItemsToBottom();
557 void alignSelectedItemsLeft();
558 void alignSelectedItemsHCenter();
559 void alignSelectedItemsRight();
560 void alignSelectedItemsTop();
561 void alignSelectedItemsVCenter();
562 void alignSelectedItemsBottom();
566 void lockSelectedItems();
568 void unlockAllItems();
627 void cancelCommand();
630 void endMultiFrameCommand();
632 void cancelMultiFrameCommand();
644 void addComposerMap(
QgsComposerMap* map,
const bool setDefaultPreviewStyle =
true );
665 void removeComposerItem(
QgsComposerItem* item,
const bool createCommand =
true,
const bool removeGroupItems =
true );
679 void beginPrint(
QPrinter& printer,
const bool evaluateDDPageSize =
false );
688 void doPrint(
QPrinter& printer,
QPainter& painter,
bool startNewPage =
false );
693 bool print(
QPrinter &printer,
const bool evaluateDDPageSize =
false );
698 bool exportAsPDF(
const QString& file );
711 QImage printPageAsRaster(
int page,
QSize imageSize =
QSize(),
int dpi = 0 );
734 void renderPage(
QPainter* p,
int page );
756 const QRectF& exportRegion =
QRectF(),
double dpi = -1 )
const;
761 void computeWorldFileParameters(
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
773 void computeWorldFileParameters(
const QRectF& exportRegion,
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
780 Q_DECL_DEPRECATED
static void relativeResizeRect(
QRectF& rectToResize,
const QRectF& boundsBefore,
const QRectF& boundsAfter );
785 Q_DECL_DEPRECATED
static double relativePosition(
double position,
double beforeMin,
double beforeMax,
double afterMin,
double afterMax );
856 void removeCustomProperty(
const QString &key );
871 QRectF pageItemBounds(
int pageNumber,
bool visibleOnly =
false )
const;
877 QRectF compositionBounds(
bool ignorePages =
false,
double margin = 0.0 )
const;
903 void setAllUnselected();
934 double mSpaceBetweenPages;
938 void createDefaultPageStyleSymbol();
944 int mPrintResolution;
950 bool mGenerateWorldFile;
956 bool mUseAdvancedEffects;
961 double mSnapGridResolution;
962 double mSnapGridOffsetX;
963 double mSnapGridOffsetY;
976 double mResizeToContentsMarginTop;
977 double mResizeToContentsMarginRight;
978 double mResizeToContentsMarginBottom;
979 double mResizeToContentsMarginLeft;
981 bool mBoundingBoxesVisible;
995 bool mPreventCursorChange;
1009 void updateZValues(
const bool addUndoCommands =
true );
1013 int boundingRectOfSelectedItems(
QRectF& bRect );
1016 void loadDefaults();
1019 void loadSettings();
1026 void updatePaperItems();
1027 void addPaperItem();
1028 void removePaperItems();
1029 void deleteAndRemoveMultiFrames();
1088 bool ddPageSizeActive()
const;
1098 double* computeGeoTransform(
const QgsComposerMap* referenceMap =
nullptr,
const QRectF& exportRegion =
QRectF(),
double dpi = -1 )
const;
1103 void prepareAllDataDefinedExpressions();
1106 void paperSizeChanged();
1107 void nPagesChanged();
1110 void printResolutionChanged();
1144 void refreshItemsTriggered();
1147 void statusMsgChanged(
const QString& message );
1152 void variablesChanged();
1156 friend class TestQgsComposition;
1164 for ( ; itemIt != graphicsItemList.
end(); ++itemIt )
1166 T* item =
dynamic_cast<T*
>( *itemIt );
1179 for ( ; itemIt != graphicsItemList.
end(); ++itemIt )
1181 T* item =
dynamic_cast<T*
>( *itemIt );
1182 if ( item && itemPageNumber( item ) == pageNumber )
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.
const QPen & gridPen() const
A base class for objects which belong to a map composition.
Composer item for polylines.
QgsFillSymbolV2 * pageStyleSymbol()
Note: added in version 2.1.
void setPrintAsRaster(const bool enabled)
double snapGridOffsetY() const
void composerItems(QList< T *> &itemList)
Return composer items of a specific type.
A container class for data source field mapping or expression.
An item that draws an arrow between two points.
double snapGridOffsetX() const
bool snapToGridEnabled() const
void push_back(const T &value)
void setGenerateWorldFile(bool enabled)
Sets whether the composition will generate corresponding world files when pages are exported...
QgsComposerModel * itemsModel()
Returns the items model attached to the composition.
GridStyle
Style to draw the snapping grid.
QList< QGraphicsItem * > items() const
void setPlotStyle(const QgsComposition::PlotStyle style)
bool alignmentSnap() const
int printResolution() const
QgsComposerMouseHandles * selectionHandles()
Returns pointer to selection handles.
Q_DECL_DEPRECATED double alignmentSnapTolerance() const
Returns the snap tolerance to use when automatically snapping items during movement and resizing to g...
A item that forms part of a map composition.
Container of fields for a vector layer.
A container for grouping several QgsComposerItems.
bool snapLinesVisible() const
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.
bool preventCursorChange() const
QgsComposition::AtlasMode atlasMode() const
Returns the current atlas mode of the composition.
A table that displays attributes from a vector layer.
DataDefinedProperty
Data defined properties for different item types.
A composer class that displays svg files or raster format (jpg, png, ...)
QgsComposition::PlotStyle plotStyle() const
The QgsMapSettings class contains configuration for rendering of the map.
Q_DECL_DEPRECATED void sortZList()
Sorts the zList.
Q_DECL_DEPRECATED double snapGridTolerance() const
Returns the snap tolerance to use when automatically snapping items during movement and resizing to t...
void setPreventCursorChange(const bool preventChange)
If true, prevents any mouse cursor changes by the composition or by any composer items Used by QgsCom...
bool boundingBoxesVisible() const
Returns whether selection bounding boxes should be shown in the composition.
bool useAdvancedEffects() const
Returns true if a composition should use advanced effects such as blend modes.
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)
Graphics scene for map printing.
bool generateWorldFile() const
Returns true if the composition will generate corresponding world files when pages are exported...
const QgsMapSettings & mapSettings() const
Return setting of QGIS map canvas.
Object representing map window.
Frame item for a composer multiframe item.
bool smartGuidesEnabled() const
void composerItemsOnPage(QList< T *> &itemList, const int pageNumber) const
Return composer items of a specific type on a specified page.
A model for items attached to a composition.
QList< QgsPaperItem *> pages()
Return pages in the correct order.
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.
A table class that displays a vector attribute table.
Undo command to undo/redo all composer item related changes.
A composer items that draws common shapes (ellipse, triangle, rectangle)
Composer item for polygons.
int snapTolerance() const
Returns the snap tolerance to use when automatically snapping items during movement and resizing to g...
AtlasMode
Composition atlas modes.
GridStyle gridStyle() const
bool printAsRaster() const
double snapGridResolution() const
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.
bool pagesVisible() const
Returns whether the page items are be visible in the composition.
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...
double spaceBetweenPages() const
Returns the vertical space between pages in a composer view.
QList< QGraphicsLineItem *> * snapLines()
Returns pointer to snap lines collection.