GlistEngine
Loading...
Searching...
No Matches
gGUILineGraph.h
Go to the documentation of this file.
1/****************************************************************************
2 * Copyright (c) 2014 Nitra Games Ltd., Istanbul, Turkey *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice should not be *
13 * deleted from the source form of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
28
29/****************************************************************************
30 * Author: Berke Adil, Utku Sarialan, 2022-on *
31 ****************************************************************************/
32
33/*
34 * gGUILineGraph.h
35 *
36 * Created on: 28 July 2022
37 * Author: Berke Adil
38 */
39
40#ifndef UI_GGUILINEGRAPH_H_
41#define UI_GGUILINEGRAPH_H_
42
43
44#include "gImage.h"
45#include "gGUIFrame.h"
46#include "gGUIPanel.h"
47#include "gGUIButton.h"
48#include "gGUITextbox.h"
49#include "gGUIGraph.h"
50#include "gLine.h"
51#include "gRectangle.h"
52#include "gCircle.h"
53#include <array>
54#include <deque>
55#include <unordered_map>
56
57
58class gGUILineGraph: public gGUIGraph {
59
60public:
62 virtual ~gGUILineGraph();
63
67 void set(gBaseApp* root, gBaseGUIObject* topParentGUIObject, gBaseGUIObject* parentGUIObject, int parentSlotLineNo, int parentSlotColumnNo, int x, int y, int w, int h) override;
68
72 void setMaxX(float maxX) override;
73
77 void setMinX(float minX) override;
78
82 void setMaxY(float maxY) override;
83
87 void setMinY(float minY) override;
88
92 void setLabelCountX(int labelCount) override;
93
97 void setLabelCountY(int labelCount) override;
98
102 void enableRange(bool isRangeEnabled) override;
103
107 void setRange(float rangeStart, float rangeEnd) override;
108
112 void enablePoints(bool arePointsEnabled);
113
117 void setLineColor(int lineIndex, gColor lineColor);
118
122 gColor getLineColor(int lineIndex);
123
127 void setFilledAreaColor(int lineIndex, gColor fillColor);
128
133
137 void addLine();
138
142 void addData(int lineIndex, std::deque<std::array<float, 2>> dataToAdd);
143
147 void addPointToLine(int lineIndex, float x, float y);
148
152 void setPointValues(int lineIndex, int pointIndex, float newX, float newY);
153
157 void setPointValues(int lineIndex, float oldX, float oldY, float newX, float newY);
158
162 void removeFirstPointsFromLine(int lineIndex, int pointNumLimit);
163
167 int getPointNum(int lineIndex);
168
172 float getPointXValue(int lineIndex, int pointIndex);
173
177 float getPointYValue(int lineIndex, int pointIndex);
178
182 void clear() override;
183
187 void setOffset(int leftOffset, int rightOffset, int topOffset, int bottomOffset);
188
193
197 void setLineThickness(float thickness);
198
202 float getLineThickness() const;
203
208 void setRoundedCorners(bool isRounded);
209
213 bool getRoundedCorners() const;
214
219private:
220 static const int linecolornum = 6;
221 static gColor defaultLineColor(int lineIndex);
222 void ensureLineColorSlot(int lineIndex);
223 void clearGeometryCache();
224 void drawGraph() override;
225 void updatePoints();
226 void updateOffset();
227
228 std::deque<std::deque<std::array<float, 4>>> graphlines;
229 std::deque<PolylineStroke> cachedstrokes;
230 std::vector<gCircle> cachedcircles;
231 std::unordered_map<uint64_t, size_t> circlesmap;
232 std::vector<gColor> linecolors;
233 std::vector<gColor> filledcolors;
234
235 bool pointsenabled;
236 bool isfilledarea;
237 bool isautoscaled;
238 bool roundedcorners;
239 float linethickness;
240 bool needsupdate = false;
241 int offsetleft;
242 int offsetright;
243 int offsettop;
244 int offsetbottom;
245
246
247 uint64_t hash(uint32_t a, uint32_t b) const {
248 return ((uint64_t)a << 32) | b;
249 }
250};
251
252
253#endif /* UI_GGUILINEGRAPH_H_ */
Definition gBaseApp.h:16
gBaseApp * root
Definition gBaseGUIObject.h:151
Definition gColor.h:17
void setMinX(float minX) override
float getLineThickness() const
gColor getFilledAreaColor(int lineIndex)
void setMaxX(float maxX) override
void addData(int lineIndex, std::deque< std::array< float, 2 > > dataToAdd)
bool getRoundedCorners() const
virtual ~gGUILineGraph()
void setOffset(int leftOffset, int rightOffset, int topOffset, int bottomOffset)
void setLabelCountY(int labelCount) override
void setLineThickness(float thickness)
void removeFirstPointsFromLine(int lineIndex, int pointNumLimit)
void enableFilledArea(bool isEnabled)
int getPointNum(int lineIndex)
void setMaxY(float maxY) override
void setLineColor(int lineIndex, gColor lineColor)
void setMinY(float minY) override
void setRange(float rangeStart, float rangeEnd) override
void addPointToLine(int lineIndex, float x, float y)
void enableAutoScale(bool isEnabled)
void enablePoints(bool arePointsEnabled)
void enableRange(bool isRangeEnabled) override
float getPointYValue(int lineIndex, int pointIndex)
void clear() override
void setPointValues(int lineIndex, int pointIndex, float newX, float newY)
void setLabelCountX(int labelCount) override
gColor getLineColor(int lineIndex)
void set(gBaseApp *root, gBaseGUIObject *topParentGUIObject, gBaseGUIObject *parentGUIObject, int parentSlotLineNo, int parentSlotColumnNo, int x, int y, int w, int h) override
void setPointValues(int lineIndex, float oldX, float oldY, float newX, float newY)
void setFilledAreaColor(int lineIndex, gColor fillColor)
float getPointXValue(int lineIndex, int pointIndex)
void setRoundedCorners(bool isRounded)
float a
Definition gColor.h:22
float b
Definition gColor.h:22