Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port ability to wheel zoom into/out of layout designer
- Loading branch information
1 parent
4065a7f
commit 20ca51b
Showing
5 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- coding: utf-8 -*- | ||
"""QGIS Unit tests for QgsLayoutView. | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
""" | ||
__author__ = 'Nyall Dawson' | ||
__date__ = '05/07/2017' | ||
__copyright__ = 'Copyright 2017, The QGIS Project' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
import qgis # NOQA | ||
|
||
from qgis.gui import QgsLayoutView | ||
from qgis.PyQt.QtCore import QRectF | ||
from qgis.PyQt.QtGui import QTransform | ||
|
||
from qgis.testing import start_app, unittest | ||
|
||
start_app() | ||
|
||
|
||
class TestQgsLayoutView(unittest.TestCase): | ||
|
||
def testScaleSafe(self): | ||
""" test scaleSafe method """ | ||
|
||
view = QgsLayoutView() | ||
view.fitInView(QRectF(0, 0, 10, 10)) | ||
scale = view.transform().m11() | ||
view.scaleSafe(2) | ||
self.assertAlmostEqual(view.transform().m11(), 2) | ||
view.scaleSafe(4) | ||
self.assertAlmostEqual(view.transform().m11(), 8) | ||
|
||
# try to zoom in heaps | ||
view.scaleSafe(99999999) | ||
# assume we have hit the limit | ||
scale = view.transform().m11() | ||
view.scaleSafe(2) | ||
self.assertAlmostEqual(view.transform().m11(), scale) | ||
|
||
view.setTransform(QTransform.fromScale(1, 1)) | ||
self.assertAlmostEqual(view.transform().m11(), 1) | ||
# test zooming out | ||
view.scaleSafe(0.5) | ||
self.assertAlmostEqual(view.transform().m11(), 0.5) | ||
view.scaleSafe(0.1) | ||
self.assertAlmostEqual(view.transform().m11(), 0.05) | ||
|
||
# try zooming out heaps | ||
view.scaleSafe(0.000000001) | ||
# assume we have hit the limit | ||
scale = view.transform().m11() | ||
view.scaleSafe(0.5) | ||
self.assertAlmostEqual(view.transform().m11(), scale) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |