AGX Dynamics  2.37.3.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 #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 
103  void generateCurrentValue();
104 
108  size_t getNewValueMarker() const;
109 
113  const agx::RealVector& getAllValues() const;
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 
179  void setStatistic(agxUtil::Statistic* statistic);
180 
189  void setStatistic(agxUtil::StatisticHandleRef statistic);
190 
191 
196  const agxUtil::Statistic* getStatistic() const;
197 
198  // INTERNAL
203  bool isTime() const;
204  bool hasImportedJournalData() const;
205  bool hasDataPath() const;
206  agx::Uuid getEntityId() const;
207  void importedJournal();
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
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
Namespace contains functionality related to plotting.
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Base class providing referencing counted objects.
Definition: Referenced.h:119
Templated vector class.
Definition: Vector.h:52
uint32_t UInt
Definition: Integer.h:34
agx::Event representationChanged
Definition: DataSeries.h:211
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
Pure virtual statistic class containing the fundamentals for implementing a statistics method...
Definition: Statistic.h:36
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
uint16_t UInt16
Definition: Integer.h:39
double Real
Definition: Real.h:42
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
AGXCORE_EXPORT Component * root()
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
An event with no arguments.
Definition: Event.h:89