From 9714f05709f47673ccbc24e35cd5eb630d0b3ac3 Mon Sep 17 00:00:00 2001 From: Evgeny Gagua Date: Wed, 6 Dec 2023 19:06:40 +0000 Subject: [PATCH] MAsking Problems --- .../jsapi_dynamic/mojo_dashboard.js | 192 +++++++----------- lib/javascript/jsapi_dynamic/mojo_reports.js | 42 ++-- 2 files changed, 98 insertions(+), 136 deletions(-) diff --git a/lib/javascript/jsapi_dynamic/mojo_dashboard.js b/lib/javascript/jsapi_dynamic/mojo_dashboard.js index 2eb875e..29ef252 100644 --- a/lib/javascript/jsapi_dynamic/mojo_dashboard.js +++ b/lib/javascript/jsapi_dynamic/mojo_dashboard.js @@ -131,7 +131,7 @@ var l3dMapOverlayGeometry = new THREE.SphereGeometry( 490, 60, 40 ); l3dMapOverlayGeometry.scale( -1, 1, 1 ); var l3dMapOverlayMesh = new THREE.Mesh( l3dMapOverlayGeometry, l3dMapOverlayMaterial ); -function addl3dTarget( id, radius, az, el, color = 0xff0000 ){ +function addl3dTarget( id, radius, az, el, color /* = 0xff0000 */ ){ if( id > 0 ){ var target = {}; target.geometry = new THREE.BoxGeometry( 10, 10, 10 ); @@ -181,74 +181,43 @@ function select2DROI( id, event ){ var roi = csvg.getElementById( "roi" ); if( roi != null ) csvg.removeChild( roi ); - var bBox = csvg.getBBox(); - var x = ( bBox.width / csvg.clientWidth ) * event.offsetX; - var y = ( bBox.height / csvg.clientHeight ) * event.offsetY; - - var dx=x-( bBox.width/ 2.0 ); - var dy=y-( bBox.height/ 2.0 ); - var hr = Math.sqrt( dx*dx + dy*dy );// - if( hr > ( bBox.width/ 2.0 ) ) hr = bBox.width/ 2.0; - // Normalization + var x = ( 287.0 / csvg.clientWidth ) * event.offsetX; + var y = ( 287.0 / csvg.clientHeight ) * event.offsetY; + var dx= x - ( 287.0 / 2 ); + var dy= y - ( 287.0 / 2 ); + var hr = Math.sqrt( dx*dx + dy*dy ) * 2; + if( hr > ( 284.0 ) ) hr = 284.0 ; var zat = -1.0 * Math.atan2( dy, dx ); if( zat < 0.0 ) zat += Math.PI * 2.0; - x = ( bBox.width / 2.0 ) + hr * Math.cos( zat ); - y = ( bBox.width / 2.0 ) - hr * Math.sin( zat ); - var cc = document.createElementNS('http://www.w3.org/2000/svg', "circle"); - // - var rk = bBox.width / csvg.clientWidth; - cc.setAttributeNS(null, "cx", x ); - cc.setAttributeNS(null, "cy", y ); - cc.setAttributeNS(null, "r", ""+(6*rk)+"" ); - cc.setAttributeNS(null, "stroke", "#FFFF00" ); - cc.setAttributeNS(null, "stroke-width", ""+(2*rk)+"" ); - cc.setAttributeNS(null, "fill", "#0000FF" ); - cc.setAttributeNS(null, "clip-path", "url(#svg_mask_"+id+")" ); - //cc.setAttributeNS(null, "fill-opacity", "0.4"); - cc.setAttributeNS(null, "id", "roi"); - csvg.appendChild( cc ); - var lts = -1; - var r = 0; - if( targets_lts_2d[ id ] != undefined ) lts = targets_lts_2d[ id ]; + var r = -1; + if( targets_lts_2d[ id ] != undefined ) lts = targets_lts_2d[ id ]; switch( drawZoomLevels[ id ] ){ case 100:{ - r = Math.round( hr * ( 2048.0 / ( bBox.width/ 2.0 ) ) ); + r = Math.round( hr * ( 2048.0 / 284.0 ) ); if( r > 2048 ) r = 2048; - roi_2d[id]={ range: r, az: zat, ts: lts }; - set2DZoomLevel( id, 100 ); break; }; case 50:{ - r = Math.round( hr * ( 1024.0 / ( bBox.width/ 2.0 ) ) ); + r = Math.round( hr * ( 1024.0 / 284.0 ) ); if( r > 1024 ) r = 1024; - roi_2d[id]={ range: r, az: zat, ts: lts }; - set2DZoomLevel( id, 50 ); break; }; case 25:{ - r = Math.round( hr * ( 512.0 / ( bBox.width/ 2.0 ) ) ); + r = Math.round( hr * ( 512.0 / 284.0 ) ); if( r > 512 ) r = 512; - roi_2d[id]={ range: r, az: zat, ts: lts }; - set2DZoomLevel( id, 25 ); break; }; case 12:{ - r = Math.round( hr * ( 256.0 / ( bBox.width/ 2.0 ) ) ); + r = Math.round( hr * ( 256.0 / 284.0 ) ); if( r > 256 ) r = 256; - roi_2d[id]={ range: r, az: zat, ts: lts }; - set2DZoomLevel( id, 12 ); - break; - }; - default:{ - r = -1; - roi_2d[id]={ range: r, az: zat, ts: lts }; - set2DZoomLevel( id, 100 ); break; }; }; + roi_2d[id]={ range: r, az: zat, ts: lts }; //alert('R:'+r+' AZ:'+zat+' TS:'+lts ); if( r > -1 ){ + set2DZoomLevel( id, drawZoomLevels[ id ] ); var z = Math.round( zat * 3000 / Math.PI ); if( z < 0 ) z += 6000 ; doDeviceOperation( id, 42, r+':'+z, true ); @@ -257,40 +226,33 @@ function select2DROI( id, event ){ } else { var csvg = document.getElementById( 'draw_svg_' + id ); if( csvg!= undefined ){ - var bBox = csvg.getBBox(); - var x = ( bBox.width / csvg.clientWidth ) * event.offsetX; - var y = ( bBox.height / csvg.clientHeight ) * event.offsetY; - - var dx=x-( bBox.width/ 2.0 ); - var dy=y-( bBox.height/ 2.0 ); - var hr = Math.sqrt( dx*dx + dy*dy );// - if( hr > ( bBox.width/ 2.0 ) ) hr = bBox.width/ 2.0; - // Normalization + var x = ( 287.0 / csvg.clientWidth ) * event.offsetX; + var y = ( 287.0 / csvg.clientHeight ) * event.offsetY; + var dx= x - ( 287.0 / 2 ); + var dy= y - ( 287.0 / 2 ); + var hr = Math.sqrt( dx*dx + dy*dy ) * 2; + if( hr > ( 284.0 ) ) hr = 284.0 ; var zat = -1.0 * Math.atan2( dy, dx ); if( zat < 0.0 ) zat += Math.PI * 2.0; - x = ( bBox.width / 2.0 ) + hr * Math.cos( zat ); - y = ( bBox.width / 2.0 ) - hr * Math.sin( zat ); - var lts = -1; - var r = 0; - if( targets_lts_2d[ id ] != undefined ) lts = targets_lts_2d[ id ]; + var r = -1; switch( drawZoomLevels[ id ] ){ case 100:{ - r = Math.round( hr * ( 2048.0 / ( bBox.width/ 2.0 ) ) ); + r = Math.round( hr * ( 2048.0 / 284.0 ) ); if( r > 2048 ) r = 2048; break; }; case 50:{ - r = Math.round( hr * ( 1024.0 / ( bBox.width/ 2.0 ) ) ); + r = Math.round( hr * ( 1024.0 / 284.0 ) ); if( r > 1024 ) r = 1024; break; }; case 25:{ - r = Math.round( hr * ( 512.0 / ( bBox.width/ 2.0 ) ) ); + r = Math.round( hr * ( 512.0 / 284.0 ) ); if( r > 512 ) r = 512; break; }; case 12:{ - r = Math.round( hr * ( 256.0 / ( bBox.width/ 2.0 ) ) ); + r = Math.round( hr * ( 256.0 / 284.0 ) ); if( r > 256 ) r = 256; break; }; @@ -321,11 +283,6 @@ function select2DROI( id, event ){ t = Ext.getCmp('cp_radar_'+id ); if( t != undefined ){ t.removeClass( 'yellow_bg' ); - //W = t.ownerCt.ownerCt.getWidth(); - //H = t.ownerCt.ownerCt.getHeight(); - //if( H ){ - // if( ( W / H ) < 1.5 ) t.collapse( true ); - //}; }; t = document.getElementById('draw_svg_'+id ); if( t != undefined ){ @@ -346,7 +303,7 @@ function Draw3DTargets( k, b ){ }; }; -let isUserInteracting = false, onPointerDownMouseX = 0, onPointerDownMouseY = 0, +var isUserInteracting = false, onPointerDownMouseX = 0, onPointerDownMouseY = 0, lon = 0, onPointerDownLon = 0, lat = 0, onPointerDownLat = 0, phi = 0, theta = 0; @@ -781,21 +738,16 @@ function draw2DTargets( a ){ var roi = csvg.getElementById( "roi" ); if( roi != null ) csvg.removeChild( roi ); var cpath = csvg.getElementById( "svg_mask_"+a ); - var bBox; - //if( cpath!=undefined){ - // bBox = cpath.getBBox(); - //} else { - bBox = csvg.getBBox(); - //}; - var max = 2048; + var max = 2048.0; switch( drawZoomLevels[a] ){ - case 50: max = 1024; break; - case 25: max = 512; break; - case 12: max = 256; break; + case 50: max = 1024.0; break; + case 25: max = 512.0; break; + case 12: max = 256.0; break; }; - var rk = bBox.width / ( max * 2 ); - var cpx = bBox.width / 2.0; - var cpy = bBox.height / 2.0; + //var rk = bBox.width / ( max * 2 ); + var cpx= 287.0; + var cpy= 287.0; + var rk = 284.0 / max; //console.log( '2 box: '+ bBox.width+'x'+bBox.height ); if( targets_2d[a] != undefined ){ if( targets_2d[a].length ) { @@ -807,7 +759,7 @@ function draw2DTargets( a ){ x = cpx + rk * targets_2d[a][idx].range * Math.cos( targets_2d[a][idx].az*ak ); y = cpy - rk * targets_2d[a][idx].range * Math.sin( targets_2d[a][idx].az*ak ); var cc = document.createElementNS('http://www.w3.org/2000/svg', "circle"); - var rz = bBox.width / csvg.clientWidth; + var rz = 574 / csvg.clientWidth; cc.setAttributeNS(null, "cx", x ); cc.setAttributeNS(null, "cy", y ); cc.setAttributeNS(null, "r", ""+(6*rz)+"" ); @@ -830,7 +782,7 @@ function draw2DTargets( a ){ y = cpy - rk * roi_2d[a].range * Math.sin( roi_2d[a].az ); var cc = document.createElementNS('http://www.w3.org/2000/svg', "circle"); // - var rz = bBox.width / csvg.clientWidth; + var rz = 574 / csvg.clientWidth; cc.setAttributeNS(null, "cx", x ); cc.setAttributeNS(null, "cy", y ); cc.setAttributeNS(null, "r", ""+(6*rz)+"" ); @@ -873,27 +825,30 @@ function draw2DMasks( a, zzz='' ){ if( csvg != undefined ){ masks_2d_shown[a] = []; var cpath = csvg.getElementById( "svg_mask_"+a ); - var bBox; - if( cpath!=undefined ){ - - bBox = cpath.getBBox(); - } else { - bBox = csvg.getBBox(); + //var bBox; + //if( cpath!=undefined ){ + // bBox = cpath.getBBox(); + //} else { + // bBox = csvg.getBBox(); + //}; + var colors=['#FF0000','#FFFF00','#00FF00','#203080','#0000FF','#FaFF00']; + //var cpx = bBox.width / 2.0; + //var cpy = bBox.height / 2.0; + var max = 1024.0; + switch( drawZoomLevels[a] ){ + case 50: max = 512.0; break; + case 25: max = 256.0; break; + case 12: max = 128.0; break; }; - var colors=['#FF0000','#FFFF00','#00FF00','#203080','#0000FF','#FFFF00']; + //var rk = bBox.width / ( max * 2 ); + var cpx= 287.0; + var cpy= 287.0; + var rk = 284.0 / max; for( i = 0; i < 6; i++ ){ masks_2d_shown[a][i] = []; if( masks_2d[a][i].vtx != undefined ){ //console.log( '0 box: '+ bBox.width+'x'+bBox.height ); - var cpx = bBox.width / 2.0; - var cpy = bBox.height / 2.0; - var max = 2048; - switch( drawZoomLevels[a] ){ - case 50: max = 1024; break; - case 25: max = 512; break; - case 12: max = 256; break; - }; - var rk = bBox.width / ( max * 2 ); + for( k=0; k