From 2ea69ca9ef6160535b5d5ed3d437b767085d7493 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Wed, 27 May 2020 12:50:14 +0200 Subject: basegfx: test of coordinate system conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I059d1f272f0633c450287f272083bb09732357b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95304 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit b5dee02018f9f7cd8d9afc6e8991e6e20ebb0e81) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95915 Tested-by: Tomaž Vajngerl --- basegfx/test/B2DHomMatrixTest.cxx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'basegfx') diff --git a/basegfx/test/B2DHomMatrixTest.cxx b/basegfx/test/B2DHomMatrixTest.cxx index 8063587ac2dd..e5b923e6dd82 100644 --- a/basegfx/test/B2DHomMatrixTest.cxx +++ b/basegfx/test/B2DHomMatrixTest.cxx @@ -503,6 +503,36 @@ public: CPPUNIT_ASSERT_DOUBLES_EQUAL(26, aRange.getMaxY(), 1E-12); } + void testCoordinateSystemConversion() + { + // Use case when we convert + + B2DRange aWindow(50, 50, 150, 150); + + B2DRange aSubPage(0, 0, 2000, 2000); + + B2DHomMatrix aB2DMatrix; + aB2DMatrix.scale(aWindow.getWidth() / aSubPage.getWidth(), + aWindow.getHeight() / aSubPage.getHeight()); + aB2DMatrix.translate(aWindow.getMinX(), aWindow.getMinY()); + + B2DPoint aPoint1(0, 0); + aPoint1 *= aB2DMatrix; + + CPPUNIT_ASSERT_DOUBLES_EQUAL(50, aPoint1.getX(), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(50, aPoint1.getY(), 1E-12); + + B2DPoint aPoint2(1000, 1000); + aPoint2 *= aB2DMatrix; + CPPUNIT_ASSERT_DOUBLES_EQUAL(100, aPoint2.getX(), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(100, aPoint2.getY(), 1E-12); + + B2DPoint aPoint3(2000, 2000); + aPoint3 *= aB2DMatrix; + CPPUNIT_ASSERT_DOUBLES_EQUAL(150, aPoint3.getX(), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(150, aPoint3.getY(), 1E-12); + } + // Change the following lines only, if you add, remove or rename // member functions of the current class, // because these macros are need by auto register mechanism. @@ -520,6 +550,8 @@ public: CPPUNIT_TEST(testMultiplyWithAnotherMatrix); CPPUNIT_TEST(testTransformPoint); CPPUNIT_TEST(testTransformRange); + CPPUNIT_TEST(testCoordinateSystemConversion); + CPPUNIT_TEST_SUITE_END(); }; // class b2dhommatrix -- cgit