geomui 0.5.51 → 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.
- package/dist/Drawing.svelte +283 -221
- package/dist/Drawing.svelte.d.ts +23 -21
- package/dist/DrawingList.svelte +43 -30
- package/dist/DrawingList.svelte.d.ts +18 -16
- package/dist/InputParams.svelte +321 -258
- package/dist/InputParams.svelte.d.ts +24 -22
- package/dist/LabelCheckbox.svelte +2 -1
- package/dist/LabelCheckbox.svelte.d.ts +16 -14
- package/dist/LocStorRead.svelte +23 -17
- package/dist/LocStorRead.svelte.d.ts +19 -17
- package/dist/LocStorTable.svelte +79 -65
- package/dist/LocStorTable.svelte.d.ts +20 -18
- package/dist/LocStorWrite.svelte +36 -21
- package/dist/LocStorWrite.svelte.d.ts +19 -17
- package/dist/ModalDiag.svelte +17 -12
- package/dist/ModalDiag.svelte.d.ts +30 -20
- package/dist/ModalImg.svelte +7 -5
- package/dist/ModalImg.svelte.d.ts +19 -17
- package/dist/OneDesign.svelte +11 -6
- package/dist/OneDesign.svelte.d.ts +19 -17
- package/dist/ParamDrawExport.svelte +151 -131
- package/dist/ParamDrawExport.svelte.d.ts +20 -18
- package/dist/SimpleDrawing.svelte +65 -49
- package/dist/SimpleDrawing.svelte.d.ts +22 -20
- package/dist/SubDesign.svelte +57 -41
- package/dist/SubDesign.svelte.d.ts +20 -18
- package/dist/TimeControl.svelte +71 -63
- package/dist/TimeControl.svelte.d.ts +21 -19
- package/dist/ZoomControl.svelte +31 -14
- package/dist/ZoomControl.svelte.d.ts +18 -16
- package/package.json +26 -25
package/dist/Drawing.svelte
CHANGED
|
@@ -1,222 +1,284 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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>
|
package/dist/Drawing.svelte.d.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { tCanvasAdjust, tParamDef, tGeomFunc } from 'geometrix';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
package/dist/DrawingList.svelte
CHANGED
|
@@ -1,33 +1,46 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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>
|