Changeset 3538 in josm


Ignore:
Timestamp:
Sep 18, 2010 1:06:48 PM (3 years ago)
Author:
bastiK
Message:

fixed #5452 - Tools-->UnGlue Ways is counterintuitive

File:
1 edited

Legend:

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

    r3242 r3538  
    193193    /** 
    194194     * Checks if the selection consists of something we can work with. 
    195      * Checks only if the number and type of items selected looks good; 
    196      * does not check whether the selected items are really a valid 
    197      * input for splitting (this would be too expensive to be carried 
    198      * out from the selectionChanged listener). 
     195     * Checks only if the number and type of items selected looks good. 
    199196     * 
    200197     * If this method returns "true", selectedNode and selectedWay will 
     
    233230    /** 
    234231     * Checks if the selection consists of something we can work with. 
    235      * Checks only if the number and type of items selected looks good; 
    236      * does not check whether the selected items are really a valid 
    237      * input for splitting (this would be too expensive to be carried 
    238      * out from the selectionChanged listener). 
     232     * Checks only if the number and type of items selected looks good. 
    239233     * 
    240234     * Returns true if one way and any number of nodes that are part of 
     
    347341    private void unglueWays() { 
    348342        LinkedList<Command> cmds = new LinkedList<Command>(); 
    349         List<Node> newNodes = new LinkedList<Node>(); 
     343        LinkedList<Node> newNodes = new LinkedList<Node>(); 
    350344 
    351345        if (selectedWay == null) { 
    352             boolean firstway = true; 
    353             // modify all ways containing the nodes 
    354             for (Way w : OsmPrimitive.getFilteredList(selectedNode.getReferrers(), Way.class)) { 
    355                 if (w.isDeleted() || w.isIncomplete()) { 
    356                     continue; 
    357                 } 
    358                 if (!firstway) { 
    359                     cmds.add(new ChangeCommand(w, modifyWay(selectedNode, w, cmds, newNodes))); 
    360                 } 
    361                 firstway = false; 
     346            Way wayWithSelectedNode = null; 
     347            LinkedList<Way> parentWays = new LinkedList<Way>(); 
     348            for (OsmPrimitive osm : selectedNode.getReferrers()) { 
     349                if (osm.isUsable() && osm instanceof Way) { 
     350                    Way w = (Way) osm; 
     351                    if (wayWithSelectedNode == null && !w.isFirstLastNode(selectedNode)) { 
     352                        wayWithSelectedNode = w; 
     353                    } else { 
     354                        parentWays.add(w); 
     355                    } 
     356                } 
     357            } 
     358            if (wayWithSelectedNode == null) { 
     359                wayWithSelectedNode = parentWays.removeFirst(); 
     360            } 
     361            for (Way w : parentWays) { 
     362                cmds.add(new ChangeCommand(w, modifyWay(selectedNode, w, cmds, newNodes))); 
    362363            } 
    363364        } else { 
     
    368369 
    369370        Main.main.undoRedo.add(new SequenceCommand(tr("Dupe into {0} nodes", newNodes.size()+1), cmds)); 
    370         if (selectedWay == null) { // if a node has been selected, new selection is ALL nodes 
    371             newNodes.add(selectedNode); 
    372         } // if a node and a way has been selected, new selection is only the new node that was added to the selected way 
    373         getCurrentDataSet().setSelected(newNodes); 
     371        // select one of the new nodes 
     372        getCurrentDataSet().setSelected(newNodes.getFirst()); 
    374373    } 
    375374 
Note: See TracChangeset for help on using the changeset viewer.