Commit 5ef1fd32a373efb2a850bac4bb5f698b6aea5ffe

Authored by Menouard AZIB
1 parent dde4b598

HistoPlot was added to plotFunction and everything works well

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... ... @@ -343,7 +343,6 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
343 343 $statusPlotNode->setColorMap($panelData->{'panel-status-colormap'});
344 344 }
345 345 }
346   -
347 346 //Axes
348 347 foreach ($panelData->{'axes'} as $axisData)
349 348 $this->unmarshallAxis($axisData, $panelData->{'constants'}, $plotNode);
... ... @@ -2037,12 +2036,119 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
2037 2036 $axis->{"axis-legend-font-bold"} = TRUE;
2038 2037 }
2039 2038  
  2039 + private function setPanelTitleStyle($panel){
  2040 + $panel->{"panel-title-font-activated"} = TRUE;
  2041 + $panel->{"panel-title-font-size"} = 12;
  2042 + $panel->{"panel-title-font-bold"} = TRUE;
  2043 + }
  2044 +
  2045 + private function setHistoXAxis($crtXAxis, $input)
  2046 + {
  2047 + $crtXAxis->{"id"} = 'xaxis_id';
  2048 + $crtXAxis->{"axis-type"} = "x";
  2049 + $crtXAxis->{'axis-range-max'} = $input->{'histo1d-xmax'};
  2050 + $crtXAxis->{'axis-range-min'} = $input->{'histo1d-xmin'};
  2051 + $crtXAxis->{"axis-scale"} = $input->scale_abscisse;
  2052 + }
  2053 +
  2054 +
  2055 + private function unmarshallPlotFunctionHisto($input, $plotInput)
  2056 + {
  2057 + $panels = [];
  2058 +
  2059 + foreach ($plotInput->{'panels'} as $input_panel) {
  2060 + if ($input->{'panelId'} == $input_panel->{'id'}) {
  2061 + // Clone the input panel to avoid modifying the original object
  2062 + $panel = clone ($input_panel);
  2063 +
  2064 + // Set the panel type to 'histoPlot'
  2065 + $panel->{'panel-plot-type'} = 'histoPlot';
  2066 +
  2067 + // Apply panel title style
  2068 + $this->setPanelTitleStyle($panel);
  2069 +
  2070 + // Initialize 'params' as an empty array
  2071 + $panel->{"params"} = [];
  2072 +
  2073 + foreach ($input_panel->{'params'} as $param) {
  2074 + $crtParam = clone ($param);
  2075 +
  2076 + // Check if 'spectro-yaxis' exists, if so, throw an exception
  2077 + if (isset($crtParam->{'param-drawing-object'}->{'spectro-yaxis'})) {
  2078 + throw new Exception('Cannot apply Histogram 1D on Spectro.');
  2079 + } else {
  2080 + // If not, set 'histo1d-color' based on 'serie-lines-color'
  2081 + $crtParam->{'param-drawing-object'}->{'histo1d-color'} = $param->{'param-drawing-object'}->{'serie-lines-color'};
  2082 + }
  2083 +
  2084 + // Set other parameters
  2085 + $crtParam->{'param-drawing-type'} = 'histogram1d';
  2086 + $crtParam->{'param-drawing-object'}->{'histo1d-xbinnumber'} = $input->{'histo1d-xbinnumber'};
  2087 + $crtParam->{'param-drawing-object'}->{'histo1d-function'} = $input->{'histo1d-function'};
  2088 +
  2089 + // Add the modified parameter to the 'params' array
  2090 + $panel->{"params"}[] = $crtParam;
  2091 + }
  2092 +
  2093 + // Find and clone the X-axis
  2094 + $crtXAxis = NULL;
  2095 + foreach ($panel->{'axes'} as $axis) {
  2096 + if ("time" == $axis->{'id'}) {
  2097 + $crtXAxis = clone ($axis);
  2098 + $this->setHistoXAxis($crtXAxis, $input);
  2099 + break;
  2100 + }
  2101 + }
  2102 +
  2103 + // Find and clone the Y-axis
  2104 + $firstParam = $panel->{"params"}[0];
  2105 + $crtYAxis = NULL;
  2106 + foreach ($panel->{'axes'} as $axis) {
  2107 + if ($firstParam->{'param-drawing-object'}->{'serie-yaxis'} == $axis->{'id'}) {
  2108 + $crtYAxis = clone ($axis);
  2109 + $crtYAxis->{"axis-scale"} = $input->scale_ordonnee;
  2110 + break;
  2111 + }
  2112 + }
  2113 +
  2114 + // Throw an exception if Y-axis is not found
  2115 + if (!$crtYAxis) {
  2116 + throw new Exception('Cannot retrieve y Axis for Plot Function/Histogram.');
  2117 + }
  2118 +
  2119 + // Find and clone the color Z-axis
  2120 + $crtColorAxis = NULL;
  2121 + foreach ($panel->{'axes'} as $axis) {
  2122 + if ($axis->{'id'} == 'color') {
  2123 + $crtColorAxis = clone ($axis);
  2124 + break;
  2125 + }
  2126 + }
  2127 +
  2128 + // Assign the axes to the panel
  2129 + $panel->{"axes"} = [];
  2130 + $panel->{"axes"}[] = $crtXAxis;
  2131 + $panel->{"axes"}[] = $crtYAxis;
  2132 + $panel->{"axes"}[] = $crtColorAxis;
  2133 +
  2134 + // Add the modified panel to the panels array
  2135 + $panels[] = $panel;
  2136 + break; // Exit the loop after finding the matching panel
  2137 + }
  2138 + }
  2139 +
  2140 + // Update the panels in the plotInput object
  2141 + $plotInput->{'panels'} = $panels;
  2142 +
  2143 + return $plotInput;
  2144 + }
  2145 +
2040 2146 private function unmarshallPlotFunction($input, $plotInput)
2041 2147 {
  2148 + $histoPlotName = "histoPlot";
2042 2149 date_default_timezone_set('UTC');
2043 2150 $plotInput->{"startDate"} =$input->starttime;
2044 2151 $plotInput->{"stopDate"} = $input->stoptime;
2045   - $plotInput->{"file-prefix"} = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME;
2046 2152 $plotInput->{"interactive-preview"} = true;
2047 2153 $plotInput->{"file-format"} = "PNG";
2048 2154 $plotInput->{"file-output"} = "INTERACTIVE";
... ... @@ -2053,6 +2159,14 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
2053 2159 "layout-panel-spacing" => 0.05
2054 2160 );
2055 2161  
  2162 + if ($input->type == $histoPlotName){
  2163 + $plotInput->{"file-prefix"} = $histoPlotName;
  2164 + return $this->unmarshallPlotFunctionHisto($input, $plotInput);
  2165 + }else{
  2166 + $plotInput->{"file-prefix"} = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME;
  2167 + }
  2168 +
  2169 +
2056 2170 $panels = [];
2057 2171  
2058 2172 foreach ($plotInput->{'panels'} as $input_panel) {
... ... @@ -2066,9 +2180,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
2066 2180 $scale_abscisse = $input->scale_abscisse;
2067 2181 $scale_ordonnee = $input->scale_ordonnee;
2068 2182 $panel->{'panel-plot-type'} = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME;
2069   - $panel->{"panel-title-font-activated"} = TRUE;
2070   - $panel->{"panel-title-font-size"} = 12;
2071   - $panel->{"panel-title-font-bold"} = TRUE;
  2183 + $this->setPanelTitleStyle($panel);
2072 2184  
2073 2185 /**
2074 2186 * @var object $crtParam
... ... @@ -2202,5 +2314,4 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
2202 2314 $plotInput->{'panels'} = $panels;
2203 2315 return $plotInput;
2204 2316 }
2205   -
2206 2317 }
... ...