Skip to content

Commit 03880fd

Browse files
committed
Merged PR 47704: Filling out VOs and Adapters for 3D Points, Lines, and Rectangles
Filling out and making symmetric our set of VOs and adapters for: - Point3D (MathNET and Windows) - Line3D (MathNET) - Rect3D (Windows) And handling all combinations of T, Nullable<T>, and List<T>. Added descriptions to all configuration properties for these. Related work items: #132887
1 parent 267c66a commit 03880fd

21 files changed

+490
-291
lines changed

Sources/Visualization/Microsoft.Psi.Visualization.Windows/Adapters/CoordinateSystemAdapter.cs

-29
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.Psi.Visualization.Adapters
5+
{
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using MathNet.Spatial.Euclidean;
9+
using Microsoft.Psi.Visualization.Data;
10+
11+
/// <summary>
12+
/// Used to adapt streams of lists of <see cref="Line3D"/> to lists of nullable <see cref="Line3D"/>.
13+
/// </summary>
14+
[StreamAdapter]
15+
public class Line3DListToNullableAdapter : StreamAdapter<List<Line3D>, List<Line3D?>>
16+
{
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="Line3DListToNullableAdapter"/> class.
19+
/// </summary>
20+
public Line3DListToNullableAdapter()
21+
: base(Adapter)
22+
{
23+
}
24+
25+
private static List<Line3D?> Adapter(List<Line3D> value, Envelope env)
26+
{
27+
return value?.Select(p => p as Line3D?).ToList();
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.Psi.Visualization.Adapters
5+
{
6+
using MathNet.Spatial.Euclidean;
7+
using Microsoft.Psi.Visualization.Data;
8+
9+
/// <summary>
10+
/// Used to adapt streams of <see cref="Line3D"/> into nullable <see cref="Line3D"/>.
11+
/// </summary>
12+
[StreamAdapter]
13+
public class Line3DToNullableAdapter : StreamAdapter<Line3D, Line3D?>
14+
{
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="Line3DToNullableAdapter"/> class.
17+
/// </summary>
18+
public Line3DToNullableAdapter()
19+
: base(Adapter)
20+
{
21+
}
22+
23+
private static Line3D? Adapter(Line3D value, Envelope env)
24+
{
25+
return value;
26+
}
27+
}
28+
}

Sources/Visualization/Microsoft.Psi.Visualization.Windows/Adapters/MathNetNullableLine3DToLine3DListVisualizationObject.cs

-36
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.Psi.Visualization.Adapters
5+
{
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using Microsoft.Psi.Visualization.Data;
9+
10+
using MathNet = MathNet.Spatial.Euclidean;
11+
using Windows = System.Windows.Media.Media3D;
12+
13+
/// <summary>
14+
/// Used to adapt streams of lists of nullable <see cref="MathNet.Point3D"/> into lists of nullable <see cref="Windows.Point3D"/>.
15+
/// </summary>
16+
[StreamAdapter]
17+
public class MathNetNullablePoint3DListToWindowsNullablePoint3DListAdapter : StreamAdapter<List<MathNet.Point3D?>, List<Windows.Point3D?>>
18+
{
19+
/// <summary>
20+
/// Initializes a new instance of the <see cref="MathNetNullablePoint3DListToWindowsNullablePoint3DListAdapter"/> class.
21+
/// </summary>
22+
public MathNetNullablePoint3DListToWindowsNullablePoint3DListAdapter()
23+
: base(Adapter)
24+
{
25+
}
26+
27+
private static List<Windows.Point3D?> Adapter(List<MathNet.Point3D?> value, Envelope env)
28+
{
29+
return value?.Select(p => p.HasValue ? new Windows.Point3D(p.Value.X, p.Value.Y, p.Value.Z) as Windows.Point3D? : null).ToList();
30+
}
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.Psi.Visualization.Adapters
5+
{
6+
using Microsoft.Psi.Visualization.Data;
7+
8+
using MathNet = MathNet.Spatial.Euclidean;
9+
using Windows = System.Windows.Media.Media3D;
10+
11+
/// <summary>
12+
/// Used to adapt streams of nullable <see cref="MathNet.Point3D"/> into nullable <see cref="Windows.Point3D"/>.
13+
/// </summary>
14+
[StreamAdapter]
15+
public class MathNetNullablePoint3DToWindowsNullablePoint3DAdapter : StreamAdapter<MathNet.Point3D?, Windows.Point3D?>
16+
{
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="MathNetNullablePoint3DToWindowsNullablePoint3DAdapter"/> class.
19+
/// </summary>
20+
public MathNetNullablePoint3DToWindowsNullablePoint3DAdapter()
21+
: base(Adapter)
22+
{
23+
}
24+
25+
private static Windows.Point3D? Adapter(MathNet.Point3D? value, Envelope env)
26+
{
27+
return value.HasValue ? new Windows.Point3D(value.Value.X, value.Value.Y, value.Value.Z) as Windows.Point3D? : null;
28+
}
29+
}
30+
}

Sources/Visualization/Microsoft.Psi.Visualization.Windows/Adapters/MathNetNullablePoint3DToWindowsPoint3DListAdapter.cs

-33
This file was deleted.

Sources/Visualization/Microsoft.Psi.Visualization.Windows/Adapters/MathNetPoint3DListToWindowsPoint3DListAdapter.cs Sources/Visualization/Microsoft.Psi.Visualization.Windows/Adapters/MathNetPoint3DListToWindowsNullablePoint3DListAdapter.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ namespace Microsoft.Psi.Visualization.Adapters
1111
using Windows = System.Windows.Media.Media3D;
1212

1313
/// <summary>
14-
/// Used to adapt streams of lists of MathNet.Spatial.Eudlidean.Point3Ds into lists of System.Windows.Media.Media32.Point3Ds.
14+
/// Used to adapt streams of lists of <see cref="MathNet.Point3D"/> into lists of nullable <see cref="Windows.Point3D"/>.
1515
/// </summary>
1616
[StreamAdapter]
17-
public class MathNetPoint3DListToWindowsPoint3DListAdapter : StreamAdapter<List<MathNet.Point3D>, List<Windows.Point3D>>
17+
public class MathNetPoint3DListToWindowsNullablePoint3DListAdapter : StreamAdapter<List<MathNet.Point3D>, List<Windows.Point3D?>>
1818
{
1919
/// <summary>
20-
/// Initializes a new instance of the <see cref="MathNetPoint3DListToWindowsPoint3DListAdapter"/> class.
20+
/// Initializes a new instance of the <see cref="MathNetPoint3DListToWindowsNullablePoint3DListAdapter"/> class.
2121
/// </summary>
22-
public MathNetPoint3DListToWindowsPoint3DListAdapter()
22+
public MathNetPoint3DListToWindowsNullablePoint3DListAdapter()
2323
: base(Adapter)
2424
{
2525
}
2626

27-
private static List<Windows.Point3D> Adapter(List<MathNet.Point3D> value, Envelope env)
27+
private static List<Windows.Point3D?> Adapter(List<MathNet.Point3D> value, Envelope env)
2828
{
29-
return value.Select(p => new Windows.Point3D(p.X, p.Y, p.Z)).ToList();
29+
return value?.Select(p => new Windows.Point3D(p.X, p.Y, p.Z) as Windows.Point3D?).ToList();
3030
}
3131
}
3232
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.Psi.Visualization.Adapters
5+
{
6+
using Microsoft.Psi.Visualization.Data;
7+
8+
using MathNet = MathNet.Spatial.Euclidean;
9+
using Windows = System.Windows.Media.Media3D;
10+
11+
/// <summary>
12+
/// Used to adapt streams of <see cref="MathNet.Point3D"/> into nullable <see cref="Windows.Point3D"/>.
13+
/// </summary>
14+
[StreamAdapter]
15+
public class MathNetPoint3DToWindowsNullablePoint3DAdapter : StreamAdapter<MathNet.Point3D, Windows.Point3D?>
16+
{
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="MathNetPoint3DToWindowsNullablePoint3DAdapter"/> class.
19+
/// </summary>
20+
public MathNetPoint3DToWindowsNullablePoint3DAdapter()
21+
: base(Adapter)
22+
{
23+
}
24+
25+
private static Windows.Point3D? Adapter(MathNet.Point3D value, Envelope env)
26+
{
27+
return new Windows.Point3D(value.X, value.Y, value.Z);
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.Psi.Visualization.Adapters
5+
{
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Windows.Media.Media3D;
9+
using Microsoft.Psi.Visualization.Data;
10+
11+
/// <summary>
12+
/// Used to adapt streams of lists of <see cref="Rect3D"/> to lists of nullable <see cref="Rect3D"/>.
13+
/// </summary>
14+
[StreamAdapter]
15+
public class Rect3DListToNullableAdapter : StreamAdapter<List<Rect3D>, List<Rect3D?>>
16+
{
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="Rect3DListToNullableAdapter"/> class.
19+
/// </summary>
20+
public Rect3DListToNullableAdapter()
21+
: base(Adapter)
22+
{
23+
}
24+
25+
private static List<Rect3D?> Adapter(List<Rect3D> value, Envelope env)
26+
{
27+
return value?.Select(p => p as Rect3D?).ToList();
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.Psi.Visualization.Adapters
5+
{
6+
using System.Windows.Media.Media3D;
7+
using Microsoft.Psi.Visualization.Data;
8+
9+
/// <summary>
10+
/// Used to adapt streams of <see cref="Rect3D"/> into nullable <see cref="Rect3D"/>.
11+
/// </summary>
12+
[StreamAdapter]
13+
public class Rect3DToNullableAdapter : StreamAdapter<Rect3D, Rect3D?>
14+
{
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="Rect3DToNullableAdapter"/> class.
17+
/// </summary>
18+
public Rect3DToNullableAdapter()
19+
: base(Adapter)
20+
{
21+
}
22+
23+
private static Rect3D? Adapter(Rect3D value, Envelope env)
24+
{
25+
return value;
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.Psi.Visualization.Adapters
5+
{
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Windows.Media.Media3D;
9+
using Microsoft.Psi.Visualization.Data;
10+
11+
/// <summary>
12+
/// Used to adapt streams of lists of <see cref="Point3D"/> to lists of nullable <see cref="Point3D"/>.
13+
/// </summary>
14+
[StreamAdapter]
15+
public class WindowsPoint3DListToNullableAdapter : StreamAdapter<List<Point3D>, List<Point3D?>>
16+
{
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="WindowsPoint3DListToNullableAdapter"/> class.
19+
/// </summary>
20+
public WindowsPoint3DListToNullableAdapter()
21+
: base(Adapter)
22+
{
23+
}
24+
25+
private static List<Point3D?> Adapter(List<Point3D> value, Envelope env)
26+
{
27+
return value?.Select(p => p as Point3D?).ToList();
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)