Skip to content

Commit

Permalink
Merge pull request #24 from ahoirg/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ahoirg authored Jun 14, 2023
2 parents f37f17e + 8b2c825 commit 3f8b034
Show file tree
Hide file tree
Showing 11 changed files with 1,855 additions and 16 deletions.
1,776 changes: 1,776 additions & 0 deletions Assets/_UDVT/Scenes/ChooseKdeParameters.unity

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Assets/_UDVT/Scenes/ChooseKdeParameters.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class KernelDensityEstimation
/// <param name="sigma"></param>
/// <param name="nsteps"></param>
/// <returns></returns>
public static double[,] KDE(double[] data, double sigma = 1, int nsteps = 100) // GROUP12: Added default sigma and nsteps values
public static double[,] KDE(double[] data, double sigma, int nsteps)
{
//Taken from https://gist.github.com/ksandric/e91860143f1dd378645c01d518ddf013

Expand Down
40 changes: 40 additions & 0 deletions Assets/_UDVT/Scripts/Runtime/MenuScripts/ChooseKdeParameters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using System;

/// <summary>
/// It includes input buttons to obtaining the parameters required in KDE calculations from the user.
/// </summary>
public class ChooseKdeParameters : MonoBehaviour
{
public InputField sigmaValue;
public InputField stepsValue;

public void OnChangeSigmaValue()
{
string inputText = (string) sigmaValue.text;

if (double.TryParse(inputText, out double doubleValue))
CurrentParams.kdeSigmaValue = doubleValue;
else
CurrentParams.SetDefaultKdeSigmaValue(); // set default
}

public void OnChangeStepsValue()
{
string inputText = (string)stepsValue.text;

if (Int32.TryParse(inputText, out int intValue))
CurrentParams.kdeStepsValue = intValue;
else
CurrentParams.SetDefaultKdeStepsValue(); // set default
}

public void SaveValuesAndRedirect()
{
SceneManager.LoadScene("LoadData");
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Assets/_UDVT/Scripts/Runtime/MenuScripts/CurrentParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ public class CurrentParams : MonoBehaviour
public static VisType currentVisType = VisType.Scatterplot; // default
public static BinningType currentBinningType = BinningType.Squareroot; // default
public static Dictionary<string, double[]> loadedData = null; // default
public static double kdeSigmaValue = 1; // default
public static int kdeStepsValue = 100; // default

public static void SetDefaultKdeSigmaValue() { CurrentParams.kdeSigmaValue = 1; }
public static void SetDefaultKdeStepsValue() { CurrentParams.kdeStepsValue = 100; }

}
2 changes: 1 addition & 1 deletion Assets/_UDVT/Scripts/Runtime/MenuScripts/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void StartWithHistogram()
public void StartWithDensityplot()
{
CurrentParams.currentVisType = VisType.Densityplot;
CallLoadData();
SceneManager.LoadScene("ChooseKdeParameters");
}

public void StartWithViolinPlot()
Expand Down
12 changes: 3 additions & 9 deletions Assets/_UDVT/Scripts/Runtime/Visualization/VisDensityplot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override GameObject CreateVis(GameObject container)
{
base.CreateVis(container);

KDEresult = KernelDensityEstimation.KDE(dataSets[0].ElementAt(0).Value);
KDEresult = KernelDensityEstimation.KDE(dataSets[0].ElementAt(0).Value, CurrentParams.kdeSigmaValue, CurrentParams.kdeStepsValue);
ChangeDataMarks();

//## 01: Create Axes and Grids
Expand Down Expand Up @@ -72,32 +72,26 @@ public override void ChangeDataMarks()
/// <param name="datamarks"></param>
public void ConnectDataMarks(List<DataMark> datamarks)
{
//Debug.Log(dataSets[0].ElementAt(0).Value[0]);
for (int i = 0; i < datamarks.Count-1; i++)
{
//
var startTransform = datamarks[i].GetDataMarkInstance().transform;
var endTransform = datamarks[i+1].GetDataMarkInstance().transform;
var start = new Vector3(startTransform.localPosition.x,startTransform.localPosition.y,startTransform.localPosition.z);
//var end = new Vector3(endTransform.localPosition.x,endTransform.localPosition.y,endTransform.localPosition.z);
//debug(dataSets[0].ElementAt(0).Value[0])
//Debug.DrawLine(startTransform.position, endTransform.position, Color.red);

GameObject line = new GameObject();
line.name = i + "";
line.transform.localPosition = start;
line.transform.localScale = new Vector3(0.03f, 0.03f, 0.03f);
line.AddComponent<LineRenderer>();
//line.transform.SetParent(GameObject.Find("Data Marks").transform,false);

LineRenderer renderer = line.GetComponent<LineRenderer>();
renderer.useWorldSpace = true;
//(GameObject)Resources.Load("Prefabs/DataVisPrefabs/Marks/Sphere");
renderer.material = (Material)Resources.Load("Prefabs/DataVisPrefabs/Marks/Line");
renderer.material.SetColor("_Color", Color.white);
renderer.startWidth = 0.003f;
renderer.endWidth = 0.003f;
renderer.SetPosition(0, startTransform.position);
renderer.SetPosition(1, endTransform.position);

}
}
}
3 changes: 1 addition & 2 deletions Assets/_UDVT/Scripts/Runtime/Visualization/VisHistogram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public override void ChangeAxisAttribute(int axisId, int selectedDimension, int

for (var i = 0; i < numberOfTicks; i++)
{
int temp = minMaxValues.Where(q => (q >= _min) && (q < (_min + _range))).Count();
_frequency.Add(temp);
_frequency.Add(minMaxValues.Where(q => (q >= _min) && (q < (_min + _range))).Count());

//It calculates the numbers to be displayed on the x-axis.
_min = _min + _range;
Expand Down
3 changes: 3 additions & 0 deletions ProjectSettings/EditorBuildSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ EditorBuildSettings:
- enabled: 1
path: Assets/_UDVT/Scenes/MainScene.unity
guid: 9fc0d4010bbf28b4594072e72b8655ab
- enabled: 1
path: Assets/_UDVT/Scenes/ChooseKdeParameters.unity
guid: 92ba5c33c38cd9b42a99f2ca41cb76c4
m_configObjects: {}
9 changes: 6 additions & 3 deletions UserSettings/EditorUserSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ EditorUserSettings:
serializedVersion: 4
m_ConfigSettings:
RecentlyUsedSceneGuid-0:
value: 5a0801565156595a585d0e7b15705c444f15192e7e7176322b284b31e0b2603c
value: 5a5455070400585f5f585f2742720f444f4e4c7d7e717164287f4531b6b9323d
flags: 0
RecentlyUsedSceneGuid-1:
value: 5a5455070400585f5f585f2742720f444f4e4c7d7e717164287f4531b6b9323d
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
flags: 0
RecentlyUsedSceneGuid-2:
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
value: 5a0801565156595a585d0e7b15705c444f15192e7e7176322b284b31e0b2603c
flags: 0
RecentlyUsedSceneGuid-3:
value: 5a03560750565a080e5d5421147a5d44441641732a7a253179781e31b5b6376c
flags: 0
RecentlyUsedSceneGuid-4:
value: 51500d515d070c5a0c5b5f7b457a0944464e4072757124332b284d64bae1306e
flags: 0
vcSharedLogLevel:
Expand Down

0 comments on commit 3f8b034

Please sign in to comment.