jsl/symbols/SymbolNode¶
Package name: jsl/symbols/SymbolNode
TODO:
We should discuss Symbol Grid Units and what this abstraction is for.
Summary¶
Data Types¶
VirtualPinParams¶
Pin Statement Optional Parameters
Functions¶
Function | Description |
---|---|
VirtualPinParams | |
add-pin | |
VirtualPin |
SymbolElement¶
Base Type for all SymbolNode types
PinDecorator¶
Pin Decorator - add art to a pin
Functions¶
Function | Description |
---|---|
VirtualPin | |
PinDecorator | |
add-decorator (+ 1) | Add a decorator to this pin |
SymbolNode¶
Scene Graph Builder for Schematic Symbols
Functions¶
Function | Description |
---|---|
add-glyph | |
polyline | |
add-backend-substitution (+ 1) | |
triangle | |
create-child | Create a new child node |
add-ref-label | |
circle | |
get-scale | Recursively Retrieve the Scale Parameter |
get-pins | Get the VirtualPin instances in this node and all descendents |
line-rectangle | |
make-symbol | |
set-preferred-orientation | |
SymbolNode (+ 1) | |
append (+ 2) | |
get-glyphs | Get all Glyph instances in this node. |
approx-arc | |
add-pin | |
add-value-label | |
text (+ 1) | |
append-all (+ 1) | |
rectangle | |
add-backend-substitutions | |
line | |
glyph-bounds | Compute the bounding box around the glyphs of this symbol. |
elements | |
is-root? | |
polygon |
VirtualPin¶
Virtual Pin in the Symbol Node Frame of Reference
Functions¶
Function | Description |
---|---|
get-pins | Get the VirtualPin instances in this node and all descendents |
make-vpin-symbol | |
add-pin | |
append | |
VirtualPin | |
append-all | |
add-decorator (+ 1) | Add a decorator to this pin |
Glyph¶
A Glyph is a set of geometry that creates an electrical symbol
Functions¶
Function | Description |
---|---|
add-glyph | |
polyline | |
triangle | |
Glyph | |
append-all | |
circle | |
line | |
line-rectangle | |
make-glyph-symbol | |
append | |
polygon | |
get-glyphs | Get all Glyph instances in this node. |
approx-arc |
General Definitions¶
Function | Description |
---|---|
font-to-unit | |
text-size |
Variable | Description |
---|---|
UNIT-TO-MM | |
FONT-TO-UNIT |
Definitions¶
VirtualPinParams¶
Pin Statement Optional Parameters
public defstruct VirtualPinParams <: Equalable
direction: Dir
pad-ref-size: Maybe<Double>
pin-length: Double
pin-name-size: Maybe<Double>
-
direction: Dir
-
pad-ref-size: Maybe<Double>
- Pad Id/Ref Text Size This parameter is optional and if set toNone
then no pad Ref text will be generated -
pin-length: Double
-
pin-name-size: Maybe<Double>
- Pin Name Text Size This parameter is optional and if set toNone
then no pin name text will be generated
The pin
statement in a pcb-symbol
can be a standalone
point or it can have some parameterizations. This
struct defines the parameterization so that the user can
optionally include this in pin definitions.
Functions¶
VirtualPinParams¶
public defn VirtualPinParams ( -- direction:Dir, pin-length:Double, pad-ref-size:Double = ?, pin-name-size:Double = ?) -> VirtualPinParams
- Returns
VirtualPinParams
add-pin¶
public defn add-pin (sn:SymbolNode, pin-name:String|Ref, position:Point|[Double, Double]|[Int, Int] -- params:VirtualPinParams = ?, name:String = ?, class:Seqable<String>|String = ?) -> VirtualPin
- Returns
VirtualPin
VirtualPin¶
public defn VirtualPin (pin-name:String|Ref, position:Point -- params:Maybe<VirtualPinParams> = ?, decorators:Seqable<PinDecorator> = ?, name?:Maybe<String> = ?, class:Seqable<String>|String = ?) -> VirtualPin
- Returns
VirtualPin
SymbolElement¶
Base Type for all SymbolNode types
public deftype SymbolElement <: Classable
Functions¶
elements¶
public defn elements (sn:SymbolNode) -> Seq<SymbolElement>
- Returns
Seq<SymbolElement>
PinDecorator¶
Pin Decorator - add art to a pin
public defstruct PinDecorator <: SymbolElement
art: Shape
art: Shape
- Art to apply to the pin The shape defined here will be applied in a frame of reference where the pin's position is the origin. It is assumed that the pin is pointed to theLeft
when drawing the art. The art shape will be flipped across the Y axis forRight
pins. For theUp
pins, the Left pin version is rotated 90 degrees. For theDown
pins, the Right pin is rotated 90 degrees.
This type is used to construct shapes that are used to indicate special functions for pins.
For Example:
- Bubble for active-low indication
- Arrows for Input / Output
- Open-Drain Indicator
- Clock Angle Symbol
Functions¶
VirtualPin¶
public defn VirtualPin (pin-name:String|Ref, position:Point -- params:Maybe<VirtualPinParams> = ?, decorators:Seqable<PinDecorator> = ?, name?:Maybe<String> = ?, class:Seqable<String>|String = ?) -> VirtualPin
- Returns
VirtualPin
PinDecorator¶
public defn PinDecorator (art:Shape -- name?:Maybe<String> = ?, class:Seqable<String>|String = ?) -> PinDecorator
- Returns
PinDecorator
add-decorator¶
Add a decorator to this pin
public defn add-decorator (vp:VirtualPin, dec:PinDecorator)
User can add multiple decorators to a pin. Current implementation doesn't handle preventing overlap well.
add-decorator¶
public defn add-decorator (vp:VirtualPin, decs:Seqable<PinDecorator>)
SymbolNode¶
Scene Graph Builder for Schematic Symbols
public defstruct SymbolNode <: SymbolElement
backend-sub?: Vector<KeyValue<String, SchematicSymbol>>
children: Vector<SymbolNode>
glyphs: Vector<Glyph>
parent: Maybe<SymbolNode>
pose: Pose
preferred-orient?: Maybe<SymbolOrientation>
scale: Maybe<Double>
vpins: Vector<VirtualPin>
-
backend-sub?: Vector<KeyValue<String, SchematicSymbol>>
- Backend Symbol Substitutions This vector holds a mapping ofname
to substitute symbols. Thename
parameter is the backend name likeAltium
orKicad
The substitute symbol is apcb-symbol
definition that will replace the symbol generated by this generator when exported to the proposed backend. -
children: Vector<SymbolNode>
-
glyphs: Vector<Glyph>
-
parent: Maybe<SymbolNode>
-
pose: Pose
-
preferred-orient?: Maybe<SymbolOrientation>
- Optional Preferred Orientation This parameter is only applicable for the root node of the symbol scene graph. This generates thepreferred-orientation
statement in the symbol context if notNone()
-
scale: Maybe<Double>
- Converts from Symbol grid to millimeters When we create schematic symbols, we often like to construct elements of that symbol with respect to a grid. For example, we might want all of the pins on a 100mil grid. This makes all of the symbols consistent and leads to a nicer aesthetic.This parameter is used to enforce a grid scaler so that when we construct pins and glyphs, we can use simple units.
The default scale converts 1.0 -> 2.54mm -> 100mil
-
vpins: Vector<VirtualPin>
The SymbolNode
is a node in the scene graph
for a schematic symbol. The idea is that we can
construct a symbol by combing various leafs that
are transformed from the root node. This allows for
grouping content and simplifying the calculations needed
to combine various forms of content.
Functions¶
add-glyph¶
public defn add-glyph (sn:SymbolNode, art:Shape -- name?:Maybe<String> = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
polyline¶
public defn polyline (sn:SymbolNode, pts:Collection<Arc|Point|[Double, Double]|[Int, Int]> -- width:Double = ?, name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
add-backend-substitution¶
public defn add-backend-substitution (sn:SymbolNode, nameSymb:KeyValue<String, SchematicSymbol>)
add-backend-substitution¶
public defn add-backend-substitution (sn:SymbolNode, name:String, symb:SchematicSymbol)
triangle¶
public defn triangle (sn:SymbolNode, p0:Point|[Double, Double], p1:Point|[Double, Double], w:Double -- name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
create-child¶
Create a new child node
public defn create-child (sn:SymbolNode -- pose:Pose = ?, scale:Double = ?, name:String = ?, class:Seqable<String>|String = ?) -> SymbolNode
sn: SymbolNode
- SymbolNode parent for the new child.pose: Pose
- Coordinate transformation for the child. Note that this is applied before the scaling operation.scale: Double
- Optional scale for the child glyphs. By default, the parent's scale factor is used.name: String
- Sets the id name for this child if anyclass: Seqable<String>|String
- Set class names that apply to this child.- Returns
SymbolNode
- Child node in the symbol scene graph.
add-ref-label¶
public defn add-ref-label (sn:SymbolNode, pos:Pose|Point|[Double, Double]|[Int, Int] -- anchor:Anchor = ?, unit-size:Double = ?)
circle¶
public defn circle (sn:SymbolNode, r:Double, p:Point|[Double, Double]|[Int, Int] = ? -- name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
get-scale¶
Recursively Retrieve the Scale Parameter
public defn get-scale (sn:SymbolNode) -> Double
- Returns
Double
- Throws
RuntimeError
- If no ancestor has a valid scale.
This function uses either the local scale override for this node or searches back through its ancestors (parents) for a valid scale parameter.
get-pins¶
Get the VirtualPin
instances in this node and all descendents
public defn get-pins (sn:SymbolNode) -> Tuple<VirtualPin>
- Returns
Tuple<VirtualPin>
This function recursively retrieves all of the pins in this component.
line-rectangle¶
public defn line-rectangle (sn:SymbolNode, p0:Point, p1:Point, width:Double -- pose:Pose = ?, name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
make-symbol¶
public defn make-symbol (sn:SymbolNode, parent-pose:Pose = ?)
set-preferred-orientation¶
public defn set-preferred-orientation (sn:SymbolNode, orient:SymbolOrientation)
SymbolNode¶
public defn SymbolNode (parent:SymbolNode, pose:Pose = ? -- scale:Maybe<Double> = ?, name:Maybe<String> = ?, class:Seqable<String>|String = ?) -> SymbolNode
- Returns
SymbolNode
SymbolNode¶
public defn SymbolNode (pose:Pose = ? -- scale:Double = ?, name:String = ?, class:Seqable<String>|String = ?) -> SymbolNode
- Returns
SymbolNode
append¶
public defn append (sn:SymbolNode, vp:VirtualPin) -> False
- Returns
False
append¶
public defn append (sn:SymbolNode, g:Glyph) -> False
- Returns
False
append¶
public defn append (sn:SymbolNode, child:SymbolNode) -> False
- Returns
False
get-glyphs¶
Get all Glyph
instances in this node.
public defn get-glyphs (sn:SymbolNode) -> Tuple<Glyph>
- Returns
Tuple<Glyph>
approx-arc¶
public defn approx-arc (sn:SymbolNode, p:Point|[Double, Double], r:Double, a1:Double, a0:Double = ?, w:Double = ?, n:Int = ? -- name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
add-pin¶
public defn add-pin (sn:SymbolNode, pin-name:String|Ref, position:Point|[Double, Double]|[Int, Int] -- params:VirtualPinParams = ?, name:String = ?, class:Seqable<String>|String = ?) -> VirtualPin
- Returns
VirtualPin
add-value-label¶
public defn add-value-label (sn:SymbolNode, pos:Pose|Point|[Double, Double]|[Int, Int] -- anchor:Anchor = ?, unit-size:Double = ?)
text¶
public defn text (sn:SymbolNode, p:Pose|Point|[Double, Double]|[Int, Int], content:String|Printable -- font-size:Int = ?, anchor:Anchor = ?, name:String = ?, class:Seqable<String>|String = ?)
text¶
public defn text (sn:SymbolNode, p:Pose|Point|[Double, Double]|[Int, Int], content:String|Printable -- unit-size:Double, anchor:Anchor = ?, name:String = ?, class:Seqable<String>|String = ?)
append-all¶
public defn append-all (sn:SymbolNode, vps:Seqable<VirtualPin>) -> False
- Returns
False
append-all¶
public defn append-all (sn:SymbolNode, gs:Seqable<Glyph>) -> False
- Returns
False
rectangle¶
public defn rectangle (sn:SymbolNode, width:Double, height:Double -- anchor:Anchor = ?, pose:Pose = ?, name:String = ?, class:Seqable<String>|String = ?)
add-backend-substitutions¶
public defn add-backend-substitutions (sn:SymbolNode, nameSymbs:Seqable<KeyValue<String, SchematicSymbol>>)
line¶
public defn line (sn:SymbolNode, pts:Collection<Point|[Double, Double]|[Int, Int]> -- width:Double = ?, name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
glyph-bounds¶
Compute the bounding box around the glyphs of this symbol.
public defn glyph-bounds (sn:SymbolNode) -> Box
- Returns
Box
elements¶
public defn elements (sn:SymbolNode) -> Seq<SymbolElement>
- Returns
Seq<SymbolElement>
is-root?¶
public defn is-root? (sn:SymbolNode) -> True|False
- Returns
True|False
polygon¶
public defn polygon (sn:SymbolNode, pts:Collection<Point|[Double, Double]|[Int, Int]> -- name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
VirtualPin¶
Virtual Pin in the Symbol Node Frame of Reference
public defstruct VirtualPin <: SymbolElement
decorators: Vector<PinDecorator>
params: Maybe<VirtualPinParams>
pin-name: Ref
position: Point
-
decorators: Vector<PinDecorator>
- Optional set of decorators for this pin. -
params: Maybe<VirtualPinParams>
- Optional Pin Statement Parameters -
pin-name: Ref
- Pin Name This must be a valid symbol reference in JITX -
position: Point
- Position of the pin connection point This position is with respect to the currentSymbolNode
's frame of reference. This value is in millimeters.
This type allows the user to define a pin to be placed in the symbol node frame a reference. The pin can be created either as a single point or as a parameterized pin like one might consider in legacy CAD.
The single point pin version is often useful for two-pin components like resistors, capacitors, etc. The fully parameterized pin is often useful when you want to be explicit about pad reference or pin names.
Functions¶
get-pins¶
Get the VirtualPin
instances in this node and all descendents
public defn get-pins (sn:SymbolNode) -> Tuple<VirtualPin>
- Returns
Tuple<VirtualPin>
This function recursively retrieves all of the pins in this component.
make-vpin-symbol¶
public defn make-vpin-symbol (vp:VirtualPin, scale:Double, pose:Pose = ?)
add-pin¶
public defn add-pin (sn:SymbolNode, pin-name:String|Ref, position:Point|[Double, Double]|[Int, Int] -- params:VirtualPinParams = ?, name:String = ?, class:Seqable<String>|String = ?) -> VirtualPin
- Returns
VirtualPin
append¶
public defn append (sn:SymbolNode, vp:VirtualPin) -> False
- Returns
False
VirtualPin¶
public defn VirtualPin (pin-name:String|Ref, position:Point -- params:Maybe<VirtualPinParams> = ?, decorators:Seqable<PinDecorator> = ?, name?:Maybe<String> = ?, class:Seqable<String>|String = ?) -> VirtualPin
- Returns
VirtualPin
append-all¶
public defn append-all (sn:SymbolNode, vps:Seqable<VirtualPin>) -> False
- Returns
False
add-decorator¶
Add a decorator to this pin
public defn add-decorator (vp:VirtualPin, dec:PinDecorator)
User can add multiple decorators to a pin. Current implementation doesn't handle preventing overlap well.
add-decorator¶
public defn add-decorator (vp:VirtualPin, decs:Seqable<PinDecorator>)
Glyph¶
A Glyph is a set of geometry that creates an electrical symbol
public defstruct Glyph <: SymbolElement
art: Shape
art: Shape
This is used to group together geometry into various symbols. These symbols are often reusable. Primarily this is
Functions¶
add-glyph¶
public defn add-glyph (sn:SymbolNode, art:Shape -- name?:Maybe<String> = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
polyline¶
public defn polyline (sn:SymbolNode, pts:Collection<Arc|Point|[Double, Double]|[Int, Int]> -- width:Double = ?, name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
triangle¶
public defn triangle (sn:SymbolNode, p0:Point|[Double, Double], p1:Point|[Double, Double], w:Double -- name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
Glyph¶
public defn Glyph (art:Shape -- name?:Maybe<String> = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
append-all¶
public defn append-all (sn:SymbolNode, gs:Seqable<Glyph>) -> False
- Returns
False
circle¶
public defn circle (sn:SymbolNode, r:Double, p:Point|[Double, Double]|[Int, Int] = ? -- name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
line¶
public defn line (sn:SymbolNode, pts:Collection<Point|[Double, Double]|[Int, Int]> -- width:Double = ?, name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
line-rectangle¶
public defn line-rectangle (sn:SymbolNode, p0:Point, p1:Point, width:Double -- pose:Pose = ?, name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
make-glyph-symbol¶
public defn make-glyph-symbol (g:Glyph, scale:Double, pose:Pose = ?)
append¶
public defn append (sn:SymbolNode, g:Glyph) -> False
- Returns
False
polygon¶
public defn polygon (sn:SymbolNode, pts:Collection<Point|[Double, Double]|[Int, Int]> -- name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
get-glyphs¶
Get all Glyph
instances in this node.
public defn get-glyphs (sn:SymbolNode) -> Tuple<Glyph>
- Returns
Tuple<Glyph>
approx-arc¶
public defn approx-arc (sn:SymbolNode, p:Point|[Double, Double], r:Double, a1:Double, a0:Double = ?, w:Double = ?, n:Int = ? -- name:String = ?, class:Seqable<String>|String = ?) -> Glyph
- Returns
Glyph
General Definitions¶
font-to-unit¶
public defn font-to-unit (i:Int) -> Double
- Returns
Double
text-size¶
public defn text-size (content:String|Printable, unit-size:Double) -> Dims
- Returns
Dims
UNIT-TO-MM¶
public val UNIT-TO-MM
FONT-TO-UNIT¶
public val FONT-TO-UNIT
Related Packages¶
Forwarded by packages: jsl/symbols/framework, jsl/symbols