Commit 76255392 authored by Michael Abrahams's avatar Michael Abrahams

Snap free transform with shift key

BUG: 349782
parent f52db296
......@@ -385,6 +385,8 @@ bool KisFreeTransformStrategy::beginPrimaryAction(const QPointF &pt)
void KisFreeTransformStrategy::continuePrimaryAction(const QPointF &mousePos, bool specialModifierActive)
{
// Note: "specialModifierActive" just tells us if the shift key is being pressed
switch (m_d->function) {
case MOVE: {
QPointF diff = mousePos - m_d->clickPos;
......@@ -421,9 +423,18 @@ void KisFreeTransformStrategy::continuePrimaryAction(const QPointF &mousePos, bo
qreal a1 = atan2(clickMouseImagePos.y(), clickMouseImagePos.x());
qreal a2 = atan2(mouseImagePos.y(), mouseImagePos.x());
double theta = -a1 + a2;
qreal theta = a2 - a1;
m_d->currentArgs.setAZ(normalizeAngle(m_d->clickArgs.aZ() + theta));
// Snap with shift key
if (specialModifierActive) {
const qreal snapAngle = M_PI_4 / 6.0; // fifteen degrees
qint32 thetaIndex = static_cast<qint32>((theta / snapAngle) + 0.5);
m_d->currentArgs.setAZ(normalizeAngle(thetaIndex * snapAngle));
}
else {
m_d->currentArgs.setAZ(normalizeAngle(m_d->clickArgs.aZ() + theta));
}
KisTransformUtils::MatricesPack m(m_d->currentArgs);
QTransform t = m.finalTransform();
......
......@@ -61,17 +61,25 @@ class KisPerspectiveTransformStrategy;
/**
* Transform tool
* The tool offers two different modes : Free Transform and Warp
* - Free Transform mode allows the user to translate, scale, shear, rotate
* and apply a perspective transformation to a selection or the whole
* canvas.
* - Warp mode allows the user to warp the selection of the canvas
* by grabbing and moving control points placed on the image.
* The user can either work with default control points, like a grid
* whose density can be modified, or place the control points manually.
* The modifications made on the selected pixels are applied only when
* the user clicks the Apply button : the semi-transparent image displayed
* until the user click that button is only a preview.
* This tool offers several modes.
* - Free Transform mode allows the user to translate, scale, shear, rotate and
* apply a perspective transformation to a selection or the whole canvas.
* - Warp mode allows the user to warp the selection of the canvas by grabbing
* and moving control points placed on the image. The user can either work
* with default control points, like a grid whose density can be modified, or
* place the control points manually. The modifications made on the selected
* pixels are applied only when the user clicks the Apply button : the
* semi-transparent image displayed until the user click that button is only a
* preview.
* - Cage transform is similar to warp transform with control points exactly
* placed on the outer boundary. The user draws a boundary polygon, the
* vertices of which become control points.
* - Perspective transform applies a two-point perspective transformation. The
* user can manipulate the corners of the selection. If the vanishing points
* of the resulting quadrilateral are on screen, the user can manipulate those
* as well.
* - Liquify transform transforms the selection by painting motions, as if the
* user were fingerpainting.
*/
class KisToolTransform : public KisTool
{
......
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