Skip to content

Commit

Permalink
Merge pull request #238 from open-ephys/issue-136
Browse files Browse the repository at this point in the history
Add visualizers for Quaternion and Vector3
  • Loading branch information
jonnew authored Aug 21, 2024
2 parents 17f4f93 + d613e0b commit 549771b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<ItemGroup>
<PackageReference Include="Bonsai.Design" Version="2.8.5" />
<PackageReference Include="Bonsai.Design.Visualizers" Version="2.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OpenEphys.ProbeInterface.NET" Version="0.1.0" />
<PackageReference Include="ZedGraph" Version="5.1.7" />
Expand Down
32 changes: 32 additions & 0 deletions OpenEphys.Onix1.Design/QuaternionVisualizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using Bonsai;
using Bonsai.Design.Visualizers;
using System.Numerics;
using OpenEphys.Onix1.Design;

[assembly: TypeVisualizer(typeof(QuaternionVisualizer), Target = typeof(Quaternion))]

namespace OpenEphys.Onix1.Design
{
/// <summary>
/// Provides a type visualizer that displays a sequence of <see cref="Quaternion"/>
/// values as a time series.
/// </summary>
public class QuaternionVisualizer : TimeSeriesVisualizer
{
/// <summary>
/// Initializes a new instance of the <see cref="QuaternionVisualizer"/> class.
/// </summary>
public QuaternionVisualizer()
: base(numSeries: 4)
{
}

/// <inheritdoc/>
public override void Show(object value)
{
var q = (Quaternion)value;
AddValue(DateTime.Now, q.X, q.Y, q.Z, q.W);
}
}
}
32 changes: 32 additions & 0 deletions OpenEphys.Onix1.Design/Vector3Visualizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using Bonsai;
using Bonsai.Design.Visualizers;
using System.Numerics;
using OpenEphys.Onix1.Design;

[assembly: TypeVisualizer(typeof(Vector3Visualizer), Target = typeof(Vector3))]

namespace OpenEphys.Onix1.Design
{
/// <summary>
/// Provides a type visualizer that displays a sequence of <see cref="Vector3"/>
/// values as a time series.
/// </summary>
public class Vector3Visualizer : TimeSeriesVisualizer
{
/// <summary>
/// Initializes a new instance of the <see cref="Vector3Visualizer"/> class.
/// </summary>
public Vector3Visualizer()
: base(numSeries: 3)
{
}

/// <inheritdoc/>
public override void Show(object value)
{
var v = (Vector3)value;
AddValue(DateTime.Now, v.X, v.Y, v.Z);
}
}
}

0 comments on commit 549771b

Please sign in to comment.