AGX Dynamics  2.38.0.2
DataSeries.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 #pragma once
18 
19 #include <agxPlot/DataGenerator.h>
21 #include <agxPlot/Queue.h>
22 
23 #include <agx/Uuid.h>
24 #include <agx/agx_vector_types.h>
25 #include <agx/Event.h>
26 
27 #include <agxUtil/Statistic.h>
28 
29 #include <functional>
30 #include <memory>
31 
32 namespace agxSDK
33 {
34  class Simulation;
35 }
36 
37 namespace agxPlot
38 {
39 
45  {
46  public:
47  enum Settings
48  {
49  DATASERIES_SETTINGS_NONE = 0,
50  DATASERIES_SETTINGS_ISTIME = 1
51  };
52 
57  DataSeries(const agx::Uuid& entityId, const agx::String& dataPath, agxSDK::Simulation* simulation, const agx::String& name);
58 
62  DataSeries(std::function<double()> lambdaFunction, const agx::String& name);
63 
67  DataSeries(agxPlot::DataListener* listener, const agx::String& name);
68 
72  DataSeries(agxPlot::DataGenerator* dataGenerator, const agx::String& name);
73 
77  DataSeries(const agx::String& dataPath, agxSDK::Simulation* simulation, const agx::String& name);
78 
83 
91 
95  DataSeries(const agx::String& name = "");
96 
101  void push(agx::Real value);
102 
107  void generateCurrentValue();
108 
112  size_t getNewValueMarker() const;
113 
117  const agx::RealVector& getAllValues() const;
118 
122  void clearData();
123 
127  void resetDirty();
128 
132  void setName(const agx::String& name);
133 
137  const agx::String& getName() const;
138 
142  void setUnit(const agx::String& unit);
143 
147  const agx::String& getUnit() const;
148 
152  void setLogarithmic(bool isLogarithmic);
153 
154  bool getLogarithmic() const;
155 
159  void setSettings(agx::UInt16 settings);
160 
170  void getDescription(agxJson::Value& root) const;
174  void setFromDescription(const agxJson::Value& root);
175 
183  void setStatistic(agxUtil::Statistic* statistic);
184 
193  void setStatistic(agxUtil::StatisticHandleRef statistic);
194 
199  const agxUtil::Statistic* getStatistic() const;
200 
201  // INTERNAL
206  bool isTime() const;
207  bool hasImportedJournalData() const;
208  bool hasDataPath() const;
209  agx::Uuid getEntityId() const;
210  void importedJournal();
211  const agx::String& getDataPath() const;
212  agx::UInt getID() const;
213 
215 
216  protected:
217  virtual ~DataSeries();
218 
219  void init(DataGeneratorRef generator, const agx::String& name);
220 
221  private:
222  void addOutput(Queue* queue);
223  void setID(agx::UInt id);
224  bool isMultipleSource() const;
225  void pushSecondary(agx::Real value);
226  void sumValues();
227 
228  agx::RealVector m_values;
229  agx::RealVector m_secondaryValues;
230  agx::RealVector m_sumValues;
231  size_t m_currentSumIndex;
232 
233  agx::String m_name;
234  agx::String m_unit;
235  bool m_isLogarithmic;
236  bool m_journalDataImported;
237  agx::UInt16 m_settings;
238 
239  agx::UInt m_id;
240 
241  size_t m_currentIndex;
242 
243  DataGeneratorRef m_generator;
244  std::unique_ptr<agxUtil::Statistic> m_statistic;
245 
246  agx::Uuid m_entityId;
247  agx::String m_dataPath;
248 
249  QueueRef m_inputQueue;
250  QueueRef m_secondaryInputQueue;
251  agx::Vector<Queue*> m_outputQueues;
252  };
253 
256 
257 
262  {
263  public:
264  // Create a data series that makes a time lambda function connected to the selected simulation
266 
267  protected:
268  virtual ~TimeDataSeries();
269 
270  private:
271  agxSDK::Simulation* m_simulation;
272  };
273 
276 }
agx::UInt
uint64_t UInt
Definition: Integer.h:27
agx::Real
double Real
Definition: Real.h:42
Statistic.h
agx::Vector
Templated vector class.
Definition: Vector.h:52
agxPlot
Namespace contains functionality related to plotting.
agxPlot::DataSeries::representationChanged
agx::Event representationChanged
Definition: DataSeries.h:214
CallbackDataGenerator.h
agx::VectorPOD< Real >
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxPlot::Queue
Definition: Queue.h:29
agxPlot::DataGenerator
Abstract base class for creating data to be plotted.
Definition: DataGenerator.h:27
agxUtil::Statistic
Pure virtual statistic class containing the fundamentals for implementing a statistics method.
Definition: Statistic.h:36
AGX_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agx::UInt16
uint16_t UInt16
Definition: Integer.h:31
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:125
agxPlot::DataSeries::Settings
Settings
Definition: DataSeries.h:47
Queue.h
Event.h
agx::root
AGXCORE_EXPORT Component * root()
Uuid.h
agxPlot::DataSeries
Class that encapsulates data to be plotted, including methods for accessing the data,...
Definition: DataSeries.h:44
DataGenerator.h
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agx::AgXString< std::string >
agxPlot::DataListener
Event listener that will generate plotting data.
Definition: CallbackDataGenerator.h:28
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agx::init
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.
agx::Uuid
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
agxPlot::TimeDataSeries
Class for generating a data serie containg simulation time.
Definition: DataSeries.h:261
agx::Event
An event with no arguments.
Definition: Event.h:89
agx_vector_types.h