Skip to content

Commit 2aeb022

Browse files
Merge pull request #97 from vpython/Update_from_GlowScript3.0
Updating from GlowScript 3.0
2 parents eb3bb39 + 993dc60 commit 2aeb022

File tree

5 files changed

+23
-69
lines changed

5 files changed

+23
-69
lines changed

labextension/vpython/src/glowcommlab.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,7 @@ function send() { // periodically send events and update_canvas and request obje
195195
// Should eventually have glowcomm.html, glowcom.js, and glowcommlab.js all import this common component.
196196

197197
window.__GSlang = "vpython"
198-
box = vp_box
199-
sphere = vp_sphere
200-
simple_sphere = vp_simple_sphere
201-
cylinder = vp_cylinder
202-
pyramid = vp_pyramid
203-
cone = vp_cone
204-
helix = vp_helix
205-
//ellipsoid = vp_ellipsoid // This line causes a big problem in jupyterlab vpython extension
206-
ring = vp_ring
207-
arrow = vp_arrow
208-
compound = vp_compound
198+
209199
function msclock() {
210200
"use strict";
211201
if (performance.now) return performance.now()

vpython/vpython_libraries/glow.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vpython/vpython_libraries/glowcomm.html

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
}
7676
var t2 = msclock()
7777
var dt = Math.floor(t1+interval-t2) // attempt to keep the time between renders constant
78-
if (dt < 15) dt = 0 // because setTimeout is inaccurate for small dt's
78+
if (dt < 15) dt = 0 // becaause setTimeout is inaccurate for small dt's
7979
timer = setTimeout(send, dt)
8080
}
8181

@@ -117,17 +117,6 @@
117117
// Should eventually have glowcomm.html, glowcom.js, and glowcommlab.js all import this common component.
118118

119119
window.__GSlang = "vpython"
120-
box = vp_box
121-
sphere = vp_sphere
122-
simple_sphere = vp_simple_sphere
123-
cylinder = vp_cylinder
124-
pyramid = vp_pyramid
125-
cone = vp_cone
126-
helix = vp_helix
127-
ellipsoid = vp_ellipsoid
128-
ring = vp_ring
129-
arrow = vp_arrow
130-
compound = vp_compound
131120

132121
function msclock() {
133122
"use strict";
@@ -256,13 +245,11 @@
256245
events.push(evt)
257246
}
258247

259-
function send_compound(cvs, pos, size, up) { // compound, extrusion, 3D text
248+
function send_compound(cvs, pos, size, up) {
260249
"use strict";
261250
var evt = {event: '_compound', 'canvas': cvs, 'pos': [pos.x, pos.y, pos.z],
262251
'size': [size.x, size.y, size.z], 'up': [up.x, up.y, up.z]}
263252
events.push(evt)
264-
clearTimeout(timer) // Don't wait for next transmission to Python
265-
send()
266253
}
267254

268255
var waitfor_canvas = null
@@ -408,7 +395,7 @@
408395
'p':'left', 'q':'right', 'r':'top', 's':'bottom', 't':'_cloneid',
409396
'u':'logx', 'v':'logy', 'w':'dot', 'x':'dot_radius',
410397
'y':'markers', 'z':'legend', 'A':'label','B':'delta', 'C':'marker_color',
411-
'D':'size_units', 'E':'userpan', 'F':'scroll', 'G':'choices'}
398+
'D':'size_units', 'E':'userpan', 'F':'scroll'}
412399

413400
// methods are X in {'m': '23X....'}
414401
var methods = {'a':'select', 'b':'pos', 'c':'start', 'd':'stop', 'f':'clear', // unused eghijklmnopvxyzCDFAB
@@ -423,7 +410,7 @@
423410
'marker_color']
424411

425412
var textattrs = ['text', 'align', 'caption', 'title', 'title_align', 'xtitle', 'ytitle', 'selected', 'capture',
426-
'label', 'append_to_caption', 'append_to_title', 'bind', 'unbind', 'pause', 'GSprint', 'choices']
413+
'label', 'append_to_caption', 'append_to_title', 'bind', 'unbind', 'pause', 'GSprint']
427414

428415
// patt gets idx and attr code; vpatt gets x,y,z of a vector
429416
var patt = /(\d+)(.)(.*)/
@@ -467,12 +454,8 @@
467454
vs = [Number(val[1]), Number(val[2]), Number(val[3]), Number(val[4])]
468455
}
469456
} else if (textattrs.indexOf(attr) > -1) {
470-
if (attr == 'choices') { // menu choices to be wrapped in a list
471-
val = m[3].split(' ')
472-
} else {
473-
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
474-
val = m[3].replace(/<br>/g, "\n")
475-
}
457+
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
458+
val = m[3].replace(/<br>/g, "\n")
476459
} else if (attr == 'rotate') { // angle,x,y,z,x,y,z
477460
var temp = m[3]
478461
val = []
@@ -960,4 +943,4 @@
960943

961944
</script>
962945
</div>
963-
</body>
946+
</body>

vpython/vpython_libraries/glowcomm.js

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,16 @@ function checkloading() {
118118
function domessage(msg) {
119119
"use strict";
120120
if (timer !== null) clearTimeout(timer)
121-
var t1 = msclock()
121+
var t1 = msclock()
122122
var data = msg.content.data
123123
if (data != 'trigger') {
124124
var msg = decode(data)
125125
handler(msg)
126-
}
127-
if (timer !== null) { // if not a wait situation as with compound/extrusion/text
128-
var t2 = msclock()
129-
var dt = Math.floor(t1+interval-t2) // attempt to keep the time between renders constant
130-
if (dt < 15) dt = 0 // becaause setTimeout is inaccurate for small dt's
131-
timer = setTimeout(send, dt)
132-
}
126+
}
127+
var t2 = msclock()
128+
var dt = Math.floor(t1+interval-t2) // attempt to keep the time between renders constant
129+
if (dt < 15) dt = 0 // becaause setTimeout is inaccurate for small dt's
130+
timer = setTimeout(send, dt)
133131
}
134132

135133
// vpython.py calls onmessage, which responds through domessage, using send
@@ -150,7 +148,7 @@ function onmessage(msg) {
150148
if (timer !== undefined && timer !== null) clearTimeout(timer)
151149

152150
function send() { // periodically send events and update_canvas and request object update
153-
"use strict";
151+
"use strict";
154152
var update = update_canvas()
155153
if (update !== null) events = events.concat(update)
156154
if (events.length === 0) events = [{event:'update_canvas', 'trigger':1}]
@@ -169,17 +167,6 @@ function send() { // periodically send events and update_canvas and request obje
169167
// Should eventually have glowcomm.html, glowcom.js, and glowcommlab.js all import this common component.
170168

171169
window.__GSlang = "vpython"
172-
box = vp_box
173-
sphere = vp_sphere
174-
simple_sphere = vp_simple_sphere
175-
cylinder = vp_cylinder
176-
pyramid = vp_pyramid
177-
cone = vp_cone
178-
helix = vp_helix
179-
ellipsoid = vp_ellipsoid
180-
ring = vp_ring
181-
arrow = vp_arrow
182-
compound = vp_compound
183170

184171
function msclock() {
185172
"use strict";
@@ -308,13 +295,11 @@ function send_pick(cvs, p, seg) {
308295
events.push(evt)
309296
}
310297

311-
function send_compound(cvs, pos, size, up) { // compound, extrusion, 3D text
312-
"use strict";
298+
function send_compound(cvs, pos, size, up) {
299+
"use strict";
313300
var evt = {event: '_compound', 'canvas': cvs, 'pos': [pos.x, pos.y, pos.z],
314301
'size': [size.x, size.y, size.z], 'up': [up.x, up.y, up.z]}
315302
events.push(evt)
316-
clearTimeout(timer) // Don't wait for next transmission to Python
317-
send()
318303
}
319304

320305
var waitfor_canvas = null
@@ -460,7 +445,7 @@ var attrsb = {'a':'userzoom', 'b':'userspin', 'c':'range', 'd':'autoscale', 'e':
460445
'p':'left', 'q':'right', 'r':'top', 's':'bottom', 't':'_cloneid',
461446
'u':'logx', 'v':'logy', 'w':'dot', 'x':'dot_radius',
462447
'y':'markers', 'z':'legend', 'A':'label','B':'delta', 'C':'marker_color',
463-
'D':'size_units', 'E':'userpan', 'F':'scroll', 'G':'choices'}
448+
'D':'size_units', 'E':'userpan', 'F':'scroll'}
464449

465450
// methods are X in {'m': '23X....'}
466451
var methods = {'a':'select', 'b':'pos', 'c':'start', 'd':'stop', 'f':'clear', // unused eghijklmnopvxyzCDFAB
@@ -475,7 +460,7 @@ var vecattrs = ['pos', 'up', 'color', 'trail_color', 'axis', 'size', 'origin', '
475460
'marker_color']
476461

477462
var textattrs = ['text', 'align', 'caption', 'title', 'title_align', 'xtitle', 'ytitle', 'selected', 'capture',
478-
'label', 'append_to_caption', 'append_to_title', 'bind', 'unbind', 'pause', 'GSprint', 'choices']
463+
'label', 'append_to_caption', 'append_to_title', 'bind', 'unbind', 'pause', 'GSprint']
479464

480465
// patt gets idx and attr code; vpatt gets x,y,z of a vector
481466
var patt = /(\d+)(.)(.*)/
@@ -519,12 +504,8 @@ function decode(data) {
519504
vs = [Number(val[1]), Number(val[2]), Number(val[3]), Number(val[4])]
520505
}
521506
} else if (textattrs.indexOf(attr) > -1) {
522-
if (attr == 'choices') { // menu choices to be wrapped in a list
523-
val = m[3].split(' ')
524-
} else {
525-
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
526-
val = m[3].replace(/<br>/g, "\n")
527-
}
507+
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
508+
val = m[3].replace(/<br>/g, "\n")
528509
} else if (attr == 'rotate') { // angle,x,y,z,x,y,z
529510
var temp = m[3]
530511
val = []

vpython/vpython_libraries/ide.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ a:hover {
3232
padding: 0;
3333
width: 100%;
3434
overflow: hidden;
35-
background: #5c9ccc url('redmond/IDE/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png') 50% 50% repeat-x;
35+
background: #5c9ccc;
3636
color: #ffffff;
3737
z-index: 10;
3838

0 commit comments

Comments
 (0)