Removed ParDatasetImporterEditorWindow. We now import PARCHG datasets directly instead.

This commit is contained in:
Matias Lavik 2021-12-31 11:06:59 +01:00
Родитель bb5646cbfe
Коммит 9c0724e267
5 изменённых файлов: 14 добавлений и 89 удалений

Просмотреть файл

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace UnityVolumeRendering
{
@ -51,13 +52,17 @@ namespace UnityVolumeRendering
}
case DatasetType.PARCHG:
{
ParDatasetImporterEditorWindow pnd = (ParDatasetImporterEditorWindow)EditorWindow.GetWindow(typeof(ParDatasetImporterEditorWindow));
if (pnd != null)
{
pnd.Close();
}
pnd = new ParDatasetImporterEditorWindow(filePath);
pnd.Show();
ParDatasetImporter importer = new ParDatasetImporter(filePath);
VolumeDataset dataset = importer.Import();
if (dataset != null)
{
VolumeRenderedObject obj = VolumeObjectFactory.CreateObject(dataset);
}
else
{
Debug.LogError("Failed to import datset");
}
break;
}
}

Просмотреть файл

@ -1,63 +0,0 @@
using UnityEngine;
using UnityEditor;
using System.IO;
using System;
namespace UnityVolumeRendering
{
/// <summary>
/// Editor window for importing datasets.
/// </summary>
public class ParDatasetImporterEditorWindow : EditorWindow // : EditorWindow
{
private string fileToImport;
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()
{
ParDatasetImporter 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()
{
EditorGUILayout.LabelField(fileToImport);
/*GUILayout.Label("To be implemented");
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();
}
}
}

Просмотреть файл

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b9e614925fe534506b67283b90b7852c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -13,9 +13,6 @@ namespace UnityVolumeRendering
/// </summary>
public class RuntimeGUI : MonoBehaviour
{
int nx;
int ny;
int nz;
private void OnGUI()
{
GUILayout.BeginVertical();
@ -58,7 +55,7 @@ namespace UnityVolumeRendering
{
DespawnAllDatasets();
string filePath = result.path;
ParDatasetImporter parimporter = new ParDatasetImporter(filePath, nx, ny, nz);
ParDatasetImporter parimporter = new ParDatasetImporter(filePath);
VolumeDataset dataset = parimporter.Import(); //overriden somewhere
if (dataset != null)
{

Просмотреть файл

@ -54,12 +54,9 @@ namespace UnityVolumeRendering
string[] fileContentLines;
int fileContentIndex;
public ParDatasetImporter(string filePath, int nx, int ny, int nz)
public ParDatasetImporter(string filePath)
{
this.filePath = filePath;
this.nx = nx;
this.ny = ny;
this.nz = nz;
}
public VolumeDataset Import() //fills VolumeDataset object