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 
235 {
236  mProjectionsEnabled = enabled;
237 }
238 
240 {
241  return mProjectionsEnabled;
242 }
243 
244 
246 {
247  mDestCRS = crs;
249 }
250 
252 {
253  return mDestCRS;
254 }
255 
256 
258 {
260 
261  // Since the map units have changed, force a recalculation of the scale.
262  updateDerived();
263 }
264 
265 void QgsMapSettings::setFlags( QgsMapSettings::Flags flags )
266 {
267  mFlags = flags;
268 }
269 
271 {
272  if ( on )
273  mFlags |= flag;
274  else
275  mFlags &= ~flag;
276 }
277 
278 QgsMapSettings::Flags QgsMapSettings::flags() const
279 {
280  return mFlags;
281 }
282 
284 {
285  return mFlags.testFlag( flag );
286 }
287 
289 {
290  return mScaleCalculator.mapUnits();
291 }
292 
293 
295 {
296  return mValid;
297 }
298 
300 {
301  return mVisibleExtent;
302 }
303 
305 {
306  return mMapUnitsPerPixel;
307 }
308 
309 double QgsMapSettings::scale() const
310 {
311  return mScale;
312 }
313 
314 
315 
316 
317 
319 {
320  return mDatumTransformStore.transformation( layer );
321 }
322 
323 
324 
326 {
327  if ( hasCrsTransformEnabled() )
328  {
329  try
330  {
331  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
332  {
333  QgsDebugMsg( QString( "sourceCrs = " + ct->sourceCrs().authid() ) );
334  QgsDebugMsg( QString( "destCRS = " + ct->destCRS().authid() ) );
335  QgsDebugMsg( QString( "extent = " + extent.toString() ) );
336  extent = ct->transformBoundingBox( extent );
337  }
338  }
339  catch ( QgsCsException &cse )
340  {
341  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
342  }
343  }
344 
345  QgsDebugMsg( QString( "proj extent = " + extent.toString() ) );
346 
347  return extent;
348 }
349 
350 
352 {
353  if ( hasCrsTransformEnabled() )
354  {
355  try
356  {
357  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
358  {
359  QgsDebugMsg( QString( "sourceCrs = " + ct->sourceCrs().authid() ) );
360  QgsDebugMsg( QString( "destCRS = " + ct->destCRS().authid() ) );
361  QgsDebugMsg( QString( "extent = " + extent.toString() ) );
362  extent = ct->transformBoundingBox( extent, QgsCoordinateTransform::ReverseTransform );
363  }
364  }
365  catch ( QgsCsException &cse )
366  {
367  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
368  }
369  }
370 
371  QgsDebugMsg( QString( "proj extent = " + extent.toString() ) );
372 
373  return extent;
374 }
375 
376 
378 {
379  if ( hasCrsTransformEnabled() )
380  {
381  try
382  {
383  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
384  point = ct->transform( point, QgsCoordinateTransform::ForwardTransform );
385  }
386  catch ( QgsCsException &cse )
387  {
388  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
389  }
390  }
391  else
392  {
393  // leave point without transformation
394  }
395  return point;
396 }
397 
398 
400 {
401  if ( hasCrsTransformEnabled() )
402  {
403  try
404  {
405  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
406  rect = ct->transform( rect, QgsCoordinateTransform::ForwardTransform );
407  }
408  catch ( QgsCsException &cse )
409  {
410  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
411  }
412  }
413  else
414  {
415  // leave point without transformation
416  }
417  return rect;
418 }
419 
420 
422 {
423  if ( hasCrsTransformEnabled() )
424  {
425  try
426  {
427  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
428  point = ct->transform( point, QgsCoordinateTransform::ReverseTransform );
429  }
430  catch ( QgsCsException &cse )
431  {
432  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
433  }
434  }
435  else
436  {
437  // leave point without transformation
438  }
439  return point;
440 }
441 
442 
444 {
445  if ( hasCrsTransformEnabled() )
446  {
447  try
448  {
449  if ( const QgsCoordinateTransform* ct = layerTransform( theLayer ) )
450  rect = ct->transform( rect, QgsCoordinateTransform::ReverseTransform );
451  }
452  catch ( QgsCsException &cse )
453  {
454  QgsMessageLog::logMessage( QString( "Transform error caught: %1" ).arg( cse.what() ), "CRS" );
455  }
456  }
457  return rect;
458 }
459 
460 
461 
463 {
464  QgsDebugMsg( "called." );
466 
467  // reset the map canvas extent since the extent may now be smaller
468  // We can't use a constructor since QgsRectangle normalizes the rectangle upon construction
470  fullExtent.setMinimal();
471 
472  // iterate through the map layers and test each layers extent
473  // against the current min and max values
474  QStringList::const_iterator it = mLayers.begin();
475  QgsDebugMsg( QString( "Layer count: %1" ).arg( mLayers.count() ) );
476  while ( it != mLayers.end() )
477  {
478  QgsMapLayer * lyr = registry->mapLayer( *it );
479  if ( lyr == NULL )
480  {
481  QgsDebugMsg( QString( "WARNING: layer '%1' not found in map layer registry!" ).arg( *it ) );
482  }
483  else
484  {
485  QgsDebugMsg( "Updating extent using " + lyr->name() );
486  QgsDebugMsg( "Input extent: " + lyr->extent().toString() );
487 
488  if ( lyr->extent().isNull() )
489  {
490  ++it;
491  continue;
492  }
493 
494  // Layer extents are stored in the coordinate system (CS) of the
495  // layer. The extent must be projected to the canvas CS
497 
498  QgsDebugMsg( "Output extent: " + extent.toString() );
499  fullExtent.unionRect( extent );
500 
501  }
502  ++it;
503  }
504 
505  if ( fullExtent.width() == 0.0 || fullExtent.height() == 0.0 )
506  {
507  // If all of the features are at the one point, buffer the
508  // rectangle a bit. If they are all at zero, do something a bit
509  // more crude.
510 
511  if ( fullExtent.xMinimum() == 0.0 && fullExtent.xMaximum() == 0.0 &&
512  fullExtent.yMinimum() == 0.0 && fullExtent.yMaximum() == 0.0 )
513  {
514  fullExtent.set( -1.0, -1.0, 1.0, 1.0 );
515  }
516  else
517  {
518  const double padFactor = 1e-8;
519  double widthPad = fullExtent.xMinimum() * padFactor;
520  double heightPad = fullExtent.yMinimum() * padFactor;
521  double xmin = fullExtent.xMinimum() - widthPad;
522  double xmax = fullExtent.xMaximum() + widthPad;
523  double ymin = fullExtent.yMinimum() - heightPad;
524  double ymax = fullExtent.yMaximum() + heightPad;
525  fullExtent.set( xmin, ymin, xmax, ymax );
526  }
527  }
528 
529  QgsDebugMsg( "Full extent: " + fullExtent.toString() );
530  return fullExtent;
531 }
532 
533 
534 void QgsMapSettings::readXML( QDomNode& theNode )
535 {
536  // set units
537  QDomNode mapUnitsNode = theNode.namedItem( "units" );
538  QGis::UnitType units = QgsXmlUtils::readMapUnits( mapUnitsNode.toElement() );
539  setMapUnits( units );
540 
541  // set projections flag
542  QDomNode projNode = theNode.namedItem( "projections" );
543  setCrsTransformEnabled( projNode.toElement().text().toInt() );
544 
545  // set destination CRS
547  QDomNode srsNode = theNode.namedItem( "destinationsrs" );
548  srs.readXML( srsNode );
549  setDestinationCrs( srs );
550 
551  // set extent
552  QDomNode extentNode = theNode.namedItem( "extent" );
553  QgsRectangle aoi = QgsXmlUtils::readRectangle( extentNode.toElement() );
554  setExtent( aoi );
555 
556  // set rotation
557  QDomNode rotationNode = theNode.namedItem( "rotation" );
558  QString rotationVal = rotationNode.toElement().text();
559  if ( ! rotationVal.isEmpty() )
560  {
561  double rot = rotationVal.toDouble();
562  setRotation( rot );
563  }
564 
565  mDatumTransformStore.readXML( theNode );
566 }
567 
568 
569 
570 void QgsMapSettings::writeXML( QDomNode& theNode, QDomDocument& theDoc )
571 {
572  // units
573  theNode.appendChild( QgsXmlUtils::writeMapUnits( mapUnits(), theDoc ) );
574 
575  // Write current view extents
576  theNode.appendChild( QgsXmlUtils::writeRectangle( extent(), theDoc ) );
577 
578  // Write current view rotation
579  QDomElement rotNode = theDoc.createElement( "rotation" );
580  rotNode.appendChild(
581  theDoc.createTextNode( qgsDoubleToString( rotation() ) )
582  );
583  theNode.appendChild( rotNode );
584 
585  // projections enabled
586  QDomElement projNode = theDoc.createElement( "projections" );
587  projNode.appendChild( theDoc.createTextNode( QString::number( hasCrsTransformEnabled() ) ) );
588  theNode.appendChild( projNode );
589 
590  // destination CRS
591  QDomElement srsNode = theDoc.createElement( "destinationsrs" );
592  theNode.appendChild( srsNode );
593  destinationCrs().writeXML( srsNode, theDoc );
594 
595  mDatumTransformStore.writeXML( theNode, theDoc );
596 }
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:48
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
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...
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.
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)