Skip to content
Browse files

Tidy and fix the pull-through code

  • Loading branch information...
1 parent b6d4754 commit 0cf41e93e4eb93ad87dc99547c7516d3579fd9d3 @systemed committed Oct 3, 2011
Showing with 10 additions and 6 deletions.
  1. +10 −6 net/systemeD/potlatch2/controller/ControllerState.as
View
16 net/systemeD/potlatch2/controller/ControllerState.as
@@ -108,9 +108,13 @@ package net.systemeD.potlatch2.controller {
if ( paint && paint.isBackground ) {
if (event.type == MouseEvent.MOUSE_DOWN && ((event.shiftKey && event.ctrlKey) || event.altKey) ) {
// alt-click to pull data out of vector background layer
- var newSelection:Array=[];
- if (selection.indexOf(entity)==-1) { selection=[entity]; }
- for each (var entity:Entity in selection) {
+ // first, create a list of the alt-clicked item, plus anything else already selected (assuming it's in the same layer!)
+ var itemsToPullThrough:Array=[]
+ if (_selection.length && firstSelected.connection==entity.connection) itemsToPullThrough=_selection.slice();
+ if (itemsToPullThrough.indexOf(entity)==-1) itemsToPullThrough.push(entity);
+ // make sure they're unhighlighted, and pull them through
+ var newSelection:Array=[]
+ for each (var entity:Entity in itemsToPullThrough) {
paint.setHighlight(entity, { hover:false, selected: false });
if (entity is Way) paint.setHighlightOnNodes(Way(entity), { selectedway: false });
newSelection.push(paint.pullThrough(entity,controller.map.editableLayer));
@@ -317,7 +321,7 @@ package net.systemeD.potlatch2.controller {
// If there's an existing outer in the selection, use that
for each (entity in selection) {
- if (!entity is Way) return {};
+ if (!(entity is Way)) return {};
var r:Array=entity.findParentRelationsOfType('multipolygon','outer');
if (r.length) { outer=Way(entity); relation=r[0]; }
}
@@ -326,7 +330,7 @@ package net.systemeD.potlatch2.controller {
var largest:Number=0;
if (!outer) {
for each (entity in selection) {
- if (!entity is Way) return {};
+ if (!(entity is Way)) return {};
if (!Way(entity).isArea()) return {};
var props:Object=layer.wayUIProperties(entity as Way);
if (props.patharea>largest) { outer=Way(entity); largest=props.patharea; }
@@ -337,7 +341,7 @@ package net.systemeD.potlatch2.controller {
// Identify the inners
for each (entity in selection) {
if (entity==outer) continue;
- if (!entity is Way) return {};
+ if (!(entity is Way)) return {};
if (!Way(entity).isArea()) return {};
var node:Node=Way(entity).getFirstNode();
if (outer.pointWithin(node.lon,node.lat)) inners.push(entity);

0 comments on commit 0cf41e9

Please sign in to comment.
Something went wrong with that request. Please try again.