Merge branch 'fix_zone_edit' into storageareas
This commit is contained in:
commit
b2dfdea66e
|
@ -247,7 +247,7 @@ function applyZoneUnits()
|
|||
}
|
||||
else
|
||||
{
|
||||
form.elements['newZone[TempArea]'].value = 100;
|
||||
form.elements['newZone[TempArea]'].value = Math.round( area/monitorArea * 100 );
|
||||
toPercent( form.elements['newZone[MinAlarmPixels]'], area );
|
||||
toPercent( form.elements['newZone[MaxAlarmPixels]'], area );
|
||||
toPercent( form.elements['newZone[MinFilterPixels]'], area );
|
||||
|
@ -323,6 +323,7 @@ function updateZoneImage()
|
|||
Point.y = zone['Points'][i].y;
|
||||
Poly.points.appendItem( Point );
|
||||
}
|
||||
updateArea();
|
||||
}
|
||||
|
||||
function fixActivePoint( index )
|
||||
|
@ -356,6 +357,7 @@ function updateActivePoint( index )
|
|||
var Point = $('zonePoly').points.getItem(index);
|
||||
Point.x =x;
|
||||
Point.y =y;
|
||||
updateArea();
|
||||
|
||||
}
|
||||
|
||||
|
@ -379,6 +381,7 @@ function delPoint( index )
|
|||
{
|
||||
zone['Points'].splice( index, 1 );
|
||||
drawZonePoints();
|
||||
updateArea();
|
||||
}
|
||||
|
||||
function limitPointValue( point, loVal, hiVal )
|
||||
|
@ -386,6 +389,21 @@ function limitPointValue( point, loVal, hiVal )
|
|||
point.value = constrainValue(point.value, loVal, hiVal)
|
||||
}
|
||||
|
||||
function updateArea( ) {
|
||||
area = Polygon_calcArea( zone['Points'] );
|
||||
zone.Area = area;
|
||||
var form = $('zoneForm');
|
||||
form.elements['newZone[Area]'].value = area;
|
||||
if ( form.elements['newZone[Units]'].value == 'Percent' ) {
|
||||
|
||||
form.elements['newZone[TempArea]'].value = Math.round( area/monitorArea*100 );
|
||||
} else if ( form.elements['newZone[Units]'].value == 'Pixels' ) {
|
||||
form.elements['newZone[TempArea]'].value = area;
|
||||
} else {
|
||||
alert("Unknown units: " + form.elements['newZone[Units]'].value );
|
||||
}
|
||||
}
|
||||
|
||||
function updateX( index )
|
||||
{
|
||||
limitPointValue( $('newZone[Points]['+index+'][x]'), 0, maxX );
|
||||
|
@ -398,6 +416,7 @@ function updateX( index )
|
|||
var Point = $('zonePoly').points.getItem(index);
|
||||
Point.x =x;
|
||||
Point.y =y;
|
||||
updateArea();
|
||||
}
|
||||
|
||||
function updateY( index )
|
||||
|
@ -412,6 +431,7 @@ function updateY( index )
|
|||
var Point = $('zonePoly').points.getItem(index);
|
||||
Point.x =x;
|
||||
Point.y =y;
|
||||
updateArea();
|
||||
}
|
||||
|
||||
function saveChanges( element )
|
||||
|
@ -739,4 +759,16 @@ function initPage() {
|
|||
appletRefresh.delay( appletRefreshTime*1000 );
|
||||
}
|
||||
|
||||
function Polygon_calcArea( coords ) {
|
||||
var n_coords = coords.length;
|
||||
var float_area = 0.0;
|
||||
|
||||
for ( i = 0, j = n_coords-1; i < n_coords; j = i++ ) {
|
||||
var trap_area = ( ( coords[i].x - coords[j].x ) * ( coords[i].y + coords[j].y ) ) / 2;
|
||||
float_area += trap_area;
|
||||
//printf( "%.2f (%.2f)\n", float_area, trap_area );
|
||||
}
|
||||
return Math.round( Math.abs( float_area ) );
|
||||
}
|
||||
|
||||
window.addEvent( 'domready', initPage );
|
||||
|
|
|
@ -48,6 +48,7 @@ zone['Points'][<?php echo $i ?>] = { 'x': <?php echo $newZone['Points'][$i]['x']
|
|||
|
||||
var maxX = <?php echo $monitor->Width()-1 ?>;
|
||||
var maxY = <?php echo $monitor->Height()-1 ?>;
|
||||
var monitorArea = <?php echo $monitor->Width() * $monitor->Height() ?>;
|
||||
var selfIntersecting = <?php echo $selfIntersecting?'true':'false' ?>;
|
||||
|
||||
var selfIntersectingString = '<?php echo addslashes(translate('SelfIntersecting')) ?>';
|
||||
|
|
Loading…
Reference in New Issue