Commit 17f69bd1f5ad59bc396f3d686fded22c2f9ded7d

Authored by Benjamin Renard
1 parent 4ede4320

Add tick plot and status plot integration

install/testParams/newKernelDDBase/qual1_sta.xml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <param xml:id="qual1_sta">
  3 + <info>
  4 + <name>StA, Quality_MAG</name>
  5 + <short_name>StA, Quality_MAG</short_name>
  6 + <components></components>
  7 + <units></units>
  8 + <coordinates_system></coordinates_system>
  9 + <tensor_order>0</tensor_order>
  10 + <si_conversion></si_conversion>
  11 + <fill_value>-1.0e+31</fill_value>
  12 + <ucd></ucd>
  13 + <status_def>
  14 + <status minVal="0" maxVal="0" name="Outside"/>
  15 + <status minVal="1" maxVal="1" name="Inside"/>
  16 + </status_def>
  17 + <dataset_id></dataset_id>
  18 + </info>
3 19 <get>
4 20  
5   - <vi name="sta:swea:mom"><baseParam name="Quality1">
  21 + <vi name="sta:swea:mom"><baseParam name="Quality1" useNearestValue="true">
6 22  
7 23 </baseParam></vi></get>
8 24 <process/>
9 25 <output/>
10 26 </param>
  27 +
... ...
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... ... @@ -30,12 +30,6 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
30 30 $paramsNode = $requestNode->getParamsNode();
31 31  
32 32 //unmarshall time definition
33   -
34   - //BRE - For debug - TO ERASE
35   - $input->{'startDate'} = '2005-01-30T00:00:18';
36   - $input->{'stopDate'} = '2005-02-01T00:00:15';
37   -
38   -
39 33 $this->unmarshallTimeDefinition($input, $requestIndex);
40 34  
41 35 $plotOutputNode = $outputsNode->addNewOutput(RequestOutputTypeEnum::PLOT);
... ... @@ -207,12 +201,44 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
207 201 //Plot type
208 202 $plotNode = $this->unmarshallPlotType($panelData, $panelNode);
209 203  
  204 + //Tick plot
  205 + $tickPlotNode = NULL;
  206 + if ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTIME_NAME)
  207 + {
  208 + if ($this->hasTickBar($panelData->{'params'}))
  209 + {
  210 + $tickPlotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TICKPLOT,true);
  211 + if ($panelData->{'panel-tick-format'} != '')
  212 + $tickPlotNode->setFormat($panelData->{'panel-tick-format'});
  213 + }
  214 + }
  215 +
  216 + //Status plot
  217 + $statusPlotNode = NULL;
  218 + if ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTIME_NAME)
  219 + {
  220 + if ($this->hasStatusBar($panelData->{'params'}))
  221 + {
  222 + $statusPlotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::STATUSPLOT,true);
  223 + switch ($panelData->{'panel-status-position'})
  224 + {
  225 + case 'top' :
  226 + $statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP);
  227 + break;
  228 + case 'bottom' :
  229 + $statusPlotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM);
  230 + break;
  231 + }
  232 + $statusPlotNode->setColorMap($panelData->{'panel-status-colormap'});
  233 + }
  234 + }
  235 +
210 236 //Axes
211 237 foreach ($panelData->{'axes'} as $axisData)
212 238 $this->unmarshallAxis($axisData, $plotNode);
213 239  
214 240 //Params
215   - $this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode);
  241 + $this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode);
216 242  
217 243 return $panelNode;
218 244 }
... ... @@ -227,6 +253,24 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
227 253 case 'xyPlot' :
228 254 $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::XYPLOT);
229 255 break;
  256 + case 'statusPlot' :
  257 + $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::STATUSPLOT);
  258 + switch ($panelData->{'panel-status-position'})
  259 + {
  260 + case 'top' :
  261 + $plotNode->setPosition(RequestOutputPlotElementStatusPosition::TOP);
  262 + break;
  263 + case 'bottom' :
  264 + $plotNode->setPosition(RequestOutputPlotElementStatusPosition::BOTTOM);
  265 + break;
  266 + }
  267 + $plotNode->setColorMap($panelData->{'panel-status-colormap'});
  268 + break;
  269 + case 'tickPlot' :
  270 + $plotNode = $panelNode->addPlotElement(RequestOutputPlotElementTypeEnum::TICKPLOT);
  271 + if ($panelData->{'panel-tick-format'} != '')
  272 + $plotNode->setFormat($panelData->{'panel-tick-format'});
  273 + break;
230 274 default:
231 275 throw new Exception('Plot type not implemented.');
232 276 }
... ... @@ -314,7 +358,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
314 358 $this->unmarshallLabel($axisData, "axis-legend", $axisNode->getLegend());
315 359 }
316 360  
317   - protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode)
  361 + protected function unmarshallParams($paramsData, $requestParamsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode)
318 362 {
319 363 //X parameters
320 364 $isScatter = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTXY_NAME);
... ... @@ -354,7 +398,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
354 398 //Param
355 399 $paramInfo = $this->paramManager->addExistingParam($paramData->{'param-id'},$this->paramsData);
356 400 $requestParamsNode->addParam($paramInfo['id']);
357   - $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
  401 +
358 402  
359 403 $colorSerieId = -1;
360 404 if ($paramData->{'param-drawing-object'}->{'serie-colored-param'} != '')
... ... @@ -363,11 +407,29 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
363 407 switch ($paramData->{'param-drawing-type'})
364 408 {
365 409 case 'serie' :
  410 + $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
366 411 $this->unmarshallYSerie($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes'], $isScatter && ($paramData->{'param-drawing-object'}->{'serie-xaxis-param'} != ''), $colorSerieId);
367 412 break;
368 413 case 'spectro' :
  414 + $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
369 415 $this->unmarshallSpectro($paramData->{'param-drawing-object'}, $plotNode, $paramNode, $paramInfo['indexes']);
370 416 break;
  417 + case 'status-bar' :
  418 + if (($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTSTATUS_NAME) && !isset($statusPlotNode))
  419 + $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
  420 + else
  421 + $paramNode = $statusPlotNode->getParams()->getParamById($paramInfo['id']);
  422 +
  423 + $this->unmarshallStatusBar($paramData->{'param-drawing-object'}, $paramNode, $paramInfo['indexes']);
  424 + break;
  425 + case 'tick-bar' :
  426 + if (($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTICK_NAME) && !isset($tickPlotNode))
  427 + $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']);
  428 + else
  429 + $paramNode = $tickPlotNode->getParams()->getParamById($paramInfo['id']);
  430 +
  431 + $this->unmarshallTickBar($paramData->{'param-drawing-object'}, $paramNode, $paramInfo['indexes']);
  432 + break;
371 433 default :
372 434 throw new Exception('Drawing type not implemented.');
373 435 }
... ... @@ -433,6 +495,38 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
433 495 $spectroNode = $paramNode->addSpectro($paramDrawingData->{'spectro-yaxis'});
434 496 }
435 497  
  498 + protected function unmarshallStatusBar($paramDrawingData, $paramNode, $indexes)
  499 + {
  500 + if (count($indexes) == 0)
  501 + $paramNode->addStatusBar(-1);
  502 + foreach ($indexes as $index)
  503 + $paramNode->addStatusBar($index);
  504 + }
  505 +
  506 + protected function unmarshallTickBar($paramDrawingData, $paramNode, $indexes)
  507 + {
  508 + if (count($indexes) == 0)
  509 + $paramNode->addTickBar(-1);
  510 + foreach ($indexes as $index)
  511 + $paramNode->addTickBar($index);
  512 + }
  513 +
  514 + protected function hasStatusBar($paramsData)
  515 + {
  516 + foreach ($paramsData as $paramData)
  517 + if ($paramData->{'param-drawing-type'} == 'status-bar')
  518 + return true;
  519 + return false;
  520 + }
  521 +
  522 + protected function hasTickBar($paramsData)
  523 + {
  524 + foreach ($paramsData as $paramData)
  525 + if ($paramData->{'param-drawing-type'} == 'tick-bar')
  526 + return true;
  527 + return false;
  528 + }
  529 +
436 530 protected function unmarshallTitle($inputData, $keyPrefix, $titleNode)
437 531 {
438 532 if ($inputData->{$keyPrefix.'-text'} != '')
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAxesNodeClass.php
... ... @@ -23,13 +23,16 @@ abstract class RequestOutputPlotAxisTypeEnum
23 23 */
24 24 class RequestOutputPlotAxesNodeClass extends NodeClass
25 25 {
26   - public function __construct()
  26 + public function __construct($noXAxis, $noYAxis, $noZAxis)
27 27 {
28 28 parent::__construct(REQUESTOUTPUTPLOTAXES_NAME);
29 29 //create skeleton
30   - $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_XAXIS, true);
31   - $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_YAXIS, true);
32   - $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_ZAXIS, true);
  30 + if (!$noXAxis)
  31 + $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_XAXIS, true);
  32 + if (!$noYAxis)
  33 + $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_YAXIS, true);
  34 + if (!$noZAxis)
  35 + $node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_ZAXIS, true);
33 36 }
34 37  
35 38 public function addDigitalAxis($axisType,$id)
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotElementNodeClass.php
... ... @@ -13,7 +13,7 @@ require_once(&quot;RequestOutputPlotAxesNodeClass.php&quot;);
13 13 */
14 14 class RequestOutputPlotElementNodeClass extends NodeClass
15 15 {
16   - public function __construct($plotElementName, $defineLegends, $defineAdditionalObjects, $defineFills)
  16 + public function __construct($plotElementName, $defineLegends, $defineAdditionalObjects, $defineFills, $noXAxis, $noYAxis, $noZAxis)
17 17 {
18 18 parent::__construct($plotElementName);
19 19 //create plot element skeleton
... ... @@ -30,9 +30,12 @@ class RequestOutputPlotElementNodeClass extends NodeClass
30 30 $this->addChild($node);
31 31  
32 32 //axes
33   - $node = new RequestOutputPlotAxesNodeClass();
34   - $this->addChild($node);
35   -
  33 + if (!$noXAxis || !$noYAxis || !$noZAxis)
  34 + {
  35 + $node = new RequestOutputPlotAxesNodeClass($noXAxis, $noYAxis, $noZAxis);
  36 + $this->addChild($node);
  37 + }
  38 +
36 39 //ToDo additional objects
37 40 /*if ($defineAdditionalObjects)
38 41 {
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotElementStatusNodeClass.php 0 โ†’ 100644
... ... @@ -0,0 +1,58 @@
  1 +<?php
  2 +
  3 +require_once("RequestOutputPlotElementNodeClass.php");
  4 +
  5 +define ("REQUESTOUTPUTPLOTELEMENTSTATUS_NAME", "statusPlot");
  6 +define ("REQUESTOUTPUTPLOTELEMENTSTATUS_POSITION", "position");
  7 +define ("REQUESTOUTPUTPLOTELEMENTSTATUS_COLORMAP", "colorMapIndex");
  8 +
  9 +abstract class RequestOutputPlotElementStatusPosition
  10 +{
  11 + const TOP = "top";
  12 + const BOTTOM = "bottom";
  13 +}
  14 +
  15 +/**
  16 + * @class RequestOutputPlotElementStatusNodeClass
  17 + * @brief Definition of a status plot element for a panel of a plot request
  18 + * @details
  19 +*/
  20 +class RequestOutputPlotElementStatusNodeClass extends RequestOutputPlotElementNodeClass
  21 +{
  22 + public function __construct($noAxis)
  23 + {
  24 + parent::__construct(REQUESTOUTPUTPLOTELEMENTSTATUS_NAME,false,false,false,$noAxis,true,true);
  25 + if (!$noAxis)
  26 + //force time axis creation
  27 + $this->getAxes()->getTimeAxis();
  28 + }
  29 +
  30 + public function getTimeAxis()
  31 + {
  32 + if ($this->getAxes() == NULL)
  33 + return NULL;
  34 + return $this->getAxes()->getTimeAxis();
  35 + }
  36 +
  37 + public function setPosition($position)
  38 + {
  39 + $this->setAttribute(REQUESTOUTPUTPLOTELEMENTSTATUS_POSITION, $position);
  40 + }
  41 +
  42 + public function getPosition()
  43 + {
  44 + return $this->getAttribute(REQUESTOUTPUTPLOTELEMENTSTATUS_POSITION);
  45 + }
  46 +
  47 + public function setColorMap($colorMapIndex)
  48 + {
  49 + $this->setAttribute(REQUESTOUTPUTPLOTELEMENTSTATUS_COLORMAP, $colorMapIndex);
  50 + }
  51 +
  52 + public function getColorMap()
  53 + {
  54 + return $this->getAttribute(REQUESTOUTPUTPLOTELEMENTSTATUS_COLORMAP);
  55 + }
  56 +}
  57 +
  58 +?>
0 59 \ No newline at end of file
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotElementTickNodeClass.php 0 โ†’ 100644
... ... @@ -0,0 +1,41 @@
  1 +<?php
  2 +
  3 +require_once("RequestOutputPlotElementNodeClass.php");
  4 +
  5 +define ("REQUESTOUTPUTPLOTELEMENTTICK_NAME", "tickPlot");
  6 +define ("REQUESTOUTPUTPLOTELEMENTTICK_FORMAT", "format");
  7 +
  8 +/**
  9 + * @class RequestOutputPlotElementTickNodeClass
  10 + * @brief Definition of a tick plot element for a panel of a plot request
  11 + * @details
  12 +*/
  13 +class RequestOutputPlotElementTickNodeClass extends RequestOutputPlotElementNodeClass
  14 +{
  15 + public function __construct($noAxis)
  16 + {
  17 + parent::__construct(REQUESTOUTPUTPLOTELEMENTTICK_NAME,false,false,false,$noAxis,true,true);
  18 + if (!$noAxis)
  19 + //force time axis creation
  20 + $this->getAxes()->getTimeAxis();
  21 + }
  22 +
  23 + public function getTimeAxis()
  24 + {
  25 + if ($this->getAxes() == NULL)
  26 + return NULL;
  27 + return $this->getAxes()->getTimeAxis();
  28 + }
  29 +
  30 + public function setFormat($format)
  31 + {
  32 + $this->setAttribute(REQUESTOUTPUTPLOTELEMENTTICK_FORMAT, $format);
  33 + }
  34 +
  35 + public function getFormat()
  36 + {
  37 + return $this->getAttribute(REQUESTOUTPUTPLOTELEMENTTICK_FORMAT);
  38 + }
  39 +}
  40 +
  41 +?>
0 42 \ No newline at end of file
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotElementTimeNodeClass.php
... ... @@ -13,7 +13,7 @@ class RequestOutputPlotElementTimeNodeClass extends RequestOutputPlotElementNode
13 13 {
14 14 public function __construct()
15 15 {
16   - parent::__construct(REQUESTOUTPUTPLOTELEMENTTIME_NAME,true,true,true);
  16 + parent::__construct(REQUESTOUTPUTPLOTELEMENTTIME_NAME,true,true,true,false,false,false);
17 17 //force time axis creation
18 18 $this->getAxes()->getTimeAxis();
19 19 //force color axis creation
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotElementXYNodeClass.php
... ... @@ -15,7 +15,7 @@ class RequestOutputPlotElementXYNodeClass extends RequestOutputPlotElementNodeCl
15 15 {
16 16 public function __construct()
17 17 {
18   - parent::__construct(REQUESTOUTPUTPLOTELEMENTXY_NAME,true,true,false);
  18 + parent::__construct(REQUESTOUTPUTPLOTELEMENTXY_NAME,true,true,false,false,false,false);
19 19 //create x axis
20 20 $this->getAxes()->addDigitalAxis(RequestOutputPlotAxisTypeEnum::XAXIS,REQUESTOUTPUTPLOTELEMENTXY_XAXISID);
21 21 //force color axis creation
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotPanelNodeClass.php
... ... @@ -2,6 +2,8 @@
2 2  
3 3 require_once("RequestOutputPlotElementTimeNodeClass.php");
4 4 require_once("RequestOutputPlotElementXYNodeClass.php");
  5 +require_once("RequestOutputPlotElementStatusNodeClass.php");
  6 +require_once("RequestOutputPlotElementTickNodeClass.php");
5 7  
6 8 define ("REQUESTOUTPUTPLOTPANEL_NAME", "panel");
7 9 define ("REQUESTOUTPUTPLOTPANEL_TITLE", "title");
... ... @@ -11,6 +13,8 @@ abstract class RequestOutputPlotElementTypeEnum
11 13 {
12 14 const TIMEPLOT = "TimePlot";
13 15 const XYPLOT = "XYPlot";
  16 + const STATUSPLOT = "StatusPlot";
  17 + const TICKPLOT = "TickPlot";
14 18 }
15 19  
16 20 /**
... ... @@ -63,11 +67,8 @@ class RequestOutputPlotPanelNodeClass extends NodeClass
63 67 return $node;
64 68 }
65 69  
66   - public function addPlotElement($type)
  70 + public function addPlotElement($type,$noAxes = false)
67 71 {
68   - if ($this->getPlotElement() != NULL)
69   - return $this->getPlotElement();
70   -
71 72 switch ($type)
72 73 {
73 74 case RequestOutputPlotElementTypeEnum::TIMEPLOT :
... ... @@ -76,6 +77,12 @@ class RequestOutputPlotPanelNodeClass extends NodeClass
76 77 case RequestOutputPlotElementTypeEnum::XYPLOT :
77 78 $node = new RequestOutputPlotElementXYNodeClass();
78 79 break;
  80 + case RequestOutputPlotElementTypeEnum::STATUSPLOT :
  81 + $node = new RequestOutputPlotElementStatusNodeClass($noAxes);
  82 + break;
  83 + case RequestOutputPlotElementTypeEnum::TICKPLOT :
  84 + $node = new RequestOutputPlotElementTickNodeClass($noAxes);
  85 + break;
79 86 default :
80 87 return NULL;
81 88 }
... ... @@ -83,16 +90,7 @@ class RequestOutputPlotPanelNodeClass extends NodeClass
83 90 return $node;
84 91 }
85 92  
86   - public function getPlotElement()
87   - {
88   - return $this->getFirstChildByName(REQUESTOUTPUTPLOTPANEL_NAME);
89   - }
90   -
91   - /* ToDo tickPlot */
92   -
93   - /* ToDo backgroundColor */
94 93  
95   - /* ToDo colorMapIndex */
96 94  
97 95 /* ToDo prefered size */
98 96  
... ...
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php
... ... @@ -18,6 +18,12 @@ define (&quot;REQUESTOUTPUTPLOTCOLORSERIE_INDEX&quot;, &quot;index&quot;);
18 18 define ("REQUESTOUTPUTPLOTSPECTRO_NAME", "spectro");
19 19 define ("REQUESTOUTPUTPLOTSPECTRO_YAXIS", "yAxis");
20 20  
  21 +define ("REQUESTOUTPUTPLOTSTATUSBAR_NAME", "serie");
  22 +define ("REQUESTOUTPUTPLOTSTATUSBAR_INDEX", "index");
  23 +
  24 +define ("REQUESTOUTPUTPLOTTICKBAR_NAME", "serie");
  25 +define ("REQUESTOUTPUTPLOTTICKBAR_INDEX", "index");
  26 +
21 27 /**
22 28 * @class RequestOutputPlotParamNodeClass
23 29 * @brief Definition of a param for a plot of a plot request
... ... @@ -81,6 +87,24 @@ class RequestOutputPlotParamNodeClass extends NodeClass
81 87 $this->addChild($colorSerieNode);
82 88 return $colorSerieNode;
83 89 }
  90 +
  91 + public function addStatusBar($index)
  92 + {
  93 + $statusBarNode = new NodeClass(REQUESTOUTPUTPLOTSTATUSBAR_NAME);
  94 + if ($index >= 0)
  95 + $statusBarNode->setAttribute(REQUESTOUTPUTPLOTSTATUSBAR_INDEX, $index);
  96 + $this->addChild($statusBarNode);
  97 + return $statusBarNode;
  98 + }
  99 +
  100 + public function addTickBar($index)
  101 + {
  102 + $tickBarNode = new NodeClass(REQUESTOUTPUTPLOTTICKBAR_NAME);
  103 + if ($index >= 0)
  104 + $tickBarNode->setAttribute(REQUESTOUTPUTPLOTTICKBAR_INDEX, $index);
  105 + $this->addChild($tickBarNode);
  106 + return $tickBarNode;
  107 + }
84 108 }
85 109  
86 110 /**
... ...