From 16d36cf4c1b8f3ec0a868472afb30772946b6ce5 Mon Sep 17 00:00:00 2001 From: Richard Fairhurst Date: Sat, 22 May 2010 09:48:36 +0000 Subject: [PATCH] make junctions on shift-clicking --- net/systemeD/halcyon/WayUI.as | 8 ++++++++ net/systemeD/potlatch2/controller/SelectedWay.as | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/net/systemeD/halcyon/WayUI.as b/net/systemeD/halcyon/WayUI.as index e8bcb5af..0ef5f281 100755 --- a/net/systemeD/halcyon/WayUI.as +++ b/net/systemeD/halcyon/WayUI.as @@ -462,9 +462,17 @@ package net.systemeD.halcyon { return null; } + // ------------------------------------------------------------------------------------------ + // Interaction + override protected function mouseEvent(event:MouseEvent):void { paint.map.entityMouseEvent(event, way); } + public function hitTest(x:Number, y:Number):Way { + if (hitzone.hitTestPoint(x,y,true)) { return way; } + return null; + } + } } diff --git a/net/systemeD/potlatch2/controller/SelectedWay.as b/net/systemeD/potlatch2/controller/SelectedWay.as index f7e6d327..ae947089 100644 --- a/net/systemeD/potlatch2/controller/SelectedWay.as +++ b/net/systemeD/potlatch2/controller/SelectedWay.as @@ -8,6 +8,7 @@ package net.systemeD.potlatch2.controller { import net.systemeD.potlatch2.tools.Simplify; import net.systemeD.halcyon.connection.*; import net.systemeD.halcyon.MapPaint; + import net.systemeD.halcyon.WayUI; import net.systemeD.halcyon.Globals; public class SelectedWay extends ControllerState { @@ -60,7 +61,6 @@ package net.systemeD.potlatch2.controller { override public function processKeyboardEvent(event:KeyboardEvent):ControllerState { switch (event.keyCode) { case 80: return new SelectedParallelWay(selectedWay); -// var p:Parallelise=new Parallelise(selectedWay); p.draw(0.001); return this; case 81: Quadrilateralise.quadrilateralise(selectedWay); return this; case 82: selectedWay.reverseNodes(MainUndoStack.getGlobalStack().addAction); return this; case 89: Simplify.simplify(selectedWay, controller.map, true); return this; @@ -72,12 +72,19 @@ package net.systemeD.potlatch2.controller { } protected function addNode(event:MouseEvent):int { - trace("add node"); + // find which other ways are under the mouse + var ways:Array=[]; var w:Way; + for each (var wayui:WayUI in controller.map.paint.wayuis) { + w=wayui.hitTest(event.stageX, event.stageY); + if (w && w!=selectedWay) { ways.push(w); } + } + var lat:Number = controller.map.coord2lat(event.localY); var lon:Number = controller.map.coord2lon(event.localX); var undo:CompositeUndoableAction = new CompositeUndoableAction("Insert node"); var node:Node = controller.connection.createNode({}, lat, lon, undo.push); var index:int = selectedWay.insertNodeAtClosestPosition(node, true, undo.push); + for each (w in ways) { w.insertNodeAtClosestPosition(node, true, undo.push); } MainUndoStack.getGlobalStack().addAction(undo); return index; } -- 2.36.1