Refactored QgsCoordinateTransform to QgsMapToPixel

git-svn-id: http://svn.osgeo.org/qgis/trunk@2536 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2004-12-30 02:52:37 +00:00
parent b8293946bd
commit 977ff433ad
30 changed files with 64 additions and 66 deletions

View File

@ -42,7 +42,7 @@
#include "../../src/qgsmaplayer.h"
#include "../../src/qgsvectorlayer.h"
#include "../../src/qgsdataprovider.h"
#include "../../src/qgscoordinatetransform.h"
#include "../../src/qgsmaptopixel.h"
#include "../../src/qgsfeatureattribute.h"
extern "C" {

View File

@ -42,7 +42,7 @@
#include "../../src/qgsmaplayer.h"
#include "../../src/qgsvectorlayer.h"
#include "../../src/qgsdataprovider.h"
#include "../../src/qgscoordinatetransform.h"
#include "../../src/qgsmaptopixel.h"
#include "../../src/qgsfield.h"
#include "../../src/qgsfeatureattribute.h"

View File

@ -27,7 +27,7 @@
#include "../../src/qgisapp.h"
#include "../../src/qgspoint.h"
#include "../../src/qgisiface.h"
#include "../../src/qgscoordinatetransform.h"
#include "../../src/qgsmaptopixel.h"
class QgsGrassProvider;
#include "qgsgrasseditbase.h"
@ -276,7 +276,7 @@ private:
QPixmap *mPixmap;
//! Transformation
QgsCoordinateTransform *mTransform;
QgsMapToPixel *mTransform;
//! Last point where user clicked (map units)
QgsPoint mLastPoint;

View File

@ -325,7 +325,7 @@ void QgsGrassPlugin::displayRegion(QPainter *painter)
points[3].setX(window.west); points[3].setY(window.north);
points[4].setX(window.west); points[4].setY(window.south);
QgsCoordinateTransform *transform = mCanvas->getCoordinateTransform();
QgsMapToPixel *transform = mCanvas->getCoordinateTransform();
QPointArray pointArray(5);
for ( int i = 0; i < 5; i++ ) {

View File

@ -48,7 +48,7 @@
#include "../../src/qgsvectorlayer.h"
#include "../../src/qgisiface.h"
#include "../../src/qgsmapcanvas.h"
#include "../../src/qgscoordinatetransform.h"
#include "../../src/qgsmaptopixel.h"
#include "../../src/qgspoint.h"
extern "C" {
@ -384,7 +384,7 @@ void QgsGrassRegion::displayRegion()
points[3].setX(mWindow.west); points[3].setY(mWindow.north);
points[4].setX(mWindow.west); points[4].setY(mWindow.south);
QgsCoordinateTransform *transform = mCanvas->getCoordinateTransform();
QgsMapToPixel *transform = mCanvas->getCoordinateTransform();
for ( int i = 0; i < 5; i++ ) {
transform->transform( &(points[i]) );

View File

@ -10,7 +10,7 @@ void MapLayerTest::setQgisMainWindow(QMainWindow *app){
qgisApp = app;
}
// set the coordinate transform for drawing the layer
void MapLayerTest::setCoordinateTransform(QgsCoordinateTransform *xform){
void MapLayerTest::setCoordinateTransform(QgsMapToPixel *xform){
coordTransform = xform;
}
void MapLayerTest::initGui(){

View File

@ -3,13 +3,13 @@
#include <qmainwindow.h>
#include <qmenubar.h>
#include "../../src/qgsmaplayerinterface.h"
#include "../../src/qgscoordinatetransform.h"
#include "../../src/qgsmaptopixel.h"
class MapLayerTest : public QgsMapLayerInterface{
Q_OBJECT
public:
MapLayerTest();
void setQgisMainWindow(QMainWindow *app);
void setCoordinateTransform(QgsCoordinateTransform *xform);
void setCoordinateTransform(QgsMapToPixel *xform);
public slots:
void initGui();
void open();
@ -19,7 +19,7 @@ private:
QMainWindow *qgisApp;
QMenuBar *menu;
int menuId;
QgsCoordinateTransform *coordTransform;
QgsMapToPixel *coordTransform;
};

View File

@ -43,7 +43,7 @@ email : sbr00pwb@users.sourceforge.net
#include <qpen.h>
#include <qgspoint.h>
#include <qpointarray.h>
#include <qgscoordinatetransform.h>
#include <qgsmaptopixel.h>
#include <qstring.h>
#include <qfontmetrics.h>
#include <qfont.h>

View File

@ -172,9 +172,7 @@
<argumentsHintDelay>400</argumentsHintDelay>
<headerCompletionDelay>250</headerCompletionDelay>
</codecompletion>
<references>
<pcs>Qt</pcs>
</references>
<references/>
</kdevcppsupport>
<kdevdocumentation>
<projectdoc>

View File

@ -49,7 +49,7 @@ headers = \
qgscolortable.h \
qgscontcoldialog.h \
qgscontinuouscolrenderer.h \
qgscoordinatetransform.h \
qgsmaptopixel.h \
qgscustomsymbol.h \
qgsdataprovider.h \
qgsdatasource.h \
@ -231,7 +231,7 @@ qgis_SOURCES = \
qgscolortable.cpp \
qgscontcoldialog.cpp \
qgscontinuouscolrenderer.cpp \
qgscoordinatetransform.cpp \
qgsmaptopixel.cpp \
qgscustomsymbol.cpp \
qgsdatasource.cpp \
qgsdlgvectorlayerproperties.cpp \
@ -341,7 +341,7 @@ libqgis_la_SOURCES = \
qgsacetaterectangle.cpp \
qgscolortable.cpp \
qgscontinuouscolrenderer.cpp \
qgscoordinatetransform.cpp \
qgsmaptopixel.cpp \
qgsfeatureattribute.cpp \
qgsfeature.cpp \
qgsfield.cpp \

View File

@ -19,7 +19,7 @@
/* $Id$ */
#include <qstring.h>
#include <qpainter.h>
#include <qgscoordinatetransform.h>
#include <qgsmaptopixel.h>
#include <qgspoint.h>
#include <qgsrect.h>
#include "qgsline.h"
@ -39,7 +39,7 @@ void QgsAcetateLines::add(QgsLine &line)
{
mLineCollection->push_back(line);
}
void QgsAcetateLines::draw(QPainter *painter, QgsCoordinateTransform *cXf)
void QgsAcetateLines::draw(QPainter *painter, QgsMapToPixel *cXf)
{
painter->setPen(QColor(255,0,0));
painter->setBrush(Qt::NoBrush);

View File

@ -24,7 +24,7 @@
class QgsPoint;
class QgsLine;
class QPainter;
class QgsCoordinateTransform;
class QgsMapToPixel;
#include <vector>
//#include "qgsline.h"
@ -36,7 +36,7 @@ class QgsCoordinateTransform;
* An acetate object is a graphic or text object that is drawn on top of the map canvas
* after rendering of all map elements is completed. Acetate objects can be drawn in
* device coordinates or map coordinates. Drawing in map coordinates requires passing
* a QgsCoordinateTransform object to the draw function.
* a QgsMapToPixel object to the draw function.
*
*/
class QgsAcetateLines : public QgsAcetateObject {
@ -58,7 +58,7 @@ class QgsAcetateLines : public QgsAcetateObject {
* assumed to be device coordinates
* rather than map coordinates.
*/
void draw (QPainter * painter, QgsCoordinateTransform * cXf=0);
void draw (QPainter * painter, QgsMapToPixel * cXf=0);
/**
* Set the origin point
* @param value Point of origin

View File

@ -18,7 +18,7 @@
/* $Id$ */
#include <qgspoint.h>
#include <qpainter.h>
#include <qgscoordinatetransform.h>
#include <qgsmaptopixel.h>
#include "qgsacetateobject.h"
QgsAcetateObject::QgsAcetateObject(QgsPoint &origin) :
@ -38,7 +38,7 @@ QgsAcetateObject::QgsAcetateObject()
QgsAcetateObject::~QgsAcetateObject()
{
}
/*void QgsAcetateObject::draw(QPainter * painter, QgsCoordinateTransform * cXf)
/*void QgsAcetateObject::draw(QPainter * painter, QgsMapToPixel * cXf)
{
}
*/

View File

@ -21,7 +21,7 @@
#define QGSACETATEOBJECT_H
class QgsPoint;
class QPainter;
class QgsCoordinateTransform;
class QgsMapToPixel;
/*! \class QgsAcetateObject
* \brief Base class for all objects that are drawn on the acetate layer of a map canvas.
@ -29,7 +29,7 @@ class QgsCoordinateTransform;
* An acetate object is a graphic or text object that is drawn on top of the map canvas
* after rendering of all map elements is completed. Acetate objects can be drawn in
* device coordinates or map coordinates. Drawing in map coordinates requires passing
* a QgsCoordinateTransform object to the draw function.
* a QgsMapToPixel object to the draw function.
*
* The draw function must be overridden in a subclass to provide the specfic logic for
* drawing the object.
@ -62,7 +62,7 @@ public:
* this parameter is not specified, coordinates are assumed to be device coordinates
* rather than map coordinates.
*/
virtual void draw (QPainter * painter, QgsCoordinateTransform * cXf=0)=0;
virtual void draw (QPainter * painter, QgsMapToPixel * cXf=0)=0;
/**
* Set the origin point
* @param value Point of origin

View File

@ -18,7 +18,7 @@
/* $Id$ */
#include <qstring.h>
#include <qpainter.h>
#include <qgscoordinatetransform.h>
#include <qgsmaptopixel.h>
#include <qgspoint.h>
#include <qgsrect.h>
#include "qgsacetaterectangle.h"
@ -33,7 +33,7 @@ QgsAcetateRectangle::~QgsAcetateRectangle()
}
void QgsAcetateRectangle::draw(QPainter *painter, QgsCoordinateTransform *cXf)
void QgsAcetateRectangle::draw(QPainter *painter, QgsMapToPixel *cXf)
{
painter->setPen(QColor(255,0,0));
painter->setBrush(Qt::NoBrush);

View File

@ -22,7 +22,7 @@
class QgsPoint;
class QPainter;
class QgsCoordinateTransform;
class QgsMapToPixel;
#include <qgsrect.h>
#include "qgsacetateobject.h"
@ -32,7 +32,7 @@ class QgsCoordinateTransform;
* An acetate object is a graphic or text object that is drawn on top of the map canvas
* after rendering of all map elements is completed. Acetate objects can be drawn in
* device coordinates or map coordinates. Drawing in map coordinates requires passing
* a QgsCoordinateTransform object to the draw function.
* a QgsMapToPixel object to the draw function.
*
*/
class QgsAcetateRectangle : public QgsAcetateObject {
@ -54,7 +54,7 @@ class QgsAcetateRectangle : public QgsAcetateObject {
* this parameter is not specified, coordinates are assumed to be device coordinates
* rather than map coordinates.
*/
void draw (QPainter * painter, QgsCoordinateTransform * cXf=0);
void draw (QPainter * painter, QgsMapToPixel * cXf=0);
/**
* Set the origin point
* @param value Point of origin

View File

@ -21,7 +21,7 @@
#include "qgsrenderer.h"
#include "qgsrenderitem.h"
#include <qpainter.h>
#include "qgscoordinatetransform.h"
#include "qgsmaptopixel.h"
#include "qgspoint.h"
#include "qgsfeature.h"
#include <iostream>

View File

@ -25,7 +25,7 @@
#include <iostream>
#include "qgspoint.h"
#include "qpainter.h"
#include "qgscoordinatetransform.h"
#include "qgsmaptopixel.h"
#include "qgsfeature.h"
#include "qgsvectorlayer.h"
#include "qgsdlgvectorlayerproperties.h"

View File

@ -30,7 +30,7 @@
#include "qgsfeature.h"
#include "qgsfield.h"
#include "qgsrect.h"
#include "qgscoordinatetransform.h"
#include "qgsmaptopixel.h"
#include "qgslabelattributes.h"
#include "qgslabeldialog.h"
@ -83,7 +83,7 @@ QString QgsLabel::fieldValue ( int attr, QgsFeature *feature )
}
void QgsLabel::renderLabel( QPainter * painter, QgsRect *viewExtent,
QgsCoordinateTransform *transform, QPaintDevice* device,
QgsMapToPixel *transform, QPaintDevice* device,
QgsFeature *feature, bool selected, QgsLabelAttributes *classAttributes )
{
#if QGISDEBUG > 3

View File

@ -32,7 +32,7 @@ class QgsField;
class QgsMapCanvas;
class QgsLabelAttributes;
class QgsRect;
class QgsCoordinateTransform;
class QgsMapToPixel;
/** Render class to display labels */
class QgsLabel
@ -70,7 +70,7 @@ public:
void dialog( QWidget * parent = 0 );
void renderLabel ( QPainter* painter, QgsRect* viewExtent,
QgsCoordinateTransform *transform, QPaintDevice *device,
QgsMapToPixel *transform, QPaintDevice *device,
QgsFeature *feature, bool selected, QgsLabelAttributes *classAttributes=0);
/** Reads the renderer configuration from an XML file

View File

@ -76,7 +76,7 @@
#include "qgsrect.h"
#include "qgsacetaterectangle.h"
#include "qgsattributedialog.h"
#include "qgscoordinatetransform.h"
#include "qgsmaptopixel.h"
#include "qgsfeature.h"
#include "qgslegend.h"
#include "qgslegenditem.h"
@ -116,7 +116,7 @@ public:
scaleCalculator( 0x0 )
{
mapWindow = new QRect;
coordXForm = new QgsCoordinateTransform;
coordXForm = new QgsMapToPixel;
pmCanvas = new QPixmap(width, height);
scaleCalculator = new QgsScaleCalculator;
// set the initial extent - can't use a constructor since QgsRect
@ -140,7 +140,7 @@ public:
scaleCalculator( 0x0 )
{
mapWindow = new QRect;
coordXForm = new QgsCoordinateTransform;
coordXForm = new QgsMapToPixel;
pmCanvas = new QPixmap;
scaleCalculator = new QgsScaleCalculator;
}
@ -206,8 +206,8 @@ public:
/** Pointer to the coordinate transform object used to transform
coordinates from real world to device coordinates
*/
//std::auto_ptr<QgsCoordinateTransform> coordXForm;
QgsCoordinateTransform * coordXForm;
//std::auto_ptr<QgsMapToPixel> coordXForm;
QgsMapToPixel * coordXForm;
/**
* \brief Currently selected map tool.
@ -812,7 +812,7 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
// return the current coordinate transform based on the extents and
// device size
QgsCoordinateTransform * QgsMapCanvas::getCoordinateTransform()
QgsMapToPixel * QgsMapCanvas::getCoordinateTransform()
{
return mCanvasProperties->coordXForm;
}

View File

@ -49,7 +49,7 @@ class QColor;
class QPaintDevice;
class QMouseEvent;
class QgsCoordinateTransform;
class QgsMapToPixel;
class QgsMapLayer;
class QgsMapLayerInterface;
class QgsLegend;
@ -166,7 +166,7 @@ class QgsMapCanvas : public QWidget
QgsScaleCalculator::units mapUnits() const;
//! Get the current coordinate transform
QgsCoordinateTransform * getCoordinateTransform();
QgsMapToPixel * getCoordinateTransform();
//! Declare the legend class as a friend of the map canvas
//friend class QgsLegend;

View File

@ -129,12 +129,12 @@ void QgsMapLayer::draw(QPainter *, QgsRect * viewExtent, int yTransform)
// std::cout << "In QgsMapLayer::draw" << std::endl;
}
void QgsMapLayer::draw(QPainter *, QgsRect *, QgsCoordinateTransform *,QPaintDevice * )
void QgsMapLayer::draw(QPainter *, QgsRect *, QgsMapToPixel *,QPaintDevice * )
{
// std::cout << "In QgsMapLayer::draw" << std::endl;
}
void QgsMapLayer::drawLabels(QPainter *, QgsRect *, QgsCoordinateTransform *,QPaintDevice * )
void QgsMapLayer::drawLabels(QPainter *, QgsRect *, QgsMapToPixel *,QPaintDevice * )
{
// std::cout << "In QgsMapLayer::draw" << std::endl;
}

View File

@ -27,7 +27,7 @@
#include <qgsrect.h>
#include <qgis.h>
#include <qgscoordinatetransform.h>
#include <qgsmaptopixel.h>
#include <qgisapp.h>
#include <qgssymbol.h>
#include <qgsfield.h>
@ -97,8 +97,8 @@ public:
virtual void draw(QPainter *, QgsRect *, int);
virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform * ,QPaintDevice *);
virtual void drawLabels(QPainter *, QgsRect *, QgsCoordinateTransform * ,QPaintDevice *);
virtual void draw(QPainter *, QgsRect *, QgsMapToPixel * ,QPaintDevice *);
virtual void drawLabels(QPainter *, QgsRect *, QgsMapToPixel * ,QPaintDevice *);
/*! Identify the feature(s) in this layer that are contained in the search rectangle
*/
virtual void identify(QgsRect *)

View File

@ -806,7 +806,7 @@ QPixmap QgsRasterLayer::getPaletteAsPixmap()
void QgsRasterLayer::draw(QPainter * theQPainter,
QgsRect * theViewExtent,
QgsCoordinateTransform * theQgsCoordinateTransform,
QgsMapToPixel * theQgsMapToPixel,
QPaintDevice* dst)
{
//Dont waste time drawing if transparency is at 0 (completely transparent)
@ -867,8 +867,8 @@ void QgsRasterLayer::draw(QPainter * theQPainter,
}
// get dimensions of clipped raster image in device coordinate space (this is the size of the viewport)
myRasterViewPort->topLeftPoint = theQgsCoordinateTransform->transform(myRasterExtent.xMin(), myRasterExtent.yMax());
myRasterViewPort->bottomRightPoint = theQgsCoordinateTransform->transform(myRasterExtent.xMax(), myRasterExtent.yMin());
myRasterViewPort->topLeftPoint = theQgsMapToPixel->transform(myRasterExtent.xMin(), myRasterExtent.yMax());
myRasterViewPort->bottomRightPoint = theQgsMapToPixel->transform(myRasterExtent.xMax(), myRasterExtent.yMin());
myRasterViewPort->drawableAreaXDimInt = static_cast<int>(myRasterViewPort->bottomRightPoint.x()) - static_cast<int>(myRasterViewPort->topLeftPoint.x());
myRasterViewPort->drawableAreaYDimInt = static_cast<int>(myRasterViewPort->bottomRightPoint.y()) - static_cast<int>(myRasterViewPort->topLeftPoint.y());

View File

@ -361,7 +361,7 @@ public:
QPixmap getPaletteAsPixmap();
/** \brief This is called when the view on the rasterlayer needs to be refreshed (redrawn). */
void draw(QPainter * theQPainter, QgsRect * theViewExtent, QgsCoordinateTransform * theQgsCoordinateTransform, QPaintDevice* dst);
void draw(QPainter * theQPainter, QgsRect * theViewExtent, QgsMapToPixel * theQgsMapToPixel, QPaintDevice* dst);
/** \brief This is an overloaded version of the above function that is called by both draw above and drawThumbnail */
void draw (QPainter * theQPainter, RasterViewPort * myRasterViewPort);

View File

@ -19,7 +19,7 @@
#define QGSRENDERER_H
class QgsFeature;
class QgsCoordinateTransform;
class QgsMapToPixel;
class QgsVectorLayer;
class QPainter;
class QgsDlgVectorLayerProperties;

View File

@ -23,7 +23,7 @@
#include "qgsrenderitem.h"
#include "qgspoint.h"
#include "qpainter.h"
#include "qgscoordinatetransform.h"
#include "qgsmaptopixel.h"
#include "qgsdlgvectorlayerproperties.h"
class QgsFeature;

View File

@ -44,7 +44,7 @@
#include "qgisapp.h"
#include "qgsrect.h"
#include "qgspoint.h"
#include "qgscoordinatetransform.h"
#include "qgsmaptopixel.h"
#include "qgsvectorlayer.h"
#include "qgsidentifyresults.h"
#include "qgsattributetable.h"
@ -252,7 +252,7 @@ void QgsVectorLayer::setDisplayField(QString fldName)
// NOTE this is a temporary method added by Tim to prevent label clipping
// which was occurring when labeller was called in the main draw loop
// This method will probably be removed again in the near future!
void QgsVectorLayer::drawLabels(QPainter * p, QgsRect * viewExtent, QgsCoordinateTransform * cXf, QPaintDevice* dst)
void QgsVectorLayer::drawLabels(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * cXf, QPaintDevice* dst)
{
if ( /*1 == 1 */ m_renderer)
{
@ -309,7 +309,7 @@ void QgsVectorLayer::drawLabels(QPainter * p, QgsRect * viewExtent, QgsCoordinat
}
}
void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTransform * cXf, QPaintDevice* dst)
void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * cXf, QPaintDevice* dst)
{
if ( /*1 == 1 */ m_renderer)
{
@ -1877,7 +1877,7 @@ bool QgsVectorLayer::rollBack()
return true;
}
void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsCoordinateTransform * cXf, QPicture* marker, double markerScaleFactor)
void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * cXf, QPicture* marker, double markerScaleFactor)
{
unsigned char *feature;
bool attributesneeded = m_renderer->needsAttributes();

View File

@ -22,7 +22,7 @@
class QPainter;
class QgsRect;
class QLibrary;
class QgsCoordinateTransform;
class QgsMapToPixel;
class OGRLayer;
class OGRDataSource;
class QgsDataProvider;
@ -292,12 +292,12 @@ protected:
void startEditing();
void stopEditing();
void drawFeature(QPainter* p, QgsFeature* fet, QgsCoordinateTransform * cXf, QPicture* marker, double markerScaleFactor);
void drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * cXf, QPicture* marker, double markerScaleFactor);
private: // Private attributes
//! Draws the layer labels using coordinate transformation
void drawLabels(QPainter * p, QgsRect * viewExtent, QgsCoordinateTransform * cXf, QPaintDevice * dst);
void drawLabels(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * cXf, QPaintDevice * dst);
/** tailor the right-click context menu with vector layer only stuff
@ -306,7 +306,7 @@ private: // Private attributes
void initContextMenu_(QgisApp *);
//! Draws the layer using coordinate transformation
void draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTransform * cXf, QPaintDevice * dst);
void draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * cXf, QPaintDevice * dst);
//! Pointer to data provider derived from the abastract base class QgsDataProvider
QgsVectorDataProvider *dataProvider;
//! index of the primary label field