Exemplo n.º 1
0
    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}
    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}
Exemplo n.º 3
0
        
    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")
        }
Exemplo n.º 4
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
Exemplo n.º 5
0
#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()
    
        #PAINTER_WRAPPER = PygameWrapper(wrap=PAINTER, position=(4,1,-10), rotation=(-20,15,3)).activate()
Exemplo n.º 6
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()
Exemplo n.º 7
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
Exemplo n.º 8
0
def left90(vector):
    return (-vector[1],vector[0])

def right90(vector):
    return (vector[1],-vector[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()