FramesSelection.js
4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Ext.define('treps.controller.Frames.FramesSelection', {
extend: 'Ext.app.Controller',
requires: [
'treps.controller.Frames.FramesManager',
'treps.controller.Bodies.BodySelection',
'treps.controller.Data.Store.DataStoreManager'
],
views: [
'Steps.TransformationDefinition.TransformationDefinitionPanel'
],
refs: [
{
ref: 'sourceCombo',
selector: '#srcSysFrame'
},
{
ref: 'destCombo',
selector: '#destSysFrame'
}
],
srcCenter : '',
dstCenter : '',
init: function() {
var me = this;
//timeDefController.init();
this.control({
'#srcSysFrame': {
select: me.onSrcFrameSelect,
scope: me
}
});
this.control({
'#destSysFrame': {
select: me.onDstFrameSelect,
scope: me
}
});
},
onSrcFrameSelect: function() {
var me = this;
var timeDefController = treps.app.getController('Times.SourceTimeSelection');
if((me.getSrcFrame()=='RTN') || (me.getSrcFrame()=='RTP')) {
if(timeDefController.getTimeFormat() == "") {//check time is defined
treps.Messages.showWarning("You must select a time field to use RTN/RTP coordinate system.");
me.getSourceCombo().setValue(null);
} else {
me.selectRTBodies('Select bodies for '+me.getSrcFrame(),me.getSourceCombo());
}
}
},
onDstFrameSelect: function() {
var me = this;
var timeDefController = treps.app.getController('Times.SourceTimeSelection');
if((me.getDstFrame()=='RTN') || (me.getDstFrame()=='RTP')) {
if(timeDefController.getTimeFormat() == "") {//check time is defined
treps.Messages.showWarning("You must select a time field to use RTN/RTP coordinate system.");
me.getDestCombo().setValue(null);
} else {
me.selectRTBodies('Select bodies for '+me.getDstFrame(),me.getDestCombo());
}
}
},
initStore: function(onReady)
{
var me = this;
treps.controller.Frames.FramesManager.loadFramesStore(
function(store)
{
me.getSourceCombo().store = store;
me.getDestCombo().store = store;
if (onReady != null)
onReady.call(me, store);
});
},
//show RTN/RTP bodies selection and returns center formated string as follow:
// centerid centername scid scname
ctrlAdded: false,
currentCombo: undefined,
currentBodyWin: undefined,
selectRTBodies: function(pTitle,frameCombo) {
var me = this;
//var bodySelCtrl = treps.app.getController('treps.controller.Bodies.BodySelection');
var bodySelCtrl = Ext.create('treps.controller.Bodies.BodySelection');
treps.controller.Data.Store.DataStoreManager.getStore('SourceDataStore');
var bodySelWin = bodySelCtrl.getBodySelWin(pTitle);
this.currentCombo=frameCombo;
this.currentBodyWin = bodySelWin;
if(!this.ctrlAdded) {
this.control({
'bodies_panel > #okbtn': {
click: function() {
var center = bodySelCtrl.getCenterBody()+' '+bodySelCtrl.getScBody();
if(this.currentCombo==me.getSourceCombo()) {
me.srcCenter = center;
console.log("set src center "+me.srcCenter+" dst="+me.dstCenter);
}
if(this.currentCombo==me.getDestCombo()) {
me.dstCenter = center;
console.log("set dst center "+me.dstCenter+" src="+me.srcCenter);
}
me.currentBodyWin.close();
},
scope: me
}
});
this.ctrlAdded = true;
}
var srcStore = treps.controller.Data.Store.DataStoreManager.getStore('SourceDataStore');
var gridController = treps.app.getController('Data.Grid.SourceDataGrid');
var timeCol = gridController.getFirstColumnDataIndex(gridController.getSourceGrid());
bodySelCtrl.initStore(srcStore.getAt(0).get(timeCol), srcStore.getAt(srcStore.totalCount-1).get(timeCol),
function(lBodies){
console.log("combo Sc found? "+bodySelCtrl.getBodiesScCombo().store.count(false));
console.log("combo Center found? "+bodySelCtrl.getBodiesCenterCombo().store.count(false));
//for RTN, select default sun value
if(frameCombo.getValue()=='RTN') bodySelCtrl.getBodiesCenterCombo().setValue('10');
bodySelWin.add(bodySelCtrl.getBodiesScCombo().ownerCt);
bodySelWin.doLayout();
bodySelWin.show();
}
);
},
getSrcCenter: function() {
return this.srcCenter;
},
getDstCenter: function() {
return this.dstCenter;
},
getSrcFrame: function() {
return this.getSourceCombo().getValue();
},
getDstFrame: function() {
return this.getDestCombo().getValue();
},
setSrcFrame: function(srcFrame) {
this.getSourceCombo().setValue(srcFrame);
},
isValid: function() {
var srcFrame = this.getSrcFrame();
var dstFrame = this.getDstFrame();
if ((srcFrame == null) && (dstFrame == null))
{
//No transformation
return true;
}
else if (srcFrame == null)
{
treps.Messages.showError('Please select a source frame');
return false;
}
else if (dstFrame == null)
{
treps.Messages.showError('Please select a destination frame');
return false;
}
return true;
}
});