Skip to content

Commit

Permalink
#25 call rect selection
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuque committed Feb 25, 2014
1 parent 3020156 commit 2d6d07a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions inner/js/model/MMMeshLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if (!window.mobmap) { window.mobmap={}; }
this._lctrlObserved = false;
this.dataReady = false;
this.sourceLoader = null;
this.localSelectionPool = new mobmap.SelectionPool();

this.meshData = null;
}
Expand Down
5 changes: 5 additions & 0 deletions inner/js/model/MMProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ if (!window.mobmap) { window.mobmap={}; }
getLayerList: function() {
return this.layerList;
},

getCurrentTimeInSeconds: function() {
var d = this.currentDateTime;
return d.getCurrentTime();
},

addMovingObjectLayer: function() {
var lyr = new mobmap.MovingObjectLayer();
Expand Down
13 changes: 13 additions & 0 deletions inner/js/selection/selection-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ if (!window.mobmap) { window.mobmap={}; }
function SelectionPool() {
var eve = document.createElement('span');
this.jEventElement = $(eve);

this.idmap = createCleanHash();
}

SelectionPool.CHANGE_EVENT = "selection-pool-change";
Expand All @@ -17,6 +19,17 @@ if (!window.mobmap) { window.mobmap={}; }

fire: function() {
this.eventDispatcher().trigger(SelectionPool.CHANGE_EVENT, this);
},

clear: function() {
var m = this.idmap;
for (var i in m) {
delete m[i];
}
},

addId: function(objId) {
this.idmap[objId] = true;
}
};

Expand Down
20 changes: 19 additions & 1 deletion inner/js/selection/selection-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,34 @@ if (!window.mobmap) { window.mobmap={}; }
},

makeIDCollection: function(targetProject) {
var pickTime = targetProject.getCurrentTimeInSeconds();

var ls = targetProject.getLayerList();
var len = ls.getCount();

for (var i = 0;i < len;++i) {
var lyr = ls.getLayerAt(i);
var selp = lyr.localSelectionPool;
selp.clear();

if (lyr.capabilities & mobmap.LayerCapability.SpatialSelectable) {
console.log("layer selection");
var pool = lyr.movingData.createPickPool();
pool.clear();

lyr.movingData.pickAt(pool, pickTime);
this.filterRect(pool, selp);
// var allCount = pool.pickedCount;
// console.log("layer selection", allCount);
}
}
},

filterRect: function(sourcePickPool, targetSelPool) {
var xmin = Math.min(this.startPos.lng, this.endPos.lng);
var xmax = Math.max(this.startPos.lng, this.endPos.lng);
var ymin = Math.min(this.startPos.lat, this.endPos.lat);
var ymax = Math.max(this.startPos.lat, this.endPos.lat);
},

// - - - - - - - - - -

Expand Down

0 comments on commit 2d6d07a

Please sign in to comment.