Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit c2533934 authored by Ed Rogers's avatar Ed Rogers
Browse files

Add update of bar

parent 6c44759a
......@@ -68,26 +68,37 @@ class HearingMplCanvas(FigureCanvas):
QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self.ul_bar = None
self.ll_bar = None
self.plot_result(HearingResult(parent.library.freqs))
def plot_result(self, result: HearingResult):
inds = np.arange(0, result.bands.size)
baseline = -10
self.axes.set_axis_bgcolor('k')
self.axes.bar(inds, result.upper_bounds-baseline, color=(0, 0.5, 0), bottom=baseline)
self.axes.bar(inds, result.lower_bounds-baseline, color=(0, 1, 0), bottom=baseline)
self.ul_bar = self.axes.bar(inds, result.upper_bounds-baseline, color=(0, 0.5, 0), bottom=baseline)
self.ll_bar = self.axes.bar(inds, result.lower_bounds-baseline, color=(0, 1, 0), bottom=baseline)
xlim = self.axes.get_xlim()
for i in np.arange(result.lower_lim+baseline, result.upper_lim, result.get_block_size()):
self.axes.plot(self.axes.get_xlim(), np.ones(2)*i, color='k')
labels = [str(b) for b in result.bands]
labels.insert(0, '')
self.axes.set_xticklabels(labels)
print(result.bands)
print(labels)
print(result.lower_bounds)
# print(result.bands)
# print(labels)
# print(result.lower_bounds)
self.axes.set_ylim(-10, 110)
self.axes.set_xlim(xlim)
def update_result(self, result: HearingResult) -> None:
self.set_bar_heights(self.ul_bar, result.upper_bounds)
self.set_bar_heights(self.ll_bar, result.lower_bounds)
@staticmethod
def set_bar_heights(bars: matplotlib.container.BarContainer, vals: np.ndarray):
for bar, h in zip(bars, vals):
bar.set_height(h)
class HearingTestThread(QtCore.QThread):
played_sound = QtCore.pyqtSignal(float, float)
......@@ -152,7 +163,7 @@ class TestWindow(QMainWindow):
self.log.setText('')
self.title.setText('Test running')
self.log.append('Starting...')
self.testing_thread = HearingTestThread(self.library)
self.testing_thread = HearingTestThread(self.library, result)
self.testing_thread.played_sound.connect(self.sound_played)
self.testing_thread.finished.connect(self.test_finished)
self.testing_thread.start()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment