def __init__(self, view, predictor, workQueue, notifier): self.font = pygame.font.Font(None, 36) self.predictor = predictor self.workQueue = workQueue self.notifier = notifier self.view = view self.protocol = CalibrationProtocol(self.view, self.notifier, self)
class CalibrationController (ATTController): ID = "CALIBRATION" notifier = None workQueue = None predictor = None font = None view = None def __init__(self, view, predictor, workQueue, notifier): self.font = pygame.font.Font(None, 36) self.predictor = predictor self.workQueue = workQueue self.notifier = notifier self.view = view self.protocol = CalibrationProtocol(self.view, self.notifier, self) def start(self): pass def render(self): #self.view.buildScene() self.view.displayTable() self.view.displayReferencePoints() self.renderSerialLog() pygame.display.flip() def renderSerialLog(self): self.notifier.clearView() self.notifier.render() def renderSummary(self): if self.state == 1: if len(self.summary) > 0: self.view.renderSummary(self.summary) def process(self, app, event): done = False LEFTBUTTON = 1 if event.type == pygame.MOUSEBUTTONUP and event.button == LEFTBUTTON: _the_x, _the_y = event.pos logReading = "("+str(_the_x)+", "+str(_the_y)+")" self.notifier.push(logReading) if not self.workQueue.empty(): self.currentHit = self.workQueue.get() if self.currentHit <> "": self.processHit() self.render() if app.isPressed(pygame.K_ESCAPE): self.clearView() app.dispatcher.setCurrentController(MenuController.ID) return done def processHit(self, ): logReading = "> "+self.currentHit["raw"] #print logReading self.notifier.push(logReading) self.protocol.processSate(self.currentHit)