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,20 +1,22 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { tPageDef, tAllLink } from 'geometrix';
3
- declare const __propDef: {
4
- props: {
5
- pageDef: tPageDef;
6
- pLink: tAllLink;
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;
7
12
  };
8
- events: {
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> {
13
+ z_$$bindings?: Bindings;
19
14
  }
20
- export {};
15
+ declare const OneDesign: $$__sveltets_2_IsomorphicComponent<{
16
+ pageDef: tPageDef;
17
+ pLink: tAllLink;
18
+ }, {
19
+ [evt: string]: CustomEvent<any>;
20
+ }, {}, {}, string>;
21
+ type OneDesign = InstanceType<typeof OneDesign>;
22
+ export default OneDesign;
@@ -1,132 +1,152 @@
1
- <script>import {
2
- EFormat,
3
- fileBinContent,
4
- fileTextContent,
5
- fileSuffix,
6
- fileMime,
7
- fileBin,
8
- adjustZero
9
- } from "geometrix";
10
- import InputParams from "./InputParams.svelte";
11
- import Drawing from "./Drawing.svelte";
12
- import SubDesign from "./SubDesign.svelte";
13
- import { storePV } from "./storePVal";
14
- export let pDef;
15
- export let fgeom;
16
- export let pLink;
17
- function checkWarn(txt) {
18
- let rWarn = true;
19
- const re = /warn/i;
20
- if (txt.search(re) < 0) {
21
- rWarn = false;
22
- }
23
- return rWarn;
24
- }
25
- let optFaces = [];
26
- let exportFace;
27
- let selFace;
28
- let simTime = 0;
29
- let zAdjust = adjustZero();
30
- let logValue = "Dummy initial\nWill be replaced during onMount\n";
31
- let calcErr = false;
32
- let calcWarn = false;
33
- let subD = {};
34
- function paramChange2(iPageName, iSimTime) {
35
- const mydate = (/* @__PURE__ */ new Date()).toLocaleTimeString();
36
- logValue = `Geometry ${iPageName} computed at ${mydate}
37
- `;
38
- const geome = fgeom(iSimTime, $storePV[pDef.partName]);
39
- logValue += geome.logstr;
40
- calcErr = geome.calcErr;
41
- calcWarn = checkWarn(geome.logstr);
42
- optFaces = Object.keys(geome.fig);
43
- exportFace = "zip";
44
- subD = geome.sub;
45
- }
46
- function paramChange() {
47
- paramChange2(pDef.partName, simTime);
48
- }
49
- $: paramChange2(pDef.partName, simTime);
50
- function download_binFile(fName, fContent) {
51
- const elem_a_download = document.createElement("a");
52
- const payload = URL.createObjectURL(fContent);
53
- elem_a_download.setAttribute("href", payload);
54
- elem_a_download.setAttribute("download", fName);
55
- elem_a_download.click();
56
- elem_a_download.remove();
57
- URL.revokeObjectURL(payload);
58
- }
59
- function download_textFile(fName, fContent, fMime) {
60
- const elem_a_download = document.createElement("a");
61
- const payload = "data:" + fMime + ";utf-8," + encodeURIComponent(fContent);
62
- elem_a_download.setAttribute("href", payload);
63
- elem_a_download.setAttribute("download", fName);
64
- elem_a_download.click();
65
- elem_a_download.remove();
66
- }
67
- function dateString() {
68
- const re1 = /[-:]/g;
69
- const re2 = /\..*$/;
70
- const rDateStr = (/* @__PURE__ */ new Date()).toISOString().replace(re1, "").replace(re2, "").replace("T", "_");
71
- return rDateStr;
72
- }
73
- async function downloadExport(iExportFace) {
74
- const reSvg = /^svg_/;
75
- const reDxf = /^dxf_/;
76
- let exportFormat = EFormat.eSVG;
77
- let nFace = "all";
78
- if (iExportFace.match(reSvg)) {
79
- exportFormat = EFormat.eSVG;
80
- nFace = iExportFace.replace(reSvg, "");
81
- } else if (iExportFace.match(reDxf)) {
82
- exportFormat = EFormat.eDXF;
83
- nFace = iExportFace.replace(reDxf, "");
84
- } else if (iExportFace === "allsvg") {
85
- exportFormat = EFormat.eSVGALL;
86
- } else if (iExportFace === "alldxf") {
87
- exportFormat = EFormat.eDXFALL;
88
- } else if (iExportFace === "compute_log") {
89
- exportFormat = EFormat.eTXTLOG;
90
- } else if (iExportFace === "pax") {
91
- exportFormat = EFormat.ePAX;
92
- } else if (iExportFace === "oscad") {
93
- exportFormat = EFormat.eOPENSCAD;
94
- } else if (iExportFace === "ojscad") {
95
- exportFormat = EFormat.eJSCAD;
96
- } else if (iExportFace === "freecad") {
97
- exportFormat = EFormat.eFREECAD;
98
- } else if (iExportFace === "zip") {
99
- exportFormat = EFormat.eZIP;
100
- } else {
101
- console.log(`err883: downloadExport iExportFace ${iExportFace} invalid`);
102
- }
103
- const fSuffix = fileSuffix(exportFormat);
104
- const fMime = fileMime(exportFormat);
105
- const fBin = fileBin(exportFormat);
106
- const fName = pDef.partName + "_" + nFace + "_" + dateString() + fSuffix;
107
- if (fBin) {
108
- const fContent = await fileBinContent(
109
- fgeom,
110
- simTime,
111
- $storePV[pDef.partName],
112
- pDef,
113
- exportFormat
114
- );
115
- download_binFile(fName, fContent);
116
- } else {
117
- const fContent = fileTextContent(
118
- fgeom,
119
- $storePV[pDef.partName],
120
- pDef,
121
- nFace,
122
- exportFormat
123
- );
124
- download_textFile(fName, fContent, fMime);
125
- }
126
- }
127
- async function downloadExport2() {
128
- await downloadExport(exportFace);
129
- }
1
+ <script lang="ts">
2
+ //import type { tParamDef, tGeomFunc, tSubDesign, tAllLink, tCanvasAdjust } from 'geometrix';
3
+ import type { tParamDef, tGeomFunc, tSubDesign, tAllLink } from 'geometrix';
4
+ import {
5
+ EFormat,
6
+ fileBinContent,
7
+ fileTextContent,
8
+ fileSuffix,
9
+ fileMime,
10
+ fileBin,
11
+ adjustZero
12
+ } from 'geometrix';
13
+ import InputParams from './InputParams.svelte';
14
+ import Drawing from './Drawing.svelte';
15
+ import SubDesign from './SubDesign.svelte';
16
+ import { storePV } from './storePVal';
17
+
18
+ export let pDef: tParamDef;
19
+ export let fgeom: tGeomFunc;
20
+ export let pLink: tAllLink;
21
+
22
+ function checkWarn(txt: string) {
23
+ let rWarn = true;
24
+ const re = /warn/i;
25
+ if (txt.search(re) < 0) {
26
+ rWarn = false;
27
+ }
28
+ return rWarn;
29
+ }
30
+ let optFaces: string[] = [];
31
+ let exportFace: string;
32
+ let selFace: string;
33
+ let simTime = 0;
34
+ let zAdjust = adjustZero();
35
+ // log and paramChange
36
+ let logValue = 'Dummy initial\nWill be replaced during onMount\n';
37
+ let calcErr = false;
38
+ let calcWarn = false;
39
+ let subD: tSubDesign = {};
40
+ function paramChange2(iPageName: string, iSimTime: number) {
41
+ const mydate = new Date().toLocaleTimeString();
42
+ logValue = `Geometry ${iPageName} computed at ${mydate}\n`;
43
+ const geome = fgeom(iSimTime, $storePV[pDef.partName]);
44
+ logValue += geome.logstr;
45
+ calcErr = geome.calcErr;
46
+ calcWarn = checkWarn(geome.logstr);
47
+ optFaces = Object.keys(geome.fig);
48
+ exportFace = 'zip';
49
+ //geomRedraw(iSimTime);
50
+ subD = geome.sub;
51
+ }
52
+ function paramChange() {
53
+ paramChange2(pDef.partName, simTime);
54
+ }
55
+ $: paramChange2(pDef.partName, simTime); // for reactivity on page change and simTime
56
+ // export drawings
57
+ function download_binFile(fName: string, fContent: Blob) {
58
+ //create temporary an invisible element
59
+ const elem_a_download = document.createElement('a');
60
+ //const payload = 'data:' + fMime + ';base64,' + fContent;
61
+ const payload = URL.createObjectURL(fContent);
62
+ elem_a_download.setAttribute('href', payload);
63
+ elem_a_download.setAttribute('download', fName);
64
+ //document.body.appendChild(elem_a_download); // it does not seem required to append the element to the DOM to use it
65
+ elem_a_download.click();
66
+ //document.body.removeChild(elem_a_download);
67
+ elem_a_download.remove(); // Is this really required?
68
+ URL.revokeObjectURL(payload);
69
+ }
70
+ function download_textFile(fName: string, fContent: string, fMime: string) {
71
+ //create temporary an invisible element
72
+ const elem_a_download = document.createElement('a');
73
+ const payload = 'data:' + fMime + ';utf-8,' + encodeURIComponent(fContent);
74
+ elem_a_download.setAttribute('href', payload);
75
+ elem_a_download.setAttribute('download', fName);
76
+ //document.body.appendChild(elem_a_download); // it does not seem required to append the element to the DOM to use it
77
+ elem_a_download.click();
78
+ //document.body.removeChild(elem_a_download);
79
+ elem_a_download.remove(); // Is this really required?
80
+ }
81
+ function dateString(): string {
82
+ const re1 = /[-:]/g;
83
+ const re2 = /\..*$/;
84
+ const rDateStr = new Date()
85
+ .toISOString()
86
+ .replace(re1, '')
87
+ .replace(re2, '')
88
+ .replace('T', '_');
89
+ return rDateStr;
90
+ }
91
+ async function downloadExport(iExportFace: string) {
92
+ //console.log(`dbg883: iExportFace ${iExportFace}`);
93
+ const reSvg = /^svg_/;
94
+ const reDxf = /^dxf_/;
95
+ let exportFormat = EFormat.eSVG;
96
+ let nFace = 'all';
97
+ if (iExportFace.match(reSvg)) {
98
+ exportFormat = EFormat.eSVG;
99
+ nFace = iExportFace.replace(reSvg, '');
100
+ } else if (iExportFace.match(reDxf)) {
101
+ exportFormat = EFormat.eDXF;
102
+ nFace = iExportFace.replace(reDxf, '');
103
+ } else if (iExportFace === 'allsvg') {
104
+ exportFormat = EFormat.eSVGALL;
105
+ } else if (iExportFace === 'alldxf') {
106
+ exportFormat = EFormat.eDXFALL;
107
+ } else if (iExportFace === 'compute_log') {
108
+ exportFormat = EFormat.eTXTLOG;
109
+ } else if (iExportFace === 'pax') {
110
+ exportFormat = EFormat.ePAX;
111
+ } else if (iExportFace === 'oscad') {
112
+ exportFormat = EFormat.eOPENSCAD;
113
+ } else if (iExportFace === 'ojscad') {
114
+ exportFormat = EFormat.eJSCAD;
115
+ } else if (iExportFace === 'freecad') {
116
+ exportFormat = EFormat.eFREECAD;
117
+ } else if (iExportFace === 'zip') {
118
+ exportFormat = EFormat.eZIP;
119
+ } else {
120
+ console.log(`err883: downloadExport iExportFace ${iExportFace} invalid`);
121
+ }
122
+ //console.log(`exportFormat ${exportFormat}`);
123
+ const fSuffix = fileSuffix(exportFormat);
124
+ const fMime = fileMime(exportFormat);
125
+ const fBin = fileBin(exportFormat);
126
+ const fName = pDef.partName + '_' + nFace + '_' + dateString() + fSuffix;
127
+ if (fBin) {
128
+ const fContent = await fileBinContent(
129
+ fgeom,
130
+ simTime,
131
+ $storePV[pDef.partName],
132
+ pDef,
133
+ exportFormat
134
+ );
135
+ download_binFile(fName, fContent);
136
+ } else {
137
+ const fContent = fileTextContent(
138
+ fgeom,
139
+ $storePV[pDef.partName],
140
+ pDef,
141
+ nFace,
142
+ exportFormat
143
+ );
144
+ download_textFile(fName, fContent, fMime);
145
+ }
146
+ }
147
+ async function downloadExport2() {
148
+ await downloadExport(exportFace);
149
+ }
130
150
  </script>
131
151
 
132
152
  <InputParams {pDef} on:paramChg={paramChange} {fgeom} {selFace} {zAdjust} {simTime} />
@@ -136,11 +156,11 @@ async function downloadExport2() {
136
156
  rows="5"
137
157
  cols="94"
138
158
  readonly
139
- wrap="off"
159
+ wrap="soft"
140
160
  value={logValue}
141
161
  class:colorErr={calcErr}
142
162
  class:colorWarn={calcWarn}
143
- />
163
+ ></textarea>
144
164
  </section>
145
165
  <Drawing {pDef} {fgeom} {optFaces} bind:selFace bind:zAdjust bind:simTime />
146
166
  <section>
@@ -1,21 +1,23 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { tParamDef, tGeomFunc, tAllLink } from 'geometrix';
3
- declare const __propDef: {
4
- props: {
5
- pDef: tParamDef;
6
- fgeom: tGeomFunc;
7
- pLink: tAllLink;
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;
8
12
  };
9
- events: {
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> {
13
+ z_$$bindings?: Bindings;
20
14
  }
21
- export {};
15
+ declare const ParamDrawExport: $$__sveltets_2_IsomorphicComponent<{
16
+ pDef: tParamDef;
17
+ fgeom: tGeomFunc;
18
+ pLink: tAllLink;
19
+ }, {
20
+ [evt: string]: CustomEvent<any>;
21
+ }, {}, {}, string>;
22
+ type ParamDrawExport = InstanceType<typeof ParamDrawExport>;
23
+ export default ParamDrawExport;
@@ -1,54 +1,70 @@
1
- <script>import { copyLayers, mergeFaces } from "geometrix";
2
- import { storePV } from "./storePVal";
3
- import { dLayers } from "./drawingLayers";
4
- import { onMount } from "svelte";
5
- export let pageName;
6
- export let fgeom;
7
- export let selFace;
8
- export let zAdjust;
9
- export let simTime = 0;
10
- let canvasMini;
11
- const canvas_size_mini = 200;
12
- let mAdjust;
13
- function canvasRedrawMini(aFigure, iLayers) {
14
- const sLayers = copyLayers(iLayers);
15
- sLayers.ruler = false;
16
- const ctx1 = canvasMini.getContext("2d");
17
- ctx1.clearRect(0, 0, ctx1.canvas.width, ctx1.canvas.height);
18
- try {
19
- if (zAdjust.init === 0) {
20
- mAdjust = aFigure.getAdjustFull(ctx1.canvas.width, ctx1.canvas.height);
21
- } else {
22
- mAdjust = zAdjust;
23
- }
24
- aFigure.draw(ctx1, mAdjust, sLayers);
25
- } catch (emsg) {
26
- console.log(emsg);
27
- }
28
- }
29
- let domInit = 0;
30
- function geomRedraw(iSimTime, ipVal, iFace, iLayers) {
31
- const FigList = fgeom(iSimTime, ipVal).fig;
32
- if (Object.keys(FigList).includes(iFace)) {
33
- const aFigure = FigList[iFace];
34
- canvasRedrawMini(aFigure, iLayers);
35
- } else {
36
- const aFigure = mergeFaces(FigList);
37
- canvasRedrawMini(aFigure, iLayers);
38
- }
39
- }
40
- onMount(() => {
41
- geomRedraw(simTime, $storePV[pageName], selFace, $dLayers);
42
- domInit = 1;
43
- });
44
- $: {
45
- if (domInit === 1) {
46
- geomRedraw(simTime, $storePV[pageName], selFace, $dLayers);
47
- }
48
- }
1
+ <script lang="ts">
2
+ //import { colors } from 'geometrix';
3
+ import type { tCanvasAdjust, tLayers, Figure, tParamVal, tGeomFunc } from 'geometrix';
4
+ import { copyLayers, mergeFaces } from 'geometrix';
5
+ import { storePV } from './storePVal';
6
+ import { dLayers } from './drawingLayers';
7
+ import { onMount } from 'svelte';
8
+
9
+ export let pageName: string;
10
+ export let fgeom: tGeomFunc;
11
+ export let selFace: string;
12
+ export let zAdjust: tCanvasAdjust;
13
+ export let simTime = 0;
14
+
15
+ let canvasMini: HTMLCanvasElement;
16
+ const canvas_size_mini = 200;
17
+
18
+ // Canavas Figures
19
+ let mAdjust: tCanvasAdjust;
20
+ function canvasRedrawMini(aFigure: Figure, iLayers: tLayers) {
21
+ const sLayers = copyLayers(iLayers);
22
+ sLayers.ruler = false;
23
+ const ctx1 = canvasMini.getContext('2d')!;
24
+ ctx1.clearRect(0, 0, ctx1.canvas.width, ctx1.canvas.height);
25
+ try {
26
+ if (zAdjust.init === 0) {
27
+ // mini-full with zAdjust set to adjustZero()
28
+ mAdjust = aFigure.getAdjustFull(ctx1.canvas.width, ctx1.canvas.height);
29
+ } else {
30
+ mAdjust = zAdjust;
31
+ }
32
+ aFigure.draw(ctx1, mAdjust, sLayers);
33
+ } catch (emsg) {
34
+ //rGeome.logstr += emsg;
35
+ console.log(emsg);
36
+ }
37
+ // extra drawing
38
+ //point(5, 5).draw(ctx1, mAdjust, 'green');
39
+ //point(5, 15).draw(ctx1, mAdjust, 'blue', 'rectangle');
40
+ }
41
+ let domInit = 0;
42
+ function geomRedraw(iSimTime: number, ipVal: tParamVal, iFace: string, iLayers: tLayers) {
43
+ const FigList = fgeom(iSimTime, ipVal).fig;
44
+ if (Object.keys(FigList).includes(iFace)) {
45
+ const aFigure = FigList[iFace];
46
+ canvasRedrawMini(aFigure, iLayers);
47
+ } else {
48
+ const aFigure = mergeFaces(FigList);
49
+ canvasRedrawMini(aFigure, iLayers);
50
+ }
51
+ }
52
+ onMount(() => {
53
+ // initial drawing
54
+ geomRedraw(simTime, $storePV[pageName], selFace, $dLayers);
55
+ domInit = 1;
56
+ //paramChange();
57
+ });
58
+ // reactivity on simTime and $storePV
59
+ $: {
60
+ if (domInit === 1) {
61
+ geomRedraw(simTime, $storePV[pageName], selFace, $dLayers);
62
+ }
63
+ }
49
64
  </script>
50
65
 
51
- <canvas class="mini" width={canvas_size_mini} height={canvas_size_mini} bind:this={canvasMini} />
66
+ <canvas class="mini" width={canvas_size_mini} height={canvas_size_mini} bind:this={canvasMini}
67
+ ></canvas>
52
68
 
53
69
  <style>/*
54
70
  $canvas-point: grey;
@@ -1,23 +1,25 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { tCanvasAdjust, tGeomFunc } from 'geometrix';
3
- declare const __propDef: {
4
- props: {
5
- pageName: string;
6
- fgeom: tGeomFunc;
7
- selFace: string;
8
- zAdjust: tCanvasAdjust;
9
- 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;
10
12
  };
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> {
13
+ z_$$bindings?: Bindings;
22
14
  }
23
- export {};
15
+ declare const SimpleDrawing: $$__sveltets_2_IsomorphicComponent<{
16
+ pageName: string;
17
+ fgeom: tGeomFunc;
18
+ selFace: string;
19
+ zAdjust: tCanvasAdjust;
20
+ simTime?: number;
21
+ }, {
22
+ [evt: string]: CustomEvent<any>;
23
+ }, {}, {}, string>;
24
+ type SimpleDrawing = InstanceType<typeof SimpleDrawing>;
25
+ export default SimpleDrawing;