• 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.59
/src/WhiskerToolbox/DataViewer_Widget/AnalogTimeSeries/AnalogViewer_Widget.cpp
1
#include "AnalogViewer_Widget.hpp"
2
#include "ui_AnalogViewer_Widget.h"
3

4
#include "DataManager/DataManager.hpp"
5
#include "DataViewer/AnalogTimeSeries/AnalogTimeSeriesDisplayOptions.hpp"
6
#include "DataViewer_Widget/OpenGLWidget.hpp"
7

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

11
AnalogViewer_Widget::AnalogViewer_Widget(std::shared_ptr<DataManager> data_manager, OpenGLWidget * opengl_widget, QWidget * parent)
20✔
12
    : QWidget(parent),
13
      ui(new Ui::AnalogViewer_Widget),
40✔
14
      _data_manager{std::move(data_manager)},
20✔
15
      _opengl_widget{opengl_widget}
40✔
16
{
17
    ui->setupUi(this);
20✔
18
    
19
    // Set the color display button to be flat and show just the color
20
    ui->color_display_button->setFlat(false);
20✔
21
    ui->color_display_button->setEnabled(false); // Make it non-clickable, just for display
20✔
22
    
23
    connect(ui->color_button, &QPushButton::clicked,
60✔
24
            this, &AnalogViewer_Widget::_openColorDialog);
40✔
25
    connect(ui->scale_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
60✔
26
            this, &AnalogViewer_Widget::_setAnalogScaleFactor);
40✔
27
    connect(ui->line_thickness_spinbox, QOverload<int>::of(&QSpinBox::valueChanged),
60✔
28
            this, &AnalogViewer_Widget::_setLineThickness);
40✔
29
    
30
    // Connect gap handling controls
31
    connect(ui->gap_mode_combo, QOverload<int>::of(&QComboBox::currentIndexChanged),
60✔
32
            this, &AnalogViewer_Widget::_setGapHandlingMode);
40✔
33
    connect(ui->gap_threshold_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
60✔
34
            this, &AnalogViewer_Widget::_setGapThreshold);
40✔
35
}
20✔
36

37
AnalogViewer_Widget::~AnalogViewer_Widget() {
40✔
38
    delete ui;
20✔
39
}
40✔
40

UNCOV
41
void AnalogViewer_Widget::setActiveKey(std::string const & key) {
×
UNCOV
42
    _active_key = key;
×
43
    ui->name_label->setText(QString::fromStdString(key));
×
44
    
45
    // Set the color and scale factor to current values from display options if available
46
    if (!key.empty()) {
×
47
        auto config = _opengl_widget->getAnalogConfig(key);
×
UNCOV
48
        if (config.has_value()) {
×
UNCOV
49
            _updateColorDisplay(QString::fromStdString(config.value()->hex_color));
×
50
            
51
            // Set scale factor from user-friendly scale
UNCOV
52
            ui->scale_spinbox->setValue(static_cast<double>(config.value()->user_scale_factor));
×
53
            
54
            // Set line thickness
UNCOV
55
            ui->line_thickness_spinbox->setValue(config.value()->line_thickness);
×
56
            
57
            // Set gap handling controls
UNCOV
58
            ui->gap_mode_combo->setCurrentIndex(static_cast<int>(config.value()->gap_handling));
×
59
            ui->gap_threshold_spinbox->setValue(static_cast<double>(config.value()->gap_threshold));
×
60
        } else {
61
            _updateColorDisplay("#0000FF"); // Default blue
×
62
            ui->scale_spinbox->setValue(1.0); // Default scale
×
63
            ui->line_thickness_spinbox->setValue(1); // Default line thickness
×
64
            ui->gap_mode_combo->setCurrentIndex(0); // Default to AlwaysConnect
×
UNCOV
65
            ui->gap_threshold_spinbox->setValue(5.0); // Default threshold
×
66
        }
67
    }
68
    
69
    std::cout << "AnalogViewer_Widget: Active key set to " << key << std::endl;
×
UNCOV
70
}
×
71

72
void AnalogViewer_Widget::_openColorDialog() {
×
73
    if (_active_key.empty()) {
×
74
        return;
×
75
    }
76
    
77
    // Get current color
78
    QColor currentColor;
×
UNCOV
79
    auto config = _opengl_widget->getAnalogConfig(_active_key);
×
80
    if (config.has_value()) {
×
UNCOV
81
        currentColor = QColor(QString::fromStdString(config.value()->hex_color));
×
82
    } else {
83
        currentColor = QColor("#0000FF");
×
84
    }
85
    
86
    // Open color dialog
87
    QColor color = QColorDialog::getColor(currentColor, this, "Choose Color");
×
88
    
UNCOV
89
    if (color.isValid()) {
×
90
        QString hex_color = color.name();
×
UNCOV
91
        _updateColorDisplay(hex_color);
×
92
        _setAnalogColor(hex_color);
×
UNCOV
93
    }
×
94
}
95

96
void AnalogViewer_Widget::_updateColorDisplay(QString const & hex_color) {
×
97
    // Update the color display button with the new color
UNCOV
98
    ui->color_display_button->setStyleSheet(
×
99
        QString("QPushButton { background-color: %1; border: 1px solid #808080; }").arg(hex_color)
×
100
    );
UNCOV
101
}
×
102

103
void AnalogViewer_Widget::_setAnalogColor(const QString& hex_color) {
×
UNCOV
104
    if (!_active_key.empty()) {
×
105
        auto config = _opengl_widget->getAnalogConfig(_active_key);
×
106
        if (config.has_value()) {
×
107
            config.value()->hex_color = hex_color.toStdString();
×
108
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
109
        }
110
        emit colorChanged(_active_key, hex_color.toStdString());
×
111
    }
UNCOV
112
}
×
113

UNCOV
114
void AnalogViewer_Widget::_setAnalogAlpha(int alpha) {
×
115
    if (!_active_key.empty()) {
×
116
        float const alpha_float = static_cast<float>(alpha) / 100.0f;
×
117
        auto config = _opengl_widget->getAnalogConfig(_active_key);
×
118
        if (config.has_value()) {
×
119
            config.value()->alpha = alpha_float;
×
120
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
121
        }
UNCOV
122
        emit alphaChanged(_active_key, alpha_float);
×
123
    }
UNCOV
124
}
×
125

126
void AnalogViewer_Widget::_setAnalogScaleFactor(double scale_factor) {
×
127
    if (!_active_key.empty()) {
×
128
        auto config = _opengl_widget->getAnalogConfig(_active_key);
×
129
        if (config.has_value()) {
×
130
            // Set the user-friendly scale factor directly
UNCOV
131
            config.value()->user_scale_factor = static_cast<float>(scale_factor);
×
UNCOV
132
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
133
        }
134
    }
UNCOV
135
}
×
136

UNCOV
137
void AnalogViewer_Widget::_setLineThickness(int thickness) {
×
UNCOV
138
    if (!_active_key.empty()) {
×
UNCOV
139
        auto config = _opengl_widget->getAnalogConfig(_active_key);
×
UNCOV
140
        if (config.has_value()) {
×
UNCOV
141
            config.value()->line_thickness = thickness;
×
UNCOV
142
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
143
        }
144
    }
UNCOV
145
}
×
146

UNCOV
147
void AnalogViewer_Widget::_setGapHandlingMode(int mode_index) {
×
UNCOV
148
    if (!_active_key.empty()) {
×
UNCOV
149
        auto config = _opengl_widget->getAnalogConfig(_active_key);
×
UNCOV
150
        if (config.has_value()) {
×
UNCOV
151
            config.value()->gap_handling = static_cast<AnalogGapHandling>(mode_index);
×
UNCOV
152
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
153
        }
154
    }
UNCOV
155
}
×
156

UNCOV
157
void AnalogViewer_Widget::_setGapThreshold(double threshold) {
×
UNCOV
158
    if (!_active_key.empty()) {
×
UNCOV
159
        auto config = _opengl_widget->getAnalogConfig(_active_key);
×
UNCOV
160
        if (config.has_value()) {
×
UNCOV
161
            config.value()->gap_threshold = static_cast<float>(threshold);
×
UNCOV
162
            _opengl_widget->updateCanvas(_data_manager->getCurrentTime());
×
163
        }
164
    }
UNCOV
165
} 
×
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