From: Richard Fairhurst Date: Mon, 17 May 2010 13:12:32 +0000 (+0000) Subject: parallelise X-Git-Tag: 0.5~446 X-Git-Url: https://git.openstreetmap.org/potlatch2.git/commitdiff_plain/f2fd917a53d1231688b125386458c41e5d698a74 parallelise --- diff --git a/net/systemeD/potlatch2/Toolbox.as b/net/systemeD/potlatch2/Toolbox.as index 94232bdf..d4de447b 100644 --- a/net/systemeD/potlatch2/Toolbox.as +++ b/net/systemeD/potlatch2/Toolbox.as @@ -16,6 +16,7 @@ package net.systemeD.potlatch2 { ** Should float above tagViewer, not beneath it ** Icons should be disabled depending on what's selected (setEntity can do this) ** Remove annoying Illustrator cruft from SVG icons! + ** Tooltips */ @@ -93,6 +94,12 @@ package net.systemeD.potlatch2 { controller.setState(SelectedWayNode(controller.state).splitWay()); } } + + public function doParallelise():void { + if (entity is Way) { + controller.setState(new SelectedParallelWay(Way(entity))); + } + } } } diff --git a/net/systemeD/potlatch2/controller/SelectedParallelWay.as b/net/systemeD/potlatch2/controller/SelectedParallelWay.as new file mode 100644 index 00000000..8a04bffe --- /dev/null +++ b/net/systemeD/potlatch2/controller/SelectedParallelWay.as @@ -0,0 +1,54 @@ +package net.systemeD.potlatch2.controller { + import flash.events.*; + import flash.display.Stage; + import net.systemeD.halcyon.connection.*; + import net.systemeD.halcyon.Map; + import net.systemeD.potlatch2.tools.Parallelise; + import net.systemeD.halcyon.Globals; + + public class SelectedParallelWay extends SelectedWay { + private var startlon:Number; + private var startlatp:Number; + private var parallelise:Parallelise; + + public function SelectedParallelWay(originalWay:Way) { + parallelise = new Parallelise(originalWay); + selectedWay=parallelise.parallelWay; + super (selectedWay); + } + + override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState { + if (event.type==MouseEvent.MOUSE_MOVE) { + var lon:Number =controller.map.coord2lon(controller.map.mouseX); + var latp:Number=controller.map.coord2latp(controller.map.mouseY); + var offset:Number=Math.sqrt(Math.pow(lon-startlon,2)+ + Math.pow(latp-startlatp,2)); + if (lon "+this); + } + override public function exitState():void { + clearSelection(); + Globals.vars.root.addDebug("**** <- "+this); + } + + override public function toString():String { + return "SelectedParallelWay"; + } + } +} diff --git a/net/systemeD/potlatch2/controller/SelectedWay.as b/net/systemeD/potlatch2/controller/SelectedWay.as index 02d5634c..7762b7c4 100644 --- a/net/systemeD/potlatch2/controller/SelectedWay.as +++ b/net/systemeD/potlatch2/controller/SelectedWay.as @@ -3,6 +3,7 @@ package net.systemeD.potlatch2.controller { import flash.display.DisplayObject; import flash.ui.Keyboard; 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.*; @@ -59,6 +60,8 @@ 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; diff --git a/net/systemeD/potlatch2/tools/Parallelise.as b/net/systemeD/potlatch2/tools/Parallelise.as new file mode 100644 index 00000000..8ba976ec --- /dev/null +++ b/net/systemeD/potlatch2/tools/Parallelise.as @@ -0,0 +1,76 @@ +package net.systemeD.potlatch2.tools { + + import net.systemeD.halcyon.connection.*; + + // FIXME: + // ** needs to be properly undoable + + public class Parallelise { + private var originalWay:Way; + public var parallelWay:Way; + private var connection:Connection; + private var offsetx:Array=[]; + private var offsety:Array=[]; + private var df:Array=[]; + private var nodes:Object={}; + + public function Parallelise(way:Way) { + var a:Number, b:Number, h:Number, i:uint; + connection = Connection.getConnection(); + originalWay = way; + parallelWay = connection.createWay({}, [], MainUndoStack.getGlobalStack().addAction); + + for (i=0; i