Commit d5bc030bad7bf90cf7ee97557978425c0bd65481

Authored by Christopher Stone
1 parent a1f7d747
Exists in master

Rotated y-axis title. This uses (inelegant) direct manipulation of OGL, which is…

… highly state-based. Sadly, there doesn't seem to be a better way to do it.
Showing 1 changed file with 13 additions and 2 deletions   Show diff stats
telemetry/code/monitor/graph_plotter_rewrite.py
... ... @@ -44,6 +44,7 @@ class Plot(pyglet.window.Window):
44 44 self.bounds = ((int(self.width * self.margins[0]), int(self.width * (1 - self.margins[0]))),
45 45 (int(self.height * self.margins[1]), int(self.height * (1 - self.margins[1]))))
46 46 pyglet.window.Window.on_resize(self, width, height)
  47 + print(self.height)
47 48  
48 49 def on_draw(self):
49 50 """Draw all the components of the graph"""
... ... @@ -84,6 +85,7 @@ class Plot(pyglet.window.Window):
84 85 font_name=self.font, font_size=self.height*self.margins[axis]*0.3,
85 86 x=self.width/2, y=0,
86 87 anchor_x='center', anchor_y='bottom')
  88 + axistitle.draw()
87 89 if axis==1: # y axis, horizontal lines
88 90 pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (limita, pos, limitb, pos)),
89 91 ('c3B', (0, 0, 0, 0, 0, 0)))
... ... @@ -94,10 +96,19 @@ class Plot(pyglet.window.Window):
94 96 axistitle = pyglet.text.Label(self.series.yname, color=BLACK,
95 97 font_name=self.font, font_size=self.height*self.margins[axis]*0.3,
96 98 x=0, y=self.height/2,
97   - anchor_x='left', anchor_y='center')
  99 + anchor_x='center', anchor_y='top')
  100 + pyglet.gl.glPushMatrix()
  101 + pyglet.gl.glTranslatef(self.height//2, self.height//2, 0.0)
  102 + pyglet.gl.glRotatef(90.0, 0.0, 0.0, 1.0)
  103 + axistitle.draw()
  104 + pyglet.gl.glPopMatrix()
  105 + #pyglet.gl.glRotatef(-90.0, 0.0, 0.0, 1.0)
  106 + #pyglet.gl.glTranslatef(-self.width//2, -self.height//2, 0.0)
  107 +
98 108 tag.draw()
99 109  
100   - axistitle.draw()
  110 +
  111 +
101 112  
102 113  
103 114  
... ...