Blame view

js/app/views/MultiPlotUI.js 3.97 KB
4efeb459   Benjamin Renard   First version for...
1
2
3
4
5
6
7
8
9
10
11
/**
 * Project   : AMDA-NG
 * Name      : MultiPlotUI.js
 * @class    amdaUI.MultiPlotUI
 * @extends  Ext. panel.Panel
 * @brief    MultiPlot UI definition (View)
 * @author
 * @version  $Id: MultiPlotUI.js benjamin
 */

Ext.define('amdaUI.MultiPlotUI', {
27a055f4   Benjamin Renard   Multiplot (#8314)
12
    extend: 'Ext.form.Panel',
4efeb459   Benjamin Renard   First version for...
13
14
15
16

    plotWin: null,

    timeSelector: null,
4efeb459   Benjamin Renard   First version for...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
    plotSelector: null,

    constructor: function(config) {
        this.init(config);
        this.callParent(arguments);
    },

    refreshMultiPlot: function() {
        var me = this;
        var tabsInfo = this.plotWin.plotTabs.getTabsInfo();
        this.plotSelector.removeAll();
        Ext.Array.each(tabsInfo, function(tabInfo) {
            me.plotSelector.add(
                {
                    boxLabel: tabInfo.name,
                    checked: tabInfo.object.get('multi-selected'),
                    listeners: {
                        change: function(field, newValue, oldValue, eOpts) {
                            tabInfo.object.set('multi-selected', newValue);
                        }
                    }
                }
            );
        });
    },

    doMultiPlot: function() {
27a055f4   Benjamin Renard   Multiplot (#8314)
44
        if (!this.isValidRequest()) {
4efeb459   Benjamin Renard   First version for...
45
46
47
            return false;
        }

d4a8d462   Benjamin Renard   Improve MultiPlot...
48
49
50
51
52
53
54
55
56
57
58
        // At least one plot must be selected
        var nbSelected = 0;
        this.plotSelector.items.each(function(item) {
            if (item.checked)
                ++nbSelected;
        });
        if (nbSelected == 0) {
            myDesktopApp.errorMsg('At least one Plot must be selected');
            return false;
        }

27a055f4   Benjamin Renard   Multiplot (#8314)
59
60
        this.plotWin.plotTabs.updatePlotTabs()

4efeb459   Benjamin Renard   First version for...
61
62
63
64
65
	// Execute multiplot request
	var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
	plotModule.linkedNode.execute();
    },

27a055f4   Benjamin Renard   Multiplot (#8314)
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
    updateTimeObject : function() {
        var timeSource = this.timeSelector.getActiveTimeSource();
        this.getForm().updateRecord(this.plotWin.object);
        this.plotWin.object.set('timesrc', timeSource);
        if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
            this.plotWin.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
    },

    isValidRequest : function() {
        this.updateTimeObject();
        if (!this.timeSelector.isValid(false)) {
            myDesktopApp.errorMsg('Error in Time definition');
            return false;
        }
        return true;
    },

4efeb459   Benjamin Renard   First version for...
83
84
85
86
    init : function(config) {
        var me = this;

        this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'multiplot-time-selector', border : false, collapsible: false, height: 180} );
4efeb459   Benjamin Renard   First version for...
87
88
89
90
91
        this.plotSelector = Ext.create('Ext.form.CheckboxGroup', {
            xtype: 'checkboxgroup',
            flex: 1,
            columns: 3,
            minHeight: 40,
d4a8d462   Benjamin Renard   Improve MultiPlot...
92
93
94
            autoScroll: true,
            fieldLabel: 'Select plots to synchronize',
            labelAlign: 'top'
4efeb459   Benjamin Renard   First version for...
95
96
97
98
99
100
101
102
103
        });
        var myConf = {
            layout: {
                type: 'vbox',
                pack: 'start',
                align: 'stretch'
            },
            items: [
                this.plotSelector,
4efeb459   Benjamin Renard   First version for...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
                this.timeSelector
            ],
            listeners: {
                afterrender: function() {
                    me.refreshMultiPlot();
                    me.timeSelector.intervalSel.setInterval(me.plotWin.object.get('startDate'), me.plotWin.object.get('stopDate'));
                    me.timeSelector.intervalSel.updateStop();
                    me.timeSelector.setTTTab(me.plotWin.object.get('timeTables'));
                    me.timeSelector.timeSrc.setActiveTab(me.plotWin.object.get('timesrc'));
                }
            },
            fbar: [
                '->',
                {
                    xtype: 'button',
                    text: 'Plot',
                    scope: this,
                    handler: function(button) {
                        this.doMultiPlot();
                    }
                }
            ]
        };
        Ext.apply(this, Ext.apply(arguments, myConf));
    }
});