本文整理汇总了C++中ZoomAndPanTester::canvasWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ ZoomAndPanTester::canvasWidget方法的具体用法?C++ ZoomAndPanTester::canvasWidget怎么用?C++ ZoomAndPanTester::canvasWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZoomAndPanTester
的用法示例。
在下文中一共展示了ZoomAndPanTester::canvasWidget方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeViewport
void KisZoomAndPanTest::initializeViewport(ZoomAndPanTester &t, bool fullscreenMode, bool rotate, bool mirror)
{
QCOMPARE(t.image()->size(), QSize(640,441));
QCOMPARE(t.image()->xRes(), 1.0);
QCOMPARE(t.image()->yRes(), 1.0);
t.canvasController()->resize(QSize(500,500));
t.zoomController()->setZoom(KoZoomMode::ZOOM_CONSTANT, 1.0);
t.canvasController()->setPreferredCenter(QPoint(320,220));
QCOMPARE(t.canvasWidget()->size(), QSize(483,483));
QCOMPARE(t.canvasWidget()->size(), t.canvasController()->viewportSize());
QVERIFY(verifyOffset(t, QPoint(79,-21)));
if (fullscreenMode) {
QCOMPARE(t.canvasController()->preferredCenter(), QPointF(320,220));
QAction *action = t.view()->actionCollection()->action("view_show_just_the_canvas");
action->setChecked(true);
QVERIFY(verifyOffset(t, QPoint(79,-21)));
QCOMPARE(t.canvasController()->preferredCenter(), QPointF(329,220));
t.canvasController()->resize(QSize(483,483));
QCOMPARE(t.canvasWidget()->size(), QSize(483,483));
QCOMPARE(t.canvasWidget()->size(), t.canvasController()->viewportSize());
QVERIFY(verifyOffset(t, QPoint(79,-21)));
/**
* FIXME: here is a small flaw in KoCanvasControllerWidget
* We cannot set the center point explicitly, because it'll be rounded
* up by recenterPreferred function, so real center point will be
* different. Make the preferredCenter() return real center of the
* image instead of the set value
*/
QCOMPARE(t.canvasController()->preferredCenter(), QPointF(320.5,220));
}
if (rotate) {
t.canvasController()->rotateCanvas(90);
QVERIFY(verifyOffset(t, QPoint(-21,79)));
QVERIFY(compareWithRounding(QPointF(220,320), t.canvasController()->preferredCenter(), 2));
QCOMPARE(t.coordinatesConverter()->imageRectInWidgetPixels().topLeft().toPoint(), -t.coordinatesConverter()->documentOffset());
}
if (mirror) {
t.canvasController()->mirrorCanvas(true);
QVERIFY(verifyOffset(t, QPoint(78, -21)));
QVERIFY(compareWithRounding(QPointF(320,220), t.canvasController()->preferredCenter(), 2));
QCOMPARE(t.coordinatesConverter()->imageRectInWidgetPixels().topLeft().toPoint(), -t.coordinatesConverter()->documentOffset());
}
}
示例2: QCOMPARE
void KisZoomAndPanTest::testZoom100ChangingWidgetSize()
{
ZoomAndPanTester t;
QCOMPARE(t.image()->size(), QSize(640,441));
QCOMPARE(t.image()->xRes(), 1.0);
QCOMPARE(t.image()->yRes(), 1.0);
t.canvasController()->resize(QSize(1000,1000));
t.zoomController()->setZoom(KoZoomMode::ZOOM_CONSTANT, 1.0);
t.canvasController()->setPreferredCenter(QPoint(320,220));
QCOMPARE(t.canvasWidget()->size(), QSize(983,983));
QCOMPARE(t.canvasWidget()->size(), t.canvasController()->viewportSize());
QVERIFY(verifyOffset(t, QPoint(-171,-271)));
t.canvasController()->resize(QSize(700,700));
QCOMPARE(t.canvasWidget()->size(), QSize(683,683));
QCOMPARE(t.canvasWidget()->size(), t.canvasController()->viewportSize());
QVERIFY(verifyOffset(t, QPoint(-171,-271)));
t.canvasController()->setPreferredCenter(QPoint(320,220));
QVERIFY(verifyOffset(t, QPoint(-21,-121)));
t.canvasController()->resize(QSize(400,400));
QCOMPARE(t.canvasWidget()->size(), QSize(383,383));
QCOMPARE(t.canvasWidget()->size(), t.canvasController()->viewportSize());
QVERIFY(verifyOffset(t, QPoint(-21,-121)));
t.canvasController()->setPreferredCenter(QPoint(320,220));
QVERIFY(verifyOffset(t, QPoint(129,29)));
t.canvasController()->pan(QPoint(100,100));
QVERIFY(verifyOffset(t, QPoint(229,129)));
}
示例3: verifyOffset
bool verifyOffset(ZoomAndPanTester &t, const QPoint &offset) {
if (t.coordinatesConverter()->documentOffset() != offset) {
qDebug() << "########################";
qDebug() << "Expected Offset:" << offset;
qDebug() << "Actual values:";
qDebug() << "Offset:" << t.coordinatesConverter()->documentOffset();
qDebug() << "wsize:" << t.canvasWidget()->size();
qDebug() << "vport:" << t.canvasController()->viewportSize();
qDebug() << "pref:" << t.canvasController()->preferredCenter();
qDebug() << "########################";
}
return t.coordinatesConverter()->documentOffset() == offset;
}
示例4: testRotation
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));
}
}
示例5: checkRotation
bool KisZoomAndPanTest::checkRotation(ZoomAndPanTester &t, qreal angle)
{
// save old values
QPoint oldOffset = t.coordinatesConverter()->documentOffset();
QPointF oldCenteringCorrection = t.coordinatesConverter()->centeringCorrection();
QPointF oldPreferredCenter = t.canvasController()->preferredCenter();
QPointF oldRealCenterPoint = t.coordinatesConverter()->widgetToImage(t.coordinatesConverter()->widgetCenterPoint());
QSize oldDocumentSize = t.canvasController()->documentSize();
qreal baseAngle = t.coordinatesConverter()->rotationAngle();
t.canvasController()->rotateCanvas(angle);
// save result values
QPoint newOffset = t.coordinatesConverter()->documentOffset();
QPointF newCenteringCorrection = t.coordinatesConverter()->centeringCorrection();
QPointF newPreferredCenter = t.canvasController()->preferredCenter();
QPointF newRealCenterPoint = t.coordinatesConverter()->widgetToImage(t.coordinatesConverter()->widgetCenterPoint());
QSize newDocumentSize = t.canvasController()->documentSize();
// calculate theoretical preferred center
QTransform rot;
rot.rotate(angle);
QSizeF dSize = t.coordinatesConverter()->imageSizeInFlakePixels();
QPointF dPoint(dSize.width(), dSize.height());
QPointF expectedPreferredCenter =
(oldPreferredCenter - dPoint * correctionMatrix(baseAngle)) * rot +
dPoint * correctionMatrix(baseAngle + angle);
// calculate theoretical offset based on the real preferred center
QPointF wPoint(t.canvasWidget()->size().width(), t.canvasWidget()->size().height());
QPointF expectedOldOffset = oldPreferredCenter - 0.5 * wPoint;
QPointF expectedNewOffset = newPreferredCenter - 0.5 * wPoint;
bool preferredCenterAsExpected =
compareWithRounding(expectedPreferredCenter, newPreferredCenter, 2);
bool oldOffsetAsExpected =
compareWithRounding(expectedOldOffset + oldCenteringCorrection, QPointF(oldOffset), 2);
bool newOffsetAsExpected =
compareWithRounding(expectedNewOffset + newCenteringCorrection, QPointF(newOffset), 3);
qreal zoom = t.zoomController()->zoomAction()->effectiveZoom();
bool realCenterPointAsExpected =
compareWithRounding(oldRealCenterPoint, newRealCenterPoint, 2/zoom);
if (!oldOffsetAsExpected ||
!newOffsetAsExpected ||
!preferredCenterAsExpected ||
!realCenterPointAsExpected) {
qDebug() << "***** ROTATE **************";
if(!oldOffsetAsExpected) {
qDebug() << " ### Old offset invariant broken";
}
if(!newOffsetAsExpected) {
qDebug() << " ### New offset invariant broken";
}
if(!preferredCenterAsExpected) {
qDebug() << " ### Preferred center invariant broken";
}
if(!realCenterPointAsExpected) {
qDebug() << " ### *Real* center invariant broken";
}
qDebug() << ppVar(expectedOldOffset);
qDebug() << ppVar(expectedNewOffset);
qDebug() << ppVar(expectedPreferredCenter);
qDebug() << ppVar(oldOffset) << ppVar(newOffset);
qDebug() << ppVar(oldCenteringCorrection) << ppVar(newCenteringCorrection);
qDebug() << ppVar(oldPreferredCenter) << ppVar(newPreferredCenter);
qDebug() << ppVar(oldRealCenterPoint) << ppVar(newRealCenterPoint);
qDebug() << ppVar(oldDocumentSize) << ppVar(newDocumentSize);
qDebug() << ppVar(baseAngle) << "deg";
qDebug() << ppVar(angle) << "deg";
qDebug() << "***************************";
}
return preferredCenterAsExpected && oldOffsetAsExpected && newOffsetAsExpected && realCenterPointAsExpected;
}