Issue #1850 - Undoing the "straighten" operation in the Measure tool ...

... does not restore the measure points

Halt the measure tool after straightening, thus removing the
expectation that undoing the operation should restore the original
points.

Halting the tool, rather than making undo work "as expected",
sidesteps several issues:

  - Implementing undo correctly is tricky, since image-undo and
    tool-undo are handled separately.

  - In fact, the measure tool doesn't provide tool-undo, so that
    image edits can be undone while the tool is active without
    affecting the tool, and it's not clear that we want to change
    this behavior.  However, this makes undoing a straighten
    operation a special case, and it's not entirely clear what the
    behavior should be when undoing other kinds of transformations,
    or when the measure points had changed since the straighten
    operation.

  - Perhaps most importantly, measure tool points are restricted to
    the pixel grid, which means that when measuring an angle
    against an orientation that's not fully horizontal or vertical
    in image space (either using a 3-point angle, or when the
    canvas is rotated), the resulting transformed point after
    straightening doesn't generally land on the pixel grid, causing
    it to be rounded, which can result in a non-zero angle after
    the rotation.  This is especially ugly, since clicking
    "straighten" again at this point would cause another non-
    trivial rotation.
This commit is contained in:
Ell
2018-07-16 00:57:41 -04:00
parent 7a91aabf37
commit 2e08c9164a

View File

@ -852,24 +852,5 @@ gimp_measure_tool_straighten_button_clicked (GtkWidget *button,
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (measure);
if (gimp_transform_tool_transform (tr_tool, tool->display))
{
gdouble x0, y0;
gdouble x1, y1;
gimp_matrix3_transform_point (&tr_tool->transform,
measure->x[0],
measure->y[0],
&x0, &y0);
gimp_matrix3_transform_point (&tr_tool->transform,
measure->x[1],
measure->y[1],
&x1, &y1);
g_object_set (measure->widget,
"x1", SIGNED_ROUND (x0),
"y1", SIGNED_ROUND (y0),
"x2", SIGNED_ROUND (x1),
"y2", SIGNED_ROUND (y1),
NULL);
}
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, tool->display);
}