custom_function.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 #include <vector>
6 #include <QWidget>
7 #include <QString>
8 #include <QDomDocument>
9 #include <QString>
10 #include "PlotJuggler/plotdata.h"
12 
13 using namespace PJ;
14 
16 
17 typedef std::shared_ptr<CustomFunction> CustomPlotPtr;
18 
20 {
21  QString alias_name;
22  QString global_vars;
23  QString function;
24  QString linked_source;
25  QStringList additional_sources;
26 };
27 
28 typedef std::map<QString, SnippetData> SnippetsMap;
29 
30 SnippetData GetSnippetFromXML(const QDomElement& snippets_element);
31 
32 SnippetsMap GetSnippetsFromXML(const QString& xml_text);
33 
34 SnippetsMap GetSnippetsFromXML(const QDomElement& snippets_element);
35 
36 QDomElement ExportSnippetToXML(const SnippetData& snippet, QDomDocument& destination_doc);
37 
38 QDomElement ExportSnippets(const SnippetsMap& snippets, QDomDocument& destination_doc);
39 
41 {
42 public:
43  CustomFunction(SnippetData snippet = {});
44 
45  void setSnippet(const SnippetData& snippet);
46 
47  void reset() override;
48 
49  int numInputs() const override
50  {
51  return -1;
52  }
53 
54  int numOutputs() const override
55  {
56  return 1;
57  }
58 
59  QString aliasName() const
60  {
61  return _snippet.alias_name;
62  }
63 
64  void calculate() override;
65 
66  bool xmlSaveState(QDomDocument& doc, QDomElement& parent_element) const override;
67 
68  bool xmlLoadState(const QDomElement& parent_element) override;
69 
70  const SnippetData& snippet() const;
71 
72  virtual QString language() const = 0;
73 
74  virtual void initEngine() = 0;
75 
76  void calculateAndAdd(PlotDataMapRef& src_data);
77 
78  virtual void calculatePoints(const std::vector<const PlotData*>& src_data,
79  size_t point_index,
80  std::vector<PlotData::Point>& new_points) = 0;
81 
82 protected:
84  std::string _linked_plot_name;
85  std::string _plot_name;
86 
87  std::vector<std::string> _used_channels;
88 };
GetSnippetsFromXML
SnippetsMap GetSnippetsFromXML(const QString &xml_text)
Definition: custom_function.cpp:132
CustomFunction::_snippet
SnippetData _snippet
Definition: custom_function.h:83
CustomFunction::numOutputs
int numOutputs() const override
Definition: custom_function.h:54
SnippetData::linked_source
QString linked_source
Definition: custom_function.h:24
CustomFunction::numInputs
int numInputs() const override
Definition: custom_function.h:49
ExportSnippets
QDomElement ExportSnippets(const SnippetsMap &snippets, QDomDocument &destination_doc)
Definition: custom_function.cpp:171
SnippetData::additional_sources
QStringList additional_sources
Definition: custom_function.h:25
transform_function.h
CustomPlotPtr
std::shared_ptr< CustomFunction > CustomPlotPtr
Definition: custom_function.h:15
SnippetData::alias_name
QString alias_name
Definition: custom_function.h:21
CustomFunction::_linked_plot_name
std::string _linked_plot_name
Definition: custom_function.h:84
CustomFunction::_plot_name
std::string _plot_name
Definition: custom_function.h:85
PJ::TransformFunction
Generic interface for a multi input - multi output transformation function. Contrariwise to other plu...
Definition: transform_function.h:22
CustomFunction::_used_channels
std::vector< std::string > _used_channels
Definition: custom_function.h:87
plotdata.h
CustomFunction
Definition: custom_function.h:40
CustomFunction::aliasName
QString aliasName() const
Definition: custom_function.h:59
SnippetData::global_vars
QString global_vars
Definition: custom_function.h:22
backward::Color::reset
@ reset
Definition: backward.hpp:3678
SnippetData
Definition: custom_function.h:19
PJ
Definition: dataloader_base.h:16
SnippetsMap
std::map< QString, SnippetData > SnippetsMap
Definition: custom_function.h:28
PJ::PlotDataMapRef
Definition: plotdata.h:34
ExportSnippetToXML
QDomElement ExportSnippetToXML(const SnippetData &snippet, QDomDocument &destination_doc)
Definition: custom_function.cpp:208
GetSnippetFromXML
SnippetData GetSnippetFromXML(const QDomElement &snippets_element)
Definition: custom_function.cpp:184


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:43