Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Changed inline functions of QgsMapToPixel to normal functions.
This fixes warnings on windows when calling them outside core lib.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6655 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Feb 22, 2007
1 parent d8b2604 commit 0766775
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 56 deletions.
59 changes: 59 additions & 0 deletions src/core/qgsmaptopixel.cpp
Expand Up @@ -20,6 +20,22 @@
#include <qpoint.h>
#include "qgsmaptopixel.h"

QgsMapToPixel::QgsMapToPixel(double mupp,
double ymax,
double ymin,
double xmin)
: mMapUnitsPerPixel(mupp),
yMax(ymax),
yMin(ymin),
xMin(xmin),
xMax(0) // XXX wasn't originally specified? Why?
{
}

QgsMapToPixel::~QgsMapToPixel()
{
}

QgsPoint QgsMapToPixel::toMapPoint(int x, int y)
{
double mx = x * mMapUnitsPerPixel + xMin;
Expand Down Expand Up @@ -80,3 +96,46 @@ QString QgsMapToPixel::showParameters()
return rep;

}


QgsPoint QgsMapToPixel::transform(double x, double y)
{
transformInPlace(x,y);
return QgsPoint(x,y);
}

QgsPoint QgsMapToPixel::transform(const QgsPoint& p)
{
double dx = p.x();
double dy = p.y();
transformInPlace(dx, dy);

//std::cerr << "Point to pixel...X : " << p.x() << "-->" << dx << ", Y: " << p.y() << " -->" << dy << std::endl;
return QgsPoint(dx, dy);
}

void QgsMapToPixel::transform(QgsPoint* p)
{
double x = p->x();
double y = p->y();
transformInPlace(x, y);

#ifdef QGISDEBUG
//std::cerr << "Point to pixel...X : " << p->x() << "-->" << x << ", Y: " << p->y() << " -->" << y << std::endl;
#endif
p->set(x,y);
}

void QgsMapToPixel::transformInPlace(double& x, double& y)
{
x = (x - xMin) / mMapUnitsPerPixel;
y = yMax - (y - yMin) / mMapUnitsPerPixel;
}

void QgsMapToPixel::transformInPlace(std::vector<double>& x,
std::vector<double>& y)
{
assert(x.size() == y.size());
for (unsigned int i = 0; i < x.size(); ++i)
transformInPlace(x[i], y[i]);
}
56 changes: 0 additions & 56 deletions src/core/qgsmaptopixel.h
Expand Up @@ -114,61 +114,5 @@ class CORE_EXPORT QgsMapToPixel{

};

inline QgsMapToPixel::QgsMapToPixel(double mupp,
double ymax,
double ymin,
double xmin)
: mMapUnitsPerPixel(mupp),
yMax(ymax),
yMin(ymin),
xMin(xmin),
xMax(0) // XXX wasn't originally specified? Why?
{
}

inline QgsMapToPixel::~QgsMapToPixel()
{
}

inline QgsPoint QgsMapToPixel::transform(double x, double y)
{
transformInPlace(x,y);
return QgsPoint(x,y);
}

inline QgsPoint QgsMapToPixel::transform(const QgsPoint& p)
{
double dx = p.x();
double dy = p.y();
transformInPlace(dx, dy);

//std::cerr << "Point to pixel...X : " << p.x() << "-->" << dx << ", Y: " << p.y() << " -->" << dy << std::endl;
return QgsPoint(dx, dy);
}

inline void QgsMapToPixel::transform(QgsPoint* p)
{
double x = p->x();
double y = p->y();
transformInPlace(x, y);

#ifdef QGISDEBUG
//std::cerr << "Point to pixel...X : " << p->x() << "-->" << x << ", Y: " << p->y() << " -->" << y << std::endl;
#endif
p->set(x,y);
}

inline void QgsMapToPixel::transformInPlace(double& x, double& y)
{
x = (x - xMin) / mMapUnitsPerPixel;
y = yMax - (y - yMin) / mMapUnitsPerPixel;
}

inline void QgsMapToPixel::transformInPlace(std::vector<double>& x,
std::vector<double>& y)
{
assert(x.size() == y.size());
for (unsigned int i = 0; i < x.size(); ++i)
transformInPlace(x[i], y[i]);
}
#endif // QGSMAPTOPIXEL

0 comments on commit 0766775

Please sign in to comment.