custom_function.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 #include <QWidget>
6 #include <QString>
7 #include <QDomDocument>
8 #include <QString>
9 #include <QJSEngine>
10 #include "PlotJuggler/plotdata.h"
11 
12 class CustomFunction;
13 class QJSEngine;
14 typedef std::shared_ptr<CustomFunction> CustomPlotPtr;
15 typedef std::unordered_map<std::string, CustomPlotPtr> CustomPlotMap;
16 
17 struct SnippetData{
18  QString name;
19  QString globalVars;
20  QString equation;
21 };
22 
23 typedef std::map<QString, SnippetData> SnippetsMap;
24 
25 SnippetsMap GetSnippetsFromXML(const QString& xml_text);
26 
27 SnippetsMap GetSnippetsFromXML(const QDomElement& snippets_element);
28 
29 QDomElement ExportSnippets(const SnippetsMap& snippets,
30  QDomDocument& destination_doc);
31 
33 {
34 public:
35  CustomFunction(const std::string &linkedPlot,
36  const std::string &plotName,
37  const QString &globalVars,
38  const QString &function);
39 
40  CustomFunction(const std::string &linkedPlot,
41  const SnippetData &snippet);
42 
43  void calculateAndAdd(PlotDataMapRef &plotData);
44 
45  void calculate(const PlotDataMapRef &plotData, PlotData *dst_data);
46 
47  const std::string& name() const;
48 
49  const std::string& linkedPlotName() const;
50 
51  const QString& globalVars() const;
52 
53  const QString& function() const;
54 
55  QDomElement xmlSaveState(QDomDocument &doc) const;
56 
57  static CustomPlotPtr createFromXML(QDomElement &element );
58 
59  static QStringList getChannelsFromFuntion(const QString& function);
60 
61 private:
62  void initJsEngine();
63 
64  PlotData::Point calculatePoint(QJSValue &calcFct,
65  const PlotData &src_data,
66  const std::vector<const PlotData *> &channels_data,
67  QJSValue &chan_values,
68  size_t point_index);
69 
70  const std::string _linked_plot_name;
71  const std::string _plot_name;
72  const QString _global_vars;
73  const QString _function;
75  std::vector<std::string> _used_channels;
76 
77  std::unique_ptr<QJSEngine> _jsEngine;
79 };
80 
81 
82 
const QString _function
std::vector< std::string > _used_channels
QString globalVars
std::map< QString, SnippetData > SnippetsMap
const QString _global_vars
QString equation
std::unique_ptr< QJSEngine > _jsEngine
const std::string _plot_name
std::shared_ptr< CustomFunction > CustomPlotPtr
double _last_updated_timestamp
QString _function_replaced
std::unordered_map< std::string, CustomPlotPtr > CustomPlotMap
const std::string _linked_plot_name
SnippetsMap GetSnippetsFromXML(const QString &xml_text)
QDomElement ExportSnippets(const SnippetsMap &snippets, QDomDocument &destination_doc)


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17