@@ -2,25 +2,39 @@ import {
2
2
drawTex ,
3
3
drawRoundedRect ,
4
4
drawTextLines ,
5
+ drawObjectHeader ,
5
6
} from "../lib/graphic-primitives.js" ;
6
7
import { getName } from "../lib/getName.js" ;
7
8
import { linkTypes } from "./links.js" ;
8
9
import { parseCharge } from "../lib/parseCharge.js" ;
9
10
11
+ const TOP_MARGIN = 45 ;
12
+
10
13
class EDMObject {
11
14
constructor ( ) {
12
15
this . x = NaN ;
13
16
this . y = NaN ;
14
17
this . index = NaN ;
15
18
this . collectionId = NaN ;
16
19
this . width = 120 ;
17
- this . height = 240 ;
20
+ this . height = 260 ;
18
21
this . lineColor = "black" ;
19
22
this . lineWidth = 2 ;
20
23
this . color = "white" ;
21
24
}
22
25
23
- draw ( ctx ) { }
26
+ draw ( ctx ) {
27
+ drawRoundedRect (
28
+ ctx ,
29
+ this . x ,
30
+ this . y ,
31
+ this . width ,
32
+ this . height ,
33
+ this . color ,
34
+ this . radius
35
+ ) ;
36
+ drawObjectHeader ( ctx , this ) ;
37
+ }
24
38
25
39
isHere ( mouseX , mouseY ) {
26
40
return (
@@ -44,10 +58,11 @@ class EDMObject {
44
58
export class MCParticle extends EDMObject {
45
59
constructor ( ) {
46
60
super ( ) ;
47
-
48
61
this . row = - 1 ;
49
-
50
62
this . texImg = null ;
63
+ this . color = "#dff6ff" ;
64
+ this . radius = 15 ;
65
+ this . height = 270 ;
51
66
}
52
67
53
68
updateTexImg ( text ) {
@@ -65,21 +80,13 @@ export class MCParticle extends EDMObject {
65
80
draw ( ctx ) {
66
81
const boxCenterX = this . x + this . width / 2 ;
67
82
68
- drawRoundedRect (
69
- ctx ,
70
- this . x ,
71
- this . y ,
72
- this . width ,
73
- this . height ,
74
- "#dff6ff" ,
75
- 15
76
- ) ;
83
+ super . draw ( ctx ) ;
77
84
78
85
if ( this . texImg . complete ) {
79
86
drawTex (
80
87
ctx ,
81
88
boxCenterX ,
82
- this . y + this . height * 0.4 ,
89
+ this . y + TOP_MARGIN + 80 ,
83
90
this . texImg ,
84
91
this . width
85
92
) ;
@@ -88,20 +95,20 @@ export class MCParticle extends EDMObject {
88
95
drawTex (
89
96
ctx ,
90
97
boxCenterX ,
91
- this . y + this . height * 0.4 ,
98
+ this . y + TOP_MARGIN + 80 ,
92
99
this . texImg ,
93
100
this . width
94
101
) ;
95
102
} ;
96
103
}
97
104
98
- const topY = this . y + 20 ;
105
+ const topY = this . y + TOP_MARGIN ;
99
106
const topLines = [ ] ;
100
107
topLines . push ( "ID: " + this . index ) ;
101
108
topLines . push ( "Gen. stat.: " + this . generatorStatus ) ;
102
109
topLines . push ( "Sim. stat.: " + this . simulatorStatus ) ;
103
110
104
- const bottomY = this . y + this . height * 0.6 ;
111
+ const bottomY = this . y + this . height * 0.65 ;
105
112
const bottomLines = [ ] ;
106
113
bottomLines . push ( "p = " + this . momentum + " GeV" ) ;
107
114
bottomLines . push ( "d = " + this . vertex + " mm" ) ;
@@ -200,23 +207,17 @@ class ReconstructedParticle extends EDMObject {
200
207
constructor ( ) {
201
208
super ( ) ;
202
209
this . width = 140 ;
203
- this . height = 180 ;
210
+ this . height = 190 ;
211
+ this . color = "#fbffdf" ;
212
+ this . radius = 30 ;
204
213
}
205
214
206
215
draw ( ctx ) {
207
216
const boxCenterX = this . x + this . width / 2 ;
208
217
209
- drawRoundedRect (
210
- ctx ,
211
- this . x ,
212
- this . y ,
213
- this . width ,
214
- this . height ,
215
- "#fbffdf" ,
216
- 30
217
- ) ;
218
+ super . draw ( ctx ) ;
218
219
219
- const topY = this . y + 20 ;
220
+ const topY = this . y + 1.5 * TOP_MARGIN ;
220
221
const lines = [ ] ;
221
222
222
223
lines . push ( "ID: " + this . index ) ;
@@ -245,23 +246,17 @@ class Cluster extends EDMObject {
245
246
constructor ( ) {
246
247
super ( ) ;
247
248
this . width = 140 ;
248
- this . height = 180 ;
249
+ this . height = 170 ;
250
+ this . color = "#ffe8df" ;
251
+ this . radius = 20 ;
249
252
}
250
253
251
254
draw ( ctx ) {
252
255
const boxCenterX = this . x + this . width / 2 ;
253
256
254
- drawRoundedRect (
255
- ctx ,
256
- this . x ,
257
- this . y ,
258
- this . width ,
259
- this . height ,
260
- "#ffe8df" ,
261
- 20
262
- ) ;
257
+ super . draw ( ctx ) ;
263
258
264
- const topY = this . y + 20 ;
259
+ const topY = this . y + TOP_MARGIN ;
265
260
const lines = [ ] ;
266
261
lines . push ( "ID: " + this . index ) ;
267
262
lines . push ( "type: " + this . type ) ;
@@ -284,23 +279,17 @@ class Track extends EDMObject {
284
279
constructor ( ) {
285
280
super ( ) ;
286
281
this . width = 140 ;
287
- this . height = 180 ;
282
+ this . height = 150 ;
283
+ this . color = "#fff6df" ;
284
+ this . radius = 25 ;
288
285
}
289
286
290
287
draw ( ctx ) {
291
288
const boxCenterX = this . x + this . width / 2 ;
292
289
293
- drawRoundedRect (
294
- ctx ,
295
- this . x ,
296
- this . y ,
297
- this . width ,
298
- this . height ,
299
- "#fff6df" ,
300
- 25
301
- ) ;
290
+ super . draw ( ctx ) ;
302
291
303
- const topY = this . y + 20 ;
292
+ const topY = this . y + TOP_MARGIN ;
304
293
305
294
const lines = [ ] ;
306
295
lines . push ( "ID: " + this . index ) ;
@@ -324,23 +313,17 @@ class ParticleID extends EDMObject {
324
313
constructor ( ) {
325
314
super ( ) ;
326
315
this . width = 140 ;
327
- this . height = 120 ;
316
+ this . height = 140 ;
317
+ this . color = "#c9edf7" ;
318
+ this . radius = 25 ;
328
319
}
329
320
330
321
draw ( ctx ) {
331
322
const boxCenterX = this . x + this . width / 2 ;
332
323
333
- drawRoundedRect (
334
- ctx ,
335
- this . x ,
336
- this . y ,
337
- this . width ,
338
- this . height ,
339
- "#c9edf7" ,
340
- 25
341
- ) ;
324
+ super . draw ( ctx ) ;
342
325
343
- const topY = this . y + 20 ;
326
+ const topY = this . y + TOP_MARGIN ;
344
327
345
328
const lines = [ ] ;
346
329
lines . push ( "ID: " + this . index ) ;
@@ -359,23 +342,17 @@ class Vertex extends EDMObject {
359
342
constructor ( ) {
360
343
super ( ) ;
361
344
this . width = 140 ;
362
- this . height = 140 ;
345
+ this . height = 150 ;
346
+ this . color = "#f5d3ef" ;
347
+ this . radius = 25 ;
363
348
}
364
349
365
350
draw ( ctx ) {
366
351
const boxCenterX = this . x + this . width / 2 ;
367
352
368
- drawRoundedRect (
369
- ctx ,
370
- this . x ,
371
- this . y ,
372
- this . width ,
373
- this . height ,
374
- "#f5d3ef" ,
375
- 25
376
- ) ;
353
+ super . draw ( ctx ) ;
377
354
378
- const topY = this . y + 20 ;
355
+ const topY = this . y + TOP_MARGIN ;
379
356
380
357
const lines = [ ] ;
381
358
lines . push ( "ID: " + this . index ) ;
0 commit comments