Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pj_proto_app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_executable(pj_proto_app
src/main_window.cpp
src/plugin_registry.cpp
src/data_source_session.cpp
src/toolbox_session.cpp
src/series_tree_model.cpp
src/chart_panel.cpp
src/time_range_slider.cpp
Expand Down
34 changes: 34 additions & 0 deletions pj_proto_app/src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ MainWindow::MainWindow(const std::string& plugin_dir, QWidget* parent)
});
connect(&refresh_timer_, &QTimer::timeout, this, &MainWindow::onRefreshTimer);

// --- Tools menu ---
auto* tools_menu = menuBar()->addMenu("&Tools");
setupToolboxPanels(tools_menu);

setWindowTitle("PlotJuggler Proto");
}

Expand Down Expand Up @@ -692,4 +696,34 @@ void MainWindow::onOpenMarketplace() {
}
}

void MainWindow::setupToolboxPanels(QMenu* tools_menu) {
for (const auto& tb : registry_.allToolboxes()) {
auto session =
std::make_unique<ToolboxSession>(engine_, const_cast<PJ::ToolboxLibrary&>(tb.library), tb.name, this);
if (!session->init()) {
continue;
}

connect(session.get(), &ToolboxSession::dataChanged, this, [this]() {
auto [begin, end] = computeVisibleRange();
chart_panel_->updateData(begin, end);
tree_model_.rebuildIfChanged();
});

ToolboxSession* raw_session = session.get();

tools_menu->addAction(QString::fromStdString(tb.name), this, [this, raw_session]() {
if (raw_session->hasDialog()) {
if (raw_session->runDialog(this)) {
auto [begin, end] = computeVisibleRange();
chart_panel_->updateData(begin, end);
tree_model_.rebuildIfChanged();
}
}
});

toolbox_sessions_.push_back(std::move(session));
}
}

} // namespace proto
7 changes: 7 additions & 0 deletions pj_proto_app/src/main_window.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QSpinBox>
#include <QSplitter>
#include <QTimer>
Expand All @@ -13,6 +15,7 @@
#include "pj_datastore/engine.hpp"
#include "plugin_registry.hpp"
#include "series_tree_model.hpp"
#include "toolbox_session.hpp"

#include "pj_marketplace/extension_manager.hpp"

Expand Down Expand Up @@ -43,6 +46,8 @@ class MainWindow : public QMainWindow {
void onTreeContextMenu(const QPoint& pos);

private:
void setupToolboxPanels(QMenu* tools_menu);

/// Compute the current visible time range based on data and streaming state.
std::pair<PJ::Timestamp, PJ::Timestamp> computeVisibleRange() const;

Expand All @@ -66,6 +71,8 @@ class MainWindow : public QMainWindow {
QTimer refresh_timer_;
int refresh_tick_ = 0;
bool streaming_active_ = false;

std::vector<std::unique_ptr<ToolboxSession>> toolbox_sessions_;
};

} // namespace proto
Loading