interactive_html_bom

Struct InteractiveHtmlBom

Source
#[non_exhaustive]
pub struct InteractiveHtmlBom {
Show 21 fields pub view_mode: ViewMode, pub highlight_pin1: HighlightPin1Mode, pub dark_mode: bool, pub board_rotation: f32, pub offset_back_rotation: bool, pub show_silkscreen: bool, pub show_fabrication: bool, pub show_pads: bool, pub checkboxes: Vec<String>, pub fields: Vec<String>, pub user_header: String, pub user_footer: String, pub user_js: String, pub drawings: Vec<Drawing>, pub tracks: Vec<Track>, pub vias: Vec<Via>, pub zones: Vec<Zone>, pub footprints: Vec<Footprint>, pub bom_front: Vec<Vec<RefMap>>, pub bom_back: Vec<Vec<RefMap>>, pub bom_both: Vec<Vec<RefMap>>, /* private fields */
}
Expand description

Interactive HTML BOM structure

The top-level structure to build & generate a HTML BOM.

Please note that this struct is not completely fool-proof as it does not validate lots of the added data. So make sure you add only valid BOM data. Only the most important things are validated to avoid generating completely broken HTML pages: Footprint IDs in BOM rows, and number of fields in footprints.

§Examples

use interactive_html_bom::*;

let mut ibom = InteractiveHtmlBom::new(
  "My Project",   // Title
  "My Company",   // Company
  "Rev. 1",       // Revision
  "1970-01-01",   // Date
  (0.0, 0.0),     // Bottom left
  (100.0, 80.0),  // Top right
);

// Set configuration.
ibom.fields = vec!["Value".into(), "Footprint".into()];

// Draw PCB.
ibom.drawings.push(Drawing::new(
  DrawingKind::Polygon,             // Kind of drawing
  DrawingLayer::Edge,               // Layer
  "M 0 0 H 100 V 80 H -100 V -80",  // SVG path
  0.1,                              // Line width
  false,                            // Filled
));
ibom.drawings.push(Drawing::new(
  DrawingKind::ReferenceText,
  DrawingLayer::SilkscreenFront,
  "M 10 10 H 80 V 60 H -80 V -60",
  0.1,
  false,
));

// Add footprints.
let id = ibom.add_footprint(
  Footprint::new(
    Layer::Front,                       // Layer
    (50.0, 40.0),                       // Position
    45.0,                               // Rotation
    (-2.0, -1.0),                       // Bottom left
    (2.0, 1.0),                         // Top right
    &["100R".into(), "0603".into()],    // Fields
    &[Pad::new(
        &[Layer::Front],                // Pad layers
        (-2.0, 0.0),                    // Pad position
        0.0,                            // Pad rotation
        "M -1 -1 H 2 V 2 H -2 V -2",    // Pad shape (SVG)
        None,                           // Pad drill
        None,                           // Pad net
        true,                           // Pin 1
      ),
      // [...]
    ],
    true,                               // Mount or not
  ),
);

// Add BOM rows (designators and their footprint IDs).
ibom.bom_front.push(vec![RefMap::new("R1", id)]);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§view_mode: ViewMode

Initial view mode

§highlight_pin1: HighlightPin1Mode

Hightlight pin-1 mode

§dark_mode: bool

Dark mode on/off

§board_rotation: f32

Board drawings rotation [°]

§offset_back_rotation: bool

Whether to offset the back side rotation or not

§show_silkscreen: bool

Silkscreen visibility

§show_fabrication: bool

Fabrication layer visibility

§show_pads: bool

Pads visibility

§checkboxes: Vec<String>

Checkbox column names

§fields: Vec<String>

Custom field names, listed as columns

§user_header: String

User-defined HTML header

This should be used carefully as we neither guarantee forward- nor backward-compatibility.
§user_footer: String

User-defined HTML footer

This should be used carefully as we neither guarantee forward- nor backward-compatibility.
§user_js: String

User-defined JavaScript

This should be used carefully as we neither guarantee forward- nor backward-compatibility.
§drawings: Vec<Drawing>

Drawings (PCB edges, silkscreen, fabrication)

§tracks: Vec<Track>

PCB tracks

§vias: Vec<Via>

PCB vias

§zones: Vec<Zone>

PCB zones

§footprints: Vec<Footprint>

Footprints

§bom_front: Vec<Vec<RefMap>>

BOM rows front side

§bom_back: Vec<Vec<RefMap>>

BOM rows back side

§bom_both: Vec<Vec<RefMap>>

BOM rows front+back

Implementations§

Source§

impl InteractiveHtmlBom

Source

pub fn new( title: &str, company: &str, revision: &str, date: &str, bottom_left: (f32, f32), top_right: (f32, f32), ) -> InteractiveHtmlBom

Construct object

§Arguments
  • title - Project title.
  • company - Company/author name.
  • revision - Project revision.
  • date - Date/time as desired.
  • bottom_left - Bottom left corner of bounding box (x, y) [mm].
  • top_right - Top right corner of bounding box (x, y) [mm].
§Returns

Returns the new object.

Source

pub fn add_footprint(&mut self, fpt: Footprint) -> usize

Add footprint

§Arguments
  • fpt - The footprint to add.
§Returns

Returns the ID of the added footprint, to be used for referencing it in BOM rows.

Source

pub fn generate_html(&self) -> Result<String, String>

Generate HTML

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.