Changeset 5435 in josm for trunk


Ignore:
Timestamp:
2012-08-12T10:49:53+02:00 (12 years ago)
Author:
akks
Message:

hope to fix #7082: ctrl-dragging near virtual node problem

File:
1 edited

Legend:

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

    r5419 r5435  
    248248
    249249        virtualManager.clear();
    250         if(mode == Mode.move && virtualManager.setupVirtual(e.getPoint())) {
    251             DataSet ds = getCurrentDataSet();
    252             if (ds != null && drawTargetHighlight) {
    253                 ds.setHighlightedVirtualNodes(virtualManager.virtualWays);
    254             }
    255             mv.setNewCursor(SelectActionCursor.virtual_node.cursor(), this);
    256             // don't highlight anything else if a virtual node will be
    257             return repaintIfRequired(newHighlights);
     250        if(mode == Mode.move) {
     251            if (!dragInProgress() && virtualManager.activateVirtualNodeNearPoint(e.getPoint())) {
     252                DataSet ds = getCurrentDataSet();
     253                if (ds != null && drawTargetHighlight) {
     254                    ds.setHighlightedVirtualNodes(virtualManager.virtualWays);
     255                }
     256                mv.setNewCursor(SelectActionCursor.virtual_node.cursor(), this);
     257                // don't highlight anything else if a virtual node will be
     258                return repaintIfRequired(newHighlights);
     259            }
    258260        }
    259261
     
    432434            // so this is not movement, but selection on primitive under cursor
    433435            if (!cancelDrawMode && nearestPrimitive instanceof Way) {
    434                 virtualManager.setupVirtual(e.getPoint());
     436                virtualManager.activateVirtualNodeNearPoint(e.getPoint());
    435437            }
    436438            selectPrims(cycleManager.cycleSetup(nearestPrimitive, e.getPoint()), false, false);
     
    523525            int dp = (int) lastMousePos.distance(e.getX(), e.getY());
    524526            if (dp < initialMoveThreshold)
    525                 return;
    526             initialMoveThresholdExceeded = true;
    527         }
    528 
     527                return; // ignore small drags
     528            initialMoveThresholdExceeded = true; //no more ingnoring uintil nex mouse press
     529        }
     530        if (e.getPoint().equals(lastMousePos))
     531            return;
     532       
    529533        EastNorth currentEN = mv.getEastNorth(e.getX(), e.getY());
    530         if (e.getPoint().equals(lastMousePos))
    531             return;
    532        
    533         if (virtualManager.hasVirtualWays()) {
    534             virtualManager.processVirtualNodeMovements(currentEN);
     534
     535        if (virtualManager.hasVirtualWaysToBeConstructed()) {
     536            virtualManager.createMiddleNodeFromVirtual(currentEN);
    535537        } else {
    536538            if (!updateCommandWhileDragging(currentEN)) return;
     
    807809        // anything if about to drag the virtual node (i.e. !released) but continue if the
    808810        // cursor is only released above a virtual node by accident (i.e. released). See #7018
    809         if ((shift && ctrl) || (ctrl && !released) || (virtualManager.hasVirtualWays() && !released))
     811        if ((shift && ctrl) || (ctrl && !released) || (virtualManager.hasVirtualWaysToBeConstructed() && !released))
    810812            return;
    811813
     
    10341036         * <code>virtualWays</code> were setup.
    10351037         */
    1036         private boolean setupVirtual(Point p) {
     1038        private boolean activateVirtualNodeNearPoint(Point p) {
    10371039            if (nodeVirtualSize > 0) {
    1038                
     1040
    10391041                Collection<WaySegment> selVirtualWays = new LinkedList<WaySegment>();
    10401042                Pair<Node, Node> vnp = null, wnp = new Pair<Node, Node>(null, null);
     
    10581060                            }
    10591061                            if (vnp.equals(wnp)) {
     1062                                // if mutiple line segments have the same points,
     1063                                // add all segments to be splitted to virtualWays list
     1064                                // if some lines are selected, only their segments will go to virtualWays
    10601065                                (w.isSelected() ? selVirtualWays : virtualWays).add(ws);
    10611066                            }
     
    10721077        }
    10731078
    1074         private void processVirtualNodeMovements(EastNorth currentEN) {
     1079        private void createMiddleNodeFromVirtual(EastNorth currentEN) {
    10751080            Collection<Command> virtualCmds = new LinkedList<Command>();
    10761081            virtualCmds.add(new AddCommand(virtualNode));
     
    10991104        }
    11001105
    1101         private boolean hasVirtualWays() {
     1106        private boolean hasVirtualWaysToBeConstructed() {
    11021107            return !virtualWays.isEmpty();
    11031108        }
Note: See TracChangeset for help on using the changeset viewer.