示例#1
0
文件: artwork.py 项目: balr0g/pcbre
    def deserialize(self, msg):
        for i in msg.vias:
            v = Via(deserialize_point2(i.point),
                    self.__project.scontext.get(i.viapairSid),
                    i.r,
                    self.__project.scontext.get(i.netSid)
            )

            self.add_artwork(v)

        for i in msg.traces:
            t = Trace(
                deserialize_point2(i.p0),
                deserialize_point2(i.p1),
                i.thickness,
                self.__project.scontext.get(i.layerSid),
                self.__project.scontext.get(i.netSid)
            )

            self.add_artwork(t)

        for i in msg.polygons:
            exterior = [deserialize_point2(j) for j in i.exterior]
            interiors = [[deserialize_point2(k) for k in j] for j in i.interiors]

            p = Polygon(
                self.__project.scontext.get(i.layerSid),
                exterior,
                interiors,
                self.__project.scontext.get(i.netSid)
            )

            self.add_artwork(p)

        for i in msg.airwires:
            aw = Airwire(
                deserialize_point2(i.p0),
                deserialize_point2(i.p1),
                self.__project.scontext.get(i.p0LayerSid),
                self.__project.scontext.get(i.p1LayerSid),
                self.__project.scontext.get(i.netSid)
            )
            self.add_artwork(aw)

        for i in msg.components:
            if i.which() == "dip":
                cmp = DIPComponent.deserialize(self.__project, i)
            elif i.which() == "smd4":
                cmp = SMD4Component.deserialize(self.__project, i)
            else:
                raise NotImplementedError()

            self.add_component(cmp)
示例#2
0
    def deserialize(self, msg: ser.Artwork) -> None:
        for i_via in msg.vias:
            v = Via(deserialize_point2(i_via.point),
                    self.__project.scontext.get(i_via.viapairSid), i_via.r,
                    self.__lookup_net_helper(i_via.netSid))

            self.add_artwork(v)

        for i_trace in msg.traces:
            t = Trace(deserialize_point2(i_trace.p0),
                      deserialize_point2(i_trace.p1), i_trace.thickness,
                      self.__project.scontext.get(i_trace.layerSid),
                      self.__lookup_net_helper(i_trace.netSid))
            self.add_artwork(t)

        for i_poly in msg.polygons:
            exterior = [deserialize_point2(j) for j in i_poly.exterior]
            interiors = [[deserialize_point2(k) for k in j]
                         for j in i_poly.interiors]

            p = Polygon(self.__project.scontext.get(i_poly.layerSid), exterior,
                        interiors, self.__lookup_net_helper(i_poly.netSid))

            self.add_artwork(p)

        for i_airwire in msg.airwires:
            aw = Airwire(deserialize_point2(i_airwire.p0),
                         deserialize_point2(i_airwire.p1),
                         self.__project.scontext.get(i_airwire.p0LayerSid),
                         self.__project.scontext.get(i_airwire.p1LayerSid),
                         self.__project.scontext.get(i_airwire.netSid))
            self.add_artwork(aw)

        for i_cmp in msg.components:
            if i_cmp.which() == "dip":
                cmp = DIPComponent.deserialize(self.__project, i_cmp)
            elif i_cmp.which() == "sip":
                cmp = SIPComponent.deserialize(self.__project, i_cmp)

            elif i_cmp.which() == "smd4":
                cmp = SMD4Component.deserialize(self.__project, i_cmp)
            elif i_cmp.which() == "passive2":
                cmp = Passive2Component.deserialize(self.__project, i_cmp)
            else:
                raise NotImplementedError()

            self.add_component(cmp)
示例#3
0
    def deserialize(self, msg):
        for i in msg.vias:
            v = Via(deserialize_point2(i.point),
                    self.__project.scontext.get(i.viapairSid), i.r,
                    self.__project.scontext.get(i.netSid))

            self.add_artwork(v)

        for i in msg.traces:
            t = Trace(deserialize_point2(i.p0), deserialize_point2(i.p1),
                      i.thickness, self.__project.scontext.get(i.layerSid),
                      self.__project.scontext.get(i.netSid))

            self.add_artwork(t)

        for i in msg.polygons:
            exterior = [deserialize_point2(j) for j in i.exterior]
            interiors = [[deserialize_point2(k) for k in j]
                         for j in i.interiors]

            p = Polygon(self.__project.scontext.get(i.layerSid), exterior,
                        interiors, self.__project.scontext.get(i.netSid))

            self.add_artwork(p)

        for i in msg.airwires:
            aw = Airwire(deserialize_point2(i.p0), deserialize_point2(i.p1),
                         self.__project.scontext.get(i.p0LayerSid),
                         self.__project.scontext.get(i.p1LayerSid),
                         self.__project.scontext.get(i.netSid))
            self.add_artwork(aw)

        for i in msg.components:
            if i.which() == "dip":
                cmp = DIPComponent.deserialize(self.__project, i)
            elif i.which() == "smd4":
                cmp = SMD4Component.deserialize(self.__project, i)
            else:
                raise NotImplementedError()

            self.add_component(cmp)