00001 #ifndef AddCustomPlotDialog_H 00002 #define AddCustomPlotDialog_H 00003 00004 #include <QDialog> 00005 #include <QListWidgetItem> 00006 #include <unordered_map> 00007 #include "PlotJuggler/plotdata.h" 00008 #include "custom_function.h" 00009 #include "qwt_plot_curve.h" 00010 #include "ui_function_editor.h" 00011 00012 00013 class AddCustomPlotDialog : public QDialog 00014 { 00015 Q_OBJECT 00016 00017 public: 00018 explicit AddCustomPlotDialog(PlotDataMapRef &plotMapData, 00019 const CustomPlotMap& mapped_custom_plots, 00020 QWidget *parent); 00021 virtual ~AddCustomPlotDialog() override; 00022 00023 void setLinkedPlotName(const QString &linkedPlotName); 00024 00025 enum EditorMode{ 00026 FUNCTION_OR_TIMESERIES, 00027 TIMESERIES_ONLY, 00028 FUNCTION_ONLY 00029 }; 00030 00031 void setEditorMode(EditorMode mode); 00032 00033 QString getLinkedData() const; 00034 QString getGlobalVars() const; 00035 QString getEquation() const; 00036 QString getName() const; 00037 const PlotData& getPlotData() const; 00038 void editExistingPlot(CustomPlotPtr data); 00039 CustomPlotPtr getCustomPlotData() const; 00040 00041 private slots: 00042 00043 void on_curvesListWidget_doubleClicked(const QModelIndex &index); 00044 00045 void on_snippetsListSaved_currentRowChanged(int currentRow); 00046 00047 void on_snippetsListSaved_doubleClicked(const QModelIndex &index); 00048 00049 void on_snippetsListRecent_currentRowChanged(int currentRow); 00050 00051 void on_snippetsListRecent_doubleClicked(const QModelIndex &index); 00052 00053 void on_nameLineEdit_textChanged(const QString &arg1); 00054 00055 void recentContextMenu(const QPoint &pos); 00056 00057 void savedContextMenu(const QPoint &pos); 00058 00059 void on_buttonLoadFunctions_clicked(); 00060 00061 void on_buttonSaveFunctions_clicked(); 00062 00063 void on_pushButtonSave_clicked(); 00064 00065 void onRenameSaved(); 00066 00067 void on_pushButtonCreate_clicked(); 00068 00069 void on_lineEditFilter_textChanged(const QString &arg1); 00070 00071 private: 00072 void importSnippets(const QByteArray &xml_text); 00073 00074 QByteArray exportSnippets() const; 00075 00076 bool addToSaved(const QString& name, const SnippetData &snippet); 00077 00078 PlotDataMapRef &_plot_map_data; 00079 const CustomPlotMap &_custom_plots; 00080 Ui::FunctionEditor *ui; 00081 00082 CustomPlotPtr _plot; 00083 bool _is_new; 00084 int _v_count; 00085 00086 SnippetsMap _snipped_saved; 00087 SnippetsMap _snipped_recent; 00088 }; 00089 00090 #endif // AddCustomPlotDialog_H