Skip to content

Commit

Permalink
Fix for ticket #92
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@5338 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Apr 22, 2006
1 parent e8691f4 commit 1433ca4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -697,9 +697,19 @@ void QgsMapCanvas::resizeEvent(QResizeEvent * e)
int width = e->size().width(), height = e->size().height();
// int width = visibleWidth(), height = visibleHeight();
mCanvas->resize(width, height);


// Adjust the size (in pixels) of that we draw by the margins in
// the widget that the drawing eventually gets placed in. In my testing
// the margin was 2 pixels on each border. Add 1 more pixel just to
// be sure that the drawn map appears fully within the margins in
// the widget.
int top, bottom, right, left;
getContentsMargins(&left, &top, &right, &bottom);
width = width - (left + right + 1);
height = height - (top + bottom + 1);

mMap->resize(/*e->size()*/ QSize(width,height));

// notify canvas items of change
updateCanvasItemsPositions();

Expand Down
12 changes: 7 additions & 5 deletions src/gui/qgsmaprender.cpp
Expand Up @@ -123,8 +123,10 @@ void QgsMapRender::adjustExtentToSize()

// calculate the translation and scaling parameters
// mupp = map units per pixel
double muppY = mExtent.height() / myHeight;
double muppX = mExtent.width() / myWidth;
double muppY = static_cast<double>(mExtent.height())
/ static_cast<double>(myHeight);
double muppX = static_cast<double>(mExtent.width())
/ static_cast<double>(myWidth);
mMupp = muppY > muppX ? muppY : muppX;

// calculate the actual extent of the mapCanvas
Expand All @@ -134,15 +136,15 @@ void QgsMapRender::adjustExtentToSize()
{
dymin = mExtent.yMin();
dymax = mExtent.yMax();
whitespace = ((myWidth * mMupp) - mExtent.width()) / 2;
whitespace = ((myWidth * mMupp) - mExtent.width()) * 0.5;
dxmin = mExtent.xMin() - whitespace;
dxmax = mExtent.xMax() + whitespace;
}
else
{
dxmin = mExtent.xMin();
dxmax = mExtent.xMax();
whitespace = ((myHeight * mMupp) - mExtent.height()) / 2;
whitespace = ((myHeight * mMupp) - mExtent.height()) * 0.5;
dymin = mExtent.yMin() - whitespace;
dymax = mExtent.yMax() + whitespace;
}
Expand All @@ -165,7 +167,7 @@ void QgsMapRender::adjustExtentToSize()
mExtent.setXmax(dxmax);
mExtent.setYmin(dymin);
mExtent.setYmax(dymax);

// update the scale
updateScale();

Expand Down

0 comments on commit 1433ca4

Please sign in to comment.