Stacked Graphs
Geometry & Aesthetics
 All Classes Functions Variables Enumerations
dataset.h
1 #ifndef DATASET_H
2 #define DATASET_H
3 
4 #include <QObject>
5 
9 struct LayoutInfo
10 {
11  QPainterPath path;
12  QBrush brush;
13 };
14 
15 
16 typedef float t_entry;
17 typedef QVector<t_entry> EntryVector;
18 
23 struct DataItem
24 {
28  QString label;
32  EntryVector data;
36  QColor color;
44  QPointF labelPos;
45 
49  int onsetTime;
53  int lastTime;
57  t_entry volatility;
61  t_entry sum;
65  t_entry max;
69  int maxIdx;
73  int idx;
74 };
75 
76 
77 typedef QList<DataItem> DataList;
78 typedef QList<DataItem*> DataPtrList;
79 typedef QList<DataItem*>& DataPtrListRef;
80 typedef DataList& DataListRef;
81 
85 struct DataSet
86 {
87 public:
88 
92  DataListRef getData() {return mData;}
93 
98  DataPtrListRef getSortedData() {return mSortedData;}
99 
103  QVector<float>& getCumHeight() { return mCumHeight; }
104 
108  int getSizeX() const {return mSizeX;}
109 
113  int getSizeY() const {return mData.size();}
114 
118  int getMinOnsetTime() const {return minOnsetTime;}
119 
123  int getMaxOnsetTime() const {return maxOnsetTime;}
124 
128  float getMinVolatility() const {return minVolatility;}
129 
133  float getMaxVolatility() const {return maxVolatility;}
134 
138  float getMinSum() const { return minSum;}
139 
143  float getMaxSum() const { return maxSum;}
144 
148  QString getPath() const { return mPath; }
149 
153  void setUnsorted()
154  {
155  mSortedData.clear();
156  auto it = mData.begin();
157  while(it!=mData.end())
158  {
159  mSortedData.append(&(*it++));
160  }
161  }
165  bool isEmpty() const { return mData.isEmpty(); }
166 private:
167  int mSizeX;
168  QString mPath;
169  DataList mData;
170  DataPtrList mSortedData;
171  QVector<float> mCumHeight;
172  int minOnsetTime;
173  int maxOnsetTime;
174  float minVolatility;
175  float maxVolatility;
176  float minSum;
177  float maxSum;
178 
179  friend class DataLoader;
180 };
181 
182 #endif // DATASET_H
float getMinSum() const
Returns the minimum sum of the overall dataset.
Definition: dataset.h:138
float getMaxSum() const
Returns the minimum sum of the overall dataset.
Definition: dataset.h:143
int getMaxOnsetTime() const
Returns the maximum onsettime of the overall dataset.
Definition: dataset.h:123
LayoutInfo layout
Information created during layouting.
Definition: dataset.h:40
DataPtrListRef getSortedData()
Returns a list of pointers which is sorted according to the current sorting algorithm.
Definition: dataset.h:98
t_entry max
The maximum data value in this layer.
Definition: dataset.h:65
The data set.
Definition: dataset.h:85
Responsible for loading data sets from file or generating random data to use.
Definition: fileloader.h:14
Represents a single layer of the stacked graph.
Definition: dataset.h:23
float getMaxVolatility() const
Returns the maximum volatility of the overall dataset.
Definition: dataset.h:133
int getMinOnsetTime() const
Returns the minimum onsettime of the overall dataset.
Definition: dataset.h:118
t_entry sum
The sum of all the data values in this layer.
Definition: dataset.h:61
int onsetTime
The first time point where data has a value.
Definition: dataset.h:49
int getSizeX() const
Retuns the size of the dataset in X direction, i.e.
Definition: dataset.h:108
int lastTime
The last time point where data has a value.
Definition: dataset.h:53
int maxIdx
The index of the maximum data value in the data vector.
Definition: dataset.h:69
int getSizeY() const
Returns the size of the dataset in Y direction, which is the number of layers this dataset has...
Definition: dataset.h:113
bool isEmpty() const
Returns true if the internal data set is empty, otherwise false.
Definition: dataset.h:165
QPointF labelPos
The optimal point to place the label, as determined during layouting.
Definition: dataset.h:44
t_entry volatility
The maximum data value change in this layer (used for sorting/coloring)
Definition: dataset.h:57
EntryVector data
The data values of this layer, for each time point.
Definition: dataset.h:32
QString label
A user-presentable label of the data.
Definition: dataset.h:28
Contains info for layouting.
Definition: dataset.h:9
DataListRef getData()
Returns a reference to the internal data set.
Definition: dataset.h:92
float getMinVolatility() const
Returns the minimum volatility of the overall dataset.
Definition: dataset.h:128
QString getPath() const
The path to the file where the dataset was loaded from.
Definition: dataset.h:148
int idx
The index of this DataItem in the parent DataSet (as per DataSet::getData)
Definition: dataset.h:73
void setUnsorted()
Resets the internal sorted list to the unsorted state, i.e.
Definition: dataset.h:153
QVector< float > & getCumHeight()
Returns the cumulated height at each point of the timeseries.
Definition: dataset.h:103
QColor color
The color for drawing this layer.
Definition: dataset.h:36