1 | /* ************************************************************************ |
---|
2 | |
---|
3 | Copyright: Weizmann Institute of Science |
---|
4 | |
---|
5 | License: GPL |
---|
6 | |
---|
7 | Authors: Evgeny Stambulchik |
---|
8 | |
---|
9 | ************************************************************************ */ |
---|
10 | |
---|
11 | /* ************************************************************************ |
---|
12 | |
---|
13 | #asset(pf/image/*.png) |
---|
14 | #asset(pf/html/*.html) |
---|
15 | |
---|
16 | ************************************************************************ */ |
---|
17 | |
---|
18 | |
---|
19 | function changeN_e(ev) |
---|
20 | { |
---|
21 | var e = ev.getTarget(); |
---|
22 | var N_e = e.getNumValue(); |
---|
23 | |
---|
24 | if (isFinite(N_e) && this.plasma.e.setN(N_e)) { |
---|
25 | this.updatePlasmaParameters(); |
---|
26 | this.updateGUI(); |
---|
27 | } |
---|
28 | } |
---|
29 | |
---|
30 | function changeT_e(ev) |
---|
31 | { |
---|
32 | var e = ev.getTarget(); |
---|
33 | var T_e = e.getNumValue(); |
---|
34 | |
---|
35 | if (isFinite(T_e)) { |
---|
36 | this.plasma.e.setT(T_e); |
---|
37 | this.plasma.i.setT(T_e); |
---|
38 | this.plasma.r.setT(T_e); |
---|
39 | this.updateGUI(); |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | function changeZ_i(ev) |
---|
44 | { |
---|
45 | var e = ev.getTarget(); |
---|
46 | var Z_i = parseInt(e.getValue()); |
---|
47 | |
---|
48 | if (isFinite(Z_i)) { |
---|
49 | this.plasma.i.setQ(Z_i); |
---|
50 | this.updatePlasmaParameters(); |
---|
51 | this.updateGUI(); |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | function changeT_i(ev) |
---|
56 | { |
---|
57 | var e = ev.getTarget(); |
---|
58 | var T_i = e.getNumValue(); |
---|
59 | |
---|
60 | if (isFinite(T_i)) { |
---|
61 | this.plasma.i.setT(T_i); |
---|
62 | this.plasma.r.setT(T_i); |
---|
63 | this.updateGUI(); |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | function changeZ_r(ev) |
---|
68 | { |
---|
69 | var e = ev.getTarget(); |
---|
70 | var Z_r = parseInt(e.getValue()); |
---|
71 | |
---|
72 | if (isFinite(Z_r)) { |
---|
73 | this.plasma.r.setQ(Z_r); |
---|
74 | this.updatePlasmaParameters(); |
---|
75 | this.updateGUI(); |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | function changeP_r(ev) |
---|
80 | { |
---|
81 | var e = ev.getTarget(); |
---|
82 | var P_r = parseInt(e.getValue())/100.0; |
---|
83 | |
---|
84 | if (isFinite(P_r)) { |
---|
85 | this.plasma.P_r = P_r; |
---|
86 | this.updatePlasmaParameters(); |
---|
87 | this.updateGUI(); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | function changeT_r(ev) |
---|
92 | { |
---|
93 | var e = ev.getTarget(); |
---|
94 | var T_r = e.getNumValue(); |
---|
95 | |
---|
96 | if (isFinite(T_r)) { |
---|
97 | this.plasma.r.setT(T_r); |
---|
98 | this.updateGUI(); |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | function changeM_i(ev) |
---|
103 | { |
---|
104 | var e = ev.getTarget(); |
---|
105 | var M_i = parseInt(e.getValue()); |
---|
106 | |
---|
107 | if (isFinite(M_i)) { |
---|
108 | this.plasma.i.setM(M_i); |
---|
109 | this.updateGUI(); |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | function changeM_r(ev) |
---|
114 | { |
---|
115 | var e = ev.getTarget(); |
---|
116 | var M_r = parseInt(e.getValue()); |
---|
117 | |
---|
118 | if (isFinite(M_r)) { |
---|
119 | this.plasma.r.setM(M_r); |
---|
120 | this.updateGUI(); |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | function changeN_u(ev) |
---|
125 | { |
---|
126 | var e = ev.getTarget(); |
---|
127 | var n_u = parseInt(e.getValue()); |
---|
128 | |
---|
129 | this.plasma.n_u = n_u; |
---|
130 | this.updateGUI(); |
---|
131 | } |
---|
132 | |
---|
133 | function changeN_l(ev) |
---|
134 | { |
---|
135 | var e = ev.getTarget(); |
---|
136 | var n_l = parseInt(e.getValue()); |
---|
137 | |
---|
138 | this.plasma.n_l = n_l; |
---|
139 | this.updateGUI(); |
---|
140 | } |
---|
141 | |
---|
142 | function changeB(ev) |
---|
143 | { |
---|
144 | var e = ev.getTarget(); |
---|
145 | var v = e.getNumValue(); |
---|
146 | |
---|
147 | if (isFinite(v)) { |
---|
148 | this.plasma.B = v; |
---|
149 | this.updateGUI(); |
---|
150 | } |
---|
151 | } |
---|
152 | |
---|
153 | function viewMenuCB(ev) |
---|
154 | { |
---|
155 | var explorer_is_seen; |
---|
156 | |
---|
157 | if (this.entity_tree.isSeeable()) { |
---|
158 | explorer_is_seen = true; |
---|
159 | } else { |
---|
160 | explorer_is_seen = false; |
---|
161 | } |
---|
162 | |
---|
163 | this.showSectionsButton.setEnabled(explorer_is_seen); |
---|
164 | this.showSpeciesButton.setEnabled(explorer_is_seen); |
---|
165 | this.redrawButton.setEnabled(this.canvas.isSeeable()); |
---|
166 | |
---|
167 | if (this.prefs.autoLoadWiki) { |
---|
168 | this.loadWikiButton.setEnabled(false); |
---|
169 | } else { |
---|
170 | var tree = this.entity_tree; |
---|
171 | var leaf = getSingleTreeSelectedItem(tree); |
---|
172 | if (leaf && leaf.classname == "qx.ui.tree.TreeFile" && explorer_is_seen) { |
---|
173 | this.loadWikiButton.setEnabled(true); |
---|
174 | } else { |
---|
175 | this.loadWikiButton.setEnabled(false); |
---|
176 | } |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | function editMenuCB(ev) |
---|
181 | { |
---|
182 | var explorer_is_seen; |
---|
183 | |
---|
184 | if (this.entity_tree.isSeeable()) { |
---|
185 | explorer_is_seen = true; |
---|
186 | } else { |
---|
187 | explorer_is_seen = false; |
---|
188 | } |
---|
189 | |
---|
190 | var tree = this.entity_tree; |
---|
191 | var leaf = getSingleTreeSelectedItem(tree); |
---|
192 | |
---|
193 | if (leaf && leaf.classname == "qx.ui.tree.TreeFile" && explorer_is_seen) { |
---|
194 | if (this.isFavorite(leaf)) { |
---|
195 | this.editMenuButtonAddToFav.setEnabled(false); |
---|
196 | this.editMenuButtonRemFromFav.setEnabled(true); |
---|
197 | } else { |
---|
198 | this.editMenuButtonAddToFav.setEnabled(true); |
---|
199 | this.editMenuButtonRemFromFav.setEnabled(false); |
---|
200 | } |
---|
201 | } else { |
---|
202 | this.editMenuButtonAddToFav.setEnabled(false); |
---|
203 | this.editMenuButtonRemFromFav.setEnabled(false); |
---|
204 | } |
---|
205 | } |
---|
206 | |
---|
207 | function getSingleTreeSelectedItem(tree) |
---|
208 | { |
---|
209 | var sels = tree.getSelection(); |
---|
210 | if (sels && sels.length == 1) { |
---|
211 | return sels[0]; |
---|
212 | } else { |
---|
213 | return null; |
---|
214 | } |
---|
215 | } |
---|
216 | |
---|
217 | function treeMenuCB(ev) |
---|
218 | { |
---|
219 | if (ev.getButton() == "right") { |
---|
220 | var menu = this.treeMenu; |
---|
221 | |
---|
222 | if (menu.isSeeable()) { |
---|
223 | menu.hide(); |
---|
224 | } else { |
---|
225 | var w = ev.getTarget(); |
---|
226 | var leaf = null; |
---|
227 | if (w.classname == "qx.ui.tree.TreeFile") { |
---|
228 | leaf = w; |
---|
229 | } else |
---|
230 | if (w.getLayoutParent().classname == "qx.ui.tree.TreeFile") { |
---|
231 | leaf = w.getLayoutParent(); |
---|
232 | } |
---|
233 | |
---|
234 | if (leaf) { |
---|
235 | if (this.isFavorite(leaf)) { |
---|
236 | this.treeMenuButtonAddToFav.setEnabled(false); |
---|
237 | this.treeMenuButtonRemFromFav.setEnabled(true); |
---|
238 | } else { |
---|
239 | this.treeMenuButtonAddToFav.setEnabled(true); |
---|
240 | this.treeMenuButtonRemFromFav.setEnabled(false); |
---|
241 | } |
---|
242 | } else { |
---|
243 | this.treeMenuButtonAddToFav.setEnabled(false); |
---|
244 | this.treeMenuButtonRemFromFav.setEnabled(false); |
---|
245 | } |
---|
246 | |
---|
247 | // position & show the menu |
---|
248 | menu.placeToMouse(ev); |
---|
249 | menu.show(); |
---|
250 | }; |
---|
251 | |
---|
252 | // ev.stopPropagation(); |
---|
253 | } |
---|
254 | } |
---|
255 | |
---|
256 | function showFundamentalCB(ev) |
---|
257 | { |
---|
258 | this.showFundamental = !this.showFundamental; |
---|
259 | this.rePopulateTree(); |
---|
260 | } |
---|
261 | |
---|
262 | function showSpectroscopyCB(ev) |
---|
263 | { |
---|
264 | this.showSpectroscopy = !this.showSpectroscopy; |
---|
265 | this.rePopulateTree(); |
---|
266 | } |
---|
267 | |
---|
268 | function showWavesCB(ev) |
---|
269 | { |
---|
270 | this.showWaves = !this.showWaves; |
---|
271 | this.rePopulateTree(); |
---|
272 | } |
---|
273 | |
---|
274 | function showCollisionsCB(ev) |
---|
275 | { |
---|
276 | this.showCollisions = !this.showCollisions; |
---|
277 | this.rePopulateTree(); |
---|
278 | } |
---|
279 | |
---|
280 | function showElectronsCB(ev) |
---|
281 | { |
---|
282 | this.showElectrons = !this.showElectrons; |
---|
283 | this.rePopulateTree(); |
---|
284 | } |
---|
285 | |
---|
286 | function showIonsCB(ev) |
---|
287 | { |
---|
288 | this.showIons = !this.showIons; |
---|
289 | this.rePopulateTree(); |
---|
290 | } |
---|
291 | |
---|
292 | function showRadiatorsCB(ev) |
---|
293 | { |
---|
294 | this.showRadiators = !this.showRadiators; |
---|
295 | this.rePopulateTree(); |
---|
296 | } |
---|
297 | |
---|
298 | function addToFavCB(ev) |
---|
299 | { |
---|
300 | var tree = this.entity_tree; |
---|
301 | var leaf = getSingleTreeSelectedItem(tree); |
---|
302 | |
---|
303 | if (!leaf) { |
---|
304 | return; |
---|
305 | } |
---|
306 | |
---|
307 | leaf.setTextColor(this.leafFavColor); |
---|
308 | |
---|
309 | // Add to the list of favorites |
---|
310 | var fav = new Array; |
---|
311 | fav.entity = leaf.getUserData("entity"); |
---|
312 | fav.species = leaf.getUserData("species"); |
---|
313 | fav.color = this.nextColor(); |
---|
314 | this.favorites.push(fav); |
---|
315 | |
---|
316 | // Switch the dimension selector ... |
---|
317 | this.gui_compare_dim.selectByValue(fav.entity.dimension); |
---|
318 | // ... and update the list of favorites |
---|
319 | this.updateFavoritesListView(); |
---|
320 | this.updateLegendListView(); |
---|
321 | } |
---|
322 | |
---|
323 | function removeFromFavCB(ev) |
---|
324 | { |
---|
325 | var tree = this.entity_tree; |
---|
326 | var leaf = getSingleTreeSelectedItem(tree); |
---|
327 | |
---|
328 | if (!leaf) { |
---|
329 | return; |
---|
330 | } |
---|
331 | leaf.setTextColor(this.leafColor); |
---|
332 | |
---|
333 | var entity = leaf.getUserData("entity"); |
---|
334 | var species = leaf.getUserData("species"); |
---|
335 | |
---|
336 | // Remove from the list of favorites |
---|
337 | for (var k = 0; k < this.favorites.length; k++) { |
---|
338 | var fav = this.favorites[k]; |
---|
339 | if (fav.entity == entity && fav.species == species) { |
---|
340 | this.favorites.splice(k, 1); |
---|
341 | break; |
---|
342 | } |
---|
343 | } |
---|
344 | |
---|
345 | // Switch the dimension selector ... |
---|
346 | this.gui_compare_dim.selectByValue(entity.dimension); |
---|
347 | // ... and update the list of favorites |
---|
348 | this.updateFavoritesListView(); |
---|
349 | this.updateLegendListView(); |
---|
350 | } |
---|
351 | |
---|
352 | function clickTreeCB(ev) |
---|
353 | { |
---|
354 | var tree = ev.getTarget(); |
---|
355 | var e = getSingleTreeSelectedItem(tree); |
---|
356 | if (e) { |
---|
357 | var entity = e.getUserData("entity"); |
---|
358 | |
---|
359 | if (entity) { |
---|
360 | this.gui_entity_units.update(entity.dimension, |
---|
361 | this.prefs.units[entity.dimension]); |
---|
362 | } else { |
---|
363 | this.gui_entity_units.update(null, null); |
---|
364 | } |
---|
365 | |
---|
366 | this.updateEntityValue(); |
---|
367 | } |
---|
368 | } |
---|
369 | |
---|
370 | function changeUnitsCB(ev) |
---|
371 | { |
---|
372 | this.updateEntityValue(); |
---|
373 | } |
---|
374 | |
---|
375 | /** |
---|
376 | * The application |
---|
377 | */ |
---|
378 | qx.Class.define("pf.Application", |
---|
379 | { |
---|
380 | extend : qx.application.Standalone, |
---|
381 | |
---|
382 | /* |
---|
383 | ***************************************************************************** |
---|
384 | MEMBERS |
---|
385 | ***************************************************************************** |
---|
386 | */ |
---|
387 | |
---|
388 | members : |
---|
389 | { |
---|
390 | showFundamental : true, |
---|
391 | showSpectroscopy : true, |
---|
392 | showWaves : true, |
---|
393 | showCollisions : true, |
---|
394 | |
---|
395 | showElectrons : true, |
---|
396 | showIons : true, |
---|
397 | showRadiators : true, |
---|
398 | |
---|
399 | leafColor : "black", |
---|
400 | leafFavColor : "red", |
---|
401 | |
---|
402 | plasma : null, |
---|
403 | |
---|
404 | updatePlasmaParameters : function() |
---|
405 | { |
---|
406 | return this.plasma.updateParameters(); |
---|
407 | }, |
---|
408 | |
---|
409 | updateGUI : function() |
---|
410 | { |
---|
411 | if (this.prefs.currentConfigName) { |
---|
412 | this.gui_configName.setLabel(this.prefs.currentConfigName); |
---|
413 | } |
---|
414 | |
---|
415 | this.gui_N_e.setNumValue(this.plasma.e.getN()); |
---|
416 | this.gui_T_e.setNumValue(this.plasma.e.getT()); |
---|
417 | |
---|
418 | this.gui_N_i.setNumValue(this.plasma.i.getN()); |
---|
419 | this.gui_T_i.setNumValue(this.plasma.i.getT()); |
---|
420 | this.gui_Z_i.setValue(this.plasma.i.getQ()); |
---|
421 | this.gui_M_i.setValue(this.plasma.i.getM()); |
---|
422 | |
---|
423 | this.gui_P_r.setValue(100*this.plasma.P_r); |
---|
424 | |
---|
425 | this.gui_N_r.setNumValue(this.plasma.r.getN()); |
---|
426 | this.gui_T_r.setNumValue(this.plasma.r.getT()); |
---|
427 | this.gui_Z_r.setValue(this.plasma.r.getQ()); |
---|
428 | this.gui_Zcore.setValue((this.plasma.r.getQ() + 1) + ''); |
---|
429 | this.gui_M_r.setValue(this.plasma.r.getM()); |
---|
430 | |
---|
431 | this.gui_B.setNumValue(this.plasma.B); |
---|
432 | |
---|
433 | this.gui_n_u.setValue(this.plasma.n_u); |
---|
434 | this.gui_n_l.setValue(this.plasma.n_l); |
---|
435 | |
---|
436 | // Update the currently selected entity |
---|
437 | this.updateEntityValue(); |
---|
438 | |
---|
439 | // Update the list of favorites |
---|
440 | this.updateFavoritesListView(); |
---|
441 | this.updateLegendListView(); |
---|
442 | }, |
---|
443 | |
---|
444 | |
---|
445 | getEntityFullName : function (entity, species) |
---|
446 | { |
---|
447 | var name = entity.name; |
---|
448 | if (entity.nspecies == 1) { |
---|
449 | var prepos = entity.prepos; |
---|
450 | if (!prepos) { |
---|
451 | prepos = "of"; |
---|
452 | } |
---|
453 | name += " " + prepos + " "; |
---|
454 | switch (species.id) { |
---|
455 | case "e": |
---|
456 | name += "electrons"; |
---|
457 | break; |
---|
458 | case "i": |
---|
459 | name += "ions"; |
---|
460 | break; |
---|
461 | case "r": |
---|
462 | name += "radiators"; |
---|
463 | break; |
---|
464 | } |
---|
465 | } |
---|
466 | |
---|
467 | return name; |
---|
468 | }, |
---|
469 | |
---|
470 | evaluateEntityValue : function(entity, species) |
---|
471 | { |
---|
472 | var formula; |
---|
473 | if (entity.nspecies == 1) { |
---|
474 | var species_str = "this.plasma." + species.id; |
---|
475 | formula = entity.formula.replace(/\%s1/g, species_str); |
---|
476 | } else { |
---|
477 | formula = entity.formula; |
---|
478 | } |
---|
479 | var v = eval(formula); |
---|
480 | |
---|
481 | return v; |
---|
482 | }, |
---|
483 | |
---|
484 | updateEntityValue : function() |
---|
485 | { |
---|
486 | var tree = this.entity_tree; |
---|
487 | var leaf = getSingleTreeSelectedItem(tree); |
---|
488 | |
---|
489 | if (!leaf) { |
---|
490 | return; |
---|
491 | } |
---|
492 | |
---|
493 | var entity = leaf.getUserData("entity"); |
---|
494 | var species = leaf.getUserData("species"); |
---|
495 | |
---|
496 | var name, section, value; |
---|
497 | if (entity) { |
---|
498 | var v = this.evaluateEntityValue(entity, species); |
---|
499 | var scale = this.gui_entity_units.getSelectedValue(); |
---|
500 | |
---|
501 | name = this.getEntityFullName(entity, species); |
---|
502 | section = entity.section; |
---|
503 | value = v*scale |
---|
504 | } else { |
---|
505 | name = null; |
---|
506 | section = null; |
---|
507 | value = 0; |
---|
508 | } |
---|
509 | |
---|
510 | this.gui_entity_name.setValue(name); |
---|
511 | |
---|
512 | this.gui_entity_section.setValue(section); |
---|
513 | |
---|
514 | if (isFinite(value)) { |
---|
515 | this.gui_entity_value.setNumValue(value); |
---|
516 | } else { |
---|
517 | this.gui_entity_value.setValue(""); |
---|
518 | } |
---|
519 | |
---|
520 | if (this.prefs.autoLoadWiki) { |
---|
521 | this.showWikiPage(entity); |
---|
522 | } else { |
---|
523 | this.showWikiPage(null); |
---|
524 | } |
---|
525 | }, |
---|
526 | |
---|
527 | isFavorite : function(leaf) |
---|
528 | { |
---|
529 | var entity = leaf.getUserData("entity"); |
---|
530 | var species = leaf.getUserData("species"); |
---|
531 | |
---|
532 | for (var k = 0; k < this.favorites.length; k++) { |
---|
533 | var fav = this.favorites[k]; |
---|
534 | if (fav.entity == entity && fav.species == species) { |
---|
535 | return true; |
---|
536 | break; |
---|
537 | } |
---|
538 | } |
---|
539 | |
---|
540 | return false; |
---|
541 | }, |
---|
542 | |
---|
543 | addEntityLeaf : function(entity, species) |
---|
544 | { |
---|
545 | var icon; |
---|
546 | if (species) { |
---|
547 | icon = "pf/image/" + species.id + "_small.png"; |
---|
548 | } else { |
---|
549 | icon = "pf/image/all_small.png"; |
---|
550 | } |
---|
551 | |
---|
552 | var leaf = new qx.ui.tree.TreeFile(entity.name); |
---|
553 | leaf.setIcon(icon); |
---|
554 | leaf.addListener("contextmenu", treeMenuCB, this); |
---|
555 | leaf.setUserData("entity", entity); |
---|
556 | |
---|
557 | if (species) { |
---|
558 | leaf.setUserData("species", species); |
---|
559 | } |
---|
560 | |
---|
561 | if (this.isFavorite(leaf)) { |
---|
562 | leaf.setTextColor(this.leafFavColor); |
---|
563 | } else { |
---|
564 | leaf.setTextColor(this.leafColor); |
---|
565 | } |
---|
566 | |
---|
567 | return leaf; |
---|
568 | }, |
---|
569 | |
---|
570 | populateTree : function() |
---|
571 | { |
---|
572 | var i, n = plasma_entities.length; |
---|
573 | var sa = new Array; |
---|
574 | if (this.showElectrons) { |
---|
575 | sa.push(this.plasma.e) |
---|
576 | } |
---|
577 | if (this.showIons) { |
---|
578 | sa.push(this.plasma.i) |
---|
579 | } |
---|
580 | if (this.showRadiators) { |
---|
581 | sa.push(this.plasma.r) |
---|
582 | } |
---|
583 | |
---|
584 | for (var i = 0; i < n; i++) { |
---|
585 | var entity = plasma_entities[i]; |
---|
586 | |
---|
587 | if (entity.section == "fundamental" && |
---|
588 | this.showFundamental != true) { |
---|
589 | continue; |
---|
590 | } |
---|
591 | if (entity.section == "spectroscopy" && |
---|
592 | this.showSpectroscopy != true) { |
---|
593 | continue; |
---|
594 | } |
---|
595 | if (entity.section == "waves" && |
---|
596 | this.showWaves != true) { |
---|
597 | continue; |
---|
598 | } |
---|
599 | if (entity.section == "collisions" && |
---|
600 | this.showCollisions != true) { |
---|
601 | continue; |
---|
602 | } |
---|
603 | |
---|
604 | var folder; |
---|
605 | switch (entity.dimension) { |
---|
606 | case "frequency": |
---|
607 | folder = this.gui_folder_freq; |
---|
608 | break; |
---|
609 | case "length": |
---|
610 | folder = this.gui_folder_length; |
---|
611 | break; |
---|
612 | case "velocity": |
---|
613 | folder = this.gui_folder_vel; |
---|
614 | break; |
---|
615 | case "energy": |
---|
616 | folder = this.gui_folder_energy; |
---|
617 | break; |
---|
618 | case "pressure": |
---|
619 | folder = this.gui_folder_pressure; |
---|
620 | break; |
---|
621 | case "area": |
---|
622 | folder = this.gui_folder_area; |
---|
623 | break; |
---|
624 | case "power_density": |
---|
625 | folder = this.gui_folder_power_density; |
---|
626 | break; |
---|
627 | case "spectral_power_density": |
---|
628 | folder = this.gui_folder_spectral_power_density; |
---|
629 | break; |
---|
630 | case "none": |
---|
631 | folder = this.gui_folder_none; |
---|
632 | break; |
---|
633 | default: |
---|
634 | folder = this.gui_folder_misc; |
---|
635 | break; |
---|
636 | } |
---|
637 | |
---|
638 | var leaf; |
---|
639 | |
---|
640 | switch (entity.nspecies) { |
---|
641 | case 1: |
---|
642 | for (var j = 0; j < sa.length; j++) { |
---|
643 | var s = sa[j]; |
---|
644 | leaf = this.addEntityLeaf(entity, s); |
---|
645 | folder.add(leaf); |
---|
646 | } |
---|
647 | break; |
---|
648 | default: |
---|
649 | leaf = this.addEntityLeaf(entity, null); |
---|
650 | folder.add(leaf); |
---|
651 | break; |
---|
652 | } |
---|
653 | } |
---|
654 | }, |
---|
655 | |
---|
656 | cleanTree : function() |
---|
657 | { |
---|
658 | this.gui_folder_freq.removeAll(); |
---|
659 | |
---|
660 | this.gui_folder_length.removeAll(); |
---|
661 | |
---|
662 | this.gui_folder_vel.removeAll(); |
---|
663 | |
---|
664 | this.gui_folder_none.removeAll(); |
---|
665 | |
---|
666 | this.gui_folder_energy.removeAll(); |
---|
667 | |
---|
668 | this.gui_folder_pressure.removeAll(); |
---|
669 | |
---|
670 | this.gui_folder_area.removeAll(); |
---|
671 | |
---|
672 | this.gui_folder_power_density.removeAll(); |
---|
673 | |
---|
674 | this.gui_folder_spectral_power_density.removeAll(); |
---|
675 | |
---|
676 | this.gui_folder_misc.removeAll(); |
---|
677 | }, |
---|
678 | |
---|
679 | rePopulateTree : function() |
---|
680 | { |
---|
681 | this.cleanTree(); |
---|
682 | |
---|
683 | this.populateTree(); |
---|
684 | }, |
---|
685 | |
---|
686 | |
---|
687 | updateFavoritesListView : function() |
---|
688 | { |
---|
689 | var lv = this.favoritesListView; |
---|
690 | var tm = lv.getTableModel(); |
---|
691 | |
---|
692 | var dimension = this.gui_compare_dim.getSelectedValue(); |
---|
693 | |
---|
694 | var scale = this.gui_compare_units.getSelectedValue(); |
---|
695 | |
---|
696 | var rowData = new Array(); |
---|
697 | |
---|
698 | for (var i = 0; i < this.favorites.length; i++) { |
---|
699 | var fav = this.favorites[i]; |
---|
700 | var entity = fav.entity; |
---|
701 | |
---|
702 | if (entity.dimension != dimension) { |
---|
703 | continue; |
---|
704 | } |
---|
705 | |
---|
706 | var species = fav.species; |
---|
707 | |
---|
708 | var icon; |
---|
709 | if (species) { |
---|
710 | icon = "pf/image/" + species.id + "_small.png"; |
---|
711 | } else { |
---|
712 | icon = "pf/image/all_small.png"; |
---|
713 | } |
---|
714 | var name = this.getEntityFullName(entity, species); |
---|
715 | var value = scale*this.evaluateEntityValue(entity, species); |
---|
716 | |
---|
717 | rowData.push([icon, name, entity.section, |
---|
718 | pf.util.Format.numPrint(value)]); |
---|
719 | } |
---|
720 | |
---|
721 | tm.setData(rowData, false); |
---|
722 | var sidx = tm.getSortColumnIndex(); |
---|
723 | tm.sortByColumn(sidx, tm.isSortAscending()); |
---|
724 | |
---|
725 | lv.updateContent(); |
---|
726 | // lv.updateSort(); |
---|
727 | // lv.update(); |
---|
728 | }, |
---|
729 | |
---|
730 | updateLegendListView : function() |
---|
731 | { |
---|
732 | var lv = this.legendListView; |
---|
733 | var tm = lv.getTableModel(); |
---|
734 | |
---|
735 | var rowData = new Array(); |
---|
736 | |
---|
737 | var dimension = this.gui_compare_dim.getSelectedValue(); |
---|
738 | |
---|
739 | for (var i = 0; i < this.favorites.length; i++) { |
---|
740 | var fav = this.favorites[i]; |
---|
741 | var entity = fav.entity; |
---|
742 | |
---|
743 | if (entity.dimension != dimension) { |
---|
744 | continue; |
---|
745 | } |
---|
746 | |
---|
747 | var species = fav.species; |
---|
748 | |
---|
749 | var name = this.getEntityFullName(entity, species); |
---|
750 | var color = fav.color; |
---|
751 | |
---|
752 | rowData.push({"color": color, "name": name, "favorite": fav}); |
---|
753 | } |
---|
754 | |
---|
755 | tm.setDataAsMapArray(rowData); |
---|
756 | // lv.updateContent(); |
---|
757 | }, |
---|
758 | |
---|
759 | |
---|
760 | renderTabPage : function(label, icon, checked) |
---|
761 | { |
---|
762 | var page_id; |
---|
763 | |
---|
764 | page_id = new qx.ui.tabview.Page(label, icon); |
---|
765 | this.tabview.add(page_id, {height: "100%"}); |
---|
766 | |
---|
767 | if (checked) { |
---|
768 | this.tabview.setSelection(page_id); |
---|
769 | } |
---|
770 | |
---|
771 | return page_id; |
---|
772 | }, |
---|
773 | |
---|
774 | renderParametersTab : function() |
---|
775 | { |
---|
776 | var fr, gl, rc, rc1, rc2; |
---|
777 | |
---|
778 | var page_id = this.renderTabPage("Parameters", |
---|
779 | "pf/image/tab-parameters.png", true); |
---|
780 | page_id.setLayout(new qx.ui.layout.VBox(10)); |
---|
781 | |
---|
782 | fr = new qx.ui.groupbox.GroupBox("Configuration name", |
---|
783 | "pf/image/info.png"); |
---|
784 | fr.setLayout(new qx.ui.layout.VBox()); |
---|
785 | |
---|
786 | this.gui_configName = |
---|
787 | new qx.ui.basic.Atom(this.prefs.currentConfigName); |
---|
788 | this.gui_configName.setRich(true) |
---|
789 | fr.add(this.gui_configName); |
---|
790 | page_id.add(fr); |
---|
791 | |
---|
792 | |
---|
793 | rc = new qx.ui.container.Composite(new qx.ui.layout.HBox(1)); |
---|
794 | page_id.add(rc); |
---|
795 | |
---|
796 | rc1 = new qx.ui.container.Composite(new qx.ui.layout.VBox(2)); |
---|
797 | rc.add(rc1, {flex : 1}); |
---|
798 | |
---|
799 | rc2 = new qx.ui.container.Composite(new qx.ui.layout.VBox(2)); |
---|
800 | rc.add(rc2, {flex : 1}); |
---|
801 | |
---|
802 | |
---|
803 | fr = new qx.ui.groupbox.GroupBox("Electrons", |
---|
804 | "pf/image/e_small.png"); |
---|
805 | fr.setLayout(new qx.ui.layout.VBox()); |
---|
806 | |
---|
807 | rc1.add(fr); |
---|
808 | |
---|
809 | var layout = new qx.ui.layout.Grid(4, 6); |
---|
810 | layout.setColumnWidth(0, 80); |
---|
811 | layout.setColumnFlex(1, 1); |
---|
812 | gl = new qx.ui.container.Composite(layout); |
---|
813 | |
---|
814 | fr.add(gl); |
---|
815 | |
---|
816 | var l, e; |
---|
817 | |
---|
818 | // N_e |
---|
819 | l = new qx.ui.basic.Label("N<sub>e</sub> (cm<sup>-3</sup>):"); |
---|
820 | l.setRich(true); |
---|
821 | gl.add(l, {row: 0, column: 0}); |
---|
822 | e = new pf.ui.TextField(this.plasma.e.getN()); |
---|
823 | gl.add(e, {row: 0, column: 1}); |
---|
824 | e.addListener("changeValue", changeN_e, this); |
---|
825 | this.gui_N_e = e; |
---|
826 | |
---|
827 | // T_e |
---|
828 | l = new qx.ui.basic.Label("T<sub>e</sub> (eV):"); |
---|
829 | l.setRich(true); |
---|
830 | gl.add(l, {row: 1, column: 0}); |
---|
831 | e = new pf.ui.TextField(this.plasma.e.getT()); |
---|
832 | gl.add(e, {row: 1, column: 1}); |
---|
833 | e.addListener("changeValue", changeT_e, this); |
---|
834 | this.gui_T_e = e; |
---|
835 | |
---|
836 | fr = new qx.ui.groupbox.GroupBox("Ions", |
---|
837 | "pf/image/i_small.png"); |
---|
838 | fr.setLayout(new qx.ui.layout.VBox()); |
---|
839 | |
---|
840 | rc1.add(fr); |
---|
841 | |
---|
842 | layout = new qx.ui.layout.Grid(4, 6); |
---|
843 | layout.setColumnWidth(0, 80); |
---|
844 | layout.setColumnFlex(1, 1); |
---|
845 | gl = new qx.ui.container.Composite(layout); |
---|
846 | |
---|
847 | fr.add(gl); |
---|
848 | |
---|
849 | // Z_i |
---|
850 | l = new qx.ui.basic.Label("Z<sub>i</sub>:"); |
---|
851 | l.setRich(true); |
---|
852 | gl.add(l, {row: 0, column: 0}); |
---|
853 | e = new qx.ui.form.Spinner(1, this.plasma.i.getQ(), 100); |
---|
854 | gl.add(e, {row: 0, column: 1}); |
---|
855 | e.addListener("changeValue", changeZ_i, this); |
---|
856 | this.gui_Z_i = e; |
---|
857 | |
---|
858 | // M_i |
---|
859 | l = new qx.ui.basic.Label("M<sub>i</sub>:"); |
---|
860 | l.setRich(true); |
---|
861 | gl.add(l, {row: 1, column: 0}); |
---|
862 | e = new qx.ui.form.Spinner(1, this.plasma.i.getM(), 200); |
---|
863 | gl.add(e, {row: 1, column: 1}); |
---|
864 | e.addListener("changeValue", changeM_i, this); |
---|
865 | this.gui_M_i = e; |
---|
866 | |
---|
867 | // T_i |
---|
868 | l = new qx.ui.basic.Label("T<sub>i</sub> (eV):"); |
---|
869 | l.setRich(true); |
---|
870 | gl.add(l, {row: 2, column: 0}); |
---|
871 | e = new pf.ui.TextField(this.plasma.i.getT()); |
---|
872 | gl.add(e, {row: 2, column: 1}); |
---|
873 | e.addListener("changeValue", changeT_i, this); |
---|
874 | this.gui_T_i = e; |
---|
875 | |
---|
876 | // N_i |
---|
877 | l = new qx.ui.basic.Label("N<sub>i</sub> (cm<sup>-3</sup>):"); |
---|
878 | l.setRich(true); |
---|
879 | gl.add(l, {row: 3, column: 0}); |
---|
880 | e = new pf.ui.TextField(this.plasma.i.getN()); |
---|
881 | gl.add(e, {row: 3, column: 1}); |
---|
882 | e.setReadOnly(true); |
---|
883 | this.gui_N_i = e; |
---|
884 | |
---|
885 | fr = new qx.ui.groupbox.GroupBox("Radiators", |
---|
886 | "pf/image/r_small.png"); |
---|
887 | fr.setLayout(new qx.ui.layout.VBox()); |
---|
888 | |
---|
889 | rc2.add(fr); |
---|
890 | |
---|
891 | layout = new qx.ui.layout.Grid(4, 6); |
---|
892 | layout.setColumnWidth(0, 80); |
---|
893 | layout.setColumnFlex(1, 1); |
---|
894 | gl = new qx.ui.container.Composite(layout); |
---|
895 | |
---|
896 | fr.add(gl); |
---|
897 | |
---|
898 | // Z_r |
---|
899 | l = new qx.ui.basic.Label("Z<sub>r</sub>:"); |
---|
900 | l.setRich(true); |
---|
901 | gl.add(l, {row: 0, column: 0}); |
---|
902 | e = new qx.ui.form.Spinner(0, this.plasma.r.getQ(), 100); |
---|
903 | gl.add(e, {row: 0, column: 1}); |
---|
904 | e.addListener("changeValue", changeZ_r, this); |
---|
905 | this.gui_Z_r = e; |
---|
906 | |
---|
907 | // M_r |
---|
908 | l = new qx.ui.basic.Label("M<sub>r</sub>:"); |
---|
909 | l.setRich(true); |
---|
910 | gl.add(l, {row: 1, column: 0}); |
---|
911 | e = new qx.ui.form.Spinner(1, this.plasma.r.getM(), 200); |
---|
912 | gl.add(e, {row: 1, column: 1}); |
---|
913 | e.addListener("changeValue", changeM_r, this); |
---|
914 | this.gui_M_r = e; |
---|
915 | |
---|
916 | // T_r |
---|
917 | l = new qx.ui.basic.Label("T<sub>r</sub> (eV):"); |
---|
918 | l.setRich(true); |
---|
919 | gl.add(l, {row: 2, column: 0}); |
---|
920 | e = new pf.ui.TextField(this.plasma.r.getT()); |
---|
921 | gl.add(e, {row: 2, column: 1}); |
---|
922 | e.addListener("changeValue", changeT_r, this); |
---|
923 | this.gui_T_r = e; |
---|
924 | |
---|
925 | // P_r |
---|
926 | l = new qx.ui.basic.Label("P<sub>r</sub> (%):"); |
---|
927 | l.setRich(true); |
---|
928 | gl.add(l, {row: 3, column: 0}); |
---|
929 | e = new qx.ui.form.Spinner(0, 100*this.plasma.P_r, 100); |
---|
930 | gl.add(e, {row: 3, column: 1}); |
---|
931 | e.addListener("changeValue", changeP_r, this); |
---|
932 | this.gui_P_r = e; |
---|
933 | |
---|
934 | // N_r |
---|
935 | l = new qx.ui.basic.Label("N<sub>r</sub> (cm<sup>-3</sup>):"); |
---|
936 | l.setRich(true); |
---|
937 | gl.add(l, {row: 4, column: 0}); |
---|
938 | e = new pf.ui.TextField(this.plasma.r.getN()); |
---|
939 | e.setReadOnly(true); |
---|
940 | gl.add(e, {row: 4, column: 1}); |
---|
941 | this.gui_N_r = e; |
---|
942 | |
---|
943 | |
---|
944 | fr = new qx.ui.groupbox.GroupBox("Fields", |
---|
945 | "pf/image/field_small.png"); |
---|
946 | fr.setLayout(new qx.ui.layout.VBox()); |
---|
947 | |
---|
948 | rc1.add(fr); |
---|
949 | |
---|
950 | layout = new qx.ui.layout.Grid(4, 6); |
---|
951 | layout.setColumnWidth(0, 80); |
---|
952 | layout.setColumnFlex(1, 1); |
---|
953 | gl = new qx.ui.container.Composite(layout); |
---|
954 | |
---|
955 | fr.add(gl); |
---|
956 | |
---|
957 | |
---|
958 | l = new qx.ui.basic.Label("B (T):"); |
---|
959 | l.setRich(true); |
---|
960 | gl.add(l, {row: 0, column: 0}); |
---|
961 | e = new pf.ui.TextField(this.plasma.B); |
---|
962 | gl.add(e, {row: 0, column: 1}); |
---|
963 | e.addListener("changeValue", changeB, this); |
---|
964 | this.gui_B = e; |
---|
965 | |
---|
966 | // Atomic system frame |
---|
967 | fr = new qx.ui.groupbox.GroupBox("Atomic system", |
---|
968 | "pf/image/all_small.png"); |
---|
969 | fr.setLayout(new qx.ui.layout.VBox()); |
---|
970 | |
---|
971 | rc2.add(fr); |
---|
972 | |
---|
973 | layout = new qx.ui.layout.Grid(4, 6); |
---|
974 | layout.setColumnWidth(0, 80); |
---|
975 | layout.setColumnFlex(1, 1); |
---|
976 | gl = new qx.ui.container.Composite(layout); |
---|
977 | |
---|
978 | fr.add(gl); |
---|
979 | |
---|
980 | l = new qx.ui.basic.Label("Z<sub>core</sub>:"); |
---|
981 | l.setRich(true); |
---|
982 | gl.add(l, {row: 0, column: 0}); |
---|
983 | e = new qx.ui.form.TextField((this.plasma.r.getQ() + 1) + ''); |
---|
984 | e.setReadOnly(true); |
---|
985 | gl.add(e, {row: 0, column: 1}); |
---|
986 | this.gui_Zcore = e; |
---|
987 | |
---|
988 | l = new qx.ui.basic.Label("n<sub>u</sub>:"); |
---|
989 | l.setRich(true); |
---|
990 | gl.add(l, {row: 1, column: 0}); |
---|
991 | e = new qx.ui.form.Spinner(2, this.plasma.n_u, 1000); |
---|
992 | gl.add(e, {row: 1, column: 1}); |
---|
993 | e.addListener("changeValue", changeN_u, this); |
---|
994 | this.gui_n_u = e; |
---|
995 | |
---|
996 | l = new qx.ui.basic.Label("n<sub>l</sub>:"); |
---|
997 | l.setRich(true); |
---|
998 | gl.add(l, {row: 2, column: 0}); |
---|
999 | e = new qx.ui.form.Spinner(1, this.plasma.n_l, 1000); |
---|
1000 | gl.add(e, {row: 2, column: 1}); |
---|
1001 | e.addListener("changeValue", changeN_l, this); |
---|
1002 | this.gui_n_l = e; |
---|
1003 | }, |
---|
1004 | |
---|
1005 | renderExplorerTab : function() |
---|
1006 | { |
---|
1007 | var page_id = this.renderTabPage("Explorer", |
---|
1008 | "pf/image/tab-explorer.png", false); |
---|
1009 | page_id.setLayout(new qx.ui.layout.VBox); |
---|
1010 | |
---|
1011 | var sp = new qx.ui.splitpane.Pane("horizontal"); |
---|
1012 | page_id.add(sp, {height: "100%"}); |
---|
1013 | |
---|
1014 | // Create container with fixed dimensions for the left: |
---|
1015 | var left_pane = new qx.ui.container.Composite(new qx.ui.layout.Grow).set({ |
---|
1016 | width: 250, |
---|
1017 | decorator : "main" |
---|
1018 | }); |
---|
1019 | |
---|
1020 | // Create container for the right: |
---|
1021 | var right_pane = new qx.ui.container.Composite(new qx.ui.layout.VBox(4)).set({ |
---|
1022 | padding : 4, |
---|
1023 | decorator : "main" |
---|
1024 | }); |
---|
1025 | |
---|
1026 | sp.add(left_pane, 0, {flex: 1}); |
---|
1027 | sp.add(right_pane, 1, {flex: 2}); |
---|
1028 | |
---|
1029 | |
---|
1030 | var tree = new qx.ui.tree.Tree("Browser"); |
---|
1031 | left_pane.add(tree); |
---|
1032 | |
---|
1033 | this.entity_tree = tree; |
---|
1034 | |
---|
1035 | var folder; |
---|
1036 | |
---|
1037 | var root = new qx.ui.tree.TreeFolder("Root"); |
---|
1038 | root.setOpen(true); |
---|
1039 | tree.setRoot(root); |
---|
1040 | tree.setHideRoot(true); |
---|
1041 | tree.setRootOpenClose(true); |
---|
1042 | tree.setOpenMode("none"); |
---|
1043 | |
---|
1044 | tree.addListener("changeSelection", clickTreeCB, this); |
---|
1045 | |
---|
1046 | folder = new qx.ui.tree.TreeFolder("Dimensionless"); |
---|
1047 | root.add(folder); |
---|
1048 | this.gui_folder_none = folder; |
---|
1049 | |
---|
1050 | folder = new qx.ui.tree.TreeFolder("Length"); |
---|
1051 | root.add(folder); |
---|
1052 | this.gui_folder_length = folder; |
---|
1053 | |
---|
1054 | folder = new qx.ui.tree.TreeFolder("Frequency"); |
---|
1055 | root.add(folder); |
---|
1056 | this.gui_folder_freq = folder; |
---|
1057 | |
---|
1058 | folder = new qx.ui.tree.TreeFolder("Velocity"); |
---|
1059 | root.add(folder); |
---|
1060 | this.gui_folder_vel = folder; |
---|
1061 | |
---|
1062 | folder = new qx.ui.tree.TreeFolder("Area"); |
---|
1063 | root.add(folder); |
---|
1064 | this.gui_folder_area = folder; |
---|
1065 | |
---|
1066 | folder = new qx.ui.tree.TreeFolder("Energy"); |
---|
1067 | root.add(folder); |
---|
1068 | this.gui_folder_energy = folder; |
---|
1069 | |
---|
1070 | folder = new qx.ui.tree.TreeFolder("Pressure"); |
---|
1071 | root.add(folder); |
---|
1072 | this.gui_folder_pressure = folder; |
---|
1073 | |
---|
1074 | folder = new qx.ui.tree.TreeFolder("Power density"); |
---|
1075 | root.add(folder); |
---|
1076 | this.gui_folder_power_density = folder; |
---|
1077 | |
---|
1078 | folder = new qx.ui.tree.TreeFolder("Power spectral density"); |
---|
1079 | root.add(folder); |
---|
1080 | this.gui_folder_spectral_power_density = folder; |
---|
1081 | |
---|
1082 | folder = new qx.ui.tree.TreeFolder("Miscellaneous"); |
---|
1083 | root.add(folder); |
---|
1084 | this.gui_folder_misc = folder; |
---|
1085 | |
---|
1086 | |
---|
1087 | |
---|
1088 | this.populateTree(); |
---|
1089 | |
---|
1090 | // Build context-sensitive popup menu |
---|
1091 | this.treeMenu = new qx.ui.menu.Menu; |
---|
1092 | var button; |
---|
1093 | |
---|
1094 | button = new qx.ui.menu.Button("Add to Favorites", |
---|
1095 | "pf/image/favorite-add.png"); |
---|
1096 | button.addListener("execute", addToFavCB, this); |
---|
1097 | this.treeMenu.add(button); |
---|
1098 | this.treeMenuButtonAddToFav = button; |
---|
1099 | button = new qx.ui.menu.Button("Remove from Favorites", |
---|
1100 | "pf/image/favorite-delete.png"); |
---|
1101 | button.addListener("execute", removeFromFavCB, this); |
---|
1102 | this.treeMenu.add(button); |
---|
1103 | this.treeMenuButtonRemFromFav = button; |
---|
1104 | |
---|
1105 | this.doc.add(this.treeMenu); |
---|
1106 | |
---|
1107 | |
---|
1108 | var layout = new qx.ui.layout.Grid(4, 6); |
---|
1109 | layout.setColumnFlex(0, 3); |
---|
1110 | layout.setColumnFlex(1, 12); |
---|
1111 | layout.setColumnFlex(2, 4); |
---|
1112 | layout.setColumnMinWidth(0, 50); |
---|
1113 | layout.setColumnMaxWidth(2, 150); |
---|
1114 | var gl = new qx.ui.container.Composite(layout); |
---|
1115 | |
---|
1116 | var l, e; |
---|
1117 | |
---|
1118 | |
---|
1119 | l = new qx.ui.basic.Label("Name:"); |
---|
1120 | gl.add(l, {row: 0, column: 0}); |
---|
1121 | e = new qx.ui.form.TextField(); |
---|
1122 | e.setReadOnly(true); |
---|
1123 | this.gui_entity_name = e; |
---|
1124 | gl.add(e, {row: 0, column: 1, colSpan: 2}); |
---|
1125 | |
---|
1126 | l = new qx.ui.basic.Label("Value:"); |
---|
1127 | gl.add(l, {row: 1, column: 0}); |
---|
1128 | e = new pf.ui.TextField(""); |
---|
1129 | e.setReadOnly(true); |
---|
1130 | gl.add(e, {row: 1, column: 1}); |
---|
1131 | this.gui_entity_value = e; |
---|
1132 | |
---|
1133 | e = new pf.UnitSelector(); |
---|
1134 | e.addListener("changeSelection", changeUnitsCB, this); |
---|
1135 | gl.add(e, {row: 1, column: 2}); |
---|
1136 | this.gui_entity_units = e; |
---|
1137 | |
---|
1138 | l = new qx.ui.basic.Label("Section:"); |
---|
1139 | gl.add(l, {row: 2, column: 0}); |
---|
1140 | e = new qx.ui.form.TextField(); |
---|
1141 | e.setReadOnly(true); |
---|
1142 | this.gui_entity_section = e; |
---|
1143 | gl.add(e, {row: 2, column: 1, colSpan: 2}); |
---|
1144 | |
---|
1145 | right_pane.add(gl); |
---|
1146 | |
---|
1147 | var fr = new qx.ui.groupbox.GroupBox("Wikipedia article", |
---|
1148 | "pf/image/wikipedia.png"); |
---|
1149 | fr.setLayout(new qx.ui.layout.Grow()); |
---|
1150 | |
---|
1151 | var iframe = new qx.ui.embed.Iframe(); |
---|
1152 | iframe.addListener("load", function(ev) { |
---|
1153 | this.setCursor("default"); |
---|
1154 | }); |
---|
1155 | |
---|
1156 | fr.add(iframe); |
---|
1157 | right_pane.add(fr, {flex: 1}); |
---|
1158 | |
---|
1159 | this.gui_wiki = iframe; |
---|
1160 | }, |
---|
1161 | |
---|
1162 | renderCompareTab : function() |
---|
1163 | { |
---|
1164 | var page_id = this.renderTabPage("Compare", |
---|
1165 | "pf/image/tab-compare.png"); |
---|
1166 | page_id.setLayout(new qx.ui.layout.VBox(1)); |
---|
1167 | |
---|
1168 | var bl = new qx.ui.container.Composite(new qx.ui.layout.VBox(10)); |
---|
1169 | page_id.add(bl, {height: "100%"}); |
---|
1170 | |
---|
1171 | var rc = new qx.ui.container.Composite(new qx.ui.layout.HBox(10)); |
---|
1172 | bl.add(rc); |
---|
1173 | |
---|
1174 | var l, e; |
---|
1175 | l = new qx.ui.basic.Label("Dimension:"); |
---|
1176 | rc.add(l); |
---|
1177 | e = new pf.ui.SelectBox; |
---|
1178 | e.addItem("None", "none"); |
---|
1179 | e.addItem("Length", "length"); |
---|
1180 | e.addItem("Frequency", "frequency"); |
---|
1181 | e.addItem("Velocity", "velocity"); |
---|
1182 | e.addItem("Area", "area"); |
---|
1183 | e.addItem("Energy", "energy"); |
---|
1184 | e.addItem("Pressure", "pressure"); |
---|
1185 | e.addItem("Power density", "power_density"); |
---|
1186 | e.addItem("Power spectral density", "spectral_power_density"); |
---|
1187 | e.addItem("Electric field", "efield"); |
---|
1188 | e.addListener("changeSelection", function(ev) { |
---|
1189 | var dimension = this.gui_compare_dim.getSelectedValue(); |
---|
1190 | this.gui_compare_units.update(dimension, |
---|
1191 | this.prefs.units[dimension]); |
---|
1192 | this.updateFavoritesListView(); |
---|
1193 | this.updateLegendListView(); |
---|
1194 | }, this); |
---|
1195 | rc.add(e); |
---|
1196 | this.gui_compare_dim = e; |
---|
1197 | |
---|
1198 | l = new qx.ui.basic.Label("Units:"); |
---|
1199 | rc.add(l); |
---|
1200 | e = new pf.UnitSelector(); |
---|
1201 | e.update("none"); |
---|
1202 | e.addListener("changeSelection", function(ev) { |
---|
1203 | this.updateFavoritesListView(); |
---|
1204 | }, this); |
---|
1205 | rc.add(e); |
---|
1206 | this.gui_compare_units = e; |
---|
1207 | |
---|
1208 | // table model |
---|
1209 | var tm = new qx.ui.table.model.Simple(); |
---|
1210 | tm.setColumns([ "", "Name", "Section", "Value" ]); |
---|
1211 | |
---|
1212 | tm.setColumnEditable(0, false); |
---|
1213 | tm.setColumnEditable(1, false); |
---|
1214 | tm.setColumnEditable(2, false); |
---|
1215 | tm.setColumnEditable(3, false); |
---|
1216 | |
---|
1217 | tm.setColumnSortable(0, false); |
---|
1218 | |
---|
1219 | tm.setSortMethods(3, function(row1, row2) { |
---|
1220 | var obj1 = parseFloat(row1[arguments.callee.columnIndex]); |
---|
1221 | var obj2 = parseFloat(row2[arguments.callee.columnIndex]); |
---|
1222 | return (obj1 > obj2) ? 1 : ((obj1 == obj2) ? 0 : -1); |
---|
1223 | }); |
---|
1224 | |
---|
1225 | // table list |
---|
1226 | var lv = new qx.ui.table.Table(tm); |
---|
1227 | |
---|
1228 | lv.setStatusBarVisible(false); |
---|
1229 | lv.setShowCellFocusIndicator(false); |
---|
1230 | lv.setColumnVisibilityButtonVisible(false); |
---|
1231 | |
---|
1232 | lv.setColumnWidth(0, 24); |
---|
1233 | lv.setColumnWidth(1, 300); |
---|
1234 | lv.setColumnWidth(2, 120); |
---|
1235 | |
---|
1236 | var renderer = new qx.ui.table.cellrenderer.Image(16, 16); |
---|
1237 | lv.getTableColumnModel().setDataCellRenderer(0, renderer); |
---|
1238 | |
---|
1239 | bl.add(lv, {flex: 1}); |
---|
1240 | |
---|
1241 | this.favoritesListView = lv; |
---|
1242 | }, |
---|
1243 | |
---|
1244 | drawAll : function(ev) |
---|
1245 | { |
---|
1246 | var canvas = this.canvas; |
---|
1247 | |
---|
1248 | canvas.setPrintable(true); |
---|
1249 | |
---|
1250 | var pname = this.guiParameter.getSelectedValue(); |
---|
1251 | var vmin = this.guiMinParam.getNumValue(); |
---|
1252 | var vmax = this.guiMaxParam.getNumValue(); |
---|
1253 | var npoints = this.guiParamPoints.getValue(); |
---|
1254 | |
---|
1255 | if (npoints < 2 || !pname) { |
---|
1256 | return; |
---|
1257 | } |
---|
1258 | |
---|
1259 | var dimension = this.gui_compare_dim.getSelectedValue(); |
---|
1260 | var scale = this.gui_compare_units.getSelectedValue(); |
---|
1261 | |
---|
1262 | var par0; |
---|
1263 | var label; |
---|
1264 | switch (pname) { |
---|
1265 | case "N_e": |
---|
1266 | par0 = this.plasma.e.getN(); |
---|
1267 | label = "N<sub>e</sub> (cm<sup>-3</sup>)" |
---|
1268 | break; |
---|
1269 | case "T": |
---|
1270 | par0 = this.plasma.e.getT(); |
---|
1271 | label = "T (eV)" |
---|
1272 | break; |
---|
1273 | case "T_e": |
---|
1274 | par0 = this.plasma.e.getT(); |
---|
1275 | label = "T<sub>e</sub> (eV)" |
---|
1276 | break; |
---|
1277 | case "T_i": |
---|
1278 | par0 = this.plasma.i.getT(); |
---|
1279 | label = "T<sub>i</sub> (eV)" |
---|
1280 | break; |
---|
1281 | case "T_r": |
---|
1282 | par0 = this.plasma.r.getT(); |
---|
1283 | label = "T<sub>r</sub> (eV)" |
---|
1284 | break; |
---|
1285 | case "T_i,r": |
---|
1286 | par0 = this.plasma.i.getT(); |
---|
1287 | label = "T<sub>i,r</sub> (eV)" |
---|
1288 | break; |
---|
1289 | case "B": |
---|
1290 | par0 = this.plasma.B; |
---|
1291 | label = "B (T)" |
---|
1292 | break; |
---|
1293 | default: |
---|
1294 | return; |
---|
1295 | } |
---|
1296 | |
---|
1297 | var xdata = new Array; |
---|
1298 | for (var j = 0; j < npoints; j++) { |
---|
1299 | var x = par0*(vmin + (vmax - vmin)*j/(npoints - 1)); |
---|
1300 | xdata.push(x); |
---|
1301 | } |
---|
1302 | |
---|
1303 | var wxmin = xdata[0]; |
---|
1304 | var wxmax = xdata[xdata.length - 1]; |
---|
1305 | |
---|
1306 | var wymin = 0; |
---|
1307 | var wymax = 0; |
---|
1308 | |
---|
1309 | var sets = new Array; |
---|
1310 | var first = true; |
---|
1311 | for (var i = 0; i < this.favorites.length; i++) { |
---|
1312 | var fav = this.favorites[i]; |
---|
1313 | var entity = fav.entity; |
---|
1314 | |
---|
1315 | if (entity.dimension != dimension) { |
---|
1316 | continue; |
---|
1317 | } |
---|
1318 | |
---|
1319 | var species = fav.species; |
---|
1320 | var vname = this.getEntityFullName(entity, species); |
---|
1321 | |
---|
1322 | var set = new Array; |
---|
1323 | var ydata = new Array; |
---|
1324 | for (var j = 0; j < npoints; j++) { |
---|
1325 | var par = xdata[j]; |
---|
1326 | |
---|
1327 | switch (pname) { |
---|
1328 | case "N_e": |
---|
1329 | this.plasma.e.setN(par); |
---|
1330 | this.updatePlasmaParameters(); |
---|
1331 | break; |
---|
1332 | case "T_e": |
---|
1333 | this.plasma.e.setT(par); |
---|
1334 | break; |
---|
1335 | case "T_i": |
---|
1336 | this.plasma.i.setT(par); |
---|
1337 | break; |
---|
1338 | case "T_r": |
---|
1339 | this.plasma.r.setT(par); |
---|
1340 | break; |
---|
1341 | case "T_i,r": |
---|
1342 | this.plasma.i.setT(par); |
---|
1343 | this.plasma.r.setT(par); |
---|
1344 | break; |
---|
1345 | case "T": |
---|
1346 | this.plasma.e.setT(par); |
---|
1347 | this.plasma.i.setT(par); |
---|
1348 | this.plasma.r.setT(par); |
---|
1349 | break; |
---|
1350 | case "B": |
---|
1351 | this.plasma.B = par; |
---|
1352 | break; |
---|
1353 | } |
---|
1354 | |
---|
1355 | var value = scale*this.evaluateEntityValue(entity, species); |
---|
1356 | |
---|
1357 | if (first) { |
---|
1358 | wymin = value; |
---|
1359 | wymax = value; |
---|
1360 | first = false; |
---|
1361 | } else { |
---|
1362 | if (value < wymin) { |
---|
1363 | wymin = value; |
---|
1364 | } |
---|
1365 | if (value > wymax) { |
---|
1366 | wymax = value; |
---|
1367 | } |
---|
1368 | } |
---|
1369 | |
---|
1370 | ydata.push(value); |
---|
1371 | } |
---|
1372 | set.x = xdata; |
---|
1373 | set.y = ydata; |
---|
1374 | set.legend = vname; |
---|
1375 | set.color = fav.color; |
---|
1376 | sets.push(set); |
---|
1377 | } |
---|
1378 | |
---|
1379 | // Restore parameter |
---|
1380 | switch (pname) { |
---|
1381 | case "N_e": |
---|
1382 | this.plasma.e.setN(par0); |
---|
1383 | this.updatePlasmaParameters(); |
---|
1384 | break; |
---|
1385 | case "T_e": |
---|
1386 | this.plasma.e.setT(par0); |
---|
1387 | break; |
---|
1388 | case "T_i": |
---|
1389 | this.plasma.i.setT(par0); |
---|
1390 | break; |
---|
1391 | case "T_r": |
---|
1392 | this.plasma.r.setT(par0); |
---|
1393 | break; |
---|
1394 | case "T_i,r": |
---|
1395 | this.plasma.i.setT(par0); |
---|
1396 | this.plasma.r.setT(par0); |
---|
1397 | break; |
---|
1398 | case "T": |
---|
1399 | this.plasma.e.setT(par0); |
---|
1400 | this.plasma.i.setT(par0); |
---|
1401 | this.plasma.r.setT(par0); |
---|
1402 | break; |
---|
1403 | case "B": |
---|
1404 | this.plasma.B = par0; |
---|
1405 | break; |
---|
1406 | } |
---|
1407 | |
---|
1408 | canvas.clear(); |
---|
1409 | |
---|
1410 | canvas.setViewportCoordinates(0.15, 0.1, 0.9, 0.9); |
---|
1411 | var dwx = Math.abs(wxmax - wxmin); |
---|
1412 | if (dwx == 0) { |
---|
1413 | dwx = wxmax; |
---|
1414 | } |
---|
1415 | var dwy = Math.abs(wymax - wymin); |
---|
1416 | if (dwy == 0) { |
---|
1417 | wymin = 0.0; |
---|
1418 | if (wymax == 0) { |
---|
1419 | wymax = 1.0; |
---|
1420 | } else { |
---|
1421 | wymax *= 2; |
---|
1422 | } |
---|
1423 | } |
---|
1424 | var wymin_r = |
---|
1425 | wymin < 0 ? (wymin - 0.05*dwy) : Math.max(0, wymin - 0.05*dwy); |
---|
1426 | var wxmin_r = |
---|
1427 | wxmin < 0 ? (wxmin - 0.05*dwx) : Math.max(0, wxmin - 0.05*dwx); |
---|
1428 | canvas.setWorldCoordinates(wxmin_r, wymin_r, |
---|
1429 | wxmax + 0.05*dwx, wymax + 0.05*dwy); |
---|
1430 | |
---|
1431 | // Draw frame |
---|
1432 | canvas.drawFrame("black"); |
---|
1433 | |
---|
1434 | // Mark initial value of the varied parameter |
---|
1435 | canvas.setColor("#c0c0c0"); |
---|
1436 | canvas.drawPolyLineW(new Array(par0, par0), |
---|
1437 | new Array(wymin, wymax)); |
---|
1438 | |
---|
1439 | // Draw title |
---|
1440 | canvas.drawTitle(this.prefs.currentConfigName, "black"); |
---|
1441 | |
---|
1442 | // Draw axis ticks |
---|
1443 | canvas.drawTicks("x", "blue"); |
---|
1444 | canvas.drawTicks("y", "blue"); |
---|
1445 | |
---|
1446 | // Draw axis labels |
---|
1447 | canvas.drawLabel("x", label, "black"); |
---|
1448 | |
---|
1449 | // Draw sets |
---|
1450 | for (var i = 0; i < sets.length; i++) { |
---|
1451 | var set = sets[i]; |
---|
1452 | canvas.setColor(set.color); |
---|
1453 | canvas.drawPolyLineW(set.x, set.y); |
---|
1454 | |
---|
1455 | delete set; |
---|
1456 | } |
---|
1457 | |
---|
1458 | delete sets; |
---|
1459 | |
---|
1460 | canvas.paint(); |
---|
1461 | }, |
---|
1462 | |
---|
1463 | showWikiPage : function(entity) |
---|
1464 | { |
---|
1465 | var url = "about:blank"; |
---|
1466 | if (entity && entity.wikiLink) { |
---|
1467 | url = "http://en.wikipedia.org/w/index.php?title=" + |
---|
1468 | entity.wikiLink + "&printable=yes"; |
---|
1469 | } |
---|
1470 | |
---|
1471 | this.gui_wiki.setCursor("wait"); |
---|
1472 | this.gui_wiki.setSource(url); |
---|
1473 | }, |
---|
1474 | |
---|
1475 | loadWikiCB : function(ev) |
---|
1476 | { |
---|
1477 | var tree = this.entity_tree; |
---|
1478 | var leaf = getSingleTreeSelectedItem(tree); |
---|
1479 | |
---|
1480 | if (!leaf) { |
---|
1481 | return; |
---|
1482 | } |
---|
1483 | |
---|
1484 | var entity = leaf.getUserData("entity"); |
---|
1485 | |
---|
1486 | this.showWikiPage(entity); |
---|
1487 | }, |
---|
1488 | |
---|
1489 | drawCB : function(ev) |
---|
1490 | { |
---|
1491 | this.drawAll(); |
---|
1492 | }, |
---|
1493 | |
---|
1494 | renderPlotTab : function() |
---|
1495 | { |
---|
1496 | var page_id = this.renderTabPage("Plot", |
---|
1497 | "pf/image/tab-plot.png"); |
---|
1498 | page_id.setLayout(new qx.ui.layout.VBox); |
---|
1499 | |
---|
1500 | var sp = new qx.ui.splitpane.Pane("horizontal"); |
---|
1501 | page_id.add(sp, {height: "100%"}); |
---|
1502 | |
---|
1503 | var left_pane = new qx.ui.container.Composite(new qx.ui.layout.Grow).set({ |
---|
1504 | decorator : "main" |
---|
1505 | }); |
---|
1506 | var right_pane = new qx.ui.container.Composite(new qx.ui.layout.VBox(4)).set({ |
---|
1507 | padding : 4, |
---|
1508 | decorator : "main" |
---|
1509 | }); |
---|
1510 | |
---|
1511 | sp.add(left_pane, 2); |
---|
1512 | sp.add(right_pane, 1); |
---|
1513 | |
---|
1514 | var canvas = new pf.ui.canvas.Plotter(); |
---|
1515 | left_pane.add(canvas); |
---|
1516 | this.canvas = canvas; |
---|
1517 | |
---|
1518 | var layout = new qx.ui.layout.Grid(4, 6); |
---|
1519 | layout.setColumnWidth(0, 100); |
---|
1520 | layout.setColumnFlex(1, 1); |
---|
1521 | var gl = new qx.ui.container.Composite(layout); |
---|
1522 | |
---|
1523 | var l, e; |
---|
1524 | |
---|
1525 | var btn = new qx.ui.form.Button("Redraw", "pf/image/tab-plot.png"); |
---|
1526 | btn.addListener("execute", this.drawCB, this); |
---|
1527 | gl.add(btn, {row: 0, column: 0}); |
---|
1528 | |
---|
1529 | l = new qx.ui.basic.Label("Parameter to vary:"); |
---|
1530 | e = new pf.ui.SelectBox; |
---|
1531 | e.addItem("N_e", "N_e"); |
---|
1532 | e.addItem("T", "T"); |
---|
1533 | e.addItem("T_e", "T_e"); |
---|
1534 | e.addItem("T_i", "T_i"); |
---|
1535 | e.addItem("T_r", "T_r"); |
---|
1536 | e.addItem("T_i,r", "T_i,r"); |
---|
1537 | e.addItem("B", "B"); |
---|
1538 | e.selectByValue("N_e"); |
---|
1539 | this.guiParameter = e; |
---|
1540 | gl.add(l, {row: 1, column: 0}); |
---|
1541 | gl.add(e, {row: 1, column: 1}); |
---|
1542 | |
---|
1543 | l = new qx.ui.basic.Label("Minimum scale:"); |
---|
1544 | e = new pf.ui.TextField(0.5); |
---|
1545 | this.guiMinParam = e; |
---|
1546 | gl.add(l, {row: 2, column: 0}); |
---|
1547 | gl.add(e, {row: 2, column: 1}); |
---|
1548 | |
---|
1549 | l = new qx.ui.basic.Label("Maximum scale:"); |
---|
1550 | e = new pf.ui.TextField(2.0); |
---|
1551 | this.guiMaxParam = e; |
---|
1552 | gl.add(l, {row: 3, column: 0}); |
---|
1553 | gl.add(e, {row: 3, column: 1}); |
---|
1554 | |
---|
1555 | l = new qx.ui.basic.Label("Number of points:"); |
---|
1556 | e = new qx.ui.form.Spinner(2, 20, 100); |
---|
1557 | this.guiParamPoints = e; |
---|
1558 | gl.add(l, {row: 4, column: 0}); |
---|
1559 | gl.add(e, {row: 4, column: 1}); |
---|
1560 | |
---|
1561 | right_pane.add(gl); |
---|
1562 | |
---|
1563 | |
---|
1564 | |
---|
1565 | var tm = new qx.ui.table.model.Simple(); |
---|
1566 | tm.setColumns(["", "Name", "Favorite"], |
---|
1567 | ["color", "name", "favorite"]); |
---|
1568 | |
---|
1569 | tm.setColumnEditable(0, false); |
---|
1570 | tm.setColumnEditable(1, false); |
---|
1571 | |
---|
1572 | tm.setColumnSortable(0, false); |
---|
1573 | |
---|
1574 | // table list |
---|
1575 | var lv = new qx.ui.table.Table(tm); |
---|
1576 | |
---|
1577 | var cm = lv.getTableColumnModel(); |
---|
1578 | cm.setColumnVisible(2, false); |
---|
1579 | |
---|
1580 | lv.setStatusBarVisible(false); |
---|
1581 | lv.setShowCellFocusIndicator(false); |
---|
1582 | lv.setColumnVisibilityButtonVisible(false); |
---|
1583 | |
---|
1584 | lv.setColumnWidth(0, 22); |
---|
1585 | lv.setColumnWidth(1, 220); |
---|
1586 | |
---|
1587 | var renderer = new pf.ui.table.cellrenderer.BgColor(); |
---|
1588 | lv.getTableColumnModel().setDataCellRenderer(0, renderer); |
---|
1589 | |
---|
1590 | right_pane.add(lv, {flex: 1}); |
---|
1591 | this.legendListView = lv; |
---|
1592 | |
---|
1593 | var sm = lv.getSelectionModel(); |
---|
1594 | |
---|
1595 | lv.addListener("dblclick", function(ev) { |
---|
1596 | ev.stopPropagation(); |
---|
1597 | |
---|
1598 | if (sm.isSelectionEmpty()) { |
---|
1599 | return; |
---|
1600 | } |
---|
1601 | |
---|
1602 | var index = sm.getLeadSelectionIndex(); |
---|
1603 | var item = tm.getRowDataAsMap(index); |
---|
1604 | |
---|
1605 | var favorite = item.favorite; |
---|
1606 | if (!favorite) { |
---|
1607 | return; |
---|
1608 | } |
---|
1609 | cpop.setUserData("favorite", null); // avoid loop call |
---|
1610 | cpop.setValue(favorite.color); |
---|
1611 | cpop.setUserData("favorite", favorite); |
---|
1612 | |
---|
1613 | cpop.placeToMouse(ev); |
---|
1614 | cpop.open(); |
---|
1615 | }); |
---|
1616 | |
---|
1617 | var cpop = new pf.ui.ColorPopup(this.colorMap); |
---|
1618 | cpop.exclude(); |
---|
1619 | |
---|
1620 | this.doc.add(cpop); |
---|
1621 | |
---|
1622 | cpop.addListener("changeValue", function(ev) { |
---|
1623 | var color = ev.getData(); |
---|
1624 | var cpop = ev.getTarget(); |
---|
1625 | var favorite = cpop.getUserData("favorite"); |
---|
1626 | if (!favorite || !color) { |
---|
1627 | return; |
---|
1628 | } |
---|
1629 | favorite.color = color; |
---|
1630 | this.updateLegendListView(); |
---|
1631 | this.drawAll(); |
---|
1632 | }, this); |
---|
1633 | |
---|
1634 | // drawAll is an expensive operation, so call it only when |
---|
1635 | // this tab is selected |
---|
1636 | this.tabview.addListener("changeSelection", function(ev) { |
---|
1637 | if (ev.getData()[0] == page_id) { |
---|
1638 | this.drawAll(); |
---|
1639 | } |
---|
1640 | }, this); |
---|
1641 | }, |
---|
1642 | |
---|
1643 | |
---|
1644 | aboutCB : function(ev) |
---|
1645 | { |
---|
1646 | this.aboutWindow.open(); |
---|
1647 | }, |
---|
1648 | |
---|
1649 | prefsCB : function(ev) |
---|
1650 | { |
---|
1651 | this.prefsWindow.open(); |
---|
1652 | }, |
---|
1653 | |
---|
1654 | updateSaveLoadList : function() |
---|
1655 | { |
---|
1656 | var lv = this.saveLoadConfigList; |
---|
1657 | var tm = lv.getTableModel(); |
---|
1658 | |
---|
1659 | var configPtrs = this.prefs.configPtrs; |
---|
1660 | |
---|
1661 | var rowData = new Array(); |
---|
1662 | |
---|
1663 | var i; |
---|
1664 | var d = new Date(); |
---|
1665 | var df = new qx.util.format.DateFormat("yyyy-MM-dd HH:mm:ss"); |
---|
1666 | |
---|
1667 | for (i = 0; i < configPtrs.length; i++) { |
---|
1668 | var configPtr = configPtrs[i]; |
---|
1669 | |
---|
1670 | d.setTime(configPtr.time); |
---|
1671 | |
---|
1672 | rowData.push([configPtr.name, df.format(d)]); |
---|
1673 | } |
---|
1674 | |
---|
1675 | tm.setData(rowData, false); |
---|
1676 | var sidx = tm.getSortColumnIndex(); |
---|
1677 | tm.sortByColumn(sidx, tm.isSortAscending()); |
---|
1678 | |
---|
1679 | lv.updateContent(); |
---|
1680 | }, |
---|
1681 | |
---|
1682 | saveAsCB : function(ev) |
---|
1683 | { |
---|
1684 | var w = this.saveLoadWindow; |
---|
1685 | |
---|
1686 | this.updateSaveLoadList(); |
---|
1687 | this.saveLoadTextField.setValue(null); |
---|
1688 | this.saveLoadTextField.setReadOnly(false); |
---|
1689 | |
---|
1690 | w.setCaption("Save configuration") |
---|
1691 | w.setIcon("pf/image/save.png"); |
---|
1692 | w.setUserData("type", "save"); |
---|
1693 | |
---|
1694 | w.open(); |
---|
1695 | }, |
---|
1696 | |
---|
1697 | saveConfigCB : function(ev) |
---|
1698 | { |
---|
1699 | if (this.prefs.currentConfigName && |
---|
1700 | this.prefs.currentConfigName != "Untitled") { |
---|
1701 | if (this.saveConfig(this.prefs.currentConfigName) != true) { |
---|
1702 | alert("Save failed!"); |
---|
1703 | } |
---|
1704 | } else { |
---|
1705 | this.saveAsCB(ev); |
---|
1706 | } |
---|
1707 | }, |
---|
1708 | |
---|
1709 | openCB : function(ev) |
---|
1710 | { |
---|
1711 | var w = this.saveLoadWindow; |
---|
1712 | |
---|
1713 | this.updateSaveLoadList(); |
---|
1714 | this.saveLoadTextField.setValue(null); |
---|
1715 | this.saveLoadTextField.setReadOnly(true); |
---|
1716 | |
---|
1717 | w.setCaption("Open configuration") |
---|
1718 | w.setIcon("pf/image/open.png"); |
---|
1719 | w.setUserData("type", "open"); |
---|
1720 | |
---|
1721 | w.open(); |
---|
1722 | }, |
---|
1723 | |
---|
1724 | buildMenu : function() |
---|
1725 | { |
---|
1726 | var menubar = this.menubar; |
---|
1727 | |
---|
1728 | var submenu, btn, q; |
---|
1729 | |
---|
1730 | submenu = new qx.ui.menu.Menu; |
---|
1731 | this.doc.add(submenu); |
---|
1732 | q = new qx.ui.core.Command("Ctrl+O"); |
---|
1733 | q.addListener("execute", this.openCB, this); |
---|
1734 | btn = new qx.ui.menu.Button("Open...", "pf/image/open.png", q); |
---|
1735 | submenu.add(btn); |
---|
1736 | q = new qx.ui.core.Command("Ctrl+S"); |
---|
1737 | q.addListener("execute", this.saveConfigCB, this); |
---|
1738 | btn = new qx.ui.menu.Button("Save", "pf/image/save.png", q); |
---|
1739 | submenu.add(btn); |
---|
1740 | btn = new qx.ui.menu.Button("Save as...", "pf/image/save.png"); |
---|
1741 | btn.addListener("execute", this.saveAsCB, this); |
---|
1742 | submenu.add(btn); |
---|
1743 | submenu.add(new qx.ui.menu.Separator); |
---|
1744 | q = new qx.ui.core.Command("Ctrl+P"); |
---|
1745 | q.addListener("execute", function(ev) { |
---|
1746 | window.print(); |
---|
1747 | }); |
---|
1748 | btn = new qx.ui.menu.Button("Print...", "pf/image/print.png", q); |
---|
1749 | submenu.add(btn); |
---|
1750 | submenu.add(new qx.ui.menu.Separator); |
---|
1751 | q = new qx.ui.core.Command("Ctrl+R"); |
---|
1752 | q.addListener("execute", function(ev) { |
---|
1753 | if (!this.prefs.warnOnExit || |
---|
1754 | confirm("Restart Plasma Formulary?")) { |
---|
1755 | this.intendedExit = true; |
---|
1756 | location.reload(true); |
---|
1757 | } |
---|
1758 | }, this); |
---|
1759 | btn = new qx.ui.menu.Button("Restart", "pf/image/reset.png", q); |
---|
1760 | submenu.add(btn); |
---|
1761 | submenu.add(new qx.ui.menu.Separator); |
---|
1762 | q = new qx.ui.core.Command("Ctrl+Q"); |
---|
1763 | q.addListener("execute", function(ev) { |
---|
1764 | if (!this.prefs.warnOnExit || |
---|
1765 | confirm("Quit Plasma Formulary?")) { |
---|
1766 | this.intendedExit = true; |
---|
1767 | window.close(); |
---|
1768 | } |
---|
1769 | }, this); |
---|
1770 | btn = new qx.ui.menu.Button("Quit", "pf/image/exit.png", q); |
---|
1771 | submenu.add(btn); |
---|
1772 | |
---|
1773 | btn = new qx.ui.menubar.Button("File", null, submenu); |
---|
1774 | menubar.add(btn); |
---|
1775 | |
---|
1776 | |
---|
1777 | submenu = new qx.ui.menu.Menu; |
---|
1778 | submenu.addListener("appear", editMenuCB, this); |
---|
1779 | this.doc.add(submenu); |
---|
1780 | btn = new qx.ui.menu.Button("Add to Favorites", |
---|
1781 | "pf/image/favorite-add.png"); |
---|
1782 | btn.addListener("execute", addToFavCB, this); |
---|
1783 | this.editMenuButtonAddToFav = btn; |
---|
1784 | submenu.add(btn); |
---|
1785 | btn = new qx.ui.menu.Button("Remove from Favorites", |
---|
1786 | "pf/image/favorite-delete.png"); |
---|
1787 | btn.addListener("execute", removeFromFavCB, this); |
---|
1788 | this.editMenuButtonRemFromFav = btn; |
---|
1789 | submenu.add(btn); |
---|
1790 | submenu.add(new qx.ui.menu.Separator); |
---|
1791 | btn = new qx.ui.menu.Button("Preferences", |
---|
1792 | "pf/image/preferences.png"); |
---|
1793 | btn.addListener("execute", this.prefsCB, this); |
---|
1794 | submenu.add(btn); |
---|
1795 | |
---|
1796 | btn = new qx.ui.menubar.Button("Edit", null, submenu); |
---|
1797 | menubar.add(btn); |
---|
1798 | |
---|
1799 | |
---|
1800 | submenu = new qx.ui.menu.Menu; |
---|
1801 | submenu.addListener("appear", viewMenuCB, this); |
---|
1802 | |
---|
1803 | var subMenu1 = new qx.ui.menu.Menu; |
---|
1804 | btn = new qx.ui.menu.CheckBox("Fundamental"); |
---|
1805 | btn.setValue(this.showFundamental); |
---|
1806 | btn.addListener("execute", showFundamentalCB, this); |
---|
1807 | subMenu1.add(btn); |
---|
1808 | btn = new qx.ui.menu.CheckBox("Spectroscopy"); |
---|
1809 | btn.setValue(this.showSpectroscopy); |
---|
1810 | btn.addListener("execute", showSpectroscopyCB, this); |
---|
1811 | subMenu1.add(btn); |
---|
1812 | btn = new qx.ui.menu.CheckBox("Waves"); |
---|
1813 | btn.setValue(this.showWaves); |
---|
1814 | btn.addListener("execute", showWavesCB, this); |
---|
1815 | subMenu1.add(btn); |
---|
1816 | btn = new qx.ui.menu.CheckBox("Collisions"); |
---|
1817 | btn.setValue(this.showCollisions); |
---|
1818 | btn.addListener("execute", showCollisionsCB, this); |
---|
1819 | subMenu1.add(btn); |
---|
1820 | this.showSectionsButton = new qx.ui.menu.Button("Show Sections", |
---|
1821 | null, null, subMenu1); |
---|
1822 | submenu.add(this.showSectionsButton); |
---|
1823 | |
---|
1824 | submenu.add(new qx.ui.menu.Separator); |
---|
1825 | |
---|
1826 | var subMenu2 = new qx.ui.menu.Menu; |
---|
1827 | btn = new qx.ui.menu.CheckBox("Electrons"); |
---|
1828 | btn.setValue(this.showElectrons); |
---|
1829 | btn.addListener("execute", showElectronsCB, this); |
---|
1830 | subMenu2.add(btn); |
---|
1831 | btn = new qx.ui.menu.CheckBox("Ions"); |
---|
1832 | btn.setValue(this.showIons); |
---|
1833 | btn.addListener("execute", showIonsCB, this); |
---|
1834 | subMenu2.add(btn); |
---|
1835 | btn = new qx.ui.menu.CheckBox("Radiators"); |
---|
1836 | btn.setValue(this.showRadiators); |
---|
1837 | btn.addListener("execute", showRadiatorsCB, this); |
---|
1838 | subMenu2.add(btn); |
---|
1839 | this.showSpeciesButton = new qx.ui.menu.Button("Show Species", |
---|
1840 | null, null, subMenu2); |
---|
1841 | submenu.add(this.showSpeciesButton); |
---|
1842 | |
---|
1843 | submenu.add(new qx.ui.menu.Separator); |
---|
1844 | q = new qx.ui.core.Command("Ctrl+W"); |
---|
1845 | q.addListener("execute", this.loadWikiCB, this); |
---|
1846 | btn = new qx.ui.menu.Button("Load Wikipedia Article", |
---|
1847 | "pf/image/wikipedia.png", q); |
---|
1848 | submenu.add(btn); |
---|
1849 | this.loadWikiButton = btn; |
---|
1850 | this.doc.add(submenu); |
---|
1851 | this.doc.add(subMenu1); |
---|
1852 | this.doc.add(subMenu2); |
---|
1853 | |
---|
1854 | submenu.add(new qx.ui.menu.Separator); |
---|
1855 | q = new qx.ui.core.Command("Ctrl+L"); |
---|
1856 | q.addListener("execute", this.drawCB, this); |
---|
1857 | btn = new qx.ui.menu.Button("Redraw Plot", |
---|
1858 | "pf/image/tab-plot.png", q); |
---|
1859 | submenu.add(btn); |
---|
1860 | this.redrawButton = btn; |
---|
1861 | |
---|
1862 | |
---|
1863 | btn = new qx.ui.menubar.Button("View", null, submenu); |
---|
1864 | menubar.add(btn); |
---|
1865 | |
---|
1866 | |
---|
1867 | var nvOptions = { |
---|
1868 | width: 800, |
---|
1869 | height: 600, |
---|
1870 | scrollbars : true, |
---|
1871 | resizable : true, |
---|
1872 | menubar : false, |
---|
1873 | status : false |
---|
1874 | }; |
---|
1875 | submenu = new qx.ui.menu.Menu; |
---|
1876 | this.doc.add(submenu); |
---|
1877 | q = new qx.ui.core.Command("F1"); |
---|
1878 | q.addListener("execute", function(ev) { |
---|
1879 | alert("Help system not implemented yet"); |
---|
1880 | }); |
---|
1881 | btn = new qx.ui.menu.Button("Help Contents", |
---|
1882 | "pf/image/help.png", q); |
---|
1883 | submenu.add(btn); |
---|
1884 | btn = new qx.ui.menu.Button("NRL Plasma Formulary", |
---|
1885 | "pf/image/nrl.png"); |
---|
1886 | btn.addListener("execute", function (ev) { |
---|
1887 | var url = "http://wwwppd.nrl.navy.mil/nrlformulary/"; |
---|
1888 | var w = qx.bom.Window.open(url, null, nvOptions); |
---|
1889 | }, this); |
---|
1890 | submenu.add(btn); |
---|
1891 | btn = new qx.ui.menu.Button("Plasma at Wikipedia", |
---|
1892 | "pf/image/wikipedia.png"); |
---|
1893 | btn.addListener("execute", function (ev) { |
---|
1894 | var url = "http://en.wikipedia.org/wiki/Plasma_%28physics%29"; |
---|
1895 | var w = qx.bom.Window.open(url, null, nvOptions); |
---|
1896 | }, this); |
---|
1897 | submenu.add(btn); |
---|
1898 | submenu.add(new qx.ui.menu.Separator); |
---|
1899 | btn = new qx.ui.menu.Button("License Terms", |
---|
1900 | "pf/image/gnu.png"); |
---|
1901 | btn.addListener("execute", function (ev) { |
---|
1902 | var url = "resource/pf/html/GPL.html"; |
---|
1903 | var w = qx.bom.Window.open(url, null, nvOptions); |
---|
1904 | }, this); |
---|
1905 | submenu.add(btn); |
---|
1906 | btn = new qx.ui.menu.Button("About...", |
---|
1907 | "pf/image/about.png"); |
---|
1908 | btn.addListener("execute", this.aboutCB, this); |
---|
1909 | submenu.add(btn); |
---|
1910 | |
---|
1911 | btn = new qx.ui.menubar.Button("Help", null, submenu); |
---|
1912 | menubar.add(btn); |
---|
1913 | }, |
---|
1914 | |
---|
1915 | nextColor : function() |
---|
1916 | { |
---|
1917 | var color = this.colorMap[this.ncolor]; |
---|
1918 | this.ncolor++; |
---|
1919 | if (this.ncolor == this.colorMap.length) { |
---|
1920 | this.ncolor = 0; |
---|
1921 | } |
---|
1922 | |
---|
1923 | return color; |
---|
1924 | }, |
---|
1925 | |
---|
1926 | savePreferences : function() |
---|
1927 | { |
---|
1928 | if (this.prefs) { |
---|
1929 | var prefstr = qx.util.Json.stringify(this.prefs); |
---|
1930 | qx.bom.Cookie.set("pf_prefs", prefstr, 3650); |
---|
1931 | } |
---|
1932 | }, |
---|
1933 | |
---|
1934 | loadPreferences : function() |
---|
1935 | { |
---|
1936 | var prefstr = qx.bom.Cookie.get("pf_prefs"); |
---|
1937 | |
---|
1938 | if (prefstr) { |
---|
1939 | this.prefs = qx.util.Json.parse(prefstr); |
---|
1940 | } |
---|
1941 | |
---|
1942 | if (!this.prefs) { |
---|
1943 | this.prefs = new Object; |
---|
1944 | } |
---|
1945 | |
---|
1946 | if (undefined === this.prefs.rememberWindowSize) { |
---|
1947 | this.prefs.rememberWindowSize = false; |
---|
1948 | } |
---|
1949 | |
---|
1950 | if (undefined === this.prefs.autoLoadWiki) { |
---|
1951 | this.prefs.autoLoadWiki = true; |
---|
1952 | } |
---|
1953 | |
---|
1954 | if (undefined === this.prefs.warnOnExit) { |
---|
1955 | this.prefs.warnOnExit = true; |
---|
1956 | } |
---|
1957 | |
---|
1958 | if (!this.prefs.units) { |
---|
1959 | this.prefs.units = new Object; |
---|
1960 | } |
---|
1961 | |
---|
1962 | if (!this.prefs.currentConfigName) { |
---|
1963 | this.prefs.currentConfigName = "Untitled"; |
---|
1964 | } |
---|
1965 | |
---|
1966 | if (!this.prefs.configPtrs) { |
---|
1967 | this.prefs.configPtrs = new Array; |
---|
1968 | } |
---|
1969 | }, |
---|
1970 | |
---|
1971 | getConfig : function(name) |
---|
1972 | { |
---|
1973 | if (!name) { |
---|
1974 | return null; |
---|
1975 | } |
---|
1976 | |
---|
1977 | var configPtrs = this.prefs.configPtrs; |
---|
1978 | |
---|
1979 | var i, configPtr = null; |
---|
1980 | for (i = 0; i < configPtrs.length; i++) { |
---|
1981 | if (configPtrs[i].name == name) { |
---|
1982 | configPtr = configPtrs[i]; |
---|
1983 | return configPtr; |
---|
1984 | break; |
---|
1985 | } |
---|
1986 | } |
---|
1987 | |
---|
1988 | return null; |
---|
1989 | }, |
---|
1990 | |
---|
1991 | saveConfig : function(name) |
---|
1992 | { |
---|
1993 | if (!name) { |
---|
1994 | return false; |
---|
1995 | } |
---|
1996 | |
---|
1997 | var configPtr = this.getConfig(name); |
---|
1998 | |
---|
1999 | var d = new Date(); |
---|
2000 | var time = d.getTime(); |
---|
2001 | |
---|
2002 | if (!configPtr) { |
---|
2003 | configPtr = new Object; |
---|
2004 | configPtr.name = name; |
---|
2005 | configPtr.hash = time; |
---|
2006 | this.prefs.configPtrs.push(configPtr); |
---|
2007 | } |
---|
2008 | |
---|
2009 | configPtr.time = time; |
---|
2010 | |
---|
2011 | var cookie_name = "pf_config_" + configPtr.hash; |
---|
2012 | |
---|
2013 | var config = new Object; |
---|
2014 | |
---|
2015 | config.N_e = this.plasma.e.getN(); |
---|
2016 | |
---|
2017 | config.T_e = this.plasma.e.getT(); |
---|
2018 | config.T_i = this.plasma.i.getT(); |
---|
2019 | config.T_r = this.plasma.r.getT(); |
---|
2020 | |
---|
2021 | config.M_i = this.plasma.i.getM(); |
---|
2022 | config.M_r = this.plasma.r.getM(); |
---|
2023 | |
---|
2024 | config.Q_i = this.plasma.i.getQ(); |
---|
2025 | config.Q_r = this.plasma.r.getQ(); |
---|
2026 | |
---|
2027 | config.P_r = this.plasma.P_r; |
---|
2028 | |
---|
2029 | config.B = this.plasma.B ; |
---|
2030 | |
---|
2031 | config.n_u = this.plasma.n_u; |
---|
2032 | config.n_l = this.plasma.n_l; |
---|
2033 | |
---|
2034 | var configstr = qx.util.Json.stringify(config); |
---|
2035 | qx.bom.Cookie.set(cookie_name, configstr, 3650); |
---|
2036 | |
---|
2037 | this.prefs.currentConfigName = name; |
---|
2038 | |
---|
2039 | return true; |
---|
2040 | }, |
---|
2041 | |
---|
2042 | loadConfig : function(name) |
---|
2043 | { |
---|
2044 | var configPtr = this.getConfig(name); |
---|
2045 | if (!configPtr) { |
---|
2046 | return false; |
---|
2047 | } |
---|
2048 | |
---|
2049 | var cookie_name = "pf_config_" + configPtr.hash; |
---|
2050 | |
---|
2051 | var configstr = qx.bom.Cookie.get(cookie_name); |
---|
2052 | if (!configstr) { |
---|
2053 | // Cookie was deleted??? |
---|
2054 | qx.lang.Array.remove(this.prefs.configPtrs, configPtr); |
---|
2055 | return false; |
---|
2056 | } |
---|
2057 | |
---|
2058 | var config = qx.util.Json.parse(configstr); |
---|
2059 | |
---|
2060 | if (config) { |
---|
2061 | this.plasma.e.setN(config.N_e); |
---|
2062 | |
---|
2063 | this.plasma.e.setT(config.T_e); |
---|
2064 | this.plasma.i.setT(config.T_i); |
---|
2065 | this.plasma.r.setT(config.T_r); |
---|
2066 | |
---|
2067 | this.plasma.i.setM(config.M_i); |
---|
2068 | this.plasma.r.setM(config.M_r); |
---|
2069 | |
---|
2070 | this.plasma.i.setQ(config.Q_i); |
---|
2071 | this.plasma.r.setQ(config.Q_r); |
---|
2072 | |
---|
2073 | this.plasma.P_r = config.P_r; |
---|
2074 | |
---|
2075 | this.plasma.B = config.B ; |
---|
2076 | |
---|
2077 | this.plasma.n_u = config.n_u; |
---|
2078 | this.plasma.n_l = config.n_l; |
---|
2079 | |
---|
2080 | this.prefs.currentConfigName = name; |
---|
2081 | |
---|
2082 | return true; |
---|
2083 | } else { |
---|
2084 | return false; |
---|
2085 | } |
---|
2086 | }, |
---|
2087 | |
---|
2088 | removeConfig : function(name) |
---|
2089 | { |
---|
2090 | var configPtr = this.getConfig(name); |
---|
2091 | if (configPtr) { |
---|
2092 | qx.lang.Array.remove(this.prefs.configPtrs, configPtr); |
---|
2093 | var cookie_name = "pf_config_" + configPtr.hash; |
---|
2094 | qx.bom.Cookie.del(cookie_name); |
---|
2095 | } |
---|
2096 | }, |
---|
2097 | |
---|
2098 | renameConfig : function(oldname, newname) |
---|
2099 | { |
---|
2100 | var configPtr = this.getConfig(oldname); |
---|
2101 | if (configPtr) { |
---|
2102 | configPtr.name = newname; |
---|
2103 | } |
---|
2104 | }, |
---|
2105 | |
---|
2106 | createSaveLoadDialog : function() |
---|
2107 | { |
---|
2108 | var w, rc1, e, btn; |
---|
2109 | // "Save as..." dialog |
---|
2110 | w = new pf.ui.DialogWindow(); |
---|
2111 | w.setLayout(new qx.ui.layout.VBox(0)); |
---|
2112 | w.setContentPadding(0); |
---|
2113 | |
---|
2114 | this.doc.add(w, {left: 200, top: 100}); |
---|
2115 | this.saveLoadWindow = w; |
---|
2116 | |
---|
2117 | var tb = new qx.ui.toolbar.ToolBar(); |
---|
2118 | var tbpart = new qx.ui.toolbar.Part(); |
---|
2119 | var btn_delete = new qx.ui.toolbar.Button("Delete", |
---|
2120 | "pf/image/delete.png"); |
---|
2121 | var btn_rename = new qx.ui.toolbar.Button("Rename", |
---|
2122 | "pf/image/rename.png"); |
---|
2123 | btn_delete.setEnabled(false); |
---|
2124 | btn_rename.setEnabled(false); |
---|
2125 | tbpart.add(btn_delete); |
---|
2126 | tbpart.add(btn_rename); |
---|
2127 | tb.add(tbpart); |
---|
2128 | w.add(tb); |
---|
2129 | |
---|
2130 | // table model |
---|
2131 | var tm = new qx.ui.table.model.Simple(); |
---|
2132 | tm.setColumns([ "Configuration", "Last Modified" ]); |
---|
2133 | |
---|
2134 | tm.setColumnEditable(0, false); |
---|
2135 | tm.setColumnEditable(1, false); |
---|
2136 | |
---|
2137 | // table list |
---|
2138 | var lv = new qx.ui.table.Table(tm); |
---|
2139 | lv.set({ |
---|
2140 | height: 250 |
---|
2141 | }); |
---|
2142 | |
---|
2143 | lv.setStatusBarVisible(false); |
---|
2144 | lv.setShowCellFocusIndicator(false); |
---|
2145 | lv.setColumnVisibilityButtonVisible(false); |
---|
2146 | |
---|
2147 | lv.setColumnWidth(0, 250); |
---|
2148 | lv.setColumnWidth(1, 150); |
---|
2149 | |
---|
2150 | var renderer = new qx.ui.table.cellrenderer.Html(); |
---|
2151 | lv.getTableColumnModel().setDataCellRenderer(0, renderer); |
---|
2152 | |
---|
2153 | this.saveLoadConfigList = lv; |
---|
2154 | w.add(lv); |
---|
2155 | |
---|
2156 | var sm = lv.getSelectionModel(); |
---|
2157 | sm.setSelectionMode(qx.ui.table.selection.Model.SINGLE_SELECTION); |
---|
2158 | |
---|
2159 | btn_delete.addListener("execute", function(ev) { |
---|
2160 | if (!sm.isSelectionEmpty()) { |
---|
2161 | var index = sm.getLeadSelectionIndex(); |
---|
2162 | var rowData = tm.getRowData(index); |
---|
2163 | var name = rowData[0]; |
---|
2164 | if (confirm("Delete \"" + name + "\"?")) { |
---|
2165 | var index = sm.getLeadSelectionIndex(); |
---|
2166 | var rowData = tm.getRowData(index); |
---|
2167 | this.removeConfig(rowData[0]); |
---|
2168 | this.updateSaveLoadList(); |
---|
2169 | } |
---|
2170 | } |
---|
2171 | }, this); |
---|
2172 | |
---|
2173 | btn_rename.addListener("execute", function(ev) { |
---|
2174 | if (!sm.isSelectionEmpty()) { |
---|
2175 | var index = sm.getLeadSelectionIndex(); |
---|
2176 | var rowData = tm.getRowData(index); |
---|
2177 | var name = rowData[0]; |
---|
2178 | var newname = prompt("Rename \"" + name + "\" to", name); |
---|
2179 | if (newname && newname != name) { |
---|
2180 | this.renameConfig(name, newname); |
---|
2181 | this.updateSaveLoadList(); |
---|
2182 | if (name == this.prefs.currentConfigName) { |
---|
2183 | this.prefs.currentConfigName = newname; |
---|
2184 | this.gui_configName.setLabel(newname); |
---|
2185 | } |
---|
2186 | this.saveLoadTextField.setValue(newname); |
---|
2187 | } |
---|
2188 | } |
---|
2189 | }, this); |
---|
2190 | |
---|
2191 | e = new qx.ui.form.TextField(); |
---|
2192 | e.setMarginTop(1); |
---|
2193 | w.add(e); |
---|
2194 | this.saveLoadTextField = e; |
---|
2195 | |
---|
2196 | sm.addListener("changeSelection", function(ev) { |
---|
2197 | if (sm.isSelectionEmpty()) { |
---|
2198 | e.setValue(null); |
---|
2199 | btn_delete.setEnabled(false); |
---|
2200 | btn_rename.setEnabled(false); |
---|
2201 | } else { |
---|
2202 | var index = sm.getLeadSelectionIndex(); |
---|
2203 | var rowData = tm.getRowData(index); |
---|
2204 | e.setValue(rowData[0]); |
---|
2205 | btn_rename.setEnabled(true); |
---|
2206 | btn_delete.setEnabled(true); |
---|
2207 | } |
---|
2208 | }); |
---|
2209 | |
---|
2210 | var layout = new qx.ui.layout.HBox(10, "right"); |
---|
2211 | rc1 = new qx.ui.container.Composite(layout); |
---|
2212 | rc1.setMargin(10, 10, 10, 10); |
---|
2213 | w.add(rc1); |
---|
2214 | |
---|
2215 | btn = new qx.ui.form.Button("Cancel", |
---|
2216 | "pf/image/cancel.png"); |
---|
2217 | btn.addListener("execute", function(ev) { |
---|
2218 | this.saveLoadWindow.close(); |
---|
2219 | }, this); |
---|
2220 | rc1.add(btn); |
---|
2221 | |
---|
2222 | btn = new qx.ui.form.Button("OK", |
---|
2223 | "pf/image/ok.png"); |
---|
2224 | btn.setEnabled(false); |
---|
2225 | btn.addListener("execute", function(ev) { |
---|
2226 | var cfgname = this.saveLoadTextField.getValue(); |
---|
2227 | if (!cfgname) { |
---|
2228 | alert("Please enter a name!"); |
---|
2229 | } else { |
---|
2230 | var type = w.getUserData("type"); |
---|
2231 | if (type == "save") { |
---|
2232 | if (this.saveConfig(cfgname) == true) { |
---|
2233 | this.saveLoadWindow.close(); |
---|
2234 | if (this.prefs.currentConfigName) { |
---|
2235 | this.gui_configName.setLabel(this.prefs.currentConfigName); |
---|
2236 | } |
---|
2237 | } else { |
---|
2238 | alert("Save failed!"); |
---|
2239 | } |
---|
2240 | } else { |
---|
2241 | if (this.loadConfig(cfgname) == true) { |
---|
2242 | this.updatePlasmaParameters(); |
---|
2243 | this.updateGUI(); |
---|
2244 | this.saveLoadWindow.close(); |
---|
2245 | } else { |
---|
2246 | alert("Load failed!"); |
---|
2247 | } |
---|
2248 | } |
---|
2249 | } |
---|
2250 | }, this); |
---|
2251 | rc1.add(btn); |
---|
2252 | |
---|
2253 | e.setLiveUpdate(true); |
---|
2254 | e.addListener("changeValue", function(ev) { |
---|
2255 | var name = this.getValue(); |
---|
2256 | btn.setEnabled(null != name && name.length != 0); |
---|
2257 | }); |
---|
2258 | }, |
---|
2259 | |
---|
2260 | createPrefsDialog : function() |
---|
2261 | { |
---|
2262 | // "Preferences..." dialog |
---|
2263 | var w = new pf.ui.DialogWindow("Preferences", |
---|
2264 | "pf/image/preferences.png"); |
---|
2265 | w.setLayout(new qx.ui.layout.VBox(10)); |
---|
2266 | |
---|
2267 | this.doc.add(w, {left: 200, top: 100}); |
---|
2268 | this.prefsWindow = w; |
---|
2269 | |
---|
2270 | var fr, l, e; |
---|
2271 | |
---|
2272 | fr = new qx.ui.groupbox.GroupBox("Default units"); |
---|
2273 | fr.setLayout(new qx.ui.layout.HBox(10)); |
---|
2274 | w.add(fr); |
---|
2275 | |
---|
2276 | l = new qx.ui.basic.Label("Dimension:"); |
---|
2277 | e = new pf.ui.SelectBox; |
---|
2278 | e.addItem("Length", "length"); |
---|
2279 | e.addItem("Frequency", "frequency"); |
---|
2280 | e.addItem("Velocity", "velocity"); |
---|
2281 | e.addItem("Energy", "energy"); |
---|
2282 | e.addItem("Pressure", "pressure"); |
---|
2283 | e.addItem("Area", "area"); |
---|
2284 | e.addItem("Power density", "power_density"); |
---|
2285 | e.addItem("Power spectral density", "spectral_power_density"); |
---|
2286 | e.addItem("Electric field", "efield"); |
---|
2287 | e.addListener("changeSelection", function(ev) { |
---|
2288 | var dimension = ev.getTarget().getSelectedValue(); |
---|
2289 | this.gui_prefs_units.update(dimension, |
---|
2290 | this.prefs.units[dimension]); |
---|
2291 | }, this); |
---|
2292 | fr.add(l); |
---|
2293 | fr.add(e); |
---|
2294 | this.gui_prefs_dim = e; |
---|
2295 | |
---|
2296 | l = new qx.ui.basic.Label("Units:"); |
---|
2297 | e = new pf.UnitSelector(); |
---|
2298 | e.addListener("changeSelection", function(ev) { |
---|
2299 | var dimension = this.gui_prefs_dim.getSelectedValue(); |
---|
2300 | var units = ev.getTarget().getSelectedValue(); |
---|
2301 | this.prefs.units[dimension] = units; |
---|
2302 | }, this); |
---|
2303 | fr.add(l); |
---|
2304 | fr.add(e); |
---|
2305 | e.update("length"); |
---|
2306 | this.gui_prefs_units = e; |
---|
2307 | |
---|
2308 | fr = new qx.ui.groupbox.GroupBox("Interface"); |
---|
2309 | fr.setLayout(new qx.ui.layout.VBox(10)); |
---|
2310 | w.add(fr); |
---|
2311 | |
---|
2312 | e = new qx.ui.form.CheckBox("Load Wikipedia articles automatically"); |
---|
2313 | e.setValue(this.prefs.autoLoadWiki); |
---|
2314 | e.addListener("changeValue", function(ev) { |
---|
2315 | this.prefs.autoLoadWiki = ev.getTarget().getValue(); |
---|
2316 | }, this); |
---|
2317 | fr.add(e); |
---|
2318 | |
---|
2319 | e = new qx.ui.form.CheckBox("Remember window dimensions on exit"); |
---|
2320 | e.setValue(this.prefs.rememberWindowSize); |
---|
2321 | e.addListener("changeValue", function(ev) { |
---|
2322 | this.prefs.rememberWindowSize = ev.getTarget().getValue(); |
---|
2323 | }, this); |
---|
2324 | fr.add(e); |
---|
2325 | |
---|
2326 | e = new qx.ui.form.CheckBox("Warn on exit or restart"); |
---|
2327 | e.setValue(this.prefs.warnOnExit); |
---|
2328 | e.addListener("changeValue", function(ev) { |
---|
2329 | this.prefs.warnOnExit = ev.getTarget().getValue(); |
---|
2330 | }, this); |
---|
2331 | fr.add(e); |
---|
2332 | |
---|
2333 | fr = new qx.ui.groupbox.GroupBox("Theme"); |
---|
2334 | fr.setLayout(new qx.ui.layout.VBox(10)); |
---|
2335 | w.add(fr); |
---|
2336 | |
---|
2337 | var btn1 = new qx.ui.form.RadioButton("Modern"); |
---|
2338 | btn1.setModel("modern"); |
---|
2339 | var btn2 = new qx.ui.form.RadioButton("Classic"); |
---|
2340 | btn2.setModel("classic"); |
---|
2341 | |
---|
2342 | fr.add(btn1); |
---|
2343 | fr.add(btn2); |
---|
2344 | |
---|
2345 | var rm = new qx.ui.form.RadioGroup(btn1, btn2); |
---|
2346 | var sels; |
---|
2347 | if (this.prefs.themeName == "classic") { |
---|
2348 | sels = new Array(btn2); |
---|
2349 | } else { |
---|
2350 | sels = new Array(btn1); |
---|
2351 | } |
---|
2352 | rm.setSelection(sels); |
---|
2353 | rm.addListener("changeSelection", function(ev) { |
---|
2354 | var btn = ev.getData()[0]; |
---|
2355 | this.prefs.themeName = btn.getModel(); |
---|
2356 | |
---|
2357 | // this.applyTheme(); |
---|
2358 | alert("New theme will be applied after restart of the application"); |
---|
2359 | }, this); |
---|
2360 | |
---|
2361 | }, |
---|
2362 | |
---|
2363 | applyTheme : function() |
---|
2364 | { |
---|
2365 | var theme; |
---|
2366 | if (this.prefs.themeName == "classic") { |
---|
2367 | theme = pf.theme.Classic; |
---|
2368 | } else { |
---|
2369 | theme = pf.theme.Modern; |
---|
2370 | } |
---|
2371 | var thm = qx.theme.manager.Meta.getInstance(); |
---|
2372 | thm.setTheme(theme); |
---|
2373 | }, |
---|
2374 | |
---|
2375 | /** |
---|
2376 | * TODOC |
---|
2377 | * |
---|
2378 | * @type member |
---|
2379 | * @param e {Event} TODOC |
---|
2380 | * @return {void} |
---|
2381 | */ |
---|
2382 | main : function(e) |
---|
2383 | { |
---|
2384 | this.base(arguments); |
---|
2385 | |
---|
2386 | // Enable logging in debug variant |
---|
2387 | if (qx.core.Variant.isSet("qx.debug", "on")) |
---|
2388 | { |
---|
2389 | // support native logging capabilities, e.g. Firebug |
---|
2390 | qx.log.appender.Native; |
---|
2391 | // support additional cross-browser console. (Press F7) |
---|
2392 | qx.log.appender.Console; |
---|
2393 | } |
---|
2394 | |
---|
2395 | this.doc = this.getRoot(); |
---|
2396 | // this.win = this.doc.getWindow(); |
---|
2397 | |
---|
2398 | // Load prefs |
---|
2399 | this.loadPreferences(); |
---|
2400 | |
---|
2401 | // Apply theme |
---|
2402 | this.applyTheme(); |
---|
2403 | |
---|
2404 | if (this.prefs.rememberWindowSize && this.prefs.dims) { |
---|
2405 | self.resizeTo(this.prefs.dims.width, this.prefs.dims.height); |
---|
2406 | } |
---|
2407 | |
---|
2408 | this.plasma = new pf.Plasma(); |
---|
2409 | |
---|
2410 | // Load config from the previous session |
---|
2411 | if (this.prefs.currentConfigName) { |
---|
2412 | this.loadConfig(this.prefs.currentConfigName); |
---|
2413 | } |
---|
2414 | |
---|
2415 | if (this.updatePlasmaParameters() != true) { |
---|
2416 | this.error("Error updating plasma parameters!"); |
---|
2417 | } |
---|
2418 | |
---|
2419 | // Favorites |
---|
2420 | this.favorites = new Array; |
---|
2421 | |
---|
2422 | this.colorMap = new Array("red", "blue", "green", "orange", |
---|
2423 | "brown", "olive", "teal", "magenta", "gray", "black"); |
---|
2424 | this.ncolor = 0; |
---|
2425 | |
---|
2426 | // Top-level container |
---|
2427 | var layout = new qx.ui.layout.VBox; |
---|
2428 | this.bl_top = new qx.ui.container.Composite(layout); |
---|
2429 | |
---|
2430 | this.doc.add(this.bl_top, {width :'100%', height: "100%"}); |
---|
2431 | |
---|
2432 | // The menubar |
---|
2433 | this.menubar = new qx.ui.menubar.MenuBar; |
---|
2434 | this.bl_top.add(this.menubar); |
---|
2435 | |
---|
2436 | // The menu items |
---|
2437 | this.buildMenu(); |
---|
2438 | |
---|
2439 | this.tabview = new qx.ui.tabview.TabView; |
---|
2440 | this.tabview.setContentPadding(6); |
---|
2441 | |
---|
2442 | this.bl_top.add(this.tabview, {flex: 1}); |
---|
2443 | // The "Parameters" tab |
---|
2444 | this.renderParametersTab(); |
---|
2445 | |
---|
2446 | // The "Explorer" tab |
---|
2447 | this.renderExplorerTab(); |
---|
2448 | |
---|
2449 | // The "Compare" tab |
---|
2450 | this.renderCompareTab(); |
---|
2451 | |
---|
2452 | // The "Plot" tab |
---|
2453 | this.renderPlotTab(); |
---|
2454 | |
---|
2455 | // "Preferences" dialog |
---|
2456 | this.createPrefsDialog(); |
---|
2457 | |
---|
2458 | // "Save as" dialog |
---|
2459 | this.createSaveLoadDialog(); |
---|
2460 | |
---|
2461 | // "About..." dialog |
---|
2462 | var w = new pf.ui.DialogWindow("About Plasma Formulary", |
---|
2463 | "pf/image/about.png"); |
---|
2464 | w.setLayout(new qx.ui.layout.VBox(10)); |
---|
2465 | |
---|
2466 | var str = 'Plasma Formulary Interactive.<br/>' + |
---|
2467 | '$Revision$.' + |
---|
2468 | '<p>Written by Evgeny Stambulchik.</p>' + |
---|
2469 | 'GUI built with the Qooxdoo toolkit.<br/>' + |
---|
2470 | 'Using Walter Zorn jsGraphics for drawing.'; |
---|
2471 | |
---|
2472 | var a = new qx.ui.basic.Atom(str); |
---|
2473 | a.setRich(true); |
---|
2474 | w.add(a); |
---|
2475 | |
---|
2476 | this.doc.add(w, {left: 200, top: 100}); |
---|
2477 | this.aboutWindow = w; |
---|
2478 | |
---|
2479 | // Handle resize events |
---|
2480 | this.doc.addListener("resize", function(e) { |
---|
2481 | if (this.prefs.rememberWindowSize) { |
---|
2482 | this.prefs.dims = this.doc.getInnerSize(); |
---|
2483 | } |
---|
2484 | this.drawAll(); |
---|
2485 | }, this); |
---|
2486 | }, |
---|
2487 | |
---|
2488 | |
---|
2489 | /** |
---|
2490 | * TODOC |
---|
2491 | * |
---|
2492 | * @type member |
---|
2493 | * @param e {Event} TODOC |
---|
2494 | * @return {void} |
---|
2495 | */ |
---|
2496 | close : function(e) |
---|
2497 | { |
---|
2498 | // Save preferences |
---|
2499 | this.savePreferences(); |
---|
2500 | |
---|
2501 | this.base(arguments); |
---|
2502 | |
---|
2503 | // Prompt user |
---|
2504 | if (this.prefs.warnOnExit && !this.intendedExit) { |
---|
2505 | return "This will end your Plasma Formulary session."; |
---|
2506 | } |
---|
2507 | } |
---|
2508 | } |
---|
2509 | }); |
---|