GlistEngine
Loading...
Searching...
No Matches
gGUICandleStickChart.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 * gGUICandleStickChart.h
35 *
36 * Created on: 15 Agu 2022
37 * Author: Berke Adil
38 */
39
40#ifndef UI_GGUICANDLESTICKCHART_H_
41#define UI_GGUICANDLESTICKCHART_H_
42
43#include "gImage.h"
44#include "gGUIFrame.h"
45#include "gGUIPanel.h"
46#include "gGUIButton.h"
47#include "gGUITextbox.h"
48#include "gGUIControl.h"
49#include "gLine.h"
50#include "gRectangle.h"
51#include "gCircle.h"
52#include "gGUIGraph.h"
53#include <array>
54#include <cstdint>
55#include <deque>
56#include <unordered_map>
57#include <vector>
58
59
61
62public:
65
69 void set(gBaseApp* root, gBaseGUIObject* topParentGUIObject, gBaseGUIObject* parentGUIObject, int parentSlotLineNo, int parentSlotColumnNo, int x, int y, int w, int h) override;
70
74 void setMaxX(float maxX) override;
75
79 void setMinX(float minX) override;
80
84 void setMaxY(float maxY) override;
85
89 void setMinY(float minY) override;
90
94 void setLabelCountX(int labelCount) override;
95
99 void setLabelCountY(int labelCount) override;
100
104 void enableRange(bool isRangeEnabled) override;
105
109 void setRange(float rangeStart, float rangeEnd) override;
110
111 void setHighColor(gColor highColor);
113 void setLowColor(gColor lowColor);
115
119 void addPointToLine(float x, float high, float low, float open, float close);
120 void setCandleWidth(float candleWidth);
122
127 void enablePoints(bool arePointsEnabled);
128
132 bool isPointsEnabled() const;
133
137 void setLineColor(int lineIndex, gColor lineColor);
138
142 gColor getLineColor(int lineIndex);
143
147 void setFilledAreaColor(int lineIndex, gColor fillColor);
148
153
157 void addLine();
158
162 void addData(int lineIndex, std::deque<std::array<float, 2>> dataToAdd);
163
167 void addPointToLine(int lineIndex, float x, float y);
168
172 void setPointValues(int lineIndex, int pointIndex, float newX, float newY);
173
177 void setPointValues(int lineIndex, float oldX, float oldY, float newX, float newY);
178
182 void removeFirstPointsFromLine(int lineIndex, int pointNumLimit);
183
187 int getLineNum() const;
188
192 int getPointNum(int lineIndex);
193
197 float getPointXValue(int lineIndex, int pointIndex);
198
202 float getPointYValue(int lineIndex, int pointIndex);
203
208
212 void clear() override;
213
217 void setOffset(int leftOffset, int rightOffset, int topOffset, int bottomOffset);
218
223
227 void setLineThickness(float thickness);
228
232 float getLineThickness() const;
233
238 void setRoundedCorners(bool isRounded);
239
243 bool getRoundedCorners() const;
244
250
251protected:
252 void drawGraph() override;
258
259private:
260 static const int defaultlinecolornum = 6;
261 static gColor defaultLineColor(int lineIndex);
262 void ensureLineColorSlot(int lineIndex);
263 void clearLineGeometryCache();
264
265 std::vector<std::array<float, 10>> graphline;
266 gColor highcolor;
267 gColor lowcolor;
268 float candlew;
269
270 std::deque<std::deque<std::array<float, 4>>> graphlines;
271 std::deque<PolylineStroke> cachedstrokes;
272 std::vector<gCircle> cachedcircles;
273 std::unordered_map<uint64_t, size_t> circlesmap;
274 std::vector<gColor> linecolors;
275 std::vector<gColor> filledcolors;
276
277 bool pointsenabled;
278 bool isfilledarea;
279 bool isautoscaled;
280 bool roundedcorners;
281 float linethickness;
282 bool needsupdate;
283 bool hascustomoffset;
284 int offsetleft;
285 int offsetright;
286 int offsettop;
287 int offsetbottom;
288
289 uint64_t hash(uint32_t a, uint32_t b) const {
290 return (static_cast<uint64_t>(a) << 32) | b;
291 }
292};
293
294
295
296#endif /* UI_GGUICANDLESTICKCHART_H_ */
Definition gBaseApp.h:16
gBaseApp * root
Definition gBaseGUIObject.h:151
Definition gColor.h:17
void setRoundedCorners(bool isRounded)
float getPointXValue(int lineIndex, int pointIndex)
void enableFilledArea(bool isEnabled)
void setMaxX(float maxX) override
void setLowColor(gColor lowColor)
void setMinX(float minX) override
void addData(int lineIndex, std::deque< std::array< float, 2 > > dataToAdd)
void setRange(float rangeStart, float rangeEnd) override
gColor getFilledAreaColor(int lineIndex)
void addPointToLine(float x, float high, float low, float open, float close)
void setMaxY(float maxY) override
bool getRoundedCorners() const
void setCandleWidth(float candleWidth)
void setHighColor(gColor highColor)
void setOffset(int leftOffset, int rightOffset, int topOffset, int bottomOffset)
virtual ~gGUICandleStickChart()
void setLineColor(int lineIndex, gColor lineColor)
gColor getLineColor(int lineIndex)
int getPointNum(int lineIndex)
float getLineThickness() const
void enableRange(bool isRangeEnabled) override
void addPointToLine(int lineIndex, float x, float y)
int getLineNum() const
void removeFirstPointsFromLine(int lineIndex, int pointNumLimit)
void setMinY(float minY) override
void setLineThickness(float thickness)
void enablePoints(bool arePointsEnabled)
void clear() override
void setFilledAreaColor(int lineIndex, gColor fillColor)
void setPointValues(int lineIndex, float oldX, float oldY, float newX, float newY)
void setPointValues(int lineIndex, int pointIndex, float newX, float newY)
void set(gBaseApp *root, gBaseGUIObject *topParentGUIObject, gBaseGUIObject *parentGUIObject, int parentSlotLineNo, int parentSlotColumnNo, int x, int y, int w, int h) override
void setLabelCountX(int labelCount) override
void drawGraph() override
bool isPointsEnabled() const
void setLabelCountY(int labelCount) override
float getPointYValue(int lineIndex, int pointIndex)
void enableAutoScale(bool isEnabled)
float a
Definition gColor.h:22
float b
Definition gColor.h:22