geomui 0.5.52 → 0.5.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,222 +1,284 @@
1
- <script>import TimeControl from "./TimeControl.svelte";
2
- import ZoomControl from "./ZoomControl.svelte";
3
- import LabelCheckbox from "./LabelCheckbox.svelte";
4
- import {
5
- colors,
6
- canvas2point,
7
- adjustCenter,
8
- adjustRect,
9
- adjustScale,
10
- adjustTranslate,
11
- mergeFaces
12
- } from "geometrix";
13
- import { storePV } from "./storePVal";
14
- import { dLayers } from "./drawingLayers";
15
- import { onMount } from "svelte";
16
- export let pDef;
17
- export let fgeom;
18
- export let optFaces;
19
- export let selFace;
20
- export let zAdjust;
21
- export let simTime = 0;
22
- const c_ParametrixAll = "ParametrixAll";
23
- let windowWidth;
24
- let canvasFull;
25
- let canvasZoom;
26
- const canvas_size_min = 400;
27
- let aFigure;
28
- let cAdjust;
29
- function canvasRedrawFull(iLayers) {
30
- const ctx1 = canvasFull.getContext("2d");
31
- ctx1.clearRect(0, 0, ctx1.canvas.width, ctx1.canvas.height);
32
- try {
33
- cAdjust = aFigure.getAdjustFull(ctx1.canvas.width, ctx1.canvas.height);
34
- aFigure.draw(ctx1, cAdjust, iLayers);
35
- } catch (emsg) {
36
- console.log(emsg);
37
- }
38
- }
39
- function canvasRedrawZoom(iLayers) {
40
- const ctx2 = canvasZoom.getContext("2d");
41
- ctx2.clearRect(0, 0, ctx2.canvas.width, ctx2.canvas.height);
42
- try {
43
- if (zAdjust === void 0 || zAdjust.init === 0) {
44
- zAdjust = aFigure.getAdjustZoom(ctx2.canvas.width, ctx2.canvas.height);
45
- }
46
- aFigure.draw(ctx2, zAdjust, iLayers);
47
- } catch (emsg) {
48
- console.log(emsg);
49
- }
50
- }
51
- function canvasSetSize() {
52
- const ctx1 = canvasFull.getContext("2d");
53
- const canvas_size = Math.max(0.4 * windowWidth, canvas_size_min);
54
- ctx1.canvas.width = canvas_size;
55
- ctx1.canvas.height = canvas_size;
56
- }
57
- function canvasResize() {
58
- canvasSetSize();
59
- canvasRedrawFull($dLayers);
60
- canvasRedrawZoom($dLayers);
61
- }
62
- let domInit = 0;
63
- function checkFace(iFaces, iFace) {
64
- let rFace = iFace;
65
- if (iFaces.length === 0) {
66
- console.log(`warn404: Drawing has an empty face list`);
67
- } else {
68
- const FaceList2 = iFaces.slice();
69
- FaceList2.push(c_ParametrixAll);
70
- if (!FaceList2.includes(rFace)) {
71
- rFace = iFaces[0];
72
- }
73
- }
74
- return rFace;
75
- }
76
- function geomRedrawSub(iSimTime, pVal, iFace, iLayers) {
77
- const FigList = fgeom(iSimTime, pVal).fig;
78
- const FigListKeys = Object.keys(FigList);
79
- const sFace = checkFace(FigListKeys, iFace);
80
- selFace = sFace;
81
- if (FigListKeys.includes(sFace)) {
82
- aFigure = FigList[sFace];
83
- } else {
84
- aFigure = mergeFaces(FigList);
85
- }
86
- canvasRedrawFull(iLayers);
87
- canvasRedrawZoom(iLayers);
88
- }
89
- function geomRedraw(iSimTime, iFace) {
90
- geomRedrawSub(iSimTime, $storePV[pDef.partName], iFace, $dLayers);
91
- }
92
- onMount(() => {
93
- canvasSetSize();
94
- geomRedraw(simTime, selFace);
95
- domInit = 1;
96
- });
97
- $: {
98
- if (domInit === 1) {
99
- geomRedrawSub(simTime, $storePV[pDef.partName], selFace, $dLayers);
100
- }
101
- }
102
- function zoomClick(event) {
103
- switch (event.detail.action) {
104
- case "zoomInit":
105
- zAdjust.init = 0;
106
- break;
107
- case "zoomIn":
108
- zAdjust = adjustScale(0.7, zAdjust);
109
- break;
110
- case "zoomOut":
111
- zAdjust = adjustScale(1.3, zAdjust);
112
- break;
113
- case "moveLeft":
114
- zAdjust.xMin += -0.2 * zAdjust.xyDiff;
115
- break;
116
- case "moveRight":
117
- zAdjust.xMin += 0.2 * zAdjust.xyDiff;
118
- break;
119
- case "moveUp":
120
- zAdjust.yMin += 0.2 * zAdjust.xyDiff;
121
- break;
122
- case "moveDown":
123
- zAdjust.yMin += -0.2 * zAdjust.xyDiff;
124
- break;
125
- default:
126
- console.log(`ERR423: ${event.detail.action} has no case!`);
127
- }
128
- canvasRedrawZoom($dLayers);
129
- }
130
- const mouseDelayMax = 3e3;
131
- const mouseDiffClick = 10;
132
- const mouseDiffRatioSelect = 3;
133
- let mouseF = { timestamp: 0, offsetX: 0, offsetY: 0 };
134
- function cFullMouseDn(eve) {
135
- if (eve.button === 0) {
136
- mouseF.timestamp = Date.now();
137
- mouseF.offsetX = eve.offsetX;
138
- mouseF.offsetY = eve.offsetY;
139
- }
140
- }
141
- function cFullMouseUp(eve) {
142
- if (eve.button === 0) {
143
- if (Date.now() - mouseF.timestamp < mouseDelayMax) {
144
- const diffX = Math.abs(mouseF.offsetX - eve.offsetX);
145
- const diffY = Math.abs(mouseF.offsetY - eve.offsetY);
146
- if (diffX < mouseDiffClick && diffY < mouseDiffClick) {
147
- const [px, py] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
148
- zAdjust = adjustCenter(px, py, zAdjust);
149
- geomRedraw(simTime, selFace);
150
- }
151
- if (diffX > mouseDiffClick && diffY > mouseDiffClick) {
152
- const diffRatio1 = diffX / diffY;
153
- const diffRatio2 = 1 / diffRatio1;
154
- if (diffRatio1 < mouseDiffRatioSelect && diffRatio2 < mouseDiffRatioSelect) {
155
- const [p1x, p1y] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
156
- const [p2x, p2y] = canvas2point(mouseF.offsetX, mouseF.offsetY, cAdjust);
157
- zAdjust = adjustRect(p1x, p1y, p2x, p2y, canvas_size_min, canvas_size_min);
158
- geomRedraw(simTime, selFace);
159
- }
160
- }
161
- } else {
162
- console.log(`Warn205: ignore ${eve.offsetX} ${eve.offsetY} because too slow`);
163
- }
164
- }
165
- }
166
- function cFullMouseMove(eve) {
167
- const ctx1 = canvasFull.getContext("2d");
168
- if (eve.buttons === 1) {
169
- const diffX = eve.offsetX - mouseF.offsetX;
170
- const diffY = eve.offsetY - mouseF.offsetY;
171
- canvasRedrawFull($dLayers);
172
- ctx1.beginPath();
173
- ctx1.rect(mouseF.offsetX, mouseF.offsetY, diffX, diffY);
174
- ctx1.strokeStyle = colors.mouse;
175
- ctx1.stroke();
176
- }
177
- if ($dLayers.ruler) {
178
- const [p1x, p1y] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
179
- ctx1.clearRect(5, 5, 200, 25);
180
- ctx1.font = "15px Arial";
181
- ctx1.fillStyle = colors.ruler;
182
- ctx1.fillText(`x: ${p1x.toFixed(4)} y: ${p1y.toFixed(4)}`, 5, 20);
183
- }
184
- }
185
- let mouseZx;
186
- let mouseZy;
187
- let mouseZadjust;
188
- function cZoomMouseDn(eve) {
189
- if (eve.button === 0) {
190
- const [p1x, p1y] = canvas2point(eve.offsetX, eve.offsetY, zAdjust);
191
- mouseZx = p1x;
192
- mouseZy = p1y;
193
- mouseZadjust = structuredClone(zAdjust);
194
- }
195
- }
196
- function cZoomMouseMove(eve) {
197
- if (eve.buttons === 1) {
198
- const [p2x, p2y] = canvas2point(eve.offsetX, eve.offsetY, mouseZadjust);
199
- zAdjust = adjustTranslate(mouseZx, mouseZy, p2x, p2y, mouseZadjust);
200
- canvasRedrawZoom($dLayers);
201
- } else {
202
- if ($dLayers.ruler) {
203
- const ctx2 = canvasZoom.getContext("2d");
204
- const [p2x, p2y] = canvas2point(eve.offsetX, eve.offsetY, zAdjust);
205
- ctx2.clearRect(5, 5, 200, 25);
206
- ctx2.font = "15px Arial";
207
- ctx2.fillStyle = colors.ruler;
208
- ctx2.fillText(`x: ${p2x.toFixed(4)} y: ${p2y.toFixed(4)}`, 5, 20);
209
- }
210
- }
211
- }
212
- function cZoomWheel(eve) {
213
- if (eve.deltaY > 0) {
214
- zAdjust = adjustScale(0.7, zAdjust);
215
- } else {
216
- zAdjust = adjustScale(1.3, zAdjust);
217
- }
218
- canvasRedrawZoom($dLayers);
219
- }
1
+ <script lang="ts">
2
+ import TimeControl from './TimeControl.svelte';
3
+ import ZoomControl from './ZoomControl.svelte';
4
+ import LabelCheckbox from './LabelCheckbox.svelte';
5
+ import type {
6
+ tCanvasAdjust,
7
+ tLayers,
8
+ Figure,
9
+ tParamDef,
10
+ tParamVal,
11
+ tGeomFunc
12
+ } from 'geometrix';
13
+ import {
14
+ colors,
15
+ canvas2point,
16
+ adjustCenter,
17
+ adjustRect,
18
+ adjustScale,
19
+ adjustTranslate,
20
+ mergeFaces
21
+ } from 'geometrix';
22
+ import { storePV } from './storePVal';
23
+ import { dLayers } from './drawingLayers';
24
+ import { onMount } from 'svelte';
25
+
26
+ export let pDef: tParamDef;
27
+ export let fgeom: tGeomFunc;
28
+ export let optFaces: string[];
29
+ export let selFace: string;
30
+ export let zAdjust: tCanvasAdjust;
31
+ export let simTime = 0;
32
+
33
+ const c_ParametrixAll = 'ParametrixAll';
34
+ let windowWidth: number;
35
+ let canvasFull: HTMLCanvasElement;
36
+ let canvasZoom: HTMLCanvasElement;
37
+ const canvas_size_min = 400;
38
+
39
+ // Canavas Figures
40
+ let aFigure: Figure;
41
+ let cAdjust: tCanvasAdjust;
42
+ //let zAdjust: tCanvasAdjust;
43
+ function canvasRedrawFull(iLayers: tLayers) {
44
+ const ctx1 = canvasFull.getContext('2d')!;
45
+ ctx1.clearRect(0, 0, ctx1.canvas.width, ctx1.canvas.height);
46
+ try {
47
+ cAdjust = aFigure.getAdjustFull(ctx1.canvas.width, ctx1.canvas.height);
48
+ aFigure.draw(ctx1, cAdjust, iLayers);
49
+ } catch (emsg) {
50
+ //rGeome.logstr += emsg;
51
+ console.log(emsg);
52
+ }
53
+ // extra drawing
54
+ //point(5, 5).draw(ctx1, cAdjust, 'green');
55
+ //point(5, 15).draw(ctx1, cAdjust, 'blue', 'rectangle');
56
+ }
57
+ function canvasRedrawZoom(iLayers: tLayers) {
58
+ const ctx2 = canvasZoom.getContext('2d')!;
59
+ ctx2.clearRect(0, 0, ctx2.canvas.width, ctx2.canvas.height);
60
+ try {
61
+ if (zAdjust === undefined || zAdjust.init === 0) {
62
+ zAdjust = aFigure.getAdjustZoom(ctx2.canvas.width, ctx2.canvas.height);
63
+ //console.log(`dbg047: init zAdjust: ${zAdjust.xMin} ${zAdjust.yMin}`);
64
+ }
65
+ aFigure.draw(ctx2, zAdjust, iLayers);
66
+ } catch (emsg) {
67
+ //rGeome.logstr += emsg;
68
+ console.log(emsg);
69
+ }
70
+ }
71
+ function canvasSetSize() {
72
+ //console.log(`windowWidth: ${windowWidth}`);
73
+ const ctx1 = canvasFull.getContext('2d')!;
74
+ const canvas_size = Math.max(0.4 * windowWidth, canvas_size_min);
75
+ ctx1.canvas.width = canvas_size;
76
+ ctx1.canvas.height = canvas_size;
77
+ }
78
+ function canvasResize() {
79
+ canvasSetSize();
80
+ canvasRedrawFull($dLayers);
81
+ canvasRedrawZoom($dLayers);
82
+ }
83
+ let domInit = 0;
84
+ function checkFace(iFaces: string[], iFace: string): string {
85
+ let rFace = iFace;
86
+ if (iFaces.length === 0) {
87
+ console.log(`warn404: Drawing has an empty face list`);
88
+ } else {
89
+ //rFace = iFaces[0];
90
+ const FaceList2 = iFaces.slice();
91
+ FaceList2.push(c_ParametrixAll);
92
+ if (!FaceList2.includes(rFace)) {
93
+ //console.log(`warn403: Drawing has an invalid face ${rFace}`);
94
+ rFace = iFaces[0];
95
+ }
96
+ }
97
+ //console.log(iFaces);
98
+ //console.log(`dbg097: rFace ${rFace}`);
99
+ return rFace;
100
+ }
101
+ function geomRedrawSub(iSimTime: number, pVal: tParamVal, iFace: string, iLayers: tLayers) {
102
+ const FigList = fgeom(iSimTime, pVal).fig;
103
+ const FigListKeys = Object.keys(FigList);
104
+ const sFace = checkFace(FigListKeys, iFace);
105
+ selFace = sFace; // update input select
106
+ if (FigListKeys.includes(sFace)) {
107
+ aFigure = FigList[sFace];
108
+ } else {
109
+ aFigure = mergeFaces(FigList);
110
+ }
111
+ canvasRedrawFull(iLayers);
112
+ canvasRedrawZoom(iLayers);
113
+ }
114
+ function geomRedraw(iSimTime: number, iFace: string) {
115
+ geomRedrawSub(iSimTime, $storePV[pDef.partName], iFace, $dLayers);
116
+ }
117
+ onMount(() => {
118
+ // initial drawing
119
+ canvasSetSize();
120
+ geomRedraw(simTime, selFace);
121
+ //paramChange();
122
+ domInit = 1;
123
+ });
124
+ // reactivity on simTime, $storePV and layers
125
+ $: {
126
+ if (domInit === 1) {
127
+ geomRedrawSub(simTime, $storePV[pDef.partName], selFace, $dLayers);
128
+ }
129
+ }
130
+ // Zoom stories
131
+ function zoomClick(event: CustomEvent<{ action: string }>) {
132
+ //console.log(`dbg094: ${event.detail.action}`);
133
+ switch (event.detail.action) {
134
+ case 'zoomInit':
135
+ zAdjust.init = 0;
136
+ break;
137
+ case 'zoomIn':
138
+ zAdjust = adjustScale(0.7, zAdjust);
139
+ break;
140
+ case 'zoomOut':
141
+ zAdjust = adjustScale(1.3, zAdjust);
142
+ break;
143
+ case 'moveLeft':
144
+ zAdjust.xMin += -0.2 * zAdjust.xyDiff;
145
+ break;
146
+ case 'moveRight':
147
+ zAdjust.xMin += 0.2 * zAdjust.xyDiff;
148
+ break;
149
+ case 'moveUp':
150
+ zAdjust.yMin += 0.2 * zAdjust.xyDiff;
151
+ break;
152
+ case 'moveDown':
153
+ zAdjust.yMin += -0.2 * zAdjust.xyDiff;
154
+ break;
155
+ default:
156
+ console.log(`ERR423: ${event.detail.action} has no case!`);
157
+ }
158
+ canvasRedrawZoom($dLayers);
159
+ }
160
+ // zoom functions on the canvasFull
161
+ interface tMouse {
162
+ timestamp: number;
163
+ offsetX: number;
164
+ offsetY: number;
165
+ }
166
+ const mouseDelayMax = 3000; // only action if mouse-up occurs less than 3000 ms after mouse-down
167
+ const mouseDiffClick = 10; // if diffX and diffY are smaller than 10 pixel then it's a click
168
+ const mouseDiffRatioSelect = 3; // The selection must be more or less a square
169
+ let mouseF: tMouse = { timestamp: 0, offsetX: 0, offsetY: 0 };
170
+ function cFullMouseDn(eve: MouseEvent) {
171
+ //console.log(`dbg131: cFullMouseDn ${eve.offsetX} ${eve.offsetY} ${eve.button}`);
172
+ // left click
173
+ if (eve.button === 0) {
174
+ mouseF.timestamp = Date.now();
175
+ mouseF.offsetX = eve.offsetX;
176
+ mouseF.offsetY = eve.offsetY;
177
+ //const ctx1 = canvasFull.getContext('2d') as CanvasRenderingContext2D;
178
+ //const [px, py] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
179
+ //point(px, py).draw(ctx1, cAdjust, colors.mouse, 'rectangle');
180
+ }
181
+ }
182
+ function cFullMouseUp(eve: MouseEvent) {
183
+ //console.log(`dbg139: cFullMouseUp ${eve.offsetX} ${eve.offsetY} ${eve.button}`);
184
+ // left click
185
+ if (eve.button === 0) {
186
+ //const ctx1 = canvasFull.getContext('2d') as CanvasRenderingContext2D;
187
+ //const [px, py] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
188
+ //point(px, py).draw(ctx1, cAdjust, colors.mouse, 'circle');
189
+ if (Date.now() - mouseF.timestamp < mouseDelayMax) {
190
+ const diffX = Math.abs(mouseF.offsetX - eve.offsetX);
191
+ const diffY = Math.abs(mouseF.offsetY - eve.offsetY);
192
+ if (diffX < mouseDiffClick && diffY < mouseDiffClick) {
193
+ //console.log(`dbg160: a click at ${eve.offsetX} ${eve.offsetY}`);
194
+ const [px, py] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
195
+ zAdjust = adjustCenter(px, py, zAdjust);
196
+ geomRedraw(simTime, selFace);
197
+ }
198
+ if (diffX > mouseDiffClick && diffY > mouseDiffClick) {
199
+ const diffRatio1 = diffX / diffY;
200
+ const diffRatio2 = 1.0 / diffRatio1;
201
+ if (diffRatio1 < mouseDiffRatioSelect && diffRatio2 < mouseDiffRatioSelect) {
202
+ //console.log(`dbg160: a selection at ${eve.offsetX} ${eve.offsetY}`);
203
+ const [p1x, p1y] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
204
+ const [p2x, p2y] = canvas2point(mouseF.offsetX, mouseF.offsetY, cAdjust);
205
+ zAdjust = adjustRect(p1x, p1y, p2x, p2y, canvas_size_min, canvas_size_min);
206
+ geomRedraw(simTime, selFace);
207
+ }
208
+ }
209
+ } else {
210
+ console.log(`Warn205: ignore ${eve.offsetX} ${eve.offsetY} because too slow`);
211
+ }
212
+ }
213
+ }
214
+ // just drawing a rectangle to help zooming
215
+ function cFullMouseMove(eve: MouseEvent) {
216
+ //console.log(`dbg179: cFullMouseMove ${eve.offsetX} ${eve.offsetY} ${eve.buttons}`);
217
+ const ctx1 = canvasFull.getContext('2d')!;
218
+ // left click
219
+ if (eve.buttons === 1) {
220
+ const diffX = eve.offsetX - mouseF.offsetX;
221
+ const diffY = eve.offsetY - mouseF.offsetY;
222
+ canvasRedrawFull($dLayers);
223
+ //const ctx1 = canvasFull.getContext('2d') as CanvasRenderingContext2D;
224
+ ctx1.beginPath();
225
+ ctx1.rect(mouseF.offsetX, mouseF.offsetY, diffX, diffY);
226
+ ctx1.strokeStyle = colors.mouse;
227
+ ctx1.stroke();
228
+ }
229
+ // mouse position
230
+ if ($dLayers.ruler) {
231
+ const [p1x, p1y] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
232
+ ctx1.clearRect(5, 5, 200, 25);
233
+ ctx1.font = '15px Arial';
234
+ ctx1.fillStyle = colors.ruler;
235
+ ctx1.fillText(`x: ${p1x.toFixed(4)} y: ${p1y.toFixed(4)}`, 5, 20);
236
+ }
237
+ }
238
+ // translate Zoom drawing
239
+ let mouseZx: number;
240
+ let mouseZy: number;
241
+ let mouseZadjust: tCanvasAdjust;
242
+ function cZoomMouseDn(eve: MouseEvent) {
243
+ //console.log(`dbg231: cZoomMouseDn ${eve.offsetX} ${eve.offsetY} ${eve.button}`);
244
+ // left click
245
+ if (eve.button === 0) {
246
+ const [p1x, p1y] = canvas2point(eve.offsetX, eve.offsetY, zAdjust);
247
+ mouseZx = p1x; // point
248
+ mouseZy = p1y;
249
+ mouseZadjust = structuredClone(zAdjust); // deepCopy
250
+ //const ctx2 = canvasZoom.getContext('2d') as CanvasRenderingContext2D;
251
+ //const [px, py] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
252
+ //point(px, py).draw(ctx2, cAdjust, colors.mouse, 'rectangle');
253
+ }
254
+ }
255
+ function cZoomMouseMove(eve: MouseEvent) {
256
+ //console.log(`dbg202: cZoomMouseMove ${eve.offsetX} ${eve.offsetY} ${eve.buttons}`);
257
+ // left click
258
+ if (eve.buttons === 1) {
259
+ const [p2x, p2y] = canvas2point(eve.offsetX, eve.offsetY, mouseZadjust);
260
+ zAdjust = adjustTranslate(mouseZx, mouseZy, p2x, p2y, mouseZadjust);
261
+ canvasRedrawZoom($dLayers);
262
+ } else {
263
+ // mouse position
264
+ if ($dLayers.ruler) {
265
+ const ctx2 = canvasZoom.getContext('2d')!;
266
+ const [p2x, p2y] = canvas2point(eve.offsetX, eve.offsetY, zAdjust);
267
+ ctx2.clearRect(5, 5, 200, 25);
268
+ ctx2.font = '15px Arial';
269
+ ctx2.fillStyle = colors.ruler;
270
+ ctx2.fillText(`x: ${p2x.toFixed(4)} y: ${p2y.toFixed(4)}`, 5, 20);
271
+ }
272
+ }
273
+ }
274
+ function cZoomWheel(eve: WheelEvent) {
275
+ if (eve.deltaY > 0) {
276
+ zAdjust = adjustScale(0.7, zAdjust);
277
+ } else {
278
+ zAdjust = adjustScale(1.3, zAdjust);
279
+ }
280
+ canvasRedrawZoom($dLayers);
281
+ }
220
282
  </script>
221
283
 
222
284
  <svelte:window bind:innerWidth={windowWidth} on:resize={canvasResize} />
@@ -240,7 +302,7 @@ function cZoomWheel(eve) {
240
302
  on:mousedown={cFullMouseDn}
241
303
  on:mouseup={cFullMouseUp}
242
304
  on:mousemove={cFullMouseMove}
243
- />
305
+ ></canvas>
244
306
  <TimeControl
245
307
  tMax={pDef.sim.tMax}
246
308
  tStep={pDef.sim.tStep}
@@ -257,7 +319,7 @@ function cZoomWheel(eve) {
257
319
  on:mousedown={cZoomMouseDn}
258
320
  on:mousemove={cZoomMouseMove}
259
321
  on:wheel|preventDefault={cZoomWheel}
260
- />
322
+ ></canvas>
261
323
  <ZoomControl on:myevent={zoomClick} />
262
324
  </div>
263
325
  </section>
@@ -1,24 +1,26 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { tCanvasAdjust, tParamDef, tGeomFunc } from 'geometrix';
3
- declare const __propDef: {
4
- props: {
5
- pDef: tParamDef;
6
- fgeom: tGeomFunc;
7
- optFaces: string[];
8
- selFace: string;
9
- zAdjust: tCanvasAdjust;
10
- simTime?: number;
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
11
12
  };
12
- events: {
13
- [evt: string]: CustomEvent<any>;
14
- };
15
- slots: {};
16
- exports?: {} | undefined;
17
- bindings?: string | undefined;
18
- };
19
- export type DrawingProps = typeof __propDef.props;
20
- export type DrawingEvents = typeof __propDef.events;
21
- export type DrawingSlots = typeof __propDef.slots;
22
- export default class Drawing extends SvelteComponent<DrawingProps, DrawingEvents, DrawingSlots> {
13
+ z_$$bindings?: Bindings;
23
14
  }
24
- export {};
15
+ declare const Drawing: $$__sveltets_2_IsomorphicComponent<{
16
+ pDef: tParamDef;
17
+ fgeom: tGeomFunc;
18
+ optFaces: string[];
19
+ selFace: string;
20
+ zAdjust: tCanvasAdjust;
21
+ simTime?: number;
22
+ }, {
23
+ [evt: string]: CustomEvent<any>;
24
+ }, {}, {}, string>;
25
+ type Drawing = InstanceType<typeof Drawing>;
26
+ export default Drawing;
@@ -1,33 +1,46 @@
1
- <script>import ModalImg from "./ModalImg.svelte";
2
- import { base } from "$app/paths";
3
- export let pDef;
4
- function getSvgList(ipDef) {
5
- const rList = [];
6
- for (const value of Object.values(ipDef.paramSvg)) {
7
- if (!rList.includes(value)) {
8
- rList.push(value);
9
- }
10
- }
11
- return rList;
12
- }
13
- function getSvgList2(partName) {
14
- if (partName === "impossible_part_name") {
15
- }
16
- const lList = getSvgList(pDef);
17
- const rList2 = [];
18
- for (const svg of lList) {
19
- rList2.push(`${base}/pgdsvg/${svg}`);
20
- }
21
- return rList2;
22
- }
23
- let lSvg = [];
24
- $: lSvg = getSvgList2(pDef.partName);
25
- let modalImg = false;
26
- let svgPath;
27
- function showSvg(iSvgPath) {
28
- svgPath = iSvgPath;
29
- modalImg = true;
30
- }
1
+ <script lang="ts">
2
+ import type { tParamDef } from 'geometrix';
3
+ import ModalImg from './ModalImg.svelte';
4
+ //import { onMount } from 'svelte';
5
+ //import { browser } from '$app/environment';
6
+ import { base } from '$app/paths';
7
+
8
+ export let pDef: tParamDef;
9
+
10
+ // helper function
11
+ function getSvgList(ipDef: tParamDef): string[] {
12
+ const rList: string[] = [];
13
+ for (const value of Object.values(ipDef.paramSvg)) {
14
+ if (!rList.includes(value)) {
15
+ rList.push(value);
16
+ }
17
+ }
18
+ return rList;
19
+ }
20
+ function getSvgList2(partName: string): string[] {
21
+ // fake using partName. partName is needed for the reactivity
22
+ if (partName === 'impossible_part_name') {
23
+ //console.log(`dummy022: partName ${partName}`);
24
+ }
25
+ const lList = getSvgList(pDef);
26
+ const rList2: string[] = [];
27
+ for (const svg of lList) {
28
+ rList2.push(`${base}/pgdsvg/${svg}`);
29
+ }
30
+ return rList2;
31
+ }
32
+ // initialization
33
+ let lSvg: string[] = [];
34
+ // reactivity
35
+ $: lSvg = getSvgList2(pDef.partName);
36
+ // modalImg
37
+ let modalImg = false;
38
+ let svgPath: string;
39
+ function showSvg(iSvgPath: string) {
40
+ svgPath = iSvgPath;
41
+ //console.log(`dbg231: svgPath: ${svgPath}`);
42
+ modalImg = true;
43
+ }
31
44
  </script>
32
45
 
33
46
  <section>