2026-04-01 12:46:48 +02:00
|
|
|
using Microsoft.VisualStudio.DebuggerVisualizers;
|
2026-04-02 15:20:12 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
2026-04-01 12:46:48 +02:00
|
|
|
using System.Collections.Generic;
|
2026-04-02 15:20:12 +02:00
|
|
|
using System.ComponentModel;
|
2026-04-01 12:46:48 +02:00
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Numerics;
|
2026-04-02 10:09:10 +02:00
|
|
|
namespace NrxVisualizerObjectSource;
|
2026-04-01 12:46:48 +02:00
|
|
|
|
2026-04-02 10:09:10 +02:00
|
|
|
public class NrxVisualizerObjectSource : VisualizerObjectSource
|
2026-04-01 12:46:48 +02:00
|
|
|
{
|
2026-04-02 10:09:10 +02:00
|
|
|
public NrxVisualizerObjectSource()
|
2026-04-01 12:46:48 +02:00
|
|
|
{
|
|
|
|
|
Debug.WriteLine("new Vector3ObjectSource");
|
|
|
|
|
}
|
|
|
|
|
public override void GetData(object target, Stream outgoingData)
|
|
|
|
|
{
|
2026-04-02 15:20:12 +02:00
|
|
|
var fullname = target.GetType().FullName;
|
|
|
|
|
Trace.WriteLine("GetData: objectType is: " + fullname);
|
|
|
|
|
VisualizerModel visualizerModel = new();
|
|
|
|
|
switch (fullname)
|
2026-04-01 12:46:48 +02:00
|
|
|
{
|
2026-04-02 15:20:12 +02:00
|
|
|
case "System.Numerics.Vector3":
|
|
|
|
|
visualizerModel.Content = target.ToString();
|
2026-04-01 12:46:48 +02:00
|
|
|
break;
|
2026-04-02 15:20:12 +02:00
|
|
|
case "System.Numerics.Quaternion":
|
|
|
|
|
visualizerModel.Content = target.ToString();
|
2026-04-01 12:46:48 +02:00
|
|
|
break;
|
2026-04-02 15:20:12 +02:00
|
|
|
case "Num.Roto.Visualization.Math.Geometry.Frame":
|
|
|
|
|
var tupleType = typeof(ValueTuple<Vector3,Quaternion,float>);
|
|
|
|
|
var tuple = (ValueTuple<Vector3, Quaternion, float>)TypeDescriptor.GetConverter(target).ConvertTo(target, tupleType);
|
|
|
|
|
visualizerModel.Content = tuple.ToString();
|
|
|
|
|
//visualizerModel.Content = (string)TypeDescriptor.GetConverter(target).ConvertTo(target, typeof(string));
|
2026-04-01 12:46:48 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2026-04-02 15:20:12 +02:00
|
|
|
if(target is IEnumerable<object> enumerable)
|
|
|
|
|
{
|
|
|
|
|
Trace.WriteLine($"enumerable is not null = {enumerable is not null}");
|
|
|
|
|
if (enumerable is not null)
|
|
|
|
|
{
|
|
|
|
|
List<string> stringList = [];
|
|
|
|
|
foreach (var item in enumerable)
|
|
|
|
|
{
|
|
|
|
|
stringList.Add(TypeDescriptor.GetConverter(item).ConvertToString(item));
|
|
|
|
|
}
|
|
|
|
|
visualizerModel.Content = string.Join(Environment.NewLine, stringList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Trace.WriteLine($"visualizerModel.Content = {visualizerModel.Content}");
|
|
|
|
|
SerializeAsJson(outgoingData, visualizerModel);
|
2026-04-01 12:46:48 +02:00
|
|
|
}
|
2026-04-02 10:09:10 +02:00
|
|
|
public override object CreateReplacementObject(object target, Stream incomingData)
|
|
|
|
|
{
|
2026-04-02 10:40:46 +02:00
|
|
|
Debug.WriteLine("CreateReplacementObject: objectType is: " + target.GetType().FullName);
|
2026-04-02 10:09:10 +02:00
|
|
|
return base.CreateReplacementObject(target, incomingData);
|
|
|
|
|
}
|
|
|
|
|
public override void TransferData(object target, Stream incomingData, Stream outgoingData)
|
|
|
|
|
{
|
2026-04-02 10:40:46 +02:00
|
|
|
Debug.WriteLine("TransferData: objectType is: " + target.GetType().FullName);
|
2026-04-02 10:09:10 +02:00
|
|
|
base.TransferData(target, incomingData, outgoingData);
|
|
|
|
|
}
|
2026-04-01 12:46:48 +02:00
|
|
|
}
|