Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotAxesNodeClass.php 4.9 KB
22521f1c   Benjamin Renard   First commit
1
2
3
<?php

require_once("RequestOutputPlotTimeAxisNodeClass.php");
c0e7e5be   Benjamin Renard   Add integration f...
4
require_once("RequestOutputPlotEpochAxisNodeClass.php");
22521f1c   Benjamin Renard   First commit
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require_once("RequestOutputPlotDigitalAxisNodeClass.php");
require_once("RequestOutputPlotColorAxisNodeClass.php");

define ("REQUESTOUTPUTPLOTAXES_NAME", "axes");
define ("REQUESTOUTPUTPLOTAXES_XAXIS", "xAxis");
define ("REQUESTOUTPUTPLOTAXES_YAXIS", "yAxis");
define ("REQUESTOUTPUTPLOTAXES_ZAXIS", "zAxis");

abstract class RequestOutputPlotAxisTypeEnum
{
	const XAXIS = REQUESTOUTPUTPLOTAXES_XAXIS;
	const YAXIS = REQUESTOUTPUTPLOTAXES_YAXIS;
	const ZAXIS = REQUESTOUTPUTPLOTAXES_ZAXIS;
}

/**
 * @class RequestOutputPlotAxesNodeClass
 * @brief Definition of a axes element for a plot of a plot request
 * @details
 */
class RequestOutputPlotAxesNodeClass extends NodeClass
{
17f69bd1   Benjamin Renard   Add tick plot and...
27
	public function __construct($noXAxis, $noYAxis, $noZAxis)
22521f1c   Benjamin Renard   First commit
28
29
30
	{
		parent::__construct(REQUESTOUTPUTPLOTAXES_NAME);
		//create skeleton
17f69bd1   Benjamin Renard   Add tick plot and...
31
32
33
34
35
36
		if (!$noXAxis)
			$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_XAXIS, true);
		if (!$noYAxis)
			$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_YAXIS, true);
		if (!$noZAxis)
			$node = $this->getChildInstanceByName(REQUESTOUTPUTPLOTAXES_ZAXIS, true);
22521f1c   Benjamin Renard   First commit
37
38
	}

966bd5f8   Benjamin Renard   Add request to ge...
39
	public function addDigitalAxis($axisType,$id = "")
22521f1c   Benjamin Renard   First commit
40
41
42
	{
		if (($axisType != RequestOutputPlotAxisTypeEnum::XAXIS) && ($axisType != RequestOutputPlotAxisTypeEnum::YAXIS))
			return NULL;
f7e9b9f1   Benjamin Renard   Complete plot con...
43
		
22521f1c   Benjamin Renard   First commit
44
		$axisNode = $this->getChildInstanceByName($axisType);
1627a2dd   Benjamin Renard   Add status bar de...
45
46
47
48
		
		if (!isset($axisNode))
			return NULL;
		
22521f1c   Benjamin Renard   First commit
49
50
51
52
53
54
55
56
57
58
59
60
61
		//add digital axis
		$digitalAxisNode = new RequestOutputPlotDigitalAxisNodeClass();
		$digitalAxisNode->setId($id);
		$axisNode->addChild($digitalAxisNode);
		return $digitalAxisNode;
	}

	public function getDigitalAxis($axisType,$id)
	{
		if (($axisType != RequestOutputPlotAxisTypeEnum::XAXIS) && ($axisType != RequestOutputPlotAxisTypeEnum::YAXIS))
			return NULL;
			
		$axisNode = $this->getChildInstanceByName($axisType);
1627a2dd   Benjamin Renard   Add status bar de...
62
63
64
65
		
		if (!isset($axisNode))
			return NULL;
		
22521f1c   Benjamin Renard   First commit
66
67
68
69
70
71
72
73
74
75
76
		$digitalAxisNodes = $axisNode->getChildrenByName(REQUESTOUTPUTPLOTDIGITALAXIS_NAME);
		foreach ($digitalAxisNodes as $digitalAxisNode)
		if ($digitalAxisNode->getId() == $id)
			return $digitalAxisNode;

		return NULL;
	}

	public function getTimeAxis()
	{
		$axisNode = $this->getChildInstanceByName(RequestOutputPlotAxisTypeEnum::XAXIS);
1627a2dd   Benjamin Renard   Add status bar de...
77
78
		if (!isset($axisNode))
			return NULL;
22521f1c   Benjamin Renard   First commit
79
80
81
82
83
84
85
86
87
		$timeAxisNode = $axisNode->getFirstChildByName(REQUESTOUTPUTPLOTTIMEAXIS_NAME);
		if (!isset($timeAxisNode))
		{
			$timeAxisNode = new RequestOutputPlotTimeAxisNodeClass();
			$axisNode->addChild($timeAxisNode);
		}
		
		return $timeAxisNode;
	}
c0e7e5be   Benjamin Renard   Add integration f...
88
89
90
91
	
	public function getEpochAxis()
	{
		$axisNode = $this->getChildInstanceByName(RequestOutputPlotAxisTypeEnum::XAXIS);
1627a2dd   Benjamin Renard   Add status bar de...
92
93
		if (!isset($axisNode))
			return NULL;
c0e7e5be   Benjamin Renard   Add integration f...
94
95
96
97
98
99
100
101
102
		$epochAxisNode = $axisNode->getFirstChildByName(REQUESTOUTPUTPLOTEPOCHAXIS_NAME);
		if (!isset($epochAxisNode))
		{
			$epochAxisNode = new RequestOutputPlotEpochAxisNodeClass();
			$axisNode->addChild($epochAxisNode);
		}
	
		return $epochAxisNode;
	}
22521f1c   Benjamin Renard   First commit
103
104
105
106

	public function getColorAxis()
	{
		$axisNode = $this->getChildInstanceByName(RequestOutputPlotAxisTypeEnum::ZAXIS);
1627a2dd   Benjamin Renard   Add status bar de...
107
108
		if (!isset($axisNode))
			return NULL;
22521f1c   Benjamin Renard   First commit
109
110
111
112
113
114
115
116
117
		$colorAxisNode = $axisNode->getFirstChildByName(REQUESTOUTPUTPLOTCOLORAXIS_NAME);
		if (!isset($colorAxisNode))
		{
			$colorAxisNode = new RequestOutputPlotColorAxisNodeClass();
			$axisNode->addChild($colorAxisNode);
		}
		
		return $colorAxisNode;
	}
966bd5f8   Benjamin Renard   Add request to ge...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
	
	public function loadFromNode($xmlNode)
	{
		$xaxisXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTAXES_XAXIS);
		if (isset($xaxisXmlNode))
		{
			$timeXmlNode = $this->getXmlNodeChildByTagName($xaxisXmlNode, REQUESTOUTPUTPLOTTIMEAXIS_NAME);
			if (isset($timeXmlNode))
				$this->getTimeAxis()->loadFromNode($timeXmlNode);
			
			$epochXmlNode = $this->getXmlNodeChildByTagName($xaxisXmlNode, REQUESTOUTPUTPLOTEPOCHAXIS_NAME);
			if (isset($epochXmlNode))
				$this->getEpochAxis()->loadFromNode($epochXmlNode);
			
			foreach ($this->getXmlNodeChildrenByTagName($xaxisXmlNode, REQUESTOUTPUTPLOTDIGITALAXIS_NAME) as $xXmlNode) {
				$this->addDigitalAxis(RequestOutputPlotAxisTypeEnum::XAXIS)->loadFromNode($xXmlNode);
			}
		}
		
		$yaxisXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTAXES_YAXIS);
		if (isset($yaxisXmlNode))
		{
			foreach ($this->getXmlNodeChildrenByTagName($yaxisXmlNode, REQUESTOUTPUTPLOTDIGITALAXIS_NAME) as $yXmlNode) {
				$this->addDigitalAxis(RequestOutputPlotAxisTypeEnum::YAXIS)->loadFromNode($yXmlNode);
			}
		}
		
		$zaxisXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPLOTAXES_ZAXIS);
		if (isset($zaxisXmlNode))
		{
71eaac9b   Benjamin Renard   Return default ax...
148
149
			$colorXmlNode = $this->getXmlNodeChildByTagName($zaxisXmlNode, REQUESTOUTPUTPLOTCOLORAXIS_NAME);
			if (isset($colorXmlNode)) {
966bd5f8   Benjamin Renard   Add request to ge...
150
				$this->getColorAxis()->loadFromNode($colorXmlNode);
71eaac9b   Benjamin Renard   Return default ax...
151
			}
966bd5f8   Benjamin Renard   Add request to ge...
152
153
		}
	}
22521f1c   Benjamin Renard   First commit
154
155
156
}

?>