Exemplo n.º 1
0
    def onNew(self, evt):
        compID.reInit()
        dlg = NewFileDialog(self)
        rc = dlg.ShowModal()
        if rc == wx.ID_OK:
            pb = dlg.getData()

        dlg.Destroy()
        if rc != wx.ID_OK:
            return

        if pb is None:
            return

        self.fileName = None
        self.presentEditor(pb)
Exemplo n.º 2
0
	def onNew(self, evt): 
		compID.reInit()	   
		dlg = NewFileDialog(self)
		rc = dlg.ShowModal()
		if rc == wx.ID_OK:
			pb = dlg.getData()
			
		dlg.Destroy()
		if rc != wx.ID_OK:
			return
		
		if pb is None:
			return
		
		self.fileName = None
		self.presentEditor(pb)
Exemplo n.º 3
0
    def loadBoard(self, fn):
        try:
            with open(fn, "r") as x:
                xml = x.read()
        except:
            return None

        xmldoc = XMLDoc(
            xml, makelist=["trace", "cut", "removal", "wire", "component"])

        compID.reInit()

        root = xmldoc.getRoot()
        sz = [int(x) for x in str(root.size).split(',')]

        pb = ProtoBoard(sz[0], sz[1])

        try:
            pb.setDescription((str(root.description)))
        except AttributeError:
            pb.setDescription(None)

        try:
            tl = root.htraces.trace
        except AttributeError:
            tl = []

        for t in tl:
            trc = [int(x) for x in str(t).split(',')]
            pb.addHTrace(trc[0], trc[1], trc[2])

        try:
            tl = root.vtraces.trace
        except AttributeError:
            tl = []

        for t in tl:
            trc = [int(x) for x in str(t).split(',')]
            pb.addVTrace(trc[0], trc[1], trc[2])

        try:
            s = str(root.hskips).strip()
        except AttributeError:
            s = ""

        if len(s) > 0:
            for sk in s.split(','):
                pb.addHSkip(int(sk))

        try:
            s = str(root.vskips).strip()
        except AttributeError:
            s = ""

        if len(s) > 0:
            for sk in s.split(','):
                pb.addVSkip(int(sk))

        try:
            cl = root.hcuts.cut
        except AttributeError:
            cl = []

        for c in cl:
            cut = [int(x) for x in str(c).split(',')]
            pb.addHCut(cut[0], cut[1], cut[2])

        try:
            cl = root.vcuts.cut
        except AttributeError:
            cl = []

        for c in cl:
            cut = [int(x) for x in str(c).split(',')]
            pb.addVCut(cut[0], cut[1], cut[2])

        try:
            rl = root.removals.removal
        except AttributeError:
            rl = []

        for r in rl:
            rmv = [int(x) for x in str(r).split(',')]
            pb.traceRemove([rmv[0], rmv[1]])

        try:
            wirelist = root.wires.wire
        except AttributeError:
            wirelist = []

        for w in wirelist:
            s = str(w.pointa)
            pta = [int(x) for x in s.split(',')]
            s = str(w.pointb)
            ptb = [int(x) for x in s.split(',')]
            s = str(w.color)
            clr = [int(x) for x in s.split(',')]

            c = StretchComponent(WIRENAME, pta, ptb, LT_WIRE)
            pb.addWire(c, wx.Colour(clr[0], clr[1], clr[2]))

        try:
            complist = root.components.component
        except AttributeError:
            complist = []

        cl = self.settings.fixedComponentList
        for c in complist:
            tp = str(c.type)
            cid = str(c.id)
            nm = str(c.name)
            value = str(c.value)
            s = str(c.anchor)
            vw = int(str(c.view))

            anchor = [int(x) for x in s.split(',')]
            comp = cl.getComponent(tp)[0]
            comp.setID(cid)
            comp.setName(nm)
            comp.setValue(value)
            comp.setAnchor(anchor)
            cl.setView(comp, vw)
            pb.addComponent(comp)
            compID.reserveID(cid)

        try:
            complist = root.stretchcomponents.component
        except AttributeError:
            complist = []

        cl = self.settings.stretchComponentList
        for c in complist:
            tp = str(c.type)
            cid = str(c.id)
            nm = str(c.name)
            value = str(c.value)
            s = str(c.pointa)
            pta = [int(x) for x in s.split(',')]
            s = str(c.pointb)
            ptb = [int(x) for x in s.split(',')]

            comp = cl.getComponent(tp)[0]
            comp.setID(cid)
            comp.setP1(pta)
            comp.setP2(ptb)
            comp.setName(nm)
            comp.setValue(value)
            pb.addStretchComponent(comp)
            compID.reserveID(cid)

        try:
            complist = root.growcomponents.component
        except AttributeError:
            complist = []

        cl = self.settings.growComponentList
        for c in complist:
            tp = str(c.type)
            cid = str(c.id)
            nm = str(c.name)
            value = str(c.value)
            s = str(c.pointa)
            pta = [int(x) for x in s.split(',')]
            s = str(c.pointb)
            ptb = [int(x) for x in s.split(',')]

            comp = cl.getComponent(tp)[0]
            comp.setID(cid)
            comp.setP1(pta)
            comp.setP2(ptb)
            comp.setName(nm)
            comp.setValue(value)
            pb.addGrowComponent(comp)
            compID.reserveID(cid)

        pb.setModified(False)
        return pb
Exemplo n.º 4
0
	def loadBoard(self, fn):
		try:
			with open(fn, "r") as x: xml = x.read()
		except:
			return None
		
		xmldoc = XMLDoc(xml, makelist=["trace", "cut", "removal", "wire", "component"])
		
		compID.reInit()
		
		root = xmldoc.getRoot()
		sz = [int(x) for x in str(root.size).split(',')]
		
		pb = ProtoBoard(sz[0], sz[1])
		
		try:
			pb.setDescription((str(root.description)))
		except AttributeError:
			pb.setDescription(None)
		
		try:
			tl = root.htraces.trace
		except AttributeError:
			tl = []
			
		for t in tl:
			trc = [int(x) for x in str(t).split(',')]
			pb.addHTrace(trc[0], trc[1], trc[2])
		
		try:
			tl = root.vtraces.trace
		except AttributeError:
			tl = []
			
		for t in tl:
			trc = [int(x) for x in str(t).split(',')]
			pb.addVTrace(trc[0], trc[1], trc[2])
		
		try:
			s = str(root.hskips).strip()
		except AttributeError:
			s = ""

		if len(s) > 0:
			for sk in s.split(','):
				pb.addHSkip(int(sk))
		
		try:
			s = str(root.vskips).strip()
		except AttributeError:
			s = ""

		if len(s) > 0:
			for sk in s.split(','):
				pb.addVSkip(int(sk))
		
		try:
			cl = root.hcuts.cut
		except AttributeError:
			cl = []
			
		for c in cl:
			cut = [int(x) for x in str(c).split(',')]
			pb.addHCut(cut[0], cut[1], cut[2])
		
		try:
			cl = root.vcuts.cut
		except AttributeError:
			cl = []
			
		for c in cl:
			cut = [int(x) for x in str(c).split(',')]
			pb.addVCut(cut[0], cut[1], cut[2])
		
		try:
			rl = root.removals.removal
		except AttributeError:
			rl = []
			
		for r in rl:
			rmv = [int(x) for x in str(r).split(',')]
			pb.traceRemove([rmv[0], rmv[1]])

		try:
			wirelist = root.wires.wire
		except AttributeError:
			wirelist = []

		for w in wirelist:
			s = str(w.pointa)
			pta = [int(x) for x in s.split(',')]
			s = str(w.pointb)
			ptb = [int(x) for x in s.split(',')]
			s = str(w.color)
			clr = [int(x) for x in s.split(',')]

			c = StretchComponent(WIRENAME, pta, ptb, LT_WIRE)
			pb.addWire(c, wx.Colour(clr[0], clr[1], clr[2]))

		try:
			complist = root.components.component
		except AttributeError:
			complist = []

		cl = self.settings.fixedComponentList
		for c in complist:
			tp = str(c.type)
			cid = str(c.id)
			nm = str(c.name)
			value = str(c.value)
			s = str(c.anchor)
			vw = int(str(c.view))
			
			anchor = [int(x) for x in s.split(',')]
			comp = cl.getComponent(tp)[0]
			comp.setID(cid)
			comp.setName(nm)
			comp.setValue(value)
			comp.setAnchor(anchor)
			cl.setView(comp, vw)
			pb.addComponent(comp)
			compID.reserveID(cid)

		try:
			complist = root.stretchcomponents.component
		except AttributeError:
			complist = []

		cl = self.settings.stretchComponentList
		for c in complist:
			tp = str(c.type)
			cid = str(c.id)
			nm = str(c.name)
			value = str(c.value)
			s = str(c.pointa)
			pta = [int(x) for x in s.split(',')]
			s = str(c.pointb)
			ptb = [int(x) for x in s.split(',')]

			comp = cl.getComponent(tp)[0]
			comp.setID(cid)
			comp.setP1(pta)
			comp.setP2(ptb)
			comp.setName(nm)
			comp.setValue(value)
			pb.addStretchComponent(comp)
			compID.reserveID(cid) 

		try:
			complist = root.growcomponents.component
		except AttributeError:
			complist = []

		cl = self.settings.growComponentList
		for c in complist:
			tp = str(c.type)
			cid = str(c.id)
			nm = str(c.name)
			value = str(c.value)
			s = str(c.pointa)
			pta = [int(x) for x in s.split(',')]
			s = str(c.pointb)
			ptb = [int(x) for x in s.split(',')]

			comp = cl.getComponent(tp)[0]
			comp.setID(cid)
			comp.setP1(pta)
			comp.setP2(ptb)
			comp.setName(nm)
			comp.setValue(value)
			pb.addGrowComponent(comp)
			compID.reserveID(cid)

			
		pb.setModified(False)
		return pb