Store Sequence sequence location in a shared_ptr class
[mussa.git] / py / gl.py
index 43d29f64ada38c4c6e511364e8a0aee8cef704da..d1e5645fd6506dd9e4cf981b8947ac8959c78ca5 100644 (file)
--- a/py/gl.py
+++ b/py/gl.py
@@ -1,18 +1,45 @@
 """Can we show a mussa gl object?
 """
+import sys
+
 from OpenGL.GLUT import *
 from OpenGL.GL import *
 import mussa
 
-def main():
-  seq = mussa.Sequence()
-  s = "AAGGCCTTAAGGCCTT" 
-  seq = mussa.Sequence(s)
-  assert s == seq.size() == len(seq)
-  glseq = mussa.GlSequence(seq)
-
-  glutInit(sys.argv)
   
+class pyMussaGL:
+  def __init__(self):
+    """Initalize our data and our glut window"""
+    # make up a simple sequence
+    self.s = "AAGGCCTT" * 5
+    self.seq = mussa.Sequence(self.s)
+
+    # add our annotation
+    annot = mussa.annot(0, 5, "name", "type")
+    self.seq.add_annotation(annot)
+
+    # AnnotationColors is required, even though it'd be nice
+    # if it were optional
+    self.glseq = mussa.GlSequence(self.seq, mussa.AnnotationColors())
+    assert len(self.s) == self.glseq.size
+
+    # set up opengl buffer
+    glutInit(sys.argv)
+    glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH )
+    glutCreateWindow('mussa')
+    glClearColor(1,1,1,0)
+
+    glOrtho(-10, len(self.s)+10, -50, 50, -50, 50)
+
+    glutDisplayFunc(self.display)
+    print "init done"
   
+  def display(self):
+    """Update showing buffer"""
+    glClear(GL_COLOR_BUFFER_BIT)
+    self.glseq.draw(-50, self.glseq.size+50)
+    #glutSwapBuffers()
+
 if __name__ == "__main__":
-  main()
+  p = pyMussaGL()
+  glutMainLoop()