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
64 void set(gBaseApp* root, gBaseGUIObject* topParentGUIObject, gBaseGUIObject* parentGUIObject, int parentSlotLineNo, int parentSlotColumnNo, int x, int y, int w, int h) override;
65
66 void setMaxX(int maxX) override;
67 void setMinX(int minX) override;
68 void setMaxY(int maxY) override;
69 void setMinY(int minY) override;
70
71 void setLabelCountX(int labelCount) override;
72 void setLabelCountY(int labelCount) override;
73
74 void enablePoints(bool arePointsEnabled);
75 void setLineColor(int lineIndex, gColor lineColor);
76 gColor getLineColor(int lineIndex);
77
78 void addLine();
79 void addData(int lineIndex, std::deque<std::array<float, 2>> dataToAdd);
80 void addPointToLine(int lineIndex, float x, float y);
81 void setPointValues(int lineIndex, int pointIndex, float newX, float newY);
82 void setPointValues(int lineIndex, float oldX, float oldY, float newX, float newY);
83 void removeFirstPointsFromLine(int lineIndex, int pointNumLimit);
84
85 int getPointNum(int lineIndex);
86
87 float getPointXValue(int lineIndex, int pointIndex);
88 float getPointYValue(int lineIndex, int pointIndex);
89
90 void clear() override;
91
92private:
93 static const int linecolornum = 6;
94 void drawGraph() override;
95 void updatePoints();
96
97 std::deque<std::deque<std::array<float, 4>>> graphlines;
98 std::vector<gLine> cachedlines;
99 std::vector<gCircle> cachedcircles;
100 std::unordered_map<uint64_t, gLine*> linesmap;
101 std::unordered_map<uint64_t, gCircle*> circlesmap;
102 gColor linecolors[linecolornum];
103
104 bool pointsenabled;
105 bool needsupdate = false;
106
107 uint64_t hash(uint32_t a, uint32_t b) {
108 return ((uint64_t)a << 32) | b;
109 }
110};
111
112
113#endif /* UI_GGUILINEGRAPH_H_ */
Definition gBaseApp.h:16
Definition gBaseGUIObject.h:18
gBaseApp * root
Definition gBaseGUIObject.h:147
Definition gColor.h:17
Definition gGUIGraph.h:49
Definition gGUILineGraph.h:58
void setMaxY(int maxY) override
void addData(int lineIndex, std::deque< std::array< float, 2 > > dataToAdd)
void setMinX(int minX) override
virtual ~gGUILineGraph()
void setLabelCountY(int labelCount) override
void removeFirstPointsFromLine(int lineIndex, int pointNumLimit)
int getPointNum(int lineIndex)
void setLineColor(int lineIndex, gColor lineColor)
void addPointToLine(int lineIndex, float x, float y)
void enablePoints(bool arePointsEnabled)
float getPointYValue(int lineIndex, int pointIndex)
void clear() override
void setPointValues(int lineIndex, int pointIndex, float newX, float newY)
void setLabelCountX(int labelCount) override
void setMaxX(int maxX) override
void setMinY(int minY) 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)
float getPointXValue(int lineIndex, int pointIndex)
float a
Definition gColor.h:22
float b
Definition gColor.h:22