Opened 4 years ago

Last modified 4 years ago

#21893 closed enhancement

Improve move action (mouse drag of osm primitives) in MapMode by aligning movement if Ctrl modifier key is pressed — at Version 1

Reported by: cmuelle8 Owned by: team
Priority: normal Milestone: 22.06
Component: Core Version: latest
Keywords: SelectAction MapMode MoveCommand Alignment Cc:

Description (last modified by cmuelle8)

The attached patch enhances moving the selection in MapMode.

If Ctrl modifier key is pressed then the last selected way within the selection is used as an alignment reference for the move operation.

The last selected way must consist of exactly two nodes for the mode option to work. It may be the only element in the selection.

Four "zones" (or quadrants) are recognized, each 90° wide. When the mouse is dragged, the angle between the vectors of the mouse move (relative to starting point of the move operation) and the reference way is continuously calculated.

  • within range [0, 45] degrees or [0, pi/2] radians the selection is moved along the reference
  • within range [45, 90] degrees or [pi/2, pi] radians it is moved perpendicular to it

The movement is only ever constrained to these axes if the modifier key "Ctrl" is pressed while a press+hold mouse operation is in progress. The modifier key may be toggled arbitrarily while the selection is moved to toggle the aligning.

It is neither intended to replace the angleSnap feature of the DrawAction, nor the AlignWays plugin that each serve slightly different purposes.


Another way to view the feature is as enhancement of the present keyboard commands that move the selection up/down/left/right (exactly) which aligned a selection move to the cardinal directions north/south/west/east respectively.

The code reuses functions present in class EastNorth to determine the difference between the headings of the vectors end points.

It has been tested to not interfer with the other use of Ctrl modifier key in mapmode, which is mergeNodes() feature:

  • if Ctrl is held at release of the mouse button and a NodeToMerge was found, a Merge operation is carried out as expected from previous behavior
  • if Ctrl is released before the mouse button is released, no node merge is performed
    • this is relevant only if a node to merge to is identified at the location the user wants to finish the drag operation
    • if the node merge is not desirable some care must be taken to not additionally move the mouse within the timespan Ctrl key and mouse button are released (in that order)

Although basic testing has been done, please test and improve the code changes before depending on them productively.

A specific use case for this is generating trapezoidal shapes or parallelograms (in combination with parallel ways tool, for instance).

Change History (2)

by cmuelle8, 4 years ago

josm_SelectAction_-_movement_with_modifier_key_-_align_movement_to_vector_given_by_way_last_selected_in_selection

comment:1 by cmuelle8, 4 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.