fixes to rendering code

git-svn-id: http://svn.osgeo.org/qgis/trunk@45 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2002-07-27 06:16:51 +00:00
parent 1c032077ef
commit c94a18c603
2 changed files with 20 additions and 4 deletions

View File

@ -28,7 +28,8 @@ QgsCoordinateTransform::~QgsCoordinateTransform(){
QgsPoint QgsCoordinateTransform::transform(QgsPoint p){
// transform x
double dx = (p.x() - xMin)/mapUnitsPerPixel;
double dy = (yMax - (p.y() - yMin))/mapUnitsPerPixel;
double dy = yMax - ((p.y() - yMin))/mapUnitsPerPixel;
// double dy = (yMax - (p.y() - yMin))/mapUnitsPerPixel;
return QgsPoint(dx,dy);
}

View File

@ -36,7 +36,9 @@ void QgsMapCanvas::addLayer(QgsMapLayer *lyr){
// update extent if warranted
if(layers.size() == 1){
fullExtent = lyr->extent();
fullExtent.scale(1.1);
currentExtent = fullExtent;
}
// set zpos to something...
@ -53,9 +55,22 @@ void QgsMapCanvas::render2(){
muppX = currentExtent.width()/width();
cout << "MuppX is: " << muppX << "\nMuppY is: " << muppY << endl;
m_mupp = muppY > muppX?muppY:muppX;
m_mupp *= 1.20;
coordXForm->setParameters(m_mupp, currentExtent.xMin(),
currentExtent.yMin(), currentExtent.yMax());
// calculate the actual extent of the mapCanvas
double dxmin,dymin,dymax,whitespace;
if(muppY > muppX){
dymin = currentExtent.yMin();
dymax = currentExtent.yMax();
whitespace = ((width() *m_mupp) - currentExtent.width())/2;
dxmin = currentExtent.xMin() - whitespace;
}else{
dxmin = currentExtent.xMin();
whitespace = ((height() *m_mupp) - currentExtent.height())/2;
dymin = currentExtent.yMin() - whitespace;
dymax = currentExtent.yMax() + whitespace;
}
cout << "dxmin: " << dxmin << endl << "dymin: " << dymin << endl << "dymax: " << dymax << endl << "whitespace: " << whitespace << endl;
coordXForm->setParameters(m_mupp, dxmin,dymin,height()); //currentExtent.xMin(), currentExtent.yMin(), currentExtent.yMax());
// render all layers in the stack, starting at the base
map<QString,QgsMapLayer *>::iterator mi = layers.begin();
while(mi != layers.end()){