diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer2.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer2.js index 0261f89766..dcb9d39790 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer2.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer2.js @@ -1100,6 +1100,9 @@ var existingNodes = this.currentGraph.graph.nodes(); var found; + var newNodeCounter = 0; + var newEdgeCounter = 0; + _.each(newNodes, function (newNode) { found = false; _.each(existingNodes, function (existingNode) { @@ -1118,22 +1121,58 @@ if (found === false) { newNode.originalColor = newNode.color; self.currentGraph.graph.addNode(newNode); + newNodeCounter++; _.each(newEdges, function (edge) { if (edge.source === newNode.id || edge.target === newNode.id) { edge.originalColor = edge.color; self.currentGraph.graph.addEdge(edge); + newEdgeCounter++; } }); - - self.startLayout(true); } - - // rerender graph - self.currentGraph.refresh(); }); + + $('#nodesCount').text(parseInt($('#nodesCount').text()) + newNodeCounter); + $('#edgesCount').text(parseInt($('#edgesCount').text()) + newEdgeCounter); + + // rerender graph + if (newNodeCounter > 0 || newEdgeCounter > 0) { + if (self.algorithm === 'force') { + self.startLayout(true, origin); + } else if (self.algorithm === 'fruchtermann') { + sigma.layouts.fruchtermanReingold.start(self.currentGraph); + self.currentGraph.refresh(); + // self.cameraToNode(origin); + } else if (self.algorithm === 'noverlap') { + self.startLayout(true, origin); // tmp bugfix, rerender with noverlap currently not possible + // self.currentGraph.startNoverlap(); + } + } }, + /* + cameraToNode: function (node) { + var self = this; + console.log(node); + + self.currentGraph.cameras[0].goTo({ + x: node['read_cam0:x'], + y: node['read_cam0:y'] + }); + /* + sigma.misc.animation.camera( + self.currentGraph.camera, + { + x: node[self.currentGraph.camera.readPrefix + 'x'], + y: node[self.currentGraph.camera.readPrefix + 'y'], + ratio: 1 + }, + {duration: self.currentGraph.settings('animationsTime') || 300} + ); + }, + */ + drawLine: function (e) { var context = window.App.graphViewer2.contextState; @@ -1277,8 +1316,8 @@ $(this.el).append( '