Ejemplo n.º 1
0
 def on_mouse_release(self, event):
     if self.selected_boundary == self.osc_boundary_start:
         self.opstack.push(Update(self.i, 'start', float(event.xdata)))
     elif self.selected_boundary == self.osc_boundary_stop:
         self.opstack.push(Update(self.i, 'stop', float(event.xdata)))
     if self.selected_boundary:
         self.selected_boundary.set_color('r')
         self.update_syl_boundaries()
     self.selected_boundary = None
     self.canvas.draw()
Ejemplo n.º 2
0
def test_read_write2(tempfile, opstack):
    opstack.push(Update(0, 'name', 'z'))
    write_stack(tempfile, opstack)
    new_opstack = read_stack(tempfile)
    assert new_opstack.original_events == opstack.original_events
    assert new_opstack.events == opstack.events
    assert new_opstack.events != new_opstack.original_events
Ejemplo n.º 3
0
    def on_key_press(self, event):

        if event.key() == Qt.Key_Right:
            self.inc_i()
        elif event.key() == Qt.Key_Left:
            self.dec_i()
        if event.key() == Qt.Key_Down:
            self.zoom_in_x()
        elif event.key() == Qt.Key_Up:
            self.zoom_out_x()
        elif event.key() <= Qt.Key_Z and event.key() >= Qt.Key_A:
            if self.N_points > int(round(self.sr * self.gap * self.maxpoint)):
                return
            newlabel = chr(event.key())
            self.opstack.push(Update(self.label_index, 'name', newlabel))
            self.inc_i()
        elif event.key() <= Qt.Key_9 and event.key() >= Qt.Key_0:
            if self.N_points > int(round(self.sr * self.gap * self.maxpoint)):
                return
            newlabel = number_shortcut[chr(event.key())]
            self.opstack.push(Update(self.label_index, 'name', newlabel))
            self.inc_i()
Ejemplo n.º 4
0
 def on_key_press(self, event):
     #print('you pressed ', event.key)
     if event.key in ('pagedown', ' ', 'right'):
         self.inc_i()
     elif event.key in ('pageup', 'backspace', 'left'):
         self.dec_i()
     elif event.key in self.keymap:
         newlabel = self.keymap[event.key]
         self.opstack.push(Update(self.i, 'name', newlabel))
         self.inc_i()
     elif event.key in ('ctrl+i', 'down'):
         if self.N_points > 5000:
             self.N_points -= 5000
             self.update_plot_data()
     elif event.key in ('ctrl+o', 'up'):
         self.N_points += 5000
         self.update_plot_data()
     elif event.key == 'ctrl+s':
         self.save()
     elif event.key == 'ctrl+h':
         print(help_string)
     elif event.key in ('ctrl+m', 'ctrl+backspace') and self.i > 0:
         self.i -= 1
         self.opstack.push(Merge(self.i))
         self.inc_i()
     elif event.key in ('ctrl+x', 'tab'):
         self.opstack.push(Delete(self.i))
         if self.i >= len(self.opstack.events):
             self.i = len(self.opstack.events) - 1
         self.update_plot_data()
     elif event.key == 'ctrl+z' and self.opstack.ops:
         self.opstack.undo()
         self.i = self.opstack.undo_ops[-1].index
         self.update_plot_data()
     elif event.key == 'ctrl+y' and self.opstack.undo_ops:
         self.opstack.redo()
         self.i = self.opstack.ops[-1].index
         self.update_plot_data()
Ejemplo n.º 5
0
 def deletelabel(self):
     if self.N_points > int(round(self.sr * self.gap * self.maxpoint)):
         return
     self.opstack.push(Update(self.label_index, 'name', ""))
     self.dec_i()
Ejemplo n.º 6
0
 def addlabel(self, str):
     if self.N_points > int(round(self.sr * self.gap * self.maxpoint)):
         return
     self.opstack.push(Update(self.label_index, 'name', str))
     self.inc_i()
Ejemplo n.º 7
0
def test_stack_undo(opstack):
    opstack.push(Update(0, 'name', 'z'))
    opstack.undo()
    assert len(opstack.ops) == 0
    assert len(opstack.undo_ops) == 1
    assert opstack.events == opstack.original_events
Ejemplo n.º 8
0
def test_stack_push(opstack):
    opstack.push(Update(0, 'name', 'z'))
    assert len(opstack.ops) == 1
    assert opstack.events != opstack.original_events
Ejemplo n.º 9
0
def test_chain(labels):
    Update(2, 'stop', 100).on(labels)
    Update(1, 'start', 100).on(labels)
    assert labels[2]['stop'] == 100
    assert labels[1]['start'] == 100
Ejemplo n.º 10
0
def test_stop(labels):
    Update(2, 'stop', 100).on(labels)
    assert labels[2]['stop'] == 100
Ejemplo n.º 11
0
def test_start(labels):
    Update(1, 'start', 100).on(labels)
    assert labels[1]['start'] == 100
Ejemplo n.º 12
0
def test_name(labels):
    Update(0, 'name', 'a2').on(labels)
    assert labels[0]['name'] == 'a2'