fix: always flip according to current viewport state
This commit is contained in:
parent
483bb07b09
commit
e1324d901c
|
@ -135,11 +135,12 @@ void GraphicsView::zoomView(qreal scaleFactor)
|
||||||
|
|
||||||
void GraphicsView::flipView(bool horizontal)
|
void GraphicsView::flipView(bool horizontal)
|
||||||
{
|
{
|
||||||
if (horizontal) {
|
QTransform tf(horizontal ? -1 : 1, 0, 0,
|
||||||
scale(-1, 1);
|
0, horizontal ? 1 : -1, 0,
|
||||||
} else {
|
0, 0, 1);
|
||||||
scale(1, -1);
|
tf = transform() * tf;
|
||||||
}
|
setTransform(tf);
|
||||||
|
|
||||||
// Ensure the navigation view is also flipped.
|
// Ensure the navigation view is also flipped.
|
||||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
}
|
}
|
||||||
|
@ -179,6 +180,8 @@ inline double zeroOrOne(double number)
|
||||||
return qFuzzyIsNull(number) ? 0 : (number > 0 ? 1 : -1);
|
return qFuzzyIsNull(number) ? 0 : (number > 0 ? 1 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: this only works if we only have 90 degree based rotation
|
||||||
|
// and no shear/translate.
|
||||||
QTransform GraphicsView::resetScale(const QTransform & orig)
|
QTransform GraphicsView::resetScale(const QTransform & orig)
|
||||||
{
|
{
|
||||||
return QTransform(zeroOrOne(orig.m11()), zeroOrOne(orig.m12()),
|
return QTransform(zeroOrOne(orig.m11()), zeroOrOne(orig.m12()),
|
||||||
|
@ -349,10 +352,3 @@ void GraphicsView::applyTransformationModeByScaleFactor()
|
||||||
scene()->trySetTransformationMode(Qt::FastTransformation);
|
scene()->trySetTransformationMode(Qt::FastTransformation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsView::resetWithScaleAndRotate(qreal scaleFactor, qreal rotateAngle)
|
|
||||||
{
|
|
||||||
QGraphicsView::resetTransform();
|
|
||||||
scale(scaleFactor, scaleFactor);
|
|
||||||
rotate(rotateAngle);
|
|
||||||
}
|
|
||||||
|
|
|
@ -59,8 +59,6 @@ private:
|
||||||
void setCheckerboardEnabled(bool enabled, bool invertColor = false);
|
void setCheckerboardEnabled(bool enabled, bool invertColor = false);
|
||||||
void applyTransformationModeByScaleFactor();
|
void applyTransformationModeByScaleFactor();
|
||||||
|
|
||||||
void resetWithScaleAndRotate(qreal scaleFactor, qreal rotateAngle);
|
|
||||||
|
|
||||||
bool m_enableFitInView = false;
|
bool m_enableFitInView = false;
|
||||||
bool m_checkerboardEnabled = false;
|
bool m_checkerboardEnabled = false;
|
||||||
bool m_isLastCheckerboardColorInverted = false;
|
bool m_isLastCheckerboardColorInverted = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user