Commit ab13f26c1c8074398bbee9f73459c20757ef663f
1 parent
51cbca5c
Exists in
master
and in
66 other branches
Add text object plot definition
Showing
4 changed files
with
216 additions
and
8 deletions
Show diff stats
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
@@ -269,9 +269,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | @@ -269,9 +269,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | ||
269 | //Plot type | 269 | //Plot type |
270 | $plotNode = $this->unmarshallPlotType($panelData, $panelNode); | 270 | $plotNode = $this->unmarshallPlotType($panelData, $panelNode); |
271 | 271 | ||
272 | + $isTimePlot = ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTIME_NAME); | ||
273 | + | ||
272 | //Tick plot | 274 | //Tick plot |
273 | $tickPlotNode = NULL; | 275 | $tickPlotNode = NULL; |
274 | - if ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTIME_NAME) | 276 | + if ($isTimePlot) |
275 | { | 277 | { |
276 | if ($this->hasTickBar($panelData->{'params'})) | 278 | if ($this->hasTickBar($panelData->{'params'})) |
277 | { | 279 | { |
@@ -283,7 +285,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | @@ -283,7 +285,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | ||
283 | 285 | ||
284 | //Status plot | 286 | //Status plot |
285 | $statusPlotNode = NULL; | 287 | $statusPlotNode = NULL; |
286 | - if ($plotNode->getName() == REQUESTOUTPUTPLOTELEMENTTIME_NAME) | 288 | + if ($isTimePlot) |
287 | { | 289 | { |
288 | if ($this->hasStatusBar($panelData->{'params'})) | 290 | if ($this->hasStatusBar($panelData->{'params'})) |
289 | { | 291 | { |
@@ -308,6 +310,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | @@ -308,6 +310,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | ||
308 | //Params | 310 | //Params |
309 | $this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode); | 311 | $this->unmarshallParams($panelData->{'params'}, $paramsNode, $plotNode, $panelNode, $statusPlotNode, $tickPlotNode); |
310 | 312 | ||
313 | + //Additional objects | ||
314 | + if ($plotNode->getAdditionalObjects() != NULL) | ||
315 | + $this->unmarshallAdditionalObjects($panelData, $plotNode->getAdditionalObjects(), $isTimePlot); | ||
316 | + | ||
311 | return $panelNode; | 317 | return $panelNode; |
312 | } | 318 | } |
313 | 319 | ||
@@ -817,6 +823,67 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | @@ -817,6 +823,67 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | ||
817 | $this->unmarshallCurve($constantData, "constant-line", $constantNode); | 823 | $this->unmarshallCurve($constantData, "constant-line", $constantNode); |
818 | } | 824 | } |
819 | 825 | ||
826 | + protected function unmarshallAdditionalObjects($panelData, $addObjectsNode, $isTimePlot) | ||
827 | + { | ||
828 | + foreach ($panelData->{'textObjs'} as $textData) | ||
829 | + $this->unmarshallTextObject($textData, $addObjectsNode, $isTimePlot); | ||
830 | + } | ||
831 | + | ||
832 | + protected function unmarshallTextObject($textData, $addObjectsNode, $isTimePlot) | ||
833 | + { | ||
834 | + $textNode = $addObjectsNode->addTextObject(); | ||
835 | + | ||
836 | + $textNode->setText($textData->{'text-value'}); | ||
837 | + | ||
838 | + switch ($textData->{'text-y-axis'}) | ||
839 | + { | ||
840 | + case 'y-right' : | ||
841 | + $textNode->setYAxis('y-right'); | ||
842 | + break; | ||
843 | + case 'y-left' : | ||
844 | + $textNode->setYAxis('y-left'); | ||
845 | + break; | ||
846 | + } | ||
847 | + | ||
848 | + if ($isTimePlot && !$textData->{'text-x-relative'}) | ||
849 | + { | ||
850 | + date_default_timezone_set('UTC'); | ||
851 | + $timeStamp = strtotime($textData->{'text-x-timevalue'}); | ||
852 | + $time = CommonClass::timeStampToDDTime($timeStamp); | ||
853 | + $textNode->setX($time); | ||
854 | + } | ||
855 | + else if ($textData->{'text-x-relative'}) | ||
856 | + $textNode->setX(($textData->{'text-x-floatvalue'}*100)."%"); | ||
857 | + else | ||
858 | + $textNode->setX($textData->{'text-x-floatvalue'}); | ||
859 | + | ||
860 | + if ($textData->{'text-y-relative'}) | ||
861 | + $textNode->setY(($textData->{'text-y-value'}*100)."%"); | ||
862 | + else | ||
863 | + $textNode->setY($textData->{'text-y-value'}); | ||
864 | + | ||
865 | + $textNode->setAngle($textData->{'text-angle'}); | ||
866 | + | ||
867 | + $textNode->setColor($this->hexColor2KernelColor($textData->{'text-color'})); | ||
868 | + | ||
869 | + switch ($textData->{'text-align'}) | ||
870 | + { | ||
871 | + case 'center' : | ||
872 | + $textNode->setAlign(RequestOutputPlotTextAlign::CENTER); | ||
873 | + break; | ||
874 | + case 'right' : | ||
875 | + $textNode->setAlign(RequestOutputPlotTextAlign::RIGHT); | ||
876 | + break; | ||
877 | + case 'left' : | ||
878 | + default: | ||
879 | + $textNode->setAlign(RequestOutputPlotTextAlign::LEFT); | ||
880 | + } | ||
881 | + | ||
882 | + //Font | ||
883 | + if ($textData->{'text-font-activated'}) | ||
884 | + $this->unmarshallFont($textData, 'text-font', $textNode->getFont()); | ||
885 | + } | ||
886 | + | ||
820 | protected function unmarshallTitle($inputData, $keyPrefix, $titleNode) | 887 | protected function unmarshallTitle($inputData, $keyPrefix, $titleNode) |
821 | { | 888 | { |
822 | if ($inputData->{$keyPrefix.'-text'} != '') | 889 | if ($inputData->{$keyPrefix.'-text'} != '') |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAdditionalObjectsNodeClass.php
0 โ 100644
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +define ("REQUESTOUTPUTPLOTADDITIONALOBJECTS_NAME", "additionalObjects"); | ||
4 | + | ||
5 | +/** | ||
6 | + * @class RequestOutputPlotAdditionalObjectsNodeClass | ||
7 | + * @brief Definition of additional objects for a plot | ||
8 | + * @details | ||
9 | + */ | ||
10 | +class RequestOutputPlotAdditionalObjectsNodeClass extends NodeClass | ||
11 | +{ | ||
12 | + public function __construct() | ||
13 | + { | ||
14 | + parent::__construct(REQUESTOUTPUTPLOTADDITIONALOBJECTS_NAME); | ||
15 | + } | ||
16 | + | ||
17 | + public function addTextObject() | ||
18 | + { | ||
19 | + $node = new RequestOutputPlotTextNodeClass(); | ||
20 | + $this->addChild($node); | ||
21 | + return $node; | ||
22 | + } | ||
23 | +} | ||
24 | + | ||
25 | +?> | ||
0 | \ No newline at end of file | 26 | \ No newline at end of file |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotElementNodeClass.php
@@ -37,12 +37,12 @@ class RequestOutputPlotElementNodeClass extends NodeClass | @@ -37,12 +37,12 @@ class RequestOutputPlotElementNodeClass extends NodeClass | ||
37 | $this->addChild($node); | 37 | $this->addChild($node); |
38 | } | 38 | } |
39 | 39 | ||
40 | - //ToDo additional objects | ||
41 | - /*if ($defineAdditionalObjects) | ||
42 | - { | ||
43 | - $node = new RequestOutputPlotAdditionalObjectsNodeClass(); | ||
44 | - $this->addChild($node); | ||
45 | - }*/ | 40 | + //additional objects |
41 | + if ($defineAdditionalObjects) | ||
42 | + { | ||
43 | + $node = new RequestOutputPlotAdditionalObjectsNodeClass(); | ||
44 | + $this->addChild($node); | ||
45 | + } | ||
46 | 46 | ||
47 | //ToDo fills | 47 | //ToDo fills |
48 | /*if ($defineFills) | 48 | /*if ($defineFills) |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotTextNodeClass.php
0 โ 100644
@@ -0,0 +1,116 @@ | @@ -0,0 +1,116 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +define ("REQUESTOUTPUTPLOTTEXT_NAME", "textPlot"); | ||
4 | +define ("REQUESTOUTPUTPLOTTEXT_TEXT", "text"); | ||
5 | +define ("REQUESTOUTPUTPLOTTEXT_YAXIS", "yAxis"); | ||
6 | +define ("REQUESTOUTPUTPLOTTEXT_X", "x"); | ||
7 | +define ("REQUESTOUTPUTPLOTTEXT_Y", "y"); | ||
8 | +define ("REQUESTOUTPUTPLOTTEXT_ANGLE", "angle"); | ||
9 | +define ("REQUESTOUTPUTPLOTTEXT_COLOR", "color"); | ||
10 | +define ("REQUESTOUTPUTPLOTTEXT_ALIGN", "align"); | ||
11 | +define ("REQUESTOUTPUTPLOTTEXT_FONT", "font"); | ||
12 | + | ||
13 | +abstract class RequestOutputPlotTextAlign | ||
14 | +{ | ||
15 | + const CENTER = "center"; | ||
16 | + const LEFT = "left"; | ||
17 | + const RIGHT = "right"; | ||
18 | +} | ||
19 | + | ||
20 | +/** | ||
21 | + * @class RequestOutputPlotTextNodeClass | ||
22 | + * @brief Definition of a text element for a plot | ||
23 | + * @details | ||
24 | + */ | ||
25 | +class RequestOutputPlotTextNodeClass extends NodeClass | ||
26 | +{ | ||
27 | + public function __construct() | ||
28 | + { | ||
29 | + parent::__construct(REQUESTOUTPUTPLOTTEXT_NAME); | ||
30 | + } | ||
31 | + | ||
32 | + public function setText($text) | ||
33 | + { | ||
34 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXT_TEXT, $text); | ||
35 | + } | ||
36 | + | ||
37 | + public function getText() | ||
38 | + { | ||
39 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXT_TEXT); | ||
40 | + } | ||
41 | + | ||
42 | + public function setYAxis($yAxis) | ||
43 | + { | ||
44 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXT_YAXIS, $yAxis); | ||
45 | + } | ||
46 | + | ||
47 | + public function getYAxis() | ||
48 | + { | ||
49 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXT_YAXIS); | ||
50 | + } | ||
51 | + | ||
52 | + public function setX($x) | ||
53 | + { | ||
54 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXT_X, $x); | ||
55 | + } | ||
56 | + | ||
57 | + public function getX() | ||
58 | + { | ||
59 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXT_X); | ||
60 | + } | ||
61 | + | ||
62 | + public function setY($y) | ||
63 | + { | ||
64 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXT_Y, $y); | ||
65 | + } | ||
66 | + | ||
67 | + public function getY() | ||
68 | + { | ||
69 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXT_Y); | ||
70 | + } | ||
71 | + | ||
72 | + public function setAngle($angle) | ||
73 | + { | ||
74 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXT_ANGLE, $angle); | ||
75 | + } | ||
76 | + | ||
77 | + public function getAngle() | ||
78 | + { | ||
79 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXT_ANGLE); | ||
80 | + } | ||
81 | + | ||
82 | + public function setColor($color) | ||
83 | + { | ||
84 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXT_COLOR, $color); | ||
85 | + } | ||
86 | + | ||
87 | + public function getColor() | ||
88 | + { | ||
89 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXT_COLOR); | ||
90 | + } | ||
91 | + | ||
92 | + public function setAlign($align) | ||
93 | + { | ||
94 | + $this->setAttribute(REQUESTOUTPUTPLOTTEXT_ALIGN, $align); | ||
95 | + } | ||
96 | + | ||
97 | + public function getAlign() | ||
98 | + { | ||
99 | + return $this->getAttribute(REQUESTOUTPUTPLOTTEXT_ALIGN); | ||
100 | + } | ||
101 | + | ||
102 | + public function getFont() | ||
103 | + { | ||
104 | + $node = $this->getFirstChildByName(REQUESTOUTPUTPLOTTEXT_FONT); | ||
105 | + | ||
106 | + if (!isset($node)) | ||
107 | + { | ||
108 | + $node = new RequestOutputPlotFontNodeClass(); | ||
109 | + $this->addChild($node); | ||
110 | + } | ||
111 | + | ||
112 | + return $node; | ||
113 | + } | ||
114 | +} | ||
115 | + | ||
116 | +?> | ||
0 | \ No newline at end of file | 117 | \ No newline at end of file |