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

paulmthompson / WhiskerToolbox / 17779724487

16 Sep 2025 09:37PM UTC coverage: 71.659% (-0.8%) from 72.505%
17779724487

push

github

paulmthompson
implementing testing for analysis dashboard widget

51 of 60 new or added lines in 5 files covered. (85.0%)

116 existing lines in 11 files now uncovered.

39156 of 54642 relevant lines covered (71.66%)

1301.46 hits per line

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

85.0
/src/WhiskerToolbox/Analysis_Dashboard/Visualizers/Points/PointDataVisualization.cpp
1
#include "PointDataVisualization.hpp"
2

3
#include "GroupManagementWidget/GroupManager.hpp"
4
#include "DataManager/Points/Point_Data.hpp"
5
#include "DataManager/Points/utils/Point_Data_utils.hpp"
6

7
#include <QOpenGLShaderProgram>
8

9
PointDataVisualization::PointDataVisualization(QString const & data_key,
22✔
10
                                               std::shared_ptr<PointData> const & point_data,
11
                                               GroupManager * group_manager)
22✔
12
    : GenericPointVisualization<float, EntityId>(data_key, group_manager),
13
      m_point_data(point_data) {
22✔
14
    
15
    // Populate data from PointData
16
    populateData();
22✔
17
}
22✔
18

19
void PointDataVisualization::populateData() {
22✔
20
    if (!m_point_data) {
22✔
21
        qDebug() << "PointDataVisualization: No PointData provided";
×
22
        return;
×
23
    }
24

25
    // Calculate bounds for QuadTree initialization
26
    BoundingBox bounds = calculateBoundsForPointData(m_point_data.get());
22✔
27

28
    // Update the spatial index with proper bounds
29
    m_spatial_index = std::make_unique<QuadTree<EntityId>>(bounds);
22✔
30
    m_vertex_data.reserve(m_point_data->GetAllPointsAsRange().size() * 3);// Reserve space for x, y, group_id
22✔
31

32
    // Collect EntityIds for each point to enable proper grouping
33
    std::vector<EntityId> entity_ids;
22✔
34
    // Pre-reserve approximate; we will push for each point below
35

36
    for (auto const & time_points_pair: m_point_data->GetAllPointsAsRange()) {
77✔
37
        // Get EntityIds for this time frame
38
        auto const & frame_entity_ids = m_point_data->getEntityIdsAtTime(time_points_pair.time);
55✔
39
        
40
        for (size_t i = 0; i < time_points_pair.points.size(); ++i) {
196✔
41
            auto const & point = time_points_pair.points[i];
141✔
42
            
43
            // Map i to entity id for this time
44
            EntityId eid = 0;
141✔
45
            if (i < frame_entity_ids.size()) {
141✔
46
                eid = frame_entity_ids[i];
141✔
47
            }
48

49
            // Store original coordinates in QuadTree with EntityId as data
50
            m_spatial_index->insert(point.x, point.y, eid);
141✔
51

52
            // Store coordinates and group_id in vertex data for OpenGL rendering
53
            m_vertex_data.push_back(point.x);
141✔
54
            m_vertex_data.push_back(point.y);
141✔
55
            m_vertex_data.push_back(0.0f);// group_id = 0 (ungrouped) initially
141✔
56
            
57
            // Store the corresponding EntityId (or 0 if unavailable)
58
            entity_ids.push_back(eid);
141✔
59
        }
60
    }
61

62
    // Initialize visibility statistics
63
    m_total_point_count = m_vertex_data.size() / 3;// 3 components per point now
22✔
64
    m_hidden_point_count = 0;
22✔
65
    m_visible_vertex_count = m_vertex_data.size();
22✔
66
    
67
    // Set up EntityIds for grouping support
68
    qDebug() << "PointDataVisualization: Setting up" << entity_ids.size() << "EntityIds for grouping";
22✔
69
    setPerPointEntityIds(std::move(entity_ids));
22✔
70

71
    // Update the OpenGL vertex buffer with the populated data
72
    if (m_vertex_buffer.isCreated()) {
22✔
73
        m_vertex_buffer.bind();
22✔
74
        m_vertex_buffer.allocate(m_vertex_data.data(), static_cast<int>(m_vertex_data.size() * sizeof(float)));
22✔
75
        m_vertex_buffer.release();
22✔
76
    }
77

78
    qDebug() << "PointDataVisualization: Populated data with" << m_total_point_count << "points";
22✔
79
}
22✔
80

UNCOV
81
BoundingBox PointDataVisualization::getDataBounds() const {
×
UNCOV
82
    if (!m_point_data) {
×
UNCOV
83
        return BoundingBox(0.0f, 0.0f, 1.0f, 1.0f);
×
84
    }
UNCOV
85
    return calculateBoundsForPointData(m_point_data.get());
×
86
}
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