1+ /* * \ingroup MapComposer
2+ * Class used to render an Atlas, iterating over geometry features.
3+ * prepareForFeature() modifies the atlas map's extent to zoom on the given feature.
4+ * This class is used for printing, exporting to PDF and images.
5+ * */
6+ class QgsAtlasRendering
7+ {
8+ public:
9+ QgsAtlasRendering ( QgsComposition* composition );
10+ ~QgsAtlasRendering ();
11+
12+ /* * Begins the rendering. Sets an optional output filename pattern */
13+ void begin ( const QString& filenamePattern = " " );
14+ /* * Ends the rendering. Restores original extent*/
15+ void end ();
16+
17+ /* * Returns the number of features in the coverage layer */
18+ size_t numFeatures () const ;
19+
20+ /* * Prepare the atlas map for the given feature. Sets the extent and context variables */
21+ void prepareForFeature ( size_t i );
22+
23+ /* * Returns the current filename. Must be called after prepareForFeature( i ) */
24+ const QString& currentFilename () const ;
25+ };
26+
127/* * \ingroup MapComposer
228 * Graphics scene for map printing. The class manages the paper item which always
329 * is the item in the back (z-value 0). It maintains the z-Values of the items and stores
430 * them in a list in ascending z-Order. This list can be changed to lower/raise items one position
531 * or to bring them to front/back.
632 * */
7- class QgsComposition : QGraphicsScene
33+ class QgsComposition : QGraphicsScene
834{
935%TypeHeaderCode
1036#include < qgscomposition.h>
1137%End
38+
1239 public:
1340
1441 /* * \brief Plot type */
@@ -67,20 +94,27 @@ class QgsComposition: QGraphicsScene
6794 /* *Returns pointer to undo/redo command storage*/
6895 QUndoStack* undoStack ();
6996
70- /* *Returns the topmose composer item. Ignores mPaperItem*/
97+ /* *Returns the topmost composer item. Ignores mPaperItem*/
7198 QgsComposerItem* composerItemAt ( const QPointF & position );
7299
100+ /* * Returns the page number (0-bsaed) given a coordinate */
101+ int pageNumberAt ( const QPointF& position ) const ;
102+
103+ /* * Returns on which page number (0-based) is displayed an item */
104+ int itemPageNumber ( const QgsComposerItem* ) const ;
105+
73106 QList<QgsComposerItem*> selectedComposerItems ();
74107
75108 /* *Returns pointers to all composer maps in the scene*/
76- // todo: needs a new mapping for QList<const T*> ?
77- // QList<const QgsComposerMap*> composerMapItems() const;
109+ %If (QLISTCONSTPTR_CONVERSION )
110+ QList<const QgsComposerMap*> composerMapItems () const ;
111+ %End
78112
79113 /* *Return composer items of a specific type*/
80114 // template<class T> void composerItems( QList<T*>& itemList );
81115
82116 /* *Returns the composer map with specified id
83- @return id or 0 pointer if the composer map item does not exist*/
117+ @return QgsComposerMap or 0 pointer if the composer map item does not exist*/
84118 const QgsComposerMap* getComposerMapById ( int id ) const ;
85119
86120 /* Returns the composer html with specified id (a string as named in the
@@ -111,7 +145,10 @@ class QgsComposition: QGraphicsScene
111145 /* *Returns pointer to map renderer of qgis map canvas*/
112146 QgsMapRenderer* mapRenderer ();
113147
114- QgsComposition::PlotStyle plotStyle ();
148+ QgsComposerMap* atlasMap ();
149+ void setAtlasMap ( QgsComposerMap* map );
150+
151+ QgsComposition::PlotStyle plotStyle () const ;
115152 void setPlotStyle ( QgsComposition::PlotStyle style );
116153
117154 /* *Returns the pixel font size for a font that has point size set.
@@ -140,8 +177,13 @@ class QgsComposition: QGraphicsScene
140177 @param doc xml document
141178 @param mapsToRestore for reading from project file: set preview move 'rectangle' to all maps and save the preview states to show composer maps on demand
142179 @param addUndoCommands insert AddItem commands if true (e.g. for copy/paste)
143- @param pos item position. Optional, take position from xml if 0*/
144- // void addItemsFromXML( const QDomElement& elem, const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore, bool addUndoCommands = false, QPointF* pos = 0 );
180+ @param pos item position. Optional, take position from xml if 0
181+ @note not available in python bindings
182+ */
183+ /*
184+ void addItemsFromXML( const QDomElement& elem, const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore = 0,
185+ bool addUndoCommands = false, QPointF* pos = 0 );
186+ */
145187
146188 /* *Adds item to z list. Usually called from constructor of QgsComposerItem*/
147189 void addItemToZList ( QgsComposerItem* item );
@@ -192,7 +234,7 @@ class QgsComposition: QGraphicsScene
192234 /* *Removes multi frame (but does not delete it)*/
193235 void removeMultiFrame ( QgsComposerMultiFrame* multiFrame );
194236 /* *Adds an arrow item to the graphics scene and advices composer to create a widget for it (through signal)*/
195- // void addComposerArrow( QgsComposerArrow* arrow );
237+ void addComposerArrow ( QgsComposerArrow* arrow );
196238 /* *Adds label to the graphics scene and advices composer to create a widget for it (through signal)*/
197239 void addComposerLabel ( QgsComposerLabel* label );
198240 /* *Adds map to the graphics scene and advices composer to create a widget for it (through signal)*/
@@ -219,10 +261,19 @@ class QgsComposition: QGraphicsScene
219261
220262 // printing
221263
222- void exportAsPDF ( const QString& file );
264+ /* * Prepare the printer for printing */
265+ void beginPrint ( QPrinter& printer );
266+ /* * Prepare the printer for printing in a PDF */
267+ void beginPrintAsPDF ( QPrinter& printer, const QString& file );
268+ /* * Print on a preconfigured printer */
269+ void doPrint ( QPrinter& printer, QPainter& painter );
223270
271+ /* * Convenience function that prepares the printer and prints */
224272 void print ( QPrinter &printer );
225273
274+ /* * Convenience function that prepares the printer for printing in PDF and prints */
275+ void exportAsPDF ( const QString& file );
276+
226277 // ! print composer page to image
227278 // ! If the image does not fit into memory, a null image is returned
228279 QImage printPageAsRaster ( int page );
0 commit comments