Commit d3d45edd authored by Dmitry Kazakov's avatar Dmitry Kazakov

Add ability to reset the transformation frame even when it was loaded form the previous action

Fixes T2326
BUG:361852
parent 62a299cb
......@@ -1100,7 +1100,20 @@ void KisToolTransform::slotResetTransform()
if (m_currentArgs.continuedTransform()) {
ToolTransformArgs::TransformMode savedMode = m_currentArgs.mode();
if (m_currentArgs.continuedTransform()->mode() == savedMode) {
/**
* Our reset transform button can be used for two purposes:
*
* 1) Reset current transform to the initial one, which was
* loaded from the previous user action.
*
* 2) Reset transform frame to infinity when the frame is unchanged
*/
const bool transformDiffers = !m_currentArgs.continuedTransform()->isSameMode(m_currentArgs);
if (transformDiffers &&
m_currentArgs.continuedTransform()->mode() == savedMode) {
m_currentArgs.restoreContinuedState();
initGuiAfterTransformMode();
slotEditingFinished();
......
......@@ -158,6 +158,53 @@ bool ToolTransformArgs::operator==(const ToolTransformArgs& other) const
|| m_liquifyWorker == other.m_liquifyWorker);
}
bool ToolTransformArgs::isSameMode(const ToolTransformArgs& other) const
{
if (m_mode != other.m_mode) return false;
bool result = true;
if (m_mode == FREE_TRANSFORM) {
result &= m_transformedCenter == other.m_transformedCenter;
result &= m_originalCenter == other.m_originalCenter;
result &= m_scaleX == other.m_scaleX;
result &= m_scaleY == other.m_scaleY;
result &= m_shearX == other.m_shearX;
result &= m_shearY == other.m_shearY;
result &= m_aX == other.m_aX;
result &= m_aY == other.m_aY;
result &= m_aZ == other.m_aZ;
} else if (m_mode == PERSPECTIVE_4POINT) {
result &= m_transformedCenter == other.m_transformedCenter;
result &= m_originalCenter == other.m_originalCenter;
result &= m_scaleX == other.m_scaleX;
result &= m_scaleY == other.m_scaleY;
result &= m_shearX == other.m_shearX;
result &= m_shearY == other.m_shearY;
result &= m_flattenedPerspectiveTransform == other.m_flattenedPerspectiveTransform;
} else if(m_mode == WARP || m_mode == CAGE) {
result &= m_origPoints == other.m_origPoints;
result &= m_transfPoints == other.m_transfPoints;
} else if (m_mode == LIQUIFY) {
result &= m_liquifyProperties &&
(m_liquifyProperties == other.m_liquifyProperties ||
*m_liquifyProperties == *other.m_liquifyProperties);
result &=
(m_liquifyWorker && other.m_liquifyWorker &&
*m_liquifyWorker == *other.m_liquifyWorker)
|| m_liquifyWorker == other.m_liquifyWorker;
} else {
KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "unknown transform mode");
}
return result;
}
ToolTransformArgs::ToolTransformArgs(TransformMode mode,
QPointF transformedCenter,
QPointF originalCenter,
......
......@@ -81,6 +81,7 @@ public:
ToolTransformArgs& operator=(const ToolTransformArgs& args);
bool operator==(const ToolTransformArgs& other) const;
bool isSameMode(const ToolTransformArgs& other) const;
inline TransformMode mode() const {
return m_mode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment