TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
tmk::io::BoardEditor Class Reference

#include <io/kicad/board_editor.hpp>

Public Member Functions

 BoardEditor (LoadedBoard &board, std::uint64_t seed=1)
 seed makes generated UUIDs deterministic.
void add_track (const model::Track &t)
void add_via (const model::Via &v)
void remove_track (std::size_t index)
void remove_via (std::size_t index)
void move_footprint (std::size_t index, model::Point pos, double angle)
 Moves footprint index to pos with orientation angle (degrees).
void flip_footprint (std::size_t index, model::Point pos, double angle)
 Moves footprint index to the other side of the board the way KiCad does (FOOTPRINT::Flip, top/bottom, about its own origin: local y and pad orientations negated, text angles 180° − a, F.
void add_zone (const model::Zone &z)
 Adds a board-level copper zone as KiCad writes one: net, layer (the zone's single copper layer), outline (first ring), clearance, minimum width, thermal and island settings, and its fills when it has any (doc 05 §53).
void set_zone_fills (std::size_t index, const std::vector< std::pair< int, std::vector< model::Point > > > &fills)
 Replaces the filled polygons of zone index (board.zones order) with fills (copper index, fractured polygon, as drc::refill_zones gives them) and marks the zone filled.
bool set_copper_layer_count (int n, std::string *why=nullptr, std::vector< std::string > *notes=nullptr)
 Gives the board n copper layers (even, 2..32; doc 05 §53): inner layers are added after the last one, or the last ones removed.
std::string write () const
void save (const std::string &path) const
std::string next_uuid ()
 Deterministic RFC-4122-style v4 UUID string.

Detailed Description

Definition at line 14 of file board_editor.hpp.

Constructor & Destructor Documentation

◆ BoardEditor()

tmk::io::BoardEditor::BoardEditor ( LoadedBoard & board,
std::uint64_t seed = 1 )
inline

seed makes generated UUIDs deterministic.

Definition at line 17 of file board_editor.hpp.

Member Function Documentation

◆ add_track()

void tmk::io::BoardEditor::add_track ( const model::Track & t)

◆ add_via()

void tmk::io::BoardEditor::add_via ( const model::Via & v)

◆ add_zone()

void tmk::io::BoardEditor::add_zone ( const model::Zone & z)

Adds a board-level copper zone as KiCad writes one: net, layer (the zone's single copper layer), outline (first ring), clearance, minimum width, thermal and island settings, and its fills when it has any (doc 05 §53).

◆ flip_footprint()

void tmk::io::BoardEditor::flip_footprint ( std::size_t index,
model::Point pos,
double angle )

Moves footprint index to the other side of the board the way KiCad does (FOOTPRINT::Flip, top/bottom, about its own origin: local y and pad orientations negated, text angles 180° − a, F.

  • <-> B.* layers, texts mirrored), then puts it at pos with the final orientation angle in degrees (flipped orientation −angle0 plus any rotation). Only for footprints where flip_supported() holds.

◆ move_footprint()

void tmk::io::BoardEditor::move_footprint ( std::size_t index,
model::Point pos,
double angle )

Moves footprint index to pos with orientation angle (degrees).

Pad and text orientations, which KiCad stores as absolute angles, are rotated by the same delta. Flipping sides is not supported here.

◆ next_uuid()

std::string tmk::io::BoardEditor::next_uuid ( )

Deterministic RFC-4122-style v4 UUID string.

◆ remove_track()

void tmk::io::BoardEditor::remove_track ( std::size_t index)

◆ remove_via()

void tmk::io::BoardEditor::remove_via ( std::size_t index)

◆ save()

void tmk::io::BoardEditor::save ( const std::string & path) const
inline

Definition at line 46 of file board_editor.hpp.

◆ set_copper_layer_count()

bool tmk::io::BoardEditor::set_copper_layer_count ( int n,
std::string * why = nullptr,
std::vector< std::string > * notes = nullptr )

Gives the board n copper layers (even, 2..32; doc 05 §53): inner layers are added after the last one, or the last ones removed.

Removing needs those layers empty (no track, arc, blind via, zone, graphic, text or pad that names them); through vias and plated holes follow the layer count by themselves. A (stackup) block is removed, since its copper and dielectrics no longer match, and KiCad builds its default stackup for the new count. Returns false with the reason in why (and the document unchanged) when it cannot; notes receives what changed besides the layers.

◆ set_zone_fills()

void tmk::io::BoardEditor::set_zone_fills ( std::size_t index,
const std::vector< std::pair< int, std::vector< model::Point > > > & fills )

Replaces the filled polygons of zone index (board.zones order) with fills (copper index, fractured polygon, as drc::refill_zones gives them) and marks the zone filled.

◆ write()

std::string tmk::io::BoardEditor::write ( ) const
inline

Definition at line 45 of file board_editor.hpp.


The documentation for this class was generated from the following file: