Changeset 1:5213e9e10846
- Timestamp:
- Jun 25, 2007, 4:29:44 PM (17 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/class/pf/Application.js
r0 r1 14 14 15 15 ************************************************************************ */ 16 17 function NumPrint(v) 18 { 19 var s; 20 if (v == 0.0) { 21 s = "0"; 22 } else 23 if (Math.abs(v) < 1.e6) { 24 s = sprintf("%.3f", v); 25 } else { 26 s = sprintf("%.3e", v); 27 } 28 29 return s; 30 } 31 32 function changeN_e(e) 33 { 34 var N_e = this.gui_N_e.getNumValue(); 35 36 if (isFinite(N_e)) { 37 this.N_e = N_e; 38 this.updatePlasmaParameters(); 39 this.gui_N_i.setNumValue(this.N_i); 40 this.gui_N_r.setNumValue(this.N_r); 41 } 42 } 43 44 function changeZ_i(e) 45 { 46 var Z_i = parseInt(this.gui_Z_i.getValue()); 47 48 if (isFinite(Z_i)) { 49 this.Z_i = Z_i; 50 this.updatePlasmaParameters(); 51 this.gui_N_i.setNumValue(this.N_i); 52 this.gui_N_r.setNumValue(this.N_r); 53 } 54 } 55 56 function changeZ_r(e) 57 { 58 var Z_r = parseInt(this.gui_Z_r.getValue()); 59 60 if (isFinite(Z_r)) { 61 this.Z_r = Z_r; 62 this.updatePlasmaParameters(); 63 this.gui_N_i.setNumValue(this.N_i); 64 this.gui_N_r.setNumValue(this.N_r); 65 } 66 } 67 68 function changeP_r(e) 69 { 70 var P_r = parseInt(this.gui_P_r.getValue())/100.0; 71 72 if (isFinite(P_r)) { 73 this.P_r = P_r; 74 this.updatePlasmaParameters(); 75 this.gui_N_i.setNumValue(this.N_i); 76 this.gui_N_r.setNumValue(this.N_r); 77 } 78 } 79 80 function changeB(e) 81 { 82 var v = this.gui_B.getNumValue(); 83 84 if (isFinite(v)) { 85 this.B = v; 86 } 87 } 16 88 17 89 /** … … 20 92 qx.Class.define("pf.Application", 21 93 { 22 extend : qx.application.Gui, 23 24 25 26 27 /* 28 ***************************************************************************** 29 MEMBERS 30 ***************************************************************************** 31 */ 32 33 members : 34 { 35 /** 36 * TODOC 37 * 38 * @type member 39 * @param e {Event} TODOC 40 * @return {void} 41 */ 42 main : function(e) 94 extend : qx.application.Gui, 95 96 /* 97 ***************************************************************************** 98 MEMBERS 99 ***************************************************************************** 100 */ 101 102 members : 43 103 { 44 this.base(arguments); 45 46 // Define alias for custom resource path 47 qx.io.Alias.getInstance().add("pf", qx.core.Setting.get("pf.resourceUri")); 48 49 // Create button 50 var button1 = new qx.ui.form.Button("First Button", "pf/image/test.png"); 51 52 // Set button location 53 button1.setTop(50); 54 button1.setLeft(50); 55 56 // Add button to document 57 button1.addToDocument(); 58 59 // Attach a tooltip 60 button1.setToolTip(new qx.ui.popup.ToolTip("A nice tooltip", "icon/32/status/dialog-information.png")); 61 62 // Add an event listener 63 button1.addEventListener("execute", function(e) { 64 alert("Hello World!"); 65 }); 104 105 checkPlasmaParameters : function() 106 { 107 if (this.N_e <= 0.0 || 108 (this.P_r < 0.0 || this.P_r > 1.0) || 109 this.Z_i < 1 || 110 this.P_r == 1.0 && this.Z_r == 0) { 111 return false; 112 } else { 113 return true; 114 } 115 }, 116 117 updatePlasmaParameters : function() 118 { 119 // Safety measures 120 if (this.checkPlasmaParameters() != true) { 121 return false; 122 } 123 124 if (this.P_r < 1.0) { 125 this.N_i = this.N_e*(1.0 - this.P_r)/ 126 (this.Z_i*(1.0 - this.P_r) + this.Z_r*this.P_r); 127 128 this.N_r = this.N_i*this.P_r/(1.0 - this.P_r); 129 } else { 130 this.N_i = 0.0; 131 this.N_r = this.N_e/this.Z_r; 132 } 133 134 return true; 135 }, 136 137 /** 138 * TODOC 139 * 140 * @type member 141 * @param e {Event} TODOC 142 * @return {void} 143 */ 144 main : function(e) 145 { 146 this.base(arguments); 147 148 // Define alias for custom resource path 149 qx.io.Alias.getInstance().add("pf", 150 qx.core.Setting.get("pf.resourceUri")); 151 152 // Defaults 153 this.N_e = 1e16; 154 this.Z_i = 1; 155 this.Z_r = 0; 156 this.P_r = 0; 157 158 this.T_e = 1; 159 this.T_i = 1; 160 this.T_r = 1; 161 162 this.M_i = 1; 163 this.M_r = 1; 164 165 this.B = 0; 166 167 if (this.updatePlasmaParameters() != true) { 168 alert("Error!"); 169 } 170 171 172 var fr, gl; 173 var l, e; 174 175 fr = new qx.ui.groupbox.GroupBox("Electrons"); 176 fr.setDimension("auto", "auto"); 177 fr.setBackgroundColor("#ffeeee"); 178 179 fr.addToDocument(); 180 181 gl = new qx.ui.layout.GridLayout; 182 gl.setVerticalSpacing(4); 183 gl.setHorizontalSpacing(6); 184 gl.setColumnCount(2); 185 gl.setColumnWidth(0, 100); 186 gl.setColumnWidth(1, 200); 187 gl.setRowCount(2); 188 gl.setRowHeight(0, 30); 189 gl.setRowHeight(1, 30); 190 191 fr.add(gl); 192 193 // N_e 194 l = new qx.ui.basic.Label("N<sub>e</sub> (cm<sup>-3</sup>):"); 195 gl.add(l, 0, 0); 196 e = new pf.ui.TextField(this.N_e); 197 gl.add(e, 1, 0); 198 e.setLiveUpdate(true); 199 e.addEventListener("changeValue", changeN_e, this); 200 this.gui_N_e = e; 201 202 // T_e 203 l = new qx.ui.basic.Label("T<sub>e</sub> (eV):"); 204 gl.add(l, 0, 1); 205 e = new pf.ui.TextField(this.T_e); 206 gl.add(e, 1, 1); 207 208 209 fr = new qx.ui.groupbox.GroupBox("Ions"); 210 fr.setDimension("auto", "auto"); 211 fr.setBackgroundColor("#eeeeff"); 212 213 fr.addToDocument(); 214 fr.setTop(100); 215 216 gl = new qx.ui.layout.GridLayout; 217 gl.setVerticalSpacing(4); 218 gl.setHorizontalSpacing(6); 219 gl.setColumnCount(2); 220 gl.setColumnWidth(0, 100); 221 gl.setColumnWidth(1, 200); 222 gl.setRowCount(4); 223 gl.setRowHeight(0, 30); 224 gl.setRowHeight(1, 30); 225 gl.setRowHeight(2, 30); 226 gl.setRowHeight(3, 30); 227 228 fr.add(gl); 229 230 // Z_i 231 l = new qx.ui.basic.Label("Z<sub>i</sub>:"); 232 gl.add(l, 0, 0); 233 e = new qx.ui.form.Spinner(1, this.Z_i, 100); 234 gl.add(e, 1, 0); 235 236 e.addEventListener("change", changeZ_i, this); 237 238 this.gui_Z_i = e; 239 240 // M_i 241 l = new qx.ui.basic.Label("M<sub>i</sub>:"); 242 gl.add(l, 0, 1); 243 e = new qx.ui.form.Spinner(1, this.M_i, 200); 244 gl.add(e, 1, 1); 245 this.gui_M_i = e; 246 247 // T_i 248 l = new qx.ui.basic.Label("T<sub>i</sub> (eV):"); 249 gl.add(l, 0, 2); 250 e = new pf.ui.TextField(this.T_i); 251 gl.add(e, 1, 2); 252 253 // N_i 254 l = new qx.ui.basic.Label("N<sub>i</sub> (cm<sup>-3</sup>):"); 255 gl.add(l, 0, 3); 256 e = new pf.ui.TextField(this.N_i); 257 gl.add(e, 1, 3); 258 e.setReadOnly(true); 259 this.gui_N_i = e; 260 261 262 fr = new qx.ui.groupbox.GroupBox("Radiators"); 263 fr.setDimension("auto", "auto"); 264 fr.setBackgroundColor("#eeffee"); 265 266 fr.addToDocument(); 267 fr.setLeft(330); 268 269 gl = new qx.ui.layout.GridLayout; 270 gl.setVerticalSpacing(4); 271 gl.setHorizontalSpacing(6); 272 gl.setColumnCount(2); 273 gl.setColumnWidth(0, 100); 274 gl.setColumnWidth(1, 200); 275 gl.setRowCount(5); 276 gl.setRowHeight(0, 30); 277 gl.setRowHeight(1, 30); 278 gl.setRowHeight(2, 30); 279 gl.setRowHeight(3, 30); 280 gl.setRowHeight(4, 30); 281 282 fr.add(gl); 283 284 285 // Z_r 286 l = new qx.ui.basic.Label("Z<sub>r</sub>:"); 287 gl.add(l, 0, 0); 288 e = new qx.ui.form.Spinner(0, this.Z_r, 100); 289 gl.add(e, 1, 0); 290 e.addEventListener("change", changeZ_r, this); 291 this.gui_Z_r = e; 292 293 // M_r 294 l = new qx.ui.basic.Label("M<sub>r</sub>:"); 295 gl.add(l, 0, 1); 296 e = new qx.ui.form.Spinner(1, this.M_r, 200); 297 gl.add(e, 1, 1); 298 this.gui_M_r = e; 299 300 // T_r 301 l = new qx.ui.basic.Label("T<sub>r</sub> (eV):"); 302 gl.add(l, 0, 2); 303 e = new pf.ui.TextField(this.T_r); 304 gl.add(e, 1, 2); 305 306 // P_r 307 l = new qx.ui.basic.Label("P<sub>r</sub> (%):"); 308 gl.add(l, 0, 3); 309 e = new qx.ui.form.Spinner(0, this.P_r, 100); 310 gl.add(e, 1, 3); 311 e.addEventListener("change", changeP_r, this); 312 this.gui_P_r = e; 313 314 // N_r 315 l = new qx.ui.basic.Label("N<sub>r</sub> (cm<sup>-3</sup>):"); 316 gl.add(l, 0, 4); 317 e = new pf.ui.TextField(this.N_r); 318 e.setReadOnly(true); 319 gl.add(e, 1, 4); 320 this.gui_N_r = e; 321 322 323 fr = new qx.ui.groupbox.GroupBox("Fields"); 324 fr.setDimension("auto", "auto"); 325 fr.setBackgroundColor("#ffffdd"); 326 327 fr.addToDocument(); 328 329 gl = new qx.ui.layout.GridLayout; 330 gl.setVerticalSpacing(4); 331 gl.setHorizontalSpacing(6); 332 gl.setColumnCount(2); 333 gl.setColumnWidth(0, 100); 334 gl.setColumnWidth(1, 200); 335 gl.setRowCount(1); 336 gl.setRowHeight(0, 30); 337 338 fr.add(gl); 339 340 fr.setLeft(330); 341 fr.setTop(202); 342 343 l = new qx.ui.basic.Label("B (T):"); 344 gl.add(l, 0, 0); 345 e = new pf.ui.TextField(this.B); 346 gl.add(e, 1, 0); 347 e.setLiveUpdate(true); 348 e.addEventListener("changeValue", changeB, this); 349 this.gui_B = e; 350 351 }, 352 353 354 /** 355 * TODOC 356 * 357 * @type member 358 * @param e {Event} TODOC 359 * @return {void} 360 */ 361 close : function(e) 362 { 363 this.base(arguments); 364 365 // Prompt user 366 // return "qooxdoo application: Do you really want to close the application?"; 367 }, 368 369 370 /** 371 * TODOC 372 * 373 * @type member 374 * @param e {Event} TODOC 375 * @return {void} 376 */ 377 terminate : function(e) { 378 this.base(arguments); 379 } 66 380 }, 67 381 68 69 /** 70 * TODOC 71 * 72 * @type member 73 * @param e {Event} TODOC 74 * @return {void} 75 */ 76 close : function(e) 77 { 78 this.base(arguments); 79 80 // Prompt user 81 // return "qooxdoo application: Do you really want to close the application?"; 82 }, 83 84 85 /** 86 * TODOC 87 * 88 * @type member 89 * @param e {Event} TODOC 90 * @return {void} 91 */ 92 terminate : function(e) { 93 this.base(arguments); 94 } 95 }, 96 97 98 99 100 /* 101 ***************************************************************************** 102 SETTINGS 103 ***************************************************************************** 104 */ 105 106 settings : { 107 "pf.resourceUri" : "./resource" 108 } 382 /* 383 ***************************************************************************** 384 SETTINGS 385 ***************************************************************************** 386 */ 387 388 settings : { 389 "pf.resourceUri" : "./resource" 390 } 109 391 }); -
source/index.html
r0 r1 2 2 <head> 3 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <title> Custom Application</title>4 <title>Plasma Formularly Interactive</title> 5 5 <script type="text/javascript" src="script/pf.js"></script> 6 <script type="text/javascript" src="sprintf.js"></script> 7 <script type="text/javascript"> 8 qx.log.Logger.ROOT_LOGGER.setMinLevel(qx.log.Logger.LEVEL_WARN); 9 </script> 6 10 </head> 7 11 </html>
Note: See TracChangeset
for help on using the changeset viewer.