Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
HexCellDisplayer.cs
Go to the documentation of this file.
1 using System;
2 using System.Linq;
6 using UnityEngine;
7 
8 namespace droid.Runtime.Prototyping.Displayers.Cells {
12  [ExecuteInEditMode]
13  [AddComponentMenu(DisplayerComponentMenuPath._ComponentMenuPath
14  + "VectorField"
15  + DisplayerComponentMenuPath._Postfix)]
17  [SerializeField] bool _plot_random_series = false;
18  [SerializeField] bool _retain_last_plot = true;
19 
20  public Boolean PlotRandomSeries {
21  get { return this._plot_random_series; }
22  set { this._plot_random_series = value; }
23  }
24 
27  protected override void Setup() { }
28 
29  public override void Display(Double value) { }
30 
31  public override void Display(float[] values) { }
32 
33  public override void Display(String values) { }
34 
35  public override void Display(Vector3 value) { throw new NotImplementedException(); }
36  public override void Display(Vector3[] value) { this.ScatterPlot(value); }
37 
38  public override void Display(Points.ValuePoint points) { this.PlotSeries(new[] {points}); }
39 
40  public override void Display(Points.ValuePoint[] points) { }
41 
42  public override void Display(Points.StringPoint point) { throw new NotImplementedException(); }
43  public override void Display(Points.StringPoint[] points) { throw new NotImplementedException(); }
44 
45  public override void Display(float values) { }
46 
47  void Update() {
48  if (this._retain_last_plot) {
49  if (this._Values != null) {
50  PlotSeries(this._Values);
51  }
52  }
53  }
54 
58  public new void ScatterPlot(Vector3[] points) { }
59 
60  /*public override void PlotSeries(float[] points) {
61 
62  }*/
63 
64  #if UNITY_EDITOR
65  void OnDrawGizmos() {
66  if (this.enabled) {
67  if (this._Values == null || this._Values.Length == 0) {
68  if (this._plot_random_series) {
69  var vs = PlotFunctions.SampleRandomSeries(9);
70  this._Values = vs.Select(v => v._Val).ToArray();
71  this.PlotSeries(vs);
72  }
73  }
74  }
75  }
76  #endif
77 
81  public new void PlotSeries(Points.ValuePoint[] points) {
82  #if NEODROID_DEBUG
83  if (this.Debugging) {
84  Debug.Log("Plotting value points");
85  }
86  #endif
87 
88  this._Values = points;
89 
90  foreach (var point in points) {
91  //point._Size
92  switch ((int)point._Val) {
93  case 0:
94  NeodroidDrawingUtilities.ForDebug(point._Pos, Vector3.forward, Color.cyan);
95  break;
96  case 1:
97  NeodroidDrawingUtilities.ForDebug(point._Pos, Vector3.back, Color.cyan);
98  break;
99  case 2:
100  NeodroidDrawingUtilities.ForDebug(point._Pos, Vector3.up, Color.cyan);
101  break;
102  case 3:
103  NeodroidDrawingUtilities.ForDebug(point._Pos, Vector3.down, Color.cyan);
104  break;
105  case 4:
106  NeodroidDrawingUtilities.ForDebug(point._Pos, Vector3.left, Color.cyan);
107  break;
108  case 5:
109  NeodroidDrawingUtilities.ForDebug(point._Pos, Vector3.right, Color.cyan);
110  break;
111  }
112  }
113  }
114  }
115 }
override void Display(Points.ValuePoint[] points)
override void Display(Points.StringPoint[] points)