To tackle the clearing of annotations, I'd probably adjust the refresh() function, to add a re-annotation function after clearing down:
Code:
function refresh(){
if(!chipLayoutIsVisible) return;
ctx.clearRect(0,0,grCanvasSize,grCanvasSize);
drawBoxes();
for(i in nodes){
if(isNodeHigh(i)) overlayNode(nodes[i].segs);
}
hiliteNode(hilited);
}
We'd initialise that function to do nothing:
Code:
drawBoxes=function(){}
and then take advantage of JavaScript being a dynamic language to use eval to adjust the function on the fly, to rewrite it, for example
Code:
drawBoxes=function(){boxLabel(['X', 50, 2317, 8820, 2490, 5689])}
Possibly I'd use the existing structure labelThese which can be populated by the URL, for example like this
http://visual6502.org/JSSim/expert.html ... ,3333,4083which gives us
Code:
labelThese[0]
["PLA", "100", "1169", "2328", "8393", "934"]
labelThese[1]
["Datapath", "100", "2143", "8820", "7676", "5689"]
labelThese[2]
["Control", "100", "3333", "4083"]
The function setupChipLayoutGraphics() could do the messy string manipulation to construct the drawBoxes function, or call a helper function to do it.
Hope this helps!
Cheers
Ed