Commit 95806dd5 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Ускорение формул. убран for in в DependencyGraph

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53204 954022d7-b5bf-4e40-9824-e11837661b57
parent 30fd9de5
...@@ -39,76 +39,78 @@ function consolelog(text){ ...@@ -39,76 +39,78 @@ function consolelog(text){
/** @constructor */ /** @constructor */
function DependencyGraph(wb) { function DependencyGraph(wb) {
var nodes = {}, badRes = [], result = [], nodeslength = 0, nodesfirst, __nodes = {}, areaNodes = {}, thas = this; var nodes = {}, nodesId = {}, badRes = [], result = [], nodeslength = 0, __nodes = {}, thas = this;
this.wb = wb; this.wb = wb;
this.clear = function(){ this.clear = function(){
nodes = {}; nodes = {};
nodesId = {};
__nodes = {}; __nodes = {};
areaNodes = {};
badRes = []; badRes = [];
result = []; result = [];
nodeslength = 0; nodeslength = 0;
nodesfirst = null;
} }
this.nodeExist = function(node){ this.nodeExist = function(node){
return nodes[node.nodeId] !== undefined; return null != this.getNode3(node);
} }
this.nodeExist2 = function(sheetId, cellId){ this.nodeExist2 = function(sheetId, cellId){
var n = new Vertex(sheetId, cellId); var bRes = false;
var exist = nodes[n.nodeId] !== undefined; var node = new Vertex(sheetId, cellId);
if ( !exist ){ var oGetRes = this.getNode4(node);
for( var id in areaNodes){ if(oGetRes.exist)
if( areaNodes[id].containCell(n) ) bRes = true;
return true; else if(oGetRes.contains && oGetRes.contains.length > 0)
} bRes = true;
} return bRes;
return exist;
} }
//добавляем вершину по id листа и по id ячейки //добавляем вершину по id листа и по id ячейки
this.addNode = function(sheetId, cellId){ this.addNode = function(sheetId, cellId){
var node = new Vertex(sheetId, cellId,this.wb); var node = new Vertex(sheetId, cellId,this.wb);
if (nodes[node.nodeId] === undefined){ this.addNode2(node);
if (nodeslength == 0){
nodesfirst = node.nodeId;
}
nodes[node.nodeId] = node;
nodeslength++;
if( node.isArea && !areaNodes[node.nodeId] ){
areaNodes[node.nodeId] = node;
}
}
} }
//добавляем уже существующую вершину //добавляем уже существующую вершину
this.addNode2 = function(node){ this.addNode2 = function(node){
if (nodes[node.nodeId] === undefined) { if(!nodesId[node.nodeId])
if (nodeslength == 0){ {
nodesfirst = node.nodeId; var nodesSheet = nodes[node.sheetId];
if(null == nodesSheet)
{
nodesSheet = new RangeDataManager(null);
nodes[node.sheetId] = nodesSheet;
} }
nodes[node.nodeId] = node; var oBBoxNode = node.getBBox();
nodeslength ++; nodesSheet.add(oBBoxNode, node);
if( node.isArea && !areaNodes[node.nodeId] ){ nodesId[node.nodeId] = node;
areaNodes[node.nodeId] = node; nodeslength++;
for( var id in nodes ){ var oIntersectNodes = nodesSheet.get(oBBoxNode);
if( !nodes[id].isArea ){ if( node.isArea)
if( node.containCell(nodes[id]) ){ {
node.addMasterEdge(nodes[id]); for(var i = 0, length = oIntersectNodes.inner.length; i < length; i++)
nodes[id].addSlaveEdge(node); {
var elem = oIntersectNodes.inner[i];
var nodeMaster = elem.data;
if(!nodeMaster.isArea)
{
node.addMasterEdge(nodeMaster);
nodeMaster.addSlaveEdge(node);
} }
} }
} }
return; else
{
for(var i = 0, length = oIntersectNodes.outer.length; i < length; i++)
{
var elem = oIntersectNodes.outer[i];
var nodeSlave = elem.data;
if(nodeSlave.isArea && elem.bbox.containsRange(oBBoxNode))
{
nodeSlave.addMasterEdge(node);
node.addSlaveEdge(nodeSlave);
} }
for( var id2 in areaNodes ){
if( areaNodes[id2].containCell(node) ){
areaNodes[id2].addMasterEdge(node);
node.addSlaveEdge(areaNodes[id2]);
} }
} }
} }
...@@ -116,150 +118,189 @@ function DependencyGraph(wb) { ...@@ -116,150 +118,189 @@ function DependencyGraph(wb) {
//добавление ребер между вершинами //добавление ребер между вершинами
this.addEdge = function(sheetIdFrom, cellIdFrom, sheetIdTo, cellIdTo){ this.addEdge = function(sheetIdFrom, cellIdFrom, sheetIdTo, cellIdTo){
var n1 = new Vertex(sheetIdFrom, cellIdFrom,this.wb), var n1 = this.getNode(sheetIdFrom, cellIdFrom),
n2 = new Vertex(sheetIdTo, cellIdTo,this.wb); n2 = this.getNode(sheetIdTo, cellIdTo);
if( !this.nodeExist(n1) ){ if( !n1 ){
n1 = new Vertex(sheetIdFrom, cellIdFrom,this.wb);
this.addNode2(n1); this.addNode2(n1);
} }
if( !this.nodeExist(n2) ){ if( !n2 ){
n2 = new Vertex(sheetIdTo, cellIdTo,this.wb);
this.addNode2(n2); this.addNode2(n2);
} }
nodes[n1.nodeId].addMasterEdge(nodes[n2.nodeId]); n1.addMasterEdge(n2);
nodes[n2.nodeId].addSlaveEdge(nodes[n1.nodeId]); n2.addSlaveEdge(n1);
} }
this.addEdge2 = function(nodeFrom, nodeTo){ this.addEdge2 = function(nodeFrom, nodeTo){
this.addEdge(nodeFrom.sheetId, nodeFrom.cellId, nodeTo.sheetId, nodeTo.cellId);
if( !this.nodeExist(nodeFrom) ){
this.addNode2(nodeFrom);
}
if( !this.nodeExist(nodeTo) ){
this.addNode2(nodeTo);
}
nodes[nodeFrom.nodeId].addMasterEdge(nodes[nodeTo.nodeId]);
nodes[nodeTo.nodeId].addSlaveEdge(nodes[nodeFrom.nodeId]);
} }
this.renameNode = function(sheetIdFrom, cellIdFrom, sheetIdTo, cellIdTo){ this.renameNode = function(sheetIdFrom, cellIdFrom, sheetIdTo, cellIdTo){
if( sheetIdFrom == sheetIdTo && cellIdFrom == cellIdTo ){ if( sheetIdFrom == sheetIdTo && cellIdFrom == cellIdTo ){
return; return;
} }
nodes[getVertexId(sheetIdTo, cellIdTo)] = nodes[getVertexId(sheetIdFrom, cellIdFrom)]; var nodeTo = this.getNode3(sheetIdTo, cellIdTo);
if( !nodes[getVertexId(sheetIdTo, cellIdTo)] ) if(null != nodeTo)
return; this.deleteNode(nodeTo);
nodes[getVertexId(sheetIdFrom, cellIdFrom)] = undefined; var nodeFrom = this.getNode3(sheetIdFrom, cellIdFrom);
delete nodes[getVertexId(sheetIdFrom, cellIdFrom)]; if(null != nodeFrom)
nodes[getVertexId(sheetIdTo, cellIdTo)].changeCellId(cellIdTo); {
this.deleteNode(nodeFrom);
nodeFrom.changeCellId(cellIdTo);
this.addNode2(nodeFrom);
}
} }
this.getNode = function(sheetId, cellId){ this.getNode = function(sheetId, cellId){
var n = new Vertex(sheetId, cellId) var n = new Vertex(sheetId, cellId)
if( this.nodeExist(n) ) return this.getNode3(n);
return nodes[n.nodeId];
} }
this.getNode2 = function(sheetId, cellId){ this.getNode2 = function(sheetId, cellId){
var n = new Vertex( sheetId, cellId ); var node = new Vertex( sheetId, cellId );
var exist = nodes[n.nodeId] !== undefined, res = []; var res = [];
if ( exist ) { var oGetRes = this.getNode4(node);
res.push( nodes[n.nodeId] ) if(oGetRes.exist)
res.push(oGetRes.exist);
else if(oGetRes.contains)
res = oGetRes.contains;
return res.length > 0 ? res : null;
} }
else { this.getNode3 = function(node){
for ( var id in areaNodes ) { // var oRes = null;
if ( areaNodes[id].containCell( n ) ) { // var nodesSheet = nodes[node.sheetId];
res.push( areaNodes[id] ) // if(nodesSheet)
// {
// var elem = nodesSheet.getExact(node.getBBox());
// if(elem)
// oRes = elem.data;
// }
return nodesId[node.nodeId];;
} }
this.getNode4 = function(node){
var oRes = {exist: null, contains: null};
oRes.exist = this.getNode3(node);
if(!oRes.exist)
{
var nodesSheet = nodes[node.sheetId];
if(nodesSheet)
{
var oBBoxNode = node.getBBox();
var oIntersectNodes = nodesSheet.get(oBBoxNode);
oRes.contains = [];
for(var i = 0, length = oIntersectNodes.outer.length; i < length; i++)
{
var elem = oIntersectNodes.outer[i];
if(elem.data.isArea && elem.bbox.containsRange(oBBoxNode))
oRes.contains.push(elem.data);
} }
} }
return res.length > 0 ? res : null;
} }
return oRes;
this.getNodeByNodeId = function(nodeId){
if( nodes[nodeId] )
return nodes[nodeId];
} }
this.getNodeBySheetId = function(sheetId){ this.getNodeBySheetId = function(sheetId){
var arr = []; var arr = [];
for(var id in nodes){ var nodesSheet = nodes[sheetId];
if ( nodes[id].sheetId == sheetId && nodes[id].getSlaveEdges()){ if(nodesSheet)
arr.push(nodes[id]); {
var n = nodes[id].getSlaveEdges() var aNodes = nodesSheet.getAll();
for(var i = 0, length = aNodes.length; i < length; i++)
{
var node = aNodes[i].data;
var n = node.getSlaveEdges();
if(n)
{
arr.push(node);
for(var id2 in n){ for(var id2 in n){
n[id2].weightNode++; n[id2].weightNode++;
// arr.push(n[id2]); // arr.push(n[id2]);
} }
} }
} }
}
return arr; return arr;
} }
this.deleteNode = function(n){ this.deleteNode = function(n){
if( this.nodeExist(n) ){ var nodesSheet = nodes[n.sheetId];
var _n = nodes[n.nodeId]; if(nodesSheet)
_n.deleteAllMasterEdges(); {
_n.deleteAllSlaveEdges(); var elem = nodesSheet.getExact(n.getBBox());
if( areaNodes[_n.nodeId] ){ if( elem )
areaNodes[_n.nodeId] = null; {
delete areaNodes[_n.nodeId]; var node = elem.data;
} node.deleteAllMasterEdges();
nodes[_n.nodeId] = null; node.deleteAllSlaveEdges();
delete nodes[_n.nodeId]; nodesSheet.removeElement(elem);
delete nodesId[node.nodeId];
nodeslength--; nodeslength--;
} }
} }
}
this.deleteMasterNodes = function(sheetId, cellId){ this.deleteMasterNodes = function(sheetId, cellId){
var n = new Vertex(sheetId, cellId); var node = this.getNode(sheetId, cellId);
if( this.nodeExist(n) ){ if(node)
var arr = nodes[n.nodeId].deleteAllMasterEdges(); {
for(var i = 0; i < arr.length; i++){ var nodesSheet = nodes[node.sheetId];
if( nodes[arr[i]].refCount <= 0 ){ if(nodesSheet)
nodes[arr[i]] = null; {
delete nodes[arr[i]]; var arr = node.deleteAllMasterEdges();
for(var i in arr){
var nodeMaster = arr[i];
if( nodeMaster.refCount <= 0 ){
//может через deleteNode ?
var elem = nodesSheet.getExact(nodeMaster.getBBox());
if(elem)
{
nodesSheet.removeElement(elem);
delete nodesId[nodeMaster.nodeId];
nodeslength--; nodeslength--;
} }
} }
} }
} }
}
}
this.deleteSlaveNodes = function(sheetId, cellId){ this.deleteSlaveNodes = function(sheetId, cellId){
var n = new Vertex(sheetId, cellId); var node = this.getNode(sheetId, cellId);
if( this.nodeExist(n) ){ if(node)
nodes[n.nodeId].deleteAllSlaveEdges(); node.deleteAllSlaveEdges();
}
} }
this.getSlaveNodes = function(sheetId, cellId){ this.getSlaveNodes = function(sheetId, cellId){
var oRes = null;
var node = new Vertex(sheetId, cellId); var node = new Vertex(sheetId, cellId);
if( this.nodeExist(node) ){ var oGetRes = this.getNode4(node);
return nodes[node.nodeId].getSlaveEdges(); if(oGetRes.exist)
} oRes = oGetRes.exist;
else{ else if(oGetRes.contains)
{
var _t = {}, f = false; var _t = {}, f = false;
for( var id in areaNodes ){ for(var i = 0, length = oGetRes.contains.length; i < length; i++)
if( areaNodes[id].containCell(node) ){ {
_t[id] = areaNodes[id]; var elem = oGetRes.contains[i];
_t[elem.nodeId] = elem;
f = true; f = true;
} }
}
if (f) if (f)
return _t; oRes = _t;
} }
return null; return oRes;
} }
this.getMasterNodes = function(sheetId, cellId){ this.getMasterNodes = function(sheetId, cellId){
var n = new Vertex(sheetId, cellId); var oRes = null;
if( this.nodeExist(n) ){ var node = this.getNode(sheetId, cellId);
return nodes[n.nodeId].getMasterEdges(); if(node)
} oRes = node.getMasterEdges();
return null; return oRes;
} }
//объект __nodes является копией объекта nodes. чтобы не бегать по всему графу в поисках очередной вершины, будем бегать по __nodes и удалять полученную новую вершину из __nodes. //объект __nodes является копией объекта nodes. чтобы не бегать по всему графу в поисках очередной вершины, будем бегать по __nodes и удалять полученную новую вершину из __nodes.
...@@ -269,55 +310,56 @@ function DependencyGraph(wb) { ...@@ -269,55 +310,56 @@ function DependencyGraph(wb) {
__nodes[n.nodeId] = n; __nodes[n.nodeId] = n;
} }
} }
this.getFirstNode = function(sheetId,cellId) {
//сортировка по зависимым(ведомым) ячейкам. у объекта берем массив slaveEdges и по нему бегаем.
this.t_sort_slave = function(sheetId,cellId){
function getFirstNode(sheetId,cellId) {
var n = new Vertex(sheetId,cellId,thas.wb); var n = new Vertex(sheetId,cellId,thas.wb);
if ( !nodes[n.nodeId] ){ var oGetRes = this.getNode4(n);
var a = []; if(oGetRes.exist)
for( var id in areaNodes ){ return oGetRes.exist;
if( areaNodes[id].containCell(n) ) else
a.push(areaNodes[id]) {
} if(oGetRes.contains && oGetRes.contains.length > 0)
if( a.length > 0 ){ {
for( var i in a ){ for( var i = 0, length = oGetRes.contains.length; i < length; i++){
n.addSlaveEdge( a[i] ); n.addSlaveEdge( oGetRes.contains[i] );
} }
n.valid = false; n.valid = false;
return n; return n;
} }
else{
return undefined; return undefined;
} }
} }
else this.getNextNode = function(node, aArrayToFind, oIndexObj) {
return nodes[n.nodeId]; if(node)
} {
for(var i = oIndexObj.cur, length = oIndexObj.indexes.length; i < length; i++)
function getNextNode(node) { {
for (var id in node.slaveEdges){ var n = aArrayToFind[oIndexObj.indexes[i]];
var n = nodes[id]; oIndexObj.cur++;
if (n !== undefined){ var node = this.getNode3(n);
if ((n.isBlack === undefined || !n.isBlack) && !n.isBad) { if(node)
return n; {
} if ((node.isBlack === undefined || !node.isBlack) && !node.isBad)
return node;
} }
else { else
delete node.slaveEdges[id]; delete aArrayToFind[id];
} }
} }
return undefined; return undefined;
} }
//сортировка по зависимым(ведомым) ячейкам. у объекта берем массив slaveEdges и по нему бегаем.
var stack = [], n = getFirstNode(sheetId,cellId),__t = true, next, badResS = [], resultS = []; this.t_sort_slave = function(sheetId,cellId){
//todo из этой функции хотелось бы убрать getNextNode, тогда можно будет убрать getSlaveEdgesIndexes
var stack = [], n = this.getFirstNode(sheetId,cellId),__t = true, next, badResS = [], resultS = [];
if( !n ){ if( !n ){
return {depF: resultS.reverse(), badF: badResS} return {depF: resultS.reverse(), badF: badResS}
} }
//todo можно будет убрать getSlaveEdgesIndexes если сделать алгоритм без getNext
var oIndexObj = {cur: 0, indexes: n.getSlaveEdgesIndexes()};
var oIndexMap = {};
oIndexMap[n.nodeId] = oIndexObj;
while (1) { while (1) {
if ( n.isGray && !n.isArea ){ if ( n.isGray && !n.isArea ){
for( var i = stack.length-1; i>=0;i--){ for( var i = stack.length-1; i>=0;i--){
...@@ -329,18 +371,34 @@ function DependencyGraph(wb) { ...@@ -329,18 +371,34 @@ function DependencyGraph(wb) {
} }
if (stack.length < 1) { if (stack.length < 1) {
for (var id in __nodes){ for (var id in __nodes){
if( nodes[id] !== undefined && ((nodes[id].isBlack === undefined || !nodes[id].isBlack) && !nodes[id].isBad) ){ var temp = __nodes[id];
n = nodes[id]; var nodeTemp = thas.getNode3(temp);
if(nodeTemp && ((nodeTemp.isBlack === undefined || !nodeTemp.isBlack) && !nodeTemp.isBad) )
{
n = nodeTemp;
oIndexObj = oIndexMap[n.nodeId];
if(!oIndexObj)
{
oIndexObj = {cur: 0, indexes: n.getSlaveEdgesIndexes()};
oIndexMap[n.nodeId] = oIndexObj;
}
delete __nodes[id]; delete __nodes[id];
} }
} }
} }
} }
next = getNextNode(n);
next = this.getNextNode(n, n.slaveEdges, oIndexObj);
if (next !== undefined) { if (next !== undefined) {
n.isGray = true; n.isGray = true;
stack.push(n); stack.push(n);
n = next; n = next;
oIndexObj = oIndexMap[n.nodeId];
if(!oIndexObj)
{
oIndexObj = {cur: 0, indexes: n.getSlaveEdgesIndexes()};
oIndexMap[n.nodeId] = oIndexObj;
}
} }
else { else {
n.isBlack = true; n.isBlack = true;
...@@ -350,6 +408,12 @@ function DependencyGraph(wb) { ...@@ -350,6 +408,12 @@ function DependencyGraph(wb) {
break; break;
n = stack.pop(); n = stack.pop();
n.isGray = false; n.isGray = false;
oIndexObj = oIndexMap[n.nodeId];
if(!oIndexObj)
{
oIndexObj = {cur: 0, indexes: n.getSlaveEdgesIndexes()};
oIndexMap[n.nodeId] = oIndexObj;
}
} }
} }
...@@ -367,57 +431,18 @@ function DependencyGraph(wb) { ...@@ -367,57 +431,18 @@ function DependencyGraph(wb) {
return {depF: resultS.reverse(), badF: badResS} return {depF: resultS.reverse(), badF: badResS}
} }
//сортировка по ведущим ячейкам. у объекта берем массив masterEdges и по нему бегаем. //сортировка по ведущим ячейкам. у объекта берем массив masterEdges и по нему бегаем.
this.t_sort_master = function(sheetId,cellId){ this.t_sort_master = function(sheetId,cellId){
//todo из этой функции хотелось бы убрать getNextNode, тогда можно будет убрать getSlaveEdgesIndexes
function getFirstNode(sheetId,cellId) { var stack = [], n = this.getFirstNode(sheetId,cellId), __t = true, next, badResS = [], resultS = [];
var n = new Vertex(sheetId,cellId,thas.wb);
if ( !nodes[n.nodeId] ){
var a = [];
for( var id in areaNodes ){
if( areaNodes[id].containCell(n) )
a.push(areaNodes[id])
}
if( a.length > 0 ){
for( var i in a ){
n.addSlaveEdge( a[i] );
}
n.valid = false;
return n;
}
else{
return undefined;
}
}
else
return nodes[n.nodeId];
}
function getNextNode(node) {
if(node){
for (var id in node.masterEdges){
var n = nodes[id];
if (n !== undefined){
if ((n.isBlack === undefined || !n.isBlack) && !n.isBad) {
return n;
}
}
else {
delete node.masterEdges[id];
}
}
}
return undefined;
}
var stack = [], n = getFirstNode(sheetId,cellId), __t = true, next, badResS = [], resultS = [];
if( !n ){ if( !n ){
return {depF: resultS, badF: badResS} return {depF: resultS, badF: badResS}
} }
//предполагаем что masterEdges не меняется в цикле
var oIndexObj = {cur: 0, indexes: n.getMasterEdgesIndexes()};
var oIndexMap = {};
oIndexMap[n.nodeId] = oIndexObj;
while (1) { while (1) {
if( n ){ if( n ){
if ( n.isGray && !n.isArea ){ if ( n.isGray && !n.isArea ){
...@@ -429,19 +454,29 @@ function DependencyGraph(wb) { ...@@ -429,19 +454,29 @@ function DependencyGraph(wb) {
} }
} }
if( n.valid && !n.isArea ){ if( n.valid && !n.isArea ){
for( var id in areaNodes ){ var oGetRes = this.getNode4(n);
if( areaNodes[id].containCell(n) ){ if(oGetRes.contains)
areaNodes[id].addMasterEdge(n); {
n.addSlaveEdge(areaNodes[id]); for(var i = 0, length = oGetRes.contains.length; i < length; i++)
{
var nodeSlave = oGetRes.contains[i];
nodeSlave.addMasterEdge(n);
n.addSlaveEdge(nodeSlave);
} }
} }
n.valid = false; n.valid = false;
} }
next = getNextNode(n); next = this.getNextNode(n, n.masterEdges, oIndexObj);
if (next !== undefined) { if (next !== undefined) {
n.isGray = true; n.isGray = true;
stack.push(n); stack.push(n);
n = next; n = next;
oIndexObj = oIndexMap[n.nodeId];
if(!oIndexObj)
{
oIndexObj = {cur: 0, indexes: n.getMasterEdgesIndexes()};
oIndexMap[n.nodeId] = oIndexObj;
}
} }
else { else {
n.isBlack = true; n.isBlack = true;
...@@ -450,6 +485,12 @@ function DependencyGraph(wb) { ...@@ -450,6 +485,12 @@ function DependencyGraph(wb) {
if (stack.length < 1) if (stack.length < 1)
break; break;
n = stack.pop(); n = stack.pop();
oIndexObj = oIndexMap[n.nodeId];
if(!oIndexObj)
{
oIndexObj = {cur: 0, indexes: n.getMasterEdgesIndexes()};
oIndexMap[n.nodeId] = oIndexObj;
}
n.isGray = false; n.isGray = false;
} }
} }
...@@ -470,35 +511,23 @@ function DependencyGraph(wb) { ...@@ -470,35 +511,23 @@ function DependencyGraph(wb) {
//сортировка всего графа по всем вершинам. //сортировка всего графа по всем вершинам.
this.t_sort = function() { this.t_sort = function() {
var stack = [],n = null,__t = true, next;
for(var i in nodes){ for(var i in nodes)
nodes[i].isBlack = false; {
nodes[i].isBad = false; var nodesSheet = nodes[i];
nodes[i].isGray = false; var aNodes = nodesSheet.getAll();
} for(var j = 0, length2 = aNodes.length; j < length2; j++)
{
function getFirstNode() { var node = aNodes[j].data;
return nodes[nodesfirst]; if(null == n)
} n = node;
node.isBlack = false;
function getNextNode(node) { node.isBad = false;
for (var id in node.masterEdges){ node.isGray = false;
var n = nodes[id];
if (n !== undefined){
if ((n.isBlack === undefined || !n.isBlack) && !n.isBad) {
return n;
}
}
else {
delete node.masterEdges[id];
}
} }
return undefined;
} }
var stack = [], var oIndexObj = this.getNextNodeIndexes(n.masterEdges);
n = getFirstNode(),__t = true,
next;
while (1) { while (1) {
if ( n.isGray ){ if ( n.isGray ){
for( var i = stack.length-1; i>=0;i--){ for( var i = stack.length-1; i>=0;i--){
...@@ -510,14 +539,17 @@ function DependencyGraph(wb) { ...@@ -510,14 +539,17 @@ function DependencyGraph(wb) {
} }
if (stack.length < 1) { if (stack.length < 1) {
for (var id in __nodes){ for (var id in __nodes){
if( nodes[id] !== undefined && ((nodes[id].isBlack === undefined || !nodes[id].isBlack) && !nodes[id].isBad) ){ var temp = __nodes[id];
n = nodes[id]; var nodeTemp = thas.getNode3(temp);
if(nodeTemp && ((nodeTemp.isBlack === undefined || !nodeTemp.isBlack) && !nodeTemp.isBad) )
{
n = nodeTemp;
delete __nodes[id]; delete __nodes[id];
} }
} }
} }
} }
next = getNextNode(n); next = this.getNextNode(n, n.masterEdges, oIndexObj);
if (next !== undefined) { if (next !== undefined) {
n.isGray = true; n.isGray = true;
stack.push(n); stack.push(n);
...@@ -530,15 +562,17 @@ function DependencyGraph(wb) { ...@@ -530,15 +562,17 @@ function DependencyGraph(wb) {
if (stack.length < 1) { if (stack.length < 1) {
n = undefined; n = undefined;
for (var id in __nodes){ for (var id in __nodes){
if( nodes[id] !== undefined && ((nodes[id].isBlack === undefined || !nodes[id].isBlack) && !nodes[id].isBad) ){ var temp = __nodes[id];
n = nodes[id]; var nodeTemp = thas.getNode3(temp);
if(nodeTemp && ((nodeTemp.isBlack === undefined || !nodeTemp.isBlack) && !nodeTemp.isBad) )
{
n = nodeTemp;
delete __nodes[id]; delete __nodes[id];
break; break;
} }
else{ else
delete __nodes[id]; delete __nodes[id];
} }
}
if (n) if (n)
continue; continue;
else break; else break;
...@@ -552,10 +586,6 @@ function DependencyGraph(wb) { ...@@ -552,10 +586,6 @@ function DependencyGraph(wb) {
} }
this.returnNode = function(){
return nodes;
}
this.getNodesLength = function(){ this.getNodesLength = function(){
return nodeslength; return nodeslength;
} }
...@@ -566,12 +596,14 @@ function DependencyGraph(wb) { ...@@ -566,12 +596,14 @@ function DependencyGraph(wb) {
this.checkOffset = function(BBox, offset, wsId, noDelete){ this.checkOffset = function(BBox, offset, wsId, noDelete){
var move = {}, stretch = {}, recalc = {}; var move = {}, stretch = {}, recalc = {};
for( var id in nodes ){ var nodesSheet = nodes[wsId];
if( nodes[id].sheetId != wsId ) if(nodesSheet){
continue; var aNodes = nodesSheet.getAll();
var n = { r1:nodes[id].firstCellAddress.getRow0(), c1:nodes[id].firstCellAddress.getCol0(), for( var i = 0, length = aNodes.length; i < length; i++){
r2:nodes[id].lastCellAddress.getRow0(), c2:nodes[id].lastCellAddress.getCol0() } var node = aNodes[i].data;
if( nodes[id].isArea ){ var id = node.nodeId;
var n = node.getBBox();
if( node.isArea ){
/* /*
Есть 2 области. Первая - это диапазон, что участвует в формуле, второй - это который удаляют/вставляют. Нужно определить положение двух этих областей относительно друг друга. Есть 2 области. Первая - это диапазон, что участвует в формуле, второй - это который удаляют/вставляют. Нужно определить положение двух этих областей относительно друг друга.
Если вторая область находится ( ( выше и левее ) или правее или ниже ) первой, такая область нас не интересуею. Она не повлияет на сдвиг диапазона. Если вторая область находится ( ( выше и левее ) или правее или ниже ) первой, такая область нас не интересуею. Она не повлияет на сдвиг диапазона.
...@@ -601,42 +633,42 @@ function DependencyGraph(wb) { ...@@ -601,42 +633,42 @@ function DependencyGraph(wb) {
else{ else{
if( BBox1.r2 < n1.r1 ) continue; if( BBox1.r2 < n1.r1 ) continue;
else if( BBox1.r2 < n1.r2 || BBox1.r1 > n1.r1 ){ else if( BBox1.r2 < n1.r2 || BBox1.r1 > n1.r1 ){
recalc[id] = nodes[id]; recalc[id] = node;
} }
else{ else{
if( offset.offsetCol > 0 ){ if( offset.offsetCol > 0 ){
if( BBox1.r1 <= n1.r1 && BBox1.r2 >= n1.r2){ if( BBox1.r1 <= n1.r1 && BBox1.r2 >= n1.r2){
if( BBox1.c2 <= n1.c2 && BBox1.c1 <= n1.c1 || BBox1.c1 == n1.c1 && BBox1.c2 > n1.c2 ) if( BBox1.c2 <= n1.c2 && BBox1.c1 <= n1.c1 || BBox1.c1 == n1.c1 && BBox1.c2 > n1.c2 )
move[id] = { node : nodes[id], offset : offset }; move[id] = { node : node, offset : offset };
else if( BBox1.c1 > n1.c1 && BBox1.c1 <= n1.c2 ){ else if( BBox1.c1 > n1.c1 && BBox1.c1 <= n1.c2 ){
stretch[id] = { node : nodes[id], offset : offset }; stretch[id] = { node : node, offset : offset };
} }
} }
} }
else{ else{
if( BBox1.r1 <= n1.r1 && BBox1.r2 >= n1.r2){ if( BBox1.r1 <= n1.r1 && BBox1.r2 >= n1.r2){
if( BBox1.c2 < n1.c1 ){ if( BBox1.c2 < n1.c1 ){
move[id] = { node : nodes[id], offset : offset }; move[id] = { node : node, offset : offset };
} }
else if( BBox1.c2 >= n1.c1 && BBox1.c1 <= n1.c1 ){ else if( BBox1.c2 >= n1.c1 && BBox1.c1 <= n1.c1 ){
if( n1.r1 >= BBox1.r1 && n1.r2 <= BBox1.r2 && n1.c1 >= BBox1.c1 && n1.c2 <= BBox1.c2 ){ if( n1.r1 >= BBox1.r1 && n1.r2 <= BBox1.r2 && n1.c1 >= BBox1.c1 && n1.c2 <= BBox1.c2 ){
move[id] = { node : nodes[id], offset : offset , toDelete: !noDelete }; move[id] = { node : node, offset : offset , toDelete: !noDelete };
recalc[id] = nodes[id]; recalc[id] = node;
} }
else{ else{
move[id] = { node : nodes[id], offset : { offsetCol : -Math.abs(n1.c1-BBox1.c1), offsetRow: offset.offsetRow } }; move[id] = { node : node, offset : { offsetCol : -Math.abs(n1.c1-BBox1.c1), offsetRow: offset.offsetRow } };
stretch[id] = { node : nodes[id], offset : { offsetCol : -Math.abs(n1.c1-BBox1.c2)-1, offsetRow: offset.offsetRow } }; stretch[id] = { node : node, offset : { offsetCol : -Math.abs(n1.c1-BBox1.c2)-1, offsetRow: offset.offsetRow } };
recalc[id] = nodes[id]; recalc[id] = node;
} }
} }
else if( BBox1.c1 > n1.c1 && BBox1.c1 <= n1.c2 || BBox1.c1 == n1.c1 && BBox1.c2 >= n1.c1 ){ else if( BBox1.c1 > n1.c1 && BBox1.c1 <= n1.c2 || BBox1.c1 == n1.c1 && BBox1.c2 >= n1.c1 ){
if( BBox1.c2 > n1.c2 ){ if( BBox1.c2 > n1.c2 ){
stretch[id] = { node : nodes[id], offset : { offsetCol : -Math.abs(n1.c2-BBox1.c1)-1, offsetRow: offset.offsetRow } }; stretch[id] = { node : node, offset : { offsetCol : -Math.abs(n1.c2-BBox1.c1)-1, offsetRow: offset.offsetRow } };
recalc[id] = nodes[id]; recalc[id] = node;
} }
else{ else{
stretch[id] = { node : nodes[id], offset : offset }; stretch[id] = { node : node, offset : offset };
recalc[id] = nodes[id]; recalc[id] = node;
} }
} }
} }
...@@ -648,42 +680,42 @@ function DependencyGraph(wb) { ...@@ -648,42 +680,42 @@ function DependencyGraph(wb) {
else{ else{
if( BBox1.c2 < n1.c1 ) continue; if( BBox1.c2 < n1.c1 ) continue;
else if( BBox1.c2 < n1.c2 || BBox1.c1 > n1.c1 ){ else if( BBox1.c2 < n1.c2 || BBox1.c1 > n1.c1 ){
recalc[id] = nodes[id]; recalc[id] = node;
} }
else{ else{
if( offset.offsetRow > 0 ){ if( offset.offsetRow > 0 ){
if( BBox1.c1 <= n1.c1 && BBox1.c2 >= n1.c2){ if( BBox1.c1 <= n1.c1 && BBox1.c2 >= n1.c2){
if( BBox1.r2 <= n1.r2 && BBox1.r1 <= n1.r1 || BBox1.r1 == n1.r1 && BBox1.r2 > n1.r2 ) if( BBox1.r2 <= n1.r2 && BBox1.r1 <= n1.r1 || BBox1.r1 == n1.r1 && BBox1.r2 > n1.r2 )
move[id] = { node : nodes[id], offset : offset }; move[id] = { node : node, offset : offset };
else if( BBox1.r1 > n1.r1 && BBox1.r1 <= n1.r2 ){ else if( BBox1.r1 > n1.r1 && BBox1.r1 <= n1.r2 ){
stretch[id] = { node : nodes[id], offset : offset }; stretch[id] = { node : node, offset : offset };
} }
} }
} }
else{ else{
if( BBox1.c1 <= n1.c1 && BBox1.c2 >= n1.c2){ if( BBox1.c1 <= n1.c1 && BBox1.c2 >= n1.c2){
if( BBox1.r2 < n1.r1 ){ if( BBox1.r2 < n1.r1 ){
move[id] = { node : nodes[id], offset : offset }; move[id] = { node : node, offset : offset };
} }
else if( BBox1.r2 >= n1.r1 && BBox1.r1 <= n1.r1 ){ else if( BBox1.r2 >= n1.r1 && BBox1.r1 <= n1.r1 ){
if( n1.r1 >= BBox1.r1 && n1.r2 <= BBox1.r2 && n1.c1 >= BBox1.c1 && n1.c2 <= BBox1.c2 ){ if( n1.r1 >= BBox1.r1 && n1.r2 <= BBox1.r2 && n1.c1 >= BBox1.c1 && n1.c2 <= BBox1.c2 ){
move[id] = { node : nodes[id], offset : offset , toDelete: !noDelete }; move[id] = { node : node, offset : offset , toDelete: !noDelete };
recalc[id] = nodes[id]; recalc[id] = node;
} }
else{ else{
move[id] = { node : nodes[id], offset : { offsetRow : -Math.abs(n1.r1-BBox1.r1), offsetCol: offset.offsetCol } }; move[id] = { node : node, offset : { offsetRow : -Math.abs(n1.r1-BBox1.r1), offsetCol: offset.offsetCol } };
stretch[id] = { node : nodes[id], offset : { offsetRow : -Math.abs(n1.r1-BBox1.r2)-1, offsetCol: offset.offsetCol } }; stretch[id] = { node : node, offset : { offsetRow : -Math.abs(n1.r1-BBox1.r2)-1, offsetCol: offset.offsetCol } };
recalc[id] = nodes[id]; recalc[id] = node;
} }
} }
else if( BBox1.r1 > n1.r1 && BBox1.r1 <= n1.r2 || BBox1.r1 == n1.r1 && BBox1.r2 >= n1.r1 ){ else if( BBox1.r1 > n1.r1 && BBox1.r1 <= n1.r2 || BBox1.r1 == n1.r1 && BBox1.r2 >= n1.r1 ){
if( BBox1.r2 > n1.r2 ){ if( BBox1.r2 > n1.r2 ){
stretch[id] = { node : nodes[id], offset : { offsetRow : -Math.abs(n1.r2-BBox1.r1)-1, offsetCol: offset.offsetCol } }; stretch[id] = { node : node, offset : { offsetRow : -Math.abs(n1.r2-BBox1.r1)-1, offsetCol: offset.offsetCol } };
recalc[id] = nodes[id]; recalc[id] = node;
} }
else{ else{
stretch[id] = { node : nodes[id], offset : offset }; stretch[id] = { node : node, offset : offset };
recalc[id] = nodes[id]; recalc[id] = node;
} }
} }
} }
...@@ -698,10 +730,11 @@ function DependencyGraph(wb) { ...@@ -698,10 +730,11 @@ function DependencyGraph(wb) {
( n.c1 >= BBox.c1 && n.c1 <= BBox.c2 && n.r1 >= BBox.r2 && offset.offsetRow != 0 ) || ( n.c1 >= BBox.c1 && n.c1 <= BBox.c2 && n.r1 >= BBox.r2 && offset.offsetRow != 0 ) ||
( n.r1 >= BBox.r1 && n.r2 <= BBox.r2 && n.c1 >= BBox.c1 && n.c2 <= BBox.c2 ) ) ( n.r1 >= BBox.r1 && n.r2 <= BBox.r2 && n.c1 >= BBox.c1 && n.c2 <= BBox.c2 ) )
{ {
move[id] = { node : nodes[id], offset : offset , toDelete: false }; move[id] = { node : node, offset : offset , toDelete: false };
if( n.r1 >= BBox.r1 && n.r2 <= BBox.r2 && n.c1 >= BBox.c1 && n.c2 <= BBox.c2 && !noDelete && ( offset.offsetCol < 0 || offset.offsetRow < 0 ) ){ if( n.r1 >= BBox.r1 && n.r2 <= BBox.r2 && n.c1 >= BBox.c1 && n.c2 <= BBox.c2 && !noDelete && ( offset.offsetCol < 0 || offset.offsetRow < 0 ) ){
move[id].toDelete = true; move[id].toDelete = true;
recalc[id] = nodes[id]; recalc[id] = node;
}
} }
} }
} }
...@@ -716,37 +749,39 @@ function DependencyGraph(wb) { ...@@ -716,37 +749,39 @@ function DependencyGraph(wb) {
n = new Vertex(range.getWorksheet().getId(),range.getName()); n = new Vertex(range.getWorksheet().getId(),range.getName());
if( n.isArea ){ if( n.isArea ){
if( n.nodeId in nodes ){ var node = this.getNode3(n);
move[n.nodeId] = nodes[n.nodeId]; if( null != node ){
move[n.nodeId] = node;
} }
else{ else{
for( var id2 in areaNodes ){ var nodesSheet = nodes[n.sheetId];
if( n.containCell(areaNodes[id2]) ){ if(nodesSheet)
move[areaNodes[id2].nodeId] = nodes[areaNodes[id2].nodeId]; {
} var oGetRes = nodesSheet.get(n.getBBox());
} for(var i = 0, length = oGetRes.inner.length; i < length; i++)
{
range = range.getCells(); var elem = oGetRes.inner[i].data;
for( var id in range ){ move[elem.nodeId] = elem;
n = new Vertex(wsId,range[id].getName());
if( n.nodeId in nodes ){
move[n.nodeId] = nodes[n.nodeId];
}
for( var id2 in areaNodes ){
if( areaNodes[id2].containCell(n) ){
recalc[id2] = areaNodes[id2];
} }
for(var i = 0, length = oGetRes.outer.length; i < length; i++)
{
var elem = oGetRes.outer[i].data;
if(elem.isArea)
recalc[elem.nodeId] = elem;
} }
} }
} }
} }
else { else {
if( n.nodeId in nodes ){ var oGetRes = this.getNode4(n);
move[n.nodeId] = nodes[n.nodeId]; if(oGetRes.exist)
} move[n.nodeId] = oGetRes.exist;
for( var id in areaNodes ){ if(oGetRes.contains)
if( areaNodes[id].containCell(n) ){ {
recalc[id] = areaNodes[id]; for(var i = 0, length = oGetRes.contains.length; i < length; i++)
{
var elem = oGetRes.contains[i];
recalc[elem.nodeid] = elem;
} }
} }
} }
...@@ -922,9 +957,13 @@ function DependencyGraph(wb) { ...@@ -922,9 +957,13 @@ function DependencyGraph(wb) {
var arr = false; var arr = false;
this.wb.needRecalc = []; this.wb.needRecalc = [];
this.wb.needRecalc.length = 0; this.wb.needRecalc.length = 0;
for(var id in nodes){ var nodesSheet = nodes[sheetId];
if(nodes[id].sheetId == sheetId){ if(nodesSheet){
var se = nodes[id].getSlaveEdges(); var aNodes = nodesSheet.getAll();
for(var i = 0, length = aNodes.length; i < length; i++)
{
var node = aNodes[i].data;
var se = node.getSlaveEdges();
for(var id2 in se){ for(var id2 in se){
if(se[id2].sheetId != sheetId){ if(se[id2].sheetId != sheetId){
if(!arr) arr = true; if(!arr) arr = true;
...@@ -933,12 +972,12 @@ function DependencyGraph(wb) { ...@@ -933,12 +972,12 @@ function DependencyGraph(wb) {
// arr.push(se[id2]); // arr.push(se[id2]);
} }
} }
nodes[id].deleteAllMasterEdges(); node.deleteAllMasterEdges();
nodes[id].deleteAllSlaveEdges(); node.deleteAllSlaveEdges();
nodes[id] = null; delete nodesId[node.nodeId];
delete nodes[id];
nodeslength--; nodeslength--;
} }
nodesSheet.removeAll();
} }
return arr; return arr;
} }
...@@ -1005,11 +1044,15 @@ function Vertex(sheetId,cellId,wb){ ...@@ -1005,11 +1044,15 @@ function Vertex(sheetId,cellId,wb){
//masterEdges содержит ячейки, от которых зависит текущая ячейка //masterEdges содержит ячейки, от которых зависит текущая ячейка
this.masterEdges = null; this.masterEdges = null;
//masterEdgesIndexes - массив индексов masterEdges, чтобы можно было быстро делать getNext для masterEdges
this.masterEdgesIndexes = null;
this.helpMasterEdges = {}; this.helpMasterEdges = {};
//slaveEdges содержит ячейки, которые зависят от данной ячейки //slaveEdges содержит ячейки, которые зависят от данной ячейки
this.slaveEdges = null; this.slaveEdges = null;
//slaveEdgesIndexes - массив индексов masterEdges, чтобы можно было быстро делать getNext для slaveEdges
this.slaveEdgesIndexes = null;
this.refCount = 0; this.refCount = 0;
...@@ -1019,6 +1062,11 @@ Vertex.prototype = { ...@@ -1019,6 +1062,11 @@ Vertex.prototype = {
constructor: Vertex, constructor: Vertex,
getBBox : function()
{
return new Asc.Range(this.firstCellAddress.getCol0(), this.firstCellAddress.getRow0(), this.lastCellAddress.getCol0(), this.lastCellAddress.getRow0());
},
changeCellId : function(cellId){ changeCellId : function(cellId){
var lastId = this.nodeId; var lastId = this.nodeId;
this.cellId = cellId; this.cellId = cellId;
...@@ -1028,6 +1076,7 @@ Vertex.prototype = { ...@@ -1028,6 +1076,7 @@ Vertex.prototype = {
this.masterEdges[id].slaveEdges[this.nodeId] = this.masterEdges[id].slaveEdges[lastId]; this.masterEdges[id].slaveEdges[this.nodeId] = this.masterEdges[id].slaveEdges[lastId];
this.masterEdges[id].slaveEdges[lastId] = null; this.masterEdges[id].slaveEdges[lastId] = null;
delete this.masterEdges[id].slaveEdges[lastId]; delete this.masterEdges[id].slaveEdges[lastId];
this.masterEdges[id].slaveEdgesIndexes = null;
} }
} }
for( var id in this.slaveEdges ){ for( var id in this.slaveEdges ){
...@@ -1035,6 +1084,7 @@ Vertex.prototype = { ...@@ -1035,6 +1084,7 @@ Vertex.prototype = {
this.slaveEdges[id].masterEdges[this.nodeId] = this.slaveEdges[id].masterEdges[lastId]; this.slaveEdges[id].masterEdges[this.nodeId] = this.slaveEdges[id].masterEdges[lastId];
this.slaveEdges[id].masterEdges[lastId] = null; this.slaveEdges[id].masterEdges[lastId] = null;
delete this.slaveEdges[id].masterEdges[lastId]; delete this.slaveEdges[id].masterEdges[lastId];
this.slaveEdges[id].masterEdgesIndexes = null;
} }
} }
}, },
...@@ -1045,6 +1095,7 @@ Vertex.prototype = { ...@@ -1045,6 +1095,7 @@ Vertex.prototype = {
this.masterEdges = {}; this.masterEdges = {};
this.masterEdges[node.nodeId] = node; this.masterEdges[node.nodeId] = node;
this.refCount ++; this.refCount ++;
this.masterEdgesIndexes = null;
}, },
addHelpMasterEdge : function(node){ addHelpMasterEdge : function(node){
...@@ -1057,11 +1108,21 @@ Vertex.prototype = { ...@@ -1057,11 +1108,21 @@ Vertex.prototype = {
this.slaveEdges = {}; this.slaveEdges = {};
this.slaveEdges[node.nodeId] = node; this.slaveEdges[node.nodeId] = node;
this.refCount ++; this.refCount ++;
this.slaveEdgesIndexes = null;
}, },
getMasterEdges : function(){ getMasterEdges : function(){
return this.masterEdges; return this.masterEdges;
}, },
getMasterEdgesIndexes : function(){
if(null == this.masterEdgesIndexes)
{
this.masterEdgesIndexes = [];
for(var i in this.masterEdges)
this.masterEdgesIndexes.push(i);
}
return this.masterEdgesIndexes;
},
getHelpMasterEdges : function(){ getHelpMasterEdges : function(){
return this.helpMasterEdges; return this.helpMasterEdges;
...@@ -1071,6 +1132,16 @@ Vertex.prototype = { ...@@ -1071,6 +1132,16 @@ Vertex.prototype = {
return this.slaveEdges; return this.slaveEdges;
}, },
getSlaveEdgesIndexes : function(){
if(null == this.slaveEdgesIndexes)
{
this.slaveEdgesIndexes = [];
for(var i in this.slaveEdges)
this.slaveEdgesIndexes.push(i);
}
return this.slaveEdgesIndexes;
},
getSlaveEdges2 : function(){ getSlaveEdges2 : function(){
var ret = {}, count = 0; var ret = {}, count = 0;
for(var id in this.slaveEdges){ for(var id in this.slaveEdges){
...@@ -1088,6 +1159,7 @@ Vertex.prototype = { ...@@ -1088,6 +1159,7 @@ Vertex.prototype = {
this.masterEdges[node.nodeId] = null; this.masterEdges[node.nodeId] = null;
delete this.masterEdges[node.nodeId]; delete this.masterEdges[node.nodeId];
this.refCount--; this.refCount--;
this.masterEdgesIndexes = null;
}, },
deleteHelpMasterEdge : function(node){ deleteHelpMasterEdge : function(node){
...@@ -1099,19 +1171,22 @@ Vertex.prototype = { ...@@ -1099,19 +1171,22 @@ Vertex.prototype = {
this.slaveEdges[node.nodeId] = null; this.slaveEdges[node.nodeId] = null;
delete this.slaveEdges[node.nodeId]; delete this.slaveEdges[node.nodeId];
this.refCount--; this.refCount--;
this.slaveEdgesIndexes = null;
}, },
//очищаем все ребра по ведущим ячейкам. //очищаем все ребра по ведущим ячейкам.
deleteAllMasterEdges : function(){ deleteAllMasterEdges : function(){
var ret = []; var ret = {};
for( var id in this.masterEdges ){ for( var id in this.masterEdges ){
this.masterEdges[id].deleteSlaveEdge(this); var masterEdge = this.masterEdges[id];
masterEdge.deleteSlaveEdge(this);
this.masterEdges[id] = null; this.masterEdges[id] = null;
delete this.masterEdges[id]; delete this.masterEdges[id];
this.refCount--; this.refCount--;
ret.push(id); ret[id] = masterEdge;
} }
this.masterEdges = null; this.masterEdges = null;
this.masterEdgesIndexes = null;
return ret; return ret;
}, },
...@@ -1126,6 +1201,7 @@ Vertex.prototype = { ...@@ -1126,6 +1201,7 @@ Vertex.prototype = {
ret.push(id); ret.push(id);
} }
this.slaveEdges = null; this.slaveEdges = null;
this.slaveEdgesIndexes = null;
return ret; return ret;
}, },
......
...@@ -3677,6 +3677,21 @@ RangeDataManager.prototype = { ...@@ -3677,6 +3677,21 @@ RangeDataManager.prototype = {
} }
return oRes; return oRes;
}, },
getExact : function(bbox)
{
var oRes = null;
var oGet = this.get(bbox);
for(var i = 0, length = oGet.inner.length; i < length; i++)
{
var elem = oGet.inner[i];
if(elem.bbox.isEqual(bbox))
{
oRes = elem;
break;
}
}
return oRes;
},
_getByCell : function(nRow, nCol) _getByCell : function(nRow, nCol)
{ {
var oRes = null; var oRes = null;
...@@ -3737,6 +3752,11 @@ RangeDataManager.prototype = { ...@@ -3737,6 +3752,11 @@ RangeDataManager.prototype = {
this.fChange.call(this, elemToDelete.data, elemToDelete.bbox, null); this.fChange.call(this, elemToDelete.data, elemToDelete.bbox, null);
} }
}, },
removeAll : function()
{
//todo fChange
this.oIntervalTreeRB = new IntervalTreeRB();
},
shiftGet : function(bbox, bHor) shiftGet : function(bbox, bHor)
{ {
var bboxGet = null; var bboxGet = null;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment