Skip to content

Commit f3a6ca1

Browse files
committed
Place holes on rail
1 parent 9ff88fc commit f3a6ca1

7 files changed

Lines changed: 61 additions & 26 deletions

File tree

src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ function App() {
1717
0.75,
1818
0.75,
1919
1,
20-
4,
2120
"in",
2221
"LR4",
2322
));

src/components/TableEditor.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ function propertyNameToLabel(name: keyof TableEditable): string {
1616
case "railMaterialThickness": return "Rail material thickness";
1717
case "material": return "Material thickness";
1818
case "overhang": return "Tabletop overhang";
19-
case "trackWidth": return "Track Width";
2019
case "clipMinGap": return "Minimum Rail Clip Gap";
2120
}
2221
}

src/components/TableLayout.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ export default function TableLayout(props: TableLayoutProps) {
4646
const height = (tableThickness + strokeWidth) * (ySparCount + xSparCount) + (4 * kerfWidth) + (2 * (trackWidth + tableThickness));
4747
const viewBox = `0 0 ${width} ${height * 1.5}`
4848

49-
console.log("Rendering rails.")
50-
5149
let rails = [];
5250
if (configuration == "LR4") {
5351
rails.push(<TopRail key={"rail-top"} table={props.table} x={strokeWidth / 2} y={firstRail} rotation={0} strokeWidth={strokeWidth} rail={true} />);

src/components/TablePropEditor.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export default function TablePropEditor(props: TablePropEditorProps) {
2323
props.table.railMaterialThickness,
2424
props.table.material,
2525
props.table.overhang,
26-
props.table.trackWidth,
2726
props.table.units,
2827
props.table.configuration,
2928
);

src/components/TopRail.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export default class TopRail extends SVGComponent<TopRailProps> {
1212
const length = this.props.table.yCut + this.props.table.yBuffer;
1313
const sparInset = this.props.table.overhang + (this.props.table.yBuffer / 2);
1414
const trackWidth = this.props.table.trackWidth;
15+
const holeSize = this.props.table.holeSize;
16+
let [yFrontSetback, yFrontFirstX, yFrontSecondX] = this.props.table.frontHoleCoordinates;
17+
let [yBackFirstSetback, yBackSecondSetback, yBackFirstX, yBackSecondX] = this.props.table.backHoleCoordinates;
1518

1619
let pathstr = `M 0 0`
1720
pathstr += `L ${length} 0`
@@ -28,7 +31,6 @@ export default class TopRail extends SVGComponent<TopRailProps> {
2831
const offset = this.props.table.clipOffset;
2932
const holeStart = this.props.table.clipsFrontSetback;
3033
const clipCount = this.props.table.clipCount;
31-
const holeSize = this.props.table.holeSize;
3234
const clipGap = this.props.table.clipGap;
3335

3436
for (let clip = 0; clip < clipCount; clip++) {
@@ -37,8 +39,29 @@ export default class TopRail extends SVGComponent<TopRailProps> {
3739
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${x + holeSize} ${offset}`
3840
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${x} ${offset}`
3941
}
42+
} else {
43+
yFrontFirstX = trackWidth - yFrontFirstX;
44+
yFrontSecondX = trackWidth - yFrontSecondX;
45+
yBackFirstX = trackWidth - yBackFirstX;
46+
yBackSecondX = trackWidth - yBackSecondX;
4047
}
4148

49+
pathstr += `M ${yFrontSetback - (holeSize / 2)} ${yFrontFirstX}`;
50+
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${yFrontSetback + (holeSize / 2)} ${yFrontFirstX}`
51+
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${yFrontSetback - (holeSize / 2)} ${yFrontFirstX}`
52+
53+
pathstr += `M ${yFrontSetback - (holeSize / 2)} ${yFrontSecondX}`;
54+
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${yFrontSetback + (holeSize / 2)} ${yFrontSecondX}`
55+
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${yFrontSetback - (holeSize / 2)} ${yFrontSecondX}`
56+
57+
pathstr += `M ${length + (holeSize / 2) - yBackFirstSetback} ${yBackFirstX}`;
58+
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${length - (holeSize / 2) - yBackFirstSetback} ${yBackFirstX}`
59+
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${length + (holeSize / 2) - yBackFirstSetback} ${yBackFirstX}`
60+
61+
pathstr += `M ${length + (holeSize / 2) - yBackSecondSetback} ${yBackSecondX}`;
62+
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${length - (holeSize / 2) - yBackSecondSetback} ${yBackSecondX}`
63+
pathstr += `A ${holeSize / 2} ${holeSize / 2} 0 0 1 ${length + (holeSize / 2) - yBackSecondSetback} ${yBackSecondX}`
64+
4265
return SVG().path(pathstr).fill("none").attr('vector-effect', 'non-scaling-stroke');
4366
}
4467
}

src/components/XSpar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default class XSpar extends SVGComponent<XSparProps> {
2020

2121
let pathstr = '';
2222
const start = (xBuffer / 2) + overhang - (xShrink / 2);
23-
console.log(`${xBuffer} ${xShrink} ${xCut} ${start}`)
2423
if (start == 0) {
2524
pathstr += `M 0 ${thickness / 2}`;
2625
} else {

src/models/Table.ts

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface TableEditable {
1111
railMaterialThickness: number;
1212
overhang: number;
1313
material: number;
14-
trackWidth: number;
1514
}
1615

1716
export class Table implements TableEditable {
@@ -24,11 +23,10 @@ export class Table implements TableEditable {
2423
railMaterialThickness: number;
2524
overhang: number;
2625
material: number;
27-
trackWidth: number;
2826
units: Units;
2927
configuration: Configuration;
3028

31-
constructor(xCut: number, yCut: number, xSparMinGap: number, ySparMinGap: number, clipMinGap: number, thickness: number, railMaterialThickness: number, material: number, overhang: number, trackWidth: number, units: Units, configuration: Configuration) {
29+
constructor(xCut: number, yCut: number, xSparMinGap: number, ySparMinGap: number, clipMinGap: number, thickness: number, railMaterialThickness: number, material: number, overhang: number, units: Units, configuration: Configuration) {
3230
this.xCut = xCut;
3331
this.yCut = yCut,
3432
this.xSparMinGap = xSparMinGap;
@@ -38,7 +36,6 @@ export class Table implements TableEditable {
3836
this.railMaterialThickness = railMaterialThickness;
3937
this.overhang = overhang;
4038
this.material = material;
41-
this.trackWidth = trackWidth;
4239
this.units = units;
4340
this.configuration = configuration;
4441
}
@@ -89,25 +86,41 @@ export class Table implements TableEditable {
8986

9087
get holeSize(): number {
9188
return {
92-
"mm": 4,
93-
"cm": 0.4,
94-
"in": 4 / 25.4,
89+
"mm": 4.5,
90+
"cm": 0.45,
91+
"in": 4.5 / 25.4,
9592
}[this.units];
9693
}
9794

95+
get frontHoleCoordinates(): [number, number, number] {
96+
return {
97+
"mm": [7.75, 8.25, 21.75],
98+
"cm": [7.75 / 10, 8.25 / 10, 21.75 / 10],
99+
"in": [7.75 / 25.4, 8.25 / 25.4, 21.75 / 25.4],
100+
}[this.units] as [number, number, number];
101+
}
102+
103+
get backHoleCoordinates(): [number, number, number, number] {
104+
return {
105+
"mm": [15, 15, 8.25, 24.25],
106+
"cm": [15 / 10, 7.75 / 10, 8.25 / 10, 24.25 / 10],
107+
"in": [15 / 25.4, 7.75 / 25.4, 8.25 / 25.4, 24.25 / 25.4],
108+
}[this.units] as [number, number, number, number];
109+
}
110+
98111
get clipsFrontSetback(): number {
99112
return {
100-
"mm": 89,
101-
"cm": 8.9,
102-
"in": 3.50,
113+
"mm": (51 + 5 + 10),
114+
"cm": (51 + 5 + 10) / 10,
115+
"in": (51 + 5 + 10) / 25.4,
103116
}[this.units];
104117
}
105118

106119
get clipsBackSetback(): number {
107120
return {
108-
"mm": 50,
109-
"cm": 5,
110-
"in": 1.9685,
121+
"mm": 44 + 5 + 10,
122+
"cm": (44 + 5 + 10) / 10,
123+
"in": (44 + 5 + 10) / 25.4,
111124
}[this.units] ;
112125
}
113126

@@ -126,9 +139,9 @@ export class Table implements TableEditable {
126139

127140
get clipOffset(): number {
128141
return {
129-
"mm": 88,
130-
"cm": 8.8,
131-
"in": 88 / 25.4,
142+
"mm": 67.8,
143+
"cm": 6.78,
144+
"in": 67.8 / 25.4,
132145
}[this.units] ;
133146
}
134147

@@ -139,6 +152,14 @@ export class Table implements TableEditable {
139152
}[this.configuration]
140153
}
141154

155+
get trackWidth(): number {
156+
return {
157+
"mm": 80,
158+
"cm": 8,
159+
"in": 80 / 25.4,
160+
}[this.units] ;
161+
}
162+
142163
get inMillimeters(): Table {
143164
const convert = {
144165
"mm": (x: number) => x,
@@ -156,7 +177,6 @@ export class Table implements TableEditable {
156177
convert(this.railMaterialThickness),
157178
convert(this.material),
158179
convert(this.overhang),
159-
convert(this.trackWidth),
160180
"mm",
161181
this.configuration,
162182
)
@@ -179,7 +199,6 @@ export class Table implements TableEditable {
179199
convert(this.railMaterialThickness),
180200
convert(this.material),
181201
convert(this.overhang),
182-
convert(this.trackWidth),
183202
"cm",
184203
this.configuration,
185204
)
@@ -202,7 +221,6 @@ export class Table implements TableEditable {
202221
convert(this.railMaterialThickness),
203222
convert(this.material),
204223
convert(this.overhang),
205-
convert(this.trackWidth),
206224
"in",
207225
this.configuration,
208226
)

0 commit comments

Comments
 (0)