smithkit 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +467 -2
- package/dist/lib/Smith.d.ts +103 -0
- package/dist/lib/Smith.js +562 -0
- package/dist/lib/SmithArcsDefs.d.ts +10 -0
- package/dist/lib/SmithArcsDefs.js +10 -0
- package/dist/lib/SmithConstantCircle.d.ts +62 -0
- package/dist/lib/SmithConstantCircle.js +222 -0
- package/dist/lib/arcs/Tick.d.ts +33 -0
- package/dist/lib/arcs/Tick.js +40 -0
- package/dist/lib/complex/Complex.d.ts +130 -0
- package/dist/lib/complex/Complex.js +636 -0
- package/dist/lib/components.d.ts +14 -0
- package/dist/lib/components.js +26 -0
- package/dist/lib/draw/ConstCircles.d.ts +63 -0
- package/dist/lib/draw/ConstCircles.js +158 -0
- package/dist/lib/draw/ConstConductance.d.ts +4 -0
- package/dist/lib/draw/ConstConductance.js +6 -0
- package/dist/lib/draw/ConstQCircles.d.ts +29 -0
- package/dist/lib/draw/ConstQCircles.js +86 -0
- package/dist/lib/draw/ConstReactance.d.ts +4 -0
- package/dist/lib/draw/ConstReactance.js +6 -0
- package/dist/lib/draw/ConstResistance.d.ts +4 -0
- package/dist/lib/draw/ConstResistance.js +6 -0
- package/dist/lib/draw/ConstSusceptance.d.ts +4 -0
- package/dist/lib/draw/ConstSusceptance.js +6 -0
- package/dist/lib/draw/ConstSwrCircles.d.ts +29 -0
- package/dist/lib/draw/ConstSwrCircles.js +85 -0
- package/dist/lib/draw/MouseGesture.d.ts +6 -0
- package/dist/lib/draw/MouseGesture.js +26 -0
- package/dist/lib/draw/SmithArc.d.ts +10 -0
- package/dist/lib/draw/SmithArc.js +26 -0
- package/dist/lib/draw/SmithCircle.d.ts +10 -0
- package/dist/lib/draw/SmithCircle.js +24 -0
- package/dist/lib/draw/SmithCursor.d.ts +49 -0
- package/dist/lib/draw/SmithCursor.js +186 -0
- package/dist/lib/draw/SmithData.d.ts +66 -0
- package/dist/lib/draw/SmithData.js +366 -0
- package/dist/lib/draw/SmithDrawOptions.d.ts +5 -0
- package/dist/lib/draw/SmithDrawOptions.js +1 -0
- package/dist/lib/draw/SmithGridLayer.d.ts +19 -0
- package/dist/lib/draw/SmithGridLayer.js +48 -0
- package/dist/lib/draw/SmithGroup.d.ts +11 -0
- package/dist/lib/draw/SmithGroup.js +31 -0
- package/dist/lib/draw/SmithLine.d.ts +11 -0
- package/dist/lib/draw/SmithLine.js +27 -0
- package/dist/lib/draw/SmithMarker.d.ts +25 -0
- package/dist/lib/draw/SmithMarker.js +122 -0
- package/dist/lib/draw/SmithPath.d.ts +8 -0
- package/dist/lib/draw/SmithPath.js +20 -0
- package/dist/lib/draw/SmithScaler.d.ts +19 -0
- package/dist/lib/draw/SmithScaler.js +48 -0
- package/dist/lib/draw/SmithShape.d.ts +15 -0
- package/dist/lib/draw/SmithShape.js +42 -0
- package/dist/lib/draw/SmithSvg.d.ts +9 -0
- package/dist/lib/draw/SmithSvg.js +27 -0
- package/dist/lib/draw/SmithText.d.ts +22 -0
- package/dist/lib/draw/SmithText.js +56 -0
- package/dist/lib/formatting.d.ts +7 -0
- package/dist/lib/formatting.js +16 -0
- package/dist/lib/grid/definitions.d.ts +3 -0
- package/dist/lib/grid/definitions.js +123 -0
- package/dist/lib/grid/geometry.d.ts +20 -0
- package/dist/lib/grid/geometry.js +55 -0
- package/dist/lib/grid/labels.d.ts +3 -0
- package/dist/lib/grid/labels.js +41 -0
- package/dist/lib/grid/types.d.ts +30 -0
- package/dist/lib/grid/types.js +6 -0
- package/dist/lib/index.d.ts +16 -0
- package/dist/lib/index.js +9 -0
- package/dist/lib/io/touchstone.d.ts +7 -0
- package/dist/lib/io/touchstone.js +72 -0
- package/dist/lib/layers.d.ts +48 -0
- package/dist/lib/layers.js +73 -0
- package/dist/lib/math/complexRatio.d.ts +3 -0
- package/dist/lib/math/complexRatio.js +30 -0
- package/dist/lib/measurements.d.ts +53 -0
- package/dist/lib/measurements.js +19 -0
- package/dist/lib/renormalization.d.ts +10 -0
- package/dist/lib/renormalization.js +62 -0
- package/dist/lib/rf.d.ts +35 -0
- package/dist/lib/rf.js +74 -0
- package/dist/lib/samples.d.ts +6 -0
- package/dist/lib/samples.js +1 -0
- package/dist/lib/scales/SmithPeripheralScales.d.ts +13 -0
- package/dist/lib/scales/SmithPeripheralScales.js +141 -0
- package/dist/lib/scales/SmithScales.d.ts +16 -0
- package/dist/lib/scales/SmithScales.js +142 -0
- package/dist/lib/scales/peripheralScales.d.ts +12 -0
- package/dist/lib/scales/peripheralScales.js +49 -0
- package/dist/lib/scales/radialScales.d.ts +12 -0
- package/dist/lib/scales/radialScales.js +109 -0
- package/dist/lib/shapes/Arc.d.ts +6 -0
- package/dist/lib/shapes/Arc.js +1 -0
- package/dist/lib/shapes/Circle.d.ts +5 -0
- package/dist/lib/shapes/Circle.js +1 -0
- package/dist/lib/shapes/Line.d.ts +5 -0
- package/dist/lib/shapes/Line.js +1 -0
- package/dist/lib/shapes/Point.d.ts +1 -0
- package/dist/lib/shapes/Point.js +1 -0
- package/package.json +76 -4
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type * as d3 from 'd3';
|
|
2
|
+
import { SmithGroup } from './SmithGroup.js';
|
|
3
|
+
import { SmithScaler } from './SmithScaler.js';
|
|
4
|
+
import { Line } from '../shapes/Line.js';
|
|
5
|
+
import { Circle } from '../shapes/Circle.js';
|
|
6
|
+
import { Point } from '../shapes/Point.js';
|
|
7
|
+
import { SmithConstantCircle } from '../SmithConstantCircle.js';
|
|
8
|
+
export interface ArcData {
|
|
9
|
+
p1: Point;
|
|
10
|
+
p2: Point;
|
|
11
|
+
r: number;
|
|
12
|
+
largeArc: string;
|
|
13
|
+
sweep: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Shapes {
|
|
16
|
+
lines: Line[];
|
|
17
|
+
circles: Circle[];
|
|
18
|
+
arcs: ArcData[];
|
|
19
|
+
}
|
|
20
|
+
export interface ConstCirclesDrawOptions {
|
|
21
|
+
stroke: string;
|
|
22
|
+
minorWidth: string;
|
|
23
|
+
majorWidth: string;
|
|
24
|
+
textColor: string;
|
|
25
|
+
textFontFamily: string;
|
|
26
|
+
textFontSize: string;
|
|
27
|
+
}
|
|
28
|
+
export declare abstract class ConstCircles {
|
|
29
|
+
protected scaler: SmithScaler;
|
|
30
|
+
protected calcs: SmithConstantCircle;
|
|
31
|
+
protected container: SmithGroup;
|
|
32
|
+
protected opts: ConstCirclesDrawOptions;
|
|
33
|
+
protected abstract major: SmithGroup;
|
|
34
|
+
protected abstract minor: SmithGroup;
|
|
35
|
+
protected abstract texts: SmithGroup;
|
|
36
|
+
constructor(scaler: SmithScaler);
|
|
37
|
+
visibility(visible: boolean): void;
|
|
38
|
+
show(): void;
|
|
39
|
+
hide(): void;
|
|
40
|
+
displayMinor(display: boolean): void;
|
|
41
|
+
showMinor(): void;
|
|
42
|
+
hideMinor(): void;
|
|
43
|
+
protected build(): SmithGroup;
|
|
44
|
+
/** Mount labels separately so every grid line is painted before any label. */
|
|
45
|
+
get labels(): SmithGroup;
|
|
46
|
+
draw(): SmithGroup;
|
|
47
|
+
setDrawOptions(opts: ConstCirclesDrawOptions): void;
|
|
48
|
+
set Stroke(stroke: string);
|
|
49
|
+
get Stroke(): string;
|
|
50
|
+
set MajorWidth(width: string);
|
|
51
|
+
get MajorWidth(): string;
|
|
52
|
+
set MinorWidth(width: string);
|
|
53
|
+
get MinorWidth(): string;
|
|
54
|
+
set TextColor(color: string);
|
|
55
|
+
get TextColor(): string;
|
|
56
|
+
set TextFontFamily(family: string);
|
|
57
|
+
get TextFontFamily(): string;
|
|
58
|
+
set TextFontSize(size: string);
|
|
59
|
+
get TextFontSize(): string;
|
|
60
|
+
protected defaultDrawingOptions(): ConstCirclesDrawOptions;
|
|
61
|
+
protected scaleArc(scaler: SmithScaler, d: [Point, Point, number, boolean, boolean]): ArcData;
|
|
62
|
+
protected drawShapes(g: d3.Selection<SVGElement, unknown, null, undefined>, color: string, width: string, shapes: Shapes): void;
|
|
63
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { SmithGroup } from './SmithGroup.js';
|
|
2
|
+
import { SmithConstantCircle } from '../SmithConstantCircle.js';
|
|
3
|
+
export class ConstCircles {
|
|
4
|
+
scaler;
|
|
5
|
+
calcs = new SmithConstantCircle();
|
|
6
|
+
container;
|
|
7
|
+
opts;
|
|
8
|
+
constructor(scaler) {
|
|
9
|
+
this.scaler = scaler;
|
|
10
|
+
this.container = new SmithGroup();
|
|
11
|
+
this.opts = this.defaultDrawingOptions();
|
|
12
|
+
}
|
|
13
|
+
visibility(visible) {
|
|
14
|
+
if (visible) {
|
|
15
|
+
this.show();
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.hide();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
show() {
|
|
22
|
+
this.container.show();
|
|
23
|
+
this.texts.show();
|
|
24
|
+
}
|
|
25
|
+
hide() {
|
|
26
|
+
this.container.hide();
|
|
27
|
+
this.texts.hide();
|
|
28
|
+
}
|
|
29
|
+
displayMinor(display) {
|
|
30
|
+
if (display) {
|
|
31
|
+
this.minor.show();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.minor.hide();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
showMinor() {
|
|
38
|
+
this.minor.show();
|
|
39
|
+
}
|
|
40
|
+
hideMinor() {
|
|
41
|
+
this.minor.hide();
|
|
42
|
+
}
|
|
43
|
+
build() {
|
|
44
|
+
this.texts.hide();
|
|
45
|
+
return this.container.append(this.minor).append(this.major).hide();
|
|
46
|
+
}
|
|
47
|
+
/** Mount labels separately so every grid line is painted before any label. */
|
|
48
|
+
get labels() {
|
|
49
|
+
return this.texts;
|
|
50
|
+
}
|
|
51
|
+
draw() {
|
|
52
|
+
return this.container;
|
|
53
|
+
}
|
|
54
|
+
setDrawOptions(opts) {
|
|
55
|
+
this.opts = opts;
|
|
56
|
+
this.Stroke = opts.stroke;
|
|
57
|
+
this.major.StrokeWidth = opts.majorWidth;
|
|
58
|
+
this.minor.StrokeWidth = opts.minorWidth;
|
|
59
|
+
this.texts
|
|
60
|
+
.attr('fill', opts.textColor)
|
|
61
|
+
.attr('font-family', opts.textFontFamily)
|
|
62
|
+
.attr('font-size', opts.textFontSize);
|
|
63
|
+
}
|
|
64
|
+
set Stroke(stroke) {
|
|
65
|
+
this.opts.stroke = stroke;
|
|
66
|
+
this.container.Stroke = stroke;
|
|
67
|
+
this.major.Stroke = stroke;
|
|
68
|
+
this.minor.Stroke = stroke;
|
|
69
|
+
}
|
|
70
|
+
get Stroke() {
|
|
71
|
+
return this.opts.stroke;
|
|
72
|
+
}
|
|
73
|
+
set MajorWidth(width) {
|
|
74
|
+
this.opts.majorWidth = width;
|
|
75
|
+
this.major.StrokeWidth = width;
|
|
76
|
+
}
|
|
77
|
+
get MajorWidth() {
|
|
78
|
+
return this.opts.majorWidth;
|
|
79
|
+
}
|
|
80
|
+
set MinorWidth(width) {
|
|
81
|
+
this.opts.minorWidth = width;
|
|
82
|
+
this.minor.StrokeWidth = width;
|
|
83
|
+
}
|
|
84
|
+
get MinorWidth() {
|
|
85
|
+
return this.opts.minorWidth;
|
|
86
|
+
}
|
|
87
|
+
set TextColor(color) {
|
|
88
|
+
this.opts.textColor = color;
|
|
89
|
+
this.texts.Fill = color;
|
|
90
|
+
}
|
|
91
|
+
get TextColor() {
|
|
92
|
+
return this.opts.textColor;
|
|
93
|
+
}
|
|
94
|
+
set TextFontFamily(family) {
|
|
95
|
+
this.opts.textFontFamily = family;
|
|
96
|
+
this.texts.attr('font-family', family);
|
|
97
|
+
}
|
|
98
|
+
get TextFontFamily() {
|
|
99
|
+
return this.opts.textFontFamily;
|
|
100
|
+
}
|
|
101
|
+
set TextFontSize(size) {
|
|
102
|
+
this.opts.textFontSize = size;
|
|
103
|
+
this.texts.attr('font-size', size);
|
|
104
|
+
}
|
|
105
|
+
get TextFontSize() {
|
|
106
|
+
return this.opts.textFontSize;
|
|
107
|
+
}
|
|
108
|
+
defaultDrawingOptions() {
|
|
109
|
+
return {
|
|
110
|
+
// Keep curved grid strokes visible at normal browser zoom and low pixel density.
|
|
111
|
+
stroke: '#64748b',
|
|
112
|
+
majorWidth: '1',
|
|
113
|
+
minorWidth: '0.6',
|
|
114
|
+
textColor: 'black',
|
|
115
|
+
textFontFamily: 'Verdana',
|
|
116
|
+
textFontSize: '1',
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
scaleArc(scaler, d) {
|
|
120
|
+
const { p1, p2, r } = scaler.arc({ p1: d[0], p2: d[1], r: d[2] });
|
|
121
|
+
const largeArc = d[3] ? '1' : '0';
|
|
122
|
+
const sweep = d[4] ? '0' : '1';
|
|
123
|
+
return { p1, p2, r, largeArc, sweep };
|
|
124
|
+
}
|
|
125
|
+
drawShapes(g, color, width, shapes) {
|
|
126
|
+
// Shapes inherit styling so changing a layer updates all of its geometry.
|
|
127
|
+
g.attr('stroke', color).attr('stroke-width', width);
|
|
128
|
+
g.selectAll('line')
|
|
129
|
+
.data(shapes.lines)
|
|
130
|
+
.enter()
|
|
131
|
+
.append('line')
|
|
132
|
+
.attr('x1', (d) => d.p1[0])
|
|
133
|
+
.attr('y1', (d) => d.p1[1])
|
|
134
|
+
.attr('x2', (d) => d.p2[0])
|
|
135
|
+
.attr('y2', (d) => d.p2[1])
|
|
136
|
+
.attr('fill', 'none')
|
|
137
|
+
.attr('vector-effect', 'non-scaling-stroke');
|
|
138
|
+
g.selectAll('circle')
|
|
139
|
+
.data(shapes.circles)
|
|
140
|
+
.enter()
|
|
141
|
+
.append('circle')
|
|
142
|
+
.attr('cx', (d) => d.p[0])
|
|
143
|
+
.attr('cy', (d) => d.p[1])
|
|
144
|
+
.attr('r', (d) => d.r)
|
|
145
|
+
.attr('fill', 'none')
|
|
146
|
+
.attr('vector-effect', 'non-scaling-stroke');
|
|
147
|
+
g.selectAll('path')
|
|
148
|
+
.data(shapes.arcs)
|
|
149
|
+
.enter()
|
|
150
|
+
.append('path')
|
|
151
|
+
.attr('fill', 'none')
|
|
152
|
+
.attr('vector-effect', 'non-scaling-stroke')
|
|
153
|
+
.attr('d', (d) => {
|
|
154
|
+
const { p1, p2, r, largeArc, sweep } = d;
|
|
155
|
+
return `M${p1[0]},${p1[1]} A${r},${r} 0 ${largeArc},${sweep} ${p2[0]},${p2[1]}`;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SmithGroup } from './SmithGroup.js';
|
|
2
|
+
import { SmithScaler } from './SmithScaler.js';
|
|
3
|
+
interface ConstQDrawOptions {
|
|
4
|
+
stroke: string;
|
|
5
|
+
strokeWidth: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ConstQCircles {
|
|
8
|
+
private scaler;
|
|
9
|
+
private calcs;
|
|
10
|
+
private circles;
|
|
11
|
+
private opts;
|
|
12
|
+
private container;
|
|
13
|
+
constructor(scaler: SmithScaler);
|
|
14
|
+
private drawConstQCircles;
|
|
15
|
+
private drawConstQCircle;
|
|
16
|
+
private getDefaultDrawOptions;
|
|
17
|
+
setDrawOptions(opts: ConstQDrawOptions): void;
|
|
18
|
+
set Stroke(stroke: string);
|
|
19
|
+
get Stroke(): string;
|
|
20
|
+
set StrokeWidth(width: string);
|
|
21
|
+
get StrokeWidth(): string;
|
|
22
|
+
draw(): SmithGroup;
|
|
23
|
+
visibility(visible: boolean): ConstQCircles;
|
|
24
|
+
show(): void;
|
|
25
|
+
hide(): void;
|
|
26
|
+
append(Q: number): void;
|
|
27
|
+
remove(Q: number): void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { SmithGroup } from './SmithGroup.js';
|
|
2
|
+
import { SmithArc } from './SmithArc.js';
|
|
3
|
+
import { SmithConstantCircle } from '../SmithConstantCircle.js';
|
|
4
|
+
export class ConstQCircles {
|
|
5
|
+
scaler;
|
|
6
|
+
calcs = new SmithConstantCircle();
|
|
7
|
+
circles = [0.5, 1, 2, 5, 10];
|
|
8
|
+
opts;
|
|
9
|
+
container;
|
|
10
|
+
constructor(scaler) {
|
|
11
|
+
this.scaler = scaler;
|
|
12
|
+
this.container = new SmithGroup().attr('fill', 'none').hide();
|
|
13
|
+
this.drawConstQCircles(this.circles);
|
|
14
|
+
this.opts = this.getDefaultDrawOptions();
|
|
15
|
+
this.setDrawOptions(this.opts);
|
|
16
|
+
}
|
|
17
|
+
drawConstQCircles(Qs) {
|
|
18
|
+
Qs.forEach((Q) => this.drawConstQCircle(Q));
|
|
19
|
+
}
|
|
20
|
+
drawConstQCircle(Q) {
|
|
21
|
+
const r = this.calcs.constQCircle(Q).r;
|
|
22
|
+
const a = this.scaler.arc({ p1: [-1, 0], p2: [1, 0], r });
|
|
23
|
+
const a1 = new SmithArc(a.p1, a.p2, a.r, false, false);
|
|
24
|
+
a1.nonScalingStroke();
|
|
25
|
+
this.container.append(a1);
|
|
26
|
+
const a2 = new SmithArc(a.p1, a.p2, a.r, false, true);
|
|
27
|
+
a2.nonScalingStroke();
|
|
28
|
+
this.container.append(a2);
|
|
29
|
+
}
|
|
30
|
+
getDefaultDrawOptions() {
|
|
31
|
+
return { stroke: 'blue', strokeWidth: '1' };
|
|
32
|
+
}
|
|
33
|
+
setDrawOptions(opts) {
|
|
34
|
+
this.opts = opts;
|
|
35
|
+
this.container.setDrawOptions(opts);
|
|
36
|
+
}
|
|
37
|
+
set Stroke(stroke) {
|
|
38
|
+
this.opts.stroke = stroke;
|
|
39
|
+
this.container.Stroke = stroke;
|
|
40
|
+
}
|
|
41
|
+
get Stroke() {
|
|
42
|
+
return this.opts.stroke;
|
|
43
|
+
}
|
|
44
|
+
set StrokeWidth(width) {
|
|
45
|
+
this.opts.strokeWidth = width;
|
|
46
|
+
this.container.StrokeWidth = width;
|
|
47
|
+
}
|
|
48
|
+
get StrokeWidth() {
|
|
49
|
+
return this.opts.strokeWidth;
|
|
50
|
+
}
|
|
51
|
+
draw() {
|
|
52
|
+
return this.container;
|
|
53
|
+
}
|
|
54
|
+
visibility(visible) {
|
|
55
|
+
if (visible) {
|
|
56
|
+
this.container.show();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.container.hide();
|
|
60
|
+
}
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
show() {
|
|
64
|
+
this.container.show();
|
|
65
|
+
}
|
|
66
|
+
hide() {
|
|
67
|
+
this.container.hide();
|
|
68
|
+
}
|
|
69
|
+
append(Q) {
|
|
70
|
+
const index = this.circles.indexOf(Q);
|
|
71
|
+
if (index !== -1) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.circles.push(Q);
|
|
75
|
+
this.drawConstQCircle(Q);
|
|
76
|
+
}
|
|
77
|
+
remove(Q) {
|
|
78
|
+
const index = this.circles.indexOf(Q);
|
|
79
|
+
if (index === -1) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.circles.splice(index, 1);
|
|
83
|
+
this.container.Element.selectAll('*').remove();
|
|
84
|
+
this.drawConstQCircles(this.circles);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SmithGroup } from './SmithGroup.js';
|
|
2
|
+
import { SmithScaler } from './SmithScaler.js';
|
|
3
|
+
interface ConstSwrDrawOptions {
|
|
4
|
+
stroke: string;
|
|
5
|
+
strokeWidth: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ConstSwrCircles {
|
|
8
|
+
private scaler;
|
|
9
|
+
private calcs;
|
|
10
|
+
private circles;
|
|
11
|
+
private opts;
|
|
12
|
+
private container;
|
|
13
|
+
constructor(scaler: SmithScaler);
|
|
14
|
+
private drawConstSwrCircles;
|
|
15
|
+
private drawConstSwrCircle;
|
|
16
|
+
private getDefaultDrawOptions;
|
|
17
|
+
setDrawOptions(opts: ConstSwrDrawOptions): void;
|
|
18
|
+
set Stroke(stroke: string);
|
|
19
|
+
get Stroke(): string;
|
|
20
|
+
set StrokeWidth(width: string);
|
|
21
|
+
get StrokeWidth(): string;
|
|
22
|
+
draw(): SmithGroup;
|
|
23
|
+
visibility(visible: boolean): ConstSwrCircles;
|
|
24
|
+
show(): void;
|
|
25
|
+
hide(): void;
|
|
26
|
+
append(swr: number): void;
|
|
27
|
+
remove(swr: number): void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { SmithGroup } from './SmithGroup.js';
|
|
2
|
+
import { SmithCircle } from './SmithCircle.js';
|
|
3
|
+
import { SmithConstantCircle } from '../SmithConstantCircle.js';
|
|
4
|
+
export class ConstSwrCircles {
|
|
5
|
+
scaler;
|
|
6
|
+
calcs = new SmithConstantCircle();
|
|
7
|
+
circles = [1.2, 1.5, 2, 3, 5, 10];
|
|
8
|
+
opts;
|
|
9
|
+
container;
|
|
10
|
+
constructor(scaler) {
|
|
11
|
+
this.scaler = scaler;
|
|
12
|
+
this.container = new SmithGroup().attr('fill', 'none').hide();
|
|
13
|
+
this.drawConstSwrCircles(this.circles);
|
|
14
|
+
this.opts = this.getDefaultDrawOptions();
|
|
15
|
+
this.setDrawOptions(this.opts);
|
|
16
|
+
}
|
|
17
|
+
drawConstSwrCircles(swrs) {
|
|
18
|
+
swrs.forEach((swr) => this.drawConstSwrCircle(swr));
|
|
19
|
+
}
|
|
20
|
+
drawConstSwrCircle(swr) {
|
|
21
|
+
const c = this.scaler.circle({
|
|
22
|
+
p: [0, 0],
|
|
23
|
+
r: this.calcs.swrToRflCoeffEOrI(swr),
|
|
24
|
+
});
|
|
25
|
+
const circle = new SmithCircle(c);
|
|
26
|
+
circle.nonScalingStroke();
|
|
27
|
+
this.container.append(circle);
|
|
28
|
+
}
|
|
29
|
+
getDefaultDrawOptions() {
|
|
30
|
+
return { stroke: 'orange', strokeWidth: '1' };
|
|
31
|
+
}
|
|
32
|
+
setDrawOptions(opts) {
|
|
33
|
+
this.opts = opts;
|
|
34
|
+
this.container.setDrawOptions(opts);
|
|
35
|
+
}
|
|
36
|
+
set Stroke(stroke) {
|
|
37
|
+
this.opts.stroke = stroke;
|
|
38
|
+
this.container.Stroke = stroke;
|
|
39
|
+
}
|
|
40
|
+
get Stroke() {
|
|
41
|
+
return this.opts.stroke;
|
|
42
|
+
}
|
|
43
|
+
set StrokeWidth(width) {
|
|
44
|
+
this.opts.strokeWidth = width;
|
|
45
|
+
this.container.StrokeWidth = width;
|
|
46
|
+
}
|
|
47
|
+
get StrokeWidth() {
|
|
48
|
+
return this.opts.strokeWidth;
|
|
49
|
+
}
|
|
50
|
+
draw() {
|
|
51
|
+
return this.container;
|
|
52
|
+
}
|
|
53
|
+
visibility(visible) {
|
|
54
|
+
if (visible) {
|
|
55
|
+
this.container.show();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.container.hide();
|
|
59
|
+
}
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
show() {
|
|
63
|
+
this.container.show();
|
|
64
|
+
}
|
|
65
|
+
hide() {
|
|
66
|
+
this.container.hide();
|
|
67
|
+
}
|
|
68
|
+
append(swr) {
|
|
69
|
+
const index = this.circles.indexOf(swr);
|
|
70
|
+
if (index !== -1) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.circles.push(swr);
|
|
74
|
+
this.drawConstSwrCircle(swr);
|
|
75
|
+
}
|
|
76
|
+
remove(swr) {
|
|
77
|
+
const index = this.circles.indexOf(swr);
|
|
78
|
+
if (index === -1) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.circles.splice(index, 1);
|
|
82
|
+
this.container.Element.selectAll('*').remove();
|
|
83
|
+
this.drawConstSwrCircles(this.circles);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { select, dragEnable } from 'd3';
|
|
2
|
+
/** Release only window listeners belonging to this chart's active mouse gesture. */
|
|
3
|
+
export class MouseGesture {
|
|
4
|
+
release;
|
|
5
|
+
capture(event, namespace) {
|
|
6
|
+
if (event.type !== 'mousedown' || !event.view) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const view = event.view;
|
|
10
|
+
const selection = select(view);
|
|
11
|
+
const move = `mousemove.${namespace}`;
|
|
12
|
+
const up = `mouseup.${namespace}`;
|
|
13
|
+
const listener = selection.on(move);
|
|
14
|
+
this.release = () => {
|
|
15
|
+
// A different chart may have started a gesture since this one ended.
|
|
16
|
+
if (listener && selection.on(move) === listener) {
|
|
17
|
+
selection.on(`${move} ${up}`, null);
|
|
18
|
+
dragEnable(view, false);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
destroy() {
|
|
23
|
+
this.release?.();
|
|
24
|
+
this.release = undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Point } from '../shapes/Point.js';
|
|
2
|
+
import { SmithShape } from './SmithShape.js';
|
|
3
|
+
import { SmithDrawOptions } from './SmithDrawOptions.js';
|
|
4
|
+
export declare class SmithArc extends SmithShape {
|
|
5
|
+
constructor(p1: Point, p2: Point, r: number, largeArc: boolean, sweep: boolean, options?: SmithDrawOptions);
|
|
6
|
+
move(p1: Point, p2: Point, r: number, largeArc: boolean, sweep: boolean): SmithArc;
|
|
7
|
+
hide(): void;
|
|
8
|
+
show(): void;
|
|
9
|
+
nonScalingStroke(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as d3 from 'd3';
|
|
2
|
+
import { SmithShape } from './SmithShape.js';
|
|
3
|
+
export class SmithArc extends SmithShape {
|
|
4
|
+
constructor(p1, p2, r, largeArc, sweep, options) {
|
|
5
|
+
super(d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'path')));
|
|
6
|
+
if (options) {
|
|
7
|
+
this.setDrawOptions(options);
|
|
8
|
+
}
|
|
9
|
+
this.move(p1, p2, r, largeArc, sweep);
|
|
10
|
+
}
|
|
11
|
+
move(p1, p2, r, largeArc, sweep) {
|
|
12
|
+
const la = largeArc ? '1' : '0';
|
|
13
|
+
const s = sweep ? '1' : '0';
|
|
14
|
+
this.element.attr('d', `M${p1[0]},${p1[1]} A${r},${r} 0 ${la},${s} ${p2[0]},${p2[1]}`);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
hide() {
|
|
18
|
+
this.Element.attr('opacity', '0');
|
|
19
|
+
}
|
|
20
|
+
show() {
|
|
21
|
+
this.Element.attr('opacity', null);
|
|
22
|
+
}
|
|
23
|
+
nonScalingStroke() {
|
|
24
|
+
this.Element.attr('vector-effect', 'non-scaling-stroke');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Circle } from '../shapes/Circle.js';
|
|
2
|
+
import { SmithShape } from './SmithShape.js';
|
|
3
|
+
import { SmithDrawOptions } from './SmithDrawOptions.js';
|
|
4
|
+
export declare class SmithCircle extends SmithShape {
|
|
5
|
+
constructor(c: Circle, options?: SmithDrawOptions);
|
|
6
|
+
move(c: Circle): SmithCircle;
|
|
7
|
+
hide(): void;
|
|
8
|
+
show(): void;
|
|
9
|
+
nonScalingStroke(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as d3 from 'd3';
|
|
2
|
+
import { SmithShape } from './SmithShape.js';
|
|
3
|
+
export class SmithCircle extends SmithShape {
|
|
4
|
+
constructor(c, options) {
|
|
5
|
+
super(d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'circle')));
|
|
6
|
+
if (options) {
|
|
7
|
+
this.setDrawOptions(options);
|
|
8
|
+
}
|
|
9
|
+
this.move(c);
|
|
10
|
+
}
|
|
11
|
+
move(c) {
|
|
12
|
+
this.element.attr('cx', c.p[0]).attr('cy', c.p[1]).attr('r', c.r);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
hide() {
|
|
16
|
+
this.Element.attr('opacity', '0');
|
|
17
|
+
}
|
|
18
|
+
show() {
|
|
19
|
+
this.Element.attr('opacity', null);
|
|
20
|
+
}
|
|
21
|
+
nonScalingStroke() {
|
|
22
|
+
this.Element.attr('vector-effect', 'non-scaling-stroke');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SmithGroup } from './SmithGroup.js';
|
|
2
|
+
import { SmithScaler } from './SmithScaler.js';
|
|
3
|
+
import { Complex } from '../complex/Complex.js';
|
|
4
|
+
interface DrawOptions {
|
|
5
|
+
point: {
|
|
6
|
+
radius: number;
|
|
7
|
+
color: string;
|
|
8
|
+
};
|
|
9
|
+
impedance: {
|
|
10
|
+
width: number;
|
|
11
|
+
color: string;
|
|
12
|
+
};
|
|
13
|
+
admittance: {
|
|
14
|
+
width: number;
|
|
15
|
+
color: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare class SmithCursor {
|
|
19
|
+
private scaler;
|
|
20
|
+
private epsilon;
|
|
21
|
+
private pendingMove;
|
|
22
|
+
private drawingOpts;
|
|
23
|
+
private calcs;
|
|
24
|
+
private zClipCircle;
|
|
25
|
+
private yClipCircle;
|
|
26
|
+
private rc;
|
|
27
|
+
private group;
|
|
28
|
+
private point;
|
|
29
|
+
private impedance;
|
|
30
|
+
private admittance;
|
|
31
|
+
private moveHandler;
|
|
32
|
+
constructor(scaler: SmithScaler);
|
|
33
|
+
private appendAll;
|
|
34
|
+
get Group(): SmithGroup;
|
|
35
|
+
get Position(): Complex;
|
|
36
|
+
set Position(rc: Complex);
|
|
37
|
+
private isWithinPlot;
|
|
38
|
+
private movePoint;
|
|
39
|
+
private moveResistance;
|
|
40
|
+
private moveReactance;
|
|
41
|
+
private moveConductance;
|
|
42
|
+
private moveSusceptance;
|
|
43
|
+
show(): void;
|
|
44
|
+
hide(): void;
|
|
45
|
+
private cancelPendingMove;
|
|
46
|
+
setMoveHandler(handler: ((rc: Complex) => void) | null): void;
|
|
47
|
+
setDrawOptions(opts: DrawOptions): void;
|
|
48
|
+
}
|
|
49
|
+
export {};
|