@tscircuit/core 0.0.27 → 0.0.28
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/index.d.ts
CHANGED
|
@@ -119,7 +119,10 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
|
|
|
119
119
|
computePcbPropsTransform(): Matrix;
|
|
120
120
|
/**
|
|
121
121
|
* Compute a transformation matrix combining all parent transforms for PCB
|
|
122
|
-
* components
|
|
122
|
+
* components, including this component's translation and rotation.
|
|
123
|
+
*
|
|
124
|
+
* This is used to compute this component's position as well as all children
|
|
125
|
+
* components positions
|
|
123
126
|
*/
|
|
124
127
|
computePcbGlobalTransform(): Matrix;
|
|
125
128
|
/**
|
package/dist/index.js
CHANGED
|
@@ -239,9 +239,23 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
241
|
* Compute a transformation matrix combining all parent transforms for PCB
|
|
242
|
-
* components
|
|
242
|
+
* components, including this component's translation and rotation.
|
|
243
|
+
*
|
|
244
|
+
* This is used to compute this component's position as well as all children
|
|
245
|
+
* components positions
|
|
243
246
|
*/
|
|
244
247
|
computePcbGlobalTransform() {
|
|
248
|
+
const { _parsedProps: props } = this;
|
|
249
|
+
const manualPlacement = this.getSubcircuit()._getManualPlacementForComponent(this);
|
|
250
|
+
if (manualPlacement && this.props.pcbX === void 0 && this.props.pcbY === void 0) {
|
|
251
|
+
return compose(
|
|
252
|
+
this.parent?.computePcbGlobalTransform() ?? identity(),
|
|
253
|
+
compose(
|
|
254
|
+
translate(manualPlacement.x, manualPlacement.y),
|
|
255
|
+
rotate((props.pcbRotation ?? 0) * Math.PI / 180)
|
|
256
|
+
)
|
|
257
|
+
);
|
|
258
|
+
}
|
|
245
259
|
return compose(
|
|
246
260
|
this.parent?.computePcbGlobalTransform() ?? identity(),
|
|
247
261
|
this.computePcbPropsTransform()
|
|
@@ -296,10 +310,6 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
296
310
|
return null;
|
|
297
311
|
}
|
|
298
312
|
getGlobalPcbPosition() {
|
|
299
|
-
const manualPlacement = this.getSubcircuit()._getManualPlacementForComponent(this);
|
|
300
|
-
if (manualPlacement) {
|
|
301
|
-
return manualPlacement;
|
|
302
|
-
}
|
|
303
313
|
return applyToPoint(this.computePcbGlobalTransform(), { x: 0, y: 0 });
|
|
304
314
|
}
|
|
305
315
|
getGlobalSchematicPosition() {
|
|
@@ -126,9 +126,31 @@ export abstract class PrimitiveComponent<
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* Compute a transformation matrix combining all parent transforms for PCB
|
|
129
|
-
* components
|
|
129
|
+
* components, including this component's translation and rotation.
|
|
130
|
+
*
|
|
131
|
+
* This is used to compute this component's position as well as all children
|
|
132
|
+
* components positions
|
|
130
133
|
*/
|
|
131
134
|
computePcbGlobalTransform(): Matrix {
|
|
135
|
+
const { _parsedProps: props } = this
|
|
136
|
+
const manualPlacement =
|
|
137
|
+
this.getSubcircuit()._getManualPlacementForComponent(this)
|
|
138
|
+
|
|
139
|
+
// pcbX or pcbY will override the manual placement
|
|
140
|
+
if (
|
|
141
|
+
manualPlacement &&
|
|
142
|
+
this.props.pcbX === undefined &&
|
|
143
|
+
this.props.pcbY === undefined
|
|
144
|
+
) {
|
|
145
|
+
return compose(
|
|
146
|
+
this.parent?.computePcbGlobalTransform() ?? identity(),
|
|
147
|
+
compose(
|
|
148
|
+
translate(manualPlacement.x, manualPlacement.y),
|
|
149
|
+
rotate(((props.pcbRotation ?? 0) * Math.PI) / 180),
|
|
150
|
+
),
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
132
154
|
return compose(
|
|
133
155
|
this.parent?.computePcbGlobalTransform() ?? identity(),
|
|
134
156
|
this.computePcbPropsTransform(),
|
|
@@ -198,11 +220,6 @@ export abstract class PrimitiveComponent<
|
|
|
198
220
|
}
|
|
199
221
|
|
|
200
222
|
getGlobalPcbPosition(): { x: number; y: number } {
|
|
201
|
-
const manualPlacement =
|
|
202
|
-
this.getSubcircuit()._getManualPlacementForComponent(this)
|
|
203
|
-
if (manualPlacement) {
|
|
204
|
-
return manualPlacement
|
|
205
|
-
}
|
|
206
223
|
return applyToPoint(this.computePcbGlobalTransform(), { x: 0, y: 0 })
|
|
207
224
|
}
|
|
208
225
|
|