Skip to content
Permalink
Browse files
Merge of rendercontext branch into trunk
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8440 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 15, 2008
1 parent 15c76ee commit 47f79b541d9d26c89db8e2107730fce13b7c4cee
Showing with 1,153 additions and 958 deletions.
  1. +1 −0 python/core/core.sip
  2. +1 −1 python/core/qgscontinuouscolorrenderer.sip
  3. +1 −1 python/core/qgsgraduatedsymbolrenderer.sip
  4. +3 −7 python/core/qgsmaplayer.sip
  5. +1 −1 python/core/qgsmaprender.sip
  6. +1 −9 python/core/qgsrasterlayer.sip
  7. +44 −0 python/core/qgsrendercontext.sip
  8. +1 −1 python/core/qgsrenderer.sip
  9. +1 −1 python/core/qgssinglesymbolrenderer.sip
  10. +2 −2 python/core/qgssymbol.sip
  11. +1 −1 python/core/qgsuniquevaluerenderer.sip
  12. +3 −19 python/core/qgsvectorlayer.sip
  13. +1 −1 python/gui/qgsmapcanvas.sip
  14. +11 −9 src/app/composer/qgscomposer.cpp
  15. +32 −128 src/app/composer/qgscomposermap.cpp
  16. +5 −2 src/app/composer/qgscomposermap.h
  17. +22 −1 src/app/composer/qgscomposition.cpp
  18. +8 −1 src/app/legend/qgslegend.cpp
  19. +4 −4 src/app/legend/qgslegendlayer.cpp
  20. +2 −2 src/app/legend/qgslegendlayer.h
  21. +49 −2 src/app/qgisapp.cpp
  22. +7 −0 src/app/qgisapp.h
  23. +72 −59 src/app/qgscontinuouscolordialog.cpp
  24. +64 −66 src/app/qgsgraduatedsymboldialog.cpp
  25. +1 −1 src/app/qgsmaptoolselect.cpp
  26. +4 −0 src/app/qgsoptions.cpp
  27. +5 −5 src/app/qgssinglesymboldialog.cpp
  28. +2 −2 src/app/qgssinglesymboldialog.h
  29. +63 −56 src/app/qgsuniquevaluedialog.cpp
  30. +1 −0 src/core/CMakeLists.txt
  31. +7 −7 src/core/qgscoordinatetransform.cpp
  32. +8 −8 src/core/qgscoordinatetransform.h
  33. +5 −5 src/core/qgslabel.cpp
  34. +5 −5 src/core/qgslabel.h
  35. +2 −5 src/core/qgsmaplayer.cpp
  36. +4 −11 src/core/qgsmaplayer.h
  37. +100 −21 src/core/qgsmaprender.cpp
  38. +8 −4 src/core/qgsmaprender.h
  39. +9 −9 src/core/qgsmaptopixel.cpp
  40. +9 −9 src/core/qgsmaptopixel.h
  41. +1 −1 src/core/qgsrect.cpp
  42. +1 −1 src/core/qgsrect.h
  43. +36 −0 src/core/qgsrendercontext.cpp
  44. +94 −0 src/core/qgsrendercontext.h
  45. +2 −2 src/core/qgsscalecalculator.cpp
  46. +2 −2 src/core/qgsscalecalculator.h
  47. +66 −72 src/core/qgsvectorlayer.cpp
  48. +14 −28 src/core/qgsvectorlayer.h
  49. +48 −43 src/core/raster/qgsrasterlayer.cpp
  50. +13 −20 src/core/raster/qgsrasterlayer.h
  51. +7 −8 src/core/renderer/qgscontinuouscolorrenderer.cpp
  52. +1 −1 src/core/renderer/qgscontinuouscolorrenderer.h
  53. +29 −31 src/core/renderer/qgsgraduatedsymbolrenderer.cpp
  54. +1 −1 src/core/renderer/qgsgraduatedsymbolrenderer.h
  55. +1 −1 src/core/renderer/qgsrenderer.h
  56. +5 −6 src/core/renderer/qgssinglesymbolrenderer.cpp
  57. +1 −1 src/core/renderer/qgssinglesymbolrenderer.h
  58. +34 −40 src/core/renderer/qgsuniquevaluerenderer.cpp
  59. +1 −1 src/core/renderer/qgsuniquevaluerenderer.h
  60. +23 −21 src/core/symbology/qgssymbol.cpp
  61. +3 −3 src/core/symbology/qgssymbol.h
  62. +24 −3 src/gui/qgsmapcanvas.cpp
  63. +1 −1 src/gui/qgsmapcanvas.h
  64. +2 −2 src/gui/qgsmapoverviewcanvas.cpp
  65. +1 −1 src/gui/qgsmaptoolzoom.cpp
  66. +1 −1 src/plugins/grass/qgsgrassedit.h
  67. +42 −57 src/ui/qgscontinuouscolordialogbase.ui
  68. +129 −144 src/ui/qgssinglesymboldialogbase.ui
@@ -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
@@ -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*/
@@ -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);
@@ -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();
@@ -28,7 +28,7 @@ class QgsMapRender : QObject
//! returns current extent
QgsRect extent();

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

double scale() const;
double mupp() const;
@@ -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,
@@ -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);
};
@@ -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*/
@@ -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*/
@@ -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 */
@@ -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*/
@@ -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();
@@ -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();
@@ -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);
@@ -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);

@@ -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();

@@ -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;
Loading

0 comments on commit 47f79b5

Please sign in to comment.