{'action'})) { $input = $this->unmarshallActionRequest($input); $forceTimeZoomReset = isset($input->{'force-time-zoom-reset'}) ? $input->{'force-time-zoom-reset'} : false; } else { $resetZoom = true; //save request $this->saveIHMRequest(PLOT_RESULT_FILE_KEY . "_" . $input->{'tab-index'}, $input); } //Request $this->isInteractiveRequest = ($input->{'file-output'} == 'INTERACTIVE'); $this->isFromWS = ($input->{'file-output'} == 'WS'); if ($resetZoom || $forceTimeZoomReset) $this->resetZoomList(PLOT_RESULT_FILE_KEY . "_" . $input->{'tab-index'}, $forceTimeZoomReset); $requestNode = $this->paramsData->addRequestNode($input->{'tab-index'}); $outputsNode = $requestNode->getOutputsNode(); $paramsNode = $requestNode->getParamsNode(); //unmarshall time definition $isIntervalRequest = ($input->timesrc == 'Interval'); $ttFileIndex = -1; $ttIntIndex = -1; if ($this->isInteractiveRequest && !$isIntervalRequest && !$input->{'page-superpose-mode'}) { $ttFileIndex = !isset($input->{'ttFileIndex'}) ? 0 : $input->{'ttFileIndex'}; $ttIntIndex = !isset($input->{'intIndex'}) ? 0 : $input->{'intIndex'}; } $this->unmarshallTimeDefinition($input, $input->{'tab-index'}, $ttFileIndex, $ttIntIndex); $this->interactiveCrtTTFileIndex = $ttFileIndex; $plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT); $plotOutputNode->setWriteContextFile($this->isInteractiveRequest ? "true" : "false"); $plotOutputNode->setWriteDataFile($this->isInteractiveRequest ? "true" : "false"); $compression = ""; if (!$this->isInteractiveRequest && !$this->isFromWS) { switch ($input->{'file-output'}) { case 'TGZ': $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::TAR); $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::GZIP); $compression = ".tar.gz"; break; case 'ZIP': $plotOutputNode->addPostProcessing(RequestOutputPostProcessingEnumClass::ZIP); $compression = ".zip"; break; default: throw new Exception('Compression not implemented.'); } } if ($input->{'one-file-per-interval'}) $plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE_PER_INTERVAL); else $plotOutputNode->setStructure(RequestOutputPlotStructureEnum::ONE_FILE); //prefix $filePrefix = "plot_"; if ($input->{'file-prefix'} && ($input->{'file-prefix'} != "")) $filePrefix = $input->{'file-prefix'}; $filePrefix .= $input->{'tab-index'}; $plotOutputNode->setFilePrefix($filePrefix); //page $pageNode = $plotOutputNode->getPage(); $fileFormat = RequestOutputPlotPageFormatEnum::PNG; $extension = ".png"; switch ($input->{'file-format'}) { case 'PNG': $fileFormat = RequestOutputPlotPageFormatEnum::PNG; $extension = ".png"; break; case 'PDF': $fileFormat = RequestOutputPlotPageFormatEnum::PDF; $extension = ".pdf"; break; case 'PS': $fileFormat = RequestOutputPlotPageFormatEnum::PS; $extension = ".ps"; break; case 'SVG': $fileFormat = RequestOutputPlotPageFormatEnum::SVG; $extension = ".svg"; break; default: throw new Exception('File format not implemented.'); } $pageNode->setFormat($fileFormat); $this->unmarshallTitle($input, 'page-title', $pageNode->getTitle()); $isPortrait = false; switch ($input->{'page-orientation'}) { case 'landscape': $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::LANDSCAPE); break; case 'portrait': $pageNode->setOrientation(RequestOutputPlotPageOrientationEnum::PORTRAIT); $isPortrait = true; break; } switch ($input->{'page-dimension'}) { case 'ISO A4': $pageNode->setDimension(RequestOutputPlotPageDimensionEnum::ISO_A4); break; case 'US letter': $pageNode->setDimension(RequestOutputPlotPageDimensionEnum::US_LETTER); break; default: throw new Exception('Page dimension not implemented.'); } switch ($input->{'page-mode'}) { case 'grayscale': $pageNode->setMode(RequestOutputPlotPageModeEnum::GRAYSCALE); break; case 'color': default: $pageNode->setMode(RequestOutputPlotPageModeEnum::COLOR); break; } if ($input->{'page-margins-activated'}) { $pageNode->getMargins()->setHorizontal($input->{'page-margin-x'}); $pageNode->getMargins()->setVertical($input->{'page-margin-y'}); } if ($input->{'page-font-activated'}) $this->unmarshallFont($input, 'page-font', $pageNode->getFont()); //Superpose mode $pageNode->setSuperposeMode($input->{'page-superpose-mode'} ? "true" : "false"); //Layout $this->unmarshallLayout($input, $pageNode); foreach ($input->{'panels'} as $panelData) $this->unmarshallPanel($panelData, $pageNode, $paramsNode); if ($this->isInteractiveRequest || $this->isFromWS) { $resultFile = $filePrefix . "_*" . $extension; $waitingResultFile = $filePrefix . $extension; } else { $resultFile = $filePrefix . "_*" . $compression; $waitingResultFile = $filePrefix . $compression; } if ($this->isInteractiveRequest) { $this->interactiveTimeSelectionState[PLOT_RESULT_FILE_KEY . "_" . $input->{'tab-index'}] = $isIntervalRequest; $this->interactivePlotTitle[PLOT_RESULT_FILE_KEY . "_" . $input->{'tab-index'}] = $input->{'tab-title'}; $this->interactivePlotIndex[PLOT_RESULT_FILE_KEY . "_" . $input->{'tab-index'}] = $input->{'tab-index'}; $this->interactivePreview = isset($input->{'interactive-preview'}) && ($input->{'interactive-preview'}); $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY . "_" . $input->{'tab-index'}, $waitingResultFile); } else $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $waitingResultFile); //Remove old result files foreach (glob($this->paramsData->getWorkingPath() . $resultFile) as $oldFile) { unlink($oldFile); } //Post process command to apply to the result file $postProcessCmd = $this->paramsData->getPostCmd(); if ($postProcessCmd != "") $postProcessCmd .= " | "; $postProcessCmd .= "mv " . $resultFile . " " . $waitingResultFile; if (($this->isInteractiveRequest) && $isPortrait) $postProcessCmd .= " | convert " . $waitingResultFile . " -rotate -90 " . $waitingResultFile; else if ($this->isFromWS) { if ($isPortrait) $postProcessCmd .= " | convert " . $waitingResultFile . " -rotate -90 " . $input->{"ws-result-file"}; else $postProcessCmd .= " | mv " . $waitingResultFile . " " . $input->{"ws-result-file"}; } $this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && $this->isInteractiveRequest)); $this->paramsData->setPostCmd($postProcessCmd); return $this->paramsData; } protected function unmarshallLayout($request, $pageNode) { switch ($request->{'page-layout-type'}) { case 'vertical': $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL); $pageNode->getLayout()->setPanelHeight($request->{'page-layout-object'}->{'layout-panel-height'}); $pageNode->getLayout()->setPanelSpacing($request->{'page-layout-object'}->{'layout-panel-spacing'}); $pageNode->getLayout()->setExpand($request->{'page-layout-object'}->{'layout-expand'} ? "true" : "false"); $pageNode->getLayout()->setOnlyLowerTimeAxesLegend($request->{'page-layout-object'}->{'layout-timeaxes-legend-lowerone'} ? "true" : "false"); //if ($request->{'page-layout-object'}->{'layout-timeplot-width'} > 0) // $pageNode->setDefaultTimePlotWidth($request->{'page-layout-object'}->{'layout-timeplot-width'}); if ($request->{'page-layout-object'}->{'layout-timeplot-height'} > 0) $pageNode->setDefaultTimePlotHeight($request->{'page-layout-object'}->{'layout-timeplot-height'}); if ($request->{'page-layout-object'}->{'layout-xyplot-width'} > 0) $pageNode->setDefaultXYPlotWidth($request->{'page-layout-object'}->{'layout-xyplot-width'}); if ($request->{'page-layout-object'}->{'layout-xyplot-height'} > 0) $pageNode->setDefaultXYPlotHeight($request->{'page-layout-object'}->{'layout-xyplot-height'}); break; case 'auto': $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::AUTO); $pageNode->getLayout()->setPanelHeight($request->{'page-layout-object'}->{'layout-panel-height'}); $pageNode->getLayout()->setPanelSpacing($request->{'page-layout-object'}->{'layout-panel-spacing'}); $pageNode->getLayout()->setExpand($request->{'page-layout-object'}->{'layout-expand'} ? "true" : "false"); $pageNode->getLayout()->setOnlyLowerTimeAxesLegend($request->{'page-layout-object'}->{'layout-timeaxes-legend-lowerone'} ? "true" : "false"); break; case 'manual': $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::MANUAL); $timePlotLeftMargin = $request->{'page-layout-object'}->{'layout-timeplot-margin-left'} ? $request->{'page-layout-object'}->{'layout-timeplot-margin-left'} : -1; $timePlotRightMargin = $request->{'page-layout-object'}->{'layout-timeplot-margin-right'} ? $request->{'page-layout-object'}->{'layout-timeplot-margin-right'} : -1; $pageNode->setDefaultTimePlotXMargin($timePlotLeftMargin, $timePlotRightMargin); $xyPlotLeftMargin = $request->{'page-layout-object'}->{'layout-xyplot-margin-left'} ? $request->{'page-layout-object'}->{'layout-xyplot-margin-left'} : -1; $xyPlotRightMargin = $request->{'page-layout-object'}->{'layout-xyplot-margin-right'} ? $request->{'page-layout-object'}->{'layout-xyplot-margin-right'} : -1; $pageNode->setDefaultXYPlotXMargin($xyPlotLeftMargin, $xyPlotRightMargin); break; default: throw new Exception('Layout type not implemented.'); } } protected function unmarshallPanel($panelData, $pageNode, $paramsNode) { $panelNode = $pageNode->addPanel(); switch ($pageNode->getLayout()->getType()) { case RequestOutputPlotLayoutTypeEnum::MANUAL: //Panel bounds $panelNode->getBounds()->setX($panelData->{'panel-bounds-x'}); $panelNode->getBounds()->setY($panelData->{'panel-bounds-y'}); $panelNode->getBounds()->setWidth($panelData->{'panel-bounds-width'}); $panelNode->getBounds()->setHeight($panelData->{'panel-bounds-height'}); //Panel margins $leftMargin = $panelData->{'panel-margin-left'} ? $panelData->{'panel-margin-left'} : -1; $rightMargin = $panelData->{'panel-margin-right'} ? $panelData->{'panel-margin-right'} : -1; $panelNode->setXMargin($leftMargin, $rightMargin); break; case RequestOutputPlotLayoutTypeEnum::VERTICAL: //Panel prefered dimensions if ($panelData->{'panel-prefered-width'} > 0) $panelNode->setPreferedWidth($panelData->{'panel-prefered-width'}); if ($panelData->{'panel-prefered-height'} > 0) $panelNode->setPreferedHeight($panelData->{'panel-prefered-height'}); break; default: //Nothing to do } //Panel id if (isset($panelData->{'id'})) $panelNode->setId($panelData->{'id'}); //Panel id if (isset($panelData->{'panel-index'})) $panelNode->setIndex($panelData->{'panel-index'}); //Panel background color if (($panelData->{'panel-background-color'} != 'none') && ($panelData->{'panel-background-color'} != '')) $panelNode->setBackgroundColor($this->hexColor2KernelColor($panelData->{'panel-background-color'})); //Plot Area background color if (($panelData->{'panel-plotareabackground-color'} != 'none') && ($panelData->{'panel-plotareabackground-color'} != '')) { $panelNode->setPlotAreaBackgroundColor($this->hexColor2KernelColor($panelData->{'panel-plotareabackground-color'})); } //Panel font $this->unmarshallFont($panelData, 'panel-font', $panelNode->getFont()); //Panel title $this->unmarshallTitle($panelData, 'panel-title', $panelNode->getTitle()); //Plot type $this->isInstantPlot = false; $plotNode = $this->unmarshallPlotType($panelData, $panelNode); $isTimePlot = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTIME_NAME); //Tick plot $tickPlotNode = NULL; if ($isTimePlot) { if ($this->hasTickBar($panelData->{'params'})) { $tickPlotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TICKPLOT, true); if ($panelData->{'panel-tick-format'} != '') $tickPlotNode->setFormat($panelData->{'panel-tick-format'}); } } //Status plot $statusPlotNode = NULL; if ($isTimePlot) { if ($this->hasStatusBar($panelData->{'params'})) { $statusPlotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::STATUSPLOT, true); switch ($panelData->{'panel-status-position'}) { case 'top': $statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP); break; case 'bottom': $statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM); break; } $statusPlotNode->setColorMap($panelData->{'panel-status-colormap'}); } } //Axes foreach ($panelData->{'axes'} as $axisData) $this->unmarshallAxis($axisData, $panelData->{'constants'}, $plotNode); //Params $this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode, $panelData->{'axes'}); //Additional objects if ($plotNode->getAdditionalObjects() != NULL) $this->unmarshallAdditionalObjects($panelData, $plotNode->getAdditionalObjects(), $isTimePlot); //Fills if ($plotNode->getFills() != NULL) $this->unmarshallFills($panelData, $plotNode->getFills()); return $panelNode; } protected function unmarshallPlotType($panelData, $panelNode) { switch ($panelData->{'panel-plot-type'}) { case 'timePlot': $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TIMEPLOT); break; case 'xyPlot': $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::XYPLOT); $plotNode->setIsIsotropic($panelData->{'panel-scatter-isotropic'}); break; case 'histoPlot': $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::HISTOPLOT); break; case 'statusPlot': $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::STATUSPLOT); switch ($panelData->{'panel-status-position'}) { case 'top': $plotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP); break; case 'bottom': $plotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM); break; } $plotNode->setColorMap($panelData->{'panel-status-colormap'}); break; case 'tickPlot': $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TICKPLOT); if ($panelData->{'panel-tick-format'} != '') $plotNode->setFormat($panelData->{'panel-tick-format'}); break; case 'epochPlot': $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::EPOCHPLOT); if ($panelData->{'panel-epoch-centertimeid'} != '') $plotNode->setCenterTimeId($panelData->{'panel-epoch-centertimeid'}); break; case 'instantPlot': $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::INSTANTPLOT); date_default_timezone_set('UTC'); $time = CommonClass::strTimeToDDTime($panelData->{'panel-instant-time'}); $plotNode->setTime($time); $this->isInstantPlot = true; break; case RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME: $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::PLOTFUNCTION); $plotNode->setAbscisse($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_ABSCISSE}); $plotNode->setType($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TYPE}); $plotNode->setScaleAbscisse($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ABSCISSE}); $plotNode->setScaleOrdonnee($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ORDONNEE}); //$plotNode->setParamsNbPoints($panelData->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_PARAMS_NB_POINTS}); break; default: throw new Exception('Plot type not implemented.'); } //Params Legend if (isset($panelData->{'panel-series-legend'}) && $panelData->{'panel-series-legend'}->{'legend-series-activated'}) $this->unmarshallParamsLegend($panelData->{'panel-series-legend'}, $plotNode->getLegends()->getParamsLegend()); //Text Legends foreach ($panelData->{'text-legends'} as $textLegendData) { $legendNode = $plotNode->getLegends()->addTextLegend(); $this->unmarshallTextLegend($textLegendData, $legendNode); } return $plotNode; } protected function unmarshallAxis($axisData, $constantsData, $plotNode) { //axis type $constantAxisId = ''; switch ($axisData->{'axis-type'}) { case 'time': $axisNode = $plotNode->getTimeAxis(); $axisNode->setFormat($axisData->{'axis-time-format'}); $constantAxisId = 'x'; break; case 'epoch': $axisNode = $plotNode->getEpochAxis(); $axisNode->setNormalized($axisData->{'axis-epoch-normalized'} ? "true" : "false"); $constantAxisId = 'x'; break; case 'x': $axisNode = $plotNode->getXAxis(); $constantAxisId = 'x'; break; case 'y-left': $axisNode = $plotNode->addYAxis('y-left'); $constantAxisId = 'y-left'; break; case 'y-right': $axisNode = $plotNode->addYAxis('y-right'); $axisNode->setPosition(RequestOutputPlotAxisElementPosition::RIGHT); $constantAxisId = 'y-right'; break; case 'color': $axisNode = $plotNode->getZAxis(); $axisNode->setColorMapIndex($axisData->{'axis-color-map'}); if ($axisData->{'axis-color-minval'} != 'none') $axisNode->setMinValColor($this->hexColor2KernelColor($axisData->{'axis-color-minval'})); if ($axisData->{'axis-color-maxval'} != 'none') $axisNode->setMaxValColor($this->hexColor2KernelColor($axisData->{'axis-color-maxval'})); break; default: throw new Exception('Axis type not implemented.'); } //reverse axis if (isset($axisData->{'axis-reverse'})) $axisNode->setReverse($axisData->{'axis-reverse'} ? "true" : "false"); //axis scale switch ($axisData->{'axis-scale'}) { case 'logarithmic': $axisNode->setScale(RequestOutputPlotAxisElementScale::LOGARITHMIC); break; default: $axisNode->setScale(RequestOutputPlotAxisElementScale::LINEAR); } //axis range if ($axisData->{'axis-range-min'} < $axisData->{'axis-range-max'}) $axisNode->getRange()->setMinMax($axisData->{'axis-range-min'}, $axisData->{'axis-range-max'}); if (isset($axisData->{'axis-range-extend'})) $axisNode->getRange()->setExtend($axisData->{'axis-range-extend'} ? "true" : "false"); //axis color if (isset($axisData->{'axis-color'})) $axisNode->setColor($this->hexColor2KernelColor($axisData->{'axis-color'})); //axis thickness if (isset($axisData->{'axis-thickness'})) $axisNode->setThickness($axisData->{'axis-thickness'}); //axis ticks position switch ($axisData->{'axis-tick-position'}) { case 'inwards': $axisNode->getTick()->setPosition(RequestOutputPlotAxisElementTickPosition::INWARDS); break; default: $axisNode->getTick()->setPosition(RequestOutputPlotAxisElementTickPosition::OUTWARDS); } //axis minor and major grid if (isset($axisData->{'axis-grid-minor'})) $axisNode->getTick()->setMinorGrid($axisData->{'axis-grid-minor'} ? "true" : "false"); if (isset($axisData->{'axis-grid-major'})) $axisNode->getTick()->setMajorGrid($axisData->{'axis-grid-major'} ? "true" : "false"); if ($axisData->{'axis-grid-specify-ticks-number'}) { if (isset($axisData->{'axis-grid-minor-number'}) && $axisData->{'axis-grid-minor-number'} != 0) $axisNode->getTick()->setMinorGridNumber($axisData->{'axis-grid-minor-number'}); if (isset($axisData->{'axis-grid-major-number'}) && $axisData->{'axis-grid-major-number'} != 0) $axisNode->getTick()->setMajorGridNumber($axisData->{'axis-grid-major-number'}); } elseif ($axisData->{'axis-grid-specify-ticks-spacing'}) { if (isset($axisData->{'axis-grid-major-space'}) && $axisData->{'axis-grid-major-space'} != 0) $axisNode->getTick()->setMajorGridSpace($axisData->{'axis-grid-major-space'}); if (isset($axisData->{'axis-grid-minor-space'}) && $axisData->{'axis-grid-minor-space'} != 0) $axisNode->getTick()->setMinorGridSpace($axisData->{'axis-grid-minor-space'}); } //legend if (isset($axisData->{'axis-legend-text'}) && $axisData->{'axis-legend-text'} != '') { $axisNode->getLegend()->setText($axisData->{'axis-legend-text'}); } $axisNode->getLegend()->setColor($this->hexColor2KernelColor($axisData->{'axis-legend-color'})); $this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend()); //Show legend if (isset($axisData->{'axis-legend-activated'})) $axisNode->setShowLegend($axisData->{'axis-legend-activated'} ? "true" : "false"); //Show tick marks if (isset($axisData->{'axis-tick-showmarks'})) $axisNode->setShowTickMarks($axisData->{'axis-tick-showmarks'} ? "true" : "false"); //Add constants if ($constantAxisId != '') { foreach ($constantsData as $constantData) if ($constantData->{'constant-axis-id'} == $constantAxisId) $this->unmarshallConstant($constantData, $axisNode); } } protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode, $axesData) { //X parameters $isScatter = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME); $isHisto = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTHISTO_NAME); $xIds = array(); if ($isScatter || $isHisto) { $crtXId = 0; foreach ($paramsData as $paramData) { if ($paramData->{'param-drawing-object'}->{'serie-xaxis-param'} == '') continue; if (array_key_exists($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $xIds)) { //x param already exists continue; } $paramXInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-xaxis-param'}, $this->paramsData); if ($paramXInfo['id'] == '') throw new Exception('Cannot retrieve X parameter.'); $requestParamsNode->addParam($paramXInfo['id']); $xParamNode = $plotNode->getParams()->getParamById($paramXInfo['id']); switch ($paramData->{'param-drawing-type'}) { case 'histogram2d': case 'serie': //Unmarshall x serie if (count($paramXInfo['indexes']) == 0) $xParamNode->addXSerie(-1, $crtXId, $paramData->{'param-drawing-object'}->{'serie-xvalue-min'}, $paramData->{'param-drawing-object'}->{'serie-xvalue-max'}); else if (count($paramXInfo['indexes']) == 1) $xParamNode->addXSerie($paramXInfo['indexes'][0], $crtXId, $paramData->{'param-drawing-object'}->{'serie-xvalue-min'}, $paramData->{'param-drawing-object'}->{'serie-xvalue-max'}); else throw new Exception('X parameter for serie must be a component.'); break; default: throw new Exception('X parameter not allowed for this drawing type. '); } $xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] = $crtXId; ++$crtXId; } } //Main drawing element parameter $drawingEltIndex = 0; foreach ($paramsData as $paramData) { $isTTCat = ($paramData->{'param-type'} == 'ttcat'); //Param if (!$isTTCat) { $paramInfo = $this->paramManager->addExistingParam($paramData->{'paramid'}, $this->paramsData, isset($paramData->{'template_args'}) ? $paramData->{'template_args'} : NULL); } else { $paramInfo = $this->paramManager->addTTCatParam($paramData->{'paramid'}, $this->paramsData); } $paramInfo['indexes'] = array(); if ($paramData->{'param-drawing-type'} == 'sauvaud') { $this->paramManager->applyRangesAndIndexes($this->paramsData, $paramData, false, $paramInfo); } else { $this->paramManager->applyRangesAndIndexes($this->paramsData, $paramData, !$this->isInstantPlot, $paramInfo); } $this->paramManager->applyFilter($this->paramsData, $paramData, $paramInfo); $requestParamsNode->addParam($paramInfo['id']); $colorSerieId = -1; if (!empty($paramData->{'param-drawing-object'}->{'serie-colored-param'})) $colorSerieId = $drawingEltIndex; $xId = ($isScatter && !empty($paramData->{'param-drawing-object'}->{'serie-xaxis-param'})) ? $xIds[$paramData->{'param-drawing-object'}->{'serie-xaxis-param'}] : -1; switch ($paramData->{'param-drawing-type'}) { case 'serie': $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes'], $xId, $colorSerieId, false); break; case 'histogram2d': $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); if(!empty($paramData->{'param-drawing-object'}->{'histotype-param'})) $paramZInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'histotype-param'}, $this->paramsData); else $paramZInfo = NULL; $this->unmarshallHistogram2D($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes'], $xId, $paramZInfo,$axesData); break; case 'histogram1d': $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallHistogram1D($paramData, $requestParamsNode, $plotNode, $paramNode, $paramInfo['indexes']); break; case 'orbit-serie': $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, -1, $xId, $colorSerieId, true); break; case 'spectro': $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']); break; case 'sauvaud': $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallSauvaud($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']); break; case 'status-bar': if (($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTSTATUS_NAME) && !isset($statusPlotNode)) $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); else $paramNode = $statusPlotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallStatusBar($paramData->{'param-drawing-object'}, $paramNode, $paramInfo['indexes']); break; case 'tick-bar': if (($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTICK_NAME) && !isset($tickPlotNode)) $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); else $paramNode = $tickPlotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallTickBar($paramData->{'param-drawing-object'}, $paramNode, $paramInfo['indexes']); break; case 'iserie': $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallInstantSerie($paramData->{'param-drawing-object'}, $plotNode, $paramNode); break; case 'ispectro': $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallInstantSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']); break; case 'intervals': $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); $this->unmarshallIntervals($paramData->{'param-drawing-object'}, $paramNode); break; default: throw new Exception('Drawing type not implemented.'); } ++$drawingEltIndex; } //Colored parameter $drawingEltIndex = 0; foreach ($paramsData as $paramData) { if (empty($paramData->{'param-drawing-object'}->{'serie-colored-param'})) { ++$drawingEltIndex; continue; } $paramColoredInfo = $this->paramManager->addExistingParam($paramData->{'param-drawing-object'}->{'serie-colored-param'}, $this->paramsData); if ($paramColoredInfo['id'] == '') throw new Exception('Cannot retrieve colored parameter.'); $requestParamsNode->addParam($paramColoredInfo['id']); $coloredParamNode = $plotNode->getParams()->getParamById($paramColoredInfo['id']); $colorSerieId = $drawingEltIndex; switch ($paramData->{'param-drawing-type'}) { case 'serie': case 'orbit-serie': //Unmarshall colored serie if (count($paramColoredInfo['indexes']) == 0) $coloredParamNode->addColorSerie($colorSerieId, -1); else if (count($paramColoredInfo['indexes']) == 1) $coloredParamNode->addColorSerie($colorSerieId, $paramColoredInfo['indexes'][0]); else throw new Exception('Colored parameter for serie must be a component.'); break; default: throw new Exception('Colored parameter not allowed for this drawing type. '); } ++$drawingEltIndex; } } protected function unmarshallHistogram2D($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes, $xId, $paramZInfo,$axesData) { $histogram2DNodes = array(); if (count($indexes) == 0) { $histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $xId); if (isset($histogram2DNode)) { $histogram2DNode->setId($paramData->{'id'}); $histogram2DNodes[] = $histogram2DNode; } } foreach ($indexes as $index) { $histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $xId); if (isset($histogram2DNode)) { if (count($indexes) == 1) $histogram2DNode->setId($paramData->{'id'}); $histogram2DNodes[] = $histogram2DNode; } } foreach ($histogram2DNodes as $histogram2DNode) { // resampling switch ($paramData->{'param-drawing-object'}->{'serie-resampling-mode'}) { case 'yparam': $histogram2DNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::YPARAM); break; case 'xparam': default: $histogram2DNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::XPARAM); } // xBinNumber & yBinNumber $histogram2DNode->getBins()->addManualBins($paramData->{'param-drawing-object'}->{'histo2d-xbinnumber'},$paramData->{'param-drawing-object'}->{'histo2d-ybinnumber'}); // histotype, function $histogram2DNode->getHistotype()->setFunction($paramData->{'param-drawing-object'}->{'histo2d-function'}); //smoothfactor $histogram2DNode->getHistotype()->setSmoothFactor($paramData->{'param-drawing-object'}->{'histo2d-smoothfactor'}); if(($paramData->{'param-drawing-object'}->{'histo2d-function'} != "density") && ($paramData->{'param-drawing-object'}->{'histo2d-function'} != "normdensity")){ // paramId if (empty($paramZInfo['id'])) { throw new Exception('Z parameter must be defined to apply function.'); } $requestParamsNode->addParam($paramZInfo['id']); $histogram2DNode->getHistotype()->setParamId($paramZInfo['id']); // index if (count($paramZInfo['indexes']) == 0) $histogram2DNode->getHistotype()->setIndex(-1); else if (count($paramZInfo['indexes']) == 1) $histogram2DNode->getHistotype()->setIndex($paramZInfo['indexes'][0]); else throw new Exception('Z parameter for serie must be a component.'); } } } protected function unmarshallHistogram1D($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes) { $histogram1DNodes = array(); if ($paramData->{'param-drawing-object'}->{'histo1d-color'} == "none") { $color = NULL; } else { $color = $this->hexColor2KernelColor($paramData->{'param-drawing-object'}->{'histo1d-color'}); } if (count($indexes) == 0) { $histogram1DNode = $paramNode->addHistogram1DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $color); if (isset($histogram1DNode)) { $histogram1DNode->setId($paramData->{'id'}); $histogram1DNodes[] = $histogram1DNode; } } foreach ($indexes as $index) { $histogram1DNode = $paramNode->addHistogram1DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $color); if (isset($histogram1DNode)) { if (count($indexes) == 1) $histogram1DNode->setId($paramData->{'id'}); $histogram1DNodes[] = $histogram1DNode; } } foreach ($histogram1DNodes as $histogram1DNode) { // xBinNumber $histogram1DNode->getBins()->addManual1DBins($paramData->{'param-drawing-object'}->{'histo1d-xbinnumber'}); // histotype, function $histogram1DNode->getHistotype()->set1DFunction($paramData->{'param-drawing-object'}->{'histo1d-function'}); } } protected function unmarshallSerie($paramData, $requestParamsNode, $plotNode, $paramNode, $indexes, $xId, $colorSerieId, $isOrbitSerie) { $serieNodes = array(); if (!$isOrbitSerie) { if (count($indexes) == 0) { $serieNode = $paramNode->addYSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $xId, $colorSerieId, $paramData->{'param-drawing-object'}->{'serie-value-min'}, $paramData->{'param-drawing-object'}->{'serie-value-max'}); $serieNode->setId($paramData->{'id'}); if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'})) $serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'}); $serieNodes[] = $serieNode; } foreach ($indexes as $index) { $serieNode = $paramNode->addYSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $xId, $colorSerieId, $paramData->{'param-drawing-object'}->{'serie-value-min'}, $paramData->{'param-drawing-object'}->{'serie-value-max'}); if (count($indexes) == 1) $serieNode->setId($paramData->{'id'}); if (!empty($paramData->{'param-drawing-object'}->{'serie-resolution'})) $serieNode->setResolution($paramData->{'param-drawing-object'}->{'serie-resolution'}); $serieNodes[] = $serieNode; } } else { $orbitSerie = $paramNode->addOrbitSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $colorSerieId); $orbitSerie->setId($paramData->{'id'}); $serieNodes[] = $orbitSerie; } foreach ($serieNodes as $serieNode) { if (!$isOrbitSerie) { //Resampling if ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME) { switch ($paramData->{'param-drawing-object'}->{'serie-resampling-mode'}) { case 'yparam': $serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::YPARAM); break; case 'xparam': default: $serieNode->getResampling()->setType(RequestOutputPlotResamplingTypeEnum::XPARAM); } } } else { //Projection switch ($paramData->{'param-drawing-object'}->{'serie-projection'}) { case 'XY': $serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XY); break; case 'XZ': $serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XZ); break; case 'YZ': $serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YZ); break; case 'XR': $serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::XR); break; case 'YR': $serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::YR); break; case 'ZR': $serieNode->setProjection(RequestOutputPlotOrbitSerieProjectionEnum::ZR); break; default: throw new Exception('Projection not allowed for the orbit serie'); } } //Line $this->unmarshallLine($paramData->{'param-drawing-object'}, 'serie', $serieNode->getLine(), $paramData->{'param-drawing-object'}->{"serie-lines-activated"} ? RequestOutputPlotLineTypeEnum::LINE : RequestOutputPlotLineTypeEnum::NO); //Symbol if (!$paramData->{'param-drawing-object'}->{"serie-symbols-activated"}) $serieNode->getSymbol()->setType(RequestOutputPlotSymbolTypeEnum::NO); else $this->unmarshallSymbol($paramData->{'param-drawing-object'}, 'serie-symbols', $serieNode->getSymbol()); //Time tick if ($paramData->{'param-drawing-object'}->{'serie-timetick-activated'}) $this->unmarshallTimeTick($paramData->{'param-drawing-object'}, $serieNode->getTimeTicks()); //Interval tick if ($paramData->{'param-drawing-object'}->{'serie-intervaltick-activated'}) $this->unmarshallIntervalTick($paramData->{'param-drawing-object'}, $serieNode->getIntervalTicks()); if (!$isOrbitSerie) { //Error bar if ($paramData->{'param-drawing-object'}->{'serie-errorbar-activated'}) $this->unmarshallErrorBar($paramData->{'param-drawing-object'}, $requestParamsNode, $serieNode->getErrorBar()); } } } protected function unmarshallTimeTick($serieData, $timeTickNode) { //Font if ($serieData->{'serie-timetick-font-activated'}) $this->unmarshallFont($serieData, 'serie-timetick-font', $timeTickNode->getFont()); //First Symbol if ($serieData->{'serie-timetick-firstsymbols-activated'}) $this->unmarshallSymbol($serieData, 'serie-timetick-firstsymbols', $timeTickNode->getFirstSymbol()); //Symbol $this->unmarshallSymbol($serieData, 'serie-timetick-symbols', $timeTickNode->getSymbol()); //Set options by type switch ($serieData->{'serie-timetick-type'}) { case 'time-step': $timeTickNode->setStep(CommonClass::timeStampToDDTime($serieData->{'serie-timetick-step'})); $timeTickNode->setNumber(0); break; case 'nb-major': $timeTickNode->setStep(0); $timeTickNode->setNumber($serieData->{'serie-timetick-nbmajor'}); break; case 'auto': default: $timeTickNode->setStep('auto'); $timeTickNode->setNumber(0); } //Minor $timeTickNode->setMinor($serieData->{'serie-timetick-nbminor'}); //Color $timeTickNode->setColor($this->hexColor2KernelColor($serieData->{'serie-timetick-color'})); } protected function unmarshallIntervalTick($serieData, $intervalTickNode) { //Mode switch ($serieData->{'serie-intervaltick-mode'}) { case 'symbol-only': $intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::SYMBOLONLY); break; case 'interval-index': $intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::INTERVALINDEX); break; case 'start-stop-time': $intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTSTOPTIME); break; case 'start-time': default: $intervalTickNode->setMode(RequestOutputPlotSerieIntervalTicksModeEnum::STARTTIME); } //Color $intervalTickNode->setColor($this->hexColor2KernelColor($serieData->{'serie-intervaltick-color'})); //Symbol $this->unmarshallSymbol($serieData, 'serie-intervaltick-symbols', $intervalTickNode->getSymbol()); //Font if ($serieData->{'serie-intervaltick-font-activated'}) $this->unmarshallFont($serieData, 'serie-intervaltick-font', $intervalTickNode->getFont()); } protected function unmarshallErrorBar($serieData, $requestParamsNode, $errorBarNode) { //Type switch ($serieData->{'serie-errorbar-type'}) { case 'min-max': $errorBarTypeNode = $errorBarNode->getBarByType(RequestOutputPlotYSerieErrorBarTypeEnum::MINMAX); $minParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-minparam'}, $this->paramsData); if ($minParamInfo['id'] == '') throw new Exception('Cannot retrieve min. error parameter.'); $requestParamsNode->addParam($minParamInfo['id']); if (count($minParamInfo['indexes']) == 0) $errorBarTypeNode->setMinParam($minParamInfo['id'], -1); else if (count($minParamInfo['indexes']) == 1) $errorBarTypeNode->setMinParam($minParamInfo['id'], $minParamInfo['indexes'][0]); else throw new Exception('Min parameter for error bar must be a component.'); $maxParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-maxparam'}, $this->paramsData); if ($maxParamInfo['id'] == '') throw new Exception('Cannot retrieve max. error parameter.'); $requestParamsNode->addParam($maxParamInfo['id']); if (count($maxParamInfo['indexes']) == 0) $errorBarTypeNode->setMaxParam($maxParamInfo['id'], -1); else if (count($maxParamInfo['indexes']) == 1) $errorBarTypeNode->setMaxParam($maxParamInfo['id'], $maxParamInfo['indexes'][0]); else throw new Exception('Max parameter for error bar must be a component.'); break; case 'delta': $errorBarTypeNode = $errorBarNode->getBarByType(RequestOutputPlotYSerieErrorBarTypeEnum::DELTA); $deltaParamInfo = $this->paramManager->addExistingParam($serieData->{'serie-errorbar-deltaparam'}, $this->paramsData); if ($deltaParamInfo['id'] == '') throw new Exception('Cannot retrieve delta error parameter.'); $requestParamsNode->addParam($deltaParamInfo['id']); if (count($deltaParamInfo['indexes']) == 0) $errorBarTypeNode->setDeltaParam($deltaParamInfo['id'], -1); else if (count($deltaParamInfo['indexes']) == 1) $errorBarTypeNode->setDeltaParam($deltaParamInfo['id'], $deltaParamInfo['indexes'][0]); else throw new Exception('Delta parameter for error bar must be a component.'); break; default: throw new Exception('Unknown error bar type.'); } //Line $this->unmarshallLine($serieData, 'serie-errorbar', $errorBarNode->getLine(), RequestOutputPlotLineTypeEnum::LINE); } protected function unmarshallInstantSerie($paramDrawingData, $plotNode, $paramNode) { $iserieNode = $paramNode->addInstantSerie('y-left'); //Table on X Axis $iserieNode->setTableOnXAxis($paramDrawingData->{'iserie-tableonx'} ? "true" : "false"); //Line $this->unmarshallLine($paramDrawingData, 'iserie', $iserieNode->getLine(), $paramDrawingData->{"iserie-lines-activated"} ? RequestOutputPlotLineTypeEnum::LINE : RequestOutputPlotLineTypeEnum::NO); //Symbol if (!$paramDrawingData->{"iserie-symbols-activated"}) $iserieNode->getSymbol()->setType(RequestOutputPlotSymbolTypeEnum::NO); else $this->unmarshallSymbol($paramDrawingData, 'iserie-symbols', $iserieNode->getSymbol()); } protected function unmarshallSpectro($paramDrawingData, $plotNode, $paramNode, $indexes) { $spectroNode = $paramNode->addSpectro( $paramDrawingData->{'spectro-yaxis'}, empty($paramDrawingData->{'spectro-resolution'}) ? NULL : $paramDrawingData->{'spectro-resolution'}, count($indexes) > 0 ? $indexes[0] : NULL, $paramDrawingData->{'spectro-value-min'}, $paramDrawingData->{'spectro-value-max'}, isset($paramDrawingData->{'spectro-log0-as-min'}) ? $paramDrawingData->{'spectro-log0-as-min'} : false, empty($paramDrawingData->{'spectro-normalization'}) ? NULL : $paramDrawingData->{'spectro-normalization'}, empty($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE}, !isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE}, !isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}) || ($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM} == "") ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM} ); } protected function unmarshallSauvaud($paramDrawingData, $plotNode, $paramNode, $indexes) { $spectroNode = $paramNode->addSauvaud( $paramDrawingData->{'spectro-yaxis'}, empty($paramDrawingData->{'spectro-resolution'}) ? NULL : $paramDrawingData->{'spectro-resolution'}, count($indexes) > 0 ? $indexes[0] : NULL, $paramDrawingData->{'spectro-value-min'}, $paramDrawingData->{'spectro-value-max'}, isset($paramDrawingData->{'spectro-log0-as-min'}) ? $paramDrawingData->{'spectro-log0-as-min'} : false, empty($paramDrawingData->{'spectro-normalization'}) ? NULL : $paramDrawingData->{'spectro-normalization'}, empty($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_TYPE}, !isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_VALUE}, !isset($paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}) ? NULL : $paramDrawingData->{REQUESTOUTPUTPLOTSPECTRO_BGS_DIM}, $paramDrawingData->{'right_dim'} ); } protected function unmarshallInstantSpectro($paramDrawingData, $plotNode, $paramNode, $indexes) { //TBD how to process inexes if they are defined ? $spectroNode = $paramNode->addInstantSpectro('y-left', $paramDrawingData->{'ispectro-dimonxaxis'}); } protected function unmarshallStatusBar($paramDrawingData, $paramNode, $indexes) { if ($paramDrawingData->{'statusbar-color'} == "none") { $color = NULL; } else { $color = $this->hexColor2KernelColor($paramDrawingData->{'statusbar-color'}); } if (count($indexes) == 0) $paramNode->addStatusBar(-1, $color); else { foreach ($indexes as $index) $paramNode->addStatusBar($index, $color); } } protected function unmarshallIntervals($paramDrawingData, $paramNode) { if ($paramDrawingData->{'intervals-color'} == "none") { $color = NULL; } else { $color = $this->hexColor2KernelColor($paramDrawingData->{'intervals-color'}); } $intervalsNode = $paramNode->addIntervals($color); if ($paramDrawingData->{'legend-text-activated'}) { $textLegendNode = $intervalsNode->addTextLegend(); $this->unmarshallTextLegend($paramDrawingData, $textLegendNode); } } protected function unmarshallTickBar($paramDrawingData, $paramNode, $indexes) { if (count($indexes) == 0) $paramNode->addTickBar(-1); foreach ($indexes as $index) $paramNode->addTickBar($index); } protected function hasStatusBar($paramsData) { foreach ($paramsData as $paramData) if ($paramData->{'param-drawing-type'} == 'status-bar') return true; return false; } protected function hasTickBar($paramsData) { foreach ($paramsData as $paramData) if ($paramData->{'param-drawing-type'} == 'tick-bar') return true; return false; } protected function unmarshallParamsLegend($paramsLegendData, $paramsLegendNode) { //Legend type switch ($paramsLegendData->{'legend-series-type'}) { case 'text-line-symbol': $paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTLINESYMBOL); break; case 'text-only': default: $paramsLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTONLY); } //Show param legend $paramsLegendNode->setShowParamInfo($paramsLegendData->{'legend-series-showparaminfo'} ? "true" : "false"); //Show interval legend $paramsLegendNode->setShowIntervalInfo($paramsLegendData->{'legend-series-intervalinfo-activated'} ? "true" : "false"); //Interval info type switch ($paramsLegendData->{'legend-series-intervalinfo-type'}) { case 'start-stop': $paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::STARTSTOP); break; case 'index': default: $paramsLegendNode->setIntervalInfoType(RequestOutputPlotParamsLegendIntervalInfoTypeEnum::INDEX); } //Position switch ($paramsLegendData->{'legend-series-position'}) { case 'inside': $paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::INSIDE); break; case 'outside': default: $paramsLegendNode->setPosition(RequestOutputPlotParamsLegendPositionEnum::OUTSIDE); } //Default text color $paramsLegendNode->setDefaultTextColor($this->hexColor2KernelColor($paramsLegendData->{'legend-series-defaulttextcolor'})); //Border visible $paramsLegendNode->setBorderVisible($paramsLegendData->{'legend-series-border-activated'} ? "true" : "false"); //Border color $paramsLegendNode->setBorderColor($this->hexColor2KernelColor($paramsLegendData->{'legend-series-border-color'})); //Font if ($paramsLegendData->{'legend-series-font-activated'}) $this->unmarshallFont($paramsLegendData, 'legend-series-font', $paramsLegendNode->getFont()); } protected function unmarshallTextLegend($textLegendData, $parentNode) { //Legend text $parentNode->setText($textLegendData->{'legend-text-value'}); //Legend position switch ($textLegendData->{'legend-text-position'}) { case 'top': $parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::TOP); break; case 'bottom': $parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::BOTTOM); break; case 'left': $parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::LEFT); break; case 'right': default: $parentNode->setPosition(RequestOutputPlotTextLegendPositionEnum::RIGHT); } //Legend text color $parentNode->setColor($this->hexColor2KernelColor($textLegendData->{'legend-text-color'})); //Font if ($textLegendData->{'legend-text-font-activated'}) { $this->unmarshallFont($textLegendData, 'legend-text-font', $parentNode->getFont()); } } protected function unmarshallConstant($constantData, $axisNode) { $constantNode = $axisNode->addConstant(); $constantNode->setId($constantData->{'id'}); //Constant value switch ($axisNode->getName()) { case REQUESTOUTPUTPLOTTIMEAXIS_NAME: date_default_timezone_set('UTC'); $time = CommonClass::strTimeToDDTime($constantData->{'constant-time-value'}); $constantNode->setConstantValue($time); break; default: $constantNode->setConstantValue($constantData->{'constant-float-value'}); } //Curve options $this->unmarshallCurve($constantData, "constant-line", $constantNode); } protected function unmarshallAdditionalObjects($panelData, $addObjectsNode, $isTimePlot) { foreach ($panelData->{'textObjs'} as $textData) $this->unmarshallTextObject($textData, $addObjectsNode, $isTimePlot); foreach ($panelData->{'curves'} as $curveData) $this->unmarshallCurveObject($curveData, $addObjectsNode); } protected function unmarshallTextObject($textData, $addObjectsNode, $isTimePlot) { $textNode = $addObjectsNode->addTextObject(); $textNode->setText($textData->{'text-value'}); switch ($textData->{'text-y-axis'}) { case 'y-right': $textNode->setYAxis('y-right'); break; case 'y-left': $textNode->setYAxis('y-left'); break; } if ($isTimePlot && !$textData->{'text-x-relative'}) { date_default_timezone_set('UTC'); $time = CommonClass::strTimeToDDTime($textData->{'text-x-timevalue'}); $textNode->setX($time); } else if ($textData->{'text-x-relative'}) $textNode->setX(($textData->{'text-x-floatvalue'} * 100) . "%"); else $textNode->setX($textData->{'text-x-floatvalue'}); if ($textData->{'text-y-relative'}) $textNode->setY(($textData->{'text-y-value'} * 100) . "%"); else $textNode->setY($textData->{'text-y-value'}); $textNode->setAngle($textData->{'text-angle'}); $textNode->setColor($this->hexColor2KernelColor($textData->{'text-color'})); switch ($textData->{'text-align'}) { case 'center': $textNode->setAlign(RequestOutputPlotTextAlign::CENTER); break; case 'right': $textNode->setAlign(RequestOutputPlotTextAlign::RIGHT); break; case 'left': default: $textNode->setAlign(RequestOutputPlotTextAlign::LEFT); } //Font if ($textData->{'text-font-activated'}) $this->unmarshallFont($textData, 'text-font', $textNode->getFont()); } protected function unmarshallCurveObject($curveData, $addObjectsNode) { if (($curveData->{'curve-name'} == '') || !isset($curveData->{'curve-serie-id'})) return; $curveNode = $addObjectsNode->addCurveObject(); $curveNode->setSerieId($curveData->{'curve-serie-id'}); $curveNode->getFunction()->setFunctionName($curveData->{'curve-name'}); foreach ($curveData->{'params'} as $paramData) $curveNode->getFunction()->addAttribute($paramData->{'curve-param-name'}, $paramData->{'curve-param-value'}); //Curve options $this->unmarshallCurve($curveData, "curve-line", $curveNode); } protected function unmarshallFills($panelData, $fillsNode) { foreach ($panelData->{'fills'} as $fillData) { //Serie / Constant if ($fillData->{'fill-type'} == 'serie-constant') { $fillNode = $fillsNode->addFill(RequestOutputPlotFillTypeEnum::SERIECONSTANT); $fillNode->setSerieId($fillData->{'fill-firstserie-id'}); $fillNode->setConstantId($fillData->{'fill-constant-id'}); if ($fillData->{'fill-greater-color'} != 'none') $fillNode->setGreaterColor($this->hexColor2KernelColor($fillData->{'fill-greater-color'})); if ($fillData->{'fill-less-color'} != 'none') $fillNode->setLessColor($this->hexColor2KernelColor($fillData->{'fill-less-color'})); } } foreach ($panelData->{'fills'} as $fillData) { //Serie / Serie if ($fillData->{'fill-type'} == 'serie-serie') { $fillNode = $fillsNode->addFill(RequestOutputPlotFillTypeEnum::SERIESERIE); $fillNode->setFirstSerieId($fillData->{'fill-firstserie-id'}); $fillNode->setSecondSerieId($fillData->{'fill-secondserie-id'}); if ($fillData->{'fill-greater-color'} != 'none') $fillNode->setGreaterColor($this->hexColor2KernelColor($fillData->{'fill-greater-color'})); if ($fillData->{'fill-less-color'} != 'none') $fillNode->setLessColor($this->hexColor2KernelColor($fillData->{'fill-less-color'})); } } } protected function unmarshallTitle($inputData, $keyPrefix, $titleNode) { if ($inputData->{$keyPrefix . '-text'} != '') { $titleNode->setText($inputData->{$keyPrefix . '-text'}); } switch ($inputData->{$keyPrefix . '-position'}) { case 'top': $titleNode->setPosition(RequestOutputPlotTitlePosition::TOP); break; case 'bottom': $titleNode->setPosition(RequestOutputPlotTitlePosition::BOTTOM); break; } switch ($inputData->{$keyPrefix . '-alignment'}) { case 'center': $titleNode->setAlign(RequestOutputPlotTitleAlign::CENTER); break; case 'left': $titleNode->setAlign(RequestOutputPlotTitleAlign::LEFT); break; case 'right': $titleNode->setAlign(RequestOutputPlotTitleAlign::RIGHT); break; } if ($inputData->{$keyPrefix . '-color'} != '') $titleNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix . '-color'})); $this->unmarshallLabel($inputData, $keyPrefix, $titleNode); } protected function unmarshallLabel($inputData, $keyPrefix, $labelNode) { if ($inputData->{$keyPrefix . '-font-activated'}) { $labelNode->setFontName($inputData->{$keyPrefix . '-font-name'}); $labelNode->setFontSize($inputData->{$keyPrefix . '-font-size'}); if ($inputData->{$keyPrefix . '-font-bold'}) { $labelNode->setFontWeight("bold"); } if ($inputData->{$keyPrefix . '-font-italic'}) { $labelNode->setFontStyle("italic"); } } } protected function unmarshallFont($inputData, $keyPrefix, $fontNode) { if ($inputData->{$keyPrefix . '-activated'}) { $fontNode->setFontName($inputData->{$keyPrefix . '-name'}); $fontNode->setSize($inputData->{$keyPrefix . '-size'}); if ($inputData->{$keyPrefix . '-italic'}) $fontNode->setStyle(RequestOutputPlotFontStyle::ITALIC); else $fontNode->setStyle(RequestOutputPlotFontStyle::UPRIGHT); if ($inputData->{$keyPrefix . '-bold'}) $fontNode->setWeight(RequestOutputPlotFontWeight::BOLD); else $fontNode->setWeight(RequestOutputPlotFontWeight::MEDIUM); } } protected function unmarshallCurve($inputData, $keyPrefix, $curveNode) { switch ($inputData->{$keyPrefix . '-style'}) { case 'dot': $curveNode->setStyle(RequestOutputPlotCurveStyleEnum::DOT); break; case 'long-spaced-dot': $curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSPACEDDOT); break; case 'long-short-dot': $curveNode->setStyle(RequestOutputPlotCurveStyleEnum::LONGSHORTDOT); break; case 'plain': default: $curveNode->setStyle(RequestOutputPlotCurveStyleEnum::PLAIN); break; } if (isset($inputData->{$keyPrefix . '-width'})) $curveNode->setWidth($inputData->{$keyPrefix . '-width'}); if (isset($inputData->{$keyPrefix . '-color'}) && ($inputData->{$keyPrefix . '-color'} != 'auto')) $curveNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix . '-color'})); } protected function unmarshallLine($inputData, $keyPrefix, $lineNode, $lineType) { $lineNode->setType($lineType); $this->unmarshallCurve($inputData, $keyPrefix . "-lines", $lineNode); } protected function unmarshallSymbol($inputData, $keyPrefix, $symbolNode) { switch ($inputData->{$keyPrefix . '-type'}) { case 'dot': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOT); break; case 'plus': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::PLUS); break; case 'wildcard': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::WILDCARD); break; case 'circle': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CIRCLE); break; case 'crux': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUX); break; case 'square': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::SQUARE); break; case 'triangle': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::TRIANGLE); break; case 'crux-in-circle': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::CRUXINCIRCLE); break; case 'dot-in-circle': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DOTINCIRCLE); break; case 'diamond': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DIAMOND); break; case 'star': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::STAR); break; case 'david-star': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::DAVIDSTAR); break; case 'full-square': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSQUARE); break; case 'full-circle': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLCIRCLE); break; case 'full-star': $symbolNode->setType(RequestOutputPlotSymbolTypeEnum::FULLSTAR); break; default: throw new Exception('Symbol type not implemented.'); } $symbolNode->setSize($inputData->{$keyPrefix . '-size'}); if ($inputData->{$keyPrefix . '-color'} != 'auto') $symbolNode->setColor($this->hexColor2KernelColor($inputData->{$keyPrefix . '-color'})); } /* * @brief method to marshall the result of a download request */ protected function marshallResult($data) { if (!$this->isInteractiveRequest) { //add to job $commonRes = $this->commonMarshallResult($data, PLOT_RESULT_FILE_KEY); return $commonRes; } //Interactive request if (!$data->getSuccess()) return array( 'success' => false, 'message' => $data->getLastErrorMessage() ); switch ($data->getStatus()) { case ProcessStatusEnumClass::DONE: $result = array(); foreach ($data->getWaitingResults() as $key => $waitingResult) { $contextResult = str_replace(".png", "_context.xml", $waitingResult); $result[] = array( "id" => $key, "title" => $this->interactivePlotTitle[$key], "preview" => $this->interactivePreview, "isInterval" => $this->interactiveTimeSelectionState[$key], "index" => $this->interactivePlotIndex[$key], "ttFileIndex" => $this->interactiveCrtTTFileIndex, "context" => IHMPlotContextFileClass::parse($this->getWorkingPath() . $contextResult), "plot" => $waitingResult, "exectime" => $data->getExecTime(), "multiplot" => $this->isMultiPlot, ); } return array( 'success' => true, 'id' => $data->getId(), 'folder' => $this->getWorkingDirName(), 'result' => $result ); case ProcessStatusEnumClass::KILLED: return array( 'success' => true, 'killed' => true ); default: $errorMsg = $data->getErrorMsg(); return array( 'success' => false, 'message' => 'Request processing error' . (!empty($errorMsg) ? "
(" . $errorMsg . ")" : "") ); } } private function hexColor2KernelColor($hex) { $hex = str_replace("#", "", $hex); $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); return "[" . $r . "," . $g . "," . $b . "]"; } protected function saveIHMRequest($interactiveId, $input) { $path = $this->getWorkingPath() . "ihm.request." . $interactiveId; if (!is_dir($this->getWorkingPath())) mkdir($this->getWorkingPath(), 0777); $file = fopen($path, 'w'); fwrite($file, json_encode($input)); fclose($file); } protected function loadIHMRequest($interactiveId) { $path = $this->getWorkingPath() . "ihm.request." . $interactiveId; if (!file_exists($path)) return NULL; return json_decode(file_get_contents($path)); } private function loadZoomList($interactiveId) { $path = $this->getWorkingPath() . "zoom.list." . $interactiveId; if (!file_exists($path)) return NULL; return json_decode(file_get_contents($path)); } private function saveZoomList($interactiveId, $zoomList) { $path = $this->getWorkingPath() . "zoom.list." . $interactiveId; if (!is_dir($this->getWorkingPath())) mkdir($this->getWorkingPath(), 0777); $file = fopen($path, 'w'); fwrite($file, json_encode($zoomList)); fclose($file); } private function unmarshallActionRequest($input) { $actionInput = $input->{'action'}; $plotInput = $this->loadIHMRequest($actionInput->{'interactiveId'}); if (!isset($plotInput)) throw new Exception('Cannot retrieve request input for interactive action.'); switch ($actionInput->{'action'}) { case 'zoom': return $this->unmarshallZoom($actionInput, $plotInput); case 'forward': case 'halfforward': case 'quarterforward': case 'backward': case 'halfbackward': case 'quarterbackward': case 'extend': case 'shift': return $this->unmarshallNavigation($actionInput, $plotInput); case 'goto': return $this->unmarshallTTGoto($actionInput, $plotInput); case 'instant': return $this->unmarshallInstant($actionInput, $plotInput); case 'undozoom': return $this->unmarshallUndoZoom($actionInput, $plotInput); case RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME: return $this->unmarshallPlotFunction($actionInput, $plotInput); default: throw new Exception('Interactive action not implemented.'); } } private function addZoomInList($input, $isInterval, $minOrFileIndex, $maxOrIntervalIndex) { //if $isInterval == true, $minOrFileIndex is the min and $maxOrInetrvalIndex is the max //if $isInterval == false, $minOrFileIndex is the fileIndex and $maxOrInetrvalIndex is the intervalIndex $zoomList = $this->loadZoomList($input->interactiveId); if (!isset($zoomList)) { //Init zoom list $zoomList = (object)array( 'times' => array(), 'panels' => (object)array() ); } if ($input->{'axeId'} == 'timeAxis') { if ($isInterval) array_push($zoomList->times, (object)array( 'isInterval' => true, 'min' => $minOrFileIndex, 'max' => $maxOrIntervalIndex )); else array_push($zoomList->times, (object)array( 'isInterval' => false, 'ttFileIndex' => $minOrFileIndex, 'intIndex' => $maxOrIntervalIndex )); } else { if (!isset($zoomList->panels->{$input->{'panelId'}})) { $zoomList->panels->{$input->{'panelId'}} = (object) array( 'axes' => (object)array() ); } if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) { $zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}} = array(); } array_push($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}, (object)array( 'min' => $minOrFileIndex, 'max' => $maxOrIntervalIndex )); } $this->saveZoomList($input->interactiveId, $zoomList); } private function resetZoomList($interactiveId, $resetOnlyTimeZoom = false) { if (!$resetOnlyTimeZoom) { $zoomList = (object)array( 'times' => array(), 'panels' => (object)array() ); } else { $zoomList = $this->loadZoomList($interactiveId); $zoomList->times = array(); } $this->saveZoomList($interactiveId, $zoomList); } private function undoZoomInList($input) { $zoomList = $this->loadZoomList($input->interactiveId); $result = NULL; if ($zoomList) { if ($input->{'axeId'} == 'timeAxis') { if (count($zoomList->times) <= 0) return NULL; $result = array_pop($zoomList->times); } else { if (!isset($zoomList->panels->{$input->{'panelId'}})) return NULL; if (!isset($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}})) return NULL; $result = array_pop($zoomList->panels->{$input->{'panelId'}}->axes->{$input->{'axeId'}}); } } else return NULL; $this->saveZoomList($input->interactiveId, $zoomList); return $result; } private function unmarshallZoom($input, $plotInput, $isUndo = false) { if ($input->{'axeId'} == 'timeAxis') { //Zoom on Time Axis if ($plotInput->{'timesrc'} != 'Interval') { $plotInput->{'timesrc'} = 'Interval'; if (!$isUndo) $this->addZoomInList( $input, false, isset($plotInput->{'ttFileIndex'}) ? $plotInput->{'ttFileIndex'} : 0, isset($plotInput->{'intIndex'}) ? $plotInput->{'intIndex'} : 0 ); } else { if (!$isUndo) $this->addZoomInList($input, true, $plotInput->{'startDate'}, $plotInput->{'stopDate'}); } $plotInput->{'startDate'} = $input->{'min'}; $plotInput->{'stopDate'} = $input->{'max'}; $plotInput->{'force-time-zoom-reset'} = false; $this->saveIHMRequest($input->interactiveId, $plotInput); return $plotInput; } //Digital axis zoom foreach ($plotInput->{'panels'} as $panel) { if ($input->{'panelId'} == $panel->{'id'}) { foreach ($panel->{'axes'} as $axis) { if ($input->{'axeId'} == $axis->{'id'}) { $axis->{'axis-range-extend'} = false; $oldMin = $axis->{'axis-range-min'}; $oldMax = $axis->{'axis-range-max'}; $axis->{'axis-range-min'} = $input->{'min'}; $axis->{'axis-range-max'} = $input->{'max'}; $this->saveIHMRequest($input->interactiveId, $plotInput); //Do not save 'force-single-replot' in request file! $plotInput->{'force-single-replot'} = true; $plotInput->{'force-time-zoom-reset'} = false; if (!$isUndo) $this->addZoomInList($input, true, $oldMin, $oldMax); return $plotInput; } } throw new Exception('Cannot retrieve axis for zoom action.'); } } throw new Exception('Cannot retrieve plot panel for zoom action.'); } private function unmarshallUndoZoom($input, $plotInput) { $result = $this->undoZoomInList($input); if ($result != NULL) { if (isset($result->isInterval)) { if (!$result->isInterval) { $input->ttFileIndex = $result->ttFileIndex; $input->intIndex = $result->intIndex; return $this->unmarshallTTGoto($input, $plotInput); } } $input->min = $result->min; $input->max = $result->max; return $this->unmarshallZoom($input, $plotInput, true); } throw new Exception('No undo zoom to apply.'); } private function unmarshallNavigation($input, $plotInput) { $startTime = $plotInput->{'startDate'}; $stopTime = $plotInput->{'stopDate'}; //Compute new start / stop time date_default_timezone_set('UTC'); $startTimeStamp = strtotime($startTime); $stopTimeStamp = strtotime($stopTime); $duration = $stopTimeStamp - $startTimeStamp; switch ($input->{'action'}) { case 'forward': $startTimeStamp += $duration; $stopTimeStamp += $duration; break; case 'halfforward': $startTimeStamp += ($duration / 2); $stopTimeStamp += ($duration / 2); break; case 'quarterforward': $startTimeStamp += ($duration / 4); $stopTimeStamp += ($duration / 4); break; case 'backward': $startTimeStamp -= $duration; $stopTimeStamp -= $duration; break; case 'halfbackward': $startTimeStamp -= ($duration / 2); $stopTimeStamp -= ($duration / 2); break; case 'quarterbackward': $startTimeStamp -= ($duration / 4); $stopTimeStamp -= ($duration / 4); break; case 'extend': $startTimeStamp -= $input->{'duration'}; $stopTimeStamp += $input->{'duration'}; break; case 'shift': $startTimeStamp += $input->{'duration'}; $stopTimeStamp += $input->{'duration'}; break; } if ($stopTimeStamp - $startTimeStamp <= 0) throw new Exception('New duration is lower than 0.'); $startTime = date("Y-m-d\TH:i:s", $startTimeStamp); $stopTime = date("Y-m-d\TH:i:s", $stopTimeStamp); //Update request $plotInput->{'startDate'} = $startTime; $plotInput->{'stopDate'} = $stopTime; $plotInput->{'force-time-zoom-reset'} = true; $this->saveIHMRequest($input->interactiveId, $plotInput); return $plotInput; } private function unmarshallTTGoto($input, $plotInput) { $plotInput->{'timesrc'} = 'TimeTable'; $plotInput->{'ttFileIndex'} = $input->{'ttFileIndex'}; $plotInput->{'intIndex'} = $input->{'intIndex'}; $plotInput->{'force-time-zoom-reset'} = true; $this->saveIHMRequest($input->interactiveId, $plotInput); return $plotInput; } private function unmarshallInstant($input, $plotInput) { //Find current panel $crtPanel = NULL; foreach ($plotInput->{'panels'} as $panel) { if ($input->{'panelId'} == $panel->{'id'}) { $crtPanel = $panel; break; } } if (!$crtPanel) throw new Exception('Cannot retrieve plot panel for instant plot.'); if ($crtPanel->{'panel-plot-type'} != 'timePlot') throw new Exception('Instant plot action only available for Time plot.'); //Find spectra parameter $crtParam = NULL; foreach ($crtPanel->{'params'} as $param) { if ($param->{'param-drawing-type'} == 'spectro') { $crtParam = $param; break; } } if (!$crtParam) throw new Exception('Cannot retrieve plot param for instant plot.'); //Find table Y-axis $crtYAxis = NULL; foreach ($crtPanel->{'axes'} as $axis) { if ($crtParam->{'param-drawing-object'}->{'spectro-yaxis'} == $axis->{'id'}) { $crtYAxis = $axis; break; } } if (!$crtYAxis) throw new Exception('Cannot retrieve plot y Axis for instant plot.'); //Find color Z-axis $crtColorAxis = NULL; foreach ($crtPanel->{'axes'} as $axis) { if ($axis->{'id'} == 'color') { $crtColorAxis = $axis; break; } } if (!$crtColorAxis) throw new Exception('Cannot retrieve plot color Axis for instant plot.'); date_default_timezone_set('UTC'); $timeStamp = strtotime($input->time); $instantPlotInput = (object)array( "interactive-preview" => true, "file-format" => "PNG", "file-output" => "INTERACTIVE", "file-prefix" => "instant", "timesrc" => "Interval", "startDate" => date("Y-m-d\TH:i:s", $timeStamp - 3600), "stopDate" => date("Y-m-d\TH:i:s", $timeStamp + 3600), "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() ); $instantPanel = (object)array( "id" => "1", "panel-plot-type" => "instantPlot", "panel-instant-time" => $input->time, "panel-title-font-activated" => TRUE, "panel-title-font-size" => 12, "panel-title-font-bold" => TRUE, "axes" => array(), "params" => array(), ); $instantXAxis = (object)array( "id" => "xaxis_id", "axis-type" => "x", "axis-scale" => $crtYAxis->{"axis-scale"}, "axis-thickness" => 1, "axis-legend-font-activated" => TRUE, "axis-legend-font-size" => 12, "axis-legend-font-bold" => TRUE, "axis-range-min" => $crtYAxis->{"axis-range-min"}, "axis-range-max" => $crtYAxis->{"axis-range-max"}, "axis-reverse" => $crtYAxis->{"axis-reverse"}, ); $instantYAxis = (object)array( "id" => "y-left", "axis-type" => "y-left", "axis-scale" => $crtColorAxis->{"axis-scale"}, "axis-thickness" => 1, "axis-legend-font-activated" => TRUE, "axis-legend-font-size" => 12, "axis-legend-font-bold" => TRUE, "axis-range-min" => $crtColorAxis->{"axis-range-min"}, "axis-range-max" => $crtColorAxis->{"axis-range-max"}, "axis-reverse" => $crtColorAxis->{"axis-reverse"}, ); $instantPanel->{"axes"}[] = $instantXAxis; $instantPanel->{"axes"}[] = $instantYAxis; $instantParam = (object)array( "id" => 1, "paramid" => $crtParam->{'paramid'}, "template_args" => $crtParam->{'template_args'}, "param-drawing-type" => "iserie", "param-drawing-object" => (object)array( "iserie-tableonx" => true, "iserie-lines-activated" => true, "iserie-lines-style" => "plain", "iserie-lines-width" => 3, "iserie-lines-color" => "#0000ff" ), "dim1-index" => $crtParam->{'dim1-index'}, "dim1-sum-type" => $crtParam->{'dim1-sum-type'}, "dim1-min-value" => $crtParam->{'dim1-min-value'}, "dim1-max-value" => $crtParam->{'dim1-max-value'}, "dim1-min-index" => $crtParam->{'dim1-min-index'}, "dim1-max-index" => $crtParam->{'dim1-max-index'}, "dim2-index" => $crtParam->{'dim2-index'}, "dim2-sum-type" => $crtParam->{'dim2-sum-type'}, "dim2-min-value" => $crtParam->{'dim2-min-value'}, "dim2-max-value" => $crtParam->{'dim2-max-value'}, "dim2-min-index" => $crtParam->{'dim2-min-index'}, "dim2-max-index" => $crtParam->{'dim2-max-index'}, "type" => $crtParam->{'type'} ); $instantPanel->{"params"}[] = $instantParam; $instantPlotInput->{"panels"}[] = $instantPanel; return $instantPlotInput; } /** * Set preview font style to given axis */ private function setPlotPreviewFont($axis){ $axis->{"axis-legend-font-activated"} = TRUE; $axis->{"axis-legend-font-size"} = 12; $axis->{"axis-legend-font-bold"} = TRUE; } private function unmarshallPlotFunction($input, $plotInput) { date_default_timezone_set('UTC'); $plotInput->{"startDate"} =$input->starttime; $plotInput->{"stopDate"} = $input->stoptime; $plotInput->{"file-prefix"} = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME; $plotInput->{"interactive-preview"} = true; $plotInput->{"file-format"} = "PNG"; $plotInput->{"file-output"} = "INTERACTIVE"; $plotInput->{"page-layout-type"} = "vertical"; $plotInput->{"page-layout-object"} = (object)array( "layout-expand" => true, "layout-panel-height" => 0.5, "layout-panel-spacing" => 0.05 ); $panels = []; foreach ($plotInput->{'panels'} as $input_panel) { if ($input->{'panelId'} == $input_panel->{'id'}) { $panel = $input_panel; if ($panel->{'panel-plot-type'} !== 'timePlot') throw new Exception('Plot Function action only available for Time plot.'); $panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_ABSCISSE} = $input->abscisse; $panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TYPE} = $input->type; $scale_abscisse = $input->scale_abscisse; $scale_ordonnee = $input->scale_ordonnee; $panel->{'panel-plot-type'} = RequestOutPutPlotElementPlotFunctionNodeClass::REQUESTOUTPUTPLOTELEMENT_PLOTFUNCTION_NAME; $panel->{"panel-title-font-activated"} = TRUE; $panel->{"panel-title-font-size"} = 12; $panel->{"panel-title-font-bold"} = TRUE; /** * @var object $crtParam */ $crtParam = NULL; $isSpectro = false; //Find serie/spectra parameter foreach ($panel->{'params'} as $param) { if ($param->{'param-drawing-type'} == 'spectro') { $crtParam = $param; $isSpectro = true; break; } if ($param->{'param-drawing-type'} == 'serie') { $crtParam = $param; break; } } if ($isSpectro && RequestOutPutPlotElementPlotFunctionNodeClass::isFourier($input->type)) throw new Exception('Cannot apply FFT/DFT on Spectro.'); if (!$crtParam) throw new Exception('Cannot retrieve panel parameters for Plot function.'); //Find X-axis $crtXAxis = NULL; foreach ($panel->{'axes'} as $axis) { if ("time" == $axis->{'id'}) { $crtXAxis = $axis; break; } } //Find Y-axis $crtYAxis = NULL; foreach ($panel->{'axes'} as $axis) { if ($crtParam->{'param-drawing-object'}->{'spectro-yaxis'} == $axis->{'id'}) { $crtYAxis = $axis; break; } if ($crtParam->{'param-drawing-object'}->{'serie-yaxis'} == $axis->{'id'}) { $crtYAxis = $axis; break; } } if (!$crtYAxis) throw new Exception('Cannot retrieve y Axis for Plot Function.'); //Find color Z-axis $crtColorAxis = NULL; foreach ($panel->{'axes'} as $axis) { if ($axis->{'id'} == 'color') { $crtColorAxis = $axis; break; } } if ($isSpectro && !$crtColorAxis) throw new Exception('Cannot retrieve color Axis for Plot function.'); $panel->{"axes"} = []; /** * @var object $plotFctXAxisDigital, digital x axis for plot function, used for spectro and Fourier */ $plotFctXAxisDigital = NULL; /** * @var object $plotFctXAxisTime, this axis is used only for Series */ $plotFctXAxisTime = clone ($crtXAxis); $plotFctXAxisTime->{"id"} = RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_TIMEAXIS_ID; /** * @var object $plotFctYAxis, y axis for plot fucntion */ $plotFctYAxis = clone ($crtYAxis); if ($isSpectro) { $plotFctXAxisDigital = clone ($crtYAxis); $plotFctXAxisDigital->{"id"} = RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_DIGITALAXIS_ID; $plotFctXAxisDigital->{"axis-type"} = "x"; if (RequestOutPutPlotElementPlotFunctionNodeClass::isFourier($input->type)) $plotFctXAxisDigital->{'axis-legend-text'} = RequestOutPutPlotElementPlotFunctionNodeClass::getTextLegend($input->abscisse); $plotFctYAxis = clone ($crtColorAxis); $plotFctYAxis->{"id"} = RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_YAXIS_ID; $plotFctYAxis->{"axis-type"} = RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_YAXIS_ID; $panel->{"axes"}[] = $plotFctXAxisDigital; $panel->{"axes"}[] = $plotFctYAxis; $panel->{"axes"}[] = $plotFctXAxisTime; } else { $panel->{"axes"}[] = $plotFctXAxisTime; $panel->{"axes"}[] = $plotFctYAxis; if (RequestOutPutPlotElementPlotFunctionNodeClass::isFourier($input->type)) { $plotFctXAxisDigital = clone ($crtXAxis); $plotFctXAxisDigital->{"id"} = RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_DIGITALAXIS_ID; $plotFctXAxisDigital->{"axis-type"} = "x"; $plotFctXAxisDigital->{'axis-legend-text'} = RequestOutPutPlotElementPlotFunctionNodeClass::getTextLegend($input->abscisse); $plotFctYAxis->{'axis-legend-text'} = ""; $panel->{"axes"}[] = $plotFctXAxisDigital; } } $this->setPlotPreviewFont($plotFctXAxisDigital); $this->setPlotPreviewFont($plotFctYAxis); $this->setPlotPreviewFont($plotFctXAxisTime); /** * In this block, I will update the axis scale depending on the user choice hosted in thess variables $scale_abscisse and scale_ordonnee. * If 'Inherites' is selected then the scale of axis of the current time plot are used. */ if ($scale_abscisse == RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_IHERITS) $scale_abscisse = $plotFctXAxisDigital->{"axis-scale"}; else $plotFctXAxisDigital->{"axis-scale"} = $scale_abscisse; if ($scale_ordonnee == RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_IHERITS) $scale_ordonnee = $plotFctYAxis->{"axis-scale"}; else $plotFctYAxis->{"axis-scale"} = $scale_ordonnee; $panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ABSCISSE} = $scale_abscisse; $panel->{RequestOutPutPlotElementPlotFunctionNodeClass::PLOT_FUNCTION_SCALE_ORDONNEE} = $scale_ordonnee; $panels[]= $panel; break; } } $plotInput->{'panels'} = $panels; return $plotInput; } }