From 707134ab55b3402e78379739a658840625b80ed8 Mon Sep 17 00:00:00 2001 From: jasonks2 <85245498+jasonks2@users.noreply.github.com> Date: Thu, 23 Sep 2021 11:06:51 -0500 Subject: [PATCH] Add files via upload --- .../Editor/ParDatasetImporterEditorWindow.cs | 63 +++++++++++++++++++ .../ParDatasetImporterEditorWindow.cs.meta | 11 ++++ 2 files changed, 74 insertions(+) create mode 100644 Assets/Editor/ParDatasetImporterEditorWindow.cs create mode 100644 Assets/Editor/ParDatasetImporterEditorWindow.cs.meta diff --git a/Assets/Editor/ParDatasetImporterEditorWindow.cs b/Assets/Editor/ParDatasetImporterEditorWindow.cs new file mode 100644 index 0000000..18f510e --- /dev/null +++ b/Assets/Editor/ParDatasetImporterEditorWindow.cs @@ -0,0 +1,63 @@ +using UnityEngine; +using UnityEditor; +using System.IO; +using System; + +namespace UnityVolumeRendering +{ + /// + /// Editor window for importing datasets. + /// + public class ParDatasetImporterEditorWindow : EditorWindow // : EditorWindow + { + private string fileToImport; + private string filePath; + private string moleculeName; + private int nx; + private int ny; + private int nz; + + + public ParDatasetImporterEditorWindow(string filePath) + { + fileToImport = filePath; + + if (Path.GetExtension(fileToImport) == ".vasp") + { + this.minSize = new Vector2(250.0f, 150.0f); + } + } + + private void ImportDataset() + { + + DatasetImporterBase importer = new ParDatasetImporter(fileToImport, nx, ny, nz); + VolumeDataset dataset = importer.Import(); + + if (dataset != null) + { + VolumeRenderedObject obj = VolumeObjectFactory.CreateObject(dataset); + } + else + { + Debug.LogError("Failed to import datset"); + } + + this.Close(); + } + + private void OnGUI() + { + ParDatasetImporter pd = new ParDatasetImporter(filePath, nx, ny, nz); + nx = EditorGUILayout.IntField("nx dimension grid values", nx); + ny = EditorGUILayout.IntField("ny dimension grid values", ny); + nz = EditorGUILayout.IntField("nz dimension grid values", nz); + + if (GUILayout.Button("Import")) + ImportDataset(); + + if (GUILayout.Button("Cancel")) + this.Close(); + } + } +} diff --git a/Assets/Editor/ParDatasetImporterEditorWindow.cs.meta b/Assets/Editor/ParDatasetImporterEditorWindow.cs.meta new file mode 100644 index 0000000..ea6f48d --- /dev/null +++ b/Assets/Editor/ParDatasetImporterEditorWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b9e614925fe534506b67283b90b7852c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: