Changeset 853 in josm


Ignore:
Timestamp:
Aug 24, 2008 12:18:15 AM (5 years ago)
Author:
stoecker
Message:

create virtual nodes only in case point is moved

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r813 r853  
    5151        private long mouseDownTime = 0; 
    5252        private boolean didMove = false; 
     53        Node virtualNode = null; 
     54        WaySegment virtualWay = null; 
     55        SequenceCommand virtualCmds = null; 
    5356 
    5457        /** 
     
    133136        @Override public void mouseDragged(MouseEvent e) { 
    134137                if (mode == Mode.select) return; 
    135                  
     138 
    136139                // do not count anything as a move if it lasts less than 100 milliseconds. 
    137140                if ((mode == Mode.move) && (System.currentTimeMillis() - mouseDownTime < initialMoveDelay)) return; 
     
    164167                        return; 
    165168 
     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 
    166184                Collection<OsmPrimitive> selection = Main.ds.getSelected(); 
    167185                Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 
     
    173191                Command c = !Main.main.undoRedo.commands.isEmpty() 
    174192                        ? Main.main.undoRedo.commands.getLast() : null; 
     193                if(c instanceof SequenceCommand) 
     194                        c = ((SequenceCommand)c).getLastCommand(); 
    175195 
    176196                if (mode == Mode.move) { 
     
    227247                                                if(p.distanceSq(pc) < snapDistance) 
    228248                                                { 
    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; 
    238252                                                } 
    239253                                        } 
     
    287301                        selectionManager.register(Main.map.mapView); 
    288302                        selectionManager.mousePressed(e); 
     303                } 
     304                if(mode != Mode.move || shift || ctrl) 
     305                { 
     306                        virtualNode = null; 
     307                        virtualWay = null; 
    289308                } 
    290309 
  • trunk/src/org/openstreetmap/josm/command/SequenceCommand.java

    r655 r853  
    6161        } 
    6262 
     63        public Command getLastCommand() { 
     64                if(sequence.length == 0) 
     65                        return null; 
     66                return sequence[sequence.length-1]; 
     67        } 
    6368        private void undoCommands(int start) { 
    6469                // We probably aborted this halfway though the 
Note: See TracChangeset for help on using the changeset viewer.