Changeset 4479 in osm for applications/editors/josm
- Timestamp:
- 2007-09-06T22:42:51+02:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/core_0.5/src/org/openstreetmap/josm/actions/mapmode/AddSegmentAction.java
r4466 r4479 52 52 */ 53 53 public AddSegmentAction(MapFrame mapFrame) { 54 super(tr("Connect two node"), 54 super(tr("Connect two nodes"), 55 55 "addsegment", 56 56 tr("Connect two nodes using ways."), … … 73 73 } 74 74 75 75 /** 76 * Called when user hits space bar while dragging. 77 */ 76 78 @Override public void actionPerformed(ActionEvent e) { 77 79 super.actionPerformed(e); … … 102 104 103 105 Node hovered = Main.map.mapView.getNearestNode(e.getPoint()); 104 if (hovered == null || hovered == first) return; 105 106 if (hovered == second) return; 107 108 drawHint(false); 106 109 second = hovered; 107 110 drawHint(true); … … 115 118 drawHint(false); 116 119 makeSegment(); 120 first = null; 117 121 } 118 122 } … … 143 147 Node n1 = first; 144 148 Node n2 = second; 145 first = null; 146 second = null; 149 150 // this is to allow continued segment drawing by hitting the space bar 151 // at every intermediate node 152 first = second; 153 second = null; 147 154 148 155 if (n1 == null || n2 == null || n1 == n2) return; 149 156 150 157 Way w = getWayForNode(n1); 151 158 Way wnew; 159 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 160 152 161 if (w == null) { 162 // create a new way and add it to the current selection. 153 163 wnew = new Way(); 154 164 wnew.nodes.add(n1); 155 165 wnew.nodes.add(n2); 156 166 Main.main.undoRedo.add(new AddCommand(wnew)); 167 sel.add(wnew); 168 Main.ds.setSelected(sel); 157 169 } else { 170 // extend an existing way; only add to current selection if 171 // it is not already in there. 158 172 wnew = new Way(w); 159 173 if (wnew.nodes.get(wnew.nodes.size() - 1) == n1) { … … 163 177 } 164 178 Main.main.undoRedo.add(new ChangeCommand(w, wnew)); 179 // do not use wnew below; ChangeCommand only uses wnew as a 180 // message about changes to be done to w but will not replace w! 181 if (!sel.contains(w)) { 182 sel.add(w); 183 } 184 // do not move this into the if block above since it also 185 // fires the selection change event which is desired. 186 Main.ds.setSelected(sel); 165 187 } 166 167 Collection<OsmPrimitive> sel = Main.ds.getSelected();168 sel.add(wnew);169 Main.ds.setSelected(sel);170 188 171 189 Main.map.mapView.repaint();
Note:
See TracChangeset
for help on using the changeset viewer.
