Matthew Turk avatar Matthew Turk committed a81eb76

Initial import.

Comments (0)

Files changed (3)

+HIGH LEVEL INTERFACE
+====================
+
+We want to avoid any manual manipulation of objects.  We are necessarily
+restricting what we make available to the user, as we mainly want to present
+this as a visualization interface.
+
+Parameter File Selector
+-----------------------
+
+We should present a set of known parameter files to the user, queried from the
+parameter file store.  Only one can be in use at a time.
+
+Data Object Selector
+--------------------
+
+Typically we do not want to do this, but if we do choose to allow it, then we
+can allow them in a few ways.  All data, a sphere at the center, and that's
+about it.  It's unlikely that people will want something more complex.  If they
+do, they should add it.
+
+Volume Rendering
+----------------
+
+We want to only present the unified concept of a volume rendering.  So rather
+than a 'camera' we just present a unified widget.  This widget includes the
+gaussians or the transfer functions, the display, and the colormap.  In this
+sense, we restrict again what the user can do, but this opens things up a bit
+more for a simple interface.

twisted_client.py

+
+#install_twisted_rector must be called before importing the reactor
+from kivy.support import install_twisted_reactor
+install_twisted_reactor()
+
+
+#A simple Client that send messages to the echo server
+from twisted.internet import reactor, protocol
+
+class EchoClient(protocol.Protocol):
+    def connectionMade(self):
+        self.factory.app.on_connection(self.transport)
+
+    def dataReceived(self, data):
+        self.factory.app.print_message(data)
+
+class EchoFactory(protocol.ClientFactory):
+    protocol = EchoClient
+    def __init__(self, app):
+        self.app = app
+
+    def clientConnectionLost(self, conn, reason):
+        self.app.print_message("connection lost")
+
+    def clientConnectionFailed(self, conn, reason):
+        self.app.print_message("connection failed")
+
+
+from kivy.app import App
+from kivy.uix.label import Label
+from kivy.uix.textinput import TextInput
+from kivy.uix.boxlayout import BoxLayout
+
+# A simple kivy App, with a textbox to enter messages, and
+# a large label to display all the messages received from
+# the server
+class TwistedClientApp(App):
+    connection = None
+
+    def build(self):
+        root = self.setup_gui()
+        self.connect_to_server()
+        return root
+
+    def setup_gui(self):
+        self.textbox = TextInput(size_hint_y=.1, multiline=False)
+        self.textbox.bind(on_text_validate=self.send_message)
+        self.label = Label(text='connecting...\n')
+        self.layout = BoxLayout(orientation='vertical')
+        self.layout.add_widget(self.label)
+        self.layout.add_widget(self.textbox)
+        return self.layout
+
+    def connect_to_server(self):
+        reactor.connectTCP('localhost', 8000, EchoFactory(self))
+
+    def on_connection(self, connection):
+        self.print_message("connected succesfully!")
+        self.connection = connection
+
+    def send_message(self, *args):
+        msg = self.textbox.text
+        if msg and self.connection:
+            self.connection.write(str(self.textbox.text))
+            self.textbox.text = ""
+
+    def print_message(self, msg):
+        self.label.text += msg + "\n"
+
+
+if __name__ == '__main__':
+    TwistedClientApp().run()

twisted_server.py

+# install_twisted_rector must be called before importing  and using the reactor
+from kivy.support import install_twisted_reactor
+install_twisted_reactor()
+
+
+from twisted.internet import reactor
+from twisted.internet import protocol
+
+class EchoProtocol(protocol.Protocol):
+    def dataReceived(self, data):
+        response = self.factory.app.handle_message(data)
+        if response:
+            self.transport.write(response)
+
+class EchoFactory(protocol.Factory):
+    protocol = EchoProtocol
+    def __init__(self, app):
+        self.app = app
+
+
+from kivy.app import App
+from kivy.uix.label import Label
+
+class TwistedServerApp(App):
+    def build(self):
+        self.label = Label(text="server started\n")
+        reactor.listenTCP(8000, EchoFactory(self))
+        return self.label
+
+    def handle_message(self, msg):
+        self.label.text  = "received:  %s\n" % msg
+
+        if msg == "ping":  msg =  "pong"
+        if msg == "plop":  msg = "kivy rocks"
+        self.label.text += "responded: %s\n" % msg
+        return msg
+
+
+if __name__ == '__main__':
+    TwistedServerApp().run()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.