diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index 3bfc188..43cce78 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -145,6 +145,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $pageNode->getLayout()->setType(RequestOutputPlotLayoutTypeEnum::VERTICAL); + foreach ($tab->{'panels'} as $panelData) + $this->unmarshallPanel($panelData, $pageNode); + if ($this->isInteractiveRequest) { $resultFile = $filePrefix."_*".$extension; @@ -177,10 +180,125 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $this->paramsData->setBatchEnable(!(($fileFormat == RequestOutputPlotPageFormatEnum::PNG) && $this->isInteractiveRequest)); $this->paramsData->setPostCmd($postProcessCmd); - //determine extension and add post processing if needed return $this->paramsData; } + protected function unmarshallPanel($panelData, $pageNode) + { + $panelNode = $pageNode->addPanel(); + + //Panel background color + if (($panelData->{'panel-background-color'} != 'none') && ($panelData->{'panel-background-color'} != '')) + $panelNode->setBackgroundColor($this->hexColor2KernelColor($panelData->{'panel-background-color'})); + + //Panel font + $this->unmarshallFont($panelData, 'panel', $panelNode->getFont()); + + //Panel title + $this->unmarshallTitle($panelData, 'panel-title', $panelNode->getTitle()); + + //Plot type + $this->unmarshallPlotType($panelData, $panelNode); + + 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); + break; + default: + throw new Exception('Plot type not implemented.'); + } + + //Axes + foreach ($panelData->{'axes'} as $axisData) + $this->unmarshallAxis($axisData, $plotNode); + } + + protected function unmarshallAxis($axisData, $plotNode) + { + //axis type + switch ($axisData->{'axis-type'}) + { + case 'time' : + $axisNode = $plotNode->getTimeAxis(); + $axisNode->setFormat($axisData->{'axis-time-format'}); + break; + case 'epoch' : + $axisNode = $plotNode->getEpochAxis(); + $axisNode->setNormalized($axisData->{'axis-epoch-normalized'} ? "true" : "false"); + break; + case 'x' : + $axisNode = $plotNode->getXAxis(); + break; + case 'y-left' : + $axisNode = $plotNode->addYAxis('y1'); + break; + case 'y-right' : + $axisNode = $plotNode->addYAxis('y2'); + 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 + $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'}); + $axisNode->getRange()->setExtend($axisData->{'axis-range-extend'} ? "true" : "false"); + + //axis color + $axisNode->setColor($this->hexColor2KernelColor($axisData->{'axis-color'})); + + //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 + $axisNode->getTick()->setMinorGrid($axisData->{'axis-grid-minor'} ? "true" : "false"); + $axisNode->getTick()->setMajorGrid($axisData->{'axis-grid-major'} ? "true" : "false"); + + //legend + $axisNode->getLegend()->setText($axisData->{'-text'}); + $this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend()); + } + protected function unmarshallTitle($inputData, $keyPrefix, $titleNode) { if ($inputData->{$keyPrefix.'-text'} != '') diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAxisElementNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAxisElementNodeClass.php index 4d44bc9..46ba2c1 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAxisElementNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAxisElementNodeClass.php @@ -1,15 +1,36 @@ setAttribute(REQUESTOUTPUTPLOTAXISELEMENTTICK_POSITION, $position); + } + + public function getPosition() + { + return $this->getAttribute(REQUESTOUTPUTPLOTAXISELEMENTTICK_POSITION); + } + + public function setMinorGrid($minorGrid) + { + $this->setAttribute(REQUESTOUTPUTPLOTAXISELEMENTTICK_MINORGRID, $minorGrid); + } + + public function getMinorGrid() + { + return $this->getAttribute(REQUESTOUTPUTPLOTAXISELEMENTTICK_MINORGRID); + } + + public function setMajorGrid($majorGrid) + { + $this->setAttribute(REQUESTOUTPUTPLOTAXISELEMENTTICK_MAJORGRID, $majorGrid); + } + + public function getMajorGrid() + { + return $this->getAttribute(REQUESTOUTPUTPLOTAXISELEMENTTICK_MAJORGRID); + } +} + +/** * @class RequestOutputPlotAxisElementLegendNodeClass * @brief Definition of legend for an axis * @details */ -class RequestOutputPlotAxisElementLegendNodeClass extends NodeClass +class RequestOutputPlotAxisElementLegendNodeClass extends RequestOutputPlotLabelNodeClass { public function __construct() { @@ -89,6 +153,10 @@ class RequestOutputPlotAxisElementNodeClass extends NodeClass $node = new RequestOutputPlotAxisElementRangeNodeClass(); $this->addChild($node); + //tick + $node = new RequestOutputPlotAxisElementTickClass(); + $this->addChild($node); + //legend $node = new RequestOutputPlotAxisElementLegendNodeClass(); $this->addChild($node); @@ -99,7 +167,10 @@ class RequestOutputPlotAxisElementNodeClass extends NodeClass return $this->getFirstChildByName(REQUESTOUTPUTPLOTAXISELEMENTRANGE_NAME); } - /* ToDo tick */ + public function getTick() + { + return $this->getFirstChildByName(REQUESTOUTPUTPLOTAXISELEMENTTICK_NAME); + } public function getLegend() { @@ -120,15 +191,47 @@ class RequestOutputPlotAxisElementNodeClass extends NodeClass return $this->getAttribute(REQUESTOUTPUTPLOTAXISELEMENT_POSITION); } - /* ToDo thickness */ + public function setThickness($thickness) + { + $this->setAttribute(REQUESTOUTPUTPLOTAXISELEMENT_THICKNESS, $thickness); + } - /* ToDo ColorGroup */ + public function getThickness() + { + return $this->getAttribute(REQUESTOUTPUTPLOTAXISELEMENT_THICKNESS); + } + + public function setColor($color) + { + $this->setAttribute(REQUESTOUTPUTPLOTAXISELEMENT_COLOR, $color); + } + + public function getColor() + { + return $this->getAttribute(REQUESTOUTPUTPLOTAXISELEMENT_COLOR); + } + + public function setReverse($reverse) + { + $this->setAttribute(REQUESTOUTPUTPLOTAXISELEMENT_REVERSE, $reverse); + } - /* ToDo reverse */ + public function getReverse() + { + return $this->getAttribute(REQUESTOUTPUTPLOTAXISELEMENT_REVERSE); + } /* ToDo visible */ - /* ToDo scale */ + public function setScale($scale) + { + $this->setAttribute(REQUESTOUTPUTPLOTAXISELEMENT_SCALE, $scale); + } + + public function getScale() + { + return $this->getAttribute(REQUESTOUTPUTPLOTAXISELEMENT_SCALE); + } /* ToDo showLegend */ diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotColorAxisNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotColorAxisNodeClass.php index cc1ba1e..63fcfd9 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotColorAxisNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotColorAxisNodeClass.php @@ -5,6 +5,9 @@ require_once("RequestOutputPlotAxisElementNodeClass.php"); define ("REQUESTOUTPUTPLOTCOLORAXIS_NAME", "colorAxis"); define ("REQUESTOUTPUTPLOTCOLORAXIS_ID", "id"); define ("REQUESTOUTPUTPLOTCOLORAXIS_MAPINDEX", "colorMapIndex"); +define ("REQUESTOUTPUTPLOTCOLORAXIS_MINVALCOLOR", "minValColor"); +define ("REQUESTOUTPUTPLOTCOLORAXIS_MAXVALCOLOR", "maxValColor"); + /** * @class RequestOutputPlotColorAxisNodeClass @@ -23,7 +26,26 @@ class RequestOutputPlotColorAxisNodeClass extends RequestOutputPlotAxisElementNo { $this->setAttribute(REQUESTOUTPUTPLOTCOLORAXIS_MAPINDEX, $mapIndex); } - /* ToDo min max valcolor */ + + public function setMinValColor($minValColor) + { + $this->setAttribute(REQUESTOUTPUTPLOTCOLORAXIS_MINVALCOLOR, $minValColor); + } + + public function getMinValColor() + { + return $this->getAttribute(REQUESTOUTPUTPLOTCOLORAXIS_MINVALCOLOR); + } + + public function setMaxValColor($maxValColor) + { + $this->setAttribute(REQUESTOUTPUTPLOTCOLORAXIS_MAXVALCOLOR, $maxValColor); + } + + public function getMaxValColor() + { + return $this->getAttribute(REQUESTOUTPUTPLOTCOLORAXIS_MAXVALCOLOR); + } } ?> \ No newline at end of file diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotEpochAxisNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotEpochAxisNodeClass.php new file mode 100644 index 0000000..48987b0 --- /dev/null +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotEpochAxisNodeClass.php @@ -0,0 +1,31 @@ +setAttribute(REQUESTOUTPUTPLOTEPOCHAXIS_NORMALIZED, $normalized); + } + + public function getNormalized() + { + return $this->getAttribute(REQUESTOUTPUTPLOTEPOCHAXIS_NORMALIZED); + } +} + +?> \ No newline at end of file diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotLabelNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotLabelNodeClass.php new file mode 100644 index 0000000..f71fd7c --- /dev/null +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotLabelNodeClass.php @@ -0,0 +1,72 @@ +setAttribute(REQUESTOUTPUTPLOTLABEL_FONTNAME, $fontName); + } + + public function getFontName() + { + return $this->getAttribute(REQUESTOUTPUTPLOTLABEL_FONTNAME); + } + + public function setFontSize($fontSize) + { + $this->setAttribute(REQUESTOUTPUTPLOTLABEL_FONTSIZE, $fontSize); + } + + public function getFontSize() + { + return $this->getAttribute(REQUESTOUTPUTPLOTLABEL_FONTSIZE); + } + + public function setFontStyle($style) + { + $this->setAttribute(REQUESTOUTPUTPLOTLABEL_STYLE, $style); + } + + public function getFontStyle() + { + return $this->getAttribute(REQUESTOUTPUTPLOTLABEL_STYLE); + } + + public function setColor($color) + { + $this->setAttribute(REQUESTOUTPUTPLOTLABEL_COLOR, $color); + } + + public function getColor() + { + return $this->getAttribute(REQUESTOUTPUTPLOTLABEL_COLOR); + } + + public function setColorMapIndex($colorMapIndex) + { + $this->setAttribute(REQUESTOUTPUTPLOTLABEL_COLORMAPINDEX, $colorMapIndex); + } + + public function getColorMapIndex() + { + return $this->getAttribute(REQUESTOUTPUTPLOTLABEL_COLORMAPINDEX); + } +} + +?> \ No newline at end of file diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPanelNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPanelNodeClass.php index b8776a3..900a48b 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPanelNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPanelNodeClass.php @@ -5,6 +5,7 @@ require_once("RequestOutputPlotElementXYNodeClass.php"); define ("REQUESTOUTPUTPLOTPANEL_NAME", "panel"); define ("REQUESTOUTPUTPLOTPANEL_TITLE", "title"); +define ("REQUESTOUTPUTPLOTPANEL_BACKGROUNDCOLOR", "backgroundColor"); abstract class RequestOutputPlotElementTypeEnum { @@ -22,24 +23,44 @@ class RequestOutputPlotPanelNodeClass extends NodeClass public function __construct() { parent::__construct(REQUESTOUTPUTPLOTPANEL_NAME); - //default attributes - $this->setTitle(""); } + public function setBackgroundColor($color) + { + $this->setAttribute(REQUESTOUTPUTPLOTPANEL_BACKGROUNDCOLOR, $color); + } + + public function getBackgroundColor() + { + return $this->getAttribute(REQUESTOUTPUTPLOTPANEL_BACKGROUNDCOLOR); + } + /* ToDo bounds */ - /* ToDo font */ - - public function setTitle($title) + public function getFont() { - $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTPANEL_TITLE, true); - $node->setValue($title); + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTFONT_NODENAME); + + if (!isset($node)) + { + $node = new RequestOutputPlotFontNodeClass(); + $this->addChild($node); + } + + return $node; } public function getTitle() { - $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTPANEL_TITLE); - return (($node == NULL) ? "" : $node->getValue()); + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTPANEL_TITLE); + + if (!isset($node)) + { + $node = new RequestOutputPlotTitleNodeClass(); + $this->addChild($node); + } + + return $node; } public function addPlotElement($type) diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotTitleNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotTitleNodeClass.php index ffb8e8d..a03e07d 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotTitleNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotTitleNodeClass.php @@ -18,18 +18,12 @@ abstract class RequestOutputPlotTitleAlign define ("REQUESTOUTPUTPLOTTITLE_NAME", "title"); define ("REQUESTOUTPUTPLOTTITLE_POSITION", "position"); define ("REQUESTOUTPUTPLOTTITLE_ALIGN", "align"); -define ("REQUESTOUTPUTPLOTTITLE_FONTNAME", "fontName"); -define ("REQUESTOUTPUTPLOTTITLE_FONTSIZE", "fontSize"); -define ("REQUESTOUTPUTPLOTTITLE_STYLE", "style"); -define ("REQUESTOUTPUTPLOTTITLE_COLOR", "color"); -define ("REQUESTOUTPUTPLOTTITLE_COLORMAPINDEX", "colorMapIndex"); - /** * @class RequestOutputPlotTitleNodeClass * @brief Definition of a title for a plot request * @details */ -class RequestOutputPlotTitleNodeClass extends NodeClass +class RequestOutputPlotTitleNodeClass extends RequestOutputPlotLabelNodeClass { public function __construct() { @@ -65,56 +59,6 @@ class RequestOutputPlotTitleNodeClass extends NodeClass { return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_ALIGN); } - - public function setFontName($fontName) - { - $this->setAttribute(REQUESTOUTPUTPLOTTITLE_FONTNAME, $fontName); - } - - public function getFontName() - { - return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_FONTNAME); - } - - public function setFontSize($fontSize) - { - $this->setAttribute(REQUESTOUTPUTPLOTTITLE_FONTSIZE, $fontSize); - } - - public function getFontSize() - { - return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_FONTSIZE); - } - - public function setFontStyle($style) - { - $this->setAttribute(REQUESTOUTPUTPLOTTITLE_STYLE, $style); - } - - public function getFontStyle() - { - return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_STYLE); - } - - public function setColor($color) - { - $this->setAttribute(REQUESTOUTPUTPLOTTITLE_COLOR, $color); - } - - public function getColor() - { - return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_COLOR); - } - - public function setColorMapIndex($colorMapIndex) - { - $this->setAttribute(REQUESTOUTPUTPLOTTITLE_COLORMAPINDEX, $colorMapIndex); - } - - public function getColorMapIndex() - { - return $this->getAttribute(REQUESTOUTPUTPLOTTITLE_COLORMAPINDEX); - } } ?> \ No newline at end of file diff --git a/test/debug_request.php b/test/debug_request.php index de522be..72f6bec 100644 --- a/test/debug_request.php +++ b/test/debug_request.php @@ -1,6 +1,6 @@ $debug_1); -- libgit2 0.21.2