• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

paulmthompson / WhiskerToolbox / 18685379784

21 Oct 2025 01:25PM UTC coverage: 72.522% (+0.1%) from 72.391%
18685379784

push

github

paulmthompson
fix failing tests

18 of 40 new or added lines in 1 file covered. (45.0%)

1765 existing lines in 32 files now uncovered.

53998 of 74457 relevant lines covered (72.52%)

46177.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.88
/src/WhiskerToolbox/DataViewer_Widget/DigitalEvent/EventViewer_Widget.cpp
1
#include "EventViewer_Widget.hpp"
2
#include "ui_EventViewer_Widget.h"
3

4
#include "DataManager/DataManager.hpp"
5
#include "DataViewer/DigitalEvent/DigitalEventSeriesDisplayOptions.hpp"
6
#include "DataViewer_Widget/OpenGLWidget.hpp"
7

8
#include <QColorDialog>
9
#include <iostream>
10

11
EventViewer_Widget::EventViewer_Widget(std::shared_ptr<DataManager> data_manager, OpenGLWidget * opengl_widget, QWidget * parent)
20✔
12
    : QWidget(parent),
13
      ui(new Ui::EventViewer_Widget),
40✔
14
      _data_manager{std::move(data_manager)},
20✔
15
      _opengl_widget{opengl_widget} {
40✔
16
    ui->setupUi(this);
20✔
17

18
    // Set the color display button to be flat and show just the color
19
    ui->color_display_button->setFlat(false);
20✔
20
    ui->color_display_button->setEnabled(false); // Make it non-clickable, just for display
20✔
21

22
    connect(ui->color_button, &QPushButton::clicked,
60✔
23
            this, &EventViewer_Widget::_openColorDialog);
40✔
24

25
    // Connect display option controls
26
    connect(ui->mode_combo, QOverload<int>::of(&QComboBox::currentIndexChanged),
60✔
27
            this, &EventViewer_Widget::_setDisplayMode);
40✔
28
    connect(ui->spacing_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
60✔
29
            this, &EventViewer_Widget::_setVerticalSpacing);
40✔
30
    connect(ui->height_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
60✔
31
            this, &EventViewer_Widget::_setEventHeight);
40✔
32
}
20✔
33

34
EventViewer_Widget::~EventViewer_Widget() {
40✔
35
    delete ui;
20✔
36
}
40✔
37

UNCOV
38
void EventViewer_Widget::setActiveKey(std::string const & key) {
×
UNCOV
39
    _active_key = key;
×
40
    ui->name_label->setText(QString::fromStdString(key));
×
41

42
    // Set the color and display options to current values from display options if available
43
    if (!key.empty()) {
×
44
        auto config = _opengl_widget->getDigitalEventConfig(key);
×
UNCOV
45
        if (config.has_value()) {
×
UNCOV
46
            _updateColorDisplay(QString::fromStdString(config.value()->hex_color));
×
47

48
            // Set display mode controls
49
            ui->mode_combo->setCurrentIndex(static_cast<int>(config.value()->display_mode));
×
UNCOV
50
            ui->spacing_spinbox->setValue(static_cast<double>(config.value()->vertical_spacing));
×
51
            ui->height_spinbox->setValue(static_cast<double>(config.value()->event_height));
×
52
        } else {
53
            _updateColorDisplay("#FF0000");// Default red
×
54
            ui->mode_combo->setCurrentIndex(0);   // Default to Stacked
×
55
            ui->spacing_spinbox->setValue(0.1);   // Default spacing
×
UNCOV
56
            ui->height_spinbox->setValue(0.05);   // Default height
×
57
        }
58
    }
59

60
    std::cout << "EventViewer_Widget: Active key set to " << key << std::endl;
×
UNCOV
61
}
×
62

63
void EventViewer_Widget::_openColorDialog() {
×
64
    if (_active_key.empty()) {
×
65
        return;
×
66
    }
67
    
68
    // Get current color
69
    QColor currentColor;
×
UNCOV
70
    auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
71
    if (config.has_value()) {
×
UNCOV
72
        currentColor = QColor(QString::fromStdString(config.value()->hex_color));
×
73
    } else {
74
        currentColor = QColor("#FF0000");
×
75
    }
76
    
77
    // Open color dialog
78
    QColor color = QColorDialog::getColor(currentColor, this, "Choose Color");
×
79
    
UNCOV
80
    if (color.isValid()) {
×
81
        QString hex_color = color.name();
×
UNCOV
82
        _updateColorDisplay(hex_color);
×
83
        _setEventColor(hex_color);
×
UNCOV
84
    }
×
85
}
86

87
void EventViewer_Widget::_updateColorDisplay(QString const & hex_color) {
×
88
    // Update the color display button with the new color
89
    ui->color_display_button->setStyleSheet(
×
90
        QString("QPushButton { background-color: %1; border: 1px solid #808080; }").arg(hex_color)
×
91
    );
UNCOV
92
}
×
93

UNCOV
94
void EventViewer_Widget::_setEventColor(QString const & hex_color) {
×
95
    if (!_active_key.empty()) {
×
96
        auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
97
        if (config.has_value()) {
×
98
            config.value()->hex_color = hex_color.toStdString();
×
99
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
100
        }
UNCOV
101
        emit colorChanged(_active_key, hex_color.toStdString());
×
102
    }
103
}
×
104

105
void EventViewer_Widget::_setEventAlpha(int alpha) {
×
106
    if (!_active_key.empty()) {
×
107
        float const alpha_float = static_cast<float>(alpha) / 100.0f;
×
108
        auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
109
        if (config.has_value()) {
×
110
            config.value()->alpha = alpha_float;
×
UNCOV
111
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
112
        }
113
        emit alphaChanged(_active_key, alpha_float);
×
114
    }
UNCOV
115
}
×
116

UNCOV
117
void EventViewer_Widget::_setDisplayMode(int mode_index) {
×
UNCOV
118
    if (!_active_key.empty()) {
×
UNCOV
119
        auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
UNCOV
120
        if (config.has_value()) {
×
UNCOV
121
            config.value()->display_mode = static_cast<EventDisplayMode>(mode_index);
×
UNCOV
122
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
123
        }
124
    }
UNCOV
125
}
×
126

UNCOV
127
void EventViewer_Widget::_setVerticalSpacing(double spacing) {
×
UNCOV
128
    if (!_active_key.empty()) {
×
UNCOV
129
        auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
UNCOV
130
        if (config.has_value()) {
×
UNCOV
131
            config.value()->vertical_spacing = static_cast<float>(spacing);
×
UNCOV
132
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
133
        }
134
    }
UNCOV
135
}
×
136

UNCOV
137
void EventViewer_Widget::_setEventHeight(double height) {
×
UNCOV
138
    if (!_active_key.empty()) {
×
UNCOV
139
        auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
UNCOV
140
        if (config.has_value()) {
×
UNCOV
141
            config.value()->event_height = static_cast<float>(height);
×
UNCOV
142
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
143
        }
144
    }
UNCOV
145
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc