QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsmapsettings.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmapsettings.cpp
3  --------------------------------------
4  Date : December 2013
5  Copyright : (C) 2013 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsmapsettings.h"
17 
18 #include "qgsscalecalculator.h"
19 #include "qgsmaprendererjob.h"
20 #include "qgsmaptopixel.h"
21 #include "qgslogger.h"
22 
23 #include "qgscrscache.h"
24 #include "qgsmessagelog.h"
25 #include "qgsmaplayer.h"
26 #include "qgsmaplayerregistry.h"
27 #include "qgsxmlutils.h"
28 
29 
30 Q_GUI_EXPORT extern int qt_defaultDpiX();
31 
32 
34  : mDpi( qt_defaultDpiX() ) // DPI that will be used by default for QImage instances
35  , mSize( QSize( 0, 0 ) )
36  , mExtent()
37  , mRotation( 0.0 )
38  , mProjectionsEnabled( false )
39  , mDestCRS( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId ) // WGS 84
40  , mDatumTransformStore( mDestCRS )
41  , mBackgroundColor( Qt::white )
42  , mSelectionColor( Qt::yellow )
43  , mFlags( Antialiasing | UseAdvancedEffects | DrawLabeling | DrawSelection )
44  , mImageFormat( QImage::Format_ARGB32_Premultiplied )
45  , mValid( false )
46  , mVisibleExtent()
47  , mMapUnitsPerPixel( 1 )
48  , mScale( 1 )
49 {
50  updateDerived();
51 
52  // set default map units - we use WGS 84 thus use degrees
54 }
55 
56 
58 {
59  return mExtent;
60 }
61 
63 {
64  mExtent = extent;
65 
66  updateDerived();
67 }
68 
70 {
71  return mRotation;
72 }
73 
74 void QgsMapSettings::setRotation( double degrees )
75 {
76  if ( mRotation == degrees ) return;
77 
78  mRotation = degrees;
79 
80  // TODO: update extent while keeping scale ?
81  updateDerived();
82 }
83 
84 
86 {
88 
89  if ( extent.isEmpty() || !extent.isFinite() )
90  {
91  mValid = false;
92  return;
93  }
94 
95  // Don't allow zooms where the current extent is so small that it
96  // can't be accurately represented using a double (which is what
97  // currentExtent uses). Excluding 0 avoids a divide by zero and an
98  // infinite loop when rendering to a new canvas. Excluding extents
99  // greater than 1 avoids doing unnecessary calculations.
100 
101  // The scheme is to compare the width against the mean x coordinate
102  // (and height against mean y coordinate) and only allow zooms where
103  // the ratio indicates that there is more than about 12 significant
104  // figures (there are about 16 significant figures in a double).
105 
106  if ( extent.width() > 0 &&
107  extent.height() > 0 &&
108  extent.width() < 1 &&
109  extent.height() < 1 )
110  {
111  // Use abs() on the extent to avoid the case where the extent is
112  // symmetrical about 0.
113  double xMean = ( qAbs( extent.xMinimum() ) + qAbs( extent.xMaximum() ) ) * 0.5;
114  double yMean = ( qAbs( extent.yMinimum() ) + qAbs( extent.yMaximum() ) ) * 0.5;
115 
116  double xRange = extent.width() / xMean;
117  double yRange = extent.height() / yMean;
118 
119  static const double minProportion = 1e-12;
120  if ( xRange < minProportion || yRange < minProportion )
121  {
122  mValid = false;
123  return;
124  }
125  }
126 
127  double myHeight = mSize.height();
128  double myWidth = mSize.width();
129 
130  if ( !myWidth || !myHeight )
131  {
132  mValid = false;
133  return;
134  }
135 
136  // calculate the translation and scaling parameters
137  double mapUnitsPerPixelY = mExtent.height() / myHeight;
138  double mapUnitsPerPixelX = mExtent.width() / myWidth;
139  mMapUnitsPerPixel = mapUnitsPerPixelY > mapUnitsPerPixelX ? mapUnitsPerPixelY : mapUnitsPerPixelX;
140 
141  // calculate the actual extent of the mapCanvas
142  double dxmin = mExtent.xMinimum(), dxmax = mExtent.xMaximum(),
143  dymin = mExtent.yMinimum(), dymax = mExtent.yMaximum(), whitespace;
144 
145  if ( mapUnitsPerPixelY > mapUnitsPerPixelX )
146  {
147  whitespace = (( myWidth * mMapUnitsPerPixel ) - mExtent.width() ) * 0.5;
148  dxmin -= whitespace;
149  dxmax += whitespace;
150  }
151  else
152  {
153  whitespace = (( myHeight * mMapUnitsPerPixel ) - mExtent.height() ) * 0.5;
154  dymin -= whitespace;
155  dymax += whitespace;
156  }
157 
158  mVisibleExtent.set( dxmin, dymin, dxmax, dymax );
159 
160  // update the scale
163 
165  visibleExtent().center().x(),
166  visibleExtent().center().y(),
167  outputSize().width(),
168  outputSize().height(),
169  mRotation );
170 
171 #if 1 // set visible extent taking rotation in consideration
172  if ( mRotation )
173  {
174  QgsPoint p1 = mMapToPixel.toMapCoordinates( QPoint( 0, 0 ) );
175  QgsPoint p2 = mMapToPixel.toMapCoordinates( QPoint( 0, myHeight ) );
176  QgsPoint p3 = mMapToPixel.toMapCoordinates( QPoint( myWidth, 0 ) );
177  QgsPoint p4 = mMapToPixel.toMapCoordinates( QPoint( myWidth, myHeight ) );
178  dxmin = std::min( p1.x(), std::min( p2.x(), std::min( p3.x(), p4.x() ) ) );
179  dymin = std::min( p1.y(), std::min( p2.y(), std::min( p3.y(), p4.y() ) ) );
180  dxmax = std::max( p1.x(), std::max( p2.x(), std::max( p3.x(), p4.x() ) ) );
181  dymax = std::max( p1.y(), std::max( p2.y(), std::max( p3.y(), p4.y() ) ) );
182  mVisibleExtent.set( dxmin, dymin, dxmax, dymax );
183  }
184 #endif
185 
186  QgsDebugMsg( QString( "Map units per pixel (x,y) : %1, %2" ).arg( qgsDoubleToString( mapUnitsPerPixelX ) ).arg( qgsDoubleToString( mapUnitsPerPixelY ) ) );
187  QgsDebugMsg( QString( "Pixmap dimensions (x,y) : %1, %2" ).arg( qgsDoubleToString( mSize.width() ) ).arg( qgsDoubleToString( mSize.height() ) ) );
188  QgsDebugMsg( QString( "Extent dimensions (x,y) : %1, %2" ).arg( qgsDoubleToString( mExtent.width() ) ).arg( qgsDoubleToString( mExtent.height() ) ) );
190  QgsDebugMsg( QString( "Adjusted map units per pixel (x,y) : %1, %2" ).arg( qgsDoubleToString( mVisibleExtent.width() / myWidth ) ).arg( qgsDoubleToString( mVisibleExtent.height() / myHeight ) ) );
191  QgsDebugMsg( QString( "Recalced pixmap dimensions (x,y) : %1, %2" ).arg( qgsDoubleToString( mVisibleExtent.width() / mMapUnitsPerPixel ) ).arg( qgsDoubleToString( mVisibleExtent.height() / mMapUnitsPerPixel ) ) );
192  QgsDebugMsg( QString( "Scale (assuming meters as map units) = 1:%1" ).arg( qgsDoubleToString( mScale ) ) );
193  QgsDebugMsg( QString( "Rotation: %1 degrees" ).arg( mRotation ) );
194 
195  mValid = true;
196 }
197 
198 
200 {
201  return mSize;
202 }
203 
205 {
206  mSize = size;
207 
208  updateDerived();
209 }
210 
212 {
213  return mDpi;
214 }
215 
217 {
218  mDpi = dpi;
219 
220  updateDerived();
221 }
222 
223 
224 QStringList QgsMapSettings::layers() const
225 {
226  return mLayers;
227 }
228 
229 void QgsMapSettings::setLayers( const QStringList& layers )
230 {
231  mLayers = layers;
232 }
233 
234 QMap<QString, QString> QgsMapSettings::layerStyleOverrides() const
235 {
236  return mLayerStyleOverrides;
237 }
238 
239 void QgsMapSettings::setLayerStyleOverrides( const QMap<QString, QString>& overrides )
240 {
241  mLayerStyleOverrides = overrides;
242 }
243 
245 {
246  mProjectionsEnabled = enabled;
247 }
248 
250 {
251  return mProjectionsEnabled;
252 }
253 
254 
256 {
257  mDestCRS = crs;
259 }
260 
262 {
263  return mDestCRS;
264 }
265 
266 
268 {
270 
271  // Since the map units have changed, force a recalculation of the scale.
272  updateDerived();
273 }
274 
275 void QgsMapSettings::setFlags( QgsMapSettings::Flags flags )
276 {
277  mFlags = flags;
278 }
279 
281 {
282  if ( on )
283  mFlags |= flag;
284  else
285  mFlags &= ~flag;
286 }
287 
288 QgsMapSettings::Flags QgsMapSettings::flags() const
289 {
290  return mFlags;
291 }
292 
294 {
295  return mFlags.testFlag( flag );
296 }
297 
299 {
300  return mScaleCalculator.mapUnits();
301 }
302 
303 
305 {
306  return mValid;
307 }
308 
310 {
311  return mVisibleExtent;
312 }
313 
315 {
316  return mMapUnitsPerPixel;
317 }
318 
319 double QgsMapSettings::scale() const
320 {
321  return mScale;
322 }
323 
324 
325 
326 
327 
329 {
330  return mDatumTransformStore.transformation( layer );
331 }
332 
333 
334 
336 {
337  if ( hasCrsTransformEnabled() )
338  {
339  try
340  {
341  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
342  {
343  QgsDebugMsg( QString( "sourceCrs = " + ct->sourceCrs().authid() ) );
344  QgsDebugMsg( QString( "destCRS = " + ct->destCRS().authid() ) );
345  QgsDebugMsg( QString( "extent = " + extent.toString() ) );
346  extent = ct->transformBoundingBox( extent );
347  }
348  }
349  catch ( QgsCsException &cse )
350  {
351  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
352  }
353  }
354 
355  QgsDebugMsg( QString( "proj extent = " + extent.toString() ) );
356 
357  return extent;
358 }
359 
360 
362 {
363  if ( hasCrsTransformEnabled() )
364  {
365  try
366  {
367  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
368  {
369  QgsDebugMsg( QString( "sourceCrs = " + ct->sourceCrs().authid() ) );
370  QgsDebugMsg( QString( "destCRS = " + ct->destCRS().authid() ) );
371  QgsDebugMsg( QString( "extent = " + extent.toString() ) );
372  extent = ct->transformBoundingBox( extent, QgsCoordinateTransform::ReverseTransform );
373  }
374  }
375  catch ( QgsCsException &cse )
376  {
377  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
378  }
379  }
380 
381  QgsDebugMsg( QString( "proj extent = " + extent.toString() ) );
382 
383  return extent;
384 }
385 
386 
388 {
389  if ( hasCrsTransformEnabled() )
390  {
391  try
392  {
393  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
394  point = ct->transform( point, QgsCoordinateTransform::ForwardTransform );
395  }
396  catch ( QgsCsException &cse )
397  {
398  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
399  }
400  }
401  else
402  {
403  // leave point without transformation
404  }
405  return point;
406 }
407 
408 
410 {
411  if ( hasCrsTransformEnabled() )
412  {
413  try
414  {
415  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
416  rect = ct->transform( rect, QgsCoordinateTransform::ForwardTransform );
417  }
418  catch ( QgsCsException &cse )
419  {
420  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
421  }
422  }
423  else
424  {
425  // leave point without transformation
426  }
427  return rect;
428 }
429 
430 
432 {
433  if ( hasCrsTransformEnabled() )
434  {
435  try
436  {
437  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
438  point = ct->transform( point, QgsCoordinateTransform::ReverseTransform );
439  }
440  catch ( QgsCsException &cse )
441  {
442  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
443  }
444  }
445  else
446  {
447  // leave point without transformation
448  }
449  return point;
450 }
451 
452 
454 {
455  if ( hasCrsTransformEnabled() )
456  {
457  try
458  {
459  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
460  rect = ct->transform( rect, QgsCoordinateTransform::ReverseTransform );
461  }
462  catch ( QgsCsException &cse )
463  {
464  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
465  }
466  }
467  return rect;
468 }
469 
470 
471 
473 {
474  QgsDebugMsg( "called." );
476 
477  // reset the map canvas extent since the extent may now be smaller
478  // We can't use a constructor since QgsRectangle normalizes the rectangle upon construction
480  fullExtent.setMinimal();
481 
482  // iterate through the map layers and test each layers extent
483  // against the current min and max values
484  QStringList::const_iterator it = mLayers.begin();
485  QgsDebugMsg( QString( "Layer count: %1" ).arg( mLayers.count() ) );
486  while ( it != mLayers.end() )
487  {
488  QgsMapLayer * lyr = registry->mapLayer( *it );
489  if ( lyr == NULL )
490  {
491  QgsDebugMsg( QString( "WARNING: layer '%1' not found in map layer registry!" ).arg( *it ) );
492  }
493  else
494  {
495  QgsDebugMsg( "Updating extent using " + lyr->name() );
496  QgsDebugMsg( "Input extent: " + lyr->extent().toString() );
497 
498  if ( lyr->extent().isNull() )
499  {
500  ++it;
501  continue;
502  }
503 
504  // Layer extents are stored in the coordinate system (CS) of the
505  // layer. The extent must be projected to the canvas CS
507 
508  QgsDebugMsg( "Output extent: " + extent.toString() );
509  fullExtent.unionRect( extent );
510 
511  }
512  ++it;
513  }
514 
515  if ( fullExtent.width() == 0.0 || fullExtent.height() == 0.0 )
516  {
517  // If all of the features are at the one point, buffer the
518  // rectangle a bit. If they are all at zero, do something a bit
519  // more crude.
520 
521  if ( fullExtent.xMinimum() == 0.0 && fullExtent.xMaximum() == 0.0 &&
522  fullExtent.yMinimum() == 0.0 && fullExtent.yMaximum() == 0.0 )
523  {
524  fullExtent.set( -1.0, -1.0, 1.0, 1.0 );
525  }
526  else
527  {
528  const double padFactor = 1e-8;
529  double widthPad = fullExtent.xMinimum() * padFactor;
530  double heightPad = fullExtent.yMinimum() * padFactor;
531  double xmin = fullExtent.xMinimum() - widthPad;
532  double xmax = fullExtent.xMaximum() + widthPad;
533  double ymin = fullExtent.yMinimum() - heightPad;
534  double ymax = fullExtent.yMaximum() + heightPad;
535  fullExtent.set( xmin, ymin, xmax, ymax );
536  }
537  }
538 
539  QgsDebugMsg( "Full extent: " + fullExtent.toString() );
540  return fullExtent;
541 }
542 
543 
544 void QgsMapSettings::readXML( QDomNode& theNode )
545 {
546  // set units
547  QDomNode mapUnitsNode = theNode.namedItem( "units" );
548  QGis::UnitType units = QgsXmlUtils::readMapUnits( mapUnitsNode.toElement() );
549  setMapUnits( units );
550 
551  // set projections flag
552  QDomNode projNode = theNode.namedItem( "projections" );
553  setCrsTransformEnabled( projNode.toElement().text().toInt() );
554 
555  // set destination CRS
557  QDomNode srsNode = theNode.namedItem( "destinationsrs" );
558  srs.readXML( srsNode );
559  setDestinationCrs( srs );
560 
561  // set extent
562  QDomNode extentNode = theNode.namedItem( "extent" );
563  QgsRectangle aoi = QgsXmlUtils::readRectangle( extentNode.toElement() );
564  setExtent( aoi );
565 
566  // set rotation
567  QDomNode rotationNode = theNode.namedItem( "rotation" );
568  QString rotationVal = rotationNode.toElement().text();
569  if ( ! rotationVal.isEmpty() )
570  {
571  double rot = rotationVal.toDouble();
572  setRotation( rot );
573  }
574 
575  mDatumTransformStore.readXML( theNode );
576 }
577 
578 
579 
580 void QgsMapSettings::writeXML( QDomNode& theNode, QDomDocument& theDoc )
581 {
582  // units
583  theNode.appendChild( QgsXmlUtils::writeMapUnits( mapUnits(), theDoc ) );
584 
585  // Write current view extents
586  theNode.appendChild( QgsXmlUtils::writeRectangle( extent(), theDoc ) );
587 
588  // Write current view rotation
589  QDomElement rotNode = theDoc.createElement( "rotation" );
590  rotNode.appendChild(
591  theDoc.createTextNode( qgsDoubleToString( rotation() ) )
592  );
593  theNode.appendChild( rotNode );
594 
595  // projections enabled
596  QDomElement projNode = theDoc.createElement( "projections" );
597  projNode.appendChild( theDoc.createTextNode( QString::number( hasCrsTransformEnabled() ) ) );
598  theNode.appendChild( projNode );
599 
600  // destination CRS
601  QDomElement srsNode = theDoc.createElement( "destinationsrs" );
602  theNode.appendChild( srsNode );
603  destinationCrs().writeXML( srsNode, theDoc );
604 
605  mDatumTransformStore.writeXML( theNode, theDoc );
606 }
void setMapUnits(QGis::UnitType mapUnits)
Set the map units.
void unionRect(const QgsRectangle &rect)
updates rectangle to include passed argument
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Base class for all map layer types.
Definition: qgsmaplayer.h:49
QgsPoint layerToMapCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from layer's CRS to output CRS
bool isEmpty() const
test if rectangle is empty.
QgsRectangle mVisibleExtent
extent with some additional white space that matches the output aspect ratio
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
QgsMapToPixel mMapToPixel
double scale() const
Return the calculated scale of the map.
void readXML(QDomNode &theNode)
QgsRectangle fullExtent() const
returns current extent of layer set
const QgsCoordinateTransform * layerTransform(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
double yMaximum() const
Get the y maximum value (top side of rectangle)
Definition: qgsrectangle.h:188
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
void setOutputDpi(int dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
UnitType
Map units that qgis supports.
Definition: qgis.h:229
QgsCoordinateReferenceSystem mDestCRS
QMap< QString, QString > mLayerStyleOverrides
static QgsMapLayerRegistry * instance()
Definition: qgssingleton.h:23
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
QMap< QString, QString > layerStyleOverrides() const
Get map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
void setDpi(double dpi)
Set the dpi to be used in scale calculations.
void setDestinationCrs(const QgsCoordinateReferenceSystem &destCrs)
static QDomElement writeRectangle(const QgsRectangle &rect, QDomDocument &doc)
Definition: qgsxmlutils.cpp:96
void setParameters(double mapUnitsPerPixel, double xmin, double ymin, double height)
QGis::UnitType mapUnits() const
Returns current map units.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
QgsRectangle layerExtentToOutputExtent(QgsMapLayer *theLayer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS
Flags flags() const
Return combination of flags used for rendering.
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Set map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
QgsPoint mapToLayerCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from output CRS to layer's CRS
void setLayers(const QStringList &layers)
Set list of layer IDs for map rendering.
Q_GUI_EXPORT int qt_defaultDpiX()
double x() const
Definition: qgspoint.h:126
static void logMessage(QString message, QString tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void set(const QgsPoint &p1, const QgsPoint &p2)
Set the rectangle from two QgsPoints.
const QString & name() const
Get the display name of the layer.
bool mValid
whether the actual settings are valid (set in updateDerived())
int outputDpi() const
Return DPI used for conversion between real world units (e.g.
QgsRectangle mExtent
double calculate(const QgsRectangle &mapExtent, int canvasWidth)
Calculate the scale denominator.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Definition: qgsrectangle.h:193
Flag
Enumeration of flags that adjust the way how map is rendered.
QSize outputSize() const
Return the size of the resulting map image.
double xMaximum() const
Get the x maximum value (right side of rectangle)
Definition: qgsrectangle.h:178
void setRotation(double degrees)
Set the rotation of the resulting map image Units are clockwise degrees.
bool hasValidSettings() const
Check whether the map settings are valid and can be used for rendering.
void setMapUnits(QGis::UnitType u)
Set units of map's geographical coordinates - used for scale calculation.
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void writeXML(QDomNode &parentNode, QDomDocument &theDoc) const
const long GEOCRS_ID
Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id.
Definition: qgis.h:385
double mapUnitsPerPixel() const
Return the distance in geographical coordinates that equals to one pixel in the map.
QGis::UnitType mapUnits() const
Get units of map's geographical coordinates - used for scale calculation.
const QgsCoordinateTransform * transformation(QgsMapLayer *layer) const
will return transform from layer's CRS to current destination CRS.
QgsScaleCalculator mScaleCalculator
A class to represent a point.
Definition: qgspoint.h:63
static QGis::UnitType readMapUnits(const QDomElement &element)
Definition: qgsxmlutils.cpp:9
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a m...
int min(int a, int b)
Definition: util.h:93
QString qgsDoubleToString(const double &a, const int &precision=17)
Definition: qgis.h:317
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
QgsPoint toMapCoordinates(int x, int y) const
QString what() const
Definition: qgsexception.h:35
bool writeXML(QDomNode &theNode, QDomDocument &theDoc) const
double mMapUnitsPerPixel
void readXML(const QDomNode &parentNode)
void setOutputSize(const QSize &size)
Set the size of the resulting map image.
Class for storing a coordinate reference system (CRS)
void setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
QgsRectangle extent() const
Return geographical coordinates of the rectangle that should be rendered.
Class for doing transforms between two map coordinate systems.
double y() const
Definition: qgspoint.h:134
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
Custom exception class for Coordinate Reference System related exceptions.
QStringList mLayers
QgsRectangle outputExtentToLayerExtent(QgsMapLayer *theLayer, QgsRectangle extent) const
transform bounding box from output CRS to layer's CRS
double width() const
Width of the rectangle.
Definition: qgsrectangle.h:198
QgsDatumTransformStore mDatumTransformStore
virtual QgsRectangle extent()
Return the extent of the layer.
double size
Definition: qgssvgcache.cpp:77
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
void setFlags(Flags flags)
Set combination of flags that will be used for rendering.
double xMinimum() const
Get the x minimum value (left side of rectangle)
Definition: qgsrectangle.h:183
int max(int a, int b)
Definition: util.h:87
static QgsRectangle readRectangle(const QDomElement &element)
Definition: qgsxmlutils.cpp:38
double height() const
Height of the rectangle.
Definition: qgsrectangle.h:203
static QDomElement writeMapUnits(QGis::UnitType units, QDomDocument &doc)
Definition: qgsxmlutils.cpp:68
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
void writeXML(QDomNode &theNode, QDomDocument &theDoc)