Skip to content

Commit

Permalink
Don't update minimap when it is hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
drasmuss committed Feb 8, 2016
1 parent 4567c3d commit b94c9a8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 29 deletions.
72 changes: 44 additions & 28 deletions nengo_gui/static/components/netgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,27 +319,33 @@ Nengo.NetGraph.prototype.on_message = function(event) {
} else if (data.type === 'expand') {
var item = this.svg_objects[data.uid];
item.expand(true,true)

var item_mini = this.minimap_objects[data.uid];
item_mini.expand(true,true)

if (this.mm_display) {
var item_mini = this.minimap_objects[data.uid];
item_mini.expand(true,true)
}

} else if (data.type === 'collapse') {
var item = this.svg_objects[data.uid];
item.collapse(true,true)

var item_mini = this.minimap_objects[data.uid];
item_mini.collapse(true,true)
if (this.mm_display) {
var item_mini = this.minimap_objects[data.uid];
item_mini.collapse(true,true)
}

} else if (data.type === 'pos_size') {
var item = this.svg_objects[data.uid];
item.set_position(data.pos[0], data.pos[1]);
item.set_size(data.size[0], data.size[1]);

var item = this.minimap_objects[data.uid];
item.set_position(data.pos[0], data.pos[1]);
item.set_size(data.size[0], data.size[1]);

this.scaleMiniMap();
if (this.mm_display) {
var item = this.minimap_objects[data.uid];
item.set_position(data.pos[0], data.pos[1]);
item.set_size(data.size[0], data.size[1]);

this.scaleMiniMap();
}

} else if (data.type === 'config') {
// Anything about the config of a component has changed
Expand All @@ -363,11 +369,13 @@ Nengo.NetGraph.prototype.on_message = function(event) {
}
item.remove();

var item_mini = this.minimap_objects[data.uid];
if (item_mini === undefined) {
item_mini = this.minimap_conns[data.uid];
if (this.mm_display) {
var item_mini = this.minimap_objects[data.uid];
if (item_mini === undefined) {
item_mini = this.minimap_conns[data.uid];
}
item_mini.remove();
}
item_mini.remove();

} else if (data.type === 'reconnect') {
var conn = this.svg_conns[data.uid];
Expand All @@ -376,10 +384,12 @@ Nengo.NetGraph.prototype.on_message = function(event) {
conn.set_recurrent(data.pres[0] === data.posts[0]);
conn.redraw();

var conn_mini = this.minimap_conns[data.uid];
conn_mini.set_pres(data.pres);
conn_mini.set_posts(data.posts);
conn_mini.redraw();
if (this.mm_display) {
var conn_mini = this.minimap_conns[data.uid];
conn_mini.set_pres(data.pres);
conn_mini.set_posts(data.posts);
conn_mini.redraw();
}

} else if (data.type === 'delete_graph') {
var uid = data.uid;
Expand Down Expand Up @@ -427,14 +437,18 @@ Nengo.NetGraph.prototype.redraw = function() {
this.svg_objects[key].redraw_position();
this.svg_objects[key].redraw_size();

this.minimap_objects[key].pos = this.svg_objects[key].pos
this.minimap_objects[key].size = this.svg_objects[key].size
this.minimap_objects[key].redraw_position();
this.minimap_objects[key].redraw_size();
if (this.mm_display) {
this.minimap_objects[key].pos = this.svg_objects[key].pos
this.minimap_objects[key].size = this.svg_objects[key].size
this.minimap_objects[key].redraw_position();
this.minimap_objects[key].redraw_size();
}
}
for (var key in this.svg_conns) {
this.svg_conns[key].redraw();
this.minimap_conns[key].redraw();
if (this.mm_display) {
this.minimap_conns[key].redraw();
}
}
}

Expand Down Expand Up @@ -519,11 +533,13 @@ Nengo.NetGraph.prototype.toggle_network = function(uid) {
item.expand();
}

var item_mini = this.minimap_objects[uid];
if (item_mini.expanded) {
item_mini.collapse(true);
} else {
item_mini.expand();
if (this.mm_display) {
var item_mini = this.minimap_objects[uid];
if (item_mini.expanded) {
item_mini.collapse(true);
} else {
item_mini.expand();
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion nengo_gui/static/components/netgraph_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,11 +745,12 @@ Nengo.NetGraphItem.prototype.redraw_size = function() {
};

Nengo.NetGraphItem.prototype.get_width = function() {
if (this.minimap && !this.ng.mm_display) { return 1; }

if (this.fixed_width !== null) {
return this.fixed_width;
}


if (this.minimap == false) {
var w = $(this.ng.svg).width();
var screen_w = this.get_nested_width() * w * this.ng.scale;
Expand All @@ -766,6 +767,8 @@ Nengo.NetGraphItem.prototype.get_width = function() {
}

Nengo.NetGraphItem.prototype.get_height = function() {
if (this.minimap && !this.ng.mm_display) { return 1; }

if (this.fixed_height !== null) {
return this.fixed_height;
}
Expand Down Expand Up @@ -796,6 +799,8 @@ Nengo.NetGraphItem.prototype.redraw = function() {
/** determine the pixel location of the centre of the item */
Nengo.NetGraphItem.prototype.get_screen_location = function() {
// FIXME this should probably use this.ng.get_scaled_width and this.ng.get_scaled_height
if (this.minimap && !this.ng.mm_display) { return [1, 1]; }

if (this.minimap == false) {
var w = $(this.ng.svg).width() * this.ng.scale;
var h = $(this.ng.svg).height() * this.ng.scale;
Expand Down

0 comments on commit b94c9a8

Please sign in to comment.