fix: warn when zone coordinates extend beyond image dimensions

Before limitPoints() silently clamps coordinates, check if any zone
point exceeds the monitor's image dimensions and show a warning icon
with tooltip in the zones table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Isaac Connor
2026-02-15 12:25:09 -05:00
parent f813658f6d
commit 66f25b8027

View File

@@ -65,6 +65,14 @@ echo getNavBarHTML();
foreach ( dbFetchAll('SELECT * FROM Zones WHERE MonitorId=? ORDER BY Area DESC', NULL, array($mid)) as $row ) {
$row['Points'] = coordsToPoints($row['Coords']);
$row['OutOfBounds'] = false;
foreach ($row['Points'] as $point) {
if ($point['x'] < $minX || $point['x'] > $maxX || $point['y'] < $minY || $point['y'] > $maxY) {
$row['OutOfBounds'] = true;
break;
}
}
limitPoints($row['Points'], $minX, $minY, $maxX, $maxY);
$row['Coords'] = pointsToCoords($row['Points']);
$row['AreaCoords'] = preg_replace('/\s+/', ',', $row['Coords']);
@@ -91,7 +99,11 @@ echo getNavBarHTML();
foreach ($zones as $zone) {
?>
<tr>
<td class="colName"><?php echo makeLink('?view=zone&mid='.$mid.'&zid='.$zone['Id'], validHtmlStr($zone['Name']), true, 'data-on-click-true="streamCmdQuit"'); ?></td>
<td class="colName"><?php echo makeLink('?view=zone&mid='.$mid.'&zid='.$zone['Id'], validHtmlStr($zone['Name']), true, 'data-on-click-true="streamCmdQuit"');
if ($zone['OutOfBounds']) {
echo ' <span class="text-warning" title="'.htmlspecialchars('Zone coordinates extend beyond image dimensions ('.$monitor->ViewWidth().'x'.$monitor->ViewHeight().'). Points have been clamped.').'">&nbsp;<i class="fa fa-exclamation-triangle"></i></span>';
}
?></td>
<td class="colType"><?php echo validHtmlStr($zone['Type']) ?></td>
<td class="colUnits"><?php echo $zone['Area'] ?>&nbsp;/&nbsp;<?php echo sprintf('%.2f', ($zone['Area']*100)/($monitor->ViewWidth()*$monitor->ViewHeight()) ) ?></td>
<td class="colMark"><input type="checkbox" name="markZids[]" value="<?php echo $zone['Id'] ?>" data-on-click-this="configureDeleteButton"<?php if ( !canEdit('Monitors') ) { ?> disabled="disabled"<?php } ?>/></td>