QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
70  bool useAdvancedEffects() const {return mUseAdvancedEffects;}
73  void setUseAdvancedEffects( bool enabled ) { mUseAdvancedEffects = enabled; }
74 
75  bool drawEditingInformation() const {return mDrawEditingInformation;}
76 
77  double rendererScale() const {return mRendererScale;}
78 
80  QgsLabelingEngineInterface* labelingEngine() const { return mLabelingEngine; }
81 
83  QColor selectionColor() const { return mSelectionColor; }
84 
91  bool showSelection() const { return mShowSelection; }
92 
93  //setters
94 
96  void setCoordinateTransform( const QgsCoordinateTransform* t );
97  void setMapToPixel( const QgsMapToPixel& mtp ) {mMapToPixel = mtp;}
98  void setExtent( const QgsRectangle& extent ) {mExtent = extent;}
99  void setDrawEditingInformation( bool b ) {mDrawEditingInformation = b;}
100  void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;}
101  void setScaleFactor( double factor ) {mScaleFactor = factor;}
102  void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;}
103  void setRendererScale( double scale ) {mRendererScale = scale;}
104  void setPainter( QPainter* p ) {mPainter = p;}
106  void setForceVectorOutput( bool force ) {mForceVectorOutput = force;}
108  void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
110  void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
111 
118  void setShowSelection( const bool showSelection ) { mShowSelection = showSelection; }
119 
121  bool useRenderingOptimization() const { return mUseRenderingOptimization; }
122  void setUseRenderingOptimization( bool enabled ) { mUseRenderingOptimization = enabled; }
123 
125  const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
126  void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
127 
128  private:
129 
131  QPainter* mPainter;
132 
134  const QgsCoordinateTransform* mCoordTransform;
135 
137  bool mDrawEditingInformation;
138 
139  QgsRectangle mExtent;
140 
142  bool mForceVectorOutput;
143 
145  bool mUseAdvancedEffects;
146 
147  QgsMapToPixel mMapToPixel;
148 
150  bool mRenderingStopped;
151 
153  double mScaleFactor;
154 
156  double mRasterScaleFactor;
157 
159  double mRendererScale;
160 
162  QgsLabelingEngineInterface* mLabelingEngine;
163 
165  bool mShowSelection;
166 
168  QColor mSelectionColor;
169 
171  bool mUseRenderingOptimization;
172 
174  QgsVectorSimplifyMethod mVectorSimplifyMethod;
175 };
176 
177 #endif
void setForceVectorOutput(bool force)
Added in QGIS v1.5.
Definition: qgsrendercontext.h:106
void setRenderingStopped(bool stopped)
Definition: qgsrendercontext.h:100
A rectangle specified with double values.
Definition: qgsrectangle.h:35
QColor selectionColor() const
Added in QGIS v2.0.
Definition: qgsrendercontext.h:83
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Added in QGIS v2.4.
Definition: qgsrendercontext.h:125
double rendererScale() const
Definition: qgsrendercontext.h:77
void setRendererScale(double scale)
Definition: qgsrendercontext.h:103
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Definition: qgsrendercontext.h:126
const QgsRectangle & extent() const
Definition: qgsrendercontext.h:56
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
Definition: qgsrendercontext.h:91
double scaleFactor() const
Definition: qgsrendercontext.h:60
const QgsCoordinateTransform * coordinateTransform() const
Definition: qgsrendercontext.h:54
const QPainter * constPainter() const
Definition: qgsrendercontext.h:52
void setExtent(const QgsRectangle &extent)
Definition: qgsrendercontext.h:98
The QgsMapSettings class contains configuration for rendering of the map.
Definition: qgsmapsettings.h:52
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
Definition: qgsrendercontext.h:70
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:33
void setSelectionColor(const QColor &color)
Added in QGIS v2.0.
Definition: qgsrendercontext.h:110
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
Definition: qgsrendercontext.h:73
void setScaleFactor(double factor)
Definition: qgsrendercontext.h:101
bool renderingStopped() const
Definition: qgsrendercontext.h:64
void setDrawEditingInformation(bool b)
Definition: qgsrendercontext.h:99
bool forceVectorOutput() const
Definition: qgsrendercontext.h:66
void setPainter(QPainter *p)
Definition: qgsrendercontext.h:104
double rasterScaleFactor() const
Definition: qgsrendercontext.h:62
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
Definition: qgsrendercontext.h:121
bool drawEditingInformation() const
Definition: qgsrendercontext.h:75
This class contains information how to simplify geometries fetched from a vector layer.
Definition: qgsvectorsimplifymethod.h:24
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:39
QPainter * painter()
Definition: qgsrendercontext.h:51
void setLabelingEngine(QgsLabelingEngineInterface *iface)
Added in QGIS v1.4.
Definition: qgsrendercontext.h:108
void setMapToPixel(const QgsMapToPixel &mtp)
Definition: qgsrendercontext.h:97
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:52
void setUseRenderingOptimization(bool enabled)
Definition: qgsrendercontext.h:122
const QgsMapToPixel & mapToPixel() const
Definition: qgsrendercontext.h:58
void setRasterScaleFactor(double factor)
Definition: qgsrendercontext.h:102
Labeling engine interface.
Definition: qgsmaprenderer.h:69
void setShowSelection(const bool showSelection)
Sets whether vector selections should be shown in the rendered map.
Definition: qgsrendercontext.h:118
QgsLabelingEngineInterface * labelingEngine() const
Added in QGIS v1.4.
Definition: qgsrendercontext.h:80