Ignore:
Timestamp:
2008-08-24T00:18:15+02:00 (16 years ago)
Author:
stoecker
Message:

create virtual nodes only in case point is moved

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.