fix way splitting and node/UI renumbering
authorRichard Fairhurst <richard@systemed.net>
Sun, 28 Mar 2010 18:56:11 +0000 (18:56 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sun, 28 Mar 2010 18:56:11 +0000 (18:56 +0000)
TODO.txt
net/systemeD/halcyon/Map.as
net/systemeD/halcyon/MapPaint.as
net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/connection/Way.as
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/controller/SelectedWayNode.as

index f6297c0..3fa5c13 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -25,7 +25,6 @@ Potlatch 2: main outstanding issues
 
 * Non-900913 projections
 * Plugin support
-* pressing x to split ways doesn't seem to shorten the original way
 
 
 == UI ==
@@ -53,6 +52,6 @@ Potlatch 2: main outstanding issues
 * Shields
 * Arrows (dash-style or something) for oneway et al
 * Complete MapCSS support
-* Would be useful to be able to 'suspend' redrawing
+* Don't redraw stuff that's offscreen
 * 'Light' version without vectorlayer support etc.
-* Boost z-indexes to 20
+* Infinite z-indexes
index 1c10e50..db20ca5 100755 (executable)
@@ -94,6 +94,8 @@ package net.systemeD.halcyon {
                        connection = Connection.getConnection(initparams);
             connection.addEventListener(Connection.NEW_WAY, newWayCreated);
             connection.addEventListener(Connection.NEW_POI, newPOICreated);
+            connection.addEventListener(Connection.WAY_RENUMBERED, wayRenumbered);
+            connection.addEventListener(Connection.NODE_RENUMBERED, nodeRenumbered);
                        gotEnvironment(null);
 
                        addEventListener(Event.ENTER_FRAME, everyFrame);
@@ -245,6 +247,16 @@ package net.systemeD.halcyon {
                        nodeui.redraw();
         }
 
+               private function wayRenumbered(event:EntityRenumberedEvent):void {
+            var way:Way = event.entity as Way;
+                       paint.renumberWayUI(way,event.oldID);
+               }
+
+               private function nodeRenumbered(event:EntityRenumberedEvent):void {
+            var node:Node = event.entity as Node;
+                       paint.renumberNodeUI(node,event.oldID);
+               }
+
         public function setHighlight(entity:Entity, settings:Object):void {
                        var stateType:String;
                        var ui:EntityUI=null;
index c912a44..209cb33 100644 (file)
@@ -84,6 +84,18 @@ package net.systemeD.halcyon {
                        nodeuis[node.id].removeSprites();
                        delete nodeuis[node.id];
                }
+               
+               public function renumberWayUI(way:Way,oldID:int):void {
+                       if (!wayuis[oldID]) { return; }
+                       wayuis[way.id]=wayuis[oldID];
+                       delete wayuis[oldID];
+               }
+
+               public function renumberNodeUI(node:Node,oldID:int):void {
+                       if (!nodeuis[oldID]) { return; }
+                       nodeuis[node.id]=nodeuis[oldID];
+                       delete nodeuis[oldID];
+               }
 
         private function getPaintSprite():Sprite {
             var s:Sprite = new Sprite();
index 0941d50..5079008 100755 (executable)
@@ -60,6 +60,9 @@ package net.systemeD.halcyon.connection {
         public static var NEW_WAY:String = "new_way";
         public static var NEW_RELATION:String = "new_relation";
         public static var NEW_POI:String = "new_poi";
+        public static var NODE_RENUMBERED:String = "node_renumbered";
+        public static var WAY_RENUMBERED:String = "way_renumbered";
+        public static var RELATION_RENUMBERED:String = "relation_renumbered";
         public static var TAG_CHANGED:String = "tag_change";
         public static var NODE_MOVED:String = "node_moved";
         public static var WAY_NODE_ADDED:String = "way_node_added";
@@ -86,33 +89,36 @@ package net.systemeD.halcyon.connection {
             return negativeID--;
         }
 
-        protected function setNode(node:Node,queue:Boolean):void {
+        protected function setNode(node:Node, queue:Boolean):void {
             nodes[node.id] = node;
             if (node.loaded) { sendEvent(new EntityEvent(NEW_NODE, node),queue); }
         }
 
-        protected function setWay(way:Way,queue:Boolean):void {
+        protected function setWay(way:Way, queue:Boolean):void {
             ways[way.id] = way;
             if (way.loaded) { sendEvent(new EntityEvent(NEW_WAY, way),queue); }
         }
 
-        protected function setRelation(relation:Relation,queue:Boolean):void {
+        protected function setRelation(relation:Relation, queue:Boolean):void {
             relations[relation.id] = relation;
             if (relation.loaded) { sendEvent(new EntityEvent(NEW_RELATION, relation),queue); }
         }
 
-        protected function renumberNode(oldID:Number, node:Node):void {
+        protected function renumberNode(oldID:Number, node:Node, queue:Boolean):void {
             nodes[node.id] = node;
+            if (node.loaded) { sendEvent(new EntityRenumberedEvent(NODE_RENUMBERED, node, oldID),queue); }
             delete nodes[oldID];
         }
 
-        protected function renumberWay(oldID:Number, way:Way):void {
+        protected function renumberWay(oldID:Number, way:Way, queue:Boolean):void {
             ways[way.id] = way;
+            if (way.loaded) { sendEvent(new EntityRenumberedEvent(WAY_RENUMBERED, way, oldID),queue); }
             delete ways[oldID];
         }
 
-        protected function renumberRelation(oldID:Number, relation:Relation):void {
+        protected function renumberRelation(oldID:Number, relation:Relation, queue:Boolean):void {
             relations[relation.id] = relation;
+            if (relation.loaded) { sendEvent(new EntityRenumberedEvent(RELATION_RENUMBERED, relation, oldID),queue); }
             delete relations[oldID];
         }
 
index a838fb8..0e0a543 100644 (file)
@@ -80,7 +80,11 @@ package net.systemeD.halcyon.connection {
                }
 
                public function deleteNodesFrom(start:int):void {
+                       for (var i:int=start; i<nodes.length; i++) {
+                               nodes[i].removeParent(this);
+                       }
                        nodes.splice(start);
+                       markDirty();
                }
 
                public function mergeWith(way:Way,topos:int,frompos:int):void {
index 0104931..859a588 100644 (file)
@@ -267,9 +267,9 @@ package net.systemeD.halcyon.connection {
                 entity.markClean(newID, version);
                 
                 if ( oldID != newID ) {
-                    if ( type == "node" ) renumberNode(oldID, entity as Node);
-                    else if ( type == "way" ) renumberWay(oldID, entity as Way);
-                    else if ( type == "relation" ) renumberRelation(oldID, entity as Relation);
+                    if ( type == "node" ) renumberNode(oldID, entity as Node, false);
+                    else if ( type == "way" ) renumberWay(oldID, entity as Way, false);
+                    else if ( type == "relation" ) renumberRelation(oldID, entity as Relation, false);
                 }
                 // *** TODO *** handle deleting
             }
index f4960d1..340a112 100644 (file)
@@ -110,6 +110,8 @@ package net.systemeD.potlatch2.controller {
                        var newWay:Way = controller.connection.createWay(
                                selectedWay.getTagsCopy(), 
                                selectedWay.sliceNodes(selectedWay.indexOfNode(selectedNode),selectedWay.length));
+                       newWay.suspend();
+                       selectedWay.suspend();
                        selectedWay.deleteNodesFrom(selectedWay.indexOfNode(selectedNode)+1);
                        
                        // copy relations
@@ -117,7 +119,8 @@ package net.systemeD.potlatch2.controller {
                                // ** needs to copy roles as well
                                r.appendMember(new RelationMember(newWay, ''));
                        }
-                       controller.map.paint.wayuis[newWay.id].redraw();        // ** should we do this by firing an event?
+                       newWay.resume();
+                       selectedWay.resume();
 
                        return new SelectedWay(selectedWay);
                }