mainwindow.h
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5  */
6 
7 #ifndef MAINWINDOW_H
8 #define MAINWINDOW_H
9 
10 #include <set>
11 #include <deque>
12 #include <functional>
13 
14 #include <QCommandLineParser>
15 #include <QElapsedTimer>
16 #include <QMainWindow>
17 #include <QSignalMapper>
18 #include <QShortcut>
19 #include <QMovie>
20 
21 #include "plotwidget.h"
22 #include "plot_docker.h"
23 #include "curvelist_panel.h"
24 #include "tabbedplotwidget.h"
25 #include "realslider.h"
26 #include "utils.h"
34 
35 #include "ui_mainwindow.h"
36 
37 class MainWindow : public QMainWindow
38 {
39  Q_OBJECT
40 
41 public:
42  explicit MainWindow(const QCommandLineParser& commandline_parser,
43  QWidget* parent = nullptr);
44 
45  ~MainWindow();
46 
47  bool loadLayoutFromFile(QString filename);
48  bool loadDataFromFiles(QStringList filenames);
49  std::unordered_set<std::string> loadDataFromFile(const FileLoadInfo& info);
50 
51  void stopStreamingPlugin();
52  void startStreamingPlugin(QString streamer_name);
53  void enableStreamingNotificationsButton(bool enabled);
54 
55 public slots:
56 
57  void resizeEvent(QResizeEvent*);
58  // Undo - Redo
59  void onUndoableChange();
60  void onUndoInvoked();
61  void onRedoInvoked();
62 
63  // Actions in UI
64  void on_streamingToggled();
65 
66  void on_buttonStreamingPause_toggled(bool paused);
68 
70 
71  void on_comboStreaming_currentIndexChanged(const QString& current_text);
72 
73  void on_splitterMoved(int, int);
74 
75  void onTrackerTimeUpdated(double absolute_time, bool do_replot);
76  void onTrackerMovedFromWidget(QPointF pos);
77  void onTimeSlider_valueChanged(double abs_time);
78 
79  void onPlotAdded(PlotWidget* plot);
80 
81  void onPlotTabAdded(PlotDocker* docker);
82 
83  void onPlotZoomChanged(PlotWidget* modified_plot, QRectF new_range);
84 
85  void on_tabbedAreaDestroyed(QObject* object);
86 
87  void updateDataAndReplot(bool replot_hidden_tabs);
88 
90 
91  void onDeleteMultipleCurves(const std::vector<std::string>& curve_names);
92 
93  void onAddCustomPlot(const std::string& plot_name);
94 
95  void onEditCustomPlot(const std::string& plot_name);
96 
97  void onRefreshCustomPlot(const std::string& plot_name);
98 
99  void onCustomPlotCreated(std::vector<CustomPlotPtr> plot);
100 
101  void onPlaybackLoop();
102 
103  void linkedZoomOut();
104 
105 private:
106  Ui::MainWindow* ui;
107 
109 
110  QShortcut _undo_shortcut;
111  QShortcut _redo_shortcut;
114  QShortcut _playback_shotcut;
115 
117 
119 
121 
123 
124  std::map<QString, DataLoaderPtr> _data_loader;
125  std::map<QString, StatePublisherPtr> _state_publisher;
126  std::map<QString, DataStreamerPtr> _data_streamer;
127  std::map<QString, ToolboxPluginPtr> _toolboxes;
128 
130 
132 
133  std::shared_ptr<DataStreamer> _active_streamer_plugin;
134 
135  std::deque<QDomDocument> _undo_states;
136  std::deque<QDomDocument> _redo_states;
137  QElapsedTimer _undo_timer;
139 
141 
143 
145 
146  QStringList _enabled_plugins;
147  QStringList _disabled_plugins;
148 
149  std::vector<FileLoadInfo> _loaded_datafiles;
151 
152  std::map<CurveTracker::Parameter, QIcon> _tracker_button_icons;
153 
155 
156  QTimer* _replot_timer;
157  QTimer* _publish_timer;
159 
161 
163 
166 
168  {
172  };
173 
175 
178 
179  QString _skin_path;
180 
181  void initializeActions();
182  QStringList initializePlugins(QString subdir_name);
183 
184  void forEachWidget(std::function<void(PlotWidget*, PlotDocker*, int)> op);
185  void forEachWidget(std::function<void(PlotWidget*)> op);
186 
187  void rearrangeGridLayout();
188 
189  QDomDocument xmlSaveState() const;
190  bool xmlLoadState(QDomDocument state_document);
191 
192  void checkAllCurvesFromLayout(const QDomElement& root);
193 
194  void importPlotDataMap(PlotDataMapRef& new_data, bool remove_old);
195 
196  bool isStreamingActive() const;
197 
198  void closeEvent(QCloseEvent* event);
199 
200  void loadPluginState(const QDomElement& root);
201  QDomElement savePluginState(QDomDocument& doc);
202 
203  std::tuple<double, double, int> calculateVisibleRangeX();
204 
205  void deleteAllData();
206 
207  void updateRecentDataMenu(QStringList new_filenames);
208  void updateRecentLayoutMenu(QStringList new_filenames);
209 
210  void updatedDisplayTime();
211 
212  void updateTimeSlider();
213  void updateTimeOffset();
214 
215  void buildDummyData();
216 
217  void loadStyleSheet(QString file_path);
218 
219  void updateDerivedSeries();
220 
221  void updateReactivePlots();
222 
223  void dragEnterEvent(QDragEnterEvent* event);
224 
225  void dropEvent(QDropEvent* event);
226 
227 signals:
228  void dataSourceRemoved(const std::string& name);
229  void dataSourceUpdated(const std::string& name);
230  void activateTracker(bool active);
231  void stylesheetChanged(QString style_name);
232 
233 public slots:
234 
237 
240 
241  void on_deleteSerieFromGroup(std::string group_name);
242 
243  void on_streamingNotificationsChanged(int active_notifications_count);
244 
246 
250  // TODO ? void on_actionSaveAllPlotTabs_triggered();
251 
254 
255  void on_pushButtonActivateGrid_toggled(bool checked);
256  void on_pushButtonRatio_toggled(bool checked);
257  void on_pushButtonPlay_toggled(bool checked);
258  void on_pushButtonUseDateTime_toggled(bool checked);
260  void on_pushButtonRemoveTimeOffset_toggled(bool checked);
261 
263 
264 private slots:
265  void on_stylesheetChanged(QString style_name);
268  void on_playbackStep_valueChanged(double arg1);
272 
277 
283 
285 
286 private:
287  QStringList readAllCurvesFromXML(QDomElement root_node);
288  void loadAllPlugins(QStringList command_line_plugin_folders);
289 };
290 
291 class PopupMenu : public QMenu
292 {
293  Q_OBJECT
294 public:
295  explicit PopupMenu(QWidget* relative_widget, QWidget* parent = nullptr);
296 
297  void showEvent(QShowEvent*) override;
298  void leaveEvent(QEvent*) override;
299  void closeEvent(QCloseEvent*) override;
300 
301 private:
302  QWidget* _w;
303 };
304 
305 #endif // MAINWINDOW_H
void on_actionExit_triggered()
void onRedoInvoked()
Definition: mainwindow.cpp:422
QTimer * _animated_streaming_timer
Definition: mainwindow.h:165
void on_actionClearBuffer_triggered()
void on_comboStreaming_currentIndexChanged(const QString &current_text)
QString _skin_path
Definition: mainwindow.h:179
void onActionFullscreenTriggered()
QShortcut _streaming_shortcut
Definition: mainwindow.h:113
QTimer * _replot_timer
Definition: mainwindow.h:156
void on_actionColorMap_Editor_triggered()
void on_actionSupportPlotJuggler_triggered()
Ui::MainWindow * ui
Definition: mainwindow.h:106
void dataSourceRemoved(const std::string &name)
void rearrangeGridLayout()
void on_pushButtonLoadDatafile_clicked()
void on_actionShare_the_love_triggered()
QShortcut _fullscreen_shortcut
Definition: mainwindow.h:112
void onEditCustomPlot(const std::string &plot_name)
void on_buttonStreamingStart_clicked()
void updateReactivePlots()
void onPlotTabAdded(PlotDocker *docker)
Definition: mainwindow.cpp:987
void on_actionPreferences_triggered()
CurveListPanel * _curvelist_widget
Definition: mainwindow.h:118
std::map< QString, std::shared_ptr< ParserFactoryPlugin > > ParserFactories
void on_stylesheetChanged(QString style_name)
void updatedDisplayTime()
bool _test_option
Definition: mainwindow.h:140
std::vector< FileLoadInfo > _loaded_datafiles
Definition: mainwindow.h:149
QTimer * _publish_timer
Definition: mainwindow.h:157
void deleteAllData()
void resizeEvent(QResizeEvent *)
Definition: mainwindow.cpp:920
bool loadDataFromFiles(QStringList filenames)
void linkedZoomOut()
std::unordered_map< std::string, std::shared_ptr< TransformFunction > > TransformsMap
void checkAllCurvesFromLayout(const QDomElement &root)
PlotDataMapRef _mapped_plot_data
Definition: mainwindow.h:120
void closeEvent(QCloseEvent *event)
std::map< CurveTracker::Parameter, QIcon > _tracker_button_icons
Definition: mainwindow.h:152
bool xmlLoadState(QDomDocument state_document)
bool loadLayoutFromFile(QString filename)
void forEachWidget(std::function< void(PlotWidget *, PlotDocker *, int)> op)
void on_actionReportBug_triggered()
void on_actionClearRecentLayout_triggered()
void dropEvent(QDropEvent *event)
void on_actionCheatsheet_triggered()
void onTrackerMovedFromWidget(QPointF pos)
Definition: mainwindow.cpp:462
void on_pushButtonZoomOut_clicked()
std::map< QString, ToolboxPluginPtr > _toolboxes
Definition: mainwindow.h:127
QMovie * _animated_streaming_movie
Definition: mainwindow.h:164
void on_actionClearRecentData_triggered()
std::deque< QDomDocument > _redo_states
Definition: mainwindow.h:136
void onPlotAdded(PlotWidget *plot)
Definition: mainwindow.cpp:925
void updateDataAndReplot(bool replot_hidden_tabs)
void onTimeSlider_valueChanged(double abs_time)
Definition: mainwindow.cpp:473
QStringList initializePlugins(QString subdir_name)
Definition: mainwindow.cpp:595
std::map< QString, DataStreamerPtr > _data_streamer
Definition: mainwindow.h:126
void startStreamingPlugin(QString streamer_name)
void on_buttonStreamingNotifications_clicked()
MainWindow(const QCommandLineParser &commandline_parser, QWidget *parent=nullptr)
Definition: mainwindow.cpp:70
QStringList readAllCurvesFromXML(QDomElement root_node)
TransformsMap _transform_functions
Definition: mainwindow.h:122
void initializeActions()
Definition: mainwindow.cpp:499
std::map< QString, StatePublisherPtr > _state_publisher
Definition: mainwindow.h:125
void updateDerivedSeries()
double _tracker_time
Definition: mainwindow.h:144
void on_pushButtonPlay_toggled(bool checked)
void buildDummyData()
Definition: mainwindow.cpp:884
void onPlotZoomChanged(PlotWidget *modified_plot, QRectF new_range)
Definition: mainwindow.cpp:965
QElapsedTimer _undo_timer
Definition: mainwindow.h:137
void on_pushButtonLegend_clicked()
void on_pushButtonLoadLayout_clicked()
void onTrackerTimeUpdated(double absolute_time, bool do_replot)
Definition: mainwindow.cpp:479
TabbedPlotWidget * _main_tabbed_widget
Definition: mainwindow.h:108
void loadAllPlugins(QStringList command_line_plugin_folders)
Definition: mainwindow.cpp:531
void updateRecentLayoutMenu(QStringList new_filenames)
QShortcut _playback_shotcut
Definition: mainwindow.h:114
void onPlaybackLoop()
void on_buttonHidePublishersFrame_clicked()
void loadPluginState(const QDomElement &root)
void on_deleteSerieFromGroup(std::string group_name)
void loadStyleSheet(QString file_path)
QStringList _disabled_plugins
Definition: mainwindow.h:147
void on_actionLoadStyleSheet_triggered()
void on_buttonHideFileFrame_clicked()
void on_tabbedAreaDestroyed(QObject *object)
LabelStatus _labels_status
Definition: mainwindow.h:174
QDateTime _prev_publish_time
Definition: mainwindow.h:160
CurveTracker::Parameter _tracker_param
Definition: mainwindow.h:150
void updateTimeSlider()
void on_pushButtonRatio_toggled(bool checked)
void on_streamingSpinBox_valueChanged(int value)
QMenu * _recent_data_files
Definition: mainwindow.h:176
void onUndoInvoked()
Definition: mainwindow.cpp:439
void stopStreamingPlugin()
void enableStreamingNotificationsButton(bool enabled)
void stylesheetChanged(QString style_name)
void onAddCustomPlot(const std::string &plot_name)
#define op
QDomElement savePluginState(QDomDocument &doc)
QShortcut _redo_shortcut
Definition: mainwindow.h:111
bool _minimized
Definition: mainwindow.h:116
void dragEnterEvent(QDragEnterEvent *event)
PJ::DelayedCallback _tracker_delay
Definition: mainwindow.h:158
void on_actionDeleteAllData_triggered()
void on_buttonRecentData_clicked()
void on_buttonHideStreamingFrame_clicked()
FunctionEditorWidget * _function_editor
Definition: mainwindow.h:162
void onDeleteMultipleCurves(const std::vector< std::string > &curve_names)
bool _autostart_publishers
Definition: mainwindow.h:142
MonitoredValue _time_offset
Definition: mainwindow.h:154
void on_actionAbout_triggered()
std::deque< QDomDocument > _undo_states
Definition: mainwindow.h:135
ParserFactories _parser_factories
Definition: mainwindow.h:131
std::map< QString, DataLoaderPtr > _data_loader
Definition: mainwindow.h:124
void on_buttonRecentLayout_clicked()
void on_streamingToggled()
std::shared_ptr< DataStreamer > _active_streamer_plugin
Definition: mainwindow.h:133
bool isStreamingActive() const
void on_pushButtonUseDateTime_toggled(bool checked)
void updateTimeOffset()
void onRefreshCustomPlot(const std::string &plot_name)
void on_buttonStreamingPause_toggled(bool paused)
QStringList _enabled_plugins
Definition: mainwindow.h:146
void onCustomPlotCreated(std::vector< CustomPlotPtr > plot)
QShortcut _undo_shortcut
Definition: mainwindow.h:110
void activateTracker(bool active)
QWidget * _w
Definition: mainwindow.h:302
void dataSourceUpdated(const std::string &name)
Definition: core.h:1131
void on_pushButtonActivateGrid_toggled(bool checked)
void importPlotDataMap(PlotDataMapRef &new_data, bool remove_old)
void on_buttonStreamingOptions_clicked()
void on_playbackStep_valueChanged(double arg1)
void on_pushButtonTimeTracker_pressed()
bool _disable_undo_logging
Definition: mainwindow.h:138
void onUndoableChange()
Definition: mainwindow.cpp:401
QMenu * _recent_layout_files
Definition: mainwindow.h:177
QString _default_streamer
Definition: mainwindow.h:129
QDomDocument xmlSaveState() const
Definition: mainwindow.cpp:998
void on_splitterMoved(int, int)
Definition: mainwindow.cpp:891
void on_pushButtonRemoveTimeOffset_toggled(bool checked)
void on_pushButtonSaveLayout_clicked()
void updateRecentDataMenu(QStringList new_filenames)
void onUpdateLeftTableValues()
Definition: mainwindow.cpp:457
std::unordered_set< std::string > loadDataFromFile(const FileLoadInfo &info)
void on_streamingNotificationsChanged(int active_notifications_count)
std::tuple< double, double, int > calculateVisibleRangeX()


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:01:38