-
Notifications
You must be signed in to change notification settings - Fork 0
/
bsdrawgraph.h
125 lines (110 loc) · 5.52 KB
/
bsdrawgraph.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef DRAWCOREGRAPH_H
#define DRAWCOREGRAPH_H
/// DrawGraph is a graph for standart 1D functions
/// Input: 1D array
/// Scaling: vertical scaling is 1 by default, so You can easily resize Draw
///
/// Example:
/// #include "bsdrawgraph.h"
/// #include "palettes/bspalettes_std.h"
///
/// DrawGraph* draw = new DrawGraph(SAMPLES, PORTIONS, graphopts_t::goInterp());
/// draw->setDataPalette(&paletteBkGrWh);
/// ...
/// draw->setData(some_float_data);
///
/// Created By: Elijah Vlasov
#include "core/bsqdraw.h"
#include "core/bsgraphopts.h"
/// 2D graph
class DrawGraph: public DrawQWidget
{
Q_OBJECT
protected:
DrawGraph(unsigned int samples, unsigned int graphs, unsigned int memForDeploy, const graphopts_t& graphopts, const coloropts_t& coloropts, SPLITPORTIONS splitGraphs=SP_NONE);
void reConstructor(unsigned int samples);
public:
DrawGraph(unsigned int samples, unsigned int graphs=1, const coloropts_t& copts=coloropts_t::copts(), SPLITPORTIONS splitGraphs=SP_NONE);
DrawGraph(unsigned int samples, unsigned int graphs, const graphopts_t& graphopts, const coloropts_t& copts=coloropts_t::copts(), SPLITPORTIONS splitGraphs=SP_NONE);
const graphopts_t& graphopts() const;
const coloropts_t& coloropts() const;
void setOpts(const graphopts_t& go);
void setOpts(const coloropts_t& co);
void setOpts(const graphopts_t& go, const coloropts_t& co);
public:
virtual void sizeAndScaleHint(int sizeA, int sizeB, unsigned int* matrixDimmA, unsigned int* matrixDimmB, unsigned int* scalingA, unsigned int* scalingB) const;
};
/// 2D graph dynamic portion size: Check portionSize() before each call setData
class DrawGraphUpsizeA: public DrawGraph
{
Q_OBJECT
unsigned int m_minsamples;
unsigned int m_maxsamples;
void reConstructorEx(unsigned int samples);
public:
DrawGraphUpsizeA(unsigned int minsamples, unsigned int maxsamples, unsigned int graphs=1, const coloropts_t& copts=coloropts_t::copts(), SPLITPORTIONS splitGraphs=SP_NONE);
DrawGraphUpsizeA(unsigned int minsamples, unsigned int maxsamples, unsigned int graphs, const graphopts_t& graphopts, const coloropts_t& copts=coloropts_t::copts(), SPLITPORTIONS splitGraphs=SP_NONE);
public:
virtual void sizeAndScaleHint(int sizeA, int sizeB, unsigned int* matrixDimmA, unsigned int* matrixDimmB, unsigned int* scalingA, unsigned int* scalingB) const;
virtual int sizeAndScaleChanged(bool changedDimmA, bool changedDimmB, bool changedScalingA, bool changedScalingB);
signals:
void sig_portionDimmChanged();
};
/// 2D graph with data append
class DrawGraphMove: public DrawGraph
{
private:
unsigned int m_stepSamples;
public:
DrawGraphMove(unsigned int samples, unsigned int stepsamples, unsigned int graphs=1, coloropts_t copts=coloropts_t::copts(), SPLITPORTIONS splitGraphs=SP_NONE);
DrawGraphMove(unsigned int samples, unsigned int stepsamples, unsigned int graphs, const graphopts_t& graphopts, coloropts_t copts=coloropts_t::copts(), SPLITPORTIONS splitGraphs=SP_NONE);
public:
virtual void setData(const float* data);
virtual void setData(const float* data, DataDecimator* dcim);
};
/// 2D graph with saved data for ScrollBar connecting
class DrawGraphMoveEx: public DrawGraph
{
Q_OBJECT
private:
unsigned int m_stepSamples;
int m_filloffset;
MemExpand1D m_memory;
bool m_resizeExpanding;
public:
DrawGraphMoveEx(unsigned int samples, unsigned int stepsamples, unsigned int extmemory=0, unsigned int graphs=1, coloropts_t copts=coloropts_t::copts(), bool resizeExpanding=true, SPLITPORTIONS splitGraphs=SP_NONE);
DrawGraphMoveEx(unsigned int samples, unsigned int stepsamples, unsigned int extmemory, unsigned int graphs, const graphopts_t& graphopts, coloropts_t copts=coloropts_t::copts(), bool resizeExpanding=true, SPLITPORTIONS splitGraphs=SP_NONE);
// void rescaleA(int v);
unsigned int stepSamples() const { return m_stepSamples; }
unsigned int memfloatsFilled() const { return m_memory.filled(); } // in floats
unsigned int memfloatsNonfilled() const { return m_memory.nonfilled(); } // in floats
unsigned int memfloatsTotal() const { return m_memory.total(); } // in floats
int memFillOffset() const { return m_filloffset; } // in floats
void viewDiap(unsigned int* from, unsigned int* to);
void memoryPreClear() { m_memory.onClearData(); m_filloffset = 0; }
void memoryRangeSize(int mem);
void memoryAnchor(bool v){ m_memory.setAnchoring(v); }
float* getMemfloats() { return m_memory.rawData(); }
void setMemfloatsUpdate();
public:
virtual void setData(const float* data);
virtual void setData(const float* data, DataDecimator* dcim);
virtual void clearData();
virtual void appendData(const float* data, unsigned int length);
virtual void resetData(const float* data, unsigned int length);
public:
public:
virtual void sizeAndScaleHint(int sizeA, int sizeB, unsigned int* matrixDimmA, unsigned int* matrixDimmB, unsigned int* scalingA, unsigned int* scalingB) const;
protected:
virtual int sizeAndScaleChanged(bool changedDimmA, bool changedDimmB, bool changedScalingA, bool changedScalingB);
protected:
void fillMatrix();
void clampFilloffset();
public:
virtual int scrollValue() const;
public slots:
virtual void scrollDataTo(int);
virtual void scrollDataToAbs(int);
virtual void scrollRelativeTo(int);
};
#endif // DRAWCOREGRAPH_H