mainwindow.h
Go to the documentation of this file.
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3 
4 #include <set>
5 #include <deque>
6 #include <functional>
7 
8 #include <QCommandLineParser>
9 #include <QElapsedTimer>
10 #include <QMainWindow>
11 #include <QSignalMapper>
12 #include <QShortcut>
13 #include <QMovie>
14 
15 #include "plotwidget.h"
16 #include "plot_docker.h"
17 #include "curvelist_panel.h"
18 #include "tabbedplotwidget.h"
19 #include "realslider.h"
20 #include "utils.h"
26 
27 #include "ui_mainwindow.h"
28 
29 class MainWindow : public QMainWindow
30 {
31  Q_OBJECT
32 
33 public:
34  explicit MainWindow(const QCommandLineParser& commandline_parser, QWidget* parent = nullptr);
35 
36  ~MainWindow();
37 
38  bool loadLayoutFromFile(QString filename);
39  bool loadDataFromFiles(QStringList filenames);
40  bool loadDataFromFile(const FileLoadInfo& info);
41 
42 
43  void stopStreamingPlugin();
44  void startStreamingPlugin(QString streamer_name);
45 
46 public slots:
47 
48  void resizeEvent(QResizeEvent*);
49  // Undo - Redo
50  void onUndoableChange();
51  void onUndoInvoked();
52  void onRedoInvoked();
53 
54  // Actions in UI
55  void on_streamingToggled();
56 
57  void on_buttonStreamingPause_toggled(bool paused);
58 
60 
61  void on_comboStreaming_currentIndexChanged(const QString &current_text);
62 
63  void on_splitterMoved(int, int);
64 
65  void onTrackerTimeUpdated(double absolute_time, bool do_replot);
66  void onTrackerMovedFromWidget(QPointF pos);
67  void onTimeSlider_valueChanged(double abs_time);
68 
69  void onPlotAdded(PlotWidget* plot);
70 
71  void onPlotTabAdded(PlotDocker* docker);
72 
73  void onPlotZoomChanged(PlotWidget* modified_plot, QRectF new_range);
74 
75  void on_tabbedAreaDestroyed(QObject* object);
76 
77  void updateDataAndReplot(bool replot_hidden_tabs);
78 
80 
81  void onDeleteMultipleCurves(const std::vector<std::string>& curve_names);
82 
83  void onAddCustomPlot(const std::string& plot_name);
84 
85  void onEditCustomPlot(const std::string& plot_name);
86 
87  void onRefreshCustomPlot(const std::string& plot_name);
88 
90 
91  void onPlaybackLoop();
92 
93 private:
94  Ui::MainWindow* ui;
95 
97 
98  QShortcut _undo_shortcut;
99  QShortcut _redo_shortcut;
102  QShortcut _playback_shotcut;
103 
105 
107 
110 
111  std::map<QString, DataLoaderPtr> _data_loader;
112  std::map<QString, StatePublisherPtr> _state_publisher;
113  std::map<QString, DataStreamerPtr> _data_streamer;
114  std::map<QString, std::shared_ptr<MessageParserCreator>> _message_parser_factory;
115 
116  std::shared_ptr<DataStreamer> _active_streamer_plugin;
117 
118  std::deque<QDomDocument> _undo_states;
119  std::deque<QDomDocument> _redo_states;
120  QElapsedTimer _undo_timer;
122 
124 
126 
128 
129  std::vector<FileLoadInfo> _loaded_datafiles;
131 
132  std::map<CurveTracker::Parameter, QIcon> _tracker_button_icons;
133 
135 
136  QTimer* _replot_timer;
137  QTimer* _publish_timer;
138 
140 
142 
145 
147  {
151  };
152 
154 
157 
158 
159  void initializeActions();
160  QStringList initializePlugins(QString subdir_name);
161 
162  void forEachWidget(std::function<void(PlotWidget *, PlotDocker *, int)> op);
163  void forEachWidget(std::function<void(PlotWidget*)> op);
164 
165  void rearrangeGridLayout();
166 
167  QDomDocument xmlSaveState() const;
168  bool xmlLoadState(QDomDocument state_document);
169 
170  void checkAllCurvesFromLayout(const QDomElement& root);
171 
172  void importPlotDataMap(PlotDataMapRef& new_data, bool remove_old);
173 
174  bool isStreamingActive() const;
175 
176  void closeEvent(QCloseEvent* event);
177 
178  void loadPluginState(const QDomElement& root);
179  QDomElement savePluginState(QDomDocument& doc);
180 
181  std::tuple<double, double, int> calculateVisibleRangeX();
182 
183  void deleteAllData();
184 
185  void updateRecentDataMenu(QStringList new_filenames);
186  void updateRecentLayoutMenu(QStringList new_filenames);
187 
188  void updatedDisplayTime();
189 
190  void updateTimeSlider();
191  void updateTimeOffset();
192 
193  void buildDummyData();
194 
195  void loadStyleSheet(QString file_path);
196 
197 signals:
198  void dataSourceRemoved(const std::string& name);
199  void activateTracker(bool active);
200  void stylesheetChanged(QString style_name);
201 
202 public slots:
203 
206 
209 
211 
215 // TODO ? void on_actionSaveAllPlotTabs_triggered();
216 
219 
220  void on_pushButtonActivateGrid_toggled(bool checked);
221  void on_pushButtonRatio_toggled(bool checked);
222  void on_pushButtonPlay_toggled(bool checked);
223  void on_pushButtonUseDateTime_toggled(bool checked);
225  void on_pushButtonRemoveTimeOffset_toggled(bool checked);
226 
227 private slots:
228  void on_stylesheetChanged(QString style_name);
231  void on_playbackStep_valueChanged(double arg1);
235 
241 
247 };
248 
249 class PopupMenu : public QMenu
250 {
251  Q_OBJECT
252 public:
253  explicit PopupMenu(QWidget* relative_widget, QWidget* parent = nullptr);
254 
255  void showEvent(QShowEvent*) override;
256  void leaveEvent(QEvent*) override;
257  void closeEvent(QCloseEvent*) override;
258 private:
259  QWidget* _w;
260 };
261 
262 
263 #endif // MAINWINDOW_H
void on_actionExit_triggered()
void onRedoInvoked()
Definition: mainwindow.cpp:312
QTimer * _animated_streaming_timer
Definition: mainwindow.h:144
void on_actionClearBuffer_triggered()
void on_comboStreaming_currentIndexChanged(const QString &current_text)
void onActionFullscreenTriggered()
enum MQTTPropertyCodes value
QShortcut _streaming_shortcut
Definition: mainwindow.h:101
QTimer * _replot_timer
Definition: mainwindow.h:136
void on_actionSupportPlotJuggler_triggered()
Ui::MainWindow * ui
Definition: mainwindow.h:94
void dataSourceRemoved(const std::string &name)
void rearrangeGridLayout()
void on_pushButtonLoadDatafile_clicked()
void on_actionShare_the_love_triggered()
QShortcut _fullscreen_shortcut
Definition: mainwindow.h:100
void onEditCustomPlot(const std::string &plot_name)
void on_buttonStreamingStart_clicked()
void onPlotTabAdded(PlotDocker *docker)
Definition: mainwindow.cpp:784
void on_actionPreferences_triggered()
CurveListPanel * _curvelist_widget
Definition: mainwindow.h:106
void on_stylesheetChanged(QString style_name)
void updatedDisplayTime()
bool _test_option
Definition: mainwindow.h:123
std::vector< FileLoadInfo > _loaded_datafiles
Definition: mainwindow.h:129
void onCustomPlotCreated(CustomPlotPtr plot)
QTimer * _publish_timer
Definition: mainwindow.h:137
void deleteAllData()
void resizeEvent(QResizeEvent *)
Definition: mainwindow.cpp:718
bool loadDataFromFiles(QStringList filenames)
void checkAllCurvesFromLayout(const QDomElement &root)
Definition: mainwindow.cpp:817
PlotDataMapRef _mapped_plot_data
Definition: mainwindow.h:108
void closeEvent(QCloseEvent *event)
std::map< CurveTracker::Parameter, QIcon > _tracker_button_icons
Definition: mainwindow.h:132
bool xmlLoadState(QDomDocument state_document)
Definition: mainwindow.cpp:880
bool loadLayoutFromFile(QString filename)
void forEachWidget(std::function< void(PlotWidget *, PlotDocker *, int)> op)
void on_actionReportBug_triggered()
std::map< QString, std::shared_ptr< MessageParserCreator > > _message_parser_factory
Definition: mainwindow.h:114
void on_actionClearRecentLayout_triggered()
void on_actionCheatsheet_triggered()
void onTrackerMovedFromWidget(QPointF pos)
Definition: mainwindow.cpp:352
void on_pushButtonZoomOut_clicked()
QMovie * _animated_streaming_movie
Definition: mainwindow.h:143
void on_actionClearRecentData_triggered()
std::deque< QDomDocument > _redo_states
Definition: mainwindow.h:119
void onPlotAdded(PlotWidget *plot)
Definition: mainwindow.cpp:723
void updateDataAndReplot(bool replot_hidden_tabs)
void onTimeSlider_valueChanged(double abs_time)
Definition: mainwindow.cpp:363
QStringList initializePlugins(QString subdir_name)
Definition: mainwindow.cpp:415
std::map< QString, DataStreamerPtr > _data_streamer
Definition: mainwindow.h:113
void startStreamingPlugin(QString streamer_name)
MainWindow(const QCommandLineParser &commandline_parser, QWidget *parent=nullptr)
Definition: mainwindow.cpp:51
void initializeActions()
Definition: mainwindow.cpp:388
std::map< QString, StatePublisherPtr > _state_publisher
Definition: mainwindow.h:112
double _tracker_time
Definition: mainwindow.h:127
void on_pushButtonPlay_toggled(bool checked)
void buildDummyData()
Definition: mainwindow.cpp:630
void onPlotZoomChanged(PlotWidget *modified_plot, QRectF new_range)
Definition: mainwindow.cpp:761
QElapsedTimer _undo_timer
Definition: mainwindow.h:120
bool loadDataFromFile(const FileLoadInfo &info)
void on_pushButtonLegend_clicked()
void on_pushButtonLoadLayout_clicked()
void onTrackerTimeUpdated(double absolute_time, bool do_replot)
Definition: mainwindow.cpp:369
TabbedPlotWidget * _main_tabbed_widget
Definition: mainwindow.h:96
void updateRecentLayoutMenu(QStringList new_filenames)
QShortcut _playback_shotcut
Definition: mainwindow.h:102
void onPlaybackLoop()
void on_buttonHidePublishersFrame_clicked()
void loadPluginState(const QDomElement &root)
void loadStyleSheet(QString file_path)
std::shared_ptr< CustomFunction > CustomPlotPtr
void on_actionLoadStyleSheet_triggered()
void on_buttonHideFileFrame_clicked()
void on_tabbedAreaDestroyed(QObject *object)
LabelStatus _labels_status
Definition: mainwindow.h:153
QDateTime _prev_publish_time
Definition: mainwindow.h:139
CurveTracker::Parameter _tracker_param
Definition: mainwindow.h:130
void updateTimeSlider()
void on_pushButtonRatio_toggled(bool checked)
void on_streamingSpinBox_valueChanged(int value)
QMenu * _recent_data_files
Definition: mainwindow.h:155
void onUndoInvoked()
Definition: mainwindow.cpp:329
void stopStreamingPlugin()
void stylesheetChanged(QString style_name)
void onAddCustomPlot(const std::string &plot_name)
QDomElement savePluginState(QDomDocument &doc)
QShortcut _redo_shortcut
Definition: mainwindow.h:99
bool isStreamingActive() const
bool _minimized
Definition: mainwindow.h:104
void on_actionDeleteAllData_triggered()
void on_buttonRecentData_clicked()
const char * name
void on_buttonHideStreamingFrame_clicked()
CustomPlotMap _custom_plots
Definition: mainwindow.h:109
FunctionEditorWidget * _function_editor
Definition: mainwindow.h:141
void onDeleteMultipleCurves(const std::vector< std::string > &curve_names)
Definition: mainwindow.cpp:942
std::unordered_map< std::string, CustomPlotPtr > CustomPlotMap
bool _autostart_publishers
Definition: mainwindow.h:125
MonitoredValue _time_offset
Definition: mainwindow.h:134
void on_actionAbout_triggered()
std::deque< QDomDocument > _undo_states
Definition: mainwindow.h:118
std::map< QString, DataLoaderPtr > _data_loader
Definition: mainwindow.h:111
void on_buttonRecentLayout_clicked()
void on_streamingToggled()
std::shared_ptr< DataStreamer > _active_streamer_plugin
Definition: mainwindow.h:116
void on_pushButtonUseDateTime_toggled(bool checked)
void updateTimeOffset()
void onRefreshCustomPlot(const std::string &plot_name)
void on_buttonStreamingPause_toggled(bool paused)
QShortcut _undo_shortcut
Definition: mainwindow.h:98
void activateTracker(bool active)
QWidget * _w
Definition: mainwindow.h:259
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:121
void onUndoableChange()
Definition: mainwindow.cpp:291
QMenu * _recent_layout_files
Definition: mainwindow.h:156
QDomDocument xmlSaveState() const
Definition: mainwindow.cpp:793
void on_splitterMoved(int, int)
Definition: mainwindow.cpp:689
void on_pushButtonRemoveTimeOffset_toggled(bool checked)
void on_pushButtonSaveLayout_clicked()
void updateRecentDataMenu(QStringList new_filenames)
Definition: mainwindow.cpp:967
void onUpdateLeftTableValues()
Definition: mainwindow.cpp:347
std::tuple< double, double, int > calculateVisibleRangeX()


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:09