Blame view

js/app/views/PlotTabResultUI.js 3.51 KB
16035364   Benjamin Renard   First commit
1
2
3
/**
 * Project   : AMDA-NG
 * Name      : PlotTabResultUI.js
18d4a11e   Benjamin Renard   Save and load plo...
4
5
 * @class    amdaUI.PlotTabResultUI
 * @extends  Ext. panel.Panel
16035364   Benjamin Renard   First commit
6
7
 * @brief    Plot Tab Result UI definition (View)
 * @author    
18d4a11e   Benjamin Renard   Save and load plo...
8
 * @version  $Id: PlotTabResultUI.js benjamin $
16035364   Benjamin Renard   First commit
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 ********************************************************************************
 *    FT Id     :   Date   : Name - Description
 *******************************************************************************
 *              
 */

Ext.define('amdaUI.PlotTabResultUI', {
    extend: 'Ext.panel.Panel',
 
    alias: 'widget.plotTabResult',

    requires: [
        'amdaUI.InteractiveIntervalPlugin'
    ],
    
18d4a11e   Benjamin Renard   Save and load plo...
24
25
26
27
    isPortrait : false,
    pageWidth  : 0,
    pageHeight : 0,
    
16035364   Benjamin Renard   First commit
28
    constructor: function(config) {
16035364   Benjamin Renard   First commit
29
30
31
32
33
34
        this.addEvents({'pagesize':true});
        
        this.init(config);	 
        this.callParent(arguments);	 
    },  
    
18d4a11e   Benjamin Renard   Save and load plo...
35
36
37
38
39
40
    getImageSize : function() {
    	var size =  {
    			width  : this.pageWidth * this.sliderPage.getValue()/100.,
    			height : this.pageHeight * this.sliderPage.getValue()/100.
	    } 
    	return size;
16035364   Benjamin Renard   First commit
41
42
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
43
44
    getImageUrl: function(resultFolder, plotFile) {
    	return 'data/'+sessionID +'/RES/'+resultFolder+ '/' + plotFile;
16035364   Benjamin Renard   First commit
45
46
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    createPlotImage: function(resultFolder, plotFile, context) {
    	var size = this.getImageSize();
    	this.panelImage = Ext.create('Ext.Img', {
            src    : this.getImageUrl(resultFolder, plotFile),
            width  : size.width,
            height : size.height,
            refreshMe : function(){
            	var el;
            	if(el = this.el){
            		el.dom.src = this.src + '?dc=' + new Date().getTime();
                }
             },
             listeners : {
                render :  function(){
                	this.refreshMe();
16035364   Benjamin Renard   First commit
62
                }
18d4a11e   Benjamin Renard   Save and load plo...
63
             }
16035364   Benjamin Renard   First commit
64
65
66
        });

        return this.panelImage;
16035364   Benjamin Renard   First commit
67
68
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
69
70
71
72
73
74
75
76
77
78
79
    updatePlotImage: function(configResult) {
    	this.isPortrait = configResult.context.page.portrait;
    	this.pageWidth  = configResult.context.page.width;
    	this.pageHeight = configResult.context.page.height;
    	
    	this.panelImage.setSrc(this.getImageUrl(configResult.folder, configResult.plotFile));
    	
    	var size = this.getImageSize();
    	this.panelImage.setSize(size.width, size.height);
    	
    	this.panelImage.refreshMe();
16035364   Benjamin Renard   First commit
80
81
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    init: function(configResult){
    	this.isPortrait = configResult.context.page.portrait;
    	this.pageWidth  = configResult.context.page.width;
    	this.pageHeight = configResult.context.page.height;
    	
    	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)
                {
        			//ToDo - this.resetMire();
        			var size = this.getImageSize();	 
        			this.panelImage.width  = size.width;
        			this.panelImage.height = size.height;
        			this.panelImage.doComponentLayout();
        			this.fireEvent('pagesize',this,v);
                }
16035364   Benjamin Renard   First commit
106
            }
18d4a11e   Benjamin Renard   Save and load plo...
107
        });
16035364   Benjamin Renard   First commit
108
    	
18d4a11e   Benjamin Renard   Save and load plo...
109
110
111
112
113
114
115
116
117
118
119
    	var plotResultTabPanelConfig = {
    			preventHeader : true,
                autoScroll: true,       
                items: [
                        this.createPlotImage(configResult.folder, configResult.plotFile, configResult.context)
                ]
    	};
            
    	Ext.apply(this , plotResultTabPanelConfig);	
    }
});