1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Minimise filtering of nodes on redraw

This commit is contained in:
Nick O'Leary 2015-03-12 11:21:05 +00:00
parent ab3e64271b
commit eacf41a4f6
5 changed files with 52 additions and 25 deletions

View File

@ -192,7 +192,7 @@ RED.history = (function() {
}
}
RED.view.dirty(ev.dirty);
RED.view.redraw();
RED.view.redraw(true);
RED.palette.refresh();
}
}

View File

@ -169,7 +169,7 @@ var RED = (function() {
success: function(nodes) {
RED.nodes.import(nodes);
RED.view.dirty(false);
RED.view.redraw();
RED.view.redraw(true);
RED.comms.subscribe("status/#",function(topic,msg) {
var parts = topic.split("/");
var node = RED.nodes.node(parts[1]);
@ -359,21 +359,6 @@ var RED = (function() {
RED.subflow.init();
RED.view.init();
RED.view.on("selection-changed",function(selection) {
if (!selection.nodes) {
RED.menu.setDisabled("btn-export-menu",true);
RED.menu.setDisabled("btn-export-clipboard",true);
RED.menu.setDisabled("btn-export-library",true);
RED.menu.setDisabled("btn-convert-subflow",true);
} else {
RED.menu.setDisabled("btn-export-menu",false);
RED.menu.setDisabled("btn-export-clipboard",false);
RED.menu.setDisabled("btn-export-library",false);
RED.menu.setDisabled("btn-convert-subflow",false);
}
});
RED.keyboard.add(/* ? */ 191,{shift:true},function(){showHelp();d3.event.preventDefault();});
RED.comms.connect();
loadNodeList();

View File

@ -382,6 +382,18 @@ RED.library = (function() {
return {
init: function() {
RED.view.on("selection-changed",function(selection) {
if (!selection.nodes) {
RED.menu.setDisabled("btn-export-menu",true);
RED.menu.setDisabled("btn-export-clipboard",true);
RED.menu.setDisabled("btn-export-library",true);
} else {
RED.menu.setDisabled("btn-export-menu",false);
RED.menu.setDisabled("btn-export-clipboard",false);
RED.menu.setDisabled("btn-export-library",false);
}
});
loadFlowLibrary();
},
create: createUI,

View File

@ -174,6 +174,15 @@ RED.subflow = (function() {
RED.view.dirty(true);
RED.view.redraw();
});
RED.view.on("selection-changed",function(selection) {
if (!selection.nodes) {
RED.menu.setDisabled("btn-convert-subflow",true);
} else {
RED.menu.setDisabled("btn-convert-subflow",false);
}
});
}
function createSubflow() {
@ -379,7 +388,7 @@ RED.subflow = (function() {
});
RED.view.dirty(true);
RED.view.redraw();
RED.view.redraw(true);
}

View File

@ -32,6 +32,8 @@ RED.view = (function() {
var activeWorkspace = 0;
var activeSubflow = null;
var activeNodes = [];
var activeLinks = [];
var workspaceScrollPositions = {};
@ -231,6 +233,15 @@ RED.view = (function() {
var drag_line = vis.append("svg:path").attr("class", "drag_line");
function updateActiveNodes() {
activeNodes = RED.nodes.nodes.filter(function(d) {
return d.z == activeWorkspace;
});
activeLinks = RED.nodes.links.filter(function(d) {
return d.source.z == activeWorkspace && d.target.z == activeWorkspace;
})
}
var workspace_tabs = RED.tabs.create({
id: "workspace-tabs",
onchange: function(tab) {
@ -276,6 +287,7 @@ RED.view = (function() {
n.dirty = true;
});
updateSelection();
updateActiveNodes();
redraw();
},
ondblclick: function(tab) {
@ -294,10 +306,12 @@ RED.view = (function() {
}
});
RED.menu.setDisabled("btn-workspace-delete",workspace_tabs.count() == 1);
updateActiveNodes();
},
onremove: function(tab) {
RED.menu.setDisabled("btn-workspace-delete",workspace_tabs.count() == 1);
RED.menu.removeItem("btn-workspace-menu-"+tab.id.replace(".","-"));
updateActiveNodes();
}
});
@ -327,6 +341,7 @@ RED.view = (function() {
RED.menu.setAction('btn-workspace-delete',function() {
deleteWorkspace(activeWorkspace);
});
updateActiveNodes();
}
function deleteWorkspace(id) {
@ -563,6 +578,7 @@ RED.view = (function() {
}
if (mouse_mode == RED.state.IMPORT_DRAGGING) {
RED.keyboard.remove(/* ESCAPE */ 27);
updateActiveNodes();
setDirty(true);
}
redraw();
@ -644,6 +660,7 @@ RED.view = (function() {
clearSelection();
nn.selected = true;
moving_set.push({n:nn});
updateActiveNodes();
updateSelection();
redraw();
@ -886,6 +903,7 @@ RED.view = (function() {
RED.history.push({t:'delete',nodes:removedNodes,links:removedLinks,subflowOutputs:removedSubflowOutputs,subflowInputs:removedSubflowInputs,dirty:startDirty});
selected_link = null;
updateActiveNodes();
updateSelection();
redraw();
}
@ -980,6 +998,7 @@ RED.view = (function() {
var link = {source: src, sourcePort:src_port, target: dst};
RED.nodes.addLink(link);
RED.history.push({t:'add',links:[link],dirty:dirty});
updateActiveNodes();
setDirty(true);
} else {
}
@ -1220,7 +1239,8 @@ RED.view = (function() {
vis.selectAll(".subflowinput").remove();
}
var node = vis.selectAll(".nodegroup").data(RED.nodes.nodes.filter(function(d) { return d.z == activeWorkspace }),function(d){return d.id});
//var node = vis.selectAll(".nodegroup").data(RED.nodes.nodes.filter(function(d) { return d.z == activeWorkspace }),function(d){return d.id});
var node = vis.selectAll(".nodegroup").data(activeNodes,function(d){return d.id});
node.exit().remove();
var nodeEnter = node.enter().insert("svg:g").attr("class", "node nodegroup");
@ -1579,9 +1599,7 @@ RED.view = (function() {
}
var link = vis.selectAll(".link").data(
RED.nodes.links.filter(function(d) {
return d.source.z == activeWorkspace && d.target.z == activeWorkspace;
}),
activeLinks,
function(d) {
return d.source.id+":"+d.sourcePort+":"+d.target.id+":"+d.target.i;
}
@ -1756,7 +1774,7 @@ RED.view = (function() {
dirty:RED.view.dirty()
});
updateActiveNodes();
redraw();
}
} catch(error) {
@ -1972,7 +1990,10 @@ RED.view = (function() {
showWorkspace: function(id) {
workspace_tabs.activateTab(id);
},
redraw: function() {
redraw: function(updateActive) {
if (updateActive) {
updateActiveNodes();
}
RED.nodes.eachSubflow(function(sf) {
if (workspace_tabs.contains(sf.id)) {
workspace_tabs.renameTab(sf.id,"Subflow: "+sf.name);