Skip to content

Iterative way to add track points #3

Description

@osresearch

For tracks that have to cross multiple reference frames it is helpful to be able to add points to them, where each new point is computed in the current matrix. I hacked something together in my code to do this, which might be useful to figure out how to add it to the library.

class Track:
        def __init__(self, painter, net=None):
                self.painter = painter
                self.net = net
                self.prev = None
        def add(self, x, y):
                new_xy = self.painter._local_to_world(x,y)
                if self.prev is None:
                        self.prev = new_xy
                        return

                track = pcbnew.PCB_TRACK(self.painter.pcb)
                track.SetWidth(pcbnew.FromMM(self.painter.draw_width))
                track.SetLayer(self.painter.layers[self.painter.draw_layer])
                if self.net is not None:
                        track.SetNet(self.painter._find_net(self.net))
                track.SetStart(self.prev)
                track.SetEnd(new_xy)
                self.prev = new_xy
                return self.painter._add_item(track)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions