-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
107 lines (91 loc) · 3.15 KB
/
Copy pathPlugin.cs
File metadata and controls
107 lines (91 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.IO;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Media.Media3D;
using HelixToolkit.Wpf;
using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.AFH5;
public class Plugin : IViewer
{
public int Priority => 0;
public void Init()
{
}
public bool CanHandle(string path)
{
return !Directory.Exists(path) && path.ToLower().EndsWith(".cas.h5")
|| !Directory.Exists(path) && path.ToLower().EndsWith(".msh.h5");
}
public void Prepare(string path, ContextObject context)
{
context.PreferredSize = new Size { Width = 600, Height = 600 };
}
public void View(string path, ContextObject context)
{
if (path.ToLower().EndsWith(".cas.h5"))
{
string content = CasH5.Read(path);
var textBox = new TextBox
{
Text = content,
IsReadOnly = true,
IsReadOnlyCaretVisible = true,
Padding = new Thickness(10),
TextWrapping = TextWrapping.Wrap,
BorderThickness = new Thickness(0),
Margin = new Thickness(0, 0, 0, -5)
};
var scrollViewer = new ScrollViewer
{
Content = textBox,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
};
context.ViewerContent = scrollViewer;
}
else if (path.ToLower().EndsWith("msh.h5"))
{
context.PreferredSize = new Size { Width = 1200, Height = 600 };
var mesh_data = MshH5.Read(path);
var view_point = new HelixViewport3D
{
ZoomExtentsWhenLoaded = true,
ShowCoordinateSystem = true,
IsRotationEnabled = mesh_data.Dimension == 3,
PanGesture = new MouseGesture(MouseAction.LeftClick),
Camera = new OrthographicCamera()
{
Position = new Point3D(0, 0, 100),
LookDirection = new Vector3D(0, 0, -50),
UpDirection = new Vector3D(0, 1, 0),
}
};
var render_points = new Point3DCollection();
foreach (int index in mesh_data.Connections)
{
if (index >= 0 && index < mesh_data.Nodes.Count)
{
render_points.Add(mesh_data.Nodes[index]);
}
}
render_points.Freeze();
var wire_frame = new LinesVisual3D
{
Color = Colors.Blue,
Thickness = 0.8,
Points = render_points,
};
view_point.Children.Add(wire_frame);
context.ViewerContent = view_point;
}
context.Title = $"{Path.GetFileName(path)}";
context.IsBusy = false;
}
public void Cleanup()
{
}
}