Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
CTendencyCurve.hpp
Go to the documentation of this file.
1#ifndef LIBS_DIAGRAMS_CTENDENCYCURVE_HPP_
2#define LIBS_DIAGRAMS_CTENDENCYCURVE_HPP_
3
4#include "core/Timestamp.hpp"
5#include "math/CMath.hpp"
7
8#include <bits/stdint-uintn.h>
9#include <memory>
10#include <string>
11
12class AbstractLog;
13class IGraphics;
14
16{
17 Analog,
19};
20
22{
23 STendencyPoint() = default;
25 {
26 m_time = time;
27 m_value = value;
28 }
29 ~STendencyPoint() = default;
30
31#pragma GCC diagnostic push
32#pragma GCC diagnostic ignored "-Wfloat-equal"
33 bool operator==(const STendencyPoint &b) const
34 {
35 return ((m_time == b.m_time) && (m_value == b.m_value));
36 }
37#pragma GCC diagnostic pop
39 double m_value;
40};
41
43{
45
46 STendencyChannelData(const iv::time::Timestamp &initInterval, const iv::time::Timestamp &endInterval, double yMin,
47 double yMax, uint64_t step)
48 {
49 m_tendencyCurve = std::make_shared<std::vector<STendencyPoint>>();
50 m_initInterval = initInterval;
51 m_endInterval = endInterval;
52 m_yMin = yMin;
53 m_yMax = yMax;
54 m_step = step;
55 }
56
59
61
62 std::shared_ptr<std::vector<STendencyPoint>> m_tendencyCurve;
65 double m_yMin;
66 double m_yMax;
67 uint64_t m_step;
68};
69
71{
72public:
73 CTendencyCurve() = delete;
74 CTendencyCurve(const CTendencyCurve &other) = delete;
75 CTendencyCurve(CTendencyCurve &&other) = delete;
76 static std::shared_ptr<CTendencyCurve>
77 createTendencyCurveAnalog(std::string_view tagChannel, std::string_view descriptionChannel,
78 const iv::time::Timestamp &initInterval, const iv::time::Timestamp &endInterval,
79 uint64_t step, double yMin, double yMax, double multiplier, uint16_t numDecimalsY,
80 std::string_view strUnit, bool isDigital = false);
81 static std::shared_ptr<CTendencyCurve> createTendencyCurveDigital(std::string_view tagChannel,
82 std::string_view descriptionChannel,
83 const iv::time::Timestamp &initInterval,
84 const iv::time::Timestamp &endInterval,
85 uint64_t step, bool isDigital = true);
87
88 CTendencyCurve &operator=(const CTendencyCurve &other) = delete;
90 bool operator==(const CTendencyCurve &b) const;
91
92 void addPoint(iv::types::timestamp timeSeconds, double value) const;
93 void drawAxis(IGraphics *graphics, bool withAxisX, bool withAxisY, bool withVerticalGrid, bool withHorizontalGrid,
94 iv::types::height textHeight, iv::types::color colorRGBAxisY, uint64_t indCurve, bool multipleCurves,
95 bool isPrinting = false) const;
96 void drawAxisReference(double valueX, IGraphics *graphics, double maxY, double minY, bool multipleCurves) const;
97
98 void sortPoints() const;
99
100 [[nodiscard]] std::shared_ptr<std::vector<std::shared_ptr<std::vector<iv::math::geometry::Point2d>>>>
101 generatePlotLines() const;
102 void printValues(AbstractLog *logger) const;
103 std::string strValue(double valueX, double valueY, unsigned char *justify) const;
104 std::vector<std::string> strClickedTime(double clickedPointX) const;
105 void writeClickedTime(IGraphics *graphics, double maxY, double minY, double clickedTime, unsigned char justify,
106 bool multipleCurves, double sizeHeight) const;
107 double moveValuePositionX(double actualPositionX, double percentage) const;
108
109 [[nodiscard]] iv::time::Timestamp getStartTime() const;
110 [[nodiscard]] iv::time::Timestamp getEndTime() const;
111 [[nodiscard]] std::string getDescriptionChannel() const;
112 [[nodiscard]] std::string getStrUnit() const;
113 [[nodiscard]] double getMinY() const;
114 [[nodiscard]] double getMaxY() const;
115 [[nodiscard]] ETendencyCurveType getCurveType() const;
116
117private:
118 static std::shared_ptr<std::vector<std::shared_ptr<std::vector<iv::math::geometry::Point2d>>>>
119 prvGenerateSegmentLines(const std::shared_ptr<std::vector<STendencyPoint>> &tendencyPoints,
120 iv::types::timestamp startTime, iv::types::timestamp endTime, double yMin, double yMax);
121
122 CTendencyCurve(ETendencyCurveType typeTendencyCurve, std::string_view tagChannel,
123 std::string_view descriptionChannel, STendencyChannelData **tendencyChannelData, double yMin,
124 double yMax, double multiplier, uint16_t numDecimalsY, std::string_view strUnit, bool isDigital);
125
127 std::string m_tagChannel;
130
136 std::string m_strUnit;
137
146};
147
148#endif /* LIBS_DIAGRAMS_CTENDENCYCURVE_HPP_ */
ETendencyCurveType
Definition CTendencyCurve.hpp:16
Definition AbstractLog.hpp:9
Definition CTendencyCurve.hpp:71
std::string m_tagChannel
Definition CTendencyCurve.hpp:127
std::string getStrUnit() const
Definition CTendencyCurve.cpp:359
std::string strValue(double valueX, double valueY, unsigned char *justify) const
Definition CTendencyCurve.cpp:241
std::string m_descriptionChannel
Definition CTendencyCurve.hpp:128
uint16_t m_numDecimalsY
Definition CTendencyCurve.hpp:134
void drawAxis(IGraphics *graphics, bool withAxisX, bool withAxisY, bool withVerticalGrid, bool withHorizontalGrid, iv::types::height textHeight, iv::types::color colorRGBAxisY, uint64_t indCurve, bool multipleCurves, bool isPrinting=false) const
Definition CTendencyCurve.cpp:93
bool m_isDigital
Definition CTendencyCurve.hpp:135
double m_yMaxAnalog
Definition CTendencyCurve.hpp:132
static std::shared_ptr< CTendencyCurve > createTendencyCurveAnalog(std::string_view tagChannel, std::string_view descriptionChannel, const iv::time::Timestamp &initInterval, const iv::time::Timestamp &endInterval, uint64_t step, double yMin, double yMax, double multiplier, uint16_t numDecimalsY, std::string_view strUnit, bool isDigital=false)
Definition CTendencyCurve.cpp:13
CTendencyCurve(CTendencyCurve &&other)=delete
void sortPoints() const
Definition CTendencyCurve.cpp:176
void printValues(AbstractLog *logger) const
Definition CTendencyCurve.cpp:230
void addPoint(iv::types::timestamp timeSeconds, double value) const
Definition CTendencyCurve.cpp:55
void drawAxisReference(double valueX, IGraphics *graphics, double maxY, double minY, bool multipleCurves) const
Definition CTendencyCurve.cpp:159
double moveValuePositionX(double actualPositionX, double percentage) const
Definition CTendencyCurve.cpp:334
static std::shared_ptr< CTendencyCurve > createTendencyCurveDigital(std::string_view tagChannel, std::string_view descriptionChannel, const iv::time::Timestamp &initInterval, const iv::time::Timestamp &endInterval, uint64_t step, bool isDigital=true)
Definition CTendencyCurve.cpp:27
double m_yMinAnalog
Definition CTendencyCurve.hpp:131
ETendencyCurveType getCurveType() const
Definition CTendencyCurve.cpp:374
CTendencyCurve & operator=(const CTendencyCurve &other)=delete
iv::time::Timestamp getStartTime() const
Definition CTendencyCurve.cpp:344
ETendencyCurveType m_typeTendencyCurve
Definition CTendencyCurve.hpp:126
CTendencyCurve()=delete
CTendencyCurve & operator=(CTendencyCurve &&other)=delete
iv::time::Timestamp getEndTime() const
Definition CTendencyCurve.cpp:349
double m_multiplier
Definition CTendencyCurve.hpp:133
std::shared_ptr< std::vector< std::shared_ptr< std::vector< iv::math::geometry::Point2d > > > > generatePlotLines() const
Definition CTendencyCurve.cpp:203
std::string getDescriptionChannel() const
Definition CTendencyCurve.cpp:354
std::string m_strUnit
Definition CTendencyCurve.hpp:136
double getMaxY() const
Definition CTendencyCurve.cpp:369
bool operator==(const CTendencyCurve &b) const
Definition CTendencyCurve.cpp:47
double getMinY() const
Definition CTendencyCurve.cpp:364
void writeClickedTime(IGraphics *graphics, double maxY, double minY, double clickedTime, unsigned char justify, bool multipleCurves, double sizeHeight) const
Definition CTendencyCurve.cpp:287
static std::shared_ptr< std::vector< std::shared_ptr< std::vector< iv::math::geometry::Point2d > > > > prvGenerateSegmentLines(const std::shared_ptr< std::vector< STendencyPoint > > &tendencyPoints, iv::types::timestamp startTime, iv::types::timestamp endTime, double yMin, double yMax)
Definition CTendencyCurve.cpp:380
~CTendencyCurve()
Definition CTendencyCurve.cpp:41
std::vector< std::string > strClickedTime(double clickedPointX) const
Definition CTendencyCurve.cpp:273
CTendencyCurve(const CTendencyCurve &other)=delete
STendencyChannelData * m_tendencyChannelData
Definition CTendencyCurve.hpp:129
Definition IGraphics.hpp:20
Definition Timestamp.hpp:17
static constexpr iv::types::timestamp MillisecondsInSeconds
Definition constants.hpp:35
uint64_t timestamp
Definition types.hpp:21
double height
Definition types.hpp:14
uint32_t color
Definition types.hpp:12
double coord
Definition types.hpp:13
Definition CTendencyCurve.hpp:139
static constexpr iv::types::coord textPrintingVerticalSeparation
Definition CTendencyCurve.hpp:143
static constexpr iv::types::height textSize
Definition CTendencyCurve.hpp:141
static constexpr iv::types::coord textVerticalSeparation
Definition CTendencyCurve.hpp:142
static constexpr iv::types::coord numberSeparation
Definition CTendencyCurve.hpp:144
static constexpr iv::types::timestamp maxTimeBetweenPoints
Definition CTendencyCurve.hpp:140
Definition CTendencyCurve.hpp:43
double m_yMax
Definition CTendencyCurve.hpp:66
STendencyChannelData()=delete
uint64_t m_step
Definition CTendencyCurve.hpp:67
STendencyChannelData(const iv::time::Timestamp &initInterval, const iv::time::Timestamp &endInterval, double yMin, double yMax, uint64_t step)
Definition CTendencyCurve.hpp:46
double m_yMin
Definition CTendencyCurve.hpp:65
~STendencyChannelData()=default
STendencyChannelData(STendencyChannelData &&)=delete
iv::time::Timestamp m_endInterval
Definition CTendencyCurve.hpp:64
std::shared_ptr< std::vector< STendencyPoint > > m_tendencyCurve
Definition CTendencyCurve.hpp:62
STendencyChannelData(const STendencyChannelData &)=delete
iv::time::Timestamp m_initInterval
Definition CTendencyCurve.hpp:63
Definition CTendencyCurve.hpp:22
STendencyPoint(iv::types::timestamp time, double value)
Definition CTendencyCurve.hpp:24
iv::types::timestamp m_time
Definition CTendencyCurve.hpp:38
~STendencyPoint()=default
bool operator==(const STendencyPoint &b) const
Definition CTendencyCurve.hpp:33
STendencyPoint()=default
double m_value
Definition CTendencyCurve.hpp:39