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

paulmthompson / WhiskerToolbox / 18762825348

23 Oct 2025 09:42PM UTC coverage: 72.822% (+0.3%) from 72.522%
18762825348

push

github

paulmthompson
add boolean digital interval logic test

693 of 711 new or added lines in 5 files covered. (97.47%)

718 existing lines in 10 files now uncovered.

54997 of 75522 relevant lines covered (72.82%)

45740.9 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

38
void EventViewer_Widget::setActiveKey(std::string const & key) {
×
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);
×
45
        if (config.has_value()) {
×
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));
×
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
×
56
            ui->height_spinbox->setValue(0.05);   // Default height
×
57
        }
58
    }
59

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

63
void EventViewer_Widget::_openColorDialog() {
×
64
    if (_active_key.empty()) {
×
65
        return;
×
66
    }
67
    
68
    // Get current color
69
    QColor currentColor;
×
70
    auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
71
    if (config.has_value()) {
×
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
    
80
    if (color.isValid()) {
×
81
        QString hex_color = color.name();
×
82
        _updateColorDisplay(hex_color);
×
83
        _setEventColor(hex_color);
×
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
    );
92
}
×
93

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
            emit colorChanged(_active_key, hex_color.toStdString());
×
100
            // Trigger immediate repaint
101
            _opengl_widget->update();
×
102
        }
103
    }
UNCOV
104
}
×
105

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

119
void EventViewer_Widget::_setDisplayMode(int mode_index) {
×
120
    if (!_active_key.empty()) {
×
121
        auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
122
        if (config.has_value()) {
×
UNCOV
123
            config.value()->display_mode = static_cast<EventDisplayMode>(mode_index);
×
124
            // Trigger immediate repaint
125
            _opengl_widget->update();
×
126
        }
127
    }
128
}
×
129

130
void EventViewer_Widget::_setVerticalSpacing(double spacing) {
×
131
    if (!_active_key.empty()) {
×
132
        auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
UNCOV
133
        if (config.has_value()) {
×
UNCOV
134
            config.value()->vertical_spacing = static_cast<float>(spacing);
×
135
            // Trigger immediate repaint
UNCOV
136
            _opengl_widget->update();
×
137
        }
138
    }
139
}
×
140

141
void EventViewer_Widget::_setEventHeight(double height) {
×
142
    if (!_active_key.empty()) {
×
UNCOV
143
        auto config = _opengl_widget->getDigitalEventConfig(_active_key);
×
UNCOV
144
        if (config.has_value()) {
×
145
            config.value()->event_height = static_cast<float>(height);
×
146
            // Trigger immediate repaint
UNCOV
147
            _opengl_widget->update();
×
148
        }
149
    }
UNCOV
150
}
×
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