Skip to content

Commit

Permalink
Merge of rendercontext branch into trunk
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@8440 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 15, 2008
1 parent acdbb66 commit 68cdb3a
Show file tree
Hide file tree
Showing 68 changed files with 1,153 additions and 958 deletions.
1 change: 1 addition & 0 deletions python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
%Include qgsrastertransparency.sip
%Include qgsrasterviewport.sip
%Include qgsrect.sip
%Include qgsrendercontext.sip
%Include qgsrenderer.sip
%Include qgsscalecalculator.sip
%Include qgssinglesymbolrenderer.sip
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgscontinuouscolorrenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class QgsContinuousColorRenderer : QgsRenderer
QgsContinuousColorRenderer(const QgsContinuousColorRenderer& other);
virtual ~QgsContinuousColorRenderer();
/**Renders the feature using the minimum and maximum value of the classification field*/
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, double* scalefactor, bool selected, double widthScale = 1);
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0);
/**Returns the number of the classification field*/
int classificationField() const;
/**Sets the id of the classification field*/
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsgraduatedsymbolrenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class QgsGraduatedSymbolRenderer : QgsRenderer
\param p a painter (usually the one from the current map canvas)
\param f a pointer to a feature to render
\param t the transform object containing the information how to transform the map coordinates to screen coordinates*/
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, double* scalefactor, bool selected, double widthScale = 1);
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0);
/**Sets the number of the classicifation field
\param field the number of the field to classify*/
void setClassificationField(int field);
Expand Down
10 changes: 3 additions & 7 deletions python/core/qgsmaplayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,13 @@ public:
const QString & name() const;

/** Render the layer, to be overridden in child classes
* @param painter Painter that to be used for rendered output
* @param rect Extent of the layer to be drawn
* @param mtp Transformation class
* @return FALSE if an error occurred during drawing
*/
virtual bool draw(QPainter* painter, QgsRect& rect, QgsMapToPixel* mtp, QgsCoordinateTransform* ct, bool);
virtual bool draw(QgsRenderContext& renderContext);

/** Draw labels
* @TODO to be removed: used only in vector layers
*/
virtual void drawLabels(QPainter* painter, QgsRect& rect, QgsMapToPixel* mtp, QgsCoordinateTransform* ct);
virtual void drawLabels(QgsRenderContext& renderContext);

/** Return the extent of the layer as a QRect */
const QgsRect extent();
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsmaprender.sip
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class QgsMapRender : QObject
//! returns current extent
QgsRect extent();

QgsMapToPixel* coordXForm();
const QgsMapToPixel* coordXForm();

double scale() const;
double mupp() const;
Expand Down
10 changes: 1 addition & 9 deletions python/core/qgsrasterlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,8 @@ public:
QPixmap getPaletteAsPixmap();

/** \brief This is called when the view on the rasterlayer needs to be refreshed (redrawn).

\param drawingToEditingCanvas Are we drawing to an editable canvas?
currently not used, but retain to be similar to
the QgsVectorLayer interface
*/
bool draw(QPainter * theQPainter,
QgsRect & theViewExtent,
QgsMapToPixel * theQgsMapToPixel,
QgsCoordinateTransform* ct,
bool drawingToEditingCanvas);
bool draw(QgsRenderContext& renderContext);

/** \brief This is an overloaded version of the above function that is called by both draw above and drawThumbnail */
void draw(QPainter * theQPainter, QgsRasterViewPort * myRasterViewPort,
Expand Down
44 changes: 44 additions & 0 deletions python/core/qgsrendercontext.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

class QgsRenderContext
{

%TypeHeaderCode
#include <qgsrendercontext.h>
%End

public:
QgsRenderContext();
~QgsRenderContext();

//getters

QPainter* painter();

const QgsCoordinateTransform* coordTransform() const;

const QgsRect& extent() const;

const QgsMapToPixel& mapToPixel() const;

double scaleFactor() const;

double rasterScaleFactor() const;

bool renderingStopped() const;

bool forceVectorOutput() const;

bool drawEditingInformation() const;

//setters

/**Sets coordinate transformation. QgsRenderContext takes ownership and deletes if necessary*/
void setCoordTransform(QgsCoordinateTransform* t);
void setMapToPixel(const QgsMapToPixel& mtp);
void setExtent(const QgsRect& extent);
void setDrawEditingInformation(bool b);
void setRenderingStopped(bool stopped);
void setScaleFactor(double factor);
void setRasterScaleFactor(double factor);
void setPainter(QPainter* p);
};
2 changes: 1 addition & 1 deletion python/core/qgsrenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class QgsRenderer
@param f a pointer to the feature to be rendered
@param pic pointer to a marker from SVG (is only used by marker renderers)
@param scalefactor pointer to the scale factor for the marker image*/
virtual void renderFeature(QPainter* p, QgsFeature& f,QImage* pic, double* scalefactor, bool selected, double widthScale = 1)=0;
virtual void renderFeature(QPainter* p, QgsFeature& f,QImage* pic, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0)=0;
/**Reads the renderer configuration from an XML file
@param rnode the DOM node to read
@param vl the vector layer which will be associated with the renderer*/
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgssinglesymbolrenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class QgsSingleSymbolRenderer : QgsRenderer
/*Returns a pointer to mSymbol*/
const QgsSymbol* symbol() const;
/**Renders an OGRFeature*/
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, double* scalefactor, bool selected, double widthScale = 1);
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0);
/**Reads the renderer configuration from an XML file
@param rnode the DOM node to read
@param vl the vector layer which will be associated with the renderer*/
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgssymbol.sip
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class QgsSymbol
/**Sets the fill color*/
virtual void setFillColor(QColor c);
/**Get the line width*/
virtual int lineWidth() const;
virtual double lineWidth() const;
/**Sets the line width*/
virtual void setLineWidth(int w);
virtual void setLineWidth(double w);
/**Sets the pen*/
virtual void setPen(QPen p);
/**Gets a reference to m_pen. Don't use the pen to change color/style */
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsuniquevaluerenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class QgsUniqueValueRenderer : QgsRenderer
/** Determines if a feature will be rendered or not
@param f a pointer to the feature to determine if rendering will happen*/
bool willRenderFeature(QgsFeature *f);
void renderFeature(QPainter* p, QgsFeature& f,QImage* img, double* scalefactor, bool selected, double widthScale = 1);
void renderFeature(QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0);
/**Reads the renderer configuration from an XML file
@param rnode the DOM node to read
@param vl the vector layer which will be associated with the renderer*/
Expand Down
22 changes: 3 additions & 19 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -273,31 +273,15 @@ existing rings, 5 no feature found where ring can be inserted*/
/** Draws the layer using coordinate transformation
* @return FALSE if an error occurred during drawing
*/
bool draw(QPainter * p,
QgsRect & viewExtent,
QgsMapToPixel * cXf,
QgsCoordinateTransform* ct,
bool drawingToEditingCanvas);
bool draw(QgsRenderContext& renderContext);

/** Draws the layer labels using coordinate transformation */
void drawLabels(QPainter * p, QgsRect & viewExtent, QgsMapToPixel * cXf, QgsCoordinateTransform* ct);

/** \brief Draws the layer using coordinate transformation
* \param widthScale line width scale
* \param symbolScale symbol scale
*/
void draw(QPainter * p,
QgsRect & viewExtent,
QgsMapToPixel * cXf,
QgsCoordinateTransform* ct,
bool drawingToEditingCanvas,
double widthScale,
double symbolScale);
void drawLabels(QgsRenderContext& renderContext);

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

/** returns array of added features */
QList<QgsFeature>& addedFeatures();
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmapcanvas.sip
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class QgsMapCanvas : QGraphicsView
QGis::units mapUnits() const;

//! Get the current coordinate transform
QgsMapToPixel * getCoordinateTransform();
const QgsMapToPixel * getCoordinateTransform();

//! true if canvas currently drawing
bool isDrawing();
Expand Down
20 changes: 11 additions & 9 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ void QgsComposer::on_mActionPrint_activated(void)

//set the resolution and paper orientation each time we call up the dialog, not just the first time we run it
mPrinter->setResolution(mComposition->resolution());

if (mComposition->paperOrientation() == QgsComposition::Portrait)
{
mPrinter->setOrientation(QPrinter::Portrait);
Expand Down Expand Up @@ -372,7 +373,7 @@ void QgsComposer::on_mActionPrint_activated(void)

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

double scale = resolution / 25.4 / mComposition->scale();
//double scale = resolution / 25.4 / mComposition->scale();

mComposition->setPlotStyle(QgsComposition::Postscript);

Expand Down Expand Up @@ -404,12 +405,12 @@ void QgsComposer::on_mActionPrint_activated(void)
}

QPainter p(mPrinter);
p.scale(scale, scale);
//p.scale(scale, scale);

QRectF renderArea(0, 0, (mComposition->paperWidth() * mComposition->scale()),
(mComposition->paperHeight() * mComposition->scale()));
//QRectF renderArea(0, 0, (mComposition->paperWidth() * mComposition->scale()),
//(mComposition->paperHeight() * mComposition->scale()));

mComposition->canvas()->render(&p, renderArea);
mComposition->canvas()->render(&p/*, renderArea*/);

p.end();

Expand Down Expand Up @@ -614,12 +615,13 @@ void QgsComposer::on_mActionPrint_activated(void)
{
std::cout << "Printing ... " << std::endl;
QPainter p(mPrinter);
p.scale(scale, scale);
//p.scale(scale, scale);

QRectF renderArea(0, 0, (mComposition->paperWidth() * mComposition->scale()),
(mComposition->paperHeight() * mComposition->scale()));
//MH: is this necessary?
//QRectF renderArea(0, 0, (mComposition->paperWidth() * mComposition->scale()),
//(mComposition->paperHeight() * mComposition->scale()));

mComposition->canvas()->render(&p, renderArea);
mComposition->canvas()->render(&p/*, renderArea*/);

p.end();
std::cout << "... printing finished" << std::endl;
Expand Down
Loading

0 comments on commit 68cdb3a

Please sign in to comment.