graph: Add ability to hide/show sensors.
This commit is contained in:
parent
ac3bde654a
commit
fdf81ecf06
@ -17,6 +17,10 @@ class HeaterGraph(Gtk.DrawingArea):
|
||||
self.store = {}
|
||||
self.max_length = 0
|
||||
self.connect('draw', self.draw_graph)
|
||||
self.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
self.connect('touch-event', self.event_cb)
|
||||
self.connect('button_press_event', self.event_cb)
|
||||
|
||||
def add_object(self, name, type, rgb=[0, 0, 0], dashed=False, fill=False):
|
||||
if name not in self.store:
|
||||
@ -28,6 +32,28 @@ class HeaterGraph(Gtk.DrawingArea):
|
||||
}})
|
||||
self.max_length = max(self.max_length, len(self.printer.get_temp_store(name, type)))
|
||||
|
||||
def event_cb(self, da, ev):
|
||||
if ev.get_source_device().get_source() == Gdk.InputSource.MOUSE:
|
||||
if ev.type == Gdk.EventType.BUTTON_PRESS:
|
||||
x = ev.x
|
||||
y = ev.y
|
||||
|
||||
if ev.get_source_device().get_source() == Gdk.InputSource.TOUCHSCREEN:
|
||||
if ev.touch.type == Gdk.EventType.TOUCH_BEGIN:
|
||||
x = ev.touch.x
|
||||
y = ev.touch.y
|
||||
|
||||
logging.info("Drawing area clicked: %s %s" % (x, y))
|
||||
|
||||
|
||||
def get_max_length(self):
|
||||
n = []
|
||||
for name in self.store:
|
||||
if "temperatures" not in self.store[name]:
|
||||
continue
|
||||
n.append(len(self.printer.get_temp_store(name, "temperatures")))
|
||||
return max(n)
|
||||
|
||||
def get_max_num(self, data_points=0):
|
||||
mnum = []
|
||||
for x in self.store:
|
||||
@ -65,16 +91,18 @@ class HeaterGraph(Gtk.DrawingArea):
|
||||
[g_width, g_height]
|
||||
]
|
||||
|
||||
|
||||
self.max_length = self.get_max_length()
|
||||
graph_width = gsize[1][0] - gsize[0][0]
|
||||
points_per_pixel = self.max_length / graph_width
|
||||
if points_per_pixel > 3:
|
||||
points_per_pixel = 3
|
||||
data_points = graph_width * points_per_pixel
|
||||
logging.info("Max length: %s PPP: %s" % (self.max_length, points_per_pixel))
|
||||
logging.info("aa: %s %s" % (points_per_pixel, data_points))
|
||||
max_num = math.ceil(self.get_max_num(data_points) * 1.1 / 10) * 10
|
||||
d_width = 1 / points_per_pixel
|
||||
|
||||
|
||||
d_height_scale = self.graph_lines(ctx, gsize, max_num)
|
||||
self.graph_time(ctx, gsize, points_per_pixel)
|
||||
|
||||
|
@ -339,7 +339,7 @@ class Printer:
|
||||
def _update_temp_store(self):
|
||||
for device in self.tempstore:
|
||||
for x in self.tempstore[device]:
|
||||
t = len(self.tempstore[device][x]) - 1
|
||||
self.tempstore[device][x].pop(0)
|
||||
if len(self.tempstore[device][x]) >= 1200:
|
||||
self.tempstore[device][x].pop(0)
|
||||
self.tempstore[device][x].append(round(self.get_dev_stat(device, x[:-1]), 2))
|
||||
return True
|
||||
|
@ -115,6 +115,7 @@ class MainPanel(MenuPanel):
|
||||
dev.add(labels)
|
||||
|
||||
self.devices[device] = {
|
||||
"class": class_name,
|
||||
"name": name,
|
||||
"temp": temp
|
||||
}
|
||||
@ -151,6 +152,14 @@ class MainPanel(MenuPanel):
|
||||
def graph_show_device(self, widget, show=True):
|
||||
logging.info("Graph show: %s %s" % (self.popover_device, show))
|
||||
self.labels['da'].set_showing(self.popover_device, show)
|
||||
if show:
|
||||
self.devices[self.popover_device]['name'].get_style_context().remove_class("graph_label_hidden")
|
||||
self.devices[self.popover_device]['name'].get_style_context().add_class(
|
||||
self.devices[self.popover_device]['class'])
|
||||
else:
|
||||
self.devices[self.popover_device]['name'].get_style_context().remove_class(
|
||||
self.devices[self.popover_device]['class'])
|
||||
self.devices[self.popover_device]['name'].get_style_context().add_class("graph_label_hidden")
|
||||
self.labels['da'].queue_draw()
|
||||
self.popover_populate_menu()
|
||||
self.labels['popover'].show_all()
|
||||
|
@ -444,6 +444,7 @@ popover button {
|
||||
}
|
||||
|
||||
/* Hardcoded values until creation of dynamic CSS updates */
|
||||
.graph_label_hidden {padding-left: .9em;} /* .4em on top of normal button padding */
|
||||
.graph_label_extruder {border-left: .4em solid #ff5252;}
|
||||
.graph_label_extruder2 {border-left: .4em solid #ff7252;}
|
||||
.graph_label_heater_bed {border-left: .4em solid #1fb0ff;}
|
||||
|
Loading…
x
Reference in New Issue
Block a user