AGX Dynamics  2.35.0.1
DataSeries.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXPLOT_DATASERIES_H
18 #define AGXPLOT_DATASERIES_H
19 
20 #include <agxPlot/DataGenerator.h>
22 #include <agxPlot/Queue.h>
23 
24 #include <agx/Uuid.h>
25 #include <agx/agx_vector_types.h>
26 #include <agx/Event.h>
27 
28 #include <agxUtil/Statistic.h>
29 
30 #include <functional>
31 #include <memory>
32 
33 namespace agxSDK
34 {
35  class Simulation;
36 }
37 
38 namespace agxPlot
39 {
41  {
42  public:
43  enum Settings
44  {
45  DATASERIES_SETTINGS_NONE = 0,
46  DATASERIES_SETTINGS_ISTIME = 1
47  };
48 
53  DataSeries(const agx::Uuid& entityId, const agx::String& dataPath, agxSDK::Simulation* simulation, const agx::String& name);
54 
58  DataSeries(std::function<double()> lambdaFunction, const agx::String& name);
59 
63  DataSeries(agxPlot::DataListener* listener, const agx::String& name);
64 
68  DataSeries(agxPlot::DataGenerator* dataGenerator, const agx::String& name);
69 
73  DataSeries(const agx::String& dataPath, agxSDK::Simulation* simulation, const agx::String& name);
74 
79 
87 
91  DataSeries(const agx::String& name = "");
92 
97  void push(agx::Real value);
98 
104 
108  size_t getNewValueMarker() const;
109 
114 
118  void clearData();
119 
123  void resetDirty();
124 
128  void setName(const agx::String& name);
129 
133  const agx::String& getName() const;
134 
138  void setUnit(const agx::String& unit);
139 
143  const agx::String& getUnit() const;
144 
148  void setLogarithmic(bool isLogarithmic);
149 
150  bool getLogarithmic() const;
151 
155  void setSettings(agx::UInt16 settings);
156 
166  void getDescription(agxJson::Value& root) const;
170  void setFromDescription(const agxJson::Value& root);
171 
180 
190 
191 
197 
198  // INTERNAL
203  bool isTime() const;
205  bool hasDataPath() const;
208  const agx::String& getDataPath() const;
209  agx::UInt getID() const;
210 
212 
213  protected:
214  virtual ~DataSeries();
215 
216  void init(DataGeneratorRef generator, const agx::String& name);
217 
218  private:
219  void addOutput(Queue* queue);
220  void setID(agx::UInt id);
221  bool isMultipleSource() const;
222  void pushSecondary(agx::Real value);
223  void sumValues();
224 
225  agx::RealVector m_values;
226  agx::RealVector m_secondaryValues;
227  agx::RealVector m_sumValues;
228  size_t m_currentSumIndex;
229 
230  agx::String m_name;
231  agx::String m_unit;
232  bool m_isLogarithmic;
233  bool m_journalDataImported;
234  agx::UInt16 m_settings;
235 
236  agx::UInt m_id;
237 
238  size_t m_currentIndex;
239 
240  DataGeneratorRef m_generator;
241  std::unique_ptr<agxUtil::Statistic> m_statistic;
242 
243  agx::Uuid m_entityId;
244  agx::String m_dataPath;
245 
246  QueueRef m_inputQueue;
247  QueueRef m_secondaryInputQueue;
248  agx::Vector<Queue*> m_outputQueues;
249  };
250 
253 
255  {
256  public:
257  // Create a data series that makes a time lambda function connected to the selected simulation
259 
260  protected:
261  virtual ~TimeDataSeries();
262 
263  private:
264  agxSDK::Simulation* m_simulation;
265  };
266 
269 }
270 
271 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
DataSeries(agxPlot::DataSeries *sourceA, agxPlot::DataSeries *sourceB)
Create a DataSeries that gets fed by two sources and adding their data.
DataSeries(const agx::Uuid &entityId, const agx::String &dataPath, agxSDK::Simulation *simulation, const agx::String &name)
Create a DataSeries that takes fields from the rigidBody specified by the entity ID.
bool hasImportedJournalData() const
const agx::String & getName() const
Get the name of the data series.
agx::Event representationChanged
Definition: DataSeries.h:211
void setFromDescription(const agxJson::Value &root)
Set from a description of the format from getDescription.
void init(DataGeneratorRef generator, const agx::String &name)
DataSeries(agxPlot::DataGenerator *dataGenerator, const agx::String &name)
Create a DataSeries that calls getValue on the given DataGenerator to generate data.
DataSeries(agxPlot::DataSeries *source)
Create a DataSeries that gets fed by the source specified.
void setUnit(const agx::String &unit)
Set a string representing the unit of the data series.
void setName(const agx::String &name)
Set the name of the data series.
const agx::RealVector & getAllValues() const
Get all values that have been generated so far.
size_t getNewValueMarker() const
Get the index of the oldest new value.
DataSeries(agxPlot::DataListener *listener, const agx::String &name)
Create a DataSeries that calls the getValue operator of the DataListener to generate data.
agx::Uuid getEntityId() const
void setLogarithmic(bool isLogarithmic)
Should the axis be logarithmic if displayed.
void setStatistic(agxUtil::StatisticHandleRef statistic)
Pass data read from the data generator through the given statistic before adding it to the data serie...
void getDescription(agxJson::Value &root) const
Get the description of the following format.
void setSettings(agx::UInt16 settings)
Set special settings for the data series.
void resetDirty()
All current values are now observed and dirty flags can be cleaned up.
void generateCurrentValue()
Fetches the current value from the specified way of generation and append it to the series.
DataSeries(const agx::String &dataPath, agxSDK::Simulation *simulation, const agx::String &name)
Create a DataSeries that calls the getValue operator of the DataListener to generate data.
bool getLogarithmic() const
const agx::String & getUnit() const
Get the unit of the data series.
DataSeries(std::function< double()> lambdaFunction, const agx::String &name)
Create a DataSeries that calls the specified function to generate data.
bool hasDataPath() const
void push(agx::Real value)
Manually add a value at the end of the DataSeries.
void setStatistic(agxUtil::Statistic *statistic)
Pass data read from the data generator through the given statistic before adding it to the data serie...
const agx::String & getDataPath() const
bool isTime() const
Time works different, thus the time data series have this flag.
DataSeries(const agx::String &name="")
Create a DataSeries that can only get values by manually pushing them.
void clearData()
Remove all values in stored.
agx::UInt getID() const
const agxUtil::Statistic * getStatistic() const
Return the statistic, if any, through which data from generator is passed before being added to the d...
TimeDataSeries(agxSDK::Simulation *)
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
Pure virtual statistic class containing the fundamentals for implementing a statistics method.
Definition: Statistic.h:37
An event with no arguments.
Definition: Event.h:90
Base class providing referencing counted objects.
Definition: Referenced.h:114
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:42
Templated vector class.
Definition: agx/Vector.h:53
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
Namespace contains functionality related to plotting.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
uint16_t UInt16
Definition: Integer.h:39
AGXCORE_EXPORT Component * root()
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42