Commit 9f08f4eba0ef2b238041d969ab8664237a030a5b
1 parent
d0b61b72
Exists in
master
and in
112 other branches
Zoom in interactive plot
Showing
8 changed files
with
755 additions
and
422 deletions
Show diff stats
js/app/controllers/PlotModule.js
... | ... | @@ -71,7 +71,8 @@ Ext.define('amdaDesktop.PlotModule', { |
71 | 71 | var plotTabConfig = { |
72 | 72 | folder : session.folder, |
73 | 73 | plotFile : tabResult.plot, |
74 | - context : tabResult.context | |
74 | + context : tabResult.context, | |
75 | + tabId : tabResult.id | |
75 | 76 | }; |
76 | 77 | |
77 | 78 | if (winResult == null) { |
... | ... | @@ -123,7 +124,7 @@ Ext.define('amdaDesktop.PlotModule', { |
123 | 124 | }); |
124 | 125 | }, |
125 | 126 | |
126 | - updateInteractiveSession : function() { | |
127 | + updateInteractiveSession : function(interactiveResult) { | |
127 | 128 | |
128 | 129 | }, |
129 | 130 | |
... | ... |
js/app/views/InteractiveIntervalPlugin.js deleted
... | ... | @@ -1,370 +0,0 @@ |
1 | -/** | |
2 | - * Project : AMDA-NG | |
3 | - * Name : InteractiveIntervalPlug.js | |
4 | - * @plugin amdaUI.InteractiveIntervalPlug | |
5 | - * @extends Ext.util.Observable | |
6 | - * @ptype interactiveIntervalPlugin | |
7 | - * @brief Plot interactive session UI (View) | |
8 | - * @author Myriam | |
9 | - * @version $Id: InteractiveIntervalPlugin.js 2617 2014-10-24 12:06:57Z elena $ | |
10 | - ******************************************************************************** | |
11 | - * FT Id : Date : Name - Description | |
12 | - ******************************************************************************* | |
13 | - * : | |
14 | - */ | |
15 | - | |
16 | - | |
17 | -Ext.define('amdaUI.InteractiveIntervalPlugin', { | |
18 | - extend: 'Ext.util.Observable',//'Ext.AbstractPlugin', | |
19 | - alias: 'plugin.interactiveIntervalPlugin', | |
20 | - | |
21 | - linkedNode : null, | |
22 | - | |
23 | - moduleId : 'timetab-win', | |
24 | - | |
25 | - rootNode : null, | |
26 | - win : null, | |
27 | - | |
28 | - addInterval : false, | |
29 | - | |
30 | - constructor: function(config) { | |
31 | - Ext.apply(this, config); | |
32 | - this.callParent(arguments); | |
33 | - }, | |
34 | - | |
35 | - | |
36 | - init: function(cmp) { | |
37 | - this.hostCmp = cmp; | |
38 | - this.hostCmp.on({ | |
39 | - open: this.onOpen, | |
40 | - startTime: this.setStart, | |
41 | - stopTime: this.setStop, | |
42 | - scope: this | |
43 | - }); | |
44 | - | |
45 | -//Global event | |
46 | - myDesktopApp.EventManager.on({ | |
47 | - refresh : this.insertInterval, | |
48 | - scope: this}); | |
49 | - }, | |
50 | - | |
51 | - onDestroy : function() { | |
52 | - this.win = null; | |
53 | - }, | |
54 | - | |
55 | - setStart: function(a){ | |
56 | - if (this.form) | |
57 | - this.form.getForm().findField('start').setValue(a); | |
58 | - }, | |
59 | - | |
60 | - setStop: function(b){ | |
61 | - var a = new Date(this.form.getForm().findField('start').getValue()); | |
62 | - if (a <= b) { | |
63 | - this.form.getForm().findField('stop').setValue(b); | |
64 | - } else { | |
65 | - this.form.getForm().findField('start').setValue(b); | |
66 | - this.form.getForm().findField('stop').setValue(a); | |
67 | - } | |
68 | - }, | |
69 | - | |
70 | -/** | |
71 | - * add Interval to Time table | |
72 | - **/ | |
73 | - insertInterval: function() { | |
74 | - | |
75 | - if (this.addInterval) { | |
76 | - var targetModule = myDesktopApp.getLoadedModule(this.moduleId); | |
77 | - if (targetModule) | |
78 | - { | |
79 | - var targetModuleUI = targetModule.getUiContent(); | |
80 | - if (targetModuleUI) | |
81 | - targetModuleUI.addInterval(this.start,this.stop); | |
82 | - } | |
83 | - } | |
84 | - this.addInterval = false; | |
85 | - }, | |
86 | - | |
87 | -/** | |
88 | - * creation of the window | |
89 | - */ | |
90 | - onOpen: function() { | |
91 | - if (!this.win) { | |
92 | - this.win = new Ext.Window({ | |
93 | - id: 'interactiveInter-win-' + this.hostCmp.ownerCt.ownerCt.getId(), // Plot window ID | |
94 | - width: 380, | |
95 | - height: 160, | |
96 | - x: 0, y: 0, | |
97 | - baseCls:'x-panel', | |
98 | - title: 'Interactive Interval', | |
99 | - layout: 'fit', | |
100 | - constrain: true, | |
101 | - collapsible: true, | |
102 | - ghost: false, | |
103 | - renderTo: this.hostCmp.ownerCt.getId(), | |
104 | - items: this.getFormConfig(), | |
105 | - listeners: { | |
106 | - scope: this, | |
107 | - beforeclose: function() { | |
108 | - this.hostCmp.ownerCt.destroyMire(); | |
109 | - Ext.PluginManager.unregister(this); | |
110 | - } | |
111 | - }, | |
112 | - getConstrainVector: function(constrainTo){ | |
113 | - var me = this; | |
114 | - if (me.constrain || me.constrainHeader) { | |
115 | - constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent(); | |
116 | - return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo); | |
117 | - } | |
118 | - } | |
119 | - }); | |
120 | - | |
121 | - this.win.on('destroy', this.onDestroy, this); | |
122 | - | |
123 | - this.id = 'interactiveInter-' + this.hostCmp.ownerCt.ownerCt.getId(); | |
124 | - | |
125 | - Ext.PluginManager.register(this); | |
126 | - this.win.show(); | |
127 | - this.win.setPosition(0,0); | |
128 | - var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
129 | - this.rootNode = tree.getRootNode().findChild('id','timeTable-treeRootNode',true); | |
130 | - | |
131 | - amdaModel.InteractiveNode.preloadNodes(this.rootNode, | |
132 | - function() | |
133 | - { | |
134 | - }); | |
135 | - } | |
136 | - }, | |
137 | - | |
138 | -/** | |
139 | - * check if multi or individual operation | |
140 | - */ | |
141 | - isMultiZoom: function() { | |
142 | - | |
143 | - var win = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id); | |
144 | - if (!win) return false; | |
145 | - | |
146 | - var multiPlotUI = win.items.getAt(0); | |
147 | - var checked = multiPlotUI.checkBoxGroup.getChecked(); | |
148 | - | |
149 | - if (checked.length == 0) return false; | |
150 | - // check if this Plot is not checked then this is individual zoom | |
151 | - var hostId = this.hostCmp.ownerCt.ownerCt.getId(); | |
152 | - | |
153 | - var isUnique = Ext.Array.every(checked, function(item){ | |
154 | - if (item.name === hostId) | |
155 | - return false; | |
156 | - }); | |
157 | - | |
158 | - return !isUnique; | |
159 | - }, | |
160 | - | |
161 | - resetStartStop: function() { | |
162 | - this.form.getForm().findField('start').setValue(''); | |
163 | - this.form.getForm().findField('stop').setValue(''); | |
164 | - this.hostCmp.ownerCt.resetMire(); | |
165 | - }, | |
166 | - | |
167 | - | |
168 | -/** | |
169 | - * Main form | |
170 | - */ | |
171 | - getFormConfig: function(){ | |
172 | - this.form = new Ext.form.FormPanel( { | |
173 | - frame: true, | |
174 | - width: 380, | |
175 | - height: 160, | |
176 | - layout: 'hbox', | |
177 | - fieldDefaults: { | |
178 | - labelWidth: 100 | |
179 | - }, | |
180 | - items: [ | |
181 | - { | |
182 | - xtype: 'container', | |
183 | - width : 250, | |
184 | - layout : 'vbox', | |
185 | - defaults: { height : 25, width: 250 }, | |
186 | - items: [ | |
187 | - { | |
188 | - xtype:'datefield', name:'start', fieldLabel: 'Start Time', | |
189 | - format : 'Y-m-d\\TH:i:s' | |
190 | - }, | |
191 | - { | |
192 | - xtype:'datefield', name:'stop', fieldLabel: 'Stop Time', | |
193 | - format : 'Y-m-d\\TH:i:s' | |
194 | - }, | |
195 | - { | |
196 | - xtype: 'textfield', | |
197 | - fieldLabel: 'Add in TimeTable', | |
198 | - name: 'timeTableName', | |
199 | - listeners : | |
200 | - { | |
201 | - render : function(o,op) | |
202 | - { | |
203 | - var me = this; | |
204 | - var el = me.el; | |
205 | - var dropTarget = Ext.create('Ext.dd.DropTarget', el, { | |
206 | - ddGroup: 'explorerTree', | |
207 | - notifyOver : function(ddSource, e, data) | |
208 | - { | |
209 | - if ((data.records[0].data.nodeType == 'timeTable') && (data.records[0].data.leaf)) | |
210 | - { | |
211 | - this.valid = true; | |
212 | - return this.dropAllowed; | |
213 | - } | |
214 | - this.valid = false; | |
215 | - return this.dropNotAllowed; | |
216 | - }, | |
217 | - notifyDrop : function(ddSource, e, data) | |
218 | - { | |
219 | - if (!this.valid) | |
220 | - return false; | |
221 | - me.setValue(data.records[0].get('text')); | |
222 | - return true; | |
223 | - } | |
224 | - }); | |
225 | - } | |
226 | - } | |
227 | - } | |
228 | - ] | |
229 | - }, | |
230 | - { | |
231 | - xtype: 'container', | |
232 | - width : 130, | |
233 | - margin: '0 0 0 15', | |
234 | - layout : 'vbox', | |
235 | - defaults: {height : 25, width: 100}, | |
236 | - items: [ | |
237 | - { | |
238 | - xtype: 'button', | |
239 | - text: 'Reset Start/Stop', | |
240 | - scope: this, | |
241 | - handler: function() { | |
242 | - this.resetStartStop(); | |
243 | - } | |
244 | - }, | |
245 | - { xtype: 'component', height: 34 }, | |
246 | - { | |
247 | - xtype: 'button', | |
248 | - text: 'Insert Interval', | |
249 | - scope: this, | |
250 | - handler: function(){ | |
251 | - // linkedNode.isValidName(value); | |
252 | - this.start = this.form.getForm().findField('start').getValue(); | |
253 | - this.stop = this.form.getForm().findField('stop').getValue(); | |
254 | - // new TimeTable or typed manually | |
255 | - var targetModule = myDesktopApp.getLoadedModule(this.moduleId); | |
256 | - var targetModuleUI = null; | |
257 | - if (targetModule) | |
258 | - targetModuleUI = targetModule.getUiContent(); | |
259 | - var TTname = this.form.getForm().findField('timeTableName').getValue(); | |
260 | -// TT window was closed or TTname was changed | |
261 | - if (!targetModuleUI || !this.linkedNode || TTname !== this.linkedNode.get('text')) { | |
262 | - var nodeWithSameName = this.rootNode.findChild('text', TTname, true); | |
263 | - if (nodeWithSameName !== null) { | |
264 | - this.linkedNode = nodeWithSameName; | |
265 | - this.linkedNode.editLeaf(); | |
266 | - this.addInterval = true; | |
267 | - } | |
268 | - else { | |
269 | - obj = Ext.create('amdaModel.TimeTable', {name : TTname, fromPlugin : true}); | |
270 | - this.linkedNode = Ext.create('amdaModel.TimeTableNode', { | |
271 | - leaf : true, | |
272 | - text : TTname, | |
273 | - nodeType : 'timeTable', | |
274 | - object : obj | |
275 | - }); | |
276 | - // this.linkedNode.set('id',''); | |
277 | - this.linkedNode.editLeaf(); | |
278 | - //TODO generic PRELOAD problem to fix | |
279 | - Ext.Function.defer(function(){ | |
280 | - var targetModule = myDesktopApp.getLoadedModule(this.moduleId); | |
281 | - if (targetModule) | |
282 | - { | |
283 | - targetModuleUI = targetModule.getUiContent(); | |
284 | - targetModuleUI.addInterval(this.start,this.stop); | |
285 | - } | |
286 | - this.resetStartStop(); | |
287 | - }, 1000, this); | |
288 | - } | |
289 | - } | |
290 | - else { | |
291 | - targetModuleUI.addInterval(this.start, this.stop); | |
292 | - this.resetStartStop(); | |
293 | - } | |
294 | - } | |
295 | - } | |
296 | - ] | |
297 | - } | |
298 | - ], | |
299 | - fbar : [ | |
300 | - { | |
301 | - text: 'Zoom In Start/Stop', | |
302 | - width: 100, | |
303 | - scope: this, | |
304 | - handler: function(){ | |
305 | - var startZoom = this.form.getForm().findField('start').getValue(); | |
306 | - var stopZoom = this.form.getForm().findField('stop').getValue(); | |
307 | - if(!startZoom || !stopZoom || !this.form.getForm().isValid()) { | |
308 | - myDesktopApp.warningMsg('StartTime or StopTime is incorrect'); | |
309 | - return; | |
310 | - } | |
311 | - | |
312 | - this.hostCmp.ownerCt.resetMire(); | |
313 | - var multiZoom = this.isMultiZoom(); | |
314 | - | |
315 | - if (multiZoom) { | |
316 | - var win = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id); | |
317 | - var multiPlotUI = win.items.getAt(0); | |
318 | - var checked = multiPlotUI.checkBoxGroup.getChecked(); | |
319 | - | |
320 | - Ext.Array.each(checked,function(item, index, all){ | |
321 | - var id = item.name; | |
322 | - var winRes = myDesktopApp.getDesktop().getWindow(id); | |
323 | - | |
324 | - if (winRes) { | |
325 | - var panelResult = winRes.items.items[0]; | |
326 | - panelResult.setObjectIntoNode(); | |
327 | - panelResult.object.fireEvent('execute', true, 'zoom',startZoom,stopZoom); | |
328 | - } | |
329 | - }); | |
330 | - } | |
331 | - else { | |
332 | - this.hostCmp.ownerCt.setObjectIntoNode(); | |
333 | - this.hostCmp.ownerCt.object.fireEvent('execute', false, 'zoom',startZoom,stopZoom); | |
334 | - } | |
335 | - } | |
336 | - }, | |
337 | - { | |
338 | - text: 'Reset Zoom', | |
339 | - width: 100, | |
340 | - scope : this, | |
341 | - handler: function(){ | |
342 | - this.hostCmp.ownerCt.resetMire(); | |
343 | - var multiZoom = this.isMultiZoom(); | |
344 | - | |
345 | - if (multiZoom) { | |
346 | - var win = myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.interactive_plot.id); | |
347 | - var multiPlotUI = win.items.getAt(0); | |
348 | - var checked = multiPlotUI.checkBoxGroup.getChecked(); | |
349 | - | |
350 | - Ext.Array.each(checked,function(item, index, all){ | |
351 | - var id = item.name; | |
352 | - var winRes = myDesktopApp.getDesktop().getWindow(id); | |
353 | - if (winRes) { | |
354 | - var panelResult = winRes.items.items[0]; | |
355 | - panelResult.setObjectIntoNode(); | |
356 | - panelResult.object.fireEvent('execute', true, 'resetzoom'); | |
357 | - } | |
358 | - }); | |
359 | - } | |
360 | - else { | |
361 | - this.hostCmp.ownerCt.object.fireEvent('execute', false, 'resetzoom'); | |
362 | - } | |
363 | - } | |
364 | - } | |
365 | - ] | |
366 | - | |
367 | - }); | |
368 | - return this.form; | |
369 | - } | |
370 | -}); | |
371 | 0 | \ No newline at end of file |
js/app/views/PlotComponents/PlotContextManager.js
... | ... | @@ -13,7 +13,6 @@ Ext.define('amdaPlotComp.PlotContextManager', { |
13 | 13 | |
14 | 14 | getPanel : function(context, xPos, yPos) |
15 | 15 | { |
16 | - | |
17 | 16 | if (!context.success) |
18 | 17 | return null; |
19 | 18 | |
... | ... | @@ -35,6 +34,40 @@ Ext.define('amdaPlotComp.PlotContextManager', { |
35 | 34 | return resPanel; |
36 | 35 | }, |
37 | 36 | |
37 | + getPanelById : function(context, panelId) | |
38 | + { | |
39 | + if (!context.success) | |
40 | + return null; | |
41 | + | |
42 | + var resPanel = null; | |
43 | + Ext.each(context.page.panels, function(panel) { | |
44 | + if (panel.id == panelId) | |
45 | + { | |
46 | + resPanel = panel; | |
47 | + return; | |
48 | + } | |
49 | + }); | |
50 | + | |
51 | + return resPanel; | |
52 | + }, | |
53 | + | |
54 | + getPanelAxisById : function(panelContext, axisId) | |
55 | + { | |
56 | + if (!panelContext || !panelContext.plotArea) | |
57 | + return null; | |
58 | + | |
59 | + var resAxis = null; | |
60 | + Ext.each(panelContext.plotArea.axes, function(axis) { | |
61 | + if (axis.id == axisId) | |
62 | + { | |
63 | + resAxis = axis; | |
64 | + return; | |
65 | + } | |
66 | + }); | |
67 | + | |
68 | + return resAxis; | |
69 | + }, | |
70 | + | |
38 | 71 | isInPlotArea : function(panelContext, xPos, yPos) |
39 | 72 | { |
40 | 73 | if (!panelContext.plotArea) |
... | ... |
js/app/views/PlotComponents/PlotResultImage.js
... | ... | @@ -18,8 +18,16 @@ Ext.define('amdaPlotComp.PlotResultImage', { |
18 | 18 | onMouseMove : null, |
19 | 19 | onClick : null, |
20 | 20 | |
21 | - verticalCursorDiv : null, | |
22 | - horizontalCursorDiv : null, | |
21 | + verticalCursor : null, | |
22 | + horizontalCursor : null, | |
23 | + | |
24 | + firstVerticalMarker : null, | |
25 | + secondVerticalMarker : null, | |
26 | + firstVerticalMarker : null, | |
27 | + secondVerticalMarker : null, | |
28 | + | |
29 | + showVerticalCursor : true, | |
30 | + showHorizontalCursor : true, | |
23 | 31 | |
24 | 32 | constructor: function(config) { |
25 | 33 | this.init(config); |
... | ... | @@ -33,53 +41,137 @@ Ext.define('amdaPlotComp.PlotResultImage', { |
33 | 41 | } |
34 | 42 | }, |
35 | 43 | |
36 | - createCursor : function() { | |
37 | - if (this.verticalCursorDiv == null) | |
44 | + createNewVerticalDiv : function() { | |
45 | + var verticalDiv = new Ext.Element(document.createElement('div')); | |
46 | + verticalDiv.setStyle('position', 'absolute'); | |
47 | + verticalDiv.setStyle('top', '1px'); | |
48 | + verticalDiv.setStyle('height', '1px'); | |
49 | + verticalDiv.setStyle('borderLeft', '1px none rgb(0, 0, 0)'); | |
50 | + verticalDiv.setStyle('pointer-events', 'none'); | |
51 | + this.el.parent().appendChild(verticalDiv); | |
52 | + return verticalDiv; | |
53 | + }, | |
54 | + | |
55 | + createNewHorizontalDiv : function() { | |
56 | + var horizontalDiv = new Ext.Element(document.createElement('div')); | |
57 | + horizontalDiv.setStyle('position', 'absolute'); | |
58 | + horizontalDiv.setStyle('left', '1px'); | |
59 | + horizontalDiv.setStyle('width', '1px'); | |
60 | + horizontalDiv.setStyle('borderTop', "1px none rgb(0, 0, 0)"); | |
61 | + horizontalDiv.setStyle('pointer-events', 'none'); | |
62 | + this.el.parent().appendChild(horizontalDiv); | |
63 | + return horizontalDiv; | |
64 | + }, | |
65 | + | |
66 | + resetCursor : function() { | |
67 | + if (this.horizontalCursor) | |
68 | + this.horizontalCursor.setStyle('borderTopStyle', 'none'); | |
69 | + if (this.verticalCursor) | |
70 | + this.verticalCursor.setStyle('borderLeftStyle', 'none'); | |
71 | + }, | |
72 | + | |
73 | + updateCursor : function(containerX, containerY, containerWidth, containerHeight, xPos, yPos) { | |
74 | + if (this.horizontalCursor && this.showHorizontalCursor) | |
38 | 75 | { |
39 | - this.verticalCursorDiv = new Ext.Element(document.createElement('div')); | |
40 | - this.verticalCursorDiv.setStyle('position', 'absolute'); | |
41 | - this.verticalCursorDiv.setStyle('top', '1px'); | |
42 | - this.verticalCursorDiv.setStyle('height', '1px'); | |
43 | - this.verticalCursorDiv.setStyle('borderLeft', '1px none rgb(0, 0, 0)'); | |
44 | - this.verticalCursorDiv.setStyle('pointer-events', 'none'); | |
45 | - this.el.parent().appendChild(this.verticalCursorDiv); | |
76 | + this.horizontalCursor.setStyle('left',containerX+'px'); | |
77 | + this.horizontalCursor.setStyle('top',yPos+'px'); | |
78 | + this.horizontalCursor.setStyle('width',containerWidth+'px'); | |
79 | + this.horizontalCursor.setStyle('borderTopStyle', 'solid'); | |
46 | 80 | } |
47 | - | |
48 | - if (this.horizontalCursorDiv == null) | |
81 | + if (this.verticalCursor && this.showVerticalCursor) | |
49 | 82 | { |
50 | - this.horizontalCursorDiv = new Ext.Element(document.createElement('div')); | |
51 | - this.horizontalCursorDiv.setStyle('position', 'absolute'); | |
52 | - this.horizontalCursorDiv.setStyle('left', '1px'); | |
53 | - this.horizontalCursorDiv.setStyle('width', '1px'); | |
54 | - this.horizontalCursorDiv.setStyle('borderTop', "1px none rgb(0, 0, 0)"); | |
55 | - this.horizontalCursorDiv.setStyle('pointer-events', 'none'); | |
56 | - this.el.parent().appendChild(this.horizontalCursorDiv); | |
83 | + this.verticalCursor.setStyle('left',xPos+'px'); | |
84 | + this.verticalCursor.setStyle('top',containerY+'px'); | |
85 | + this.verticalCursor.setStyle('height',containerHeight+'px'); | |
86 | + this.verticalCursor.setStyle('borderLeftStyle', 'solid'); | |
57 | 87 | } |
58 | - this.resetCursor(); | |
59 | 88 | }, |
60 | 89 | |
61 | - resetCursor : function() { | |
62 | - if (this.horizontalCursorDiv) | |
63 | - this.horizontalCursorDiv.setStyle('borderTopStyle', 'none'); | |
64 | - if (this.verticalCursorDiv) | |
65 | - this.verticalCursorDiv.setStyle('borderLeftStyle', 'none'); | |
90 | + resetZoom : function() { | |
91 | + //This function is override during a startZoom call | |
92 | + }, | |
93 | + | |
94 | + stopZoom : function() { | |
95 | + this.showVerticalCursor = true; | |
96 | + this.showHorizontalCursor = true; | |
97 | + this.resetZoom(); | |
98 | + this.onClick = null; | |
99 | + this.resetZoom = function() {}; | |
66 | 100 | }, |
67 | 101 | |
68 | - updateCursor : function(panelX, panelY, panelWidth, panelHeight, xPos, yPos) { | |
69 | - if (this.horizontalCursorDiv) | |
102 | + startZoom : function(isHorizontal, containerPos, containerSize, onSelectFirst, onSelectSecond) { | |
103 | + this.resetZoom(); | |
104 | + | |
105 | + //this.showVerticalCursor = isHorizontal; | |
106 | + //this.showHorizontalCursor = !isHorizontal; | |
107 | + this.resetCursor(); | |
108 | + | |
109 | + var me = this; | |
110 | + var selectFirst = null; | |
111 | + var selectSecond = null; | |
112 | + | |
113 | + selectSecond = function(x, y) | |
70 | 114 | { |
71 | - this.horizontalCursorDiv.setStyle('left',panelX+'px'); | |
72 | - this.horizontalCursorDiv.setStyle('top',yPos+'px'); | |
73 | - this.horizontalCursorDiv.setStyle('width',panelWidth+'px'); | |
74 | - this.horizontalCursorDiv.setStyle('borderTopStyle', 'solid'); | |
75 | - } | |
76 | - if (this.verticalCursorDiv) | |
115 | + if (isHorizontal) | |
116 | + { | |
117 | + me.secondVerticalMarker.setStyle('left',x+'px'); | |
118 | + me.secondVerticalMarker.setStyle('top',containerPos+'px'); | |
119 | + me.secondVerticalMarker.setStyle('height',containerSize+'px'); | |
120 | + me.secondVerticalMarker.setStyle('borderLeftStyle', 'dotted'); | |
121 | + if (onSelectSecond) | |
122 | + onSelectSecond(x); | |
123 | + } | |
124 | + else | |
125 | + { | |
126 | + me.secondHorizontalMarker.setStyle('left',containerPos+'px'); | |
127 | + me.secondHorizontalMarker.setStyle('top',y+'px'); | |
128 | + me.secondHorizontalMarker.setStyle('width',containerSize+'px'); | |
129 | + me.secondHorizontalMarker.setStyle('borderTopStyle', 'dotted'); | |
130 | + if (onSelectSecond) | |
131 | + onSelectSecond(y); | |
132 | + } | |
133 | + | |
134 | + me.onClick = selectFirst; | |
135 | + }; | |
136 | + | |
137 | + selectFirst = function(x, y) | |
77 | 138 | { |
78 | - this.verticalCursorDiv.setStyle('left',xPos+'px'); | |
79 | - this.verticalCursorDiv.setStyle('top',panelY+'px'); | |
80 | - this.verticalCursorDiv.setStyle('height',panelHeight+'px'); | |
81 | - this.verticalCursorDiv.setStyle('borderLeftStyle', 'solid'); | |
82 | - } | |
139 | + if (isHorizontal) | |
140 | + { | |
141 | + me.secondVerticalMarker.setStyle('borderLeftStyle', 'none'); | |
142 | + me.firstVerticalMarker.setStyle('left',x+'px'); | |
143 | + me.firstVerticalMarker.setStyle('top',containerPos+'px'); | |
144 | + me.firstVerticalMarker.setStyle('height',containerSize+'px'); | |
145 | + me.firstVerticalMarker.setStyle('borderLeftStyle', 'dotted'); | |
146 | + if (onSelectFirst) | |
147 | + onSelectFirst(x); | |
148 | + } | |
149 | + else | |
150 | + { | |
151 | + me.secondHorizontalMarker.setStyle('borderLeftStyle', 'none'); | |
152 | + me.firstHorizontalMarker.setStyle('left',containerPos+'px'); | |
153 | + me.firstHorizontalMarker.setStyle('top',y+'px'); | |
154 | + me.firstHorizontalMarker.setStyle('width',containerSize+'px'); | |
155 | + me.firstHorizontalMarker.setStyle('borderTopStyle', 'dotted'); | |
156 | + if (onSelectFirst) | |
157 | + onSelectFirst(y); | |
158 | + } | |
159 | + | |
160 | + me.onClick = selectSecond; | |
161 | + }; | |
162 | + | |
163 | + this.resetZoom = function() | |
164 | + { | |
165 | + me.firstVerticalMarker.setStyle('borderLeftStyle', 'none'); | |
166 | + me.secondVerticalMarker.setStyle('borderLeftStyle', 'none'); | |
167 | + me.firstHorizontalMarker.setStyle('borderTopStyle', 'none'); | |
168 | + me.secondHorizontalMarker.setStyle('borderTopStyle', 'none'); | |
169 | + | |
170 | + me.resetCursor(); | |
171 | + me.onClick = selectFirst; | |
172 | + }; | |
173 | + | |
174 | + this.onClick = selectFirst; | |
83 | 175 | }, |
84 | 176 | |
85 | 177 | init : function(config) { |
... | ... | @@ -90,11 +182,20 @@ Ext.define('amdaPlotComp.PlotResultImage', { |
90 | 182 | width : config.width, |
91 | 183 | height : config.height, |
92 | 184 | onMouseMove : config.onMouseMove, |
93 | - onClick : config.onClick, | |
185 | + onContextMenu : config.onContextMenu, | |
94 | 186 | listeners : { |
95 | 187 | render : function(img, eOpts){ |
96 | 188 | me.refreshMe(); |
97 | - me.createCursor(); | |
189 | + //Create cursor | |
190 | + me.verticalCursor = me.createNewVerticalDiv(); | |
191 | + me.horizontalCursor = me.createNewHorizontalDiv(); | |
192 | + //Create markers (used for zoom) | |
193 | + me.firstVerticalMarker = me.createNewVerticalDiv(); | |
194 | + me.secondVerticalMarker = me.createNewVerticalDiv(); | |
195 | + me.firstHorizontalMarker = me.createNewHorizontalDiv(); | |
196 | + me.secondHorizontalMarker = me.createNewHorizontalDiv(); | |
197 | + | |
198 | + me.resetCursor(); | |
98 | 199 | }, |
99 | 200 | el: { |
100 | 201 | click: function(e, t, eOpts) { |
... | ... | @@ -102,10 +203,19 @@ Ext.define('amdaPlotComp.PlotResultImage', { |
102 | 203 | me.onClick(e.getX()-me.getPosition()[0], e.getY()-me.getPosition()[1]); |
103 | 204 | }, |
104 | 205 | mousemove: function(e, t, eOpts){ |
105 | - me.verticalCursorDiv.setStyle('left', (e.getX()-me.getPosition()[0]-1)+"px"); | |
106 | - me.horizontalCursorDiv.setStyle('top', (e.getY()-me.getPosition()[1]-1)+"px"); | |
206 | + me.verticalCursor.setStyle('left', (e.getX()-me.getPosition()[0])+"px"); | |
207 | + me.horizontalCursor.setStyle('top', (e.getY()-me.getPosition()[1])+"px"); | |
107 | 208 | if (me.onMouseMove) |
108 | 209 | me.onMouseMove(e.getX()-me.getPosition()[0], e.getY()-me.getPosition()[1]); |
210 | + }, | |
211 | + contextmenu : function(event, t, eOpts ) { | |
212 | + event = event || window.event; | |
213 | + if (event.preventDefault) { | |
214 | + event.preventDefault(); | |
215 | + } | |
216 | + if (me.onContextMenu) | |
217 | + me.onContextMenu(event.getX(), event.getY(), event.getX()-me.getPosition()[0], event.getY()-me.getPosition()[1]); | |
218 | + return false; | |
109 | 219 | } |
110 | 220 | } |
111 | 221 | } |
... | ... |
... | ... | @@ -0,0 +1,363 @@ |
1 | +/** | |
2 | + * Project : AMDA-NG | |
3 | + * Name : PlotZoomPlug.js | |
4 | + * @plugin amdaPlotComp.PlotZoomPlug | |
5 | + * @extends Ext.util.Observable | |
6 | + * @ptype plotZoomPlugin | |
7 | + * @brief Plot Zoom UI (View) | |
8 | + * @author Benjamin | |
9 | + * @version $Id: PlotZoomPlug.js | |
10 | + ******************************************************************************** | |
11 | + * FT Id : Date : Name - Description | |
12 | + ******************************************************************************* | |
13 | + * : | |
14 | + */ | |
15 | + | |
16 | + | |
17 | +Ext.define('amdaPlotComp.PlotZoomPlug', { | |
18 | + extend: 'Ext.util.Observable', | |
19 | + alias: 'plugin.plotZoomPlugin', | |
20 | + | |
21 | + ttModuleId : 'timetab-win', | |
22 | + | |
23 | + win : null, | |
24 | + form : null, | |
25 | + zoomType : '', | |
26 | + tabId : '', | |
27 | + panelId : -1, | |
28 | + | |
29 | + constructor: function(config) { | |
30 | + Ext.apply(this, config); | |
31 | + this.callParent(arguments); | |
32 | + }, | |
33 | + | |
34 | + onDestroy : function() { | |
35 | + this.win = null; | |
36 | + }, | |
37 | + | |
38 | + init: function(cmp) { | |
39 | + this.hostCmp = cmp; | |
40 | + }, | |
41 | + | |
42 | + setMinValue : function(min) { | |
43 | + if (!this.form) | |
44 | + return; | |
45 | + | |
46 | + if (this.zoomType == 'timeAxis') | |
47 | + this.form.getForm().findField('zoom-min-time').setValue(min); | |
48 | + else | |
49 | + this.form.getForm().findField('zoom-min-float').setValue(min); | |
50 | + }, | |
51 | + | |
52 | + setMaxValue : function(max) { | |
53 | + if (!this.form) | |
54 | + return; | |
55 | + | |
56 | + if (this.zoomType == 'timeAxis') | |
57 | + { | |
58 | + var minValue = this.form.getForm().findField('zoom-min-time').getValue(); | |
59 | + if (minValue <= max) | |
60 | + this.form.getForm().findField('zoom-max-time').setValue(max); | |
61 | + else | |
62 | + { | |
63 | + this.form.getForm().findField('zoom-min-time').setValue(max); | |
64 | + this.form.getForm().findField('zoom-max-time').setValue(minValue); | |
65 | + } | |
66 | + } | |
67 | + else | |
68 | + { | |
69 | + var minValue = this.form.getForm().findField('zoom-min-float').getValue(); | |
70 | + if (minValue <= max) | |
71 | + this.form.getForm().findField('zoom-max-float').setValue(max); | |
72 | + else | |
73 | + { | |
74 | + this.form.getForm().findField('zoom-min-float').setValue(max); | |
75 | + this.form.getForm().findField('zoom-max-float').setValue(minValue); | |
76 | + } | |
77 | + } | |
78 | + }, | |
79 | + | |
80 | +/** | |
81 | + * add Interval to Time table | |
82 | + **/ | |
83 | + insertInterval: function() { | |
84 | + if (this.zoomType != 'timeAxis') | |
85 | + return; | |
86 | + | |
87 | + myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module){ | |
88 | + var targetModuleUI = targetModule.getUiContent(); | |
89 | + //if (targetModuleUI) | |
90 | + // targetModuleUI.addInterval(this.start,this.stop); | |
91 | + }); | |
92 | + }, | |
93 | + | |
94 | +/** | |
95 | + * creation of the window | |
96 | + */ | |
97 | + show : function(tabId, zoomType, panelId) { | |
98 | + if (!this.win) | |
99 | + { | |
100 | + this.win = new Ext.Window({ | |
101 | + id: 'plot-zoom-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID | |
102 | + width: 250, | |
103 | + height: 250, | |
104 | + x: 0, y: 0, | |
105 | + baseCls:'x-panel', | |
106 | + title: 'Zoom', | |
107 | + layout: 'fit', | |
108 | + constrain: true, | |
109 | + collapsible: true, | |
110 | + resizable: false, | |
111 | + ghost: false, | |
112 | + renderTo: this.hostCmp.ownerCt.body, | |
113 | + items: this.getFormConfig(), | |
114 | + listeners: { | |
115 | + scope: this, | |
116 | + beforeclose: function() { | |
117 | + this.hostCmp.panelImage.stopZoom(); | |
118 | + Ext.PluginManager.unregister(this); | |
119 | + } | |
120 | + }, | |
121 | + getConstrainVector: function(constrainTo){ | |
122 | + var me = this; | |
123 | + if (me.constrain || me.constrainHeader) { | |
124 | + constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent(); | |
125 | + return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo); | |
126 | + } | |
127 | + } | |
128 | + }); | |
129 | + | |
130 | + this.win.on('destroy', this.onDestroy, this); | |
131 | + | |
132 | + Ext.PluginManager.register(this); | |
133 | + } | |
134 | + | |
135 | + this.tabId = tabId; | |
136 | + this.updateWinByType(zoomType, panelId); | |
137 | + this.win.show(); | |
138 | + this.win.setPosition(0,0); | |
139 | + }, | |
140 | + | |
141 | + close : function() { | |
142 | + if (this.win == null) | |
143 | + return; | |
144 | + this.win.close(); | |
145 | + }, | |
146 | + | |
147 | + updateWinByType : function(zoomType, panelId) { | |
148 | + if (this.win == null) | |
149 | + return; | |
150 | + | |
151 | + this.zoomType = zoomType; | |
152 | + this.panelId = panelId; | |
153 | + | |
154 | + switch (zoomType) | |
155 | + { | |
156 | + case 'timeAxis': | |
157 | + this.win.setTitle('Zoom on time axis & Interval selection - Panel Id : '+panelId); | |
158 | + break; | |
159 | + case 'y-left' : | |
160 | + this.win.setTitle('Zoom on Y Left axis - Panel Id : '+panelId); | |
161 | + break; | |
162 | + case 'y-right' : | |
163 | + this.win.setTitle('Zoom on Y Right axis - Panel Id : '+panelId); | |
164 | + break; | |
165 | + case 'xaxis_id' : | |
166 | + this.win.setTitle('Zoom on X axis - Panel Id : '+panelId); | |
167 | + break; | |
168 | + } | |
169 | + | |
170 | + this.form.getForm().findField('zoom-min-time').setVisible(this.zoomType == 'timeAxis'); | |
171 | + this.form.getForm().findField('zoom-max-time').setVisible(this.zoomType == 'timeAxis'); | |
172 | + | |
173 | + this.form.getForm().findField('zoom-min-float').setVisible(this.zoomType != 'timeAxis'); | |
174 | + this.form.getForm().findField('zoom-max-float').setVisible(this.zoomType != 'timeAxis'); | |
175 | + | |
176 | + var ttNameField = this.form.getForm().findField('tt-name'); | |
177 | + if (ttNameField) | |
178 | + ttNameField.findParentByType('fieldset').setVisible(this.zoomType == 'timeAxis'); | |
179 | + | |
180 | + this.win.setHeight((this.zoomType == 'timeAxis') ? 250 : 160); | |
181 | + }, | |
182 | + | |
183 | + resetMinMaxValue: function() { | |
184 | + if (this.zoomType == 'timeAxis') | |
185 | + { | |
186 | + this.form.getForm().findField('zoom-min-time').setValue(''); | |
187 | + this.form.getForm().findField('zoom-max-time').setValue(''); | |
188 | + } | |
189 | + else | |
190 | + { | |
191 | + this.form.getForm().findField('zoom-min-float').setValue(null); | |
192 | + this.form.getForm().findField('zoom-max-float').setValue(null); | |
193 | + } | |
194 | + | |
195 | + this.hostCmp.panelImage.resetZoom(); | |
196 | + }, | |
197 | + | |
198 | +/** | |
199 | + * Main form | |
200 | + */ | |
201 | + getFormConfig: function(){ | |
202 | + | |
203 | + var intervalFieldSet = { | |
204 | + xtype: 'fieldset', | |
205 | + title: 'Interval Selection', | |
206 | + name: 'interval-selection-fieldset', | |
207 | + collapsible: false, | |
208 | + layout: { | |
209 | + type: 'vbox', | |
210 | + pack: 'start', | |
211 | + align: 'stretch' | |
212 | + }, | |
213 | + items : [ | |
214 | + { | |
215 | + xtype:'datefield', name:'zoom-min-time', fieldLabel: 'Start Time', | |
216 | + format : 'Y-m-d\\TH:i:s' | |
217 | + }, | |
218 | + { | |
219 | + xtype:'datefield', name:'zoom-max-time', fieldLabel: 'Stop Time', | |
220 | + format : 'Y-m-d\\TH:i:s' | |
221 | + }, | |
222 | + { | |
223 | + xtype:'numberfield', name:'zoom-min-float', fieldLabel: 'Min Value' | |
224 | + }, | |
225 | + { | |
226 | + xtype:'numberfield', name:'zoom-max-float', fieldLabel: 'Max Value' | |
227 | + }, | |
228 | + { | |
229 | + xtype: 'button', | |
230 | + width: 100, | |
231 | + text: 'Reset interval', | |
232 | + scope: this, | |
233 | + handler: function() { | |
234 | + this.resetMinMaxValue(); | |
235 | + } | |
236 | + } | |
237 | + ] | |
238 | + }; | |
239 | + | |
240 | + var insertTTFieldSet = { | |
241 | + xtype: 'fieldset', | |
242 | + title: 'TimeTable Insertion', | |
243 | + name: 'tt-insertion-fieldset', | |
244 | + collapsible: false, | |
245 | + layout: { | |
246 | + type: 'vbox', | |
247 | + pack: 'start', | |
248 | + align: 'stretch' | |
249 | + }, | |
250 | + items : [ | |
251 | + { | |
252 | + xtype: 'textfield', | |
253 | + fieldLabel: 'TimeTable Name', | |
254 | + name: 'tt-name', | |
255 | + listeners : | |
256 | + { | |
257 | + render : function(o,op) | |
258 | + { | |
259 | + var me = this; | |
260 | + var el = me.el; | |
261 | + var dropTarget = Ext.create('Ext.dd.DropTarget', el, { | |
262 | + ddGroup: 'explorerTree', | |
263 | + notifyOver : function(ddSource, e, data) | |
264 | + { | |
265 | + if ((data.records[0].data.nodeType == 'timeTable') && (data.records[0].data.leaf)) | |
266 | + { | |
267 | + this.valid = true; | |
268 | + return this.dropAllowed; | |
269 | + } | |
270 | + this.valid = false; | |
271 | + return this.dropNotAllowed; | |
272 | + }, | |
273 | + notifyDrop : function(ddSource, e, data) | |
274 | + { | |
275 | + if (!this.valid) | |
276 | + return false; | |
277 | + me.setValue(data.records[0].get('text')); | |
278 | + return true; | |
279 | + } | |
280 | + }); | |
281 | + } | |
282 | + } | |
283 | + }, | |
284 | + { | |
285 | + xtype: 'button', | |
286 | + width: 100, | |
287 | + text: 'Insert Interval', | |
288 | + scope: this, | |
289 | + handler: function(){ | |
290 | + if (this.zoomType != 'timeAxis') | |
291 | + return; | |
292 | + | |
293 | + this.start = this.form.getForm().findField('zoom-min-time').getValue(); | |
294 | + this.stop = this.form.getForm().findField('zoom-max-time').getValue(); | |
295 | + // new TimeTable or typed manually | |
296 | + var me = this; | |
297 | + var targetModule = myDesktopApp.getLoadedModule(this.ttModuleId, true, function(module) { | |
298 | + var targetModuleUI = module.getUiContent(); | |
299 | + var TTname = me.form.getForm().findField('tt-name').getValue(); | |
300 | + //ToDo | |
301 | + }); | |
302 | + | |
303 | + } | |
304 | + } | |
305 | + ] | |
306 | + }; | |
307 | + | |
308 | + this.form = new Ext.form.FormPanel( { | |
309 | + frame: true, | |
310 | + width: 250, | |
311 | + height: 250, | |
312 | + layout: { | |
313 | + type: 'vbox', | |
314 | + pack: 'start', | |
315 | + align: 'stretch' | |
316 | + }, | |
317 | + fieldDefaults: { | |
318 | + labelWidth: 60 | |
319 | + }, | |
320 | + items: [ | |
321 | + intervalFieldSet, | |
322 | + insertTTFieldSet | |
323 | + ], | |
324 | + fbar : [ | |
325 | + { | |
326 | + text: 'Apply Zoom', | |
327 | + width: 100, | |
328 | + scope: this, | |
329 | + handler: function(){ | |
330 | + if (this.zoomType == 'timeAxis') | |
331 | + { | |
332 | + var minZoom = this.form.getForm().findField('zoom-min-time').getValue(); | |
333 | + var maxZoom = this.form.getForm().findField('zoom-max-time').getValue(); | |
334 | + } | |
335 | + else | |
336 | + { | |
337 | + var minZoom = this.form.getForm().findField('zoom-min-float').getValue(); | |
338 | + var maxZoom = this.form.getForm().findField('zoom-max-float').getValue(); | |
339 | + } | |
340 | + | |
341 | + if(!maxZoom || !minZoom || !this.form.getForm().isValid()) { | |
342 | + myDesktopApp.warningMsg('Error in values definition'); | |
343 | + return; | |
344 | + } | |
345 | + | |
346 | + this.hostCmp.callInteractivePlot({'action' : 'zoom', 'tabId' : this.tabId, 'panelId' : this.panelId, 'axeId' : this.zoomType, 'min' : minZoom, 'max' : maxZoom}); | |
347 | + this.hostCmp.panelImage.resetZoom(); | |
348 | + } | |
349 | + }, | |
350 | + { | |
351 | + text: 'Undo Zoom', | |
352 | + width: 100, | |
353 | + scope : this, | |
354 | + handler: function(){ | |
355 | + this.hostCmp.callInteractivePlot({'action' : 'undozoom', 'tabId' : this.tabId, 'panelId' : this.panelId, 'axeId' : this.zoomType}); | |
356 | + this.hostCmp.panelImage.resetZoom(); | |
357 | + } | |
358 | + } | |
359 | + ] | |
360 | + }); | |
361 | + return this.form; | |
362 | + } | |
363 | +}); | |
0 | 364 | \ No newline at end of file |
... | ... |
js/app/views/PlotTabResultUI.js
... | ... | @@ -18,12 +18,13 @@ Ext.define('amdaUI.PlotTabResultUI', { |
18 | 18 | alias: 'widget.plotTabResult', |
19 | 19 | |
20 | 20 | requires: [ |
21 | - 'amdaUI.InteractiveIntervalPlugin', | |
21 | + 'amdaPlotComp.PlotZoomPlug', | |
22 | 22 | 'amdaPlotComp.PlotContextManager' |
23 | 23 | ], |
24 | 24 | |
25 | 25 | panelImage : null, |
26 | 26 | crtContext : null, |
27 | + tabId : '', | |
27 | 28 | |
28 | 29 | constructor: function(config) { |
29 | 30 | this.addEvents({'pagesize':true}); |
... | ... | @@ -57,6 +58,127 @@ Ext.define('amdaUI.PlotTabResultUI', { |
57 | 58 | return value*this.sliderPage.getValue()/100; |
58 | 59 | }, |
59 | 60 | |
61 | + createZoomItemsForPanel: function(panelId) { | |
62 | + var zoomPlugin = this.getPlugin('plot-zoom-plugin-id'); | |
63 | + if (zoomPlugin == null) | |
64 | + return; | |
65 | + | |
66 | + var panelContext = amdaPlotComp.PlotContextManager.getPanelById(this.crtContext, panelId); | |
67 | + | |
68 | + var me = this; | |
69 | + Ext.each(panelContext.plotArea.axes, function (axis) { | |
70 | + //Events for zoom on a time axis | |
71 | + var onMinTimeSelection = function (posX) { | |
72 | + //Panel and axis context must be retrieved by using the crtContext | |
73 | + var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId); | |
74 | + var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id); | |
75 | + var sourceXPos = me.toPixelOnSourceImage(posX); | |
76 | + var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x+panelContext.plotArea.width, sourceXPos); | |
77 | + var crtTime = new Date(crtTimestamp*1000); | |
78 | + crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset()); | |
79 | + zoomPlugin.setMinValue(crtTime); | |
80 | + }; | |
81 | + | |
82 | + var onMaxTimeSelection = function (posX) { | |
83 | + //Panel and axis context must be retrieved by using the crtContext | |
84 | + var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId); | |
85 | + var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id); | |
86 | + var sourceXPos = me.toPixelOnSourceImage(posX); | |
87 | + var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x+panelContext.plotArea.width, sourceXPos); | |
88 | + var crtTime = new Date(crtTimestamp*1000); | |
89 | + crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset()); | |
90 | + zoomPlugin.setMaxValue(crtTime); | |
91 | + }; | |
92 | + | |
93 | + //Events for zoom on a Y axis | |
94 | + var onMinYValueSelection = function(posY) { | |
95 | + //Panel and axis context must be retrieved by using the crtContext | |
96 | + var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId); | |
97 | + var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id); | |
98 | + var sourceYPos = me.toPixelOnSourceImage(posY); | |
99 | + var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.y+panelContext.plotArea.height, panelContext.plotArea.y, sourceYPos); | |
100 | + zoomPlugin.setMinValue(crtValue); | |
101 | + }; | |
102 | + | |
103 | + var onMaxYValueSelection = function(posY) { | |
104 | + //Panel and axis context must be retrieved by using the crtContext | |
105 | + var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId); | |
106 | + var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id); | |
107 | + var sourceYPos = me.toPixelOnSourceImage(posY); | |
108 | + var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.y+panelContext.plotArea.height, panelContext.plotArea.y, sourceYPos); | |
109 | + zoomPlugin.setMaxValue(crtValue); | |
110 | + }; | |
111 | + | |
112 | + //Events for zoom on X axis | |
113 | + var onMinXValueSelection = function(posX) { | |
114 | + //Panel and axis context must be retrieved by using the crtContext | |
115 | + var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId); | |
116 | + var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id); | |
117 | + var sourceXPos = me.toPixelOnSourceImage(posX); | |
118 | + var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x + panelContext.plotArea.width, sourceXPos); | |
119 | + zoomPlugin.setMinValue(crtValue); | |
120 | + }; | |
121 | + | |
122 | + var onMaxXValueSelection = function(posX) { | |
123 | + //Panel and axis context must be retrieved by using the crtContext | |
124 | + var panelContext = amdaPlotComp.PlotContextManager.getPanelById(me.crtContext, panelId); | |
125 | + var axisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panelContext, axis.id); | |
126 | + var sourceXPos = me.toPixelOnSourceImage(posX); | |
127 | + var crtValue = amdaPlotComp.PlotContextManager.toAxisValue(axisContext, panelContext.plotArea.x, panelContext.plotArea.x + panelContext.plotArea.width, sourceXPos); | |
128 | + zoomPlugin.setMaxValue(crtValue); | |
129 | + }; | |
130 | + | |
131 | + switch (axis.id) | |
132 | + { | |
133 | + case 'timeAxis': | |
134 | + me.contextualMenu.add({ | |
135 | + text:'Zoom on Time Axis', | |
136 | + handler : function(item, e) { | |
137 | + zoomPlugin.show(me.tabId, axis.id, panelContext.id); | |
138 | + zoomPlugin.resetMinMaxValue(); | |
139 | + me.panelImage.startZoom(true, me.toPixelOnResultImage(panelContext.y), me.toPixelOnResultImage(panelContext.height), onMinTimeSelection, onMaxTimeSelection); | |
140 | + }, | |
141 | + scope: this | |
142 | + }); | |
143 | + break; | |
144 | + case 'y-left' : | |
145 | + me.contextualMenu.add({ | |
146 | + text:'Zoom on Y Left Axis', | |
147 | + handler : function(item, e) { | |
148 | + zoomPlugin.show(me.tabId, axis.id, panelContext.id); | |
149 | + zoomPlugin.resetMinMaxValue(); | |
150 | + me.panelImage.startZoom(false, me.toPixelOnResultImage(panelContext.x), me.toPixelOnResultImage(panelContext.width), onMinYValueSelection, onMaxYValueSelection); | |
151 | + } | |
152 | + }); | |
153 | + break; | |
154 | + case 'y-right' : | |
155 | + me.contextualMenu.add({ | |
156 | + text:'Zoom on Y Right Axis', | |
157 | + handler : function(item, e) { | |
158 | + zoomPlugin.show(me.tabId, axis.id, panelContext.id); | |
159 | + zoomPlugin.resetMinMaxValue(); | |
160 | + me.panelImage.startZoom(false, me.toPixelOnResultImage(panelContext.x), me.toPixelOnResultImage(panelContext.width), onMinYValueSelection, onMaxYValueSelection); | |
161 | + } | |
162 | + }); | |
163 | + break; | |
164 | + case 'xaxis_id' : | |
165 | + me.contextualMenu.add({ | |
166 | + text:'Zoom on X Axis', | |
167 | + handler : function(item, e) { | |
168 | + zoomPlugin.show(me.tabId, axis.id, panelContext.id); | |
169 | + zoomPlugin.resetMinMaxValue(); | |
170 | + me.panelImage.startZoom(true, me.toPixelOnResultImage(panelContext.y), me.toPixelOnResultImage(panelContext.height), onMinXValueSelection, onMaxXValueSelection); | |
171 | + } | |
172 | + }); | |
173 | + break; | |
174 | + case 'epochAxis' : | |
175 | + //Nothing to add | |
176 | + break; | |
177 | + } | |
178 | + | |
179 | + }); | |
180 | + }, | |
181 | + | |
60 | 182 | createPlotImage: function(resultFolder, plotFile) { |
61 | 183 | var me = this; |
62 | 184 | var size = this.getImageSize(); |
... | ... | @@ -139,9 +261,31 @@ Ext.define('amdaUI.PlotTabResultUI', { |
139 | 261 | } |
140 | 262 | me.coordinatesField.setText(text); |
141 | 263 | }, |
142 | - onClick : function(x, y) { | |
143 | - //console.log('position : '+me.toPixelOnSourceImage(x)+', '+me.toPixelOnSourceImage(y)); | |
144 | - }, | |
264 | + onContextMenu : function(absoluteX, absoluteY, imageX, imageY) { | |
265 | + if (!me.crtContext) | |
266 | + return; | |
267 | + | |
268 | + me.contextualMenu.removeAll(); | |
269 | + | |
270 | + var sourceXPos = me.toPixelOnSourceImage(imageX); | |
271 | + var sourceYPos = me.toPixelOnSourceImage(imageY); | |
272 | + var panel = amdaPlotComp.PlotContextManager.getPanel(me.crtContext, sourceXPos, sourceYPos); | |
273 | + | |
274 | + if (panel != null) | |
275 | + { | |
276 | + if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos)) | |
277 | + me.createZoomItemsForPanel(panel.id); | |
278 | + } | |
279 | + | |
280 | + if (me.contextualMenu.items.getCount() > 0) | |
281 | + me.contextualMenu.add('-'); | |
282 | + | |
283 | + me.contextualMenu.add({ | |
284 | + text:'Extend/Shift Time request' | |
285 | + }); | |
286 | + | |
287 | + me.contextualMenu.showAt(absoluteX, absoluteY); | |
288 | + } | |
145 | 289 | }); |
146 | 290 | |
147 | 291 | return this.panelImage; |
... | ... | @@ -158,8 +302,38 @@ Ext.define('amdaUI.PlotTabResultUI', { |
158 | 302 | this.panelImage.refreshMe(); |
159 | 303 | }, |
160 | 304 | |
305 | + callInteractivePlot : function(obj) { | |
306 | + loadMask.show(true); | |
307 | + AmdaAction.interactivePlot(obj, function (result, e) { | |
308 | + loadMask.hide(); | |
309 | + var t = e.getTransaction(); | |
310 | + if (e.status) | |
311 | + { | |
312 | + if (result) | |
313 | + { | |
314 | + if (result.success) | |
315 | + { | |
316 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { | |
317 | + module.startInteractiveSession(result); | |
318 | + }); | |
319 | + } | |
320 | + else | |
321 | + myDesktopApp.errorMsg('Interactive action error - '+result.message); | |
322 | + } | |
323 | + else | |
324 | + myDesktopApp.errorMsg('Cannot execute interactive action'); | |
325 | + } | |
326 | + else | |
327 | + { | |
328 | + // FAILURE | |
329 | + myDesktopApp.errorMsg('Error System - '+e.message); | |
330 | + } | |
331 | + },this); | |
332 | + }, | |
333 | + | |
161 | 334 | init: function(configResult){ |
162 | 335 | this.crtContext = configResult.context; |
336 | + this.tabId = configResult.tabId; | |
163 | 337 | |
164 | 338 | this.coordinatesField = new Ext.toolbar.TextItem({ |
165 | 339 | width: 300, |
... | ... | @@ -178,7 +352,8 @@ Ext.define('amdaUI.PlotTabResultUI', { |
178 | 352 | scope : this, |
179 | 353 | changecomplete: function(s, v) |
180 | 354 | { |
181 | - //ToDo - this.resetMire(); | |
355 | + var zoomPlugin = this.getPlugin('plot-zoom-plugin-id'); | |
356 | + zoomPlugin.close(); | |
182 | 357 | var size = this.getImageSize(); |
183 | 358 | this.panelImage.width = size.width; |
184 | 359 | this.panelImage.height = size.height; |
... | ... | @@ -188,16 +363,24 @@ Ext.define('amdaUI.PlotTabResultUI', { |
188 | 363 | } |
189 | 364 | }); |
190 | 365 | |
366 | + | |
367 | + | |
191 | 368 | var mouseToolbar = { |
192 | 369 | xtype: 'toolbar', |
193 | 370 | height: 25, |
194 | 371 | dock: 'bottom', |
195 | 372 | items:[ |
196 | 373 | this.coordinatesField, |
374 | + '->', | |
197 | 375 | this.sliderPage |
198 | 376 | ] |
199 | 377 | }; |
200 | 378 | |
379 | + this.contextualMenu = Ext.create('Ext.menu.Menu', { | |
380 | + width: 200, | |
381 | + plain: true, | |
382 | + items: [] | |
383 | + }); | |
201 | 384 | |
202 | 385 | var plotResultTabPanelConfig = { |
203 | 386 | preventHeader : true, |
... | ... | @@ -205,7 +388,11 @@ Ext.define('amdaUI.PlotTabResultUI', { |
205 | 388 | items: [ |
206 | 389 | this.createPlotImage(configResult.folder, configResult.plotFile) |
207 | 390 | ], |
208 | - dockedItems: [mouseToolbar] | |
391 | + dockedItems: [mouseToolbar], | |
392 | + plugins: [ { | |
393 | + ptype: 'plotZoomPlugin', | |
394 | + pluginId : 'plot-zoom-plugin-id' | |
395 | + }] | |
209 | 396 | }; |
210 | 397 | |
211 | 398 | Ext.apply(this , plotResultTabPanelConfig); |
... | ... |
php/classes/AmdaAction.php
... | ... | @@ -1240,6 +1240,12 @@ class AmdaAction { |
1240 | 1240 | unlink(USERDIR.$name); |
1241 | 1241 | return array('success' => true); |
1242 | 1242 | } |
1243 | + | |
1244 | + public function interactivePlot($obj) | |
1245 | + { | |
1246 | + require_once(INTEGRATION_SRC_DIR."RequestManager.php"); | |
1247 | + return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION); | |
1248 | + } | |
1243 | 1249 | } |
1244 | 1250 | ?> |
1245 | 1251 | |
... | ... |