Files
@ 60b49f6c2027
Branch filter:
Location: light9/bin/lightsim - annotation
60b49f6c2027
3.6 KiB
text/plain
start porting lightsim to qt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | 9d1f323fb3d3 9d1f323fb3d3 9d1f323fb3d3 9d1f323fb3d3 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 9d1f323fb3d3 9d1f323fb3d3 60b49f6c2027 9d1f323fb3d3 9d1f323fb3d3 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 9d1f323fb3d3 9d1f323fb3d3 9d1f323fb3d3 9d1f323fb3d3 60b49f6c2027 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 9d1f323fb3d3 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 9d1f323fb3d3 60b49f6c2027 941cfe1e1691 941cfe1e1691 9d1f323fb3d3 60b49f6c2027 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 941cfe1e1691 9d1f323fb3d3 941cfe1e1691 9d1f323fb3d3 60b49f6c2027 60b49f6c2027 60b49f6c2027 9d1f323fb3d3 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 941cfe1e1691 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 941cfe1e1691 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 60b49f6c2027 | #!/usr/bin/python
from __future__ import division
import run_local
import xmlrpclib, sys, logging
sys.path.append("lib")
import qt4reactor
qt4reactor.install()
from rdflib import Literal, URIRef
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
from twisted.web.xmlrpc import Proxy
from louie import dispatcher
from PyQt4 import QtCore, QtGui, QtOpenGL
from OpenGL.GL import *
from OpenGL.GLU import *
from light9 import networking, Patch, showconfig, dmxclient, updatefreq, prof
from light9.namespaces import L9
from lightsim.openglsim import Surface
log = logging.getLogger()
logging.basicConfig(format="%(asctime)s %(levelname)-5s %(name)s %(filename)s:%(lineno)d: %(message)s")
log.setLevel(logging.DEBUG)
def poll(graph, serv, pollFreq, oglSurface):
pollFreq.update()
dispatcher.send("status", key="pollFreq", value=str(pollFreq))
d = serv.callRemote("currentlevels", dmxclient._id)
def received(dmxLevels):
level = {} # filename : level
for i, lev in enumerate(dmxLevels):
if lev == 0:
continue
try:
chan = Patch.get_channel_uri(Patch.get_channel_name(i + 1))
except KeyError:
continue
for lyr in graph.objects(chan, L9['previewLayer']):
for imgPath in graph.objects(lyr, L9['path']):
level[str(imgPath)] = lev
oglSurface.newLevels(levels=level)
d.addCallback(received)
return d
class StatusKeys(object):
# watch out- this might be an accidental redo of what curvecalc
# has. Or, maybe CC should use this obj
def __init__(self, master):
tk.Frame.__init__(self, master)
dispatcher.connect(self.status, "status")
self.row = {} # key name : (Frame, value Label)
def status(self, key, value):
if key not in self.row:
f = tk.Frame(self)
f.pack(side='top')
tk.Label(f, text=key, font="arial 8").pack(side='left')
l = tk.Label(f, text=value, font="arial 8")
l.pack(side='left')
self.row[key] = (f, l)
else:
row, lab = self.row[key]
lab.config(text=value)
class Window(QtGui.QMainWindow):
def __init__(self, filenames):
QtGui.QMainWindow.__init__(self, None)
self.w = QtGui.QWidget()
self.setCentralWidget(self.w)
self.glWidget = Surface(self, filenames,
width=120*3, height=80*3,
imgRescaleTo=128)
self.glWidget.newLevels(levels={
"lightsim/skyline/front-left.png" : .4,
"lightsim/skyline/front-right.png" : .8})
mainLayout = QtGui.QHBoxLayout()
mainLayout.addWidget(self.glWidget)
self.w.setLayout(mainLayout)
self.setWindowTitle(dmxclient._id)
if __name__ == '__main__':
app = reactor.qApp
graph = showconfig.getGraph()
filenames = []
for lyr in graph.objects(None, L9['previewLayer']):
for p in graph.objects(lyr, L9['path']):
filenames.append(str(p))
filenames.append("lightsim/skyline/front-left.png") # test
filenames.append("lightsim/skyline/front-right.png") # test
window = Window(filenames)
window.show()
serv = Proxy(networking.dmxServerUrl())
pollFreq = updatefreq.Updatefreq(samples=5)
LoopingCall(poll, graph, serv, pollFreq, window.glWidget).start(.1)
reactor.run()
######################################################
#sk = StatusKeys(root)
#sk.pack(side='top', fill='x')
#prof.run(reactor.run, profile=False)
|