| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using ReFlex.Core.Common.Util; |
| | 4 | |
|
| | 5 | | namespace ReFlex.Core.Common.Components |
| | 6 | | { |
| | 7 | | /// <summary> |
| | 8 | | /// An interaction on an elastic display. |
| | 9 | | /// </summary> |
| | 10 | | public class Interaction |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Id for tracking a touch point over time |
| | 14 | | /// </summary> |
| 33667 | 15 | | public int TouchId { get; set; } = -1; |
| | 16 | |
|
| | 17 | | /// <summary> |
| | 18 | | /// Gets the position. |
| | 19 | | /// </summary> |
| | 20 | | /// <value> |
| | 21 | | /// The position. |
| | 22 | | /// </value> |
| 30173 | 23 | | public Point3 Position { get; set; } = new Point3(); |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Gets the type. |
| | 27 | | /// </summary> |
| | 28 | | /// <value> |
| | 29 | | /// The type. |
| | 30 | | /// </value> |
| 12164 | 31 | | public InteractionType Type { get; set; } |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// description of extremum to distinguish interactions from extremums between two interactions. |
| | 35 | | /// </summary> |
| 10934 | 36 | | public ExtremumDescription ExtremumDescription { get; set; } = new ExtremumDescription |
| 3695 | 37 | | { |
| 3695 | 38 | | Type = ExtremumType.Undefined, |
| 3695 | 39 | | NumFittingPoints = 0, |
| 3695 | 40 | | PercentageFittingPoints = 0 |
| 3695 | 41 | | }; |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Gets or sets the confidence. |
| | 45 | | /// </summary> |
| | 46 | | /// <value> |
| | 47 | | /// The confidence. |
| | 48 | | /// </value> |
| 11460 | 49 | | public float Confidence { get; set; } |
| | 50 | |
|
| | 51 | | /// <summary> |
| | 52 | | /// Gets the time. |
| | 53 | | /// </summary> |
| | 54 | | /// <value> |
| | 55 | | /// The time. |
| | 56 | | /// </value> |
| 7664 | 57 | | public long Time { get; set; } |
| | 58 | |
|
| | 59 | | /// <summary> |
| | 60 | | /// Just for json serialization ! |
| | 61 | | /// </summary> |
| 23 | 62 | | public Interaction() |
| 23 | 63 | | { |
| 23 | 64 | | Time = DateTime.Now.Ticks; |
| 23 | 65 | | } |
| | 66 | |
|
| | 67 | | /// <summary> |
| | 68 | | /// Initializes a new instance of the <see cref="Interaction"/> class. |
| | 69 | | /// </summary> |
| 1 | 70 | | public Interaction(Point3 position, Interaction source) |
| 1 | 71 | | { |
| 1 | 72 | | Position = position; |
| 1 | 73 | | Type = source.Type; |
| 1 | 74 | | Confidence = source.Confidence; |
| 1 | 75 | | ExtremumDescription = source.ExtremumDescription; |
| 1 | 76 | | Time = source.Time; |
| 1 | 77 | | TouchId = source.TouchId; |
| 1 | 78 | | } |
| | 79 | |
|
| | 80 | | /// <summary> |
| | 81 | | /// Initializes a new instance of the <see cref="Interaction"/> struct. |
| | 82 | | /// </summary> |
| | 83 | | /// <param name="position">The position.</param> |
| | 84 | | /// <param name="type">The type.</param> |
| | 85 | | /// <param name="confidence">The confidence.</param> |
| 65 | 86 | | public Interaction(Point3 position, InteractionType type, float confidence) |
| 65 | 87 | | { |
| 65 | 88 | | Position = position; |
| 65 | 89 | | Type = type; |
| 65 | 90 | | Confidence = confidence; |
| 65 | 91 | | Time = DateTime.Now.Ticks; |
| 65 | 92 | | } |
| | 93 | |
|
| | 94 | | /// <summary> |
| | 95 | | /// Initializes a new instance of the <see cref="Interaction"/> class. |
| | 96 | | /// </summary> |
| | 97 | | /// <param name="source">The source.</param> |
| 3606 | 98 | | public Interaction(Interaction source) |
| 3606 | 99 | | { |
| 3606 | 100 | | TouchId = source.TouchId; |
| 3606 | 101 | | Position = source.Position; |
| 3606 | 102 | | Type = source.Type; |
| 3606 | 103 | | ExtremumDescription = source.ExtremumDescription; |
| 3606 | 104 | | Confidence = source.Confidence; |
| 3606 | 105 | | Time = source.Time; |
| 3606 | 106 | | } |
| | 107 | |
|
| | 108 | | /// <summary> |
| | 109 | | /// Returns [this] as a list. |
| | 110 | | /// </summary> |
| | 111 | | /// <returns></returns> |
| 1 | 112 | | public IList<Interaction> AsList() => new List<Interaction> { this }; |
| | 113 | |
|
| | 114 | | /// <summary> |
| | 115 | | /// Returns a <see cref="System.String" /> that represents this instance. |
| | 116 | | /// </summary> |
| | 117 | | /// <returns> |
| | 118 | | /// A <see cref="System.String" /> that represents this instance. |
| | 119 | | /// </returns> |
| 1 | 120 | | public override string ToString() => $"TouchId: {TouchId}, Position: " + Position + ", Type: " + Type + " ,Confi |
| | 121 | | } |
| | 122 | | } |