Commit db9b2cfe34f791f329bc50857c06bd6622b6b593
1 parent
f7e9b9f1
Exists in
master
and in
66 other branches
Zoom in interactive plot
Showing
2 changed files
with
73 additions
and
6 deletions
Show diff stats
src/InputOutput/IHMImpl/IHMInputOutputClass.php
... | ... | @@ -68,7 +68,7 @@ class IHMInputOutputClass implements InputOutputInterface |
68 | 68 | break; |
69 | 69 | case FunctionTypeEnumClass::ACTION : |
70 | 70 | $this->inputOutput = new IHMInputOutputParamsPlotClass(); |
71 | - $requestId = str_replace("_","",$input->folderId); | |
71 | + $requestId = "Plot"; | |
72 | 72 | break; |
73 | 73 | case FunctionTypeEnumClass::PROCESSDELETE : |
74 | 74 | $this->inputOutput = new IHMInputOutputDeleteProcessClass(); |
... | ... |
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... | ... | @@ -16,8 +16,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
16 | 16 | */ |
17 | 17 | protected function unmarshallRequest($input) |
18 | 18 | { |
19 | - //save request | |
20 | - $this->saveIHMRequest($input); | |
19 | + if (isset($input->{'action'})) | |
20 | + $input = $this->unmarshallActionRequest($input); | |
21 | + else | |
22 | + //save request | |
23 | + $this->saveIHMRequest($input); | |
21 | 24 | |
22 | 25 | //Request |
23 | 26 | $requestIndex = 0; |
... | ... | @@ -64,7 +67,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
64 | 67 | $filePrefix = "plot"; |
65 | 68 | if ($input->{'file-prefix'} && ($input->{'file-prefix'} != "")) |
66 | 69 | $filePrefix = $input->{'file-prefix'}; |
67 | - $filePrefix .= $requestIndex; | |
70 | + $filePrefix .= $tab->{'id'}; | |
68 | 71 | |
69 | 72 | $plotOutputNode->setFilePrefix($filePrefix); |
70 | 73 | |
... | ... | @@ -164,7 +167,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
164 | 167 | $waitingResultFile = $filePrefix.$compression; |
165 | 168 | } |
166 | 169 | |
167 | - $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$requestIndex, $waitingResultFile); | |
170 | + if ($this->isInteractiveRequest) | |
171 | + $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$tab->{'id'}, $waitingResultFile); | |
172 | + else | |
173 | + $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $waitingResultFile); | |
168 | 174 | |
169 | 175 | //Remove old result files |
170 | 176 | foreach (glob($this->paramsData->getWorkingPath().$resultFile) as $oldFile) { |
... | ... | @@ -1133,7 +1139,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
1133 | 1139 | if (!$this->isInteractiveRequest) |
1134 | 1140 | { |
1135 | 1141 | //add to job |
1136 | - $commonRes = $this->commonMarshallResult($data,PLOT_RESULT_FILE_KEY."_0"); | |
1142 | + $commonRes = $this->commonMarshallResult($data,PLOT_RESULT_FILE_KEY); | |
1137 | 1143 | |
1138 | 1144 | return $commonRes; |
1139 | 1145 | } |
... | ... | @@ -1203,5 +1209,66 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
1203 | 1209 | return NULL; |
1204 | 1210 | return json_decode(file_get_contents($path)); |
1205 | 1211 | } |
1212 | + | |
1213 | + private function unmarshallActionRequest($input) | |
1214 | + { | |
1215 | + $plotInput = $this->loadIHMRequest(); | |
1216 | + | |
1217 | + if (!isset($plotInput)) | |
1218 | + throw new Exception('Cannot retrieve request input for inetractive action.'); | |
1219 | + | |
1220 | + switch ($input->{'action'}) | |
1221 | + { | |
1222 | + case 'zoom' : | |
1223 | + return $this->unmarshallZoom($input, $plotInput); | |
1224 | + default : | |
1225 | + throw new Exception('Interactive action not implemented.'); | |
1226 | + } | |
1227 | + } | |
1228 | + | |
1229 | + private function unmarshallZoom($input, $plotInput) | |
1230 | + { | |
1231 | + if ($input->{'axeId'} == 'timeAxis') | |
1232 | + { | |
1233 | + $plotInput = $plotInput; | |
1234 | + $plotInput->{'timesrc'} = 'Interval'; | |
1235 | + $plotInput->{'startDate'} = $input->{'min'}; | |
1236 | + $plotInput->{'stopDate'} = $input->{'max'}; | |
1237 | + $this->saveIHMRequest($plotInput); | |
1238 | + return $plotInput; | |
1239 | + } | |
1240 | + | |
1241 | + //Execute only concerning plot tabs | |
1242 | + $interactiveInput = clone $plotInput; | |
1243 | + $interactiveInput->{'tabs'} = array(); | |
1244 | + foreach ($plotInput->{'tabs'} as $tab) | |
1245 | + { | |
1246 | + if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'}) | |
1247 | + { | |
1248 | + //Add current tab to interactive input | |
1249 | + $interactiveInput->{'tabs'}[] = $tab; | |
1250 | + foreach ($interactiveInput->{'tabs'}[0]->{'panels'} as $panel) | |
1251 | + { | |
1252 | + if ($input->{'panelId'} == $panel->{'id'}) | |
1253 | + { | |
1254 | + foreach ($panel->{'axes'} as $axis) | |
1255 | + { | |
1256 | + if ($input->{'axeId'} == $axis->{'id'}) | |
1257 | + { | |
1258 | + $axis->{'axis-range-extend'} = false; | |
1259 | + $axis->{'axis-range-min'} = $input->{'min'}; | |
1260 | + $axis->{'axis-range-max'} = $input->{'max'}; | |
1261 | + $this->saveIHMRequest($plotInput); | |
1262 | + return $interactiveInput; | |
1263 | + } | |
1264 | + } | |
1265 | + throw new Exception('Cannot retrieve axis for zoom action.'); | |
1266 | + } | |
1267 | + } | |
1268 | + throw new Exception('Cannot retrieve plot panel for zoom action.'); | |
1269 | + } | |
1270 | + } | |
1271 | + throw new Exception('Cannot retrieve plot tab for zoom action.'); | |
1272 | + } | |
1206 | 1273 | } |
1207 | 1274 | ?> |
1208 | 1275 | \ No newline at end of file |
... | ... |