Modify behaviour when removing node from way (minus key): remove, but don't delete...
authorSteve Bennett <stevagewp@gmail.com>
Sun, 23 Jan 2011 08:59:46 +0000 (08:59 +0000)
committerSteve Bennett <stevagewp@gmail.com>
Sun, 23 Jan 2011 08:59:46 +0000 (08:59 +0000)
http://trac.openstreetmap.org/ticket/3473

net/systemeD/potlatch2/controller/DrawWay.as
net/systemeD/potlatch2/controller/SelectedWayNode.as

index 37c825f..0e7aec2 100644 (file)
@@ -12,7 +12,7 @@ package net.systemeD.potlatch2.controller {
 
        public class DrawWay extends SelectedWay {
                private var elastic:Elastic;
-               private var editEnd:Boolean;
+               private var editEnd:Boolean;            // if true, we're drawing from node[n-1], else "backwards" from node[0] 
                private var leaveNodeSelected:Boolean;
                private var lastClick:Entity=null;
                private var lastClickTime:Date;
@@ -167,13 +167,17 @@ package net.systemeD.potlatch2.controller {
                        switch (event.keyCode) {
                                case Keyboard.ENTER:                                    return keyExitDrawing();
                                case Keyboard.ESCAPE:                                   return keyExitDrawing();
-                               case Keyboard.DELETE:           return backspaceNode(MainUndoStack.getGlobalStack().addAction);
-                               case Keyboard.BACKSPACE:        return backspaceNode(MainUndoStack.getGlobalStack().addAction);
+                               //case 90: /* Z */             
+                               case Keyboard.DELETE:           
+                               case Keyboard.BACKSPACE:        
+                                   
                                case 189: /* minus */       return backspaceNode(MainUndoStack.getGlobalStack().addAction);
                                case 82: /* R */            repeatTags(firstSelected); return this;
                        }
                        var cs:ControllerState = sharedKeyboardEvents(event);
-                       return cs ? cs : this;
+                       //if (selectedWay.length == 0) return stopDrawing(); // to catch 'undo'ing the start of a draw.
+                       return cs ? cs : this;7
+                       
                }
                
                protected function keyExitDrawing():ControllerState {
@@ -236,7 +240,8 @@ package net.systemeD.potlatch2.controller {
                                Way(firstSelected).removeNodeByIndex(0, undo.push);
                                newDraw=0;
                        }
-                       if (node.numParentWays==1 && Way(firstSelected).hasOnceOnly(node)) {
+                       // Only actually delete the node if it has no other tags, and is not part of other ways (or part of this way twice)
+                       if (node.numParentWays==1 && Way(firstSelected).hasOnceOnly(node) && !node.hasInterestingTags()) {
                                controller.map.setPurgable([node], true);
                                controller.connection.unregisterPOI(node);
                                node.remove(undo.push);
index a7a939e..363baf9 100644 (file)
@@ -1,13 +1,13 @@
 package net.systemeD.potlatch2.controller {
        import flash.events.*;
-       import flash.ui.Keyboard;
        import flash.geom.Point;
-    import net.systemeD.potlatch2.EditController;
-    import net.systemeD.potlatch2.tools.Quadrilateralise;
-    import net.systemeD.halcyon.WayUI;
-    import net.systemeD.halcyon.connection.*;
-    import net.systemeD.halcyon.connection.actions.*;
+       import flash.ui.Keyboard;
+       
        import net.systemeD.halcyon.Globals;
+       import net.systemeD.halcyon.WayUI;
+       import net.systemeD.halcyon.connection.*;
+       import net.systemeD.halcyon.connection.actions.*;
+       import net.systemeD.potlatch2.tools.Quadrilateralise;
 
     public class SelectedWayNode extends ControllerState {
                private var parentWay:Way;
@@ -138,7 +138,7 @@ package net.systemeD.potlatch2.controller {
                }
                
                public function removeNode():ControllerState {
-                       if (firstSelected.numParentWays==1 && parentWay.hasOnceOnly(firstSelected as Node)) {
+                       if (firstSelected.numParentWays==1 && parentWay.hasOnceOnly(firstSelected as Node) && !(firstSelected as Node).hasInterestingTags()) {
                                return deleteNode();
                        }
                        parentWay.removeNodeByIndex(selectedIndex, MainUndoStack.getGlobalStack().addAction);