Opened 13 years ago
Closed 12 years ago
#6694 closed enhancement (fixed)
Key combination to draw lines on multiples of 15 degrees (15°/30°/45°/60°/75°/90°...)
Reported by: | anonymous | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core | Version: | |
Keywords: | Cc: |
Description (last modified by )
Could you add a key combination or modifier (Alt + Shift?) to the Draw nodes (A) tool that allows you draw only new segments that are X degrees apart from the previous segment, where X is a multiple of 15?
This would allow the creation of geometrically precise areas in an easy way. Such functionality is available on all the vector graphics applications: Inkscape, Blender, Gimp (in its vector parts), ecc.
Attachments (9)
Change History (48)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Type: | defect → enhancement |
---|
comment:3 by , 12 years ago
Description: | modified (diff) |
---|
Here is the patch I made. Please have a look at it when you have time.
Patch is looking rather messy because of moving large fragments of code to different lines.
The code of DrawAction is huge and very complex. I tried not to affect its general behaviour, only extracted some code fragments into separate function.
SnapHelper is the new inner class which manages angle snapping.
Angle Snapping is activated by pressing TAB button while in drawing mode currently.
by , 12 years ago
Attachment: | AngleSnapping.patch added |
---|
comment:4 by , 12 years ago
Summary: | Key combination to draw lines on multiples of 15 degrees (15°/30°/45°/60°/75°/90°...) → [PATCH] Key combination to draw lines on multiples of 15 degrees (15°/30°/45°/60°/75°/90°...) |
---|
follow-up: 6 comment:5 by , 12 years ago
No additional classes in one source file please. It must be in an own class file somewhere (utils maybe or gui, ...)
comment:6 by , 12 years ago
Replying to stoecker:
No additional classes in one source file please. It must be in an own class file somewhere (utils maybe or gui, ...)
We have lots of inner classes in lots of source files. Question is: Can this be used somewhere else?
comment:7 by , 12 years ago
In current state SnapHelper can not be used anywhere else, because it use some fields from outer class. Is it possible that someone will need such specific functionality?
comment:8 by , 12 years ago
If we really need to move it to separate file, some data in DrawAction needs to be opened, which is not good...
follow-up: 10 comment:9 by , 12 years ago
If it is needed nowhere else, then it should be a subclass, not an individua lclass.
comment:10 by , 12 years ago
Replying to stoecker:
If it is needed nowhere else, then it should be a subclass, not an individua lclass.
Sorry. It already is. Maybe I should not answer tickets early in the morning on Christmas :-) Forget the comment.
by , 12 years ago
Attachment: | AngleSnappingv2.patch added |
---|
comment:12 by , 12 years ago
Here is an updated version of the patch (there hould be much less bugs).
Pressing Tab in drawing mode, user can switch between no snapping - automatic snapping - fixed direction snapping.
Parameters draw.anglesnap.step and draw.anglesnap.tol are introduced to chosse 90,30,15,... degrees step and angle tolerance.
I think it is better to wait for some comments before commiting this patch :)
by , 12 years ago
Attachment: | sample.JPG added |
---|
by , 12 years ago
Attachment: | helperline.png added |
---|
comment:14 by , 12 years ago
Replying to akks:
I think it is better to wait for some comments before commiting this patch :)
Wow, this patch works nicely. Some comments:
- I'd call the parameter
draw.anglesnap.tolerance
to make its meaning clearer - The orange color of the helper line is (afaik) not used anywhere else. I like the appearance of the helper lines of the Improve Way Accuracy plugin.
- In fact, the result after drawing one segment in the snap mode corresponds to the segment on the orange line from the current node to the circle. Thus, it would probably be more intuitive to interchange red and orange (see below for an illustration).
- After drawing a segment in the "fixed mode", the angle is then 0 and the mode remains fixed. Is this intended? I mean, it is probably not very common to extend a line with a straight segment.
- When fixing the drawing mode to a wrong angle, it requires three presses on
[Tab]
to fix it for a different angle. I don't know of any better way, though. - It could be handy to have
draw.anglesnap.step
set to 30 and 45° at the same time to cover the most used cases (this is a proposition), without having snap angles at e.g. 15°. To support this, you could allow a list of angles. For the example,[30,45]
would do it.
As said before, I like this patch a lot and it seems to be working very well. I'd like to hear your opinion on the points above.
This image illustrates my idea for 2.+3. (the line node–cursor could probably be omitted completely, the remaining orange circle and text should be considered to be red as well):
comment:16 by , 12 years ago
Two comments after short reading. At least one label text is not translated (%d FIX) and the color should not be hardcoded, but a preferences item as all other colors.
follow-up: 18 comment:17 by , 12 years ago
Thank you for your comments! I'll rework coloring, preferences and introduce angle list and translation.
Swicthing modes could be tricky. There are some questions to discuss:
When you add one node in "fixed angle" mode, would you like to
- Turn off snapping
- Enable automatic snapping (without fixing)
- Enable snapping to the same line (0'), like now
- Enable snapping to the same angle (rotating after each click...)
Possible switching mechanisms:
- Tab = Snapping on/off, Shift-Tab = Fixed/unfixed angle
- Tab = off -> on(auto angle) -> fixed angle , Shift-Tab = off
- Tab = off -> on(auto angle) -> fixed angle , Shift-Tab = on(auto angle)
comment:18 by , 12 years ago
Replying to akks:
When you add one node in "fixed angle" mode, would you like to
- Turn off snapping
- Enable automatic snapping (without fixing)
- Enable snapping to the same line (0'), like now
- Enable snapping to the same angle (rotating after each click...)
I would either like item 2. or item 4. As it is easier to switch from snapping w/o fix to snapping w/ fix, I'd suggest item 2.
Possible switching mechanisms:
- Tab = Snapping on/off, Shift-Tab = Fixed/unfixed angle
- Tab = off -> on(auto angle) -> fixed angle , Shift-Tab = off
- Tab = off -> on(auto angle) -> fixed angle , Shift-Tab = on(auto angle)
I'd stick with the current key bindings (only [Tab]
, no [Shift]+[Tab]
) for the following reason: [Shift]+[Tab]
as well as [Tab],[Tab]
involves pressing of two keys, respectively, and it is probably easier to switch through all modes with a single key as the user needs to know/remember only a single key.
Nice work – I'm looking forward to seeing this feature being part of JOSM. :-)
comment:19 by , 12 years ago
After node addition - I choose 2 too, implementing...
It's almost finished...
By the way, I can implement fixing angle while holding [TAB] (have found such code for FastDraw, linux-compatible too), but do not know if is it a good idea.
by , 12 years ago
Attachment: | AngleSnappingv3.patch added |
---|
comment:20 by , 12 years ago
Next verison of the patch is ready. Changes:
- Renamed parameter to draw.anglesnap.tolerance
- Snap helper line is like in ImproveWayAccuracy, color is in parameter draw.anglesnap.color
- Better, more understandable drawing
- Fixed angle mode is disabled after addin one point.
- Snapping angles are stored in the list draw.anglesnap.angles, angleStep removed.
- Translation for "FIX" is enabled.
I did not introduce Shift-TAB or hodling TAB, but there is another new feature:
try RIGHT-clicking any existing line segment while in snap mode :) (it was easy to implement with existing code)
What should we do next?
follow-up: 22 comment:21 by , 12 years ago
A minor issue: Use color like Main.pref.getColor(marktr("draw angle snap"), Color.ORANGE)). Colors are a bit special, as they are presented to user :-) The resulting key will then be color.draw.angle.snap.
comment:22 by , 12 years ago
Replying to stoecker:
A minor issue: Use color like Main.pref.getColor(marktr("draw angle snap"), Color.ORANGE)). Colors are a bit special, as they are presented to user :-) The resulting key will then be color.draw.angle.snap.
No problem :-)
comment:23 by , 12 years ago
Preference name is improved, some bugs (like dragging problems and creating duplicate point when closing rectangle) fixed, snapping is changed to 30-45-60-90 by default. I can not find anything else myself.
To have more bugs and enchantment advices, I am committing the changes :)
comment:25 by , 12 years ago
Lacking mode specific toolbars, I would suggest a checkbox menu entry "Angle snapping" in Edit menu. It could be disabled, when not in edit mode.
follow-up: 27 comment:26 by , 12 years ago
Good idea, thank you. At least people will notice something new :)
comment:27 by , 12 years ago
Summary: | [PATCH] Key combination to draw lines on multiples of 15 degrees (15°/30°/45°/60°/75°/90°...) → Key combination to draw lines on multiples of 15 degrees (15°/30°/45°/60°/75°/90°...) |
---|
Replying to akks:
Good idea, thank you. At least people will notice something new :)
They should also find out via StartupPageSource. :-)
comment:28 by , 12 years ago
Oops, they have already noticed us :)
Here is the patch for menu item "angle snap". It seems to work, but I do not know, how to make it "checkboxy" and enable/disable together with drawing mapmode... Can someone help, please?
by , 12 years ago
Attachment: | DrawAction.patch added |
---|
comment:29 by , 12 years ago
I have almost figured it, but JosmAction does not like "tab" shortcut at all. Maybe it is better to use "H" for turning snap on/off?
But then what to do with TAB - 1) leave as is; 2) use for angle fixation only; 3) use for fixation while holding.
What is your opinion?
by , 12 years ago
Attachment: | snapbutton.patch added |
---|
by , 12 years ago
Attachment: | anglesnap.png added |
---|
comment:30 by , 12 years ago
Here is the patch with checkbox in menu and "H" shortcut for it, TAB behaviour unchanged.
I have also added advanced preferences "draw.anglesnap.drawConstructionGeometry", "draw.anglesnap.drawProjectedPoint" "draw.anglesnap.showAngle" that users who prefer minimalistic style can turn off.
Can you advice me, what is better to do with shortcuts and behaviour before commiting?
comment:31 by , 12 years ago
Summary: | Key combination to draw lines on multiples of 15 degrees (15°/30°/45°/60°/75°/90°...) → [PATCH needs review] Key combination to draw lines on multiples of 15 degrees (15°/30°/45°/60°/75°/90°...) |
---|
comment:32 by , 12 years ago
When in doubt, I would keep the "tab" shortcut as is and don't display anything at all for the menu entry (set null for the JosmAction). Ideally, this should be fixed, such that "tab" works the same way as "H" as menu shortcut.
comment:33 by , 12 years ago
So, the best is to remove "H" from menu and use tab to switch on-off?
Then we need something else for fixation of angle.
I will use tab holding then (this will also stop fast autoswitching when holding TAB).
Only disadvantage is that we can not change the hardcoded TAB shortcut.
comment:35 by , 12 years ago
Summary: | [PATCH needs review] Key combination to draw lines on multiples of 15 degrees (15°/30°/45°/60°/75°/90°...) → Key combination to draw lines on multiples of 15 degrees (15°/30°/45°/60°/75°/90°...) |
---|
Next version commited - menu item (checkbox) for angle snapping, holding TAB fixes the angle before turning it off, advanced preferences "draw.anglesnap.drawConstructionGeometry", "draw.anglesnap.drawProjectedPoint" "draw.anglesnap.showAngle".
Possible regression: TAB does not work ags general GUI shortcut while drawing mode is active - is it important? If it is, TAB should be changed.
If I am right, final step should be configuration from GUI - angle list with 90 45 and 30/45 presetts, checkboxes for displaying options in expert mode. Where is the the best place for it in F12 window?
comment:36 by , 12 years ago
comment:39 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
A similar feature is implemented in the plugin buildings_tools (cf. AngleSnap).