Make quadralaterawhatsit work on selected waynodes, too. Add Q shortcut for both.
authorAndy Allan <gravitystorm@gmail.com>
Thu, 13 Jan 2011 18:27:40 +0000 (18:27 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Thu, 13 Jan 2011 18:27:40 +0000 (18:27 +0000)
net/systemeD/potlatch2/Toolbox.mxml
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/SelectedWay.as
net/systemeD/potlatch2/controller/SelectedWayNode.as

index 6007b5f..7b26585 100644 (file)
                        switch (op) {
                                case 'delete':                          return true;
                                case 'reverseDirection':        return controller.state.hasSelectedWays();
                        switch (op) {
                                case 'delete':                          return true;
                                case 'reverseDirection':        return controller.state.hasSelectedWays();
-                               case 'quadrilateralise':        return controller.state.hasSelectedAreas();
+                               case 'quadrilateralise':        return (controller.state.hasSelectedAreas() || controller.state.hasSelectedWayNodesInAreas());
                                case 'straighten':                      return controller.state.hasSelectedUnclosedWays();
                                case 'circularise':                     return controller.state.hasSelectedAreas();
                                case 'split':                           return (controller.state is SelectedWayNode);
                                case 'straighten':                      return controller.state.hasSelectedUnclosedWays();
                                case 'circularise':                     return controller.state.hasSelectedAreas();
                                case 'split':                           return (controller.state is SelectedWayNode);
                        for each (var way:Way in controller.state.selectedWays) {
                                Quadrilateralise.quadrilateralise(way, undo.push);
                        }
                        for each (var way:Way in controller.state.selectedWays) {
                                Quadrilateralise.quadrilateralise(way, undo.push);
                        }
+            for each (var node:Node in controller.state.selectedNodes) {
+                for each (var parentWay:Way in node.parentWays) {
+                  Quadrilateralise.quadrilateralise(parentWay, undo.push);
+                }
+            }
                        MainUndoStack.getGlobalStack().addAction(undo);
                }
 
                        MainUndoStack.getGlobalStack().addAction(undo);
                }
 
index 060aaec..4d4e15a 100644 (file)
@@ -217,6 +217,14 @@ package net.systemeD.potlatch2.controller {
                        return selectedWays;
                }
 
                        return selectedWays;
                }
 
+        public function get selectedNodes():Array {
+            var selectedNodes:Array=[];
+            for each (var item:Entity in _selection) {
+                if (item is Node) { selectedNodes.push(item); }
+            }
+            return selectedNodes;
+        }
+
                public function hasSelectedWays():Boolean {
                        for each (var item:Entity in _selection) {
                                if (item is Way) { return true; }
                public function hasSelectedWays():Boolean {
                        for each (var item:Entity in _selection) {
                                if (item is Way) { return true; }
@@ -238,6 +246,19 @@ package net.systemeD.potlatch2.controller {
                        return false;
                }
 
                        return false;
                }
 
+        /** Determine whether or not any nodes are selected, and if so whether any of them belong to areas. */
+        public function hasSelectedWayNodesInAreas():Boolean {
+            for each (var item:Entity in _selection) {
+                if (item is Node) {
+                    var parentWays:Array = Node(item).parentWays;
+                    for each (var way:Entity in parentWays) {
+                        if (Way(way).isArea()) { return true; }
+                    }
+                }
+            }
+            return false;
+        }
+
                public function hasAdjoiningWays():Boolean {
                        if (_selection.length<2) { return false; }
                        var endNodes:Object={};
                public function hasAdjoiningWays():Boolean {
                        if (_selection.length<2) { return false; }
                        var endNodes:Object={};
index 2158881..2940fb1 100644 (file)
@@ -5,6 +5,7 @@ package net.systemeD.potlatch2.controller {
        import flash.geom.Point;
     import net.systemeD.potlatch2.EditController;
     import net.systemeD.potlatch2.tools.Parallelise;
        import flash.geom.Point;
     import net.systemeD.potlatch2.EditController;
     import net.systemeD.potlatch2.tools.Parallelise;
+    import net.systemeD.potlatch2.tools.Quadrilateralise;
     import net.systemeD.potlatch2.tools.Simplify;
     import net.systemeD.halcyon.connection.*;
        import net.systemeD.halcyon.MapPaint;
     import net.systemeD.potlatch2.tools.Simplify;
     import net.systemeD.halcyon.connection.*;
        import net.systemeD.halcyon.MapPaint;
@@ -77,6 +78,7 @@ package net.systemeD.potlatch2.controller {
                override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
                        switch (event.keyCode) {
                                case 80:  /* P */           return new SelectedParallelWay(firstSelected as Way); 
                override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
                        switch (event.keyCode) {
                                case 80:  /* P */           return new SelectedParallelWay(firstSelected as Way); 
+                               case 81:  /* Q */           Quadrilateralise.quadrilateralise(firstSelected as Way, MainUndoStack.getGlobalStack().addAction); return this;
                                case 82:  /* R */           repeatTags(firstSelected); return this;
                 case 86:  /* V */           Way(firstSelected).reverseNodes(MainUndoStack.getGlobalStack().addAction); return this;
                 case 89:  /* Y */           Simplify.simplify(firstSelected as Way, controller.map, true); return this;         
                                case 82:  /* R */           repeatTags(firstSelected); return this;
                 case 86:  /* V */           Way(firstSelected).reverseNodes(MainUndoStack.getGlobalStack().addAction); return this;
                 case 89:  /* Y */           Simplify.simplify(firstSelected as Way, controller.map, true); return this;         
index e5226c4..a7a939e 100644 (file)
@@ -3,6 +3,7 @@ package net.systemeD.potlatch2.controller {
        import flash.ui.Keyboard;
        import flash.geom.Point;
     import net.systemeD.potlatch2.EditController;
        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 net.systemeD.halcyon.WayUI;
     import net.systemeD.halcyon.connection.*;
     import net.systemeD.halcyon.connection.actions.*;
@@ -68,6 +69,7 @@ package net.systemeD.potlatch2.controller {
                        switch (event.keyCode) {
                                case 189:                                       return removeNode();                                    // '-'
                                case 88:                                        return splitWay();                                              // 'X'
                        switch (event.keyCode) {
                                case 189:                                       return removeNode();                                    // '-'
                                case 88:                                        return splitWay();                                              // 'X'
+                case 81:  /* Q */           Quadrilateralise.quadrilateralise(parentWay, MainUndoStack.getGlobalStack().addAction); return this;
                                case 82:                                        repeatTags(firstSelected); return this; // 'R'
                                case 87:                                        return new SelectedWay(parentWay);              // 'W'
                                case 191:                                       return cycleWays();                                             // '/'
                                case 82:                                        repeatTags(firstSelected); return this; // 'R'
                                case 87:                                        return new SelectedWay(parentWay);              // 'W'
                                case 191:                                       return cycleWays();                                             // '/'