Commit c9071a43fa3125853488390faba93ff82837a9bc
1 parent
f8f533d6
Exists in
master
and in
111 other branches
Add instant plot preview
Showing
3 changed files
with
210 additions
and
16 deletions
Show diff stats
js/app/controllers/PlotModule.js
... | ... | @@ -15,7 +15,8 @@ Ext.define('amdaDesktop.PlotModule', { |
15 | 15 | 'amdaUI.PlotUI', |
16 | 16 | 'amdaPlotObj.PlotRequestObject', |
17 | 17 | 'amdaModel.PlotNode', |
18 | - 'amdaUI.PlotTabResultUI' | |
18 | + 'amdaUI.PlotTabResultUI', | |
19 | + 'amdaPlotComp.PlotPreviewUI' | |
19 | 20 | ], |
20 | 21 | |
21 | 22 | contentId : 'plotUI', |
... | ... | @@ -26,7 +27,6 @@ Ext.define('amdaDesktop.PlotModule', { |
26 | 27 | * @required |
27 | 28 | */ |
28 | 29 | nodeDataModel : 'amdaModel.PlotNode', |
29 | - //objectDataModel : 'amdaPlotObj.PlotRequestObject', | |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @cfg {String} window definitions |
... | ... | @@ -39,19 +39,6 @@ Ext.define('amdaDesktop.PlotModule', { |
39 | 39 | |
40 | 40 | plotResultWindowsManager : new Ext.AbstractManager(), |
41 | 41 | |
42 | - saveState: function() { | |
43 | - /*var uiContent = this.getUiContent(); | |
44 | - var form = uiContent.down('form').getForm(); | |
45 | - var values = form.getValues(); | |
46 | - // Ext.state.Manager.set(this.id + '_form', values); | |
47 | - Ext.state.Manager.set('timeinterval', {'startDate' : values.startDate,'stopDate' : values.stopDate });*/ | |
48 | - }, | |
49 | - | |
50 | - getState : function() { | |
51 | - // return Ext.state.Manager.get(this.id + '_form'); | |
52 | - return Ext.state.Manager.get('timeinterval'); | |
53 | - }, | |
54 | - | |
55 | 42 | computeResultWindowSize : function(panelResult) |
56 | 43 | { |
57 | 44 | var size = panelResult.getImageSize(); |
... | ... | @@ -60,10 +47,34 @@ Ext.define('amdaDesktop.PlotModule', { |
60 | 47 | |
61 | 48 | return size; |
62 | 49 | }, |
50 | + | |
51 | + computePreviewWindowSize : function(previewContent) | |
52 | + { | |
53 | + var size = previewContent.getImageSize(); | |
54 | + size.width += 30; | |
55 | + size.height += 65; | |
56 | + | |
57 | + return size; | |
58 | + }, | |
63 | 59 | |
64 | 60 | updateInteractiveSession : function(session, newplot) { |
65 | 61 | var me = this; |
62 | + | |
63 | + | |
64 | + | |
66 | 65 | Ext.each(session.result, function (tabResult, index) { |
66 | + if (tabResult.preview) | |
67 | + { | |
68 | + var plotPreviewConfig = { | |
69 | + folder : session.folder, | |
70 | + plotFile : tabResult.plot, | |
71 | + context : tabResult.context, | |
72 | + tabId : tabResult.id | |
73 | + }; | |
74 | + me.updatePreview(plotPreviewConfig); | |
75 | + return; | |
76 | + } | |
77 | + | |
67 | 78 | var winResultId = tabResult.id+"-win"; |
68 | 79 | |
69 | 80 | var winResult = me.getWindowResult(winResultId); |
... | ... | @@ -130,10 +141,55 @@ Ext.define('amdaDesktop.PlotModule', { |
130 | 141 | }); |
131 | 142 | }, |
132 | 143 | |
144 | + updatePreview : function(plotPreviewConfig) { | |
145 | + var winPreviewId = "plot-preview-win"; | |
146 | + | |
147 | + var winPreview = this.getWindowResult(winPreviewId); | |
148 | + | |
149 | + if (winPreview == null) { | |
150 | + //create new preview win | |
151 | + var previewContent = new amdaPlotComp.PlotPreviewUI(plotPreviewConfig); | |
152 | + | |
153 | + var size = this.computePreviewWindowSize(previewContent); | |
154 | + | |
155 | + var win = myDesktopApp.getDesktop().createWindow({ | |
156 | + id : winPreviewId, | |
157 | + title : 'Plot Preview', | |
158 | + width : size.width, | |
159 | + height: size.height, | |
160 | + layout: 'fit', | |
161 | + items : [ | |
162 | + previewContent | |
163 | + ], | |
164 | + listeners: { | |
165 | + scope: this, | |
166 | + beforeclose: function(win,opt) { | |
167 | + this.plotResultWindowsManager.unregister(win); | |
168 | + } | |
169 | + }, | |
170 | + getPreviewContent: function() { | |
171 | + return previewContent; | |
172 | + } | |
173 | + }); | |
174 | + win.show(); | |
175 | + this.plotResultWindowsManager.register(win); | |
176 | + } | |
177 | + else | |
178 | + { | |
179 | + //update result | |
180 | + winPreview.getPreviewContent().updatePlotImage(plotPreviewConfig); | |
181 | + //update window size | |
182 | + var size = this.computePreviewWindowSize(winPreview.getPreviewContent()); | |
183 | + winPreview.setSize(size.width, size.height); | |
184 | + winPreview.toFront(); | |
185 | + } | |
186 | + }, | |
187 | + | |
133 | 188 | getInteractiveMultiPlotState : function() { |
134 | 189 | var state = {}; |
135 | 190 | this.plotResultWindowsManager.each(function (key, value, length) { |
136 | - state[value.getPanelResult().tabId] = value.getPanelResult().getInteractiveMultiPlotState(); | |
191 | + if (value.getPanelResult) | |
192 | + state[value.getPanelResult().tabId] = value.getPanelResult().getInteractiveMultiPlotState(); | |
137 | 193 | }); |
138 | 194 | return state; |
139 | 195 | }, | ... | ... |
... | ... | @@ -0,0 +1,118 @@ |
1 | +/** | |
2 | + * Projectย : AMDA-NG | |
3 | + * Name : PlotPreviewUI.js | |
4 | + * @class amdaPlotComp.PlotPreviewUI | |
5 | + * @extends Ext. panel.Panel | |
6 | + * @brief Plot Preview UI definition (View) | |
7 | + * @author | |
8 | + * @version $Id: PlotPreviewUI.js benjamin $ | |
9 | + ******************************************************************************** | |
10 | + * FT Id : Date : Name - Description | |
11 | + ******************************************************************************* | |
12 | + * | |
13 | + */ | |
14 | + | |
15 | +Ext.define('amdaPlotComp.PlotPreviewUI', { | |
16 | + extend: 'Ext.panel.Panel', | |
17 | + | |
18 | + alias: 'widget.plotPreview', | |
19 | + | |
20 | + requires: [ | |
21 | + 'amdaPlotComp.PlotContextManager' | |
22 | + ], | |
23 | + | |
24 | + panelImage : null, | |
25 | + crtContext : null, | |
26 | + sliderPage : null, | |
27 | + | |
28 | + constructor: function(config) { | |
29 | + this.init(config); | |
30 | + this.callParent(arguments); | |
31 | + }, | |
32 | + | |
33 | + getImageSize : function() { | |
34 | + if (!this.crtContext) | |
35 | + return { | |
36 | + width : 0, | |
37 | + height : 0 | |
38 | + }; | |
39 | + | |
40 | + return { | |
41 | + width : this.crtContext.page.width * this.sliderPage.getValue()/100., | |
42 | + height : this.crtContext.page.height * this.sliderPage.getValue()/100. | |
43 | + } | |
44 | + }, | |
45 | + | |
46 | + getImageUrl: function(resultFolder, plotFile) { | |
47 | + return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile; | |
48 | + }, | |
49 | + | |
50 | + createPlotImage: function(resultFolder, plotFile) { | |
51 | + var me = this; | |
52 | + var size = this.getImageSize(); | |
53 | + this.panelImage = Ext.create('amdaPlotComp.PlotResultImage', { | |
54 | + src : this.getImageUrl(resultFolder, plotFile), | |
55 | + width : size.width, | |
56 | + height : size.height | |
57 | + }); | |
58 | + | |
59 | + return this.panelImage; | |
60 | + }, | |
61 | + | |
62 | + updatePlotImage: function(configResult, newPlot) { | |
63 | + this.crtContext = configResult.context; | |
64 | + | |
65 | + this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile)); | |
66 | + | |
67 | + var size = this.getImageSize(); | |
68 | + this.panelImage.setSize(size.width, size.height); | |
69 | + | |
70 | + this.panelImage.refreshMe(); | |
71 | + }, | |
72 | + | |
73 | + init: function(configResult){ | |
74 | + this.crtContext = configResult.context; | |
75 | + this.tabId = configResult.tabId; | |
76 | + | |
77 | + this.sliderPage = new Ext.slider.Single({ | |
78 | + width: 130, | |
79 | + value: 75, | |
80 | + increment: 5, | |
81 | + minValue: 50, | |
82 | + maxValue: 100, | |
83 | + fieldLabel : 'Resize', | |
84 | + labelWidth : 40, | |
85 | + listeners: { | |
86 | + scope : this, | |
87 | + changecomplete: function(s, v) | |
88 | + { | |
89 | + var size = this.getImageSize(); | |
90 | + this.panelImage.width = size.width; | |
91 | + this.panelImage.height = size.height; | |
92 | + this.panelImage.doComponentLayout(); | |
93 | + } | |
94 | + } | |
95 | + }); | |
96 | + | |
97 | + var bottomToolbar = { | |
98 | + xtype: 'toolbar', | |
99 | + height: 25, | |
100 | + dock: 'bottom', | |
101 | + items:[ | |
102 | + '->', | |
103 | + this.sliderPage | |
104 | + ] | |
105 | + }; | |
106 | + | |
107 | + var plotPreviewPanelConfig = { | |
108 | + preventHeader : true, | |
109 | + autoScroll: true, | |
110 | + items: [ | |
111 | + this.createPlotImage(configResult.folder, configResult.plotFile) | |
112 | + ], | |
113 | + dockedItems: [bottomToolbar] | |
114 | + }; | |
115 | + | |
116 | + Ext.apply(this , plotPreviewPanelConfig); | |
117 | + } | |
118 | +}); | |
0 | 119 | \ No newline at end of file | ... | ... |
js/app/views/PlotTabResultUI.js
... | ... | @@ -285,6 +285,26 @@ Ext.define('amdaUI.PlotTabResultUI', { |
285 | 285 | |
286 | 286 | if (panel != null) |
287 | 287 | { |
288 | + if (panel.plotArea.hasSpectro) | |
289 | + { | |
290 | + me.contextualMenu.add([ | |
291 | + { | |
292 | + text:'Instant cut at this position', | |
293 | + handler : function () | |
294 | + { | |
295 | + var timeAxisContext = amdaPlotComp.PlotContextManager.getPanelAxisById(panel, 'timeAxis'); | |
296 | + if (timeAxisContext == null) | |
297 | + return; | |
298 | + var crtTimestamp = amdaPlotComp.PlotContextManager.toAxisValue(timeAxisContext, panel.plotArea.x, panel.plotArea.x+panel.plotArea.width, sourceXPos); | |
299 | + var crtTime = new Date(crtTimestamp*1000); | |
300 | + crtTime = Ext.Date.add(crtTime, Ext.Date.MINUTE, crtTime.getTimezoneOffset()); | |
301 | + me.callInteractivePlot({'action' : 'instant', 'tabId' : this.tabId, 'panelId' : panel.id, 'time' : crtTime}); | |
302 | + }, | |
303 | + scope: me | |
304 | + }, | |
305 | + '-' | |
306 | + ]); | |
307 | + } | |
288 | 308 | if (amdaPlotComp.PlotContextManager.isInPlotArea(panel, sourceXPos, sourceYPos)) |
289 | 309 | me.createZoomItemsForPanel(panel.id); |
290 | 310 | } | ... | ... |