geomui 0.5.52 → 0.5.56
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 +275 -262
- package/dist/Drawing.svelte.d.ts +8 -24
- package/dist/DrawingList.svelte +38 -33
- package/dist/DrawingList.svelte.d.ts +5 -18
- package/dist/InputParams.svelte +338 -283
- package/dist/InputParams.svelte.d.ts +7 -25
- package/dist/LabelCheckbox.svelte +12 -11
- package/dist/LabelCheckbox.svelte.d.ts +16 -14
- package/dist/LocStorRead.svelte +29 -17
- package/dist/LocStorRead.svelte.d.ts +6 -19
- package/dist/LocStorTable.svelte +88 -68
- package/dist/LocStorTable.svelte.d.ts +7 -20
- package/dist/LocStorWrite.svelte +28 -22
- package/dist/LocStorWrite.svelte.d.ts +6 -19
- package/dist/ModalDiag.svelte +33 -15
- package/dist/ModalDiag.svelte.d.ts +10 -22
- package/dist/ModalImg.svelte +11 -6
- package/dist/ModalImg.svelte.d.ts +6 -19
- package/dist/OneDesign.svelte +15 -6
- package/dist/OneDesign.svelte.d.ts +6 -19
- package/dist/ParamDrawExport.svelte +220 -134
- package/dist/ParamDrawExport.svelte.d.ts +7 -20
- package/dist/SimpleDrawing.svelte +82 -49
- package/dist/SimpleDrawing.svelte.d.ts +7 -23
- package/dist/SubDesign.svelte +64 -45
- package/dist/SubDesign.svelte.d.ts +8 -21
- package/dist/TimeControl.svelte +84 -69
- package/dist/TimeControl.svelte.d.ts +8 -21
- package/dist/ZoomControl.svelte +21 -14
- package/dist/ZoomControl.svelte.d.ts +5 -18
- package/dist/initStore.js +12 -11
- package/dist/stateDrawing.svelte.d.ts +8 -0
- package/dist/stateDrawing.svelte.js +8 -0
- package/dist/stateParams.svelte.d.ts +5 -0
- package/dist/stateParams.svelte.js +3 -0
- package/package.json +21 -21
- package/dist/drawingLayers.d.ts +0 -2
- package/dist/drawingLayers.js +0 -6
- package/dist/storePVal.d.ts +0 -5
- package/dist/storePVal.js +0 -4
package/dist/Drawing.svelte
CHANGED
|
@@ -1,235 +1,269 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
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 { tCanvasAdjust, tLayers, Figure, tSimTime } from 'geometrix';
|
|
6
|
+
import {
|
|
7
|
+
colors,
|
|
8
|
+
canvas2point,
|
|
9
|
+
adjustCopy,
|
|
10
|
+
adjustCenter,
|
|
11
|
+
adjustRect,
|
|
12
|
+
adjustScale,
|
|
13
|
+
adjustTranslate
|
|
14
|
+
} from 'geometrix';
|
|
15
|
+
import { sDraw } from './stateDrawing.svelte';
|
|
16
|
+
import { onMount } from 'svelte';
|
|
17
|
+
|
|
18
|
+
// props
|
|
19
|
+
interface Props {
|
|
20
|
+
pDefSim: tSimTime;
|
|
21
|
+
pFig: Figure;
|
|
22
|
+
simTime?: number;
|
|
23
|
+
}
|
|
24
|
+
let { pDefSim, pFig, simTime = $bindable(0) }: Props = $props();
|
|
25
|
+
|
|
26
|
+
// const
|
|
27
|
+
const canvas_size_min = 400;
|
|
28
|
+
const canvas_size_max = 1200;
|
|
29
|
+
|
|
30
|
+
// state
|
|
31
|
+
let windowWidth: number = $state(canvas_size_min); // TODO5: $state is not needed, but otherwise svelte complains
|
|
32
|
+
// those internal states are bound: no need of $state
|
|
33
|
+
let canvasFull: HTMLCanvasElement;
|
|
34
|
+
let canvasZoom: HTMLCanvasElement;
|
|
35
|
+
|
|
36
|
+
// Canavas Figures
|
|
37
|
+
let cAdjust: tCanvasAdjust;
|
|
38
|
+
function canvasRedrawFull(iFig: Figure, iLayers: tLayers) {
|
|
39
|
+
if (canvasFull) {
|
|
40
|
+
const ctx1 = canvasFull.getContext('2d')!;
|
|
41
|
+
ctx1.clearRect(0, 0, ctx1.canvas.width, ctx1.canvas.height);
|
|
42
|
+
try {
|
|
43
|
+
cAdjust = iFig.getAdjustFull(ctx1.canvas.width, ctx1.canvas.height);
|
|
44
|
+
iFig.draw(ctx1, cAdjust, iLayers);
|
|
45
|
+
} catch (emsg) {
|
|
46
|
+
//rGeome.logstr += emsg;
|
|
47
|
+
console.log(emsg);
|
|
48
|
+
}
|
|
49
|
+
// extra drawing
|
|
50
|
+
//point(5, 5).draw(ctx1, cAdjust, 'green');
|
|
51
|
+
//point(5, 15).draw(ctx1, cAdjust, 'blue', 'rectangle');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function canvasRedrawZoom(iFig: Figure, iZAdjust: tCanvasAdjust, iLayers: tLayers) {
|
|
55
|
+
if (canvasZoom) {
|
|
56
|
+
const ctx2 = canvasZoom.getContext('2d')!;
|
|
57
|
+
ctx2.clearRect(0, 0, ctx2.canvas.width, ctx2.canvas.height);
|
|
58
|
+
try {
|
|
59
|
+
if (iZAdjust === undefined || iZAdjust.init === 0) {
|
|
60
|
+
iZAdjust = iFig.getAdjustZoom(ctx2.canvas.width, ctx2.canvas.height);
|
|
61
|
+
//console.log(`dbg047: init iZAdjust: ${iZAdjust.xMin} ${iZAdjust.yMin}`);
|
|
62
|
+
}
|
|
63
|
+
iFig.draw(ctx2, iZAdjust, iLayers);
|
|
64
|
+
} catch (emsg) {
|
|
65
|
+
//rGeome.logstr += emsg;
|
|
66
|
+
console.log(emsg);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function canvasSetSize() {
|
|
71
|
+
//console.log(`windowWidth: ${windowWidth}`);
|
|
72
|
+
const ctxF = canvasFull.getContext('2d')!;
|
|
73
|
+
const ctxZ = canvasZoom.getContext('2d')!;
|
|
74
|
+
const canvas_size = Math.min(Math.max(0.4 * windowWidth, canvas_size_min), canvas_size_max);
|
|
75
|
+
ctxF.canvas.width = canvas_size;
|
|
76
|
+
ctxF.canvas.height = canvas_size;
|
|
77
|
+
ctxZ.canvas.width = canvas_size;
|
|
78
|
+
ctxZ.canvas.height = canvas_size;
|
|
79
|
+
// initialize zAdjust
|
|
80
|
+
sDraw.canvasZWidth = canvas_size;
|
|
81
|
+
if (sDraw.zAdjust.init === 0) {
|
|
82
|
+
sDraw.zAdjust = pFig.getAdjustZoom(ctxZ.canvas.width, ctxZ.canvas.height);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function canvasResize() {
|
|
86
|
+
canvasSetSize();
|
|
87
|
+
canvasRedrawFull(pFig, sDraw.dLayers);
|
|
88
|
+
canvasRedrawZoom(pFig, sDraw.zAdjust, sDraw.dLayers);
|
|
89
|
+
}
|
|
90
|
+
function geomRedraw(iFig: Figure, iZAdjust: tCanvasAdjust, iLayers: tLayers) {
|
|
91
|
+
canvasRedrawFull(iFig, iLayers);
|
|
92
|
+
canvasRedrawZoom(iFig, iZAdjust, iLayers);
|
|
93
|
+
}
|
|
94
|
+
// initialization
|
|
95
|
+
onMount(() => {
|
|
96
|
+
canvasSetSize();
|
|
97
|
+
});
|
|
98
|
+
// reactivity on pFig, zAdjust and dLayers
|
|
99
|
+
$effect(() => {
|
|
100
|
+
geomRedraw(pFig, sDraw.zAdjust, sDraw.dLayers);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// actions
|
|
104
|
+
// Zoom stories
|
|
105
|
+
function zoomClick(action: string) {
|
|
106
|
+
//console.log(`dbg094: ${action}`);
|
|
107
|
+
const ctx2 = canvasZoom.getContext('2d')!;
|
|
108
|
+
switch (action) {
|
|
109
|
+
case 'zoomInit':
|
|
110
|
+
sDraw.zAdjust = pFig.getAdjustZoom(ctx2.canvas.width, ctx2.canvas.height);
|
|
111
|
+
break;
|
|
112
|
+
case 'zoomIn':
|
|
113
|
+
sDraw.zAdjust = adjustScale(0.7, sDraw.zAdjust);
|
|
114
|
+
break;
|
|
115
|
+
case 'zoomOut':
|
|
116
|
+
sDraw.zAdjust = adjustScale(1.3, sDraw.zAdjust);
|
|
117
|
+
break;
|
|
118
|
+
case 'moveLeft':
|
|
119
|
+
sDraw.zAdjust.xMin += -0.2 * sDraw.zAdjust.xyDiff;
|
|
120
|
+
break;
|
|
121
|
+
case 'moveRight':
|
|
122
|
+
sDraw.zAdjust.xMin += 0.2 * sDraw.zAdjust.xyDiff;
|
|
123
|
+
break;
|
|
124
|
+
case 'moveUp':
|
|
125
|
+
sDraw.zAdjust.yMin += 0.2 * sDraw.zAdjust.xyDiff;
|
|
126
|
+
break;
|
|
127
|
+
case 'moveDown':
|
|
128
|
+
sDraw.zAdjust.yMin += -0.2 * sDraw.zAdjust.xyDiff;
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
console.log(`ERR423: ${action} has no case!`);
|
|
132
|
+
}
|
|
133
|
+
canvasRedrawZoom(pFig, sDraw.zAdjust, sDraw.dLayers);
|
|
134
|
+
}
|
|
135
|
+
// zoom functions on the canvasFull
|
|
136
|
+
interface tMouse {
|
|
137
|
+
timestamp: number;
|
|
138
|
+
offsetX: number;
|
|
139
|
+
offsetY: number;
|
|
140
|
+
}
|
|
141
|
+
const mouseDelayMax = 3000; // only action if mouse-up occurs less than 3000 ms after mouse-down
|
|
142
|
+
const mouseDiffClick = 10; // if diffX and diffY are smaller than 10 pixel then it's a click
|
|
143
|
+
const mouseDiffRatioSelect = 3; // The selection must be more or less a square
|
|
144
|
+
let mouseF: tMouse = { timestamp: 0, offsetX: 0, offsetY: 0 };
|
|
145
|
+
function cFullMouseDn(eve: MouseEvent) {
|
|
146
|
+
//console.log(`dbg131: cFullMouseDn ${eve.offsetX} ${eve.offsetY} ${eve.button}`);
|
|
147
|
+
// left click
|
|
148
|
+
if (eve.button === 0) {
|
|
149
|
+
mouseF.timestamp = Date.now();
|
|
150
|
+
mouseF.offsetX = eve.offsetX;
|
|
151
|
+
mouseF.offsetY = eve.offsetY;
|
|
152
|
+
//const ctx1 = canvasFull.getContext('2d') as CanvasRenderingContext2D;
|
|
153
|
+
//const [px, py] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
|
|
154
|
+
//point(px, py).draw(ctx1, cAdjust, colors.mouse, 'rectangle');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function cFullMouseUp(eve: MouseEvent) {
|
|
158
|
+
//console.log(`dbg139: cFullMouseUp ${eve.offsetX} ${eve.offsetY} ${eve.button}`);
|
|
159
|
+
// left click
|
|
160
|
+
if (eve.button === 0) {
|
|
161
|
+
//const ctx1 = canvasFull.getContext('2d') as CanvasRenderingContext2D;
|
|
162
|
+
//const [px, py] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
|
|
163
|
+
//point(px, py).draw(ctx1, cAdjust, colors.mouse, 'circle');
|
|
164
|
+
if (Date.now() - mouseF.timestamp < mouseDelayMax) {
|
|
165
|
+
const diffX = Math.abs(mouseF.offsetX - eve.offsetX);
|
|
166
|
+
const diffY = Math.abs(mouseF.offsetY - eve.offsetY);
|
|
167
|
+
if (diffX < mouseDiffClick && diffY < mouseDiffClick) {
|
|
168
|
+
//console.log(`dbg160: a click at ${eve.offsetX} ${eve.offsetY}`);
|
|
169
|
+
const [px, py] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
|
|
170
|
+
sDraw.zAdjust = adjustCenter(px, py, sDraw.zAdjust);
|
|
171
|
+
geomRedraw(pFig, sDraw.zAdjust, sDraw.dLayers);
|
|
172
|
+
}
|
|
173
|
+
if (diffX > mouseDiffClick && diffY > mouseDiffClick) {
|
|
174
|
+
const diffRatio1 = diffX / diffY;
|
|
175
|
+
const diffRatio2 = 1.0 / diffRatio1;
|
|
176
|
+
if (diffRatio1 < mouseDiffRatioSelect && diffRatio2 < mouseDiffRatioSelect) {
|
|
177
|
+
//console.log(`dbg160: a selection at ${eve.offsetX} ${eve.offsetY}`);
|
|
178
|
+
const [p1x, p1y] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
|
|
179
|
+
const [p2x, p2y] = canvas2point(mouseF.offsetX, mouseF.offsetY, cAdjust);
|
|
180
|
+
const ctx2 = canvasZoom.getContext('2d')!;
|
|
181
|
+
const w2 = ctx2.canvas.width;
|
|
182
|
+
sDraw.zAdjust = adjustRect(p1x, p1y, p2x, p2y, w2, w2);
|
|
183
|
+
geomRedraw(pFig, sDraw.zAdjust, sDraw.dLayers);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
console.log(`Warn205: ignore ${eve.offsetX} ${eve.offsetY} because too slow`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// just drawing a rectangle to help zooming
|
|
192
|
+
function cFullMouseMove(eve: MouseEvent) {
|
|
193
|
+
//console.log(`dbg179: cFullMouseMove ${eve.offsetX} ${eve.offsetY} ${eve.buttons}`);
|
|
194
|
+
if (canvasFull) {
|
|
195
|
+
const ctx1 = canvasFull.getContext('2d')!;
|
|
196
|
+
// left click
|
|
197
|
+
if (eve.buttons === 1) {
|
|
198
|
+
const diffX = eve.offsetX - mouseF.offsetX;
|
|
199
|
+
const diffY = eve.offsetY - mouseF.offsetY;
|
|
200
|
+
canvasRedrawFull(pFig, sDraw.dLayers);
|
|
201
|
+
//const ctx1 = canvasFull.getContext('2d') as CanvasRenderingContext2D;
|
|
202
|
+
ctx1.beginPath();
|
|
203
|
+
ctx1.rect(mouseF.offsetX, mouseF.offsetY, diffX, diffY);
|
|
204
|
+
ctx1.strokeStyle = colors.mouse;
|
|
205
|
+
ctx1.stroke();
|
|
206
|
+
}
|
|
207
|
+
// mouse position
|
|
208
|
+
if (sDraw.dLayers.ruler) {
|
|
209
|
+
const [p1x, p1y] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
|
|
210
|
+
ctx1.clearRect(5, 5, 200, 25);
|
|
211
|
+
ctx1.font = '15px Arial';
|
|
212
|
+
ctx1.fillStyle = colors.ruler;
|
|
213
|
+
ctx1.fillText(`x: ${p1x.toFixed(4)} y: ${p1y.toFixed(4)}`, 5, 20);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// translate Zoom drawing
|
|
218
|
+
let mouseZx: number;
|
|
219
|
+
let mouseZy: number;
|
|
220
|
+
let mouseZadjust: tCanvasAdjust;
|
|
221
|
+
function cZoomMouseDn(eve: MouseEvent) {
|
|
222
|
+
//console.log(`dbg231: cZoomMouseDn ${eve.offsetX} ${eve.offsetY} ${eve.button}`);
|
|
223
|
+
// left click
|
|
224
|
+
if (eve.button === 0) {
|
|
225
|
+
const [p1x, p1y] = canvas2point(eve.offsetX, eve.offsetY, sDraw.zAdjust);
|
|
226
|
+
mouseZx = p1x; // point
|
|
227
|
+
mouseZy = p1y;
|
|
228
|
+
mouseZadjust = adjustCopy(sDraw.zAdjust); // deepCopy
|
|
229
|
+
//const ctx2 = canvasZoom.getContext('2d') as CanvasRenderingContext2D;
|
|
230
|
+
//const [px, py] = canvas2point(eve.offsetX, eve.offsetY, cAdjust);
|
|
231
|
+
//point(px, py).draw(ctx2, cAdjust, colors.mouse, 'rectangle');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function cZoomMouseMove(eve: MouseEvent) {
|
|
235
|
+
//console.log(`dbg202: cZoomMouseMove ${eve.offsetX} ${eve.offsetY} ${eve.buttons}`);
|
|
236
|
+
// left click
|
|
237
|
+
if (eve.buttons === 1) {
|
|
238
|
+
const [p2x, p2y] = canvas2point(eve.offsetX, eve.offsetY, mouseZadjust);
|
|
239
|
+
sDraw.zAdjust = adjustTranslate(mouseZx, mouseZy, p2x, p2y, mouseZadjust);
|
|
240
|
+
canvasRedrawZoom(pFig, sDraw.zAdjust, sDraw.dLayers);
|
|
241
|
+
} else {
|
|
242
|
+
// mouse position
|
|
243
|
+
if (sDraw.dLayers.ruler && canvasZoom) {
|
|
244
|
+
const ctx2 = canvasZoom.getContext('2d')!;
|
|
245
|
+
const [p2x, p2y] = canvas2point(eve.offsetX, eve.offsetY, sDraw.zAdjust);
|
|
246
|
+
ctx2.clearRect(5, 5, 200, 25);
|
|
247
|
+
ctx2.font = '15px Arial';
|
|
248
|
+
ctx2.fillStyle = colors.ruler;
|
|
249
|
+
ctx2.fillText(`x: ${p2x.toFixed(4)} y: ${p2y.toFixed(4)}`, 5, 20);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function cZoomWheel(eve: WheelEvent) {
|
|
254
|
+
eve.preventDefault();
|
|
255
|
+
if (eve.deltaY > 0) {
|
|
256
|
+
sDraw.zAdjust = adjustScale(0.7, sDraw.zAdjust);
|
|
257
|
+
} else {
|
|
258
|
+
sDraw.zAdjust = adjustScale(1.3, sDraw.zAdjust);
|
|
259
|
+
}
|
|
260
|
+
canvasRedrawZoom(pFig, sDraw.zAdjust, sDraw.dLayers);
|
|
261
|
+
}
|
|
220
262
|
</script>
|
|
221
263
|
|
|
222
|
-
|
|
264
|
+
// TODO: onresize is not triggered when the window is maximized
|
|
265
|
+
<svelte:window bind:innerWidth={windowWidth} onresize={canvasResize} />
|
|
223
266
|
<section>
|
|
224
|
-
<h2>
|
|
225
|
-
Drawing
|
|
226
|
-
<select bind:value={selFace}>
|
|
227
|
-
{#each optFaces as optFace}
|
|
228
|
-
<option value={optFace}>{optFace}</option>
|
|
229
|
-
{/each}
|
|
230
|
-
<option value={c_ParametrixAll}>All faces merged</option>
|
|
231
|
-
</select>
|
|
232
|
-
</h2>
|
|
233
267
|
<LabelCheckbox />
|
|
234
268
|
<div class="rack">
|
|
235
269
|
<canvas
|
|
@@ -237,14 +271,14 @@ function cZoomWheel(eve) {
|
|
|
237
271
|
width={canvas_size_min}
|
|
238
272
|
height={canvas_size_min}
|
|
239
273
|
bind:this={canvasFull}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
274
|
+
onmousedown={cFullMouseDn}
|
|
275
|
+
onmouseup={cFullMouseUp}
|
|
276
|
+
onmousemove={cFullMouseMove}
|
|
277
|
+
></canvas>
|
|
244
278
|
<TimeControl
|
|
245
|
-
tMax={
|
|
246
|
-
tStep={
|
|
247
|
-
tUpdate={
|
|
279
|
+
tMax={pDefSim.tMax}
|
|
280
|
+
tStep={pDefSim.tStep}
|
|
281
|
+
tUpdate={pDefSim.tUpdate}
|
|
248
282
|
bind:simTime
|
|
249
283
|
/>
|
|
250
284
|
</div>
|
|
@@ -254,11 +288,11 @@ function cZoomWheel(eve) {
|
|
|
254
288
|
width={canvas_size_min}
|
|
255
289
|
height={canvas_size_min}
|
|
256
290
|
bind:this={canvasZoom}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
<ZoomControl
|
|
291
|
+
onmousedown={cZoomMouseDn}
|
|
292
|
+
onmousemove={cZoomMouseMove}
|
|
293
|
+
onwheel={cZoomWheel}
|
|
294
|
+
></canvas>
|
|
295
|
+
<ZoomControl {zoomClick} />
|
|
262
296
|
</div>
|
|
263
297
|
</section>
|
|
264
298
|
|
|
@@ -270,27 +304,6 @@ $canvas-point: grey;
|
|
|
270
304
|
colorCanvasPoint: $canvas-point;
|
|
271
305
|
}
|
|
272
306
|
*/
|
|
273
|
-
section > h2 {
|
|
274
|
-
color: grey;
|
|
275
|
-
margin: 1rem 0.5rem 0;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
section > h2 > select {
|
|
279
|
-
/*display: inline-block;*/
|
|
280
|
-
height: 1.6rem;
|
|
281
|
-
/*width: 1.6rem;*/
|
|
282
|
-
color: darkBlue;
|
|
283
|
-
font-size: 0.8rem;
|
|
284
|
-
font-weight: 400;
|
|
285
|
-
padding: 0.2rem 0.4rem 0.2rem;
|
|
286
|
-
border-style: solid;
|
|
287
|
-
border-width: 0.1rem;
|
|
288
|
-
border-radius: 0.2rem;
|
|
289
|
-
border-color: darkBlue;
|
|
290
|
-
margin: 0.5rem;
|
|
291
|
-
background-color: lightBlue;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
307
|
section > div.rack {
|
|
295
308
|
display: inline-block;
|
|
296
309
|
margin: 0 1rem 0;
|
package/dist/Drawing.svelte.d.ts
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
zAdjust: tCanvasAdjust;
|
|
10
|
-
simTime?: number;
|
|
11
|
-
};
|
|
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> {
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
1
|
+
import type { Figure, tSimTime } from 'geometrix';
|
|
2
|
+
declare const Drawing: import("svelte").Component<{
|
|
3
|
+
pDefSim: tSimTime;
|
|
4
|
+
pFig: Figure;
|
|
5
|
+
simTime?: number;
|
|
6
|
+
}, {}, "simTime">;
|
|
7
|
+
type Drawing = ReturnType<typeof Drawing>;
|
|
8
|
+
export default Drawing;
|