Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php 10.5 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");
f822811a   Benjamin Renard   Implements multi ...
15
define ("REQUESTOUTPUTPLOTXSERIE_ID", "id");
4f9a8e36   Benjamin Renard   Min/Max value def...
16
17
define ("REQUESTOUTPUTPLOTXSERIE_MIN", "min");
define ("REQUESTOUTPUTPLOTXSERIE_MAX", "max");
22521f1c   Benjamin Renard   First commit
18

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

944199fe   Benjamin Renard   Use table definit...
23
24
define ("REQUESTOUTPUTPLOTSPECTRO_NAME", "spectro");
define ("REQUESTOUTPUTPLOTSPECTRO_YAXIS", "yAxis");
3182799a   Benjamin Renard   Use param indexes...
25
define ("REQUESTOUTPUTPLOTSPECTRO_INDEX", "index");
4f9a8e36   Benjamin Renard   Min/Max value def...
26
27
define ("REQUESTOUTPUTPLOTSPECTRO_MIN", "min");
define ("REQUESTOUTPUTPLOTSPECTRO_MAX", "max");
0c1bcc5a   Benjamin Renard   Add option to sho...
28
define ("REQUESTOUTPUTPLOTSPECTRO_USELOG0ASMIN", "uselog0asmin");
0a56ad20   Benjamin Renard   Give the possibil...
29
define ("REQUESTOUTPUTPLOTSPECTRO_RESOLUTION", "resolution");
944199fe   Benjamin Renard   Use table definit...
30

fc153c1c   Elena.Budnik   ispectro added
31
32
33
34
define ("REQUESTOUTPUTPLOTINSTANTSPECTRO_NAME", "ispectro");
define ("REQUESTOUTPUTPLOTINSTANTSPECTRO_XAXIS", "xAxis");
define ("REQUESTOUTPUTPLOTINSTANTSPECTRO_DIMONXAXIS", "dimOnXAxis");

17f69bd1   Benjamin Renard   Add tick plot and...
35
36
37
38
39
40
define ("REQUESTOUTPUTPLOTSTATUSBAR_NAME", "serie");
define ("REQUESTOUTPUTPLOTSTATUSBAR_INDEX", "index");

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

044a9305   Benjamin Renard   Add intervals dra...
41
42
define ("REQUESTOUTPUTPLOTINTERVALS_NAME", "intervals");

22521f1c   Benjamin Renard   First commit
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
 * @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...
60
61
62
63
64
	
	public function setId($id)
	{
		$this->setAttribute(REQUESTOUTPUTPLOTPARAM_ID,$id);
	}
22521f1c   Benjamin Renard   First commit
65

f822811a   Benjamin Renard   Implements multi ...
66
	public function addYSerie($yAxis, $index, $xId = -1, $colorSerieId = -1, $min = NULL, $max = NULL)
22521f1c   Benjamin Renard   First commit
67
	{
f822811a   Benjamin Renard   Implements multi ...
68
		if ($xId != -1)
22521f1c   Benjamin Renard   First commit
69
70
		{
			$ySerieNode = new RequestOutputPlotYSerieNodeClass(REQUESTOUTPUTPLOTYSERIE_XYPLOT_NAME);
f822811a   Benjamin Renard   Implements multi ...
71
72
			$ySerieNode->setXId($xId);
			$ySerieNode->setXAxisId(REQUESTOUTPUTPLOTELEMENTXY_XAXISID);
22521f1c   Benjamin Renard   First commit
73
74
75
76
		}
		else
			$ySerieNode = new RequestOutputPlotYSerieNodeClass(REQUESTOUTPUTPLOTYSERIE_TIMEPLOT_NAME);
		$ySerieNode->setYAxisId($yAxis);
4f9a8e36   Benjamin Renard   Min/Max value def...
77
78
79
80
		if (isset($min))
			$ySerieNode->setMin($min);
		if (isset($max))
			$ySerieNode->setMax($max);
22521f1c   Benjamin Renard   First commit
81
82
		if ($index >= 0)
			$ySerieNode->setIndex($index);
4ede4320   Benjamin Renard   Integration for s...
83
84
		if ($colorSerieId >= 0)
			$ySerieNode->setColorSerieId($colorSerieId);
22521f1c   Benjamin Renard   First commit
85
86
87
		$this->addChild($ySerieNode);
		return $ySerieNode;
	}
b4ee5e62   Benjamin Renard   Add integration f...
88
	
cb46dfbf   Benjamin Renard   Fix orbit serie a...
89
	public function addOrbitSerie($yAxis, $colorSerieId = -1)
26a23052   Benjamin Renard   Add Interval Tick...
90
91
	{
		$orbitSerieNode = new RequestOutputPlotOrbitSerieNodeClass();
cb46dfbf   Benjamin Renard   Fix orbit serie a...
92
		$orbitSerieNode->setXAxisId(REQUESTOUTPUTPLOTELEMENTXY_XAXISID);
26a23052   Benjamin Renard   Add Interval Tick...
93
		$orbitSerieNode->setYAxisId($yAxis);
26a23052   Benjamin Renard   Add Interval Tick...
94
95
96
97
98
99
		if ($colorSerieId >= 0)
			$orbitSerieNode->setColorSerieId($colorSerieId);
		$this->addChild($orbitSerieNode);
		return $orbitSerieNode;
	}
	
cb46dfbf   Benjamin Renard   Fix orbit serie a...
100
	public function addInstantSerie($yAxis)
b4ee5e62   Benjamin Renard   Add integration f...
101
102
	{
		$iserieNode = new RequestOutputPlotInstantSerieNodeClass();
cb46dfbf   Benjamin Renard   Fix orbit serie a...
103
		$iserieNode->setXAxisId(REQUESTOUTPUTPLOTELEMENTXY_XAXISID);
b4ee5e62   Benjamin Renard   Add integration f...
104
105
106
107
108
		$iserieNode->setYAxisId($yAxis);
		$this->addChild($iserieNode);
		return $iserieNode;
	}
	
0a56ad20   Benjamin Renard   Give the possibil...
109
	public function addSpectro($yAxis = "", $resolution="", $index = NULL, $min = NULL, $max = NULL, $uselog0asmin = FALSE)
944199fe   Benjamin Renard   Use table definit...
110
111
112
	{
		$spectroNode = new NodeClass(REQUESTOUTPUTPLOTSPECTRO_NAME);
		$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_YAXIS, $yAxis);
0c1bcc5a   Benjamin Renard   Add option to sho...
113
		$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_USELOG0ASMIN, $uselog0asmin ? "true" : "false");
0a56ad20   Benjamin Renard   Give the possibil...
114
115
		if (isset($resolution))
			$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_RESOLUTION, $resolution);
3182799a   Benjamin Renard   Use param indexes...
116
117
		if (isset($index))
			$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_INDEX, $index);
4f9a8e36   Benjamin Renard   Min/Max value def...
118
119
120
121
		if (isset($min))
			$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_MIN, $min);
		if (isset($max))
			$spectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_MAX, $max);
944199fe   Benjamin Renard   Use table definit...
122
123
124
		$this->addChild($spectroNode);
		return $spectroNode;
	}
fc153c1c   Elena.Budnik   ispectro added
125
	
cb46dfbf   Benjamin Renard   Fix orbit serie a...
126
	public function addInstantSpectro($yAxis, $dimOnXAxis, $index = NULL, $min = NULL, $max = NULL)
fc153c1c   Elena.Budnik   ispectro added
127
128
	{
		$ispectroNode = new NodeClass(REQUESTOUTPUTPLOTINSTANTSPECTRO_NAME);
cb46dfbf   Benjamin Renard   Fix orbit serie a...
129
		$ispectroNode->setAttribute(REQUESTOUTPUTPLOTINSTANTSPECTRO_XAXIS, REQUESTOUTPUTPLOTELEMENTXY_XAXISID);
fc153c1c   Elena.Budnik   ispectro added
130
131
132
133
134
135
136
137
138
139
		$ispectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_YAXIS, $yAxis);
		$ispectroNode->setAttribute(REQUESTOUTPUTPLOTINSTANTSPECTRO_DIMONXAXIS, $dimOnXAxis);
		
		if (isset($min))
			$ispectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_MIN, $min);
		if (isset($max))
			$ispectroNode->setAttribute(REQUESTOUTPUTPLOTSPECTRO_MAX, $max);
		$this->addChild($ispectroNode);
		return $ispectroNode;
	}
22521f1c   Benjamin Renard   First commit
140

f822811a   Benjamin Renard   Implements multi ...
141
	public function addXSerie($index = -1, $id = 0, $min = NULL, $max = NULL)
22521f1c   Benjamin Renard   First commit
142
143
	{
		$xSerieNode = new NodeClass(REQUESTOUTPUTPLOTXSERIE_NAME);
22521f1c   Benjamin Renard   First commit
144
145
		if ($index >= 0)
			$xSerieNode->setAttribute(REQUESTOUTPUTPLOTXSERIE_INDEX, $index);
f822811a   Benjamin Renard   Implements multi ...
146
		$xSerieNode->setAttribute(REQUESTOUTPUTPLOTXSERIE_ID, $id);
4f9a8e36   Benjamin Renard   Min/Max value def...
147
148
149
150
		if (isset($min))
			$xSerieNode->setAttribute(REQUESTOUTPUTPLOTXSERIE_MIN, $min);
		if (isset($max))
			$xSerieNode->setAttribute(REQUESTOUTPUTPLOTXSERIE_MAX, $max);
22521f1c   Benjamin Renard   First commit
151
152
153
		$this->addChild($xSerieNode);
		return $xSerieNode;
	}
4ede4320   Benjamin Renard   Integration for s...
154
	
966bd5f8   Benjamin Renard   Add request to ge...
155
	public function addColorSerie($id = "", $index = -1)
4ede4320   Benjamin Renard   Integration for s...
156
157
158
159
160
161
162
163
	{
		$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...
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
	
	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;
	}
044a9305   Benjamin Renard   Add intervals dra...
182
183
184
185
186
187
188

	public function addIntervals()
	{
		$intervalsNode = new NodeClass(REQUESTOUTPUTPLOTINTERVALS_NAME);
		$this->addChild($intervalsNode);
		return $intervalsNode;
	}
966bd5f8   Benjamin Renard   Add request to ge...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
	
	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...
211
					$index = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_INDEX);
966bd5f8   Benjamin Renard   Add request to ge...
212
213
					$min = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_MIN);
					$max = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_MAX);
0a56ad20   Benjamin Renard   Give the possibil...
214
					$resolution = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_RESOLUTION);
0c1bcc5a   Benjamin Renard   Add option to sho...
215
					$uselog0asmin = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTSPECTRO_USELOG0ASMIN) == "true";
0a56ad20   Benjamin Renard   Give the possibil...
216
					$node = $this->addSpectro($yAxis, $resolution, $index, $min, $max, $uselog0asmin);
966bd5f8   Benjamin Renard   Add request to ge...
217
218
219
220
221
222
					break;
				case REQUESTOUTPUTPLOTXSERIE_NAME :
					$xAxis = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_XAXIS);
					$index = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_INDEX);
					if (empty($index))
						$index = -1;
f822811a   Benjamin Renard   Implements multi ...
223
224
225
					$xId = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_XID);
					if (empty($xId))
						$xId = 0;
966bd5f8   Benjamin Renard   Add request to ge...
226
227
					$min = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_MIN);
					$max = $this->getXmlNodeAttribute($plottypeXmlNode, REQUESTOUTPUTPLOTXSERIE_MAX);
f822811a   Benjamin Renard   Implements multi ...
228
					$node = $this->addXSerie($index, $xId, $min, $max);
966bd5f8   Benjamin Renard   Add request to ge...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
					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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
}

/**
 * @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...
273
	public function getParamById($id = "")
22521f1c   Benjamin Renard   First commit
274
275
276
277
278
279
280
281
282
283
	{
		$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...
284
285
286
287
288
289
290
	
	public function loadFromNode($xmlNode)
	{
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTOUTPUTPLOTPARAM_NAME) as $paramXmlNode) {
			$this->getParamById()->loadFromNode($paramXmlNode);
		}
	}
22521f1c   Benjamin Renard   First commit
291
292
}

f822811a   Benjamin Renard   Implements multi ...
293
?>