Go to the documentation of this file.00001 #ifndef MAINWINDOW_H
00002 #define MAINWINDOW_H
00003
00004 #include <set>
00005 #include <deque>
00006 #include <functional>
00007
00008 #include <QCommandLineParser>
00009 #include <QElapsedTimer>
00010 #include <QMainWindow>
00011 #include <QSignalMapper>
00012 #include <QShortcut>
00013
00014 #include "plotwidget.h"
00015 #include "plotmatrix.h"
00016 #include "curvelist_panel.h"
00017 #include "tabbedplotwidget.h"
00018 #include "subwindow.h"
00019 #include "realslider.h"
00020 #include "utils.h"
00021 #include "PlotJuggler/dataloader_base.h"
00022 #include "PlotJuggler/statepublisher_base.h"
00023 #include "PlotJuggler/datastreamer_base.h"
00024 #include "transforms/custom_function.h"
00025
00026 #include "ui_mainwindow.h"
00027
00028 class MainWindow : public QMainWindow
00029 {
00030 Q_OBJECT
00031
00032 public:
00033 explicit MainWindow(const QCommandLineParser& commandline_parser, QWidget *parent = nullptr);
00034
00035 ~MainWindow();
00036
00037 bool loadLayoutFromFile(QString filename);
00038 bool loadDataFromFiles(QStringList filenames );
00039 bool loadDataFromFile(const FileLoadInfo &info);
00040
00041 public slots:
00042
00043 void resizeEvent(QResizeEvent *) ;
00044
00045
00046 void onUndoableChange();
00047 void onUndoInvoked();
00048 void onRedoInvoked();
00049
00050
00051 void on_streamingToggled();
00052 void on_pushButtonStreaming_toggled(bool streaming);
00053 void on_streamingSpinBox_valueChanged(int value);
00054
00055 void on_splitterMoved(int, int);
00056
00057 void onTrackerTimeUpdated(double absolute_time , bool do_replot);
00058 void onTrackerMovedFromWidget(QPointF pos );
00059 void onTimeSlider_valueChanged(double abs_time);
00060
00061 void onPlotAdded(PlotWidget* plot);
00062 void onPlotMatrixAdded(PlotMatrix* matrix);
00063
00064 void on_tabbedAreaDestroyed(QObject*object);
00065
00066 void onFloatingWindowDestroyed(QObject*object);
00067
00068 void onCreateFloatingWindow(PlotMatrix* first_tab = nullptr);
00069
00070 void onSwapPlots(PlotWidget* source, PlotWidget* destination);
00071
00072 void updateDataAndReplot(bool replot_hidden_tabs);
00073
00074 void onUpdateLeftTableValues();
00075
00076 void onDeleteMultipleCurves(const std::vector<std::string> &curve_names);
00077
00078 void on_addMathPlot(const std::string &linked_name);
00079 void on_editMathPlot(const std::string &plot_name);
00080 void on_refreshMathPlot(const std::string &plot_name);
00081
00082 void onPlaybackLoop();
00083
00084 private:
00085
00086 Ui::MainWindow *ui;
00087
00088 TabbedPlotWidget *_main_tabbed_widget;
00089
00090 QShortcut _undo_shortcut;
00091 QShortcut _redo_shortcut;
00092 QShortcut _fullscreen_shortcut;
00093 QShortcut _streaming_shortcut;
00094 QShortcut _playback_shotcut;
00095
00096 bool _minimized;
00097
00098 CurveListPanel* _curvelist_widget;
00099
00100 PlotDataMapRef _mapped_plot_data;
00101 CustomPlotMap _custom_plots;
00102
00103 std::map<QString,DataLoader*> _data_loader;
00104 std::map<QString,StatePublisher*> _state_publisher;
00105 std::map<QString,DataStreamer*> _data_streamer;
00106 DataStreamer* _current_streamer;
00107
00108 std::deque<QDomDocument> _undo_states;
00109 std::deque<QDomDocument> _redo_states;
00110 QElapsedTimer _undo_timer;
00111 bool _disable_undo_logging;
00112
00113 bool _test_option;
00114
00115 bool _autostart_publishers;
00116
00117 double _tracker_time;
00118
00119 std::vector<FileLoadInfo> _loaded_datafiles;
00120 CurveTracker::Parameter _tracker_param;
00121
00122 std::map<CurveTracker::Parameter, QIcon> _tracker_button_icons;
00123
00124 MonitoredValue _time_offset;
00125
00126 QTimer *_replot_timer;
00127 QTimer *_publish_timer;
00128
00129 QDateTime _prev_publish_time;
00130
00131 void initializeActions();
00132 void initializePlugins(QString subdir_name);
00133
00134 void forEachWidget(std::function<void(PlotWidget*, PlotMatrix*, int, int)> op);
00135 void forEachWidget(std::function<void(PlotWidget*)> op);
00136
00137 void rearrangeGridLayout();
00138
00139 QDomDocument xmlSaveState() const;
00140 bool xmlLoadState(QDomDocument state_document);
00141
00142 void checkAllCurvesFromLayout(const QDomElement& root);
00143
00144 void createTabbedDialog(QString suggest_win_name, PlotMatrix *first_tab);
00145
00146 void importPlotDataMap(PlotDataMapRef &new_data, bool remove_old);
00147
00148 bool isStreamingActive() const ;
00149
00150 void closeEvent(QCloseEvent *event);
00151
00152 void loadPluginState(const QDomElement &root);
00153 QDomElement savePluginState(QDomDocument &doc);
00154
00155 std::tuple<double,double,int> calculateVisibleRangeX();
00156
00157 void addOrEditMathPlot(const std::string &name, bool edit);
00158
00159 void deleteAllData();
00160
00161 void updateRecentDataMenu(QStringList new_filenames);
00162 void updateRecentLayoutMenu(QStringList new_filenames);
00163
00164 void updatedDisplayTime();
00165
00166 void updateTimeSlider();
00167 void updateTimeOffset();
00168
00169 void buildDummyData();
00170
00171 signals:
00172 void requestRemoveCurveByName(const std::string& name);
00173 void activateStreamingMode( bool active);
00174 void activateTracker(bool active);
00175
00176 public slots:
00177 void on_actionLoadData_triggered();
00178 void on_actionLoadLayout_triggered();
00179 void on_actionSaveLayout_triggered();
00180 void on_actionLoadDummyData_triggered();
00181
00182 void on_actionFunctionEditor_triggered();
00183 void on_actionClearRecentData_triggered();
00184 void on_actionClearRecentLayout_triggered();
00185
00186 void on_actionDeleteAllData_triggered();
00187 void on_actionClearBuffer_triggered();
00188
00189 void on_actionFullscreen_triggered();
00190
00191 void on_actionReportBug_triggered();
00192 void on_actionCheatsheet_triggered();
00193 void on_actionSupportPlotJuggler_triggered();
00194 void on_actionSaveAllPlotTabs_triggered();
00195
00196 void on_actionStopStreaming_triggered();
00197 void on_actionAbout_triggered();
00198 void on_actionExit_triggered();
00199
00200 void on_pushButtonOptions_toggled(bool checked);
00201 void on_pushButtonActivateGrid_toggled(bool checked);
00202 void on_pushButtonRatio_toggled(bool checked);
00203 void on_pushButtonPlay_toggled(bool checked);
00204 void on_pushButtonUseDateTime_toggled(bool checked);
00205 void on_pushButtonTimeTracker_pressed();
00206 void on_pushButtonRemoveTimeOffset_toggled(bool checked);
00207
00208 void on_actionStartStreaming(QString streamer_name);
00209 };
00210
00211
00212
00213 #endif // MAINWINDOW_H