Skip to content

Plot height and axis width improvements #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions source/gui/plotting.py
Original file line number Diff line number Diff line change
@@ -47,22 +47,39 @@ def __init__(self, parent=None):

def set_state_machine(self, sm_info):
# Initialise plots with state machine information.
self.axiswidth = 6 + 6 * max([len(n) for n in list(sm_info.states) + list(sm_info.events)])

font = QtGui.QFont() # inherits application font size
metrics = QtGui.QFontMetrics(font)
max_tick_label_width = max([metrics.horizontalAdvance(n) for n in list(sm_info.states) + list(sm_info.events)])
padding = 10
self.axiswidth = max_tick_label_width + padding

self.states_plot.set_state_machine(sm_info)
self.events_plot.set_state_machine(sm_info)
self.analog_plot.set_state_machine(sm_info)

# size the states and events plots relative to the number of states and events
num_states = max(1, len(sm_info.states))
num_events = max(1, len(sm_info.events))
total = num_states + num_events
states_fraction = num_states / total
events_fraction = num_events / total

if self.analog_plot.inputs:
# state and event plots are 2/3 of the total height
# analog plot is 1/3 of the total height
self.analog_plot.axis.setVisible(True)
self.events_plot.axis.getAxis("bottom").setLabel("")
self.layout.setRowStretch(0, 1)
self.layout.setRowStretch(1, 1)
self.layout.setRowStretch(2, 1)
self.layout.setRowStretch(0, int(states_fraction * 66)) # States plot
self.layout.setRowStretch(1, int(events_fraction * 66)) # Events plot
self.layout.setRowStretch(2, 33) # Analog plot
else:
# state and event plots
self.analog_plot.axis.setVisible(False)
self.events_plot.axis.getAxis("bottom").setLabel("Time (seconds)")
self.layout.setRowStretch(0, 1)
self.layout.setRowStretch(1, 1)
self.layout.setRowStretch(2, 0)
self.layout.setRowStretch(0, int(states_fraction * 100)) # States plot
self.layout.setRowStretch(1, int(events_fraction * 100)) # Events plot
self.layout.setRowStretch(2, 0) # No analog plot

def run_start(self, recording):
self.pause_button.setChecked(False)