Blame view

js/app/views/MultiPlotUI.js 4.13 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
    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);
ae185f40   Benjamin Renard   Fix multiplot (#8...
36
                            tabInfo.tabContent.enableTimeSelection(!newValue);
4efeb459   Benjamin Renard   First version for...
37
38
39
40
                        }
                    }
                }
            );
ae185f40   Benjamin Renard   Fix multiplot (#8...
41
            tabInfo.tabContent.enableTimeSelection(!tabInfo.object.get('multi-selected'));
4efeb459   Benjamin Renard   First version for...
42
43
44
45
        });
    },

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

d4a8d462   Benjamin Renard   Improve MultiPlot...
50
51
52
53
54
55
56
57
58
59
60
        // 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)
61
62
        this.plotWin.plotTabs.updatePlotTabs()

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

27a055f4   Benjamin Renard   Multiplot (#8314)
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
    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...
85
86
87
88
    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...
89
90
91
92
93
        this.plotSelector = Ext.create('Ext.form.CheckboxGroup', {
            xtype: 'checkboxgroup',
            flex: 1,
            columns: 3,
            minHeight: 40,
d4a8d462   Benjamin Renard   Improve MultiPlot...
94
95
96
            autoScroll: true,
            fieldLabel: 'Select plots to synchronize',
            labelAlign: 'top'
4efeb459   Benjamin Renard   First version for...
97
98
99
100
101
102
103
104
105
        });
        var myConf = {
            layout: {
                type: 'vbox',
                pack: 'start',
                align: 'stretch'
            },
            items: [
                this.plotSelector,
4efeb459   Benjamin Renard   First version for...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
                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));
    }
});