[dev]implement pan and zoom from URL

This commit is contained in:
BigEd 2010-10-01 16:10:33 +00:00
parent 0892586d75
commit f3375f4c4b
2 changed files with 21 additions and 5 deletions

View File

@ -95,8 +95,8 @@ Enter your own program into the array of RAM
<form> <form>
<input type="button" value="Hide Chip Layout" onclick="updateChipLayoutVisibility(false)" /> <input type="button" value="Hide Chip Layout" onclick="updateChipLayoutVisibility(false)" />
<input type="button" value="Clear Highlighting" onclick="clearHighlight()" /> <input type="button" value="Clear Highlighting" onclick="clearHighlight()" />
</form>
Animate during simulation: <input type="checkbox" id="animateModeCheckbox" onchange="updateChipLayoutAnimation(this.checked)" /> Animate during simulation: <input type="checkbox" id="animateModeCheckbox" onchange="updateChipLayoutAnimation(this.checked)" />
</form>
</div> </div>
<div id="expertControlPanel" style="display:none"> <div id="expertControlPanel" style="display:none">
<form> <form>

View File

@ -40,6 +40,7 @@ var ngnd = nodenames['vss'];
var npwr = nodenames['vcc']; var npwr = nodenames['vcc'];
// some modes and parameters which can be passed in from the URL query // some modes and parameters which can be passed in from the URL query
var moveHereFirst;
var expertMode=false var expertMode=false
var animateChipLayout = true; var animateChipLayout = true;
var chipLayoutIsVisible = true; var chipLayoutIsVisible = true;
@ -69,14 +70,14 @@ function setup_part2(){
// which saves a lot of memory and allows us to run on small systems // which saves a lot of memory and allows us to run on small systems
updateChipLayoutVisibility(true); updateChipLayoutVisibility(true);
} }
setupTable();
setupNodeNameList();
window.onkeypress = function(e){handleKey(e);} window.onkeypress = function(e){handleKey(e);}
setStatus('resetting 6502...'); setStatus('resetting 6502...');
setTimeout(setup_part3, 0); setTimeout(setup_part3, 0);
} }
function setup_part3(){ function setup_part3(){
setupTable();
setupNodeNameList();
initChip(); initChip();
document.getElementById('stop').style.visibility = 'hidden'; document.getElementById('stop').style.visibility = 'hidden';
go(); go();
@ -86,6 +87,9 @@ function setupParams(){
if(location.search=="") if(location.search=="")
return return
var queryParts=location.search.slice(1).split('&'); var queryParts=location.search.slice(1).split('&');
var panx;
var pany;
var zoom;
for(var i=0;i<queryParts.length;i++){ for(var i=0;i<queryParts.length;i++){
var params=queryParts[i].split("="); var params=queryParts[i].split("=");
if(params.length!=2){ if(params.length!=2){
@ -102,12 +106,20 @@ function setupParams(){
updateExpertMode(true); updateExpertMode(true);
} else if(name=="graphics" && value.indexOf("f")==0){ } else if(name=="graphics" && value.indexOf("f")==0){
updateChipLayoutVisibility(false); updateChipLayoutVisibility(false);
} else if(name=="panx" && parseInt(value)!=NaN){
panx=parseInt(value);
} else if(name=="pany" && parseInt(value)!=NaN){
pany=parseInt(value);
} else if(name=="zoom" && parseInt(value)!=NaN){
zoom=parseInt(value);
} else { } else {
if(loglevel>0) if(loglevel>0)
console.log('unrecognised parameters:',params); console.log('unrecognised parameters:',params);
break; break;
} }
} }
if(panx!=null && pany!=null && zoom!=null)
moveHereFirst=[panx,pany,zoom];
} }
function updateChipLayoutAnimation(isOn){ function updateChipLayoutAnimation(isOn){
@ -422,14 +434,18 @@ function setupChipLayoutGraphics(){
refresh(); refresh();
document.getElementById('waiting').style.display = 'none'; document.getElementById('waiting').style.display = 'none';
setStatus('Ready!'); // would prefer chipStatus but it's not idempotent setStatus('Ready!'); // would prefer chipStatus but it's not idempotent
if(moveHereFirst!=null)
moveHere(moveHereFirst);
hilite.onmousedown = function(e){mouseDown(e);} hilite.onmousedown = function(e){mouseDown(e);}
} }
function where(){ // utility function to save graphics pan and zoom
function whereAmI(){
return [centerx, centery, zoom]; return [centerx, centery, zoom];
} }
function moveto(place){ // restore graphics pan and zoom (perhaps as given in the URL)
function moveHere(place){
centerx = place[0]; centerx = place[0];
centery = place[1]; centery = place[1];
setZoom(place[2]); setZoom(place[2]);