Skip to content

Commit

Permalink
dataload_mcap: real progress bar and share mcap file path between plu…
Browse files Browse the repository at this point in the history
…gins (#1040)

* dataload_mcap: add mcap file path toUserDefined

Include the MCAP file path in PlotJuggler's user-defined data so
that other plugins can access and utilize it.

Signed-off-by: Luca Bartoli <[email protected]>
Co-authored-by: Michele Guzzinati <[email protected]>

* dataload_mcap: add real progress bar

Add the real range of the progress bar during mcap loading, so users
can accurately track the real loading progress.

Signed-off-by: Luca Bartoli <[email protected]>
Co-authored-by: Michele Guzzinati <[email protected]>

---------

Signed-off-by: Luca Bartoli <[email protected]>
Co-authored-by: Michele Guzzinati <[email protected]>
  • Loading branch information
lucabart97 and mguzzina authored Jan 28, 2025
1 parent 45b678f commit afa2f55
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions plotjuggler_plugins/DataLoadMCAP/dataload_mcap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ bool DataLoadMCAP::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_dat
.arg(QString::fromStdString(status.message)));
return false;
}
plot_data.addUserDefined("plotjuggler::mcap::file_path")
->second.pushBack({ 0, std::any(info->filename.toStdString()) });

auto statistics = reader.statistics();

std::unordered_map<int, mcap::SchemaPtr> mcap_schemas; // schema_id
Expand Down Expand Up @@ -186,6 +189,7 @@ bool DataLoadMCAP::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_dat
}

std::unordered_set<int> enabled_channels;
size_t total_msgs = 0;

for (const auto& [channel_id, parser] : parsers_by_channel)
{
Expand All @@ -197,6 +201,11 @@ bool DataLoadMCAP::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_dat
if (_dialog_parameters->selected_topics.contains(topic_name))
{
enabled_channels.insert(channel_id);
auto mcap_channel = channels[channel_id]->id;
if (statistics->channelMessageCounts.count(mcap_channel) != 0)
{
total_msgs += statistics->channelMessageCounts[channels[channel_id]->id];
}
}
}

Expand All @@ -211,10 +220,8 @@ bool DataLoadMCAP::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_dat

QProgressDialog progress_dialog("Loading... please wait", "Cancel", 0, 0, nullptr);
progress_dialog.setWindowTitle("Loading the MCAP file");
progress_dialog.setModal(true);
progress_dialog.setAutoClose(true);
progress_dialog.setAutoReset(true);
progress_dialog.setMinimumDuration(0);
progress_dialog.setWindowModality(Qt::ApplicationModal);
progress_dialog.setRange(0, std::max<size_t>(total_msgs, 1) - 1);
progress_dialog.show();
progress_dialog.setValue(0);

Expand Down Expand Up @@ -246,6 +253,7 @@ bool DataLoadMCAP::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_dat

if (msg_count++ % 1000 == 0)
{
progress_dialog.setValue(msg_count);
QApplication::processEvents();
if (progress_dialog.wasCanceled())
{
Expand Down

0 comments on commit afa2f55

Please sign in to comment.