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(
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 );
354 void setBoundingBoxesVisible(
const bool boundsVisible );
382 int pageNumberAt(
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;
438 void setPrintResolution(
const int dpi );
452 void setUseAdvancedEffects(
const bool effectsEnabled );
455 Q_DECL_DEPRECATED
QgsMapRenderer* mapRenderer() {
return mMapRenderer; }
469 Q_DECL_DEPRECATED
int pixelFontSize(
double pointSize )
const;
474 Q_DECL_DEPRECATED
double pointFontSize(
int pixelSize )
const;
491 bool addUndoCommands =
false,
const bool clearComposition =
true );
503 bool addUndoCommands =
false,
QPointF* pos =
nullptr,
bool pasteInPlace =
false );
511 void raiseSelectedItems();
515 void lowerSelectedItems();
518 void moveSelectedItemsToTop();
521 void moveSelectedItemsToBottom();
531 void alignSelectedItemsLeft();
532 void alignSelectedItemsHCenter();
533 void alignSelectedItemsRight();
534 void alignSelectedItemsTop();
535 void alignSelectedItemsVCenter();
536 void alignSelectedItemsBottom();
540 void lockSelectedItems();
542 void unlockAllItems();
601 void cancelCommand();
604 void endMultiFrameCommand();
606 void cancelMultiFrameCommand();
618 void addComposerMap(
QgsComposerMap* map,
const bool setDefaultPreviewStyle =
true );
635 void removeComposerItem(
QgsComposerItem* item,
const bool createCommand =
true,
const bool removeGroupItems =
true );
649 void beginPrint(
QPrinter& printer,
const bool evaluateDDPageSize =
false );
658 void doPrint(
QPrinter& printer,
QPainter& painter,
bool startNewPage =
false );
663 bool print(
QPrinter &printer,
const bool evaluateDDPageSize =
false );
668 bool exportAsPDF(
const QString& file );
681 QImage printPageAsRaster(
int page,
QSize imageSize =
QSize(),
int dpi = 0 );
704 void renderPage(
QPainter* p,
int page );
719 void computeWorldFileParameters(
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
731 void computeWorldFileParameters(
const QRectF& exportRegion,
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
738 Q_DECL_DEPRECATED
static void relativeResizeRect(
QRectF& rectToResize,
const QRectF& boundsBefore,
const QRectF& boundsAfter );
743 Q_DECL_DEPRECATED
static double relativePosition(
double position,
double beforeMin,
double beforeMax,
double afterMin,
double afterMax );
814 void removeCustomProperty(
const QString &key );
829 QRectF pageItemBounds(
int pageNumber,
bool visibleOnly =
false )
const;
835 QRectF compositionBounds(
bool ignorePages =
false,
double margin = 0.0 )
const;
861 void setAllUnselected();
892 double mSpaceBetweenPages;
896 void createDefaultPageStyleSymbol();
902 int mPrintResolution;
908 bool mGenerateWorldFile;
913 bool mUseAdvancedEffects;
918 double mSnapGridResolution;
919 double mSnapGridOffsetX;
920 double mSnapGridOffsetY;
933 double mResizeToContentsMarginTop;
934 double mResizeToContentsMarginRight;
935 double mResizeToContentsMarginBottom;
936 double mResizeToContentsMarginLeft;
938 bool mBoundingBoxesVisible;
952 bool mPreventCursorChange;
966 void updateZValues(
const bool addUndoCommands =
true );
970 int boundingRectOfSelectedItems(
QRectF& bRect );
983 void updatePaperItems();
985 void removePaperItems();
986 void deleteAndRemoveMultiFrames();
1045 bool ddPageSizeActive()
const;
1049 void prepareAllDataDefinedExpressions();
1052 void paperSizeChanged();
1053 void nPagesChanged();
1056 void printResolutionChanged();
1084 void refreshItemsTriggered();
1087 void statusMsgChanged(
const QString& message );
1098 for ( ; itemIt != graphicsItemList.
end(); ++itemIt )
1100 T* item =
dynamic_cast<T*
>( *itemIt );
1113 for ( ; itemIt != graphicsItemList.
end(); ++itemIt )
1115 T* item =
dynamic_cast<T*
>( *itemIt );
1116 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.
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.
GridStyle
Style to draw the snapping grid.
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.
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.
DataDefinedProperty
Data defined properties for different item types.
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.
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
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.
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
AtlasMode
Composition atlas modes.
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.