Skip to content

Commit 97c48bd

Browse files
committed
MoveParallelTool: Add the tool for parallel object moves
The tool moves lines and area boundaries to create a larger or a smaller shape parallel to the original object. The tool reuses LineSymbol::shiftCoordinates() which currently does not handle shape degeneration. I.e., curve turns do not shrink into points but rather form a "negative" shape that is a mathematically exact image of the original curve but usually is not what the user expects. Closes GH-650
1 parent 9ede2de commit 97c48bd

File tree

10 files changed

+670
-0
lines changed

10 files changed

+670
-0
lines changed

images/cursor-move-parallel.png

1.46 KB
Loading
Lines changed: 181 additions & 0 deletions
Loading

images/svg/tool-move-parallel.svg

Lines changed: 120 additions & 0 deletions
Loading

images/tool-move-parallel.png

974 Bytes
Loading

resources.qrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<file>images/cursor-georeferencing-move.png</file>
2727
<file>images/cursor-hollow.png</file>
2828
<file>images/cursor-invisible.png</file>
29+
<file>images/cursor-move-parallel.png</file>
2930
<file>images/cursor-rotate.png</file>
3031
<file>images/cursor-scale.png</file>
3132
<file>images/cut.png</file>
@@ -102,6 +103,7 @@
102103
<file>images/tool-fill-border.png</file>
103104
<file>images/tool-gps-display.png</file>
104105
<file>images/tool-measure.png</file>
106+
<file>images/tool-move-parallel.png</file>
105107
<file>images/tool-rotate.png</file>
106108
<file>images/tool-rotate-pattern.png</file>
107109
<file>images/tool-scale.png</file>

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ set(Mapper_Common_SRCS
240240
tools/object_selector.cpp
241241
tools/pan_tool.cpp
242242
tools/point_handles.cpp
243+
tools/move_parallel_tool.cpp
243244
tools/rotate_tool.cpp
244245
tools/rotate_pattern_tool.cpp
245246
tools/scale_tool.cpp

src/gui/map/map_editor.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
#include "tools/edit_line_tool.h"
159159
#include "tools/fill_tool.h"
160160
#include "tools/pan_tool.h"
161+
#include "tools/move_parallel_tool.h"
161162
#include "tools/rotate_pattern_tool.h"
162163
#include "tools/rotate_tool.h"
163164
#include "tools/scale_tool.h"
@@ -936,6 +937,7 @@ void MapEditorController::assignKeyboardShortcuts()
936937
findAction("scaleobjects")->setShortcut(QKeySequence(tr("Z")));
937938
findAction("cutobject")->setShortcut(QKeySequence(tr("K")));
938939
findAction("cuthole")->setShortcut(QKeySequence(tr("H")));
940+
findAction("moveparallel")->setShortcut(QKeySequence(tr("Ctrl+Shift+M")));
939941
findAction("measure")->setShortcut(QKeySequence(tr("M")));
940942
findAction("booleanunion")->setShortcut(QKeySequence(tr("U")));
941943
findAction("converttocurves")->setShortcut(QKeySequence(tr("N")));
@@ -1055,6 +1057,7 @@ void MapEditorController::createActions()
10551057
cut_hole_menu->addAction(cut_hole_circle_act);
10561058
cut_hole_menu->addAction(cut_hole_rectangle_act);
10571059

1060+
move_parallel_act = newToolAction("moveparallel", tr("Move parallel"), this, SLOT(moveParallelClicked()), "tool-move-parallel.png", QString{}, "toolbars.html#tool_move_parallel");
10581061
rotate_act = newToolAction("rotateobjects", tr("Rotate objects"), this, SLOT(rotateClicked()), "tool-rotate.png", QString{}, "toolbars.html#rotate");
10591062
rotate_pattern_act = newToolAction("rotatepatterns", tr("Rotate pattern"), this, SLOT(rotatePatternClicked()), "tool-rotate-pattern.png", QString{}, "toolbars.html#tool_rotate_pattern");
10601063
scale_act = newToolAction("scaleobjects", tr("Scale objects"), this, SLOT(scaleClicked()), "tool-scale.png", QString{}, "toolbars.html#scale");
@@ -1226,6 +1229,7 @@ void MapEditorController::createMenuAndToolbars()
12261229
tools_menu->addAction(boolean_merge_holes_act);
12271230
tools_menu->addAction(cut_tool_act);
12281231
tools_menu->addMenu(cut_hole_menu);
1232+
tools_menu->addAction(move_parallel_act);
12291233
tools_menu->addAction(rotate_act);
12301234
tools_menu->addAction(rotate_pattern_act);
12311235
tools_menu->addAction(scale_act);
@@ -1363,6 +1367,7 @@ void MapEditorController::createMenuAndToolbars()
13631367
cut_hole_button->setMenu(cut_hole_menu);
13641368
toolbar_editing->addWidget(cut_hole_button);
13651369

1370+
toolbar_editing->addAction(move_parallel_act);
13661371
toolbar_editing->addAction(rotate_act);
13671372
toolbar_editing->addAction(rotate_pattern_act);
13681373
toolbar_editing->addAction(scale_act);
@@ -2616,6 +2621,8 @@ void MapEditorController::updateObjectDependentActions()
26162621
cut_tool_act->setStatusTip(tr("Cut the selected objects into smaller parts.") + (cut_tool_act->isEnabled() ? QString{} : QString(QLatin1Char(' ') + tr("Select at least one line or area object to activate this tool."))));
26172622
convert_to_curves_act->setEnabled(have_area || have_line);
26182623
convert_to_curves_act->setStatusTip(tr("Turn paths made of straight segments into smooth bezier splines.") + (convert_to_curves_act->isEnabled() ? QString{} : QString(QLatin1Char(' ') + tr("Select a path object to activate this tool."))));
2624+
move_parallel_act->setEnabled(have_area || have_line);
2625+
move_parallel_act->setStatusTip(tr("Move lines and area borders in and out.") + (move_parallel_act->isEnabled() ? QString{} : QString(QLatin1Char(' ') + tr("Select at least one line or area object to activate this tool."))));
26192626
simplify_path_act->setEnabled(have_area || have_line);
26202627
simplify_path_act->setStatusTip(tr("Reduce the number of points in path objects while trying to retain their shape.") + (simplify_path_act->isEnabled() ? QString{} : QString(QLatin1Char(' ') + tr("Select a path object to activate this tool."))));
26212628

@@ -2719,6 +2726,11 @@ void MapEditorController::editLineToolClicked()
27192726
setTool(new EditLineTool(this, edit_line_tool_act));
27202727
}
27212728

2729+
void MapEditorController::moveParallelClicked()
2730+
{
2731+
setTool(new MoveParallelTool(this, move_parallel_act));
2732+
}
2733+
27222734
void MapEditorController::drawPointClicked()
27232735
{
27242736
setTool(new DrawPointTool(this, draw_point_act));

0 commit comments

Comments
 (0)