backspace ways
authorRichard Fairhurst <richard@systemed.net>
Sun, 16 May 2010 23:05:55 +0000 (23:05 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sun, 16 May 2010 23:05:55 +0000 (23:05 +0000)
TODO.txt
net/systemeD/potlatch2/controller/DrawWay.as

index 92ef552..3269cfc 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,24 +1,16 @@
 Potlatch 2: main outstanding issues
 -----------------------------------
 
-== Code tidying ==
-
-* A fair amount of the mouse-handling in each ControllerState is shared with others -
-  and some probably should be (e.g. unhovering). Can we refactor?
-
-
 == Core geometry ==
 
 * Undo/redo: split
-* Remove node from this way only
-* Backspace
-* Not messing up relations when splitting ways
+* Remove node from this way only (will require SelectedWayNode to become aware of currently selected index)
+* Bit more work required on relations when splitting ways
 
 
 == Vector background layers ==
 
 * TagTransform (cf http://wiki.openstreetmap.org/wiki/Osmosis/TagTransform)
-* Simplify (e.g. GPX files)
 * Import from OSM (is this worth sharing with the XML API stuff?)
 
 
@@ -26,7 +18,6 @@ Potlatch 2: main outstanding issues
 
 * Non-900913 projections
 * Plugin support
-* Ability to specify that a node should be a point in a way, for example for crossings
 
 
 == Tag editing ==
@@ -39,6 +30,7 @@ Potlatch 2: main outstanding issues
 * The area of pois for dragging on to the map should have a search, with synonyms and also be categorised like the lines are.
 * Bug where the wrong feature is used, when an item that is dragged from the list when an POI has no icon.
 * Checkboxes, for example what you can recycle, or whether something is a bridge or tunnel
+* Ability to specify that a node should be a point in a way, for example for crossings
 
 
 == UI ==
index 5517952..676f608 100644 (file)
@@ -1,6 +1,7 @@
 package net.systemeD.potlatch2.controller {
        import flash.events.*;
        import flash.geom.*;
+       import flash.ui.Keyboard;
        import net.systemeD.potlatch2.EditController;
        import net.systemeD.halcyon.connection.*;
        import net.systemeD.halcyon.Elastic;
@@ -94,6 +95,7 @@ package net.systemeD.potlatch2.controller {
 
                override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
                        if ( event.keyCode == 13 || event.keyCode == 27 ) { return stopDrawing(); }
+                       else if (event.keyCode == Keyboard.BACKSPACE) { return backspaceNode(MainUndoStack.getGlobalStack().addAction); }
                        return this;
                }
                
@@ -130,6 +132,34 @@ package net.systemeD.potlatch2.controller {
                                selectedWay.insertNode(0, node, performAction);
                }
                
+               protected function backspaceNode(performAction:Function):ControllerState {
+                       var node:Node;
+                       var undo:CompositeUndoableAction = new CompositeUndoableAction("Remove node");
+                       var newDraw:int;
+                       if (editEnd) {
+                               node=selectedWay.getNode(selectedWay.length-1);
+                               selectedWay.removeNodeByIndex(selectedWay.length-1, undo.push);
+                               newDraw=selectedWay.length-2;
+                       } else {
+                               node=selectedWay.getNode(0);
+                               selectedWay.removeNodeByIndex(0, undo.push);
+                               newDraw=0;
+                       }
+                       if (node.numParentWays==1) {
+                               controller.connection.unregisterPOI(node);
+                               node.remove(undo.push);
+                       }
+                       MainUndoStack.getGlobalStack().addAction(undo);
+
+                       if (newDraw>=0 && newDraw<=selectedWay.length-1) {
+                               var mouse:Point = new Point(selectedWay.getNode(newDraw).lon, selectedWay.getNode(newDraw).latp);
+                               elastic.start = mouse;
+                               return this;
+                       } else {
+                               return new NoSelection();
+                       }
+               }
+               
                override public function enterState():void {
                        super.enterState();