Skip to content
This repository was archived by the owner on Jan 1, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions net/systemeD/potlatch2/Toolbox.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@
import flash.events.MouseEvent;
import net.systemeD.halcyon.connection.*;
import net.systemeD.halcyon.connection.actions.*;
import net.systemeD.halcyon.AttentionEvent;
import net.systemeD.potlatch2.controller.*;
import net.systemeD.potlatch2.tools.*;
import embedded.*; // for FXG icons

private var controller:EditController;

[Bindable]
Expand Down Expand Up @@ -294,10 +295,16 @@

public function doCircularise():void {
var undo:CompositeUndoableAction = new CompositeUndoableAction("Make objects circular ");
for each (var way:Way in controller.state.selectedWays) {
Circularise.circularise(way, controller.map, undo.push);
try {

for each (var way:Way in controller.state.selectedWays) {
Circularise.circularise(way, controller.map, undo.push);
}
MainUndoStack.getGlobalStack().addAction(undo);
} catch (e: Error) {
var msg:String = e.message;
controller.dispatchEvent(new AttentionEvent(AttentionEvent.ALERT, null, msg));
}
MainUndoStack.getGlobalStack().addAction(undo);
}

public function doSplit():void {
Expand Down
9 changes: 9 additions & 0 deletions net/systemeD/potlatch2/tools/Circularise.as
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ package net.systemeD.potlatch2.tools {
if (clockwise) {
if (a2>a1) { a2=a2-360; }
diff=a1-a2;
if (diff > 180) {
// If way crosses back on itself, we risk creating lots of extra nodes.
// (Bug 3786)
throw new Error ("This shape is too irregular. Sorry.");
}
if (diff>20) {
for (ang=a1-20; ang>a2+10; ang-=20) {
insertNode(ang, i+1);
Expand All @@ -90,6 +95,9 @@ package net.systemeD.potlatch2.tools {
} else {
if (a1>a2) { a1=a1-360; }
diff=a2-a1;
if (diff > 180) {
throw new Error ("This shape is too irregular. Sorry.");
}
if (diff>20) {
for (ang=a1+20; ang<a2-10; ang+=20) {
insertNode(ang, i+1);
Expand Down Expand Up @@ -168,3 +176,4 @@ package net.systemeD.potlatch2.tools {
}
}
}