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
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { tPageDef, tAllLink } from 'geometrix';
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type OneDesignProps = typeof __propDef.props;
|
|
16
|
-
export type OneDesignEvents = typeof __propDef.events;
|
|
17
|
-
export type OneDesignSlots = typeof __propDef.slots;
|
|
18
|
-
export default class OneDesign extends SvelteComponent<OneDesignProps, OneDesignEvents, OneDesignSlots> {
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
2
|
+
declare const OneDesign: import("svelte").Component<{
|
|
3
|
+
pageDef: tPageDef;
|
|
4
|
+
pLink: tAllLink;
|
|
5
|
+
}, {}, "">;
|
|
6
|
+
type OneDesign = ReturnType<typeof OneDesign>;
|
|
7
|
+
export default OneDesign;
|
|
@@ -1,148 +1,218 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
function
|
|
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
|
-
}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type {
|
|
3
|
+
tParamDef,
|
|
4
|
+
tGeomFunc,
|
|
5
|
+
tSubDesign,
|
|
6
|
+
tAllLink,
|
|
7
|
+
tFigures,
|
|
8
|
+
Figure,
|
|
9
|
+
tGeom
|
|
10
|
+
} from 'geometrix';
|
|
11
|
+
import {
|
|
12
|
+
EFormat,
|
|
13
|
+
fileBinContent,
|
|
14
|
+
fileTextContent,
|
|
15
|
+
fileSuffix,
|
|
16
|
+
fileMime,
|
|
17
|
+
fileBin,
|
|
18
|
+
mergeFaces
|
|
19
|
+
} from 'geometrix';
|
|
20
|
+
import InputParams from './InputParams.svelte';
|
|
21
|
+
import Drawing from './Drawing.svelte';
|
|
22
|
+
import SubDesign from './SubDesign.svelte';
|
|
23
|
+
import { sParams } from './stateParams.svelte';
|
|
24
|
+
|
|
25
|
+
// properties
|
|
26
|
+
interface Props {
|
|
27
|
+
pDef: tParamDef;
|
|
28
|
+
fgeom: tGeomFunc;
|
|
29
|
+
pLink: tAllLink;
|
|
30
|
+
}
|
|
31
|
+
let { pDef, fgeom, pLink }: Props = $props();
|
|
32
|
+
|
|
33
|
+
// const
|
|
34
|
+
const c_ParametrixAll = 'ParametrixAll';
|
|
35
|
+
|
|
36
|
+
// helper function
|
|
37
|
+
function checkWarn(txt: string) {
|
|
38
|
+
let rWarn = true;
|
|
39
|
+
const re = /warn/i;
|
|
40
|
+
if (txt.search(re) < 0) {
|
|
41
|
+
rWarn = false;
|
|
42
|
+
}
|
|
43
|
+
return rWarn;
|
|
44
|
+
}
|
|
45
|
+
// create pFig
|
|
46
|
+
function checkFace(iFaces: string[], iFace: string): string {
|
|
47
|
+
let rFace = iFace;
|
|
48
|
+
if (iFaces.length === 0) {
|
|
49
|
+
console.log(`warn404: Drawing has an empty face list`);
|
|
50
|
+
} else {
|
|
51
|
+
//rFace = iFaces[0];
|
|
52
|
+
const FaceList2 = iFaces.slice();
|
|
53
|
+
FaceList2.push(c_ParametrixAll);
|
|
54
|
+
if (!FaceList2.includes(rFace)) {
|
|
55
|
+
//console.log(`warn403: Drawing has an invalid face ${rFace}`);
|
|
56
|
+
rFace = iFaces[0];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//console.log(iFaces);
|
|
60
|
+
//console.log(`dbg097: rFace ${rFace}`);
|
|
61
|
+
return rFace;
|
|
62
|
+
}
|
|
63
|
+
function selectFig(iFigures: tFigures, iFace: string) {
|
|
64
|
+
let rFig: Figure;
|
|
65
|
+
const FigListKeys = Object.keys(iFigures);
|
|
66
|
+
const sFace = checkFace(FigListKeys, iFace);
|
|
67
|
+
if (FigListKeys.includes(sFace)) {
|
|
68
|
+
rFig = iFigures[sFace];
|
|
69
|
+
} else {
|
|
70
|
+
rFig = mergeFaces(iFigures);
|
|
71
|
+
}
|
|
72
|
+
return rFig;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// state
|
|
76
|
+
let simTime: number = $state(0);
|
|
77
|
+
let selFace: string = $state(checkFace(Object.keys(fgeom(0, sParams[pDef.partName]).fig), ''));
|
|
78
|
+
// internal state that should not need state
|
|
79
|
+
let exportFace: string = $state('zip'); // TODO5 keep state otherwise svelte complains
|
|
80
|
+
|
|
81
|
+
// derived
|
|
82
|
+
let geome: tGeom = $derived(fgeom(simTime, sParams[pDef.partName]));
|
|
83
|
+
let logValue: string = $derived.by(() => {
|
|
84
|
+
const mydate = new Date().toLocaleTimeString();
|
|
85
|
+
let rLogValue = `Geometry ${pDef.partName} computed at ${mydate}\n`;
|
|
86
|
+
rLogValue += geome.logstr;
|
|
87
|
+
return rLogValue;
|
|
88
|
+
});
|
|
89
|
+
let optFaces: string[] = $derived(Object.keys(geome.fig));
|
|
90
|
+
let calcErr: boolean = $derived(geome.calcErr);
|
|
91
|
+
let calcWarn: boolean = $derived(checkWarn(geome.logstr));
|
|
92
|
+
let pFig: Figure = $derived(selectFig(geome.fig, selFace));
|
|
93
|
+
let subD: tSubDesign = $derived(geome.sub);
|
|
94
|
+
|
|
95
|
+
// actions: export drawings
|
|
96
|
+
function download_binFile(fName: string, fContent: Blob) {
|
|
97
|
+
//create temporary an invisible element
|
|
98
|
+
const elem_a_download = document.createElement('a');
|
|
99
|
+
//const payload = 'data:' + fMime + ';base64,' + fContent;
|
|
100
|
+
const payload = URL.createObjectURL(fContent);
|
|
101
|
+
elem_a_download.setAttribute('href', payload);
|
|
102
|
+
elem_a_download.setAttribute('download', fName);
|
|
103
|
+
//document.body.appendChild(elem_a_download); // it does not seem required to append the element to the DOM to use it
|
|
104
|
+
elem_a_download.click();
|
|
105
|
+
//document.body.removeChild(elem_a_download);
|
|
106
|
+
elem_a_download.remove(); // Is this really required?
|
|
107
|
+
URL.revokeObjectURL(payload);
|
|
108
|
+
}
|
|
109
|
+
function download_textFile(fName: string, fContent: string, fMime: string) {
|
|
110
|
+
//create temporary an invisible element
|
|
111
|
+
const elem_a_download = document.createElement('a');
|
|
112
|
+
const payload = 'data:' + fMime + ';utf-8,' + encodeURIComponent(fContent);
|
|
113
|
+
elem_a_download.setAttribute('href', payload);
|
|
114
|
+
elem_a_download.setAttribute('download', fName);
|
|
115
|
+
//document.body.appendChild(elem_a_download); // it does not seem required to append the element to the DOM to use it
|
|
116
|
+
elem_a_download.click();
|
|
117
|
+
//document.body.removeChild(elem_a_download);
|
|
118
|
+
elem_a_download.remove(); // Is this really required?
|
|
119
|
+
}
|
|
120
|
+
function dateString(): string {
|
|
121
|
+
const re1 = /[-:]/g;
|
|
122
|
+
const re2 = /\..*$/;
|
|
123
|
+
const rDateStr = new Date()
|
|
124
|
+
.toISOString()
|
|
125
|
+
.replace(re1, '')
|
|
126
|
+
.replace(re2, '')
|
|
127
|
+
.replace('T', '_');
|
|
128
|
+
return rDateStr;
|
|
129
|
+
}
|
|
130
|
+
async function downloadExport(iExportFace: string) {
|
|
131
|
+
//console.log(`dbg883: iExportFace ${iExportFace}`);
|
|
132
|
+
const reSvg = /^svg_/;
|
|
133
|
+
const reDxf = /^dxf_/;
|
|
134
|
+
let exportFormat = EFormat.eSVG;
|
|
135
|
+
let nFace = 'all';
|
|
136
|
+
if (iExportFace.match(reSvg)) {
|
|
137
|
+
exportFormat = EFormat.eSVG;
|
|
138
|
+
nFace = iExportFace.replace(reSvg, '');
|
|
139
|
+
} else if (iExportFace.match(reDxf)) {
|
|
140
|
+
exportFormat = EFormat.eDXF;
|
|
141
|
+
nFace = iExportFace.replace(reDxf, '');
|
|
142
|
+
} else if (iExportFace === 'allsvg') {
|
|
143
|
+
exportFormat = EFormat.eSVGALL;
|
|
144
|
+
} else if (iExportFace === 'alldxf') {
|
|
145
|
+
exportFormat = EFormat.eDXFALL;
|
|
146
|
+
} else if (iExportFace === 'compute_log') {
|
|
147
|
+
exportFormat = EFormat.eTXTLOG;
|
|
148
|
+
} else if (iExportFace === 'pax') {
|
|
149
|
+
exportFormat = EFormat.ePAX;
|
|
150
|
+
} else if (iExportFace === 'oscad') {
|
|
151
|
+
exportFormat = EFormat.eOPENSCAD;
|
|
152
|
+
} else if (iExportFace === 'ojscad') {
|
|
153
|
+
exportFormat = EFormat.eJSCAD;
|
|
154
|
+
} else if (iExportFace === 'freecad') {
|
|
155
|
+
exportFormat = EFormat.eFREECAD;
|
|
156
|
+
} else if (iExportFace === 'zip') {
|
|
157
|
+
exportFormat = EFormat.eZIP;
|
|
158
|
+
} else {
|
|
159
|
+
console.log(`err883: downloadExport iExportFace ${iExportFace} invalid`);
|
|
160
|
+
}
|
|
161
|
+
//console.log(`exportFormat ${exportFormat}`);
|
|
162
|
+
const fSuffix = fileSuffix(exportFormat);
|
|
163
|
+
const fMime = fileMime(exportFormat);
|
|
164
|
+
const fBin = fileBin(exportFormat);
|
|
165
|
+
const fName = pDef.partName + '_' + nFace + '_' + dateString() + fSuffix;
|
|
166
|
+
if (fBin) {
|
|
167
|
+
const fContent = await fileBinContent(
|
|
168
|
+
fgeom,
|
|
169
|
+
simTime,
|
|
170
|
+
sParams[pDef.partName],
|
|
171
|
+
pDef,
|
|
172
|
+
exportFormat
|
|
173
|
+
);
|
|
174
|
+
download_binFile(fName, fContent);
|
|
175
|
+
} else {
|
|
176
|
+
const fContent = fileTextContent(
|
|
177
|
+
fgeom,
|
|
178
|
+
sParams[pDef.partName],
|
|
179
|
+
pDef,
|
|
180
|
+
nFace,
|
|
181
|
+
exportFormat
|
|
182
|
+
);
|
|
183
|
+
download_textFile(fName, fContent, fMime);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async function downloadExport2() {
|
|
187
|
+
await downloadExport(exportFace);
|
|
188
|
+
}
|
|
130
189
|
</script>
|
|
131
190
|
|
|
132
|
-
<InputParams {pDef}
|
|
191
|
+
<InputParams {pDef} {pFig} />
|
|
133
192
|
<section>
|
|
134
193
|
<h2>Log</h2>
|
|
135
194
|
<textarea
|
|
136
195
|
rows="5"
|
|
137
196
|
cols="94"
|
|
138
197
|
readonly
|
|
139
|
-
wrap="
|
|
198
|
+
wrap="soft"
|
|
140
199
|
value={logValue}
|
|
141
200
|
class:colorErr={calcErr}
|
|
142
201
|
class:colorWarn={calcWarn}
|
|
143
|
-
|
|
202
|
+
></textarea>
|
|
203
|
+
</section>
|
|
204
|
+
<section>
|
|
205
|
+
<h2>
|
|
206
|
+
Drawing
|
|
207
|
+
<select bind:value={selFace}>
|
|
208
|
+
{#each optFaces as optFace}
|
|
209
|
+
<option value={optFace}>{optFace}</option>
|
|
210
|
+
{/each}
|
|
211
|
+
<option value={c_ParametrixAll}>All faces merged</option>
|
|
212
|
+
</select>
|
|
213
|
+
</h2>
|
|
144
214
|
</section>
|
|
145
|
-
<Drawing {pDef} {
|
|
215
|
+
<Drawing pDefSim={pDef.sim} {pFig} bind:simTime />
|
|
146
216
|
<section>
|
|
147
217
|
<h2>Export</h2>
|
|
148
218
|
<select bind:value={exportFace}>
|
|
@@ -161,7 +231,7 @@ async function downloadExport2() {
|
|
|
161
231
|
<option value="freecad">all faces as Freecad.py</option>
|
|
162
232
|
<option value="zip">all faces and more as zip</option>
|
|
163
233
|
</select>
|
|
164
|
-
<button
|
|
234
|
+
<button onclick={downloadExport2}>Save to File</button>
|
|
165
235
|
<SubDesign {subD} origPartName={pDef.partName} {pLink} />
|
|
166
236
|
</section>
|
|
167
237
|
|
|
@@ -178,6 +248,22 @@ section > h2 {
|
|
|
178
248
|
margin: 1rem 0.5rem 0;
|
|
179
249
|
}
|
|
180
250
|
|
|
251
|
+
section > h2 > select {
|
|
252
|
+
/*display: inline-block;*/
|
|
253
|
+
height: 1.6rem;
|
|
254
|
+
/*width: 1.6rem;*/
|
|
255
|
+
color: darkBlue;
|
|
256
|
+
font-size: 0.8rem;
|
|
257
|
+
font-weight: 400;
|
|
258
|
+
padding: 0.2rem 0.4rem 0.2rem;
|
|
259
|
+
border-style: solid;
|
|
260
|
+
border-width: 0.1rem;
|
|
261
|
+
border-radius: 0.2rem;
|
|
262
|
+
border-color: darkBlue;
|
|
263
|
+
margin: 0.5rem;
|
|
264
|
+
background-color: lightBlue;
|
|
265
|
+
}
|
|
266
|
+
|
|
181
267
|
section > textarea {
|
|
182
268
|
/*resize: horizontal;*/
|
|
183
269
|
margin-left: 0.5rem;
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { tParamDef, tGeomFunc, tAllLink } from 'geometrix';
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
};
|
|
12
|
-
slots: {};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type ParamDrawExportProps = typeof __propDef.props;
|
|
17
|
-
export type ParamDrawExportEvents = typeof __propDef.events;
|
|
18
|
-
export type ParamDrawExportSlots = typeof __propDef.slots;
|
|
19
|
-
export default class ParamDrawExport extends SvelteComponent<ParamDrawExportProps, ParamDrawExportEvents, ParamDrawExportSlots> {
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
2
|
+
declare const ParamDrawExport: import("svelte").Component<{
|
|
3
|
+
pDef: tParamDef;
|
|
4
|
+
fgeom: tGeomFunc;
|
|
5
|
+
pLink: tAllLink;
|
|
6
|
+
}, {}, "">;
|
|
7
|
+
type ParamDrawExport = ReturnType<typeof ParamDrawExport>;
|
|
8
|
+
export default ParamDrawExport;
|
|
@@ -1,54 +1,87 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { tCanvasAdjust, tLayers, Figure } from 'geometrix';
|
|
3
|
+
import { adjustMini, copyLayers } from 'geometrix';
|
|
4
|
+
import { sDraw } from './stateDrawing.svelte';
|
|
5
|
+
|
|
6
|
+
// props
|
|
7
|
+
interface Props {
|
|
8
|
+
pFig: Figure;
|
|
9
|
+
full: boolean;
|
|
10
|
+
}
|
|
11
|
+
let { pFig, full }: Props = $props();
|
|
12
|
+
|
|
13
|
+
// const
|
|
14
|
+
const canvas_size_mini = 200;
|
|
15
|
+
const scaleFactor = 0.6;
|
|
16
|
+
|
|
17
|
+
// internal state: no need of reactivity with $state()
|
|
18
|
+
let canvasMini: HTMLCanvasElement;
|
|
19
|
+
|
|
20
|
+
// Canavas Figures
|
|
21
|
+
function canvasRedrawMini(
|
|
22
|
+
aFigure: Figure,
|
|
23
|
+
iZAdjust: tCanvasAdjust,
|
|
24
|
+
iCZwidth: number,
|
|
25
|
+
iLayers: tLayers
|
|
26
|
+
) {
|
|
27
|
+
const sLayers = copyLayers(iLayers);
|
|
28
|
+
sLayers.ruler = false;
|
|
29
|
+
let mAdjust: tCanvasAdjust;
|
|
30
|
+
if (canvasMini) {
|
|
31
|
+
const ctx1 = canvasMini.getContext('2d')!;
|
|
32
|
+
ctx1.clearRect(0, 0, ctx1.canvas.width, ctx1.canvas.height);
|
|
33
|
+
const c1w = ctx1.canvas.width;
|
|
34
|
+
try {
|
|
35
|
+
if (full) {
|
|
36
|
+
// mini-full with zAdjust set to adjustZero()
|
|
37
|
+
mAdjust = aFigure.getAdjustFull(ctx1.canvas.width, ctx1.canvas.height);
|
|
38
|
+
} else {
|
|
39
|
+
mAdjust = adjustMini(iCZwidth, c1w, iZAdjust);
|
|
40
|
+
}
|
|
41
|
+
aFigure.draw(ctx1, mAdjust, sLayers);
|
|
42
|
+
} catch (emsg) {
|
|
43
|
+
//rGeome.logstr += emsg;
|
|
44
|
+
console.log(emsg);
|
|
45
|
+
}
|
|
46
|
+
// extra drawing
|
|
47
|
+
//point(5, 5).draw(ctx1, mAdjust, 'green');
|
|
48
|
+
//point(5, 15).draw(ctx1, mAdjust, 'blue', 'rectangle');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// reactivity
|
|
52
|
+
$effect(() => {
|
|
53
|
+
canvasRedrawMini(pFig, sDraw.zAdjust, sDraw.canvasZWidth, sDraw.dLayers);
|
|
54
|
+
});
|
|
55
|
+
// actions
|
|
56
|
+
function clickQuater(eve: MouseEvent) {
|
|
57
|
+
const mouseX = eve.offsetX;
|
|
58
|
+
const mouseY = eve.offsetY;
|
|
59
|
+
const ctx1 = canvasMini.getContext('2d')!;
|
|
60
|
+
const quaterX = ctx1.canvas.width / 2;
|
|
61
|
+
const quaterY = ctx1.canvas.height / 2;
|
|
62
|
+
if (eve.button === 0) {
|
|
63
|
+
// pressing the main button
|
|
64
|
+
let quaterID = 1;
|
|
65
|
+
if (mouseX > quaterX) {
|
|
66
|
+
quaterID += 1 * scaleFactor;
|
|
67
|
+
}
|
|
68
|
+
if (mouseY > quaterY) {
|
|
69
|
+
quaterID += 2 * scaleFactor;
|
|
70
|
+
}
|
|
71
|
+
ctx1.canvas.width = quaterID * canvas_size_mini;
|
|
72
|
+
ctx1.canvas.height = quaterID * canvas_size_mini;
|
|
73
|
+
canvasRedrawMini(pFig, sDraw.zAdjust, sDraw.canvasZWidth, sDraw.dLayers);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
49
76
|
</script>
|
|
50
77
|
|
|
51
|
-
<canvas
|
|
78
|
+
<canvas
|
|
79
|
+
class="mini"
|
|
80
|
+
width={canvas_size_mini}
|
|
81
|
+
height={canvas_size_mini}
|
|
82
|
+
bind:this={canvasMini}
|
|
83
|
+
onclick={clickQuater}
|
|
84
|
+
></canvas>
|
|
52
85
|
|
|
53
86
|
<style>/*
|
|
54
87
|
$canvas-point: grey;
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
zAdjust: tCanvasAdjust;
|
|
9
|
-
simTime?: number;
|
|
10
|
-
};
|
|
11
|
-
events: {
|
|
12
|
-
[evt: string]: CustomEvent<any>;
|
|
13
|
-
};
|
|
14
|
-
slots: {};
|
|
15
|
-
exports?: {} | undefined;
|
|
16
|
-
bindings?: string | undefined;
|
|
17
|
-
};
|
|
18
|
-
export type SimpleDrawingProps = typeof __propDef.props;
|
|
19
|
-
export type SimpleDrawingEvents = typeof __propDef.events;
|
|
20
|
-
export type SimpleDrawingSlots = typeof __propDef.slots;
|
|
21
|
-
export default class SimpleDrawing extends SvelteComponent<SimpleDrawingProps, SimpleDrawingEvents, SimpleDrawingSlots> {
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
1
|
+
import type { Figure } from 'geometrix';
|
|
2
|
+
declare const SimpleDrawing: import("svelte").Component<{
|
|
3
|
+
pFig: Figure;
|
|
4
|
+
full: boolean;
|
|
5
|
+
}, {}, "">;
|
|
6
|
+
type SimpleDrawing = ReturnType<typeof SimpleDrawing>;
|
|
7
|
+
export default SimpleDrawing;
|