cleanup, spacing, use zone object methods to clean up svg zone layers

This commit is contained in:
Isaac Connor 2021-12-05 17:49:24 -05:00
parent 089c6044f1
commit 7b66d751d8
1 changed files with 23 additions and 20 deletions

View File

@ -24,6 +24,7 @@ if ( !canView('Stream') ) {
} }
require_once('includes/MontageLayout.php'); require_once('includes/MontageLayout.php');
require_once('includes/Zone.php');
$showControl = false; $showControl = false;
$showZones = false; $showZones = false;
@ -49,7 +50,6 @@ $heights = array(
'1080' => '1080px', '1080' => '1080px',
); );
$layouts = ZM\MontageLayout::find(NULL, array('order'=>"lower('Name')")); $layouts = ZM\MontageLayout::find(NULL, array('order'=>"lower('Name')"));
$layoutsById = array(); $layoutsById = array();
foreach ( $layouts as $l ) { foreach ( $layouts as $l ) {
@ -149,7 +149,7 @@ echo getNavBarHTML();
$html .= '<div class="container-fluid" id="mfbpanel"'.( ( $flip == 'down' ) ? ' style="display:none;"' : '' ) .'>'.PHP_EOL; $html .= '<div class="container-fluid" id="mfbpanel"'.( ( $flip == 'down' ) ? ' style="display:none;"' : '' ) .'>'.PHP_EOL;
echo $html; echo $html;
?> ?>
<div id="headerButtons"> <div id="headerButtons">
<?php <?php
if ( $showControl ) { if ( $showControl ) {
echo makeLink('?view=control', translate('Control')); echo makeLink('?view=control', translate('Control'));
@ -237,10 +237,10 @@ foreach ( $monitors as $monitor ) {
$monitor_options['width'] = '100%'; $monitor_options['width'] = '100%';
if ( 0 ) { if ( 0 ) {
if ($monitor_options['width'] > 0) if ($monitor_options['width'] > 0)
$monitor_options['width'] = $monitor_options['width'].'px'; $monitor_options['width'] = $monitor_options['width'].'px';
if ($monitor_options['height'] > 0) if ($monitor_options['height'] > 0)
$monitor_options['height'] = $monitor_options['height']?$monitor_options['height'].'px' : null; $monitor_options['height'] = $monitor_options['height']?$monitor_options['height'].'px' : null;
} # end if } # end if
$monitor_options['connkey'] = $monitor->connKey(); $monitor_options['connkey'] = $monitor->connKey();
@ -275,30 +275,28 @@ foreach ( $monitors as $monitor ) {
} else if ( $scale ) { } else if ( $scale ) {
$width = reScale($monitor->Width(), $scale); $width = reScale($monitor->Width(), $scale);
$height = reScale($monitor->Height(), $scale); $height = reScale($monitor->Height(), $scale);
} }
$zones = array(); $zones = array();
foreach( dbFetchAll('SELECT * FROM Zones WHERE MonitorId=? ORDER BY Area DESC', NULL, array($monitor->Id()) ) as $row ) { foreach ( ZM\Zone::find(array('MonitorId'=>$monitor->Id()), array('order'=>'Area DESC')) as $row ) {
$row['Points'] = coordsToPoints($row['Coords']); $points = $row->Points();
if ($scale) {
if ( $scale ) { limitPoints($points, 0, 0, $monitor->Width(), $monitor->Height());
limitPoints($row['Points'], 0, 0, $monitor->Width(), $monitor->Height());
} else { } else {
limitPoints($row['Points'], 0, 0, limitPoints($points, 0, 0,
( $width ? $width-1 : $monitor->ViewWidth()-1 ), ( $width ? $width-1 : $monitor->ViewWidth()-1 ),
( $height ? $height-1 : $monitor->ViewHeight()-1 ) ( $height ? $height-1 : $monitor->ViewHeight()-1 )
); );
} }
$row['Coords'] = pointsToCoords($row['Points']); $row->Coords(pointsToCoords($points));
$row['AreaCoords'] = preg_replace('/\s+/', ',', $row['Coords']);
$zones[] = $row; $zones[] = $row;
} // end foreach Zone } // end foreach Zone
?> ?>
<svg class="zones" id="zones<?php echo $monitor->Id() ?>" style="position:absolute; top: 0; left: 0; background: none; width: 100%; height: 100%;" viewBox="0 0 <?php echo $monitor->ViewWidth() ?> <?php echo $monitor->ViewHeight() ?>" preserveAspectRatio="none"> <svg class="zones" id="zones<?php echo $monitor->Id() ?>" style="position:absolute; top: 0; left: 0; background: none; width: 100%; height: 100%;" viewBox="0 0 <?php echo $monitor->ViewWidth().' '.$monitor->ViewHeight() ?>" preserveAspectRatio="none">
<?php <?php
foreach ( array_reverse($zones) as $zone ) { foreach (array_reverse($zones) as $zone) {
echo '<polygon points="'. $zone['AreaCoords'] .'" class="'. $zone['Type'].'" />'; echo $zone->svg_polygon();
} // end foreach zone } // end foreach zone
?> ?>
Sorry, your browser does not support inline SVG Sorry, your browser does not support inline SVG
@ -308,9 +306,14 @@ foreach ( array_reverse($zones) as $zone ) {
?> ?>
</div> </div>
<?php <?php
if ( (!ZM_WEB_COMPACT_MONTAGE) && ($monitor->Type() != 'WebSite') ) { if ((!ZM_WEB_COMPACT_MONTAGE) && ($monitor->Type() != 'WebSite')) {
?> ?>
<div id="monitorState<?php echo $monitor->Id() ?>" class="monitorState idle"><?php echo translate('State') ?>:&nbsp;<span id="stateValue<?php echo $monitor->Id() ?>"></span>&nbsp;-&nbsp;<span id="fpsValue<?php echo $monitor->Id() ?>"></span>&nbsp;fps</div> <div id="monitorState<?php echo $monitor->Id() ?>" class="monitorState idle">
<?php echo translate('State') ?>:
<span id="stateValue<?php echo $monitor->Id() ?>"></span>
&nbsp;-&nbsp;
<span id="fpsValue<?php echo $monitor->Id() ?>"></span>&nbsp;fps
</div>
<?php <?php
} }
?> ?>