"003"
*/
function zero_pad(number) {
var temp = number.toString(10);
while (temp.length < 3) {
temp = '0' + temp;
}
return temp;
}
function get_file_name(x, y, z) { // recherche du fichier correspondant au zoom et à la position
return img_prefix+'/'+zero_pad(z)+'-'+zero_pad(x)+'-'+zero_pad(y)+'.jpg';
}
function get_base_name() {
/**
* @returns the base name, which is the name (not path) of the folder where
* the tiles are.
*/
return img_prefix.split('/').reverse()[0];
}
function keys(key) {
hide_links();
evt = key || event;
//evt.preventDefault();
//evt.stopPropagation();
if (!key) {
key = window.event;
key.which = key.keyCode;
}
// alert(key);
// if (!evt.shiftKey) return;
switch (key.which) {
case 36: // home
case 35: // end
angle_control = document.getElementById('angle_ctrl');
angle_control.value = parseFloat(angle_control.value) + 180;
change_angle();
return;
case 39: // left
putImage(last.x+40, last.y);
return;
case 40: // up
putImage(last.x, last.y+20);
return;
case 37: // right
putImage(last.x-40, last.y);
return;
case 38: // down
putImage(last.x, last.y-20);
return;
case 33: // pageup
zoom_control.value--;
change_zoom()
return;
case 34: // pagedown
zoom_control.value++;
change_zoom()
return;
default:
// alert(key.which)
return;
}
}
function onImageClick(e) {
hide_contextmenu();
var index = {};
if (e.touches && e.touches.length == 2) {
e.preventDefault();
fingr = Math.sqrt((e.touches[0].clientX - e.touches[1].clientX)^2 +
(e.touches[0].clientY - e.touches[1].clientY)^2);
} else {
if (e.touches) {
e.preventDefault();
index.x = e.changedTouches[0].clientX;
index.y = e.changedTouches[0].clientY;
} else {
index.x = e.pageX;
index.y = e.pageY;
}
shift.x = last.x;
shift.y = last.y;
speed.x = 0;
speed.y = 0;
mouse.x = index.x;
mouse.y = index.y;
}
clearTimeout(tmt); //arrêt de l'éffet eventuel d'amorti en cours.
canvas.addEventListener('mousemove', stickImage, false);
canvas.addEventListener('touchmove', stickImage, false);
canvas.addEventListener('mouseup', launchImage, false);
canvas.addEventListener('touchend', launchImage, false);
//canvas.addEventListener('mouseout', launchImage, false);
canvas.style.cursor='move';
//document.onmousemove = stickImage;
//document.onmouseup = launchImage;
hide_links();
}
function stickImage(e) {
var index = {};
if (e.changedTouches && e.changedTouches.length == 2) {
e.preventDefault();
// cas du zoom à 2 doigts
var nfingr = Math.sqrt((e.changedTouches[0].clientX - e.changedTouches[1].clientX)^2 +
(e.changedTouches[0].clientY - e.changedTouches[1].clientY)^2);
var evt = {}
evt.pageX = (e.changedTouches[0].clientX + e.changedTouches[1].clientX)/2;
evt.pageY = (e.changedTouches[0].clientY + e.changedTouches[1].clientY)/2;
if (fingr > nfingr*2 || fingr < nfingr/2) {
evt.wheelDelta = fingr - nfingr;
fingr = nfingr;
return wheel_zoom(evt);
} else {
return;
}
}
if (e.touches) {
e.preventDefault();
index.x = e.changedTouches[0].clientX;
index.y = e.changedTouches[0].clientY;
} else {
index.x = e.pageX;
index.y = e.pageY;
}
var xs = mouse.x - index.x + shift.x;
var ys = mouse.y - index.y + shift.y;
speed.x = xs - last.x; //mémorisation des vitesses horizontales
speed.y = ys - last.y; //et verticales lors de ce déplacement
putImage(xs, ys);
}
function launchImage(e) {
var index = {};
if (e.touches) {
e.preventDefault();
index.x = e.changedTouches[0].clientX;
index.y = e.changedTouches[0].clientY;
} else {
index.x = e.pageX;
index.y = e.pageY;
}
distort_canvas(0);
canvas.removeEventListener('mousemove', stickImage, false);
canvas.removeEventListener('touchmove', stickImage, false);
//document.onmousemove = null;
shift.x = index.x - mouse.x + shift.x;
shift.y = index.y - mouse.y + shift.y;
tmt = setTimeout(inertialImage, 100);
}
function putImage(x, y) { // est destiné à permettre l'effet d'amortissement par la mémorisation de la position courante.
if (!zm.is_updated) return;
if (x >= zm.im.width) { // rebouclage horizontal
shift.x -= zm.im.width;
x -= zm.im.width;
} else if (x < 0) {
shift.x += zm.im.width;
x += zm.im.width;
}
if (y >= zm.im.height) { // pas de rebouclage vertical mais blocage
//distort_canvas(1, x, y);
shift.y = zm.im.height-1;
y = zm.im.height-1;
} else if (y < 0) {
//distort_canvas(-1, x, y);
shift.y = 0;
y = 0;
}
last.x = x;
last.y = y;
draw_image(x, y);
}
function inertialImage() {
speed.x *= 0.9;
speed.y *= 0.9;
if (Math.abs(speed.x) > 2 || Math.abs(speed.y) > 2) {
putImage(last.x+speed.x, last.y+speed.y);
tmt = setTimeout(inertialImage, 100);
} else {
show_links();
}
}
function tri_ref_points(v1, v2) {
return v1['x'] - v2['x'];
}
function tzoom(zv) {
this.value = zv;
this.ntiles = {x:0,y:0};
this.tile = {width:0,height:0};
this.last_tile = {width:0,height:0};
this.max_tile = {width:0,height:0};
this.im = {width:0,height:0};
this.is_updated = false;
this.refresh = function() {
this.im.visible_width = this.tile.width*(this.ntiles.x-1)+this.last_tile.width;
this.is_updated = true;
this.im.width = this.im.visible_width;
this.im.height = this.tile.height*(this.ntiles.y-1)+this.last_tile.height;
if (this.last_tile.width > this.tile.width) {
this.max_tile.width = this.im.last_tile.width;
} else {
this.max_tile.width = this.tile.width;
}
if (this.last_tile.height > this.tile.height) {
this.max_tile.height = this.im.last_tile.height;
} else {
this.max_tile.height = this.tile.height;
}
var ord_pts = new Array();
for(var label in ref_points) {
ord_pts.push(ref_points[label]);
}
ord_pts = ord_pts.sort(tri_ref_points);
is_located = (ord_pts.length > 1)
|| image_loop && (ord_pts.length > 0);
alpha_domain = {start:0, end:360};
this.pixel_y_ratio = this.im.width/360;
if (is_located) {
this.ref_pixels = new Array;
this.ref_pixels[0] = new Array(); // Attention il faut compter un intervalle de plus !
for (var i=0; i < ord_pts.length; i++) { // premier parcours pour les paramètres cap/x
this.ref_pixels[i+1] = new Array();
this.ref_pixels[i+1].x = Math.floor(ord_pts[i].x*this.im.width);
this.ref_pixels[i+1].cap = fmodulo(ord_pts[i].cap, 360);
if (i != ord_pts.length-1) {
this.ref_pixels[i+1].ratio_x = (ord_pts[i+1].x - ord_pts[i].x) /
fmodulo(ord_pts[i+1].cap - ord_pts[i].cap, 360)*this.im.width;
}
}
if (image_loop == true) {
var dpix = this.im.width;
var dangle = 360;
if (ord_pts.length > 1) {
dpix = this.im.width - this.ref_pixels[this.ref_pixels.length-1].x + this.ref_pixels[1].x;
dangle = fmodulo(this.ref_pixels[1].cap - this.ref_pixels[this.ref_pixels.length-1].cap, 360);
}
this.ref_pixels[0].ratio_x = dpix/dangle;
this.ref_pixels[ord_pts.length].ratio_x = this.ref_pixels[0].ratio_x;
dpix = this.im.width - this.ref_pixels[ord_pts.length].x;
this.ref_pixels[0].cap = fmodulo(this.ref_pixels[ord_pts.length].cap + dpix / this.ref_pixels[0].ratio_x, 360);
} else {
this.ref_pixels[0].ratio_x = this.ref_pixels[1].ratio_x;
this.ref_pixels[ord_pts.length].ratio_x = this.ref_pixels[ord_pts.length-1].ratio_x;
this.ref_pixels[0].cap = fmodulo(this.ref_pixels[1].cap - this.ref_pixels[1].x / this.ref_pixels[1].ratio_x, 360);
alpha_domain.start = this.ref_pixels[0].cap;
alpha_domain.end = fmodulo(this.ref_pixels[ord_pts.length].cap+(this.im.width-this.ref_pixels[ord_pts.length].x)/this.ref_pixels[ord_pts.length].ratio_x, 360);
this.pixel_y_ratio = this.im.width/fmodulo(alpha_domain.end-alpha_domain.start, 360);
}
this.ref_pixels[0].x = 0;
for (var i=0; i < ord_pts.length; i++) { // second parcours pour les paramètres elevation/y
this.ref_pixels[i+1].shift_y = Math.floor(this.pixel_y_ratio*ord_pts[i].ele - ord_pts[i].y*this.im.height);
if (i != ord_pts.length-1) {
var next_shift = Math.floor(this.pixel_y_ratio*ord_pts[i+1].ele - ord_pts[i+1].y*this.im.height);
this.ref_pixels[i+1].dshft_y = (next_shift - this.ref_pixels[i+1].shift_y)/(this.ref_pixels[i+2].x - this.ref_pixels[i+1].x);
}
}
if (image_loop == true) {
var dpix = this.im.width;
var delt = 0;
if (ord_pts.length > 1) {
dpix = this.im.width - this.ref_pixels[this.ref_pixels.length-1].x + this.ref_pixels[1].x;
delt = this.ref_pixels[this.ref_pixels.length-1].shift_y - this.ref_pixels[1].shift_y;
}
this.ref_pixels[0].dshft_y = -delt/dpix;
this.ref_pixels[ord_pts.length].dshft_y = this.ref_pixels[0].dshft_y;
dpix = this.im.width - this.ref_pixels[ord_pts.length].x;
this.ref_pixels[0].shift_y = this.ref_pixels[ord_pts.length].shift_y + dpix*this.ref_pixels[0].dshft_y;
} else {
this.ref_pixels[0].shift_y = this.ref_pixels[1].shift_y;
this.ref_pixels[0].dshft_y = 0;
this.ref_pixels[ord_pts.length].dshft_y = 0;
}
if (debug_mode) {
var res = document.getElementById('res');
res.innerHTML = 'liste des '+this.ref_pixels.length+' valeurs de correction (image = '+this.im.width+'x'+this.im.height+') zoom = '+this.value+':
';
for (var i=0; i < this.ref_pixels.length; i++) { // pour le debug
res.innerHTML += 'point '+i+' :
';
for (var key in this.ref_pixels[i]) { // pour le debug
res.innerHTML += '- '+key + '['+i+'] = '+this.ref_pixels[i][key]+'
';
}
if (i != this.ref_pixels.length-1) {
var tx0 = this.ref_pixels[i+1].x-1;
//var ty0 = this.ref_pixels[i+1].shift_y;
var ty0 = 0;
} else {
var tx0 = this.im.width-1;
var ty0 = 0;
}
res.innerHTML += '
test sur : '+tx0+','+ty0+'
';
var tst = this.get_cap_ele(tx0, ty0);
res.innerHTML += 'cap:'+tst.cap+', ele:'+tst.ele+'
';
var tst2 = this.get_pos_xy(tst.cap, tst.ele);
res.innerHTML += 'x:'+tst2.x+', y:'+tst2.y+'
';
}
}
}
this.pt_list = new Array();
for (var i=0; i 0 && zoom_control.value > zoom_control.min) {
zoom_control.value--;
change_zoom(zshift.x, zshift.y);
}
}
function change_zoom(shx, shy) {
var zoom_control = document.getElementById("zoom_ctrl");
var v = zoom_control.value;
prev_zm = zm;
if (zooms[v]) {
if (!zooms[v].is_updated) zooms[v].refresh();
} else {
zooms[v] = new tzoom(v);
}
if (zooms[v].is_updated) {
if (shx == undefined || shy == undefined) {
shx=0;
shy=0;
}
zm = zooms[v];
var px = (last.x+shx)*zm.im.width/prev_zm.im.width - shx;
var py = (last.y+shy)*zm.im.height/prev_zm.im.height - shy;
if (py < zm.im.height && py >= 0) {
zoom = zm.value;
tile = zm.tile;
ntiles = zm.ntiles;
update_url();
putImage(px, py);
} else {
zm = prev_zm;
zoom_control.value = zm.value;
}
}
}
function change_angle() {
var elvtn_control = document.getElementById('elvtn_ctrl');
var angle_control = document.getElementById('angle_ctrl');
var resxy = zm.get_pos_xy(angle_control.value, elvtn_control.value);
var pos_x = resxy.x;
var pos_y = Math.floor(zm.im.height/2 - resxy.y);
putImage(pos_x, pos_y);
}
function check_prox(x, y, r) { //verification si un point de coordonnées x, y est bien dans un cercle de rayon r centré en X,Y.
return Math.sqrt(x*x + y*y) < r;
}
function check_links(e) {
var mouse_x = e.pageX-canvas_pos.x;
var mouse_y = e.pageY-canvas_pos.y;
var pos_x = nmodulo(last.x + mouse_x - canvas.width/2, zm.im.width);
var pos_y = last.y + mouse_y - canvas.height/2;
for(var i = 0; i < zm.pt_list.length; i++) {
if (is_located && zm.pt_list[i]['type'] == 'pano_point') {
if (check_prox(zm.pt_list[i]['xc']-pos_x, zm.pt_list[i]['yc']-pos_y, 20)) {
if (zm.pt_list[i]['lnk'] != '') window.location = zm.pt_list[i]['lnk'];
break;
}
}
}
}
function display_links(e) {
var index = {};
if (e.touches) {
e.preventDefault();
index.x = e.changedTouches[0].clientX;
index.y = e.changedTouches[0].clientY;
} else {
index.x = e.pageX;
index.y = e.pageY;
}
var info = document.getElementById('info');
var mouse_x = index.x-canvas_pos.x;
var mouse_y = index.y-canvas_pos.y;
var pos_x = nmodulo(last.x + mouse_x - canvas.width/2, zm.im.width);
var pos_y = last.y + mouse_y - canvas.height/2;
//var cap = ((pos_x/zm.im.width)*360).toFixed(2);
var res = zm.get_cap_ele(pos_x, zm.im.height/2 - pos_y);
//var ele = ((zm.im.height/2 - pos_y)/zm.im.width)*360;
info.innerHTML = 'élévation : '+res.ele.toFixed(2)+'
cap : '+res.cap.toFixed(2);
info.style.top = index.y+'px';
info.style.left = index.x+'px';
info.style.backgroundColor = '#FFC';
info.style.display = 'block';
canvas.style.cursor='crosshair';
for(var i = 0; i < zm.pt_list.length; i++) {
if (is_located || zm.pt_list[i]['type'] == 'ref_point') {
if (check_prox(zm.pt_list[i]['xc']-pos_x, zm.pt_list[i]['yc']-pos_y, 20)) {
info.innerHTML = zm.pt_list[i]['label'];
if (zm.pt_list[i]['dist'] < 10) var dst = Math.round(zm.pt_list[i]['dist']*1000)+' m';
else var dst = zm.pt_list[i]['dist'].toFixed(1)+' kms';
info.innerHTML += '
à ' + dst;
info.style.backgroundColor = 'rgb('+point_colors[zm.pt_list[i]['type']]+')';
canvas.style.cursor='auto';
break;
}
}
}
}
function hide_links() {
canvas.removeEventListener( "mousemove", display_links, false);
canvas.removeEventListener( "touchmove", display_links, false);
var info = document.getElementById('info');
info.style.display = 'none';
}
function show_links() {
canvas.addEventListener( "mousemove", display_links, false);
canvas.addEventListener( "touchmove", display_links, false);
// var info = document.getElementById('info');
// info.style.display = 'block';
}
function hide_contextmenu() {
document.getElementById('insert').style.display = 'none';
}
function manage_ref_points(e) {
//event.preventDefault();
//event.stopPropagation();
var sel_pt = document.getElementById('sel_point');
var do_insert = document.getElementById('do-insert');
var do_delete = document.getElementById('do-delete');
var do_cancel = document.getElementById('do-cancel');
//var show_cap = document.getElementById('show-cap');
var insrt = document.getElementById('insert');
var pos_x = nmodulo(last.x + e.pageX - canvas_pos.x - canvas.width/2, zm.im.width);
var pos_y = last.y + e.pageY - canvas_pos.y - canvas.height/2;
insrt.style.left = e.pageX+'px';
insrt.style.top = e.pageY+'px';
insrt.style.display = 'block';
if (do_insert) {// true if there are ref points
for(var i = 0; i < zm.pt_list.length; i++) {
if (zm.pt_list[i]['type'] == 'ref_point') {
if (check_prox(zm.pt_list[i]['xc']-pos_x,
zm.pt_list[i]['yc']-pos_y, 20)) {
sel_pt.value = zm.pt_list[i]['label'];
}
}
}
do_delete.onclick = function() {delete_ref_point(insrt)};
do_insert.onclick = function() {insert_ref_point(insrt, e.pageX-canvas_pos.x, e.pageY-canvas_pos.y)};
// TODO: adapt to the new backend
//show_cap.onclick = function() {
// window.open('show_capline.php?title='+encodeURIComponent(btoa(title))+'&cap='+res.cap+'&org_lat='+pt_lat+'&org_lon='+pt_lon+'&dist=120000');
//};
}
do_cancel.onclick = hide_contextmenu;
var res = zm.get_cap_ele(pos_x, zm.im.height/2 - pos_y);
var pt_lat = document.getElementById('pos_lat').childNodes[0].nodeValue;
var pt_lon = document.getElementById('pos_lon').childNodes[0].nodeValue;
return false;
}
function insert_ref_point(el, x, y) {
var label, posx, posy;
el.style.display = 'none';
var selected_label = document.getElementById('sel_point').value;
var found = false;
var refpoint_url;
for(var i = 0; i < zm.pt_list.length; i++) {
label = zm.pt_list[i]['label'];
if(label == selected_label) {
refpoint_url = zm.pt_list[i]['url'];
posx = nmodulo(last.x + x - canvas.width/2, zm.im.width)/zm.im.width;
posy = 0.5 - (last.y + y - canvas.height/2)/zm.im.height;
var pval = {x:posx, y:posy, cap:zm.pt_list[i]['cap'], ele:zm.pt_list[i]['ele'], label:label};
ref_points[label] = pval;
document.getElementById('res').innerHTML = 'Dernier point entré
';
document.getElementById('res').innerHTML += 'reference["'+label+'"] = '+posx.toFixed(5)+','+posy.toFixed(5)+'
';
reset_zooms();
putImage(last.x, last.y);
found = true;
break;
}
}
if (!found) {
alert('unknown ref_point: '+label);
}
show_result();
// Then push the modif
var xhr = getXMLHttpRequest();
xhr.open("POST", "/api/v1/references/", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("X-CSRFToken", csrf_token);
xhr.send("reference_point=" + refpoint_url
+ "&panorama=" + panorama_url
+ "&x=" + Math.floor(posx * image_width)
+ "&y=" + Math.floor((posy + 0.5) * image_height));
}
function show_result(clear_before) {
var res = document.getElementById('res');
var strg = '';
for (var lbl in ref_points) {
strg += 'reference["'+lbl+'"] = '+ref_points[lbl].x.toFixed(5)+','+ref_points[lbl].y.toFixed(5)+'';
}
if (strg) strg = 'Liste de tous les points de référence
\n';
if (clear_before) res.innerHTML = strg;
else res.innerHTML += strg;
}
function delete_ref_point(el) {
var ref_name = document.getElementById('sel_point').value;
el.style.display = 'none';
var url = ref_points[ref_name].url;
delete ref_points[ref_name];
reset_zooms();
putImage(last.x, last.y);
show_result(true);
// Then push the modif
var xhr = getXMLHttpRequest();
xhr.open("DELETE", url, true);
xhr.setRequestHeader("X-CSRFToken", csrf_token);
xhr.send();
}
function clean_canvas_events(e) {
canvas.removeEventListener('mousemove', stickImage, false);
canvas.removeEventListener('touchmove', stickImage, false);
document.getElementById('info').style.display = 'none';
speed.x = 0;
speed.y = 0;
}
canvas_set_size = function() {
canvas.style.border = border_width+"px solid red";
canvas.width = window.innerWidth-2*border_width;
canvas.height = window.innerHeight-2*border_width;
canvas_pos.x = canvas.offsetLeft+border_width;
canvas_pos.y = canvas.offsetTop+border_width;
}
canvas_resize = function() {
canvas_set_size();
putImage(last.x, last.y);
}
function paramIn(e) {
e = e || window.event;
var relatedTarget = e.relatedTarget || e.fromElement;
while (relatedTarget != adding && relatedTarget.nodeName != 'BODY' && relatedTarget != document && relatedTarget != localisation) {
relatedTarget = relatedTarget.parentNode;
}
if (relatedTarget != adding && relatedTarget != localisation) {
document.removeEventListener('keydown', keys, false);
}
}
function paramOut(e) {
e = e || window.event;
var relatedTarget = e.relatedTarget || e.toElement;
while (relatedTarget != adding && relatedTarget.nodeName != 'BODY' && relatedTarget != document && relatedTarget != localisation) {
relatedTarget = relatedTarget.parentNode;
}
if (relatedTarget != adding && relatedTarget != localisation) {
document.addEventListener('keydown', keys, false);
}
}
/* Parse initial orientation from URL, either:
#zoom=A/x=B/y=C
#zoom=A/cap=B/elev=C
In the first case, (x, y) is an image coordinate in pixels, where (0, 0)
is the lower left corner.
In the second case, point to the given cap and elevation, assuming the
current panorama is already calibrated.
*/
function get_orientation_from_url() {
// Parse window.location.hash to get either x/y or cap/ele
var regexp1 = /^#zoom=(\d)\/cap=(-?\d+|-?\d+\.\d+)\/ele=(-?\d+|-?\d+\.\d+)$/;
var regexp2 = /^#zoom=(\d)\/x=(\d+)\/y=(\d+)$/;
var res = window.location.hash.match(regexp1);
if (res) {
return { zoom: parseInt(res[1], 10),
cap: parseFloat(res[2]),
elevation: parseFloat(res[3]) };
}
else {
res = window.location.hash.match(regexp2);
if (res) {
return { zoom: parseInt(res[1], 10),
x: parseInt(res[2], 10),
y: parseInt(res[3], 10) };
}
else {
/* By default, center the view */
return { zoom: 2, x: image_width / 2, y: image_height / 2 };
}
}
}
/* Update the URL to reflect the current zoom/orientation, so that it acts
* as a permalink. */
function update_url() {
var x = last.x << zm.value;
var y = image_height - (last.y << zm.value);
// Important: don't set window.location.hash directly, because it
// records a new entry in the browser history...
window.location.replace("#zoom=" + zm.value + "/x=" + x + "/y=" + y);
}
function load_pano() {
localisation = document.getElementById("locadraw");
adding = document.getElementById("adding");
canvas = document.getElementById("mon-canvas");
cntext = canvas.getContext("2d");
canvas_set_size();
canvas.addEventListener("click", check_links, false);
//canvas.addEventListener("oncontextmenu", manage_ref_points, false);
canvas.oncontextmenu = manage_ref_points;
canvas.addEventListener("mouseout" , clean_canvas_events, false);
show_links();
var initial_orientation = get_orientation_from_url();
var to_zoom = initial_orientation.zoom;
var max_zoom = zooms.length - 1;
zoom_control = document.getElementById("zoom_ctrl");
zoom_control.onchange = change_zoom;
zoom_control.max = max_zoom;
if (to_zoom > max_zoom) to_zoom = Math.floor(max_zoom/2);
zm = zooms[to_zoom];
zoom_control.value = to_zoom;
zm.refresh();
zoom = zm.value;
tile = zm.tile;
ntiles = zm.ntiles;
if (!("cap" in initial_orientation)) {
/* Compute cap and elevation from (x, y) coordinates */
var res = zm.get_cap_ele(initial_orientation.x >> zoom,
(initial_orientation.y - image_height / 2) >> zoom);
initial_orientation.cap = res.cap;
initial_orientation.elevation = res.ele;
}
angle_control = document.getElementById("angle_ctrl");
angle_control.value = initial_orientation.cap;
angle_control.onchange = change_angle;
angle_control.onclick = change_angle;
elvtn_control = document.getElementById("elvtn_ctrl");
elvtn_control.value = initial_orientation.elevation;
elvtn_control.onchange = change_angle;
elvtn_control.onclick = change_angle;
change_angle();
loca_temp = document.getElementById("loca_show");
if (loca_temp) {
loca_temp.onclick = showLoca;
loca_temp = document.getElementById("loca_hide");
loca_temp.onclick = hideLoca;
loca_temp = document.getElementById("loca_button");
loca_temp.onclick = localate_point;
loca_erase = document.getElementById("loca_erase");
loca_erase.onclick = erase_point;
localisation.addEventListener('mouseover',paramIn,false);
localisation.addEventListener('mouseout',paramOut,false);
}
canvas.addEventListener('mousedown', onImageClick, false);
canvas.addEventListener('touchstart', onImageClick, false);
document.addEventListener('keydown', keys, false);
canvas.addEventListener('mousewheel', wheel_zoom, false);
canvas.addEventListener('DOMMouseScroll', wheel_zoom, false);
window.onresize = canvas_resize;
if (adding) {
document.getElementById("paramFormHide").onclick = hideForm;
document.getElementById("paramFormShow").onclick = showForm;
adding.addEventListener('mouseover', paramIn, false);
adding.addEventListener('mouseout', paramOut, false);
}
};