AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
GaugeAxis.cs
1 /************************************************/
2 /* */
3 /* Copyright (c) 2018 - 2021 monitor1394 */
4 /* https://github.com/monitor1394 */
5 /* */
6 /************************************************/
7 
8 using System.Collections.Generic;
9 using UnityEngine;
10 
11 namespace XCharts
12 {
17  [System.Serializable]
18  public class GaugeAxis : SubComponent
19  {
20  [SerializeField] private bool m_Show = true;
21  [SerializeField] private GaugeAxisLine m_AxisLine = new GaugeAxisLine(true);
22  [SerializeField] private GaugeAxisSplitLine m_SplitLine = new GaugeAxisSplitLine(true);
23  [SerializeField] private GaugeAxisTick m_AxisTick = new GaugeAxisTick(true);
24  [SerializeField] private SerieLabel m_AxisLabel = new SerieLabel();
25  [SerializeField] private List<string> m_AxisLabelText = new List<string>();
26 
27  public bool show { get { return m_Show; } set { m_Show = value; } }
32  public GaugeAxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
37  public GaugeAxisSplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
42  public GaugeAxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
47  public SerieLabel axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
55  public List<string> axisLabelText { get { return m_AxisLabelText; } set { m_AxisLabelText = value; } }
56 
57  public List<float> runtimeStageAngle = new List<float>();
58  public List<Vector3> runtimeLabelPosition = new List<Vector3>();
59  private List<ChartLabel> m_RuntimeLabelList = new List<ChartLabel>();
60 
61  internal Color32 GetAxisLineColor(ChartTheme theme, int index)
62  {
63  var color = !ChartHelper.IsClearColor(axisLine.barColor) ? axisLine.barColor : theme.GetColor(index);
64  ChartHelper.SetColorOpacity(ref color, axisLine.lineStyle.opacity);
65  return color;
66  }
67 
68  internal Color32 GetAxisLineBackgroundColor(ChartTheme theme, int index)
69  {
70  var color = !ChartHelper.IsClearColor(axisLine.barBackgroundColor)
71  ? axisLine.barBackgroundColor : ChartConst.greyColor32;
72  ChartHelper.SetColorOpacity(ref color, axisLine.lineStyle.opacity);
73  return color;
74  }
75 
76  internal Color32 GetSplitLineColor(Color32 themeColor, int serieIndex, float angle)
77  {
78  Color32 color;
79  if (!ChartHelper.IsClearColor(splitLine.lineStyle.color))
80  {
81  color = splitLine.lineStyle.color;
82  ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
83  return color;
84  }
85  color = themeColor;
86  ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
87  return color;
88  }
89 
90  internal Color32 GetAxisTickColor(Color32 themeColor, int serieIndex, float angle)
91  {
92  Color32 color;
93  if (!ChartHelper.IsClearColor(axisTick.lineStyle.color))
94  {
95  color = axisTick.lineStyle.color;
96  ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
97  return color;
98  }
99  color = themeColor;
100  ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
101  return color;
102  }
103 
104  internal Color32 GetPointerColor(ChartTheme theme, int serieIndex, float angle, ItemStyle itemStyle)
105  {
106  Color32 color;
107  if (!ChartHelper.IsClearColor(itemStyle.color))
108  {
109  return itemStyle.GetColor();
110  }
111  for (int i = 0; i < runtimeStageAngle.Count; i++)
112  {
113  if (angle < runtimeStageAngle[i])
114  {
115  color = axisLine.stageColor[i].color;
116  ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
117  return color;
118  }
119  }
120  color = theme.GetColor(serieIndex);
121  ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
122  return color;
123  }
124 
125  public void ClearLabelObject()
126  {
127  m_RuntimeLabelList.Clear();
128  }
129 
130  public void AddLabelObject(ChartLabel label)
131  {
132  m_RuntimeLabelList.Add(label);
133  }
134 
135  public ChartLabel GetLabelObject(int index)
136  {
137  if (index >= 0 && index < m_RuntimeLabelList.Count)
138  {
139  return m_RuntimeLabelList[index];
140  }
141  return null;
142  }
143 
144  public void SetLabelObjectPosition(int index, Vector3 pos)
145  {
146  if (index >= 0 && index < m_RuntimeLabelList.Count)
147  {
148  m_RuntimeLabelList[index].SetPosition(pos);
149  }
150  }
151 
152  public void SetLabelObjectText(int index, string text)
153  {
154  if (index >= 0 && index < m_RuntimeLabelList.Count)
155  {
156  m_RuntimeLabelList[index].SetText(text);
157  }
158  }
159 
160  public void SetLabelObjectActive(bool flag)
161  {
162  foreach (var label in m_RuntimeLabelList)
163  {
164  label.SetActive(flag);
165  }
166  }
167  }
168 }
XCharts.LineStyle.opacity
float opacity
Opacity of the line. Supports value from 0 to 1, and the line will not be drawn when set to 0....
Definition: LineStyle.cs:126
XCharts.GaugeAxisLine.stageColor
List< StageColor > stageColor
阶段颜色。
Definition: GaugeAxisLine.cs:57
XCharts.GaugeAxisTick
刻度
Definition: GaugeAxisTick.cs:16
XCharts.GaugeAxis.splitLine
GaugeAxisSplitLine splitLine
slit line style. 分割线。
Definition: GaugeAxis.cs:37
XCharts.GaugeAxisLine
Definition: GaugeAxisLine.cs:35
XCharts.ChartTheme.GetColor
Color32 GetColor(int index)
Gets the color of the specified index from the palette. 获得调色盘对应系列索引的颜色值。
Definition: ChartTheme.cs:221
XCharts.GaugeAxisSplitLine
分割线
Definition: GaugeAxisSplitLine.cs:14
XCharts.GaugeAxisLine.barBackgroundColor
Color32 barBackgroundColor
进度条背景颜色。
Definition: GaugeAxisLine.cs:53
XCharts.SubComponent
Definition: ChartComponent.cs:71
XCharts.GaugeAxis
Settings related to gauge axis line. 仪表盘轴线相关设置。
Definition: GaugeAxis.cs:18
XCharts
Definition: RewardChart.cs:14
XCharts.GaugeAxis.axisLabelText
List< string > axisLabelText
Coordinate axis scale label custom content. When the content is empty, axisLabel automatically displa...
Definition: GaugeAxis.cs:55
XCharts.BaseLine.lineStyle
LineStyle lineStyle
线条样式
Definition: BaseLine.cs:35
XCharts.GaugeAxis.axisLine
GaugeAxisLine axisLine
axis line style. 仪表盘轴线样式。
Definition: GaugeAxis.cs:32
XCharts.SerieLabel
Text label of chart, to explain some data information about graphic item like value,...
Definition: SerieLabel.cs:18
XCharts.GaugeAxis.axisLabel
SerieLabel axisLabel
axis label style. 文本标签。
Definition: GaugeAxis.cs:47
XCharts.GaugeAxisLine.barColor
Color32 barColor
进度条颜色。
Definition: GaugeAxisLine.cs:49
XCharts.GaugeAxis.axisTick
GaugeAxisTick axisTick
axis tick style. 刻度。
Definition: GaugeAxis.cs:42
XCharts.ChartTheme
Theme. 主题相关配置。
Definition: ChartTheme.cs:46
XCharts.LineStyle.color
Color32 color
the color of line, default use serie color. 线的颜色。
Definition: LineStyle.cs:81