press '/' to cycle through overlapping ways
authorRichard Fairhurst <richard@systemed.net>
Sat, 27 Nov 2010 16:42:35 +0000 (16:42 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sat, 27 Nov 2010 16:42:35 +0000 (16:42 +0000)
net/systemeD/potlatch2/controller/DragWay.as
net/systemeD/potlatch2/controller/SelectedPOINode.as
net/systemeD/potlatch2/controller/SelectedWay.as
net/systemeD/potlatch2/controller/SelectedWayNode.as
net/systemeD/potlatch2/help/HelpDialog.mxml

index 3e4ce1f..dda276c 100644 (file)
@@ -1,5 +1,6 @@
 package net.systemeD.potlatch2.controller {
        import flash.events.*;
+       import flash.geom.Point;
     import net.systemeD.potlatch2.EditController;
     import net.systemeD.halcyon.connection.*;
     import net.systemeD.halcyon.connection.actions.*;
@@ -30,7 +31,7 @@ package net.systemeD.potlatch2.controller {
                   MainUndoStack.getGlobalStack().addAction(
                           new MoveWayAction(firstSelected as Way, downX, downY, event.localX, event.localY, controller.map)); 
                 }
-                return new SelectedWay(firstSelected as Way);
+                return new SelectedWay(firstSelected as Way, new Point(event.stageX,event.stageY));
 
                        } else if ( event.type == MouseEvent.MOUSE_MOVE) {
                                // dragging
index a5a4579..7e8ae54 100644 (file)
@@ -46,7 +46,7 @@ package net.systemeD.potlatch2.controller {
                        var cs:ControllerState = sharedKeyboardEvents(event);
                        return cs ? cs : this;
                }
-               
+
                public function deletePOI():ControllerState {
                        controller.connection.unregisterPOI(firstSelected as Node);
                        firstSelected.remove(MainUndoStack.getGlobalStack().addAction);
index 5c4b9bd..7e9bf50 100644 (file)
@@ -2,6 +2,7 @@ package net.systemeD.potlatch2.controller {
        import flash.events.*;
        import flash.display.DisplayObject;
        import flash.ui.Keyboard;
+       import flash.geom.Point;
     import net.systemeD.potlatch2.EditController;
     import net.systemeD.potlatch2.tools.Parallelise;
     import net.systemeD.potlatch2.tools.Simplify;
@@ -12,9 +13,13 @@ package net.systemeD.potlatch2.controller {
 
     public class SelectedWay extends ControllerState {
         protected var initWay:Way;
+        private var clicked:Point;             // did the user enter this state by clicking at a particular point?
+               private var wayList:Array;              // list of ways to cycle through with '/' keypress
         
-        public function SelectedWay(way:Way) {
+        public function SelectedWay(way:Way, point:Point=null, ways:Array=null) {
             initWay = way;
+                       clicked = point;
+                       wayList = ways;
         }
  
         protected function selectWay(way:Way):void {
@@ -65,6 +70,7 @@ package net.systemeD.potlatch2.controller {
                                case 82:                                        repeatTags(firstSelected); return this;
                 case 86:                    Way(firstSelected).reverseNodes(MainUndoStack.getGlobalStack().addAction); return this;
                 case 89:                    Simplify.simplify(firstSelected as Way, controller.map, true); return this;         
+                               case 191:                                       return cycleWays();
                                case Keyboard.BACKSPACE:        if (event.shiftKey) { return deleteWay(); } break;
                                case Keyboard.DELETE:           if (event.shiftKey) { return deleteWay(); } break;
                        }
@@ -72,6 +78,20 @@ package net.systemeD.potlatch2.controller {
                        return cs ? cs : this;
                }
         
+               private function cycleWays():ControllerState {
+                       if (!clicked || (wayList && wayList.length<2)) { return this; }
+
+                       if (!wayList) {
+                               wayList=[initWay];
+                               for each (var wayui:WayUI in controller.map.paint.wayuis) {
+                                       var w:Way=wayui.hitTest(clicked.x, clicked.y);
+                                       if (w && w!=initWay) { wayList.push(w); }
+                               }
+                       }
+                       wayList=wayList.slice(1).concat(wayList[0]);
+                       return new SelectedWay(wayList[0], clicked, wayList);
+               }
+
                public function deleteWay():ControllerState {
                        controller.map.setHighlightOnNodes(firstSelected as Way, {selectedway: false});
                        selectedWay.remove(MainUndoStack.getGlobalStack().addAction);
index 9fac579..549eb02 100644 (file)
@@ -1,6 +1,7 @@
 package net.systemeD.potlatch2.controller {
        import flash.events.*;
        import flash.ui.Keyboard;
+       import flash.geom.Point;
     import net.systemeD.potlatch2.EditController;
     import net.systemeD.halcyon.connection.*;
     import net.systemeD.halcyon.connection.actions.*;
@@ -68,6 +69,7 @@ package net.systemeD.potlatch2.controller {
                                case 88:                                        return splitWay();                                              // 'X'
                                case 82:                                        repeatTags(firstSelected); return this; // 'R'
                                case 87:                                        return new SelectedWay(parentWay);              // 'W'
+                               case 191:                                       return cycleWays();                                             // '/'
                 case 74:                    if (event.shiftKey) { return unjoin() }; return this;// 'J'
                                case Keyboard.BACKSPACE:        return deleteNode();
                                case Keyboard.DELETE:           return deleteNode();
@@ -80,6 +82,15 @@ package net.systemeD.potlatch2.controller {
                        return parentWay;
                }
 
+               private function cycleWays():ControllerState {
+                       var wayList:Array=firstSelected.parentWays;
+                       wayList.splice(wayList.indexOf(parentWay),1);
+                       return new SelectedWay(wayList[0],
+                                              new Point(controller.map.lon2coord(Node(firstSelected).lon),
+                                                        controller.map.latp2coord(Node(firstSelected).latp)),
+                                              wayList.concat(parentWay));
+               }
+
                override public function enterState():void {
             selectNode(parentWay,initIndex);
                        controller.map.setPurgable(selection,false);
index 2c61c6e..a3deebd 100644 (file)
@@ -99,8 +99,9 @@
                           ["Shift+Click at point", "Create new way from point"],
                           ["-","Delete point from selected way"],
                           ["Backspace/Delete", "Delete point"],
-                          ["Shift+Backspace/Delete", "Delete way"]
+                          ["Shift+Backspace/Delete", "Delete way"],
                           ["Ctrl+Click", "Select multiple nodes or ways (Command+Click on Mac)"],
+                          ["/", "Cycle through overlapping ways"],
                           ];
         var text2:Array =  [["D", "Dim features"],
                             ["R", "Repeat tags"],