Blame view

js/app/views/PlotComponents/PlotContextManager.js 4.34 KB
d0b61b72   Benjamin Renard   Show coordinates ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
 * Project   : AMDA-NG
 * Name      : PlotContextManager.js
 * @class   amdaPlotComp.PlotContextManager
 * @extends 
 * @brief   Manager to retrieve information about a panel by position on the result image
 * @author  Benjamin Renard
 * @version $Id: PlotContextManager.js benjamin $
 */

Ext.define('amdaPlotComp.PlotContextManager', {
	singleton: true,
	
	getPanel : function(context, xPos, yPos)
	{
d0b61b72   Benjamin Renard   Show coordinates ...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
		if (!context.success)
			return null;
		
		if (xPos < 0 || xPos > context.page.width)
			return null;
		
		if (yPos < 0 || yPos > context.page.height)
			return null;
		
		var resPanel = null;
		Ext.each(context.page.panels, function(panel) {
			if ((xPos >= panel.x) && (xPos <= (panel.x+panel.width)) && (yPos >= panel.y) && (yPos <= (panel.y+panel.height)))
			{
				resPanel = panel;
				return;
			}
		});
		
		return resPanel;
	},
	
9f08f4eb   Benjamin Renard   Zoom in interacti...
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
	getPanelById : function(context, panelId)
	{
		if (!context.success)
			return null;
		
		var resPanel = null;
		Ext.each(context.page.panels, function(panel) {
			if (panel.id == panelId)
			{
				resPanel = panel;
				return;
			}
		});
		
		return resPanel;
	},
2cd12bf9   Erdogan Furkan   #9326 - Showing T...
53

c2cc7749   Erdogan Furkan   #10098 - Modifica...
54
55
56
57
	getIntervalCoordInfo: function (context, panel, crtTimestamp) {
		var intervalName = new Array();
		var intervalId = new Array();
		var intervalText = "";
2cd12bf9   Erdogan Furkan   #9326 - Showing T...
58
59
		Ext.each(panel.intervals, function (interval) {
			if (crtTimestamp > interval.startTime && crtTimestamp < interval.stopTime) {
c2cc7749   Erdogan Furkan   #10098 - Modifica...
60
61
				intervalName.push(interval.name);
				intervalId.push(interval.id);
2cd12bf9   Erdogan Furkan   #9326 - Showing T...
62
63
64
			}
			return;
		});
c2cc7749   Erdogan Furkan   #10098 - Modifica...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
		if (intervalName.length > 0) {
			intervalText = 'TT: ' + intervalName[0] + ', id: [' + intervalId[0];
			for (i = 1; i < intervalName.length; i++) {
				if (intervalName[i] == intervalName[i - 1]) {
					intervalText += ', ' + intervalId[i];
				}
				else {
					intervalText += '] | TT: ' + intervalName[i] + ', id: [' + intervalId[i];
				}
			}
			intervalText += ']'
		}
		return intervalText;
	},

	getAllIntervalParams(context, panel, crtTimestamp) {
		var allParams = new Array();

		Ext.each(panel.intervals, function (interval) {
			if (crtTimestamp > interval.startTime && crtTimestamp < interval.stopTime && interval.params != "") {
				allParams.push(interval.params);
			}
			return;

		});
		return allParams;
	},

	getIntervalLinks(allintervalParams) {
		var links = new Array();
		Ext.each(allintervalParams, function (allParams) {

			var params = allParams.split('|');

			Ext.each(params, function (param) {
				if (param.toLowerCase().startsWith("http://") || param.toLowerCase().startsWith("https://")) {
					links.push(param);
				}
				return;
			});
			return;
		});
		return links;
	},

1be6ea03   Erdogan Furkan   #10098 - Final co...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
	setIntervalsRef(links, menu) {
		var realLinks = new Array();
		for (i = 0; i < links.length; i++) {
			var isAlreadyHere = false
			for (j = 0; j < i; j++) {
				if (links[i] == links[j]) {
					isAlreadyHere = true;
					continue;
				}
			}
			if (isAlreadyHere == false) {
				realLinks.push(links[i]);
			}
		}

		Ext.each(realLinks, function (realLink) {
			menu.add({
				text: realLink,
				handler: function () {
					window.open(realLink, "_blank");
				}
			});
		});
		return realLinks;
	},

c2cc7749   Erdogan Furkan   #10098 - Modifica...
136
137
138
139
140
141
142
143
144
	isInterval: function (context, panel, crtTimestamp) {
		isInterval = false;
		Ext.each(panel.intervals, function (interval) {
			if (crtTimestamp > interval.startTime && crtTimestamp < interval.stopTime) {
				isInterval = true;
			}
			return;
		});
		return isInterval;
2cd12bf9   Erdogan Furkan   #9326 - Showing T...
145
146
147
	},


9f08f4eb   Benjamin Renard   Zoom in interacti...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
	getPanelAxisById : function(panelContext, axisId)
	{
		if (!panelContext || !panelContext.plotArea)
			return null;
		
		var resAxis = null;
		Ext.each(panelContext.plotArea.axes, function(axis) {
			if (axis.id == axisId)
			{
				resAxis = axis;
				return;
			}
		});
		
		return resAxis;
	},
	
d0b61b72   Benjamin Renard   Show coordinates ...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
	isInPlotArea : function(panelContext, xPos, yPos)
	{
		if (!panelContext.plotArea)
			return false;
		
		return ((xPos >= panelContext.plotArea.x) && (xPos <= (panelContext.plotArea.x+panelContext.plotArea.width)) &&
				(yPos >= panelContext.plotArea.y) && (yPos <= (panelContext.plotArea.y+panelContext.plotArea.height)));
	},
	
	toAxisValue : function(axisContext, pixelMin, pixelMax, pixelValue)
	{
		if (pixelMax == pixelMin)
			return NaN;
		
5a61421b   Benjamin Renard   Support logarithm...
179
180
181
182
183
184
		if (axisContext.logarithmic)
		{
			var value = axisContext.min + (pixelValue - pixelMin)/(pixelMax - pixelMin)*(axisContext.max-axisContext.min);
			return Math.pow(10,value);
		}
		
d0b61b72   Benjamin Renard   Show coordinates ...
185
186
187
		return axisContext.min + (pixelValue - pixelMin)/(pixelMax - pixelMin)*(axisContext.max-axisContext.min);
	}
});