Skip to content

Commit 68cdb3a

Browse files
author
mhugent
committed
Merge of rendercontext branch into trunk
git-svn-id: http://svn.osgeo.org/qgis/trunk@8440 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent acdbb66 commit 68cdb3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1153
-958
lines changed

python/core/core.sip

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
%Include qgsrastertransparency.sip
4747
%Include qgsrasterviewport.sip
4848
%Include qgsrect.sip
49+
%Include qgsrendercontext.sip
4950
%Include qgsrenderer.sip
5051
%Include qgsscalecalculator.sip
5152
%Include qgssinglesymbolrenderer.sip

python/core/qgscontinuouscolorrenderer.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class QgsContinuousColorRenderer : QgsRenderer
1111
QgsContinuousColorRenderer(const QgsContinuousColorRenderer& other);
1212
virtual ~QgsContinuousColorRenderer();
1313
/**Renders the feature using the minimum and maximum value of the classification field*/
14-
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, double* scalefactor, bool selected, double widthScale = 1);
14+
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0);
1515
/**Returns the number of the classification field*/
1616
int classificationField() const;
1717
/**Sets the id of the classification field*/

python/core/qgsgraduatedsymbolrenderer.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class QgsGraduatedSymbolRenderer : QgsRenderer
2323
\param p a painter (usually the one from the current map canvas)
2424
\param f a pointer to a feature to render
2525
\param t the transform object containing the information how to transform the map coordinates to screen coordinates*/
26-
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, double* scalefactor, bool selected, double widthScale = 1);
26+
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0);
2727
/**Sets the number of the classicifation field
2828
\param field the number of the field to classify*/
2929
void setClassificationField(int field);

python/core/qgsmaplayer.sip

+3-7
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,13 @@ public:
5656
const QString & name() const;
5757

5858
/** Render the layer, to be overridden in child classes
59-
* @param painter Painter that to be used for rendered output
60-
* @param rect Extent of the layer to be drawn
61-
* @param mtp Transformation class
62-
* @return FALSE if an error occurred during drawing
6359
*/
64-
virtual bool draw(QPainter* painter, QgsRect& rect, QgsMapToPixel* mtp, QgsCoordinateTransform* ct, bool);
65-
60+
virtual bool draw(QgsRenderContext& renderContext);
61+
6662
/** Draw labels
6763
* @TODO to be removed: used only in vector layers
6864
*/
69-
virtual void drawLabels(QPainter* painter, QgsRect& rect, QgsMapToPixel* mtp, QgsCoordinateTransform* ct);
65+
virtual void drawLabels(QgsRenderContext& renderContext);
7066

7167
/** Return the extent of the layer as a QRect */
7268
const QgsRect extent();

python/core/qgsmaprender.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class QgsMapRender : QObject
2828
//! returns current extent
2929
QgsRect extent();
3030

31-
QgsMapToPixel* coordXForm();
31+
const QgsMapToPixel* coordXForm();
3232

3333
double scale() const;
3434
double mupp() const;

python/core/qgsrasterlayer.sip

+1-9
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,8 @@ public:
105105
QPixmap getPaletteAsPixmap();
106106

107107
/** \brief This is called when the view on the rasterlayer needs to be refreshed (redrawn).
108-
109-
\param drawingToEditingCanvas Are we drawing to an editable canvas?
110-
currently not used, but retain to be similar to
111-
the QgsVectorLayer interface
112108
*/
113-
bool draw(QPainter * theQPainter,
114-
QgsRect & theViewExtent,
115-
QgsMapToPixel * theQgsMapToPixel,
116-
QgsCoordinateTransform* ct,
117-
bool drawingToEditingCanvas);
109+
bool draw(QgsRenderContext& renderContext);
118110

119111
/** \brief This is an overloaded version of the above function that is called by both draw above and drawThumbnail */
120112
void draw(QPainter * theQPainter, QgsRasterViewPort * myRasterViewPort,

python/core/qgsrendercontext.sip

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
class QgsRenderContext
3+
{
4+
5+
%TypeHeaderCode
6+
#include <qgsrendercontext.h>
7+
%End
8+
9+
public:
10+
QgsRenderContext();
11+
~QgsRenderContext();
12+
13+
//getters
14+
15+
QPainter* painter();
16+
17+
const QgsCoordinateTransform* coordTransform() const;
18+
19+
const QgsRect& extent() const;
20+
21+
const QgsMapToPixel& mapToPixel() const;
22+
23+
double scaleFactor() const;
24+
25+
double rasterScaleFactor() const;
26+
27+
bool renderingStopped() const;
28+
29+
bool forceVectorOutput() const;
30+
31+
bool drawEditingInformation() const;
32+
33+
//setters
34+
35+
/**Sets coordinate transformation. QgsRenderContext takes ownership and deletes if necessary*/
36+
void setCoordTransform(QgsCoordinateTransform* t);
37+
void setMapToPixel(const QgsMapToPixel& mtp);
38+
void setExtent(const QgsRect& extent);
39+
void setDrawEditingInformation(bool b);
40+
void setRenderingStopped(bool stopped);
41+
void setScaleFactor(double factor);
42+
void setRasterScaleFactor(double factor);
43+
void setPainter(QPainter* p);
44+
};

python/core/qgsrenderer.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class QgsRenderer
1616
@param f a pointer to the feature to be rendered
1717
@param pic pointer to a marker from SVG (is only used by marker renderers)
1818
@param scalefactor pointer to the scale factor for the marker image*/
19-
virtual void renderFeature(QPainter* p, QgsFeature& f,QImage* pic, double* scalefactor, bool selected, double widthScale = 1)=0;
19+
virtual void renderFeature(QPainter* p, QgsFeature& f,QImage* pic, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0)=0;
2020
/**Reads the renderer configuration from an XML file
2121
@param rnode the DOM node to read
2222
@param vl the vector layer which will be associated with the renderer*/

python/core/qgssinglesymbolrenderer.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class QgsSingleSymbolRenderer : QgsRenderer
1414
/*Returns a pointer to mSymbol*/
1515
const QgsSymbol* symbol() const;
1616
/**Renders an OGRFeature*/
17-
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, double* scalefactor, bool selected, double widthScale = 1);
17+
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0);
1818
/**Reads the renderer configuration from an XML file
1919
@param rnode the DOM node to read
2020
@param vl the vector layer which will be associated with the renderer*/

python/core/qgssymbol.sip

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class QgsSymbol
2727
/**Sets the fill color*/
2828
virtual void setFillColor(QColor c);
2929
/**Get the line width*/
30-
virtual int lineWidth() const;
30+
virtual double lineWidth() const;
3131
/**Sets the line width*/
32-
virtual void setLineWidth(int w);
32+
virtual void setLineWidth(double w);
3333
/**Sets the pen*/
3434
virtual void setPen(QPen p);
3535
/**Gets a reference to m_pen. Don't use the pen to change color/style */

python/core/qgsuniquevaluerenderer.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class QgsUniqueValueRenderer : QgsRenderer
1111
/** Determines if a feature will be rendered or not
1212
@param f a pointer to the feature to determine if rendering will happen*/
1313
bool willRenderFeature(QgsFeature *f);
14-
void renderFeature(QPainter* p, QgsFeature& f,QImage* img, double* scalefactor, bool selected, double widthScale = 1);
14+
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0);
1515
/**Reads the renderer configuration from an XML file
1616
@param rnode the DOM node to read
1717
@param vl the vector layer which will be associated with the renderer*/

python/core/qgsvectorlayer.sip

+3-19
Original file line numberDiff line numberDiff line change
@@ -273,31 +273,15 @@ existing rings, 5 no feature found where ring can be inserted*/
273273
/** Draws the layer using coordinate transformation
274274
* @return FALSE if an error occurred during drawing
275275
*/
276-
bool draw(QPainter * p,
277-
QgsRect & viewExtent,
278-
QgsMapToPixel * cXf,
279-
QgsCoordinateTransform* ct,
280-
bool drawingToEditingCanvas);
276+
bool draw(QgsRenderContext& renderContext);
281277

282278
/** Draws the layer labels using coordinate transformation */
283-
void drawLabels(QPainter * p, QgsRect & viewExtent, QgsMapToPixel * cXf, QgsCoordinateTransform* ct);
284-
285-
/** \brief Draws the layer using coordinate transformation
286-
* \param widthScale line width scale
287-
* \param symbolScale symbol scale
288-
*/
289-
void draw(QPainter * p,
290-
QgsRect & viewExtent,
291-
QgsMapToPixel * cXf,
292-
QgsCoordinateTransform* ct,
293-
bool drawingToEditingCanvas,
294-
double widthScale,
295-
double symbolScale);
279+
void drawLabels(QgsRenderContext& renderContext);
296280

297281
/** \brief Draws the layer labels using coordinate transformation
298282
* \param scale size scale, applied to all values in pixels
299283
*/
300-
void drawLabels(QPainter * p, QgsRect & viewExtent, QgsMapToPixel * cXf, QgsCoordinateTransform* ct, double scale);
284+
void drawLabels(QPainter * p, const QgsRect& viewExtent, const QgsMapToPixel* cXf, const QgsCoordinateTransform* ct, double scale);
301285

302286
/** returns array of added features */
303287
QList<QgsFeature>& addedFeatures();

python/gui/qgsmapcanvas.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class QgsMapCanvas : QGraphicsView
144144
QGis::units mapUnits() const;
145145

146146
//! Get the current coordinate transform
147-
QgsMapToPixel * getCoordinateTransform();
147+
const QgsMapToPixel * getCoordinateTransform();
148148

149149
//! true if canvas currently drawing
150150
bool isDrawing();

src/app/composer/qgscomposer.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ void QgsComposer::on_mActionPrint_activated(void)
338338

339339
//set the resolution and paper orientation each time we call up the dialog, not just the first time we run it
340340
mPrinter->setResolution(mComposition->resolution());
341+
341342
if (mComposition->paperOrientation() == QgsComposition::Portrait)
342343
{
343344
mPrinter->setOrientation(QPrinter::Portrait);
@@ -372,7 +373,7 @@ void QgsComposer::on_mActionPrint_activated(void)
372373

373374
std::cout << "Resolution = " << resolution << std::endl;
374375

375-
double scale = resolution / 25.4 / mComposition->scale();
376+
//double scale = resolution / 25.4 / mComposition->scale();
376377

377378
mComposition->setPlotStyle(QgsComposition::Postscript);
378379

@@ -404,12 +405,12 @@ void QgsComposer::on_mActionPrint_activated(void)
404405
}
405406

406407
QPainter p(mPrinter);
407-
p.scale(scale, scale);
408+
//p.scale(scale, scale);
408409

409-
QRectF renderArea(0, 0, (mComposition->paperWidth() * mComposition->scale()),
410-
(mComposition->paperHeight() * mComposition->scale()));
410+
//QRectF renderArea(0, 0, (mComposition->paperWidth() * mComposition->scale()),
411+
//(mComposition->paperHeight() * mComposition->scale()));
411412

412-
mComposition->canvas()->render(&p, renderArea);
413+
mComposition->canvas()->render(&p/*, renderArea*/);
413414

414415
p.end();
415416

@@ -614,12 +615,13 @@ void QgsComposer::on_mActionPrint_activated(void)
614615
{
615616
std::cout << "Printing ... " << std::endl;
616617
QPainter p(mPrinter);
617-
p.scale(scale, scale);
618+
//p.scale(scale, scale);
618619

619-
QRectF renderArea(0, 0, (mComposition->paperWidth() * mComposition->scale()),
620-
(mComposition->paperHeight() * mComposition->scale()));
620+
//MH: is this necessary?
621+
//QRectF renderArea(0, 0, (mComposition->paperWidth() * mComposition->scale()),
622+
//(mComposition->paperHeight() * mComposition->scale()));
621623

622-
mComposition->canvas()->render(&p, renderArea);
624+
mComposition->canvas()->render(&p/*, renderArea*/);
623625

624626
p.end();
625627
std::cout << "... printing finished" << std::endl;

0 commit comments

Comments
 (0)