• 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

22.62
/src/WhiskerToolbox/DataViewer_Widget/DigitalInterval/IntervalViewer_Widget.cpp
1
#include "IntervalViewer_Widget.hpp"
2
#include "ui_IntervalViewer_Widget.h"
3

4
#include "DataManager/DataManager.hpp"
5
#include "DataViewer/DigitalInterval/DigitalIntervalSeriesDisplayOptions.hpp"
6
#include "DataViewer_Widget/OpenGLWidget.hpp"
7

8
#include <QColorDialog>
9
#include <QHideEvent>
10
#include <QShowEvent>
11
#include <iostream>
12

13
IntervalViewer_Widget::IntervalViewer_Widget(std::shared_ptr<DataManager> data_manager, OpenGLWidget * opengl_widget, QWidget * parent)
20✔
14
    : QWidget(parent),
15
      ui(new Ui::IntervalViewer_Widget),
40✔
16
      _data_manager{std::move(data_manager)},
20✔
17
      _opengl_widget{opengl_widget}
40✔
18
{
19
    ui->setupUi(this);
20✔
20
    
21
    // Set the color display button to be flat and show just the color
22
    ui->color_display_button->setFlat(false);
20✔
23
    ui->color_display_button->setEnabled(false); // Make it non-clickable, just for display
20✔
24
    
25
    connect(ui->color_button, &QPushButton::clicked,
60✔
26
            this, &IntervalViewer_Widget::_openColorDialog);
40✔
27
}
20✔
28

29
IntervalViewer_Widget::~IntervalViewer_Widget() {
40✔
30
    delete ui;
20✔
31
}
40✔
32

33
void IntervalViewer_Widget::showEvent(QShowEvent * event) {
×
34
    std::cout << "IntervalViewer_Widget: Show Event" << std::endl;
×
35
    connect(_opengl_widget, &OpenGLWidget::mouseClick, this, &IntervalViewer_Widget::_selectInterval);
×
36
    QWidget::showEvent(event);
×
37
}
×
38

39
void IntervalViewer_Widget::hideEvent(QHideEvent * event) {
20✔
40
    std::cout << "IntervalViewer_Widget: Hide Event" << std::endl;
20✔
41
    disconnect(_opengl_widget, &OpenGLWidget::mouseClick, this, &IntervalViewer_Widget::_selectInterval);
20✔
42
    
43
    // Clear any selected interval when widget is hidden
44
    if (!_active_key.empty()) {
20✔
45
        _opengl_widget->clearSelectedInterval(_active_key);
×
46
    }
47
    
48
    QWidget::hideEvent(event);
20✔
49
}
20✔
50

51
void IntervalViewer_Widget::setActiveKey(std::string const & key) {
×
52
    // Clear previous selection if we had one
53
    if (!_active_key.empty()) {
×
54
        _opengl_widget->clearSelectedInterval(_active_key);
×
55
    }
56
    
57
    _active_key = key;
×
58
    ui->name_label->setText(QString::fromStdString(key));
×
59
    _selection_enabled = !key.empty();
×
60
    
61
    // Set the color to the current color from display options if available
62
    if (!key.empty()) {
×
63
        auto config = _opengl_widget->getDigitalIntervalConfig(key);
×
64
        if (config.has_value()) {
×
65
            _updateColorDisplay(QString::fromStdString(config.value()->hex_color));
×
66
        } else {
67
            _updateColorDisplay("#00FF00"); // Default green
×
68
        }
69
    }
70
    
71
    std::cout << "IntervalViewer_Widget: Active key set to " << key << std::endl;
×
72
}
×
73

74
void IntervalViewer_Widget::_selectInterval(float time_coordinate, float canvas_y, QString const & series_info) {
×
75

76
    static_cast<void>(canvas_y);
77
    static_cast<void>(series_info);
78

79
    if (!_selection_enabled || _active_key.empty()) {
×
80
        return;
×
81
    }
82
    
83
    // Find interval at the clicked time coordinate
84
    auto interval = _opengl_widget->findIntervalAtTime(_active_key, time_coordinate);
×
85
    if (interval.has_value()) {
×
86
        auto const [start_time, end_time] = interval.value();
×
87
        
88
        std::cout << "IntervalViewer_Widget: Selected interval from " 
×
89
                  << start_time << " to " << end_time 
×
90
                  << " for series " << _active_key << std::endl;
×
91
        
92
        // Set the selected interval for highlighting
93
        _opengl_widget->setSelectedInterval(_active_key, start_time, end_time);
×
94
    } else {
95
        // No interval found at this time - clear selection
96
        _opengl_widget->clearSelectedInterval(_active_key);
×
97
    }
98
}
99

100
void IntervalViewer_Widget::_openColorDialog() {
×
101
    if (_active_key.empty()) {
×
102
        return;
×
103
    }
104
    
105
    // Get current color
106
    QColor currentColor;
×
107
    auto config = _opengl_widget->getDigitalIntervalConfig(_active_key);
×
108
    if (config.has_value()) {
×
109
        currentColor = QColor(QString::fromStdString(config.value()->hex_color));
×
110
    } else {
111
        currentColor = QColor("#00FF00");
×
112
    }
113
    
114
    // Open color dialog
115
    QColor color = QColorDialog::getColor(currentColor, this, "Choose Color");
×
116
    
117
    if (color.isValid()) {
×
118
        QString hex_color = color.name();
×
119
        _updateColorDisplay(hex_color);
×
120
        _setIntervalColor(hex_color);
×
121
    }
×
122
}
123

124
void IntervalViewer_Widget::_updateColorDisplay(QString const & hex_color) {
×
125
    // Update the color display button with the new color
126
    ui->color_display_button->setStyleSheet(
×
127
        QString("QPushButton { background-color: %1; border: 1px solid #808080; }").arg(hex_color)
×
128
    );
129
}
×
130

131
void IntervalViewer_Widget::_setIntervalColor(const QString& hex_color) {
×
132
    if (!_active_key.empty()) {
×
133
        auto config = _opengl_widget->getDigitalIntervalConfig(_active_key);
×
134
        if (config.has_value()) {
×
135
            config.value()->hex_color = hex_color.toStdString();
×
136
            emit colorChanged(_active_key, hex_color.toStdString());
×
137
            // Trigger immediate repaint
138
            _opengl_widget->update();
×
139
        }
140
    }
UNCOV
141
}
×
142

143
void IntervalViewer_Widget::_setIntervalAlpha(int alpha) {
×
144
    if (!_active_key.empty()) {
×
145
        float const alpha_float = static_cast<float>(alpha) / 100.0f;
×
146
        auto config = _opengl_widget->getDigitalIntervalConfig(_active_key);
×
147
        if (config.has_value()) {
×
148
            config.value()->alpha = alpha_float;
×
UNCOV
149
            emit alphaChanged(_active_key, alpha_float);
×
150
            // Trigger immediate repaint
UNCOV
151
            _opengl_widget->update();
×
152
        }
153
    }
UNCOV
154
} 
×
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