Changeset 853 in josm
- Timestamp:
- 2008-08-24T00:18:15+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r813 r853 51 51 private long mouseDownTime = 0; 52 52 private boolean didMove = false; 53 Node virtualNode = null; 54 WaySegment virtualWay = null; 55 SequenceCommand virtualCmds = null; 53 56 54 57 /** … … 133 136 @Override public void mouseDragged(MouseEvent e) { 134 137 if (mode == Mode.select) return; 135 138 136 139 // do not count anything as a move if it lasts less than 100 milliseconds. 137 140 if ((mode == Mode.move) && (System.currentTimeMillis() - mouseDownTime < initialMoveDelay)) return; … … 164 167 return; 165 168 169 if(virtualWay != null) 170 { 171 Collection<Command> virtualCmds = new LinkedList<Command>(); 172 virtualCmds.add(new AddCommand(virtualNode)); 173 Way w = virtualWay.way; 174 Way wnew = new Way(w); 175 wnew.nodes.add(virtualWay.lowerIndex+1, virtualNode); 176 virtualCmds.add(new ChangeCommand(w, wnew)); 177 virtualCmds.add(new MoveCommand(virtualNode, dx, dy)); 178 Main.main.undoRedo.add(new SequenceCommand(tr("Add and move a virtual new node to way"), virtualCmds)); 179 selectPrims(Collections.singleton((OsmPrimitive)virtualNode), false, false); 180 virtualWay = null; 181 virtualNode = null; 182 } 183 166 184 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 167 185 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); … … 173 191 Command c = !Main.main.undoRedo.commands.isEmpty() 174 192 ? Main.main.undoRedo.commands.getLast() : null; 193 if(c instanceof SequenceCommand) 194 c = ((SequenceCommand)c).getLastCommand(); 175 195 176 196 if (mode == Mode.move) { … … 227 247 if(p.distanceSq(pc) < snapDistance) 228 248 { 229 Collection<Command> cmds = new LinkedList<Command>(); 230 Node n = new Node(Main.map.mapView.getLatLon(pc.x, pc.y)); 231 cmds.add(new AddCommand(n)); 232 233 Way wnew = new Way(w); 234 wnew.nodes.add(nearestWaySeg.lowerIndex+1, n); 235 cmds.add(new ChangeCommand(w, wnew)); 236 Main.main.undoRedo.add(new SequenceCommand(tr("Add a new node to an existing way"), cmds)); 237 osm = n; 249 virtualWay = nearestWaySeg; 250 virtualNode = new Node(Main.map.mapView.getLatLon(pc.x, pc.y)); 251 osm = w; 238 252 } 239 253 } … … 287 301 selectionManager.register(Main.map.mapView); 288 302 selectionManager.mousePressed(e); 303 } 304 if(mode != Mode.move || shift || ctrl) 305 { 306 virtualNode = null; 307 virtualWay = null; 289 308 } 290 309 -
trunk/src/org/openstreetmap/josm/command/SequenceCommand.java
r655 r853 61 61 } 62 62 63 public Command getLastCommand() { 64 if(sequence.length == 0) 65 return null; 66 return sequence[sequence.length-1]; 67 } 63 68 private void undoCommands(int start) { 64 69 // We probably aborted this halfway though the
Note:
See TracChangeset
for help on using the changeset viewer.