From 261e6ec78b337bf495b3acf2cfdd3601ca1b23eb Mon Sep 17 00:00:00 2001 From: Menouar AZIB Date: Fri, 2 Sep 2022 10:59:20 +0200 Subject: [PATCH] Refactoring unmarshallPlotFunction --- src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php | 94 +++------------------------------------------------------------------------------------------- 1 file changed, 3 insertions(+), 91 deletions(-) diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index 5c2f6b7..a2636f2 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -1912,7 +1912,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $crtPanel = NULL; foreach ($plotInput->{'panels'} as $panel) { if ($input->{'panelId'} == $panel->{'id'}) { - if ($panel->{'panel-plot-type'} != 'timePlot') + if ($panel->{'panel-plot-type'} !== 'timePlot') throw new Exception('Plot Function action only available for Time plot.'); $panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_ABSCISSE} = $input->abscisse; @@ -1923,99 +1923,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $panel->{'panel-plot-type'} = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME; $panel->{"axes"} = []; break; + } else { + throw new Exception('Cannot retrieve plot panel for Plot Function.'); } } return $plotInput; - - - if (!$crtPanel) - throw new Exception('Cannot retrieve plot panel for Plot Function.'); - - //Find serie parameter - $crtParam = NULL; - - foreach ($crtPanel->{'params'} as $param) { - $crtParam = $param; - } - - if (!$crtParam) - throw new Exception('Cannot retrieve plot param for Plot Function.'); - - date_default_timezone_set('UTC'); - $timeStamp = strtotime($input->starttime); - $DATE_TYPE = "Y-m-dTH:i:s"; - $start_time_plotfunction = date($DATE_TYPE, $timeStamp); - $timestamp_stop_plotfunction = strtotime($input->stoptime); - $stop_time_plotfunction = date($DATE_TYPE, $timestamp_stop_plotfunction); - - $plotFunctionPlotInput = (object)array( - "interactive-preview" => true, - "file-format" => "PNG", - "file-output" => "INTERACTIVE", - "file-prefix" => "plotFunction", - "timesrc" => "Interval", - "startDate" => $start_time_plotfunction, - "stopDate" => $stop_time_plotfunction, - - "id" => 1, - "page-margins-activated" => $plotInput->{"page-margins-activated"}, - "page-margin-x" => $plotInput->{"page-margin-x"}, - "page-margin-y" => $plotInput->{"page-margin-y"}, - "page-orientation" => $plotInput->{"page-orientation"}, - "page-dimension" => $plotInput->{"page-dimension"}, - "page-layout-type" => "vertical", - "page-layout-object" => (object)array( - "layout-expand" => true, - "layout-panel-height" => 0.5, - "layout-panel-spacing" => 0.05 - ), - "panels" => array() - ); - - $plotPanel = (object)array( - "id" => "1", - "panel-plot-type" => 'plotFunction', - "abscisse" => $input->abscisse, - "type" => $input->type, - "scale_abscisse" => $input->scale_abscisse, - "scale_ordonnee" => $input->scale_ordonnee, - "nb_Echantillons" => $input->nb_Echantillons, - "axes" => array(), - "params" => array(), - ); - - $plotFunctionParam = (object)array( - "id" => 1, - "paramid" => $crtParam->{'paramid'}, - "template_args" => $crtParam->{'template_args'}, - "param-drawing-type" => "serie", - "param-drawing-object" => (object)array( - "serie-lines-activated" => $crtParam->{'param-drawing-object'}->{'serie-lines-activated'}, - "serie-lines-style" => $crtParam->{'param-drawing-object'}->{'serie-lines-style'}, - "serie-lines-width" => $crtParam->{'param-drawing-object'}->{'serie-lines-width'}, - "serie-lines-color" => $crtParam->{'param-drawing-object'}->{'serie-lines-color'} - ), - ); - /* - $plotFunctionParam1 = (object)array( - "id" => 2, - "paramid" => "imf_gsm", - "template_args" => $crtParam->{'template_args'}, - "param-drawing-type" => "serie", - "param-drawing-object" => (object)array( - "serie-lines-activated" => $crtParam->{'param-drawing-object'}->{'serie-lines-activated'}, - "serie-lines-style" => $crtParam->{'param-drawing-object'}->{'serie-lines-style'}, - "serie-lines-width" => $crtParam->{'param-drawing-object'}->{'serie-lines-width'}, - "serie-lines-color" => $crtParam->{'param-drawing-object'}->{'serie-lines-color'} - ), - ); - - //$plotPanel->{"params"}[] = [$plotFunctionParam, $plotFunctionParam1]; - */ - $plotPanel->{"params"}[] = $plotFunctionParam; - $plotFunctionPlotInput->{"panels"}[] = $plotPanel; - - return $plotFunctionPlotInput; } } -- libgit2 0.21.2