Compare View

switch
from
...
to
 
Commits (2)
robots/little_john/telemetry/code/monitor/graph_plotter_rewrite.py
... ... @@ -65,6 +65,7 @@ class Plot(pyglet.window.Window):
65 65 """Handle a resize event from the pyglet event loop"""
66 66 self.bounds = ((int(self.width * self.margins[0]), int(self.width * (1 - self.margins[0]))),
67 67 (int(self.height * self.margins[1]), int(self.height * (1 - self.margins[1]))))
  68 + self.tag_size = min(self.height*self.margins[1]*0.3,self.width*self.margins[0]*0.3)
68 69 # This sometimes seems to throw an error ('AttributeError: 'Plot' object has no attribute 'margins') when started for a second time from the same instance. Interesting. Causes the plot windows to freeze
69 70 pyglet.window.Window.on_resize(self, width, height)
70 71  
... ... @@ -109,11 +110,11 @@ class Plot(pyglet.window.Window):
109 110 pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (pos, limita, pos, limitb)),
110 111 ('c3B', (0, 0, 0, 0, 0, 0)))
111 112 tag = pyglet.text.Label(tagtext, color=BLACK,
112   - font_name=self.font, font_size=self.height*self.margins[1]*0.3,
  113 + font_name=self.font, font_size=self.tag_size,
113 114 x=pos, y=self.height*self.margins[1],
114 115 anchor_x='left', anchor_y='top')
115 116 axistitle = pyglet.text.Label(self.series.xname, color=BLACK,
116   - font_name=self.font, font_size=self.height*self.margins[1]*0.3,
  117 + font_name=self.font, font_size=self.tag_size,
117 118 x=self.width/2, y=0,
118 119 anchor_x='center', anchor_y='bottom')
119 120 axistitle.draw()
... ... @@ -124,11 +125,11 @@ class Plot(pyglet.window.Window):
124 125 pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (limita, pos, limitb, pos)),
125 126 ('c3B', (0, 0, 0, 0, 0, 0)))
126 127 tag = pyglet.text.Label(tagtext, color=BLACK,
127   - font_name=self.font, font_size=self.width*self.margins[0]*0.2,
  128 + font_name=self.font, font_size=self.tag_size,
128 129 x=self.width*self.margins[0]*0.9, y=pos,
129 130 anchor_x='right', anchor_y='center')
130 131 axistitle = pyglet.text.Label(self.series.yname, color=BLACK,
131   - font_name=self.font, font_size=self.height*self.margins[0]*0.3,
  132 + font_name=self.font, font_size=self.tag_size,
132 133 x=0, y=self.height/2,
133 134 anchor_x='center', anchor_y='top')
134 135 pyglet.gl.glPushMatrix() # Set up a new context to avoid confusing the main one
... ...