Blame view

js/app/views/PlotComponents/PlotPreviewUI.js 4.14 KB
c9071a43   Benjamin Renard   Add instant plot ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * Project   : AMDA-NG
 * Name      : PlotPreviewUI.js
 * @class    amdaPlotComp.PlotPreviewUI
 * @extends  Ext. panel.Panel
 * @brief    Plot Preview UI definition (View)
 * @author    
 * @version  $Id: PlotPreviewUI.js benjamin $
 ********************************************************************************
 *    FT Id     :   Date   : Name - Description
 *******************************************************************************
 *              
 */

Ext.define('amdaPlotComp.PlotPreviewUI', {
    extend: 'Ext.panel.Panel',
 
    alias: 'widget.plotPreview',

    requires: [
b3cfb4b8   Benjamin Renard   Add missing requires
21
22
        'amdaPlotComp.PlotContextManager',
        'amdaPlotComp.PlotResultImage'
c9071a43   Benjamin Renard   Add instant plot ...
23
24
25
26
27
    ],
    
    panelImage : null,
    crtContext : null,
    sliderPage : null,
ebafe59e   Benjamin Renard   Add the possibili...
28
29
    contextualMenu : null,
    hiddenForm: null,
c9071a43   Benjamin Renard   Add instant plot ...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

    constructor: function(config) {
        this.init(config);	 
        this.callParent(arguments);	 
    },  
    
    getImageSize : function() {
    	if (!this.crtContext)
    		return {
    			width : 0,
    			height : 0
    		};
    		
    	return  {
    			width  : this.crtContext.page.width * this.sliderPage.getValue()/100.,
    			height : this.crtContext.page.height * this.sliderPage.getValue()/100.
	    } 
    },
    
    getImageUrl: function(resultFolder, plotFile) {
    	return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile;
    },
	
    createPlotImage: function(resultFolder, plotFile) {
    	var me = this;
    	var size = this.getImageSize();
    	this.panelImage = Ext.create('amdaPlotComp.PlotResultImage', {
            src    : this.getImageUrl(resultFolder, plotFile),
            width  : size.width,
ebafe59e   Benjamin Renard   Add the possibili...
59
60
61
62
            height : size.height,
	    onContextMenu : function(absoluteX, absoluteY, imageX, imageY) {
		me.contextualMenu.showAt(absoluteX, absoluteY);
	    }
c9071a43   Benjamin Renard   Add instant plot ...
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
        });

        return this.panelImage;
    },
    
    updatePlotImage: function(configResult, newPlot) {
    	this.crtContext = configResult.context;

    	this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile));
    	
    	var size = this.getImageSize();
    	this.panelImage.setSize(size.width, size.height);
    	
    	this.panelImage.refreshMe();
    },
    
    init: function(configResult){
ebafe59e   Benjamin Renard   Add the possibili...
80
81
	var me = this;

c9071a43   Benjamin Renard   Add instant plot ...
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
110
111
112
113
    	this.crtContext = configResult.context;
    	this.tabId = configResult.tabId;
    	
    	this.sliderPage = new Ext.slider.Single({
            width: 130,
            value: 75,
            increment: 5,
            minValue: 50,
            maxValue: 100,
            fieldLabel : 'Resize',
            labelWidth : 40,
            listeners: {
        		scope : this,
                changecomplete: function(s, v)
                {
        			var size = this.getImageSize();	 
        			this.panelImage.width  = size.width;
        			this.panelImage.height = size.height;
        			this.panelImage.doComponentLayout();
                }
            }
        });
    	
    	var bottomToolbar = {
    		xtype: 'toolbar',
    		height: 25,
            dock: 'bottom',
            items:[
                   '->',
                   this.sliderPage
            ]
    	};
ebafe59e   Benjamin Renard   Add the possibili...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148

	this.contextualMenu = Ext.create('Ext.menu.Menu', {
		width: 200,
		plain: true,
		items: [
			{
				text: 'Save Plot',
				handler : function ()
				{
					if (me.hiddenForm == null)
						me.hiddenForm = Ext.create('Ext.form.Panel', {
							title:'hiddenForm',
							renderTo: Ext.getBody(),
							standardSubmit: true,
							url: 'php/downloadPlot.php',
							timeout: 120000,
							height:100,
							width: 100,
							hidden:true,
							items:[]
						});

					me.hiddenForm.getForm().submit({
						params: {
							sessionId: sessionID,
							tabId : me.tabId,
							preview: true
						},
						success: function(form, action) {},
						failure: function(form, action) {}
					});
				}
			}
		]
	});
c9071a43   Benjamin Renard   Add instant plot ...
149
150
151
152
153
154
155
156
157
158
159
160
            
    	var plotPreviewPanelConfig = {
    			preventHeader : true,
                autoScroll: true,       
                items: [
                        this.createPlotImage(configResult.folder, configResult.plotFile)
                ],
                dockedItems: [bottomToolbar]
    	};
            
    	Ext.apply(this , plotPreviewPanelConfig);	
    }
ebafe59e   Benjamin Renard   Add the possibili...
161
});