From c581408f028d5b8ceadc53c68d7c1252fbe09e6d Mon Sep 17 00:00:00 2001 From: rcoh Date: Wed, 22 Dec 2010 14:27:33 -0500 Subject: About halfway done with support for pixel regions. Modified the component registry a bit. Added support for multiple pixel mappers (and along with that, default components). RCOH --- pixelcore/PixelStrip.py | 1 - pixelcore/Screen.py | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'pixelcore') diff --git a/pixelcore/PixelStrip.py b/pixelcore/PixelStrip.py index cfab948..fceff8e 100644 --- a/pixelcore/PixelStrip.py +++ b/pixelcore/PixelStrip.py @@ -4,7 +4,6 @@ import util.Geo as Geo from pixelevents.StepEvent import * import pygame import math -import Util import pdb #Python class representing a single Pixel strip (usually 50 Pixels) class PixelStrip: diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py index a20cc72..da03ad2 100644 --- a/pixelcore/Screen.py +++ b/pixelcore/Screen.py @@ -1,7 +1,10 @@ from pixelcore.Pixel import * from pixelcore.PixelStrip import * from operationscore.PixelEvent import * +from operationscore.PixelMapper import * import util.Search as Search +import util.ComponentRegistry as compReg +import util.Strings as Strings import itertools #Class representing a collection of Pixels grouped into PixelStrips. Needs a #PixelMapper, currently set via setMapper by may be migrated into the argDict. @@ -29,8 +32,6 @@ class Screen: self.xPixelLocs = [p[0] for p in self.xSortedPixels] def render(self, surface): [lS.render(surface) for lS in self.pixelStrips] - def setMapper(self, mapper): - self.mapper = mapper def allOn(self): [lS.allOn(-1) for lS in self.pixelStrips] def __iter__(self): #the iterator of all our pixel strips chained togther @@ -70,8 +71,13 @@ class Screen: #[strip.respond(dict(responseInfo)) for strip in self.pixelStrips] if type(responseInfo) != type(dict()): pass - #pdb.set_trace() - pixelWeightList = self.mapper.mapEvent(responseInfo['Location'], self) + if 'Mapper' in responseInfo: + mapper = compReg.getComponent(responseInfo['Mapper']) + else: + mapper = compReg.getComponent(Strings.DEFAULT_MAPPER) + #if type(mapper) != type(PixelMapper): + # raise Exception('No default mapper specified.') + pixelWeightList = mapper.mapEvent(responseInfo['Location'], self) PixelEvent.addPixelEventIfMissing(responseInfo) for (pixel, weight) in pixelWeightList: pixel.processInput(responseInfo['PixelEvent'].scale(weight), 0) #TODO: z-index -- cgit v1.2.3