From 484ed688bd45e7f105a58410d7056cb52a4ab80a Mon Sep 17 00:00:00 2001 From: Ryan Tang Date: Fri, 23 Dec 2022 17:47:22 -0500 Subject: [PATCH] added text for detector --- geo.js | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/geo.js b/geo.js index b6fa9bb..8523566 100644 --- a/geo.js +++ b/geo.js @@ -167,6 +167,22 @@ class beamCircleElement extends basicShape{ } } +class detectorStation extends beamCircleElement { + constructor(xy, name){ + super(xy, 100, 0, Math.PI*2, color.Detector); + this.xy = xy; + this.name = name; + } + draw(onoff){ + super.draw(onoff); + let ctx = staticLayer.getContext("2d"); + ctx.font = "40px Verdana"; + ctx.fillStyle = 'black'; + let text = ctx.measureText(this.name); + ctx.fillText(this.name, this.xy[0]-text.width/2, this.xy[1] + 12); + } +} + class beamSpliter extends basicShape{ constructor(xy, r, rad, color){ super(staticLayer, color); @@ -251,6 +267,12 @@ class beamDipole extends basicShape{ } +function DrawText(xy, text, color, fontSize){ + let ctx = staticLayer.getContext("2d"); + ctx.font = fontSize + " Verdana"; + ctx.fillStyle = color; + ctx.fillText( text, xy[0], xy[1]); +} ///========================= Floor plan let windowSize = [3840, 2160]; // 4K @@ -258,12 +280,12 @@ let windowSize = [3840, 2160]; // 4K let sourceLine; { - let RFSource1a = new beamRectElement([windowSize[0]*0.9, windowSize[1]*0.8], 0, 40, 100, color.RFsourcce); + let RFSource1a = new beamRectElement([windowSize[0]*0.9, windowSize[1]*0.9], 0, 40, 100, color.RFsourcce); let RFSource1b = new beamRectElement(RFSource1a.exitPos, 0, 40, 20, color.RFsourcce); let s0 = new beamSpliter(RFSource1b.GetExitPos(120), 50, Math.PI, color.Dipole); let b0a = new beamLine(RFSource1b.exitPos, 0, 200); - let tandem = new tandemClass(b0a.exitPos, 100, 100, color.Tandem); + let tandem = new tandemClass(b0a.exitPos, 300, 100, color.Tandem); let b0b = new beamLine(tandem.exitPos, 0, 300); b0b.offset = 8; let q0 = new beamRectElement(tandem.GetExitPos(50), 0, 60, 60, color.Qpole); @@ -287,8 +309,8 @@ let targetRoom1; let q1a = new beamRectElement(fan.GetExitPos(0.8, 100), fan.exitAng, 60, 60, color.Qpole); let df1a = new beamRectElement(q1a.GetExitPos(30), fan.exitAng, 30, 40, color.Dipole); let b1a_1 = new beamLine(b1a_0.exitPos, fan.exitAng, 300); - let GammaStation = new beamCircleElement(b1a_0.exitPos, 100, 0, Math.PI*2, color.Detector); - let Catrina = new beamCircleElement(b1a_1.exitPos, 100, 0, Math.PI*2, color.Detector); + let GammaStation = new detectorStation(b1a_0.exitPos, "Gamma"); + let Catrina = new detectorStation(b1a_1.exitPos, "Carina"); upperLine = {b1a_0, q1a, df1a, b1a_1, GammaStation, Catrina}; } @@ -348,7 +370,7 @@ let targetRoom2; let df2a_2 = new beamRectElement( df2a_1.GetExitPos(30), fan2.GetExitAng(frac), 30, 40, color.Deflector); let d3 = new beamDipole(b2a.GetExitPos(0), 80, 90* deg, -40 * deg, color.Dipole); let b2a_1 = new beamLine( d3.GetExitPos(0), -95 * deg, 500); - let Resolut = new beamCircleElement(b2a_1.GetExitPos(0), 100, 0, Math.PI*2, color.Detector); + let Resolut = new detectorStation(b2a_1.GetExitPos(0), "Resolut"); ResolutLine = {b2a, df2a_0, q2a, df2a_1, df2a_2, d3, b2a_1, Resolut}; } @@ -357,9 +379,9 @@ let targetRoom2; { let frac = 0.5; let b2b = new beamLine(fan2.GetExitPos(frac, 0), fan2.GetExitAng(frac), 500); - let q2b = new beamRectElement(fan2.GetExitPos(frac, 30), fan2.GetExitAng(frac), 60, 60, color.Qpole); - let df2b = new beamRectElement( fan2.GetExitPos(frac, 120), fan2.GetExitAng(frac), 30, 40, color.Deflector); - let Anasen = new beamCircleElement(b2b.GetExitPos(0), 100, 0, Math.PI*2, color.Detector); + let q2b = new beamRectElement(fan2.GetExitPos(frac, 150), fan2.GetExitAng(frac), 60, 60, color.Qpole); + let df2b = new beamRectElement( fan2.GetExitPos(frac, 240), fan2.GetExitAng(frac), 30, 40, color.Deflector); + let Anasen = new detectorStation(b2b.GetExitPos(0), "Anasen"); AnasenLine = {b2b, q2b, df2b, Anasen}; } @@ -379,7 +401,7 @@ let targetRoom2; let q2c_1 = new beamRectElement(fan2c.GetExitPos(frac, 100), fan2c.GetExitAng(frac), 60, 60, color.Qpole); let df2c_1a = new beamRectElement( q2c_1.GetExitPos(30), fan2c.GetExitAng(frac), 30, 40, color.Deflector); let df2c_1b = new beamRectElement( df2c_1a.GetExitPos(30), fan2c.GetExitAng(frac), 30, 40, color.Deflector); - let SPS = new beamCircleElement(b2c_1.GetExitPos(0), 100, 0, Math.PI*2, color.Detector); + let SPS = new detectorStation(b2c_1.GetExitPos(0), "SPS"); SplitPoleLine = {b2c_1, q2c_1, df2c_1a, df2c_1b, SPS}; } @@ -391,7 +413,7 @@ let targetRoom2; let q2c_2 = new beamRectElement(fan2c.GetExitPos(frac, 100), fan2c.GetExitAng(frac), 60, 60, color.Qpole); let df2c_2a = new beamRectElement( q2c_2.GetExitPos(30), fan2c.GetExitAng(frac), 30, 40, color.Deflector); let df2c_2b = new beamRectElement( df2c_2a.GetExitPos(30), fan2c.GetExitAng(frac), 30, 40, color.Deflector); - let Clarion2 = new beamCircleElement(b2c_2.GetExitPos(0), 100, 0, Math.PI*2, color.Detector); + let Clarion2 = new detectorStation(b2c_2.GetExitPos(0), "Clarion2"); ClarionLine = {b2c_2, q2c_2, df2c_2a, df2c_2b, Clarion2}; } @@ -446,6 +468,6 @@ function lineMotion(){ sourceLine.b0b.march(); targetRoom1.beampipe.march(); targetRoom1.upperLine.b1a_0.march(); - setTimeout(lineMotion, 20); + setTimeout(lineMotion, 10); } lineMotion();