add the ability to lock entities against purging
authorRichard Fairhurst <richard@systemed.net>
Fri, 26 Nov 2010 16:40:25 +0000 (16:40 +0000)
committerRichard Fairhurst <richard@systemed.net>
Fri, 26 Nov 2010 16:40:25 +0000 (16:40 +0000)
TODO.txt
net/systemeD/halcyon/Map.as
net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/connection/Entity.as
net/systemeD/halcyon/connection/Way.as

index d55d4c86613799c2a58e73388782d84ef6a86de8..7fd5a9a3b7c88a9f6ea6c15cf874021668ef74bb 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -42,7 +42,6 @@ Potlatch 2: main outstanding issues
 
 == Rendering (Halcyon) ==
 
-** Entities need some sort of .purgable attribute (like EntityUIs) - currently you can select an item, then pan off-screen, and the entity is deleted at next purge, causing an exception whenever P2 tries to access it (e.g. via the selection)
 * halcyon_viewer needs updating for new tileurl stuff
 * Shields
 * More line decoration (cliffs etc.), and implied values for 'dashes' if not supplied
index 836c0e164cec4de11948cd9b9bddcc70e924651d..973878fb26fc77a9036a50e1998f36008f0a03d2 100644 (file)
@@ -274,15 +274,19 @@ package net.systemeD.halcyon {
                        if (paint.wayuis[way.id]) paint.wayuis[way.id].setHighlightOnNodes(settings);
         }
 
+               /* Protect Entities and EntityUIs against purging. This prevents the currently selected items
+                  from being purged even though they're off-screen. */
+
                public function setPurgable(entities:Array, purgable:Boolean):void {
                        for each (var entity:Entity in entities) {
+                               entity.locked=!purgable;
                                if ( entity is Way  ) {
                                        var way:Way=entity as Way;
                                        if (paint.wayuis[way.id]) { paint.wayuis[way.id].purgable=purgable; }
                                        for (var i:uint=0; i<way.length; i++) {
-                                               if (paint.nodeuis[way.getNode(i).id]) {
-                                                       paint.nodeuis[way.getNode(i).id].purgable=purgable;
-                                               }
+                                               var node:Node=way.getNode(i)
+                                               node.locked=!purgable;
+                                               if (paint.nodeuis[node.id]) { paint.nodeuis[node.id].purgable=purgable; }
                                        }
                                } else if ( entity is Node && paint.nodeuis[entity.id]) { 
                                        paint.nodeuis[entity.id].purgable=purgable;
index 1000951ff532577753ecd990fd45b3283a0cc52b..3afe045792b9bab597a8ac3f30f7dc17246a48e9 100644 (file)
@@ -312,12 +312,12 @@ package net.systemeD.halcyon.connection {
 
                public function purgeOutside(left:Number, right:Number, top:Number, bottom:Number):void {
                        for each (var way:Way in ways) {
-                               if (!way.within(left,right,top,bottom) && !way.isDirty) {
+                               if (!way.within(left,right,top,bottom) && !way.isDirty && !way.locked && !way.hasLockedNodes()) {
                                        killWayWithNodes(way.id);
                                }
                        }
                        for each (var poi:Node in pois) {
-                               if (!poi.within(left,right,top,bottom) && !poi.isDirty) {
+                               if (!poi.within(left,right,top,bottom) && !poi.isDirty && !poi.locked) {
                                        killNode(poi.id);
                                }
                        }
index b6b857030fd71b0ef808b1e6f7603f38946cf46e..0f441658b79735bc144a3c015a0250a1c1ad7a50 100644 (file)
@@ -14,7 +14,7 @@ package net.systemeD.halcyon.connection {
         private var modified:Boolean = false;
                private var _loaded:Boolean = true;
                private var parents:Dictionary = new Dictionary();
-               private var locked:Boolean = false;
+               public var locked:Boolean = false;                                              // lock against purging when off-screen
                public var deleted:Boolean = false;
 
         public function Entity(id:Number, version:uint, tags:Object, loaded:Boolean, uid:Number, timestamp:String) {
index d64dec43bdbe89a91af926413eee0ac0c8d2da41..8ca13f2c0031db3f5738e6bb6f36f337cadd0497 100644 (file)
@@ -81,6 +81,13 @@ package net.systemeD.halcyon.connection {
                public function hasOnceOnly(node:Node):Boolean {
                        return nodes.indexOf(node)==nodes.lastIndexOf(node);
                }
+               
+               public function hasLockedNodes():Boolean {
+                       for each (var node:Node in nodes) {
+                               if (node.locked) { return true; }
+                       }
+                       return false;
+               }
 
                public function removeNode(node:Node, performAction:Function):void {
                        performAction(new RemoveNodeFromWayAction(this, node, nodes));