Changeset 4917 in josm
- Timestamp:
- 2012-02-11T18:28:41+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r4805 r4917 69 69 import org.openstreetmap.josm.tools.Shortcut; 70 70 import org.openstreetmap.josm.tools.Utils; 71 import org.openstreetmap.josm.tools.Geometry; 71 72 72 73 /** … … 98 99 private Shortcut extraShortcut; 99 100 private Shortcut backspaceShortcut; 101 private int snappingKeyCode; 100 102 101 103 private JCheckBoxMenuItem snapCheckboxMenuItem; … … 110 112 extraShortcut = Shortcut.registerShortcut("mapmode:drawfocus", tr("Mode: Draw Focus"), KeyEvent.VK_N, Shortcut.GROUP_EDIT); 111 113 Main.registerActionShortcut(this, extraShortcut); 112 114 115 snappingKeyCode = Shortcut.registerShortcut("mapmode:drawanglesnapping", tr("Mode: Draw Angle snapping"), KeyEvent.VK_TAB, Shortcut.GROUP_EDIT) 116 .getKeyStroke().getKeyCode(); 113 117 snapCheckboxMenuItem = MainMenu.addWithCheckbox(Main.main.menu.editMenu, new SnapChangeAction(), MainMenu.WINDOW_MENU_GROUP.VOLATILE); 114 118 snapHelper.setMenuCheckBox(snapCheckboxMenuItem); … … 224 228 private Timer timer; 225 229 void processKeyEvent(KeyEvent e) { 226 if (e.getKeyCode() != KeyEvent.VK_TAB) return;230 if (e.getKeyCode() != snappingKeyCode) return; 227 231 //e.consume(); // ticket #7250 - TAB should work in other windows 228 232 … … 250 254 251 255 private void doKeyPressEvent(KeyEvent e) { 252 if (e.getKeyCode() != KeyEvent.VK_TAB) return;256 if (e.getKeyCode() != snappingKeyCode) return; 253 257 snapHelper.setFixedMode(); 254 258 computeHelperLine(); redrawIfRequired(); 255 259 } 256 260 private void doKeyReleaseEvent(KeyEvent e) { 257 if (e.getKeyCode() != KeyEvent.VK_TAB) return;261 if (e.getKeyCode() != snappingKeyCode) return; 258 262 snapHelper.unFixOrTurnOff(); 259 263 computeHelperLine(); redrawIfRequired(); … … 414 418 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments( 415 419 Main.map.mapView.getPoint(n), OsmPrimitive.isSelectablePredicate); 420 if (snapHelper.isActive()) { // 421 tryToMoveNodeOnIntersection(wss,n); 422 } 416 423 insertNodeIntoAllNearbySegments(wss, n, newSelection, cmds, replacedWays, reuseWays); 417 424 } … … 952 959 return a * d - b * c; 953 960 } 961 962 private void tryToMoveNodeOnIntersection(List<WaySegment> wss, Node n) { 963 if (wss.isEmpty()) return; 964 WaySegment ws = wss.get(0); 965 EastNorth p1=ws.getFirstNode().getEastNorth(); 966 EastNorth p2=ws.getSecondNode().getEastNorth(); 967 if (snapHelper.dir2!=null && currentBaseNode!=null) { 968 EastNorth xPoint = Geometry.getSegmentSegmentIntersection(p1, p2, snapHelper.dir2, currentBaseNode.getEastNorth()); 969 if (xPoint!=null) n.setEastNorth(xPoint); 970 } 971 } 954 972 /** 955 973 * Takes the data from computeHelperLine to determine which ways/nodes should be highlighted … … 1447 1465 } 1448 1466 })); 1467 add(new AbstractAction(tr("Disable")) { 1468 public void actionPerformed(ActionEvent e) { 1469 saveAngles("180"); 1470 init(); enableSnapping(); 1471 } 1472 }); 1449 1473 add(new AbstractAction(tr("0,90,...")) { 1450 1474 public void actionPerformed(ActionEvent e) {
Note:
See TracChangeset
for help on using the changeset viewer.