Commit 261e6ec78b337bf495b3acf2cfdd3601ca1b23eb

Authored by Menouard AZIB
1 parent 0a5bb843

Refactoring unmarshallPlotFunction

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... ... @@ -1912,7 +1912,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1912 1912 $crtPanel = NULL;
1913 1913 foreach ($plotInput->{'panels'} as $panel) {
1914 1914 if ($input->{'panelId'} == $panel->{'id'}) {
1915   - if ($panel->{'panel-plot-type'} != 'timePlot')
  1915 + if ($panel->{'panel-plot-type'} !== 'timePlot')
1916 1916 throw new Exception('Plot Function action only available for Time plot.');
1917 1917  
1918 1918 $panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_ABSCISSE} = $input->abscisse;
... ... @@ -1923,99 +1923,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1923 1923 $panel->{'panel-plot-type'} = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME;
1924 1924 $panel->{"axes"} = [];
1925 1925 break;
  1926 + } else {
  1927 + throw new Exception('Cannot retrieve plot panel for Plot Function.');
1926 1928 }
1927 1929 }
1928 1930  
1929 1931 return $plotInput;
1930   -
1931   -
1932   - if (!$crtPanel)
1933   - throw new Exception('Cannot retrieve plot panel for Plot Function.');
1934   -
1935   - //Find serie parameter
1936   - $crtParam = NULL;
1937   -
1938   - foreach ($crtPanel->{'params'} as $param) {
1939   - $crtParam = $param;
1940   - }
1941   -
1942   - if (!$crtParam)
1943   - throw new Exception('Cannot retrieve plot param for Plot Function.');
1944   -
1945   - date_default_timezone_set('UTC');
1946   - $timeStamp = strtotime($input->starttime);
1947   - $DATE_TYPE = "Y-m-dTH:i:s";
1948   - $start_time_plotfunction = date($DATE_TYPE, $timeStamp);
1949   - $timestamp_stop_plotfunction = strtotime($input->stoptime);
1950   - $stop_time_plotfunction = date($DATE_TYPE, $timestamp_stop_plotfunction);
1951   -
1952   - $plotFunctionPlotInput = (object)array(
1953   - "interactive-preview" => true,
1954   - "file-format" => "PNG",
1955   - "file-output" => "INTERACTIVE",
1956   - "file-prefix" => "plotFunction",
1957   - "timesrc" => "Interval",
1958   - "startDate" => $start_time_plotfunction,
1959   - "stopDate" => $stop_time_plotfunction,
1960   -
1961   - "id" => 1,
1962   - "page-margins-activated" => $plotInput->{"page-margins-activated"},
1963   - "page-margin-x" => $plotInput->{"page-margin-x"},
1964   - "page-margin-y" => $plotInput->{"page-margin-y"},
1965   - "page-orientation" => $plotInput->{"page-orientation"},
1966   - "page-dimension" => $plotInput->{"page-dimension"},
1967   - "page-layout-type" => "vertical",
1968   - "page-layout-object" => (object)array(
1969   - "layout-expand" => true,
1970   - "layout-panel-height" => 0.5,
1971   - "layout-panel-spacing" => 0.05
1972   - ),
1973   - "panels" => array()
1974   - );
1975   -
1976   - $plotPanel = (object)array(
1977   - "id" => "1",
1978   - "panel-plot-type" => 'plotFunction',
1979   - "abscisse" => $input->abscisse,
1980   - "type" => $input->type,
1981   - "scale_abscisse" => $input->scale_abscisse,
1982   - "scale_ordonnee" => $input->scale_ordonnee,
1983   - "nb_Echantillons" => $input->nb_Echantillons,
1984   - "axes" => array(),
1985   - "params" => array(),
1986   - );
1987   -
1988   - $plotFunctionParam = (object)array(
1989   - "id" => 1,
1990   - "paramid" => $crtParam->{'paramid'},
1991   - "template_args" => $crtParam->{'template_args'},
1992   - "param-drawing-type" => "serie",
1993   - "param-drawing-object" => (object)array(
1994   - "serie-lines-activated" => $crtParam->{'param-drawing-object'}->{'serie-lines-activated'},
1995   - "serie-lines-style" => $crtParam->{'param-drawing-object'}->{'serie-lines-style'},
1996   - "serie-lines-width" => $crtParam->{'param-drawing-object'}->{'serie-lines-width'},
1997   - "serie-lines-color" => $crtParam->{'param-drawing-object'}->{'serie-lines-color'}
1998   - ),
1999   - );
2000   - /*
2001   - $plotFunctionParam1 = (object)array(
2002   - "id" => 2,
2003   - "paramid" => "imf_gsm",
2004   - "template_args" => $crtParam->{'template_args'},
2005   - "param-drawing-type" => "serie",
2006   - "param-drawing-object" => (object)array(
2007   - "serie-lines-activated" => $crtParam->{'param-drawing-object'}->{'serie-lines-activated'},
2008   - "serie-lines-style" => $crtParam->{'param-drawing-object'}->{'serie-lines-style'},
2009   - "serie-lines-width" => $crtParam->{'param-drawing-object'}->{'serie-lines-width'},
2010   - "serie-lines-color" => $crtParam->{'param-drawing-object'}->{'serie-lines-color'}
2011   - ),
2012   - );
2013   -
2014   - //$plotPanel->{"params"}[] = [$plotFunctionParam, $plotFunctionParam1];
2015   - */
2016   - $plotPanel->{"params"}[] = $plotFunctionParam;
2017   - $plotFunctionPlotInput->{"panels"}[] = $plotPanel;
2018   -
2019   - return $plotFunctionPlotInput;
2020 1932 }
2021 1933 }
... ...