From f514c09f87d007544e85f125eb72412157529147 Mon Sep 17 00:00:00 2001 From: Menouar AZIB Date: Wed, 31 Aug 2022 12:05:48 +0200 Subject: [PATCH] Send Parameter's id and MinSampling in the panel plot context --- src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php b/src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php index f841dbb..f1b53c3 100644 --- a/src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php +++ b/src/InputOutput/IHMImpl/Tools/IHMPlotContextFileClass.php @@ -1,27 +1,29 @@ false, "message" => "Cannot load plot context file"); - + $doc = new DOMDocument("1.0", "UTF-8"); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; - + if (!$doc->load($filePath)) return array("success" => false, "message" => "Cannot load plot context file"); - + // $pageNodes = $doc->getElementsByTagName('page'); - + if ($pageNodes->length <= 0) return array("success" => false, "message" => "Cannot load context page node"); - + $pageNode = $pageNodes->item(0); - + $isPortrait = $pageNode->getAttribute('portrait') == "true"; - + $pageContext = array( 'startTime' => $pageNode->getAttribute('startTime'), 'stopTime' => $pageNode->getAttribute('stopTime'), @@ -35,31 +37,46 @@ class IHMPlotContextFileClass { 'height' => ($isPortrait ? intval($pageNode->getAttribute('width')) : intval($pageNode->getAttribute('height'))), 'panels' => array() ); - + // $panelNodes = $pageNode->getElementsByTagName('panel'); - - foreach ($panelNodes as $panelNode) - { + + foreach ($panelNodes as $panelNode) { $panelContext = array( 'id' => $panelNode->getAttribute('id') ); - - if ($isPortrait) - { + + if ($isPortrait) { $panelContext['x'] = intval($panelNode->getAttribute('y')); $panelContext['width'] = intval($panelNode->getAttribute('height')); $panelContext['height'] = intval($panelNode->getAttribute('width')); $panelContext['y'] = $pageContext['height'] - intval($panelNode->getAttribute('x')) - $panelContext['height']; - } - else - { + } else { $panelContext['x'] = intval($panelNode->getAttribute('x')); $panelContext['height'] = intval($panelNode->getAttribute('height')); $panelContext['y'] = $pageContext['height'] - intval($panelNode->getAttribute('y')) - $panelContext['height']; $panelContext['width'] = intval($panelNode->getAttribute('width')); } + //Parameters + $PARAMETERS_TAG = 'parameters'; + $parametersNodes = $panelNode->getElementsByTagName($PARAMETERS_TAG); + $PARAMETER_TAG = 'parameter'; + if ($parametersNodes->length > 0) { + $panelContext[$PARAMETERS_TAG] = array(); + $parametersNode = $parametersNodes->item(0); + $items = $parametersNode->getElementsByTagName($PARAMETER_TAG); + foreach ($items as $item) { + $pContext = array( + 'id' => $item->getAttribute('id'), + 'MinSampling' => $item->getAttribute('MinSampling') + ); + + $panelContext[$PARAMETERS_TAG][] = $pContext; + } + } + + // $intervalsNodes = $panelNode->getElementsByTagName('intervals'); if ($intervalsNodes->length > 0) { @@ -80,53 +97,46 @@ class IHMPlotContextFileClass { // $plotAreaNodes = $panelNode->getElementsByTagName('plotArea'); - - if ($plotAreaNodes->length > 0) - { + + if ($plotAreaNodes->length > 0) { $panelContext['plotArea'] = array(); $plotAreaNode = $plotAreaNodes->item(0); - - if ($isPortrait) - { + + if ($isPortrait) { $panelContext['plotArea']['x'] = intval($plotAreaNode->getAttribute('y')); $panelContext['plotArea']['width'] = intval($plotAreaNode->getAttribute('height')); $panelContext['plotArea']['height'] = intval($plotAreaNode->getAttribute('width')); $panelContext['plotArea']['y'] = $pageContext['height'] - intval($plotAreaNode->getAttribute('x')) - $panelContext['plotArea']['height']; - } - else - { + } else { $panelContext['plotArea']['x'] = intval($plotAreaNode->getAttribute('x')); $panelContext['plotArea']['height'] = intval($plotAreaNode->getAttribute('height')); $panelContext['plotArea']['y'] = $pageContext['height'] - intval($plotAreaNode->getAttribute('y')) - $panelContext['plotArea']['height']; $panelContext['plotArea']['width'] = intval($plotAreaNode->getAttribute('width')); } - + //hasSpectro $panelContext['plotArea']['hasSpectro'] = ($plotAreaNode->getAttribute('hasSpectro') == "true"); - + // $panelContext['plotArea']['axes'] = array(); - + $axisNodes = $plotAreaNode->getElementsByTagName('axis'); - - foreach($axisNodes as $axisNode) - { + + foreach ($axisNodes as $axisNode) { $axisContext = array( - 'id' => $axisNode->getAttribute('id'), - 'logarithmic' => ($axisNode->getAttribute('logarithmic') == "true"), - 'min' => floatval($axisNode->getAttribute('min')), - 'max' => floatval($axisNode->getAttribute('max')) + 'id' => $axisNode->getAttribute('id'), + 'logarithmic' => ($axisNode->getAttribute('logarithmic') == "true"), + 'min' => floatval($axisNode->getAttribute('min')), + 'max' => floatval($axisNode->getAttribute('max')) ); - + $panelContext['plotArea']['axes'][] = $axisContext; } } - + $pageContext['panels'][] = $panelContext; } - + return array("success" => true, "page" => $pageContext); } } - -?> \ No newline at end of file -- libgit2 0.21.2