QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrendercontext.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrendercontext.h
3  ------------------
4  begin : March 16, 2008
5  copyright : (C) 2008 by Marco Hugentobler
6  email : marco dot hugentobler at karto dot baug dot ethz dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSRENDERCONTEXT_H
19 #define QGSRENDERCONTEXT_H
20 
21 #include <QColor>
22 
23 #include "qgscoordinatetransform.h"
24 #include "qgsmaptopixel.h"
25 #include "qgsrectangle.h"
27 
28 class QPainter;
29 
31 class QgsMapSettings;
32 
39 class CORE_EXPORT QgsRenderContext
40 {
41  public:
44 
47  static QgsRenderContext fromMapSettings( const QgsMapSettings& mapSettings );
48 
49  //getters
50 
51  QPainter* painter() {return mPainter;}
52  const QPainter* constPainter() const { return mPainter; }
53 
54  const QgsCoordinateTransform* coordinateTransform() const {return mCoordTransform;}
55 
56  const QgsRectangle& extent() const {return mExtent;}
57 
58  const QgsMapToPixel& mapToPixel() const {return mMapToPixel;}
59 
60  double scaleFactor() const {return mScaleFactor;}
61 
62  double rasterScaleFactor() const {return mRasterScaleFactor;}
63 
64  bool renderingStopped() const {return mRenderingStopped;}
65 
66  bool forceVectorOutput() const {return mForceVectorOutput;}
67 
69  bool useAdvancedEffects() const {return mUseAdvancedEffects;}
71  void setUseAdvancedEffects( bool enabled ) { mUseAdvancedEffects = enabled; }
72 
73  bool drawEditingInformation() const {return mDrawEditingInformation;}
74 
75  double rendererScale() const {return mRendererScale;}
76 
77  QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
78 
79  QColor selectionColor() const { return mSelectionColor; }
80 
87  bool showSelection() const { return mShowSelection; }
88 
89  //setters
90 
92  void setCoordinateTransform( const QgsCoordinateTransform* t );
93  void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;}
94  void setExtent( const QgsRectangle& extent ) {mExtent = extent;}
95  void setDrawEditingInformation( bool b ) {mDrawEditingInformation = b;}
96  void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;}
97  void setScaleFactor( double factor ) {mScaleFactor = factor;}
98  void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;}
99  void setRendererScale( double scale ) {mRendererScale = scale;}
100  void setPainter( QPainter* p ) {mPainter = p;}
101  void setForceVectorOutput( bool force ) {mForceVectorOutput = force;}
102  void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
103  void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
104 
111  void setShowSelection( const bool showSelection ) { mShowSelection = showSelection; }
112 
114  bool useRenderingOptimization() const { return mUseRenderingOptimization; }
115  void setUseRenderingOptimization( bool enabled ) { mUseRenderingOptimization = enabled; }
116 
118  const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
119  void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
120 
121  private:
122 
124  QPainter* mPainter;
125 
127  const QgsCoordinateTransform* mCoordTransform;
128 
130  bool mDrawEditingInformation;
131 
132  QgsRectangle mExtent;
133 
135  bool mForceVectorOutput;
136 
138  bool mUseAdvancedEffects;
139 
140  QgsMapToPixel mMapToPixel;
141 
143  bool mRenderingStopped;
144 
146  double mScaleFactor;
147 
149  double mRasterScaleFactor;
150 
152  double mRendererScale;
153 
155  QgsLabelingEngineInterface* mLabelingEngine;
156 
158  bool mShowSelection;
159 
161  QColor mSelectionColor;
162 
164  bool mUseRenderingOptimization;
165 
167  QgsVectorSimplifyMethod mVectorSimplifyMethod;
168 };
169 
170 #endif