From 2aa566d316f5c2d3bc5dde030e0ade2b9c588cec Mon Sep 17 00:00:00 2001 From: Hugo Mercier Date: Tue, 2 Oct 2012 14:27:42 +0200 Subject: [PATCH] Add/Fix SIP for QgsComposition, QgsComposerMap and QgsAtlasRendering --- python/core/composer/qgscomposerlabel.sip | 3 ++ python/core/composer/qgscomposermap.sip | 20 ++++++++++ python/core/composer/qgscomposition.sip | 48 ++++++++++++++++++++++- 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/python/core/composer/qgscomposerlabel.sip b/python/core/composer/qgscomposerlabel.sip index f5a5dc066bc..225c3c32a44 100644 --- a/python/core/composer/qgscomposerlabel.sip +++ b/python/core/composer/qgscomposerlabel.sip @@ -26,6 +26,9 @@ class QgsComposerLabel : QgsComposerItem @note this function was added in version 1.2*/ QString displayText() const; + /** Sets the current feature, the current layer and a list of local variable substitutions for evaluating expressions */ + void setExpressionContext( QgsFeature* feature, QgsVectorLayer* layer, QMap substitutions = QMap() ); + QFont font() const; void setFont( const QFont& f ); /** Accessor for the vertical alignment of the label diff --git a/python/core/composer/qgscomposermap.sip b/python/core/composer/qgscomposermap.sip index fcc5a81113b..7d4b2bab0bd 100644 --- a/python/core/composer/qgscomposermap.sip +++ b/python/core/composer/qgscomposermap.sip @@ -285,9 +285,29 @@ class QgsComposerMap : QgsComposerItem Usually, this function is called before adding the composer map to the composition*/ void assignFreeId(); + bool atlasHideCoverage() const; + void setAtlasHideCoverage( bool hide ); + + bool atlasFixedScale() const; + void setAtlasFixedScale( bool fixed ); + + float atlasMargin() const; + void setAtlasMargin( float margin ); + + QString atlasFilenamePattern() const; + void setAtlasFilenamePattern( const QString& pattern ); + + QgsVectorLayer* atlasCoverageLayer() const; + void setAtlasCoverageLayer( QgsVectorLayer* lmap ); + + bool atlasSingleFile() const; + void setAtlasSingleFile( bool single ); + signals: void extentChanged(); + void atlasCoverageLayerChanged( QgsVectorLayer* ); + public slots: /**Called if map canvas has changed*/ diff --git a/python/core/composer/qgscomposition.sip b/python/core/composer/qgscomposition.sip index 6e9150f025b..13585f68d10 100644 --- a/python/core/composer/qgscomposition.sip +++ b/python/core/composer/qgscomposition.sip @@ -1,3 +1,31 @@ +/** \ingroup MapComposer + * Class used to render an Atlas, iterating over geometry features. + * prepareForFeature() modifies the atlas map's extent to zoom on the given feature. + * This class is used for printing, exporting to PDF and images. + * */ +class QgsAtlasRendering +{ +%TypeHeaderCode +#include +%End + public: + QgsAtlasRendering( QgsComposition* composition ); + + /** Begins the rendering. Sets an optional output filename pattern */ + void begin( const QString& filenamePattern = "" ); + /** Ends the rendering. Restores original extent*/ + void end(); + + /** Returns the number of features in the coverage layer */ + size_t numFeatures() const; + + /** Prepare the atlas map for the given feature. Sets the extent and context variables */ + void prepareForFeature( size_t i ); + + /** Returns the current filename. Must be called after prepareForFeature( i ) */ + const QString& currentFilename() const; +}; + /** \ingroup MapComposer * Graphics scene for map printing. The class manages the paper item which always * is the item in the back (z-value 0). It maintains the z-Values of the items and stores @@ -70,6 +98,12 @@ class QgsComposition: QGraphicsScene /**Returns the topmose composer item. Ignores mPaperItem*/ QgsComposerItem* composerItemAt( const QPointF & position ); + /** Returns the page number (0-bsaed) given a coordinate */ + int pageNumberAt( const QPointF& position ) const; + + /** Returns on which page number (0-based) is displayed an item */ + int itemPageNumber( const QgsComposerItem* ) const; + QList selectedComposerItems(); /**Returns pointers to all composer maps in the scene*/ @@ -111,6 +145,9 @@ class QgsComposition: QGraphicsScene /**Returns pointer to map renderer of qgis map canvas*/ QgsMapRenderer* mapRenderer(); + QgsComposerMap* atlasMap(); + void setAtlasMap( QgsComposerMap* map ); + QgsComposition::PlotStyle plotStyle(); void setPlotStyle( QgsComposition::PlotStyle style ); @@ -219,10 +256,19 @@ class QgsComposition: QGraphicsScene //printing - void exportAsPDF( const QString& file ); + /** Prepare the printer for printing */ + void beginPrint( QPrinter& printer ); + /** Prepare the printer for printing in a PDF */ + void beginPrintAsPDF( QPrinter& printer, const QString& file ); + /** Print on a preconfigured printer */ + void doPrint( QPrinter& printer, QPainter& painter ); + /** Convenience function that prepares the printer and prints */ void print( QPrinter &printer ); + /** Convenience function that prepares the printer for printing in PDF and prints */ + void exportAsPDF( const QString& file ); + //! print composer page to image //! If the image does not fit into memory, a null image is returned QImage printPageAsRaster( int page );