示例#1
0
    def initUIComponents(self):
        # listen to shutdown events
        ogl_display = OpenGLDisplay().getDisplayService()[0]
        self.link((ogl_display, "signal"), (self, "control"))

        # init mover
        self.mover = WheelMover(radius=15,
                                center=(0, 0, -25),
                                steps=500,
                                slots=40).activate()
        self.link((self, "mover_signal"), (self.mover, "notify"))
        self.link((self, "mover_switch"), (self.mover, "switch"))

        self.background = SkyGrassBackground(size=(5000, 5000, 0),
                                             position=(0, 0, -90)).activate()

        # create & link nav buttons
        self.up_button = ArrowButton(size=(1, 1, 0.3),
                                     position=(7, 5, -15),
                                     msg="UP").activate()
        self.down_button = ArrowButton(size=(1, 1, 0.3),
                                       position=(7, -5, -15),
                                       rotation=(0, 0, 180),
                                       msg="DOWN").activate()
        self.link((self.up_button, "outbox"), (self, "nav"))
        self.link((self.down_button, "outbox"), (self, "nav"))

        # init info display
        self.infoticker = Ticker(text_height=21,
                                 render_right=250,
                                 render_bottom=500,
                                 background_colour=(250, 250, 200),
                                 text_colour=(0, 0, 0),
                                 outline_colour=(255, 255, 255)).activate()
        self.tickerwrapper = PygameWrapper(wrap=self.infoticker,
                                           size=(2.4, 4.0, 0.3)).activate()
        self.hideinfo_button = Button(caption="Hide", fontsize=30).activate()

        infocontents = {
            self.tickerwrapper: {
                "position": (0, 0, 0)
            },
            self.hideinfo_button: {
                "position": (0, -2.4, 0)
            },
        }

        self.infocontainer = Container(contents=infocontents,
                                       position=(-10, 10, -16)).activate()
        infopath = LinearPath([(-10, 10, -16), (-3, 0, -8)], 100)

        self.infomover = PathMover(infopath, False).activate()

        self.link((self.infomover, "outbox"), (self.infocontainer, "position"))
        self.link((self, "infomover_commands"), (self.infomover, "inbox"))
        self.link((self, "torrent_info"), (self.infoticker, "inbox"))
        self.link((self.hideinfo_button, "outbox"), (self, "hide_info"))

        self.send("Stop", "infomover_commands")
示例#2
0
def player(*argv, **argd):
    screen = VideoSurface()
    screen_in_scene = PygameWrapper(wrap=screen, position=(0, 0,-8), rotation=(-30,15,3)).activate()

    i1 = MatchedTranslationInteractor(target=screen_in_scene).activate()

    return Pipeline(
               DiracDecoder(),
               ToRGB_interleaved(),
               screen,
           )
示例#3
0
 height = 768
 top = 0
 left = 0
 colours_order = [ "black", "red", "orange", "yellow", "green", "turquoise", "blue", "purple", "darkgrey", "lightgrey" ]
 ogl_display = OpenGLDisplay(title="Kamaelia Whiteboard",width=width,height=height,background_colour=(255,255,255))
 ogl_display.activate()
 OpenGLDisplay.setDisplayService(ogl_display)
 
 ogl_display = OpenGLDisplay.getDisplayService()
 PygameDisplay.setDisplayService(ogl_display[0])
 
 if (0):
     #PygameDisplay.setDisplayService(ogl_display)
     CANVAS = Canvas( position=(left,top+32),size=(1200,(900-(32+15))),notepad="Test" ).activate() #(replace width with 'width' and height with 'height-(32+15)'
     PAINTER = Painter().activate()
     CANVAS_WRAPPER = PygameWrapper(wrap=CANVAS, position=(0,0,-10), rotation=(0,0,0)).activate() 
     ERASER  = Eraser(left,top).activate()
     PALETTE = buildPalette( cols=colours, order=colours_order, topleft=(left+64,top), size=32 ).activate()
     CLEAR = ClearPage(left+(64*5)+32*len(colours),top).activate()
     #PALETTE_WRAPPER = PygameWrapper(wrap=PALETTE, position=(4,1,-10), rotation=(-20,15,3)).activate()
 
     #PAINTER_WRAPPER = PygameWrapper(wrap=PAINTER, position=(4,1,-10), rotation=(-20,15,3)).activate()
     CANVAS.link( (PAINTER,"outbox"), (CANVAS, "inbox") )
     PAINTER.link( (CANVAS,"eventsOut"), (PAINTER, "inbox") )
     PAINTER.link( (PALETTE,"outbox"), (PAINTER, "colour") )
     PAINTER.link( (ERASER, "outbox"), (PAINTER, "erase") )
     PAINTER.link( (CLEAR, "outbox"), (CANVAS, "inbox") )
     
 CANVAS = Canvas( position=(left,top+32),size=(1200,(900-(32+15))),notepad="Test" ).activate() #(replace width with 'width' and height with 'height-(32+15)'
 PAINTER = Painter().activate()
 ERASER  = Eraser(left,top).activate()
示例#4
0
from Kamaelia.Codec.Dirac import DiracDecoder
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Util.RateFilter import MessageRateLimit
from VideoSurface import VideoSurface
from PixFormatConversion import ToRGB_interleaved

from Kamaelia.UI.PygameDisplay import PygameDisplay
from Kamaelia.UI.OpenGL.OpenGLDisplay import OpenGLDisplay
from Kamaelia.UI.OpenGL.PygameWrapper import PygameWrapper
from Kamaelia.UI.OpenGL.SkyGrassBackground import SkyGrassBackground
from Kamaelia.UI.OpenGL.Movement import SimpleRotator

file = "../../../Code/Python/Kamaelia/Examples/VideoCodecs/Dirac/snowboard-jump-352x288x75.0.5.4.drc"
framerate = 15

# override pygame display service
ogl_display = OpenGLDisplay.getDisplayService()
PygameDisplay.setDisplayService(ogl_display[0])

SkyGrassBackground(size=(5000, 5000, 0), position=(0, 0, -100)).activate()
screen = VideoSurface()
screen__in_scene = PygameWrapper(wrap=screen,
                                 position=(0, 0, -5),
                                 rotation=(-30, 15, 3)).activate()
rotator = SimpleRotator(amount=(0.0, 0.0, 0.5)).activate()
rotator.link((rotator, "outbox"), (screen__in_scene, "rel_rotation"))

Pipeline(ReadFileAdaptor(file, readmode="bitrate", bitrate=300000 * 8 / 5),
         DiracDecoder(), ToRGB_interleaved(),
         MessageRateLimit(framerate, buffer=15), screen).run()
示例#5
0
READER = Textbox(size=(400, 300), text_height=30).activate()
WRITER = TextDisplayer(size=(400, 300), text_height=30).activate()

SCREEN = VideoSurface().activate()

Pipeline(
    ReadFileAdaptor("TestMaterial/TrainWindow.drc",
                    readmode="bitrate",
                    bitrate=1000000),
    DiracDecoder(),
    MessageRateLimit(10),
    ToRGB_interleaved(),
    SCREEN,
).activate()

R_ = PygameWrapper(wrap=READER, position=(-2, -2, -10),
                   rotation=(20, 10, 0)).activate()

W_ = PygameWrapper(wrap=WRITER, position=(2, 2, -10),
                   rotation=(20, 10, 0)).activate()

S_ = PygameWrapper(wrap=SCREEN, position=(-2, 2, -10),
                   rotation=(20, 10, 0)).activate()

i1 = MatchedTranslationInteractor(target=R_).activate()
i2 = MatchedTranslationInteractor(target=W_).activate()
i3 = MatchedTranslationInteractor(target=S_).activate()

button1 = Button(caption="QUIT", msg="QUIT").activate()


class Quitter(Axon.Component.component):
示例#6
0
def makeBasicSketcher(left=0, top=0, width=1024, height=768):
    CANVAS = Canvas(position=(left, top + 32),
                    size=(width, (height - (32 + 15))),
                    notepad=notepad)
    CANVAS_WRAPPER = PygameWrapper(wrap=CANVAS,
                                   position=(0, 0, -10),
                                   rotation=(0, 0, 0))
    return Graphline(
        CANVAS=CANVAS,
        CANVAS_WRAPPER=CANVAS_WRAPPER,
        #MOVER = MatchedTranslationInteractor(target=CANVAS_WRAPPER),
        PAINTER=Painter(),
        PALETTE=buildPalette(cols=colours,
                             order=colours_order,
                             topleft=(left + 64, top),
                             size=32),
        ERASER=Eraser(left, top),
        CLEAR=ClearPage(left + (64 * 5) + 32 * len(colours), top),
        SAVEDECK=SaveDeck(left + (64 * 8) + 32 * len(colours), top),
        LOADDECK=LoadDeck(left + (64 * 7) + 32 * len(colours), top),
        SMARTBOARD=SmartBoard(),

        #WEBCAM = Webcam(),
        CLOSEDECK=ClearScribbles(left + (64 * 9) + 32 * len(colours), top),
        DELETE=Delete(left + (64 * 6) + 32 * len(colours), top),
        QUIT=Quit(left + (64 * 10) + 32 * len(colours), top),
        PAGINGCONTROLS=PagingControls(left + 64 + 32 * len(colours), top),
        #LOCALPAGINGCONTROLS = LocalPagingControls(left+(64*6)+32*len(colours),top),
        #LOCALPAGEEVENTS = LocalPageEventsFilter(),
        HISTORY=CheckpointSequencer(
            lambda X: [["LOAD", SLIDESPEC % (X, )]],
            lambda X: [["SAVE", SLIDESPEC % (X, )]],
            lambda X: [["CLEAR"]],
            initial=1,
            highest=num_pages,
            notepad=notepad,
        ),
        PAINT_SPLITTER=TwoWaySplitter(),
        LOCALEVENT_SPLITTER=TwoWaySplitter(),
        DEBUG=ConsoleEchoer(),
        TICKER=Ticker(position=(left, top + height - 15),
                      background_colour=(220, 220, 220),
                      text_colour=(0, 0, 0),
                      text_height=(17),
                      render_right=(width),
                      render_bottom=(15)),
        linkages={
            ("CANVAS", "eventsOut"): ("PAINTER", "inbox"),
            ("PALETTE", "outbox"): ("PAINTER", "colour"),
            ("ERASER", "outbox"): ("PAINTER", "erase"),
            ("PAINTER", "outbox"): ("PAINT_SPLITTER", "inbox"),
            ("CLEAR", "outbox"): ("PAINT_SPLITTER", "inbox"),
            ("PAINT_SPLITTER", "outbox"): ("CANVAS", "inbox"),
            ("PAINT_SPLITTER", "outbox2"): ("", "outbox"),  # send to network
            ("SAVEDECK", "outbox"): ("CANVAS", "inbox"),
            ("LOADDECK", "outbox"): ("CANVAS", "inbox"),
            ("CLOSEDECK", "outbox"): ("CANVAS", "inbox"),
            ("DELETE", "outbox"): ("CANVAS", "inbox"),
            ("QUIT", "outbox"): ("CANVAS", "inbox"),

            #("LOCALPAGINGCONTROLS","outbox")  : ("LOCALEVENT_SPLITTER", "inbox"),
            #("LOCALEVENT_SPLITTER", "outbox2"): ("", "outbox"), # send to network
            #("LOCALEVENT_SPLITTER", "outbox") : ("LOCALPAGEEVENTS", "inbox"),
            #("", "inbox")        : ("LOCALPAGEEVENTS", "inbox"),
            #("LOCALPAGEEVENTS", "false")  : ("CANVAS", "inbox"),
            #("LOCALPAGEEVENTS", "true")  : ("HISTORY", "inbox"),
            ("PAGINGCONTROLS", "outbox"): ("HISTORY", "inbox"),
            ("HISTORY", "outbox"): ("CANVAS", "inbox"),
            ("CANVAS", "outbox"): ("", "outbox"),
            ("CANVAS", "surfacechanged"): ("HISTORY", "inbox"),
            ("CANVAS", "toTicker"): ("TICKER", "inbox"),
            ("CANVAS", "toHistory"): ("HISTORY", "inbox"),
            ("SMARTBOARD", "colour"): ("PAINTER", "colour"),
            ("SMARTBOARD", "erase"): ("PAINTER", "erase"),
            ("SMARTBOARD", "toTicker"): ("TICKER", "inbox"),

            #("WEBCAM", "outbox") : ("CANVAS", "inbox"),
            #("WEBCAM", "networkout") : ("", "outbox"), # send to network
        },
    )
示例#7
0
    mainsketcher = \
        Graphline( SKETCHER = makeBasicSketcher(left,top,width,height),
                   CONSOLE = CommandConsole(),
                   linkages = { ('','inbox'):('SKETCHER','inbox'),
                                ('SKETCHER','outbox'):('','outbox'),
                                ('CONSOLE','outbox'):('SKETCHER','inbox'),
                              }
                     )

    if (1):
        WEBCAM = VideoCaptureSource().activate()
        BLANKCANVAS = ProperSurfaceDisplayer(displaysize=(63 * 3 + 2,
                                                          140)).activate()
        BLANKCANVAS.link((WEBCAM, "outbox"), (BLANKCANVAS, "inbox"))
        WEBCAM_WRAPPER = PygameWrapper(wrap=BLANKCANVAS,
                                       position=(3.7, 2.6, -9),
                                       rotation=(0, 0, 0)).activate()
        #    WEBCAM_WRAPPER = PygameWrapper(wrap=BLANKCANVAS, position=(3.7,2.7,-9), rotation=(-1,-5,-5)).activate()
        i1 = MatchedTranslationInteractor(target=WEBCAM_WRAPPER).activate()
        imagesize = (352, 288)  # "CIF" size video
        if (0):
            Pipeline(WEBCAM, RawYUVFramer(imagesize),
                     DiracEncoder(preset="CIF"),
                     WriteFileAdapter("diracvideo.drc")).activate()

    # primary whiteboard
    Pipeline(SubscribeTo("WHITEBOARD"), TagAndFilterWrapper(mainsketcher),
             PublishTo("WHITEBOARD")).activate()

    # primary sound IO - tagged and filtered, so can't hear self
    if SoundOutput != nullSinkComponent:
示例#8
0
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------

from Kamaelia.Util.Console import ConsoleReader
from Kamaelia.UI.PygameDisplay import PygameDisplay
from Kamaelia.UI.Pygame.Ticker import Ticker
from Kamaelia.UI.OpenGL.OpenGLDisplay import OpenGLDisplay
from Kamaelia.UI.OpenGL.PygameWrapper import PygameWrapper
from Kamaelia.UI.Pygame.MagnaDoodle import *

# override pygame display service
ogl_display = OpenGLDisplay.getDisplayService()
PygameDisplay.setDisplayService(ogl_display[0])

TICKER = Ticker(size=(150, 150)).activate()
TICKER_WRAPPER = PygameWrapper(wrap=TICKER,
                               position=(4, 1, -10),
                               rotation=(-20, 15, 3)).activate()
MAGNADOODLE = MagnaDoodle(size=(200, 200)).activate()
MAGNADOODLEWRAPPER = PygameWrapper(wrap=MAGNADOODLE,
                                   position=(-2, -2, -10),
                                   rotation=(20, 10, 0)).activate()
READER = ConsoleReader().activate()

READER.link((READER, "outbox"), (TICKER, "inbox"))

Axon.Scheduler.scheduler.run.runThreads()
# Licensed to the BBC under a Contributor Agreement: THF