示例#1
0
	def getArrowEnd(self, atype):
		arrowEnd = GObject()
		if atype == "PREDCESSOR":
			arrowEnd.centerY((0,self.h))
			arrowEnd.x = self.x
			arrowEnd.y += self.y
		elif atype == "LOWER":
			arrowEnd = copy.copy(self.lowerArrowEnd)
			arrowEnd.x += self.x
			arrowEnd.y += self.y
			self.lowerArrowEnd.x += Constants.step.arrow_head_height
		elif atype == "UPPER":
			arrowEnd = copy.copy(self.upperArrowEnd)
			arrowEnd.x += self.x
			arrowEnd.y += self.y
			self.upperArrowEnd.x += Constants.step.arrow_head_height
		

		return arrowEnd
示例#2
0
class GStep(GObject):
	def __init__(self, step):
		GObject.__init__(self)
		self.h = Constants.step.h
		#initialize action
		self.action = newStepString(step.getAction()+ " "+step.getDescription())
		
		#initialize ingredients
		self.ingredients = []
		for i in step.getIngredients():
			self.ingredients.append(GIngredient(i))
		
		#calculate width
		self.w = 2*Constants.step.ingredient_padding
		for i in self.ingredients:
			self.w += i.w + Constants.step.ingredient_padding
		self.w += self.action.w

		#calculate ingredient x
		x = Constants.step.ingredient_padding
		for i in self.ingredients:
			i.x = x
			x += i.w + Constants.step.ingredient_padding
		
		#position action
		self.action.x = x
		self.action.centerY((0,self.h))
		x += self.action.w 

		#create bakckground
		if Constants.step.background_image:
			self.background = GBillboard(0,Constants.step.background_image)
			self.background.h = self.h
		
		else:
			self.background = GRect()
		
		self.background.w = self.w
		self.background.h = Constants.step.background_height
		self.background.centerY((0,self.h))

		#initialize arrow ends
		self.upperArrowEnd = GObject()
		self.upperArrowEnd.x = self.x + Constants.step.arrow_head_height/2.0
		self.upperArrowEnd.y = self.background.y + self.y + self.background.h
		
		self.lowerArrowEnd = GObject()
		self.lowerArrowEnd.x = Constants.step.arrow_head_height/2.0
		self.lowerArrowEnd.y = self.background.y


	def setColor(self,color):
		r,g,b,a = color
		r /= 255.0
		g /= 255.0
		b /= 255.0
		a /= 255.0
		color = r,g,b,a
		self.background.color = color

	def getColor(self):
		return self.background.color

	def getArrowBeginning(self):
		self.arrowBeginning = GObject()
		self.arrowBeginning.centerY((0,self.h))
		self.arrowBeginning.x  = self.x + self.w
		self.arrowBeginning.y += self.y
		return self.arrowBeginning

	def getArrowEnd(self, atype):
		arrowEnd = GObject()
		if atype == "PREDCESSOR":
			arrowEnd.centerY((0,self.h))
			arrowEnd.x = self.x
			arrowEnd.y += self.y
		elif atype == "LOWER":
			arrowEnd = copy.copy(self.lowerArrowEnd)
			arrowEnd.x += self.x
			arrowEnd.y += self.y
			self.lowerArrowEnd.x += Constants.step.arrow_head_height
		elif atype == "UPPER":
			arrowEnd = copy.copy(self.upperArrowEnd)
			arrowEnd.x += self.x
			arrowEnd.y += self.y
			self.upperArrowEnd.x += Constants.step.arrow_head_height
		

		return arrowEnd



	def draw(self,renderer):
		glPushMatrix()
		self.applyTransform()	
		
		#draw background
		self.background.draw(renderer)

		#draw ingredients
		for i in self.ingredients:
			i.draw(renderer)

		#draw action
		self.action.draw(renderer)

		glPopMatrix()