Blame view

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

require_once("RequestOutputPlotYSerieNodeClass.php");
966bd5f8   Benjamin Renard   Add request to ge...
4
5
require_once "RequestOutputPlotOrbitSerieNodeClass.php";
require_once "RequestOutputPlotInstantSerieNodeClass.php";
22521f1c   Benjamin Renard   First commit
6
7
8
9
10
11
12
13
14

define ("REQUESTOUTPUTPLOTPARAMS_NAME", "params");

define ("REQUESTOUTPUTPLOTPARAM_NAME", "param");
define ("REQUESTOUTPUTPLOTPARAM_ID", "id");

define ("REQUESTOUTPUTPLOTXSERIE_NAME", "xserie");
define ("REQUESTOUTPUTPLOTXSERIE_XAXIS", "xAxis");
define ("REQUESTOUTPUTPLOTXSERIE_INDEX", "index");
4f9a8e36   Benjamin Renard   Min/Max value def...
15
16
define ("REQUESTOUTPUTPLOTXSERIE_MIN", "min");
define ("REQUESTOUTPUTPLOTXSERIE_MAX", "max");
22521f1c   Benjamin Renard   First commit
17

4ede4320   Benjamin Renard   Integration for s...
18
19
20
21
define ("REQUESTOUTPUTPLOTCOLORSERIE_NAME", "colorserie");
define ("REQUESTOUTPUTPLOTCOLORSERIE_ID", "id");
define ("REQUESTOUTPUTPLOTCOLORSERIE_INDEX", "index");

944199fe   Benjamin Renard   Use table definit...
22
23
define ("REQUESTOUTPUTPLOTSPECTRO_NAME", "spectro");
define ("REQUESTOUTPUTPLOTSPECTRO_YAXIS", "yAxis");
3182799a   Benjamin Renard   Use param indexes...
24
define ("REQUESTOUTPUTPLOTSPECTRO_INDEX", "index");
4f9a8e36   Benjamin Renard   Min/Max value def...
25
26
define ("REQUESTOUTPUTPLOTSPECTRO_MIN", "min");
define ("REQUESTOUTPUTPLOTSPECTRO_MAX", "max");
944199fe   Benjamin Renard   Use table definit...
27

17f69bd1   Benjamin Renard   Add tick plot and...
28
29
30
31
32
33
define ("REQUESTOUTPUTPLOTSTATUSBAR_NAME", "serie");
define ("REQUESTOUTPUTPLOTSTATUSBAR_INDEX", "index");

define ("REQUESTOUTPUTPLOTTICKBAR_NAME", "serie");
define ("REQUESTOUTPUTPLOTTICKBAR_INDEX", "index");

22521f1c   Benjamin Renard   First commit
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
 * @class RequestOutputPlotParamNodeClass
 * @brief Definition of a param for a plot of a plot request
 * @details
*/
class RequestOutputPlotParamNodeClass extends NodeClass
{
	public function __construct($id)
	{
		parent::__construct(REQUESTOUTPUTPLOTPARAM_NAME);
		$this->setAttribute(REQUESTOUTPUTPLOTPARAM_ID, $id);
	}

	public function getId()
	{
		return $this->getAttribute(REQUESTOUTPUTPLOTPARAM_ID);
	}
966bd5f8   Benjamin Renard   Add request to ge...
51
52
53
54
55
	
	public function setId($id)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPARAM_ID,$id);
	}
22521f1c   Benjamin Renard   First commit
56

4f9a8e36   Benjamin Renard   Min/Max value def...
57
	public function addYSerie($yAxis, $index, $xAxis = "", $colorSerieId = -1, $min = NULL, $max = NULL)
22521f1c   Benjamin Renard   First commit
58
59
60
61
62
63
64
65
66
	{
		if ($xAxis != "")
		{
			$ySerieNode = new RequestOutputPlotYSerieNodeClass(REQUESTOUTPUTPLOTYSERIE_XYPLOT_NAME);
			$ySerieNode->setXAxisId($xAxis);
		}
		else
			$ySerieNode = new RequestOutputPlotYSerieNodeClass(REQUESTOUTPUTPLOTYSERIE_TIMEPLOT_NAME);
		$ySerieNode->setYAxisId($yAxis);
4f9a8e36   Benjamin Renard   Min/Max value def...
67
68
69
70
		if (isset($min))
			$ySerieNode->setMin($min);
		if (isset($max))
			$ySerieNode->setMax($max);
22521f1c   Benjamin Renard   First commit
71
72
		if ($index >= 0)
			$ySerieNode->setIndex($index);
4ede4320   Benjamin Renard   Integration for s...
73
74
		if ($colorSerieId >= 0)
			$ySerieNode->setColorSerieId($colorSerieId);
22521f1c   Benjamin Renard   First commit
75
76
77
		$this->addChild($ySerieNode);
		return $ySerieNode;
	}
b4ee5e62   Benjamin Renard   Add integration f...
78
	
26a23052   Benjamin Renard   Add Interval Tick...
79
80
81
82
83
84
85
86
87
88
89
	public function addOrbitSerie($yAxis, $xAxis, $colorSerieId = -1)
	{
		$orbitSerieNode = new RequestOutputPlotOrbitSerieNodeClass();
		$orbitSerieNode->setYAxisId($yAxis);
		$orbitSerieNode->setXAxisId($xAxis);
		if ($colorSerieId >= 0)
			$orbitSerieNode->setColorSerieId($colorSerieId);
		$this->addChild($orbitSerieNode);
		return $orbitSerieNode;
	}
	
b4ee5e62   Benjamin Renard   Add integration f...
90
91
92
93
94
95
96
97
98
	public function addInstantSerie($xAxis, $yAxis)
	{
		$iserieNode = new RequestOutputPlotInstantSerieNodeClass();
		$iserieNode->setXAxisId($xAxis);
		$iserieNode->setYAxisId($yAxis);
		$this->addChild($iserieNode);
		return $iserieNode;
	}
	
3182799a   Benjamin Renard   Use param indexes...
99
	public function addSpectro($yAxis = "", $index = NULL, $min = NULL, $max = NULL)
944199fe   Benjamin Renard   Use table definit...
100
101
102
	{
		$spectroNode = new NodeClass(REQUESTOUTPUTPLOTSPECTRO_NAME);
		$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_YAXIS, $yAxis);
3182799a   Benjamin Renard   Use param indexes...
103
104
		if (isset($index))
			$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_INDEX, $index);
4f9a8e36   Benjamin Renard   Min/Max value def...
105
106
107
108
		if (isset($min))
			$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_MIN, $min);
		if (isset($max))
			$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_MAX, $max);
944199fe   Benjamin Renard   Use table definit...
109
110
111
		$this->addChild($spectroNode);
		return $spectroNode;
	}
22521f1c   Benjamin Renard   First commit
112

966bd5f8   Benjamin Renard   Add request to ge...
113
	public function addXSerie($xAxis = "", $index = -1, $min = NULL, $max = NULL)
22521f1c   Benjamin Renard   First commit
114
115
116
117
118
	{
		$xSerieNode = new NodeClass(REQUESTOUTPUTPLOTXSERIE_NAME);
		$xSerieNode->setAttribute(REQUESTOUTPUTPLOTXSERIE_XAXIS, $xAxis);
		if ($index >= 0)
			$xSerieNode->setAttribute(REQUESTOUTPUTPLOTXSERIE_INDEX, $index);
4f9a8e36   Benjamin Renard   Min/Max value def...
119
120
121
122
		if (isset($min))
			$xSerieNode->setAttribute(REQUESTOUTPUTPLOTXSERIE_MIN, $min);
		if (isset($max))
			$xSerieNode->setAttribute(REQUESTOUTPUTPLOTXSERIE_MAX, $max);
22521f1c   Benjamin Renard   First commit
123
124
125
		$this->addChild($xSerieNode);
		return $xSerieNode;
	}
4ede4320   Benjamin Renard   Integration for s...
126
	
966bd5f8   Benjamin Renard   Add request to ge...
127
	public function addColorSerie($id = "", $index = -1)
4ede4320   Benjamin Renard   Integration for s...
128
129
130
131
132
133
134
135
	{
		$colorSerieNode = new NodeClass(REQUESTOUTPUTPLOTCOLORSERIE_NAME);
		$colorSerieNode->setAttribute(REQUESTOUTPUTPLOTCOLORSERIE_ID, $id);
		if ($index >= 0)
			$colorSerieNode->setAttribute(REQUESTOUTPUTPLOTCOLORSERIE_INDEX, $index);
		$this->addChild($colorSerieNode);
		return $colorSerieNode;
	}
17f69bd1   Benjamin Renard   Add tick plot and...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
	
	public function addStatusBar($index)
	{
		$statusBarNode = new NodeClass(REQUESTOUTPUTPLOTSTATUSBAR_NAME);
		if ($index >= 0)
			$statusBarNode->setAttribute(REQUESTOUTPUTPLOTSTATUSBAR_INDEX, $index);
		$this->addChild($statusBarNode);
		return $statusBarNode;
	}
	
	public function addTickBar($index)
	{
		$tickBarNode = new NodeClass(REQUESTOUTPUTPLOTTICKBAR_NAME);
		if ($index >= 0)
			$tickBarNode->setAttribute(REQUESTOUTPUTPLOTTICKBAR_INDEX, $index);
		$this->addChild($tickBarNode);
		return $tickBarNode;
	}
966bd5f8   Benjamin Renard   Add request to ge...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	
	public function loadFromNode($xmlNode)
	{
		$this->setId($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTPLOTPARAM_ID));
		
		foreach ($this->getXmlNodeChildren($xmlNode) as $plottypeXmlNode) {
			$node = NULL;
			switch ($this->getXmlNodeName($plottypeXmlNode)) {
				case REQUESTOUTPUTPLOTYSERIE_XYPLOT_NAME :
					$node = new RequestOutputPlotYSerieNodeClass(REQUESTOUTPUTPLOTYSERIE_XYPLOT_NAME);
					break;
				case REQUESTOUTPUTPLOTYSERIE_TIMEPLOT_NAME :
					$node = new RequestOutputPlotYSerieNodeClass(REQUESTOUTPUTPLOTYSERIE_TIMEPLOT_NAME);
					break;
				case REQUESTOUTPUTPLOTORBITSERIE_NAME :
					$node = new RequestOutputPlotOrbitSerieNodeClass();
					break;
				case REQUESTOUTPUTPLOTINSTANTSERIE_NAME :
					$node = new RequestOutputPlotInstantSerieNodeClass();
					break;
				case REQUESTOUTPUTPLOTSPECTRO_NAME :
					$yAxis = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_YAXIS);
3182799a   Benjamin Renard   Use param indexes...
176
					$index = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_INDEX);
966bd5f8   Benjamin Renard   Add request to ge...
177
178
					$min = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_MIN);
					$max = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_MAX);
3182799a   Benjamin Renard   Use param indexes...
179
					$node = $this->addSpectro($yAxis, $index, $min, $max);
966bd5f8   Benjamin Renard   Add request to ge...
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
					break;
				case REQUESTOUTPUTPLOTXSERIE_NAME :
					$xAxis = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_XAXIS);
					$index = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_INDEX);
					if (empty($index))
						$index = -1;
					$min = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_MIN);
					$max = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_MAX);
					$node = $this->addXSerie($xAxis, $index, $min, $max);
					break;
				case REQUESTOUTPUTPLOTCOLORSERIE_NAME :
					$id = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTCOLORSERIE_ID);
					$index = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTCOLORSERIE_INDEX);
					if (empty($index))
						$index = -1;
					$node = $this->addColorSerie($id, $index);
					break;
				case REQUESTOUTPUTPLOTSTATUSBAR_NAME :
					$index = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSTATUSBAR_INDEX);
					if (empty($index))
						$index = -1;
					$node = $this->addStatusBar($index);
					break;
				case REQUESTOUTPUTPLOTTICKBAR_NAME :
					$index = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTTICKBAR_INDEX);
					if (empty($index))
						$index = -1;
					$node = $this->addTickBar($index);
					break;
				default:
					
			}
			
			if (isset($node)) {
				$node->loadFromNode($plottypeXmlNode);
				$this->addChild($node);
			}
		}
	}
22521f1c   Benjamin Renard   First commit
219
220
221
222
223
224
225
226
227
228
229
230
231
232
}

/**
 * @class RequestOutputPlotParamsNodeClass
 * @brief Definition of a params for a plot of a plot request
 * @details
 */
class RequestOutputPlotParamsNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTPLOTPARAMS_NAME);
	}

966bd5f8   Benjamin Renard   Add request to ge...
233
	public function getParamById($id = "")
22521f1c   Benjamin Renard   First commit
234
235
236
237
238
239
240
241
242
243
	{
		$paramNodes = $this->getChildrenByName(REQUESTOUTPUTPLOTPARAM_NAME);
		foreach ($paramNodes as $paramNode)
		if ($paramNode->getId() == $id)
			return $paramNode;
		//create new param
		$paramNode = new RequestOutputPlotParamNodeClass($id);
		$this->addChild($paramNode);
		return $paramNode;
	}
966bd5f8   Benjamin Renard   Add request to ge...
244
245
246
247
248
249
250
	
	public function loadFromNode($xmlNode)
	{
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTOUTPUTPLOTPARAM_NAME) as $paramXmlNode) {
			$this->getParamById()->loadFromNode($paramXmlNode);
		}
	}
22521f1c   Benjamin Renard   First commit
251
252
253
}

?>