From 59a8bbac03ada85e8165561b508a13f1aa85e927 Mon Sep 17 00:00:00 2001 From: jonnew Date: Wed, 21 Aug 2024 11:35:50 -0400 Subject: [PATCH 1/2] Add visualizers for Quaternion and Vector3 - Both of these System.Numerics types are used data frames (Bno055DataFrame and TS4231V1PositionDataFrame) --- .../OpenEphys.Onix1.Design.csproj | 1 + .../QuaternionVisualizer.cs | 32 +++++++++++++++++++ OpenEphys.Onix1.Design/Vector3Visualizer.cs | 32 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 OpenEphys.Onix1.Design/QuaternionVisualizer.cs create mode 100644 OpenEphys.Onix1.Design/Vector3Visualizer.cs diff --git a/OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj b/OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj index 6038103..0b4c719 100644 --- a/OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj +++ b/OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj @@ -12,6 +12,7 @@ + diff --git a/OpenEphys.Onix1.Design/QuaternionVisualizer.cs b/OpenEphys.Onix1.Design/QuaternionVisualizer.cs new file mode 100644 index 0000000..3ecdbae --- /dev/null +++ b/OpenEphys.Onix1.Design/QuaternionVisualizer.cs @@ -0,0 +1,32 @@ +using System; +using Bonsai; +using Bonsai.Design.Visualizers; +using System.Numerics; +using Bonsai.Vision.Design; + +[assembly: TypeVisualizer(typeof(QuaternionVisualizer), Target = typeof(Quaternion))] + +namespace Bonsai.Vision.Design +{ + /// + /// Provides a type visualizer that displays a sequence of + /// values as a time series. + /// + public class QuaternionVisualizer : TimeSeriesVisualizer + { + /// + /// Initializes a new instance of the class. + /// + public QuaternionVisualizer() + : base(numSeries: 4) + { + } + + /// + public override void Show(object value) + { + var q = (Quaternion)value; + AddValue(DateTime.Now, q.X, q.Y, q.Z, q.W); + } + } +} diff --git a/OpenEphys.Onix1.Design/Vector3Visualizer.cs b/OpenEphys.Onix1.Design/Vector3Visualizer.cs new file mode 100644 index 0000000..7c6ca25 --- /dev/null +++ b/OpenEphys.Onix1.Design/Vector3Visualizer.cs @@ -0,0 +1,32 @@ +using System; +using Bonsai; +using Bonsai.Design.Visualizers; +using System.Numerics; +using Bonsai.Vision.Design; + +[assembly: TypeVisualizer(typeof(Vector3Visualizer), Target = typeof(Vector3))] + +namespace Bonsai.Vision.Design +{ + /// + /// Provides a type visualizer that displays a sequence of + /// values as a time series. + /// + public class Vector3Visualizer : TimeSeriesVisualizer + { + /// + /// Initializes a new instance of the class. + /// + public Vector3Visualizer() + : base(numSeries: 3) + { + } + + /// + public override void Show(object value) + { + var v = (Vector3)value; + AddValue(DateTime.Now, v.X, v.Y, v.Z); + } + } +} From d613e0bcadf7399a5e9408a7b8d1bb8f0f5ed1a4 Mon Sep 17 00:00:00 2001 From: jonnew Date: Wed, 21 Aug 2024 17:17:40 -0400 Subject: [PATCH 2/2] Fix Vector3 and Quaternion visualizer namespace - Accidentally copied namespace from Bonsai.Vision.Design where I copied the template for these classes from --- OpenEphys.Onix1.Design/QuaternionVisualizer.cs | 4 ++-- OpenEphys.Onix1.Design/Vector3Visualizer.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenEphys.Onix1.Design/QuaternionVisualizer.cs b/OpenEphys.Onix1.Design/QuaternionVisualizer.cs index 3ecdbae..6cd6b42 100644 --- a/OpenEphys.Onix1.Design/QuaternionVisualizer.cs +++ b/OpenEphys.Onix1.Design/QuaternionVisualizer.cs @@ -2,11 +2,11 @@ using Bonsai; using Bonsai.Design.Visualizers; using System.Numerics; -using Bonsai.Vision.Design; +using OpenEphys.Onix1.Design; [assembly: TypeVisualizer(typeof(QuaternionVisualizer), Target = typeof(Quaternion))] -namespace Bonsai.Vision.Design +namespace OpenEphys.Onix1.Design { /// /// Provides a type visualizer that displays a sequence of diff --git a/OpenEphys.Onix1.Design/Vector3Visualizer.cs b/OpenEphys.Onix1.Design/Vector3Visualizer.cs index 7c6ca25..6c37d18 100644 --- a/OpenEphys.Onix1.Design/Vector3Visualizer.cs +++ b/OpenEphys.Onix1.Design/Vector3Visualizer.cs @@ -2,11 +2,11 @@ using Bonsai; using Bonsai.Design.Visualizers; using System.Numerics; -using Bonsai.Vision.Design; +using OpenEphys.Onix1.Design; [assembly: TypeVisualizer(typeof(Vector3Visualizer), Target = typeof(Vector3))] -namespace Bonsai.Vision.Design +namespace OpenEphys.Onix1.Design { /// /// Provides a type visualizer that displays a sequence of