Skip to content
Permalink
Browse files

Merge atlas branch

  • Loading branch information
mhugent committed Oct 6, 2012
2 parents f1c9955 + e54e917 commit 68494068dae0b03a692047b17159049198acba47
Showing with 2,807 additions and 209 deletions.
  1. +63 −0 python/core/composer/qgsatlascomposition.sip
  2. +3 −0 python/core/composer/qgscomposerlabel.sip
  3. +32 −10 python/core/composer/qgscomposition.sip
  4. +1 −0 python/core/core.sip
  5. +12 −1 python/core/qgsexpression.sip
  6. +12 −0 resources/function_help/$feature-en_US
  7. +12 −0 resources/function_help/$numfeatures-en_US
  8. +12 −0 resources/function_help/$numpages-en_US
  9. +12 −0 resources/function_help/$page-en_US
  10. +2 −0 src/app/CMakeLists.txt
  11. +288 −0 src/app/composer/qgsatlascompositionwidget.cpp
  12. +60 −0 src/app/composer/qgsatlascompositionwidget.h
  13. +488 −67 src/app/composer/qgscomposer.cpp
  14. +5 −0 src/app/composer/qgscomposer.h
  15. +29 −0 src/app/composer/qgscomposerlabelwidget.cpp
  16. +1 −0 src/app/composer/qgscomposerlabelwidget.h
  17. +12 −0 src/app/composer/qgscomposermapwidget.cpp
  18. +7 −4 src/app/composer/qgscomposermapwidget.h
  19. +2 −0 src/core/CMakeLists.txt
  20. +337 −0 src/core/composer/qgsatlascomposition.cpp
  21. +116 −0 src/core/composer/qgsatlascomposition.h
  22. +1 −0 src/core/composer/qgscomposeritem.h
  23. +21 −5 src/core/composer/qgscomposerlabel.cpp
  24. +10 −0 src/core/composer/qgscomposerlabel.h
  25. +4 −3 src/core/composer/qgscomposermap.cpp
  26. +2 −1 src/core/composer/qgscomposermap.h
  27. +65 −15 src/core/composer/qgscomposition.cpp
  28. +23 −3 src/core/composer/qgscomposition.h
  29. +107 −9 src/core/qgsexpression.cpp
  30. +19 −1 src/core/qgsexpression.h
  31. +16 −4 src/core/qgsexpressionparser.yy
  32. +7 −7 src/gui/qgscomposerview.cpp
  33. +18 −2 src/gui/qgsexpressionbuilderwidget.cpp
  34. +198 −0 src/ui/qgsatlascompositionwidgetbase.ui
  35. +18 −11 src/ui/qgscomposerlabelwidgetbase.ui
  36. +5 −5 src/ui/qgscomposerlegendwidgetbase.ui
  37. +64 −61 src/ui/qgscomposermapwidgetbase.ui
  38. +2 −0 tests/src/core/CMakeLists.txt
  39. +227 −0 tests/src/core/testqgsatlascomposition.cpp
  40. +181 −0 tests/src/core/testqgscomposerlabel.cpp
  41. +27 −0 tests/src/core/testqgsexpression.cpp
  42. +2 −0 tests/src/python/CMakeLists.txt
  43. +169 −0 tests/src/python/test_qgsatlascomposition.py
  44. +113 −0 tests/src/python/test_qgscomposerlabel.py
  45. BIN tests/testdata/control_images/expected_composermapatlas/autoscale_0.png
  46. BIN tests/testdata/control_images/expected_composermapatlas/autoscale_1.png
  47. BIN tests/testdata/control_images/expected_composermapatlas/fixedscale_0.png
  48. BIN tests/testdata/control_images/expected_composermapatlas/fixedscale_1.png
  49. BIN tests/testdata/control_images/expected_composermapatlas/hiding_0.png
  50. BIN tests/testdata/control_images/expected_composermapatlas/hiding_1.png
  51. BIN tests/testdata/france_parts.dbf
  52. +1 −0 tests/testdata/france_parts.prj
  53. +1 −0 tests/testdata/france_parts.qpj
  54. BIN tests/testdata/france_parts.shp
  55. BIN tests/testdata/france_parts.shx
@@ -0,0 +1,63 @@
/** \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 QgsAtlasComposition : public QObject
{
%TypeHeaderCode
#include <qgsatlascomposition.h>
%End

public:
QgsAtlasComposition( QgsComposition* composition );
~QgsAtlasComposition();

/** Is the atlas generation enabled ? */
bool enabled() const;
void setEnabled( bool e );

QgsComposerMap* composerMap() const;
void setComposerMap( QgsComposerMap* map );

bool hideCoverage() const;
void setHideCoverage( bool hide );

bool fixedScale() const;
void setFixedScale( bool fixed );

float margin() const;
void setMargin( float margin );

QString filenamePattern() const;
void setFilenamePattern( const QString& pattern );

QgsVectorLayer* coverageLayer() const;
void setCoverageLayer( QgsVectorLayer* lmap );

bool singleFile() const;
void setSingleFile( bool single );

/** Begins the rendering. */
void beginRender();
/** Ends the rendering. Restores original extent */
void endRender();

/** 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;

void writeXML( QDomElement& elem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem, const QDomDocument& doc );

QgsComposition* composition();

signals:
/** emitted when one of the parameters changes */
void parameterChanged();
};
@@ -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<QString, QVariant> substitutions = QMap<QString, QVariant>() );

QFont font() const;
void setFont( const QFont& f );
/** Accessor for the vertical alignment of the label
@@ -4,11 +4,12 @@
* them in a list in ascending z-Order. This list can be changed to lower/raise items one position
* or to bring them to front/back.
* */
class QgsComposition: QGraphicsScene
class QgsComposition : QGraphicsScene
{
%TypeHeaderCode
#include <qgscomposition.h>
%End

public:

/** \brief Plot type */
@@ -67,20 +68,27 @@ class QgsComposition: QGraphicsScene
/**Returns pointer to undo/redo command storage*/
QUndoStack* undoStack();

/**Returns the topmose composer item. Ignores mPaperItem*/
/**Returns the topmost 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<QgsComposerItem*> selectedComposerItems();

/**Returns pointers to all composer maps in the scene*/
//todo: needs a new mapping for QList<const T*> ?
// QList<const QgsComposerMap*> composerMapItems() const;
%If (QLISTCONSTPTR_CONVERSION)
QList<const QgsComposerMap*> composerMapItems() const;
%End

/**Return composer items of a specific type*/
// template<class T> void composerItems( QList<T*>& itemList );

/**Returns the composer map with specified id
@return id or 0 pointer if the composer map item does not exist*/
@return QgsComposerMap or 0 pointer if the composer map item does not exist*/
const QgsComposerMap* getComposerMapById( int id ) const;

/*Returns the composer html with specified id (a string as named in the
@@ -111,7 +119,7 @@ class QgsComposition: QGraphicsScene
/**Returns pointer to map renderer of qgis map canvas*/
QgsMapRenderer* mapRenderer();

QgsComposition::PlotStyle plotStyle();
QgsComposition::PlotStyle plotStyle() const;
void setPlotStyle( QgsComposition::PlotStyle style );

/**Returns the pixel font size for a font that has point size set.
@@ -140,8 +148,13 @@ class QgsComposition: QGraphicsScene
@param doc xml document
@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
@param addUndoCommands insert AddItem commands if true (e.g. for copy/paste)
@param pos item position. Optional, take position from xml if 0*/
//void addItemsFromXML( const QDomElement& elem, const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore, bool addUndoCommands = false, QPointF* pos = 0 );
@param pos item position. Optional, take position from xml if 0
@note not available in python bindings
*/
/*
void addItemsFromXML( const QDomElement& elem, const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore = 0,
bool addUndoCommands = false, QPointF* pos = 0 );
*/

/**Adds item to z list. Usually called from constructor of QgsComposerItem*/
void addItemToZList( QgsComposerItem* item );
@@ -192,7 +205,7 @@ class QgsComposition: QGraphicsScene
/**Removes multi frame (but does not delete it)*/
void removeMultiFrame( QgsComposerMultiFrame* multiFrame );
/**Adds an arrow item to the graphics scene and advices composer to create a widget for it (through signal)*/
//void addComposerArrow( QgsComposerArrow* arrow );
void addComposerArrow( QgsComposerArrow* arrow );
/**Adds label to the graphics scene and advices composer to create a widget for it (through signal)*/
void addComposerLabel( QgsComposerLabel* label );
/**Adds map to the graphics scene and advices composer to create a widget for it (through signal)*/
@@ -219,10 +232,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 );
@@ -98,6 +98,7 @@
%Include composer/qgscomposershape.sip
%Include composer/qgscomposertable.sip
%Include composer/qgscomposition.sip
%Include composer/qgsatlascomposition.sip
%Include composer/qgsdoubleboxscalebarstyle.sip
%Include composer/qgslegendmodel.sip
%Include composer/qgsnumericscalebarstyle.sip
@@ -43,6 +43,13 @@ class QgsExpression
//! Return the number used for $rownum special column
int currentRowNumber();

//! Assign a special column
static void setSpecialColumn( const QString& name, QVariant value );
//! Unset a special column
static void unsetSpecialColumn( const QString& name );
//! Return the value of the given special column or a null QVariant if undefined
static QVariant specialColumn( const QString& name );

void setScale( double scale );

int scale();
@@ -64,7 +71,6 @@ class QgsExpression
static QString replaceExpressionText( QString action, QgsFeature &feat,
QgsVectorLayer* layer,
const QMap<QString, QVariant> *substitutionMap = 0 );

//

enum UnaryOperator
@@ -141,6 +147,11 @@ class QgsExpression
*/
static int functionCount();

/**
* Returns a list of special Column definitions
*/
static QList<QgsExpression::FunctionDef> specialColumns();

//! return quoted column reference (in double quotes)
static QString quotedColumnRef( QString name );
//! return quoted string (in single quotes)
@@ -0,0 +1,12 @@
<h3>$feature function</h3>
In atlas generation, returns the current feature number that is iterated over on the coverage layer.

<h4>Syntax</h4>
<pre>$feature</pre>

<h4>Arguments</h4>
None

<h4>Example</h4>
<pre>$feature &rarr; 2</pre>

@@ -0,0 +1,12 @@
<h3>$numfeatures function</h3>
In atlas generation, returns the total number of features within the coverage layer.

<h4>Syntax</h4>
<pre>$numfeatures</pre>

<h4>Arguments</h4>
None

<h4>Example</h4>
<pre>$numfeatures &rarr; 42</pre>

@@ -0,0 +1,12 @@
<h3>$numpages function</h3>
Returns the total number of pages in the composition.

<h4>Syntax</h4>
<pre>$numpages</pre>

<h4>Arguments</h4>
None

<h4>Example</h4>
<pre>$numpages &rarr; 42</pre>

@@ -0,0 +1,12 @@
<h3>$page function</h3>
Returns the current page number within a composition.

<h4>Syntax</h4>
<pre>$page</pre>

<h4>Arguments</h4>
None

<h4>Example</h4>
<pre>$page &rarr; 2</pre>

@@ -126,6 +126,7 @@ SET(QGIS_APP_SRCS
composer/qgscomposerlegendlayersdialog.cpp
composer/qgscomposerlegendwidget.cpp
composer/qgscompositionwidget.cpp
composer/qgsatlascompositionwidget.cpp
composer/qgsitempositiondialog.cpp

legend/qgslegendgroup.cpp
@@ -268,6 +269,7 @@ SET (QGIS_APP_MOC_HDRS
composer/qgscomposertablewidget.h
composer/qgscomposershapewidget.h
composer/qgscompositionwidget.h
composer/qgsatlascompositionwidget.h
composer/qgsitempositiondialog.h

legend/qgslegend.h

0 comments on commit 6849406

Please sign in to comment.
You can’t perform that action at this time.