#pragma once #include #include #include #include #include #include #include "tools/cabana/dbc/dbcmanager.h" #include "tools/cabana/streams/abstractstream.h" #include "tools/cabana/ui/app.h" #include "tools/cabana/ui/dialogs/settingsdialog.h" #include "tools/cabana/ui/dialogs/streamselector.h" #include "tools/cabana/ui/helpoverlay.h" #include "tools/cabana/ui/tools/tooldialog.h" #include "tools/cabana/ui/chart/chartswidget.h" #include "tools/cabana/ui/widgets/detailwidget.h" #include "tools/cabana/ui/widgets/messageswidget.h" #include "tools/cabana/ui/widgets/videowidget.h" struct GLFWwindow; class MainWindow { public: MainWindow(GLFWwindow *window, std::unique_ptr stream, StreamLoader stream_loader, const std::string &dbc_file); ~MainWindow(); void draw(); void toggleChartsDocking(); void close(); bool exited() const { return exited_; } void showStatusMessage(const std::string &msg, int timeout_ms = 0); void loadFile(const std::string &fn, SourceSet s = SOURCE_ALL, std::function then = {}); void selectAndOpenStream(); void openStream(std::unique_ptr stream, const std::string &dbc_file = {}); void closeStream(); void exportToCSV(); void newFile(SourceSet s = SOURCE_ALL); void openFile(SourceSet s = SOURCE_ALL); void loadDBCFromOpendbc(const std::string &name); void save(std::function then = {}); void saveAs(std::function then = {}); void saveToClipboard(); private: bool hasStream() const { return dynamic_cast(can) == nullptr; } void releaseStream(); void startStream(std::unique_ptr stream, const std::string &dbc_file); void loadStartupStream(const std::string &dbc_file); void remindSaveChanges(std::function then); void closeFile(SourceSet s, std::function then); void closeFile(DBCFile *dbc_file); void saveFiles(bool as, std::function then); void saveFile(DBCFile *dbc_file, std::function then = {}); void saveFileAs(DBCFile *dbc_file, std::function then = {}); void saveFileToClipboard(DBCFile *dbc_file); void copyToClipboard(const std::string &text); void loadFingerprints(); void loadFromClipboard(SourceSet s = SOURCE_ALL, bool close_all = true); void updateRecentFiles(const std::string &fn); void dbcFileChanged(); void updateDownloadProgress(uint64_t cur, uint64_t total, bool success); void openSettings(); void findSimilarBits(); void findSignal(); void toggleHelp(); void toggleFullScreen(); void updateWindowTitle(); void eventsMerged(); void saveSessionState(); void restoreSessionState(); void finishClose(); void nextFrame(std::function fn) { next_frame_.push_back(std::move(fn)); } void createDockWidgets(); void handleShortcuts(); void drawMenuBar(); void drawFileMenu(); void drawManageDBCsMenu(); void drawRecentFilesMenu(); void drawDockspace(); void drawMessagesPanel(); void drawVideoPanel(); void drawStatusBar(); void drawWaitDialog(); GLFWwindow *window_; std::unique_ptr startup_stream_; StreamLoader startup_loader_; std::unique_ptr stream_; DummyStream dummy_; std::unique_ptr messages_widget_; CenterWidget center_widget_; std::unique_ptr video_widget_; std::unique_ptr charts_widget_; StreamSelector stream_selector_; SettingsDialog settings_dialog_; HelpOverlay help_overlay_; std::unordered_map fingerprint_to_dbc_; std::vector opendbc_names_; enum { MAX_RECENT_FILES = 15 }; std::string car_fingerprint_; std::string video_dock_title_; bool messages_visible_ = true; bool video_visible_ = true; bool reset_layout_ = false; bool full_screen_ = false; #ifndef __APPLE__ int windowed_rect_[4] = {0, 0, 1600, 900}; #endif bool charts_floating_ = false; float video_splitter_ratio_ = -1.0f; std::vector> tool_dialogs_; bool closing_ = false; bool exited_ = false; bool window_modified_ = false; struct StatusBar { std::string message; double message_until = 0; bool progress_visible = false; float progress_value = 0; std::string progress_text; } status_bar_; struct WaitDialog { bool open = false; double show_at = 0; std::string text; int value = 0; Connection connection; } wait_dlg_; std::vector> next_frame_; Connections connections_; Connections stream_connections_; Connections widget_connections_; };