def __init__(self,
                 screensize=(800, 600),
                 fullscreen=False,
                 caption="Topology Viewer",
                 particleTypes=None,
                 initialTopology=None,
                 laws=None,
                 simCyclesPerRedraw=None,
                 border=100,
                 extraDrawing=None,
                 showGrid=True,
                 transparency=None,
                 position=None):
        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""

        tracker = _cat.coordinatingassistanttracker.getcat()
        display = OpenGLDisplay(width=screensize[0],
                                height=screensize[1],
                                fullscreen=fullscreen,
                                title=caption)
        display.activate()
        OpenGLDisplay.setDisplayService(display, tracker)

        super(TopologyViewer3D, self).__init__()

        self.particle = None
        self.particleTypes = {"-": Particle3D}
Exemple #2
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")
Exemple #3
0
    def __init__(self,
                 screensize=(800, 600),
                 fullscreen=False,
                 caption="3D Topology Viewer",
                 particleTypes=None,
                 initialTopology=None,
                 laws=None,
                 simCyclesPerRedraw=1,
                 border=0):
        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""

        super(TopologyViewer3D, self).__init__()

        glutInit(sys.argv)

        tracker = _cat.coordinatingassistanttracker.getcat()
        try:
            self.display = tracker.retrieveService("ogl_display")[0]
        except KeyError:
            self.display = OpenGLDisplay(width=screensize[0],
                                         height=screensize[1],
                                         fullscreen=fullscreen,
                                         title=caption)
            self.display.activate()
            OpenGLDisplay.setDisplayService(self.display, tracker)
        self.display = OpenGLDisplay.getDisplayService()[0]
        self.link((self, "display_signal"), (self.display, "notify"))
        self.link((self.display, "signal"), (self, "control"))

        self.border = border

        if particleTypes == None:
            self.particleTypes = {
                "-": CuboidParticle3D,
                "cuboid": CuboidParticle3D,
                "sphere": SphereParticle3D,
                "teapot": TeapotParticle3D
            }
        else:
            self.particleTypes = particleTypes

        if initialTopology == None:
            initialTopology = ([], [])
        self.initialNodes = list(initialTopology[0])
        self.initialBonds = list(initialTopology[1])

        self.hitParticles = []
        self.multiSelectMode = False
        self.selectedParticles = []
        self.grabbed = False
        self.rotationMode = False

        if laws == None:
            self.laws = Kamaelia.Support.Particles.SimpleLaws(bondLength=2)
        else:
            self.laws = laws

        self.physics = ParticleSystem(self.laws, [], 0)
        self.biggestRadius = 0

        # Do interaction
        self.simCyclesPerRedraw = simCyclesPerRedraw
        self.lastIdleTime = time.time()

        # Tell if new node is added; if true, new id needs adding to OpenGLDisplay list
        self.isNewNode = False

        # For hierarchy structure
        self.maxLevel = 0
        self.currentLevel = 0
        self.previousParentParticleID = self.currentParentParticleID = ''
        self.viewerOldPos = Vector()
        self.levelViewerPos = {}
        # The Physics particle system of current display level for display
        self.currentDisplayedPhysics = ParticleSystem(self.laws, [], 0)

        # For double click
        self.lastClickPos = (0, 0)
        self.lastClickTime = time.time()
        self.dClickRes = 0.3
Exemple #4
0
from Kamaelia.Apps.Whiteboard.SmartBoard import SmartBoard
from Kamaelia.Apps.Whiteboard.Webcam import Webcam

#from Webcam import Webcam
from Webcam import VideoCaptureSource

#from BlankCanvas import BlankCanvas


if __name__=="__main__":
    width = 1024
    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()
Exemple #5
0
def rotate(angle, vector):
    cos = math.cos(angle)
    sin = math.sin(angle)
    return (cos * vector[0] + sin * vector[1],
            -sin * vector[0] + cos * vector[1])


def dist(vector):
    return (vector[0] * vector[0] + vector[1] * vector[1])**0.5


if __name__ == '__main__':
    import Axon

    from Kamaelia.UI.OpenGL.OpenGLDisplay import OpenGLDisplay
    from Kamaelia.UI.OpenGL.SimpleRotationInteractor import SimpleRotationInteractor

    display = OpenGLDisplay(background_colour=(0.75, 0.75, 1.0)).activate()
    OpenGLDisplay.setDisplayService(display)

    FOLD = Simple3dFold(position=(0, 0, -22),
                        size=(15, 15, 2),
                        rotation=(-30, 0, 0),
                        radius=1.0,
                        segments=15).activate()
    #    SimpleRotationInteractor(target=FOLD).activate()

    print "Grab close to a corner and drag!"

    Axon.Scheduler.scheduler.run.runThreads()
Exemple #6
0
                if (to[0] < 0 or to[0] > 7 or to[1] < 0 or to[1] > 7
                        or to[0] + to[1]) % 2 != 0 or self.board[to[0]][
                            to[1]] is not None:
                    self.send("INVALID", self.interactor_comms[objectid])
                else:
                    self.board[fr[0]][fr[1]] = None
                    self.board[to[0]][to[1]] = colour
                    self.send("ACK", self.interactor_comms[objectid])

        while self.dataReady("control"):
            cmsg = self.recv("control")
            if isinstance(cmsg, Axon.Ipc.shutdownMicroprocess):
                # dirty way to terminate program
                sys.exit(0)

        return 1


if __name__ == '__main__':
    # initialise display, change point of view
    ogl_display = OpenGLDisplay(viewerposition=(0, -10, 0),
                                lookat=(0, 0, -15),
                                limit_fps=100)
    ogl_display.activate()
    OpenGLDisplay.setDisplayService(ogl_display)

    Checkers().activate()
    Axon.Scheduler.scheduler.run.runThreads()
# Licensed to the BBC under a Contributor Agreement: THF
Exemple #7
0
        self.send(infostring, "torrent_info")

    def hideInfo(self):
        self.send("Backward", "infomover_commands")
        self.send("Play", "infomover_commands")


if __name__ == "__main__":
    from Kamaelia.Chassis.Graphline import Graphline
    from Kamaelia.Util.Console import ConsoleReader
    from Kamaelia.UI.PygameDisplay import PygameDisplay
    from Kamaelia.UI.OpenGL.OpenGLDisplay import OpenGLDisplay
    from Kamaelia.Protocol.HTTP.HTTPClient import SimpleHTTPClient
    from Kamaelia.Protocol.Torrent.TorrentPatron import TorrentPatron

    ogl_display = OpenGLDisplay(limit_fps=100).activate()
    OpenGLDisplay.setDisplayService(ogl_display)
    # override pygame display service
    PygameDisplay.setDisplayService(ogl_display)

    Graphline(reader=ConsoleReader(prompt="Enter torrent location:", eol=""),
              httpclient=SimpleHTTPClient(),
              gui=TorrentOpenGLGUI(),
              backend=TorrentPatron(),
              linkages={
                  ("gui", "outbox"): ("backend", "inbox"),
                  ("reader", "outbox"): ("gui", "torrent_url"),
                  ("gui", "fetcher"): ("httpclient", "inbox"),
                  ("httpclient", "outbox"): ("gui", "torrent_file"),
                  ("backend", "outbox"): ("gui", "inbox")
              }).run()