diff --git a/lib/controller/doMaskOperation.php b/lib/controller/doMaskOperation.php index 10d69ea..7375e01 100644 --- a/lib/controller/doMaskOperation.php +++ b/lib/controller/doMaskOperation.php @@ -102,6 +102,74 @@ $RBASE->Query( $QS, false ); $Data['operation_id'] = intval( $RBASE->getLastInsertID() ); }; + break; + }; + case 4:{ + // Default = 10x10 meters + if( isset( $_POST['R'] ) ){ + $RANGE = intval( $_POST['R'] ); + } else { + $RANGE = 0; + }; + if( isset( $_POST['A'] ) ){ + $ANGLE = -1 * intval( $_POST['A'] ); + } else { + $ANGLE = 0; + }; + $QS = "SELECT `max_range` FROM `lrf_sensors` WHERE `id`={$SenID}"; + $RJ = $DATABASE->Query( $QS ); + $MR = floatval( $RJ[0]['max_range'] ); + if( $MR != 0 ){ + $PR = 2048.0 / $MR; + } else { + $PR = 2048.0 / 120; + } + // calc center + $J = ( M_PI * 2.0 )/ 6000.0; + $CX = $RANGE * cos( $J*$ANGLE ); + $CY = $RANGE * sin( $J*$ANGLE ); + $QS = "SELECT `id` FROM `lrf_masks` WHERE `sensor_id`={$SenID} AND `lrf_id`=0 AND `layer`=5"; + $JJ = $DATABASE->Query( $QS ); + if( count( $JJ ) ){ + $CID = $JJ[0]['id']; + $QS = "SELECT `id` FROM `lrf_mask_vertexes` WHERE `mask_id`={$CID}"; + $JJ = $DATABASE->Query( $QS ); + foreach( $JJ as $J ){ + $QS = "DELETE FROM `lrf_mask_vertex_points` WHERE `vertex_id`={$J['id']}"; + $DATABASE->Query( $QS ); + $QS = "DELETE FROM `lrf_mask_vertexes` WHERE `id`={$J['id']}"; + $DATABASE->Query( $QS ); + }; + } else { + $QS = "INSERT INTO `lrf_masks`(`sensor_id`,`lrf_id`,`layer`,`status`) VALUES( {$SenID}, 0, 5, 'E')"; + $DATABASE->Query( $QS ); + $CID = $DATABASE->getLastInsertID(); + }; + $QS = "INSERT INTO `lrf_mask_vertexes`(`mask_id`) VALUES({$CID})"; + $DATABASE->Query( $QS ); + $VID = $DATABASE->getLastInsertID(); + $LX = $CX - ( 5*$PR); + $LY = $CY - ( 5*$PR); + $QS = "INSERT INTO `lrf_mask_vertex_points`(`vertex_id`,`x`,`y`) VALUES({$VID},{$LX},{$LY})"; + $DATABASE->Query( $QS ); + $LX = $CX + ( 5*$PR); + $LY = $CY - ( 5*$PR); + $QS = "INSERT INTO `lrf_mask_vertex_points`(`vertex_id`,`x`,`y`) VALUES({$VID},{$LX},{$LY})"; + $DATABASE->Query( $QS ); + $LX = $CX + ( 5*$PR); + $LY = $CY + ( 5*$PR); + $QS = "INSERT INTO `lrf_mask_vertex_points`(`vertex_id`,`x`,`y`) VALUES({$VID},{$LX},{$LY})"; + $DATABASE->Query( $QS ); + $LX = $CX - ( 5*$PR); + $LY = $CY + ( 5*$PR); + $QS = "INSERT INTO `lrf_mask_vertex_points`(`vertex_id`,`x`,`y`) VALUES({$VID},{$LX},{$LY})"; + $DATABASE->Query( $QS ); + + $RBASE = new SQLite_DB( '/dev/shm/argus/mem_db.db'); + $QS = "INSERT INTO `nodes_qcq`(`node_id`,`cmd`,`status`,`parameter`) VALUES({$NodeID}, 80,0,'')"; + $Data['query'] = $QS; + $RBASE->Query( $QS, false ); + break; }; }; }; diff --git a/lib/javascript/jsapi_dynamic/mojo_dashboard.js b/lib/javascript/jsapi_dynamic/mojo_dashboard.js index 24e37d6..e22b18c 100644 --- a/lib/javascript/jsapi_dynamic/mojo_dashboard.js +++ b/lib/javascript/jsapi_dynamic/mojo_dashboard.js @@ -250,20 +250,84 @@ function select2DROI( id, event ){ }; }; } else { - 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 ){ - t.style.cursor = 'crosshair'; + 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 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 ]; + switch( drawZoomLevels[ id ] ){ + case 100:{ + r = Math.round( hr * ( 2048.0 / ( bBox.width/ 2.0 ) ) ); + if( r > 2048 ) r = 2048; + break; + }; + case 50:{ + r = Math.round( hr * ( 1024.0 / ( bBox.width/ 2.0 ) ) ); + if( r > 1024 ) r = 1024; + break; + }; + case 25:{ + r = Math.round( hr * ( 512.0 / ( bBox.width/ 2.0 ) ) ); + if( r > 512 ) r = 512; + break; + }; + case 12:{ + r = Math.round( hr * ( 256.0 / ( bBox.width/ 2.0 ) ) ); + if( r > 256 ) r = 256; + break; + }; + default:{ + r = -1; + break; + }; + }; + if( r > -1 ){ + var z = Math.round( zat * 3000 / Math.PI ); + if( z < 0 ) z += 6000 ; + Ext.Ajax.request({ + url: '/lib/controller/doMaskOperation.php', + params: { + NID: id, + UID: 'Data['id'];?>', + SID: '', + CMD: 4, + R: r, + A: z + }, + success: function( response, opts ){ + load2DMasks( id ); + }, + failure: failureAJAXFunction + }); + }; + 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 ){ + t.style.cursor = 'crosshair'; + }; + selectROI_mode = 0; }; - selectROI_mode = 0; }; }; diff --git a/lib/javascript/jsapi_dynamic/rgoose_devices.js b/lib/javascript/jsapi_dynamic/rgoose_devices.js index fe360c6..ad6e4ab 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_devices.js +++ b/lib/javascript/jsapi_dynamic/rgoose_devices.js @@ -2039,7 +2039,6 @@ function doAckOperation( NodeID, Cmd ){ if( t != undefined ) t.toggle( false, true ); }; }, - //animEl: 'elId', icon: Ext.MessageBox.QUESTION }); } else {