1
/** \ingroup MapComposer
2
* Graphics scene for map printing. The class manages the paper item which always
3
* is the item in the back (z-value 0). It maintains the z-Values of the items and stores
4
* them in a list in ascending z-Order. This list can be changed to lower/raise items one position
5
* or to bring them to front/back.
7
class QgsComposition: QGraphicsScene
10
#include <qgscomposition.h>
14
/** \brief Plot type */
17
Preview = 0, // Use cache etc
19
Postscript // Fonts need different scaling!
22
/**Style to draw the snapping grid*/
30
QgsComposition( QgsMapRenderer* mapRenderer );
33
/**Changes size of paper item*/
34
void setPaperSize( double width, double height );
36
/**Returns height of paper item*/
37
double paperHeight() const;
39
/**Returns width of paper item*/
40
double paperWidth() const;
42
void setSnapToGridEnabled( bool b );
43
bool snapToGridEnabled() const;
45
void setSnapGridResolution( double r );
46
double snapGridResolution() const;
48
void setSnapGridOffsetX( double offset );
49
double snapGridOffsetX() const;
51
void setSnapGridOffsetY( double offset );
52
double snapGridOffsetY() const;
54
void setGridPen( const QPen& p );
55
const QPen& gridPen() const;
57
void setGridStyle( GridStyle s );
58
GridStyle gridStyle() const;
60
/**Returns the topmose composer item. Ignores mPaperItem*/
61
QgsComposerItem* composerItemAt( const QPointF & position );
63
QList<QgsComposerItem*> selectedComposerItems();
65
/**Returns pointers to all composer maps in the scene*/
66
//todo: needs a new mapping for QList<const T*> ?
67
//QList<const QgsComposerMap*> composerMapItems() const;
69
/**Returns the composer map with specified id
70
@return id or 0 pointer if the composer map item does not exist*/
71
const QgsComposerMap* getComposerMapById( int id ) const;
73
int printResolution() const;
74
void setPrintResolution( int dpi );
76
bool printAsRaster() const;
77
void setPrintAsRaster(bool enabled);
79
/**Returns pointer to map renderer of qgis map canvas*/
80
QgsMapRenderer* mapRenderer();
82
QgsComposition::PlotStyle plotStyle();
83
void setPlotStyle( QgsComposition::PlotStyle style );
85
/**Returns the pixel font size for a font that has point size set.
86
The result depends on the resolution (dpi) and of the preview mode. Each item that sets
87
a font should call this function before drawing text*/
88
int pixelFontSize( double pointSize ) const;
90
/**Does the inverse calculation and returns points for pixels (equals to mm in QgsComposition)*/
91
double pointFontSize( int pixelSize ) const;
93
/**Writes settings to xml (paper dimension)*/
94
bool writeXML( QDomElement& composerElem, QDomDocument& doc );
96
/**Reads settings from xml file*/
97
bool readXML( const QDomElement& compositionElem, const QDomDocument& doc );
99
/**Adds item to z list. Usually called from constructor of QgsComposerItem*/
100
void addItemToZList( QgsComposerItem* item );
101
/**Removes item from z list. Usually called from destructor of QgsComposerItem*/
102
void removeItemFromZList( QgsComposerItem* item );
104
//functions to move selected items in hierarchy
105
void raiseSelectedItems();
106
void raiseItem( QgsComposerItem* item );
107
void lowerSelectedItems();
108
void lowerItem( QgsComposerItem* item );
109
void moveSelectedItemsToTop();
110
void moveItemToTop( QgsComposerItem* item );
111
void moveSelectedItemsToBottom();
112
void moveItemToBottom( QgsComposerItem* item );
114
//functions to align selected items
115
void alignSelectedItemsLeft();
116
void alignSelectedItemsHCenter();
117
void alignSelectedItemsRight();
118
void alignSelectedItemsTop();
119
void alignSelectedItemsVCenter();
120
void alignSelectedItemsBottom();
122
/**Sorts the zList. The only time where this function needs to be called is from QgsComposer
123
after reading all the items from xml file*/
126
/**Snaps a scene coordinate point to grid*/
127
QPointF snapPointToGrid( const QPointF& scenePoint ) const;