コード例 #1
0
ファイル: __init__.py プロジェクト: jbernardis/perfboard
	def doFixedComponent(self, pos):
		if self.currentFixedComponent is None:
			return
		
		cx = self.currentFixedComponent.getConnections()
		ncols, nrows = self.pb.getSize()
		for p in cx:
			if (pos[0]+p[0] >= ncols or pos[1]+p[1] >= nrows or
					pos[0]+p[0] < 0 or pos[1]+p[1] < 0):
				self.setStatusText("Component goes beyond board edge")
				return
			if self.pb.occupied([pos[0]+p[0], pos[1]+p[1]]):
				self.setStatusText("Position(s) already occupied")
				return
			if self.pb.noTrace([pos[0]+p[0], pos[1]+p[1]]):
				self.setStatusText("no Trace at that position")
				return

		self.currentFixedComponent.setAnchor(pos)

		nm = compID.generateID(self.currentComponentPrefix) 
		self.currentFixedComponent.setID(nm)  
		cv = self.currentFixedComponent.getView()		
		self.pb.addComponent(self.currentFixedComponent)
		self.currentFixedComponent = self.newFixedComponent()
		self.currentFixedComponent.setAnchor(pos)
		self.fixedComponentList.setView(self.currentFixedComponent, cv)
		self.dsp.setFixedComponent(self.currentFixedComponent)
コード例 #2
0
ファイル: __init__.py プロジェクト: jbernardis/perfboard
	def doStretchComponent(self, pos, nm=None):
		if self.pb.occupied(pos):
			self.setStatusText("Position is already occupied")
			return
		
		if self.pb.noTrace(pos):
			self.setStatusText("No trace at that position")
			return

		if nm == WIRENAME:
			self.dsp.setWireColor(self.wireColor)

		pt = self.currentStretchComponent.getP1()
		if pt is None:
			self.currentStretchComponent.setP1(pos)
			self.currentStretchComponent.setP2(pos)

		else:
			if pos[0] == pt[0] and pos[1] == pt[1]:
				self.setStatusText("Cannot start and end on the same position")
				return
			
			if self.pb.sameTrace(pos, pt):
				# re-anchor
				self.currentStretchComponent.setP1(pos)
				self.currentStretchComponent.setP2(pos)

			elif nm == WIRENAME:
				self.currentStretchComponent.setP2(pos)
				wid = compID.generateID(self.currentComponentPrefix) 
				self.currentStretchComponent.setID(wid)
				self.pb.addWire(self.currentStretchComponent, self.wireColor)
				self.currentStretchComponent = self.newStretchComponent(WIRENAME)
				self.dsp.setStretchComponent(self.currentStretchComponent)
				
			else:
				self.currentStretchComponent.setP2(pos)
				nm = compID.generateID(self.currentComponentPrefix) 
				self.currentStretchComponent.setID(nm)
				self.pb.addStretchComponent(self.currentStretchComponent)
				self.currentStretchComponent = self.newStretchComponent()
				self.dsp.setStretchComponent(self.currentStretchComponent)
		self.dsp.refresh()
コード例 #3
0
ファイル: __init__.py プロジェクト: jbernardis/perfboard
	def doGrowComponent(self, pos):
		if self.pb.occupied(pos):
			self.setStatusText("Position is already occupied")
			return
		
		if self.pb.noTrace(pos):
			self.setStatusText("no Trace at that position")
			return

		pt = self.currentGrowComponent.getP1()
		if pt is None:
			self.currentGrowComponent.setP1(pos)
			self.currentGrowComponent.setP2(pos)

		else:
			self.dsp.checkGrowEnd(pos)
			nm = compID.generateID(self.currentComponentPrefix) 
			self.currentGrowComponent.setID(nm)
			self.pb.addGrowComponent(self.currentGrowComponent)
			self.currentGrowComponent = self.newGrowComponent()
			self.dsp.setGrowComponent(self.currentGrowComponent)
		self.dsp.refresh()