void PANEL_PREV_3D::getOrientationVars( SGPOINT& scale, SGPOINT& rotation, SGPOINT& offset ) { if( NULL == xscale || NULL == yscale || NULL == zscale || NULL == xrot || NULL == yrot || NULL == zrot || NULL == xoff || NULL == yoff || NULL == zoff ) { return; } xscale->GetValue().ToDouble( &scale.x ); yscale->GetValue().ToDouble( &scale.y ); zscale->GetValue().ToDouble( &scale.z ); if( 0.0001 > scale.x || 0.0001 > scale.y || 0.0001 > scale.z ) { wxString errmsg = _("[INFO] invalid scale values; setting all to 1.0"); wxLogMessage( "%s", errmsg.ToUTF8() ); scale.x = 1.0; scale.y = 1.0; scale.z = 1.0; } xrot->GetValue().ToDouble( &rotation.x ); yrot->GetValue().ToDouble( &rotation.y ); zrot->GetValue().ToDouble( &rotation.z ); checkRotation( rotation.x ); checkRotation( rotation.y ); checkRotation( rotation.z ); xoff->GetValue().ToDouble( &offset.x ); yoff->GetValue().ToDouble( &offset.y ); zoff->GetValue().ToDouble( &offset.z ); return; }
void KisZoomAndPanTest::testRotation(qreal vastScrolling, qreal zoom) { KisConfig cfg; cfg.setVastScrolling(vastScrolling); ZoomAndPanTester t; QCOMPARE(t.image()->size(), QSize(640,441)); QCOMPARE(t.image()->xRes(), 1.0); QCOMPARE(t.image()->yRes(), 1.0); QPointF preferredCenter = zoom * t.image()->bounds().center(); t.canvasController()->resize(QSize(500,500)); t.zoomController()->setZoom(KoZoomMode::ZOOM_CONSTANT, zoom); t.canvasController()->setPreferredCenter(preferredCenter.toPoint()); QCOMPARE(t.canvasWidget()->size(), QSize(483,483)); QCOMPARE(t.canvasWidget()->size(), t.canvasController()->viewportSize()); QPointF realCenterPoint = t.coordinatesConverter()->widgetToImage(t.coordinatesConverter()->widgetCenterPoint()); QPointF expectedCenterPoint = QPointF(t.image()->bounds().center()); if(!compareWithRounding(realCenterPoint, expectedCenterPoint, 2/zoom)) { qDebug() << "Failed to set initial center point"; qDebug() << ppVar(expectedCenterPoint) << ppVar(realCenterPoint); QFAIL("FAIL: Failed to set initial center point"); } QVERIFY(checkRotation(t, 30)); QVERIFY(checkRotation(t, 20)); QVERIFY(checkRotation(t, 10)); QVERIFY(checkRotation(t, 5)); QVERIFY(checkRotation(t, 5)); QVERIFY(checkRotation(t, 5)); if(vastScrolling < 0.5 && zoom < 1) { qWarning() << "Disabling a few tests for vast scrolling =" << vastScrolling << ". See comment for more"; /** * We have to disable a couple of tests here for the case when * vastScrolling value is 0.2. The problem is that the centering * correction applied to the offset in * KisCanvasController::rotateCanvas pollutes the preferredCenter * value, because KoCnvasControllerWidget has no access to this * correction and cannot calculate the real value of the center of * the image. To fix this bug the calculation of correction * (aka "origin") should be moved to the KoCanvasControllerWidget * itself which would cause quite huge changes (including the change * of the external interface of it). Namely, we would have to * *calculate* offset from the value of the scroll bars, but not * use their values directly: * * offset = scrollBarValue - origin * * So now we just disable these unittests and allow a couple * of "jumping" bugs appear in vastScrolling < 0.5 modes, which * is, actually, not the default case. */ } else { QVERIFY(checkRotation(t, 5)); QVERIFY(checkRotation(t, 5)); QVERIFY(checkRotation(t, 5)); } }