[QGIS Commit] r8441 - trunk/qgis/src/app/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu May 15 08:46:36 EDT 2008
Author: StevenB
Date: 2008-05-15 08:46:36 -0400 (Thu, 15 May 2008)
New Revision: 8441
Modified:
trunk/qgis/src/app/composer/qgscomposer.cpp
trunk/qgis/src/app/composer/qgscomposerview.cpp
Log:
Replaced zoomFull() code with a single QGraphicsView function.
Modified: trunk/qgis/src/app/composer/qgscomposer.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.cpp 2008-05-15 08:13:05 UTC (rev 8440)
+++ trunk/qgis/src/app/composer/qgscomposer.cpp 2008-05-15 12:46:36 UTC (rev 8441)
@@ -225,52 +225,14 @@
void QgsComposer::zoomFull(void)
{
-//can we just use QGraphicsView::fitInView with the "paper" rect?
-
- QMatrix m;
-
- // scale
- double xscale = 1.0 * (mView->width()-10) / mComposition->canvas()->width();
- double yscale = 1.0 * (mView->height()-10) / mComposition->canvas()->height();
- double scale = ( xscale < yscale ? xscale : yscale );
-
- // translate
- double dx = ( mView->width() - scale * mComposition->canvas()->width() ) / 2;
- double dy = ( mView->height() - scale * mComposition->canvas()->height() ) / 2;
-
- m.translate ( dx, dy );
- m.scale( scale, scale );
-
- mView->setMatrix( m );
-// mView->repaintContents(); //needed?
-
+ mView->fitInView(0, 0, mComposition->paperWidth(), mComposition->paperHeight(), Qt::KeepAspectRatio);
}
void QgsComposer::on_mActionZoomAll_activated(void)
{
zoomFull();
}
-/*
-QMatrix QgsComposer::updateMatrix(double scaleChange)
-{
- double scale = mView->matrix().m11() * scaleChange; // get new scale
-
- double dx = ( mView->width() - scale * mComposition->canvas()->width() ) / 2;
- double dy = ( mView->height() - scale * mComposition->canvas()->height() ) / 2;
-
- // don't translate if composition is bigger than view
- if (dx < 0) dx = 0;
- if (dy < 0) dy = 0;
-
- // create new world matrix:
- QMatrix m;
- m.translate ( dx, dy );
- m.scale ( scale, scale );
- return m;
-
-}
-*/
void QgsComposer::on_mActionZoomIn_activated(void)
{
mView->scale(2, 2);
Modified: trunk/qgis/src/app/composer/qgscomposerview.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposerview.cpp 2008-05-15 08:13:05 UTC (rev 8440)
+++ trunk/qgis/src/app/composer/qgscomposerview.cpp 2008-05-15 12:46:36 UTC (rev 8441)
@@ -67,14 +67,15 @@
void QgsComposerView::resizeEvent ( QResizeEvent * )
{
+#ifdef QGISDEBUG
+ std::cout << "QgsComposerView::resizeEvent()" << std::endl;
+#endif
+
/* BUG: When QT adds scrollbars because we're zooming in, it causes a resizeEvent.
* If we call zoomFull(), we reset the view size, which keeps us from zooming in.
* Really, we should do something like re-center the window.
*/
//mComposer->zoomFull();
-#ifdef QGISDEBUG
- std::cout << "resize anchor: " << resizeAnchor() << std::endl;
-#endif
}
//TODO: add mouse wheel event forwarding
More information about the QGIS-commit
mailing list