// creates particlePoints in the Particle System game object // // //private void CreateParticles() //{ // rowCount = pointList.Count; // particlePoints = new ParticleSystem.Particle[rowCount]; // for (int i = 0; i < pointList.Count; i++) // { // // Convert object from list into float // float x = (Convert.ToSingle(pointList[i][xName]) - xMin) / (xMax - xMin); // float y = (Convert.ToSingle(pointList[i][yName]) - yMin) / (yMax - yMin); // float z = (Convert.ToSingle(pointList[i][zName]) - zMin) / (zMax - zMin); // // Set point location // particlePoints[i].position = new Vector3(x, y, z) * plotScale; // //GlowColor = // // Set point color // particlePoints[i].startColor = new Color(x, y, z, 1.0f); // particlePoints[i].startSize = particleScale; // } //} //Finds labels named in scene, assigns values to their text meshes // WARNING: game objects need to be named within scene private void AssignLabels(int number, DataForPlotting data, string method_name) { string postfix = number.ToString("0"); // Update point counter GameObject.Find("Count_Description" + postfix).GetComponent <TextMesh>().text = "Number of subjects: " + pointList.Count.ToString("0"); // Update title according to dimensionality reduction method GameObject.Find("Dataset_Label" + postfix).GetComponent <TextMesh>().text = method_name; // Update axis titles to ColumnNames GameObject.Find("X_Title" + postfix).GetComponent <TextMesh>().text = data.xName; GameObject.Find("Y_Title" + postfix).GetComponent <TextMesh>().text = data.yName; GameObject.Find("Z_Title" + postfix).GetComponent <TextMesh>().text = data.zName; // Set x Labels by finding game objects and setting TextMesh and assigning value (need to convert to string) GameObject.Find("X_Min_Lab" + postfix).GetComponent <TextMesh>().text = data.xMin.ToString("0.0"); GameObject.Find("X_Mid_Lab" + postfix).GetComponent <TextMesh>().text = (data.xMin + (data.xMax - data.xMin) / 2f).ToString("0.0"); GameObject.Find("X_Max_Lab" + postfix).GetComponent <TextMesh>().text = data.xMax.ToString("0.0"); // Set y Labels by finding game objects and setting TextMesh and assigning value (need to convert to string) GameObject.Find("Y_Min_Lab" + postfix).GetComponent <TextMesh>().text = data.yMin.ToString("0.0"); GameObject.Find("Y_Mid_Lab" + postfix).GetComponent <TextMesh>().text = (data.yMin + (data.yMax - data.yMin) / 2f).ToString("0.0"); GameObject.Find("Y_Max_Lab" + postfix).GetComponent <TextMesh>().text = data.yMax.ToString("0.0"); // Set z Labels by finding game objects and setting TextMesh and assigning value (need to convert to string) GameObject.Find("Z_Min_Lab" + postfix).GetComponent <TextMesh>().text = data.zMin.ToString("0.0"); GameObject.Find("Z_Mid_Lab" + postfix).GetComponent <TextMesh>().text = (data.zMin + (data.zMax - data.zMin) / 2f).ToString("0.0"); GameObject.Find("Z_Max_Lab" + postfix).GetComponent <TextMesh>().text = data.zMax.ToString("0.0"); }
void SetDataForPlotting(out DataForPlotting data, string xname, string yname) { data = new DataForPlotting(xname, yname); // Get maxes of each axis data.xMax = FindMaxValue(data.xName); data.yMax = FindMaxValue(data.yName); // Get minimums of each axis data.xMin = FindMinValue(data.xName); data.yMin = FindMinValue(data.yName); }
// Places the prefabs according to values read in private void PlacePrefabPoints(GameObject PointHolder, DataForPlotting data, string method_name, string status) { // Get count (number of rows in table) rowCount = pointList.Count; for (var i = 0; i < pointList.Count; i++) { // Set x/y/z, standardized to between 0-1 float x = (Convert.ToSingle(pointList[i][data.xName]) - data.xMin) / (data.xMax - data.xMin); float y = (Convert.ToSingle(pointList[i][data.yName]) - data.yMin) / (data.yMax - data.yMin); float z = (Convert.ToSingle(pointList[i][data.zName]) - data.zMin) / (data.zMax - data.zMin); // Create vector 3 for positioning particlePoints Vector3 position = new Vector3(x, y, z) * plotScale; //instantiate as gameobject variable so that it can be manipulated within loop GameObject dataPoint = Instantiate(PointPrefab, Vector3.zero, Quaternion.identity); //dataPoint.GetComponent<Microsoft.MixedReality.Toolkit.UI.Interactable>().Profiles[0].Target = dataPoint; // Make dataPoint child of PointHolder object , to keep Points within container in hiearchy dataPoint.transform.parent = PointHolder.transform; // Position point at relative to parent dataPoint.transform.localPosition = position; dataPoint.transform.localScale = new Vector3(pointScale, pointScale, pointScale); // Assigns original values to dataPointName //string dataPointName = "PCA_" + pointList[i][USUBJID_name]; string dataPointName = "" + pointList[i][USUBJID_name]; // Assigns name to the prefab dataPoint.transform.name = dataPointName; // Assigns original text to Tooltip text string dist_col; string stat_col; if (method_name == "PCA") { dist_col = plot1USUBJID_distance; stat_col = plot1USUBJID_status; } else if (method_name == "MDS") { dist_col = plot2USUBJID_distance; stat_col = plot2USUBJID_status; } else { dist_col = plot3USUBJID_distance; stat_col = plot3USUBJID_status; } //string dataPointTooltipText = method_name + " " + //pointList[i][USUBJID_name] + System.Environment.NewLine + "Distance: " + pointList[i][dist_col] + System.Environment.NewLine + "Status: " + pointList[i][stat_col]; string dataPointTooltipText = method_name + System.Environment.NewLine + pointList[i][USUBJID_name] + System.Environment.NewLine + "PCA: " + pointList[i][plot1USUBJID_status] + System.Environment.NewLine + "MDS: " + pointList[i][plot2USUBJID_status] + System.Environment.NewLine + "LLE: " + pointList[i][plot3USUBJID_status]; dataPoint.GetComponent <Microsoft.MixedReality.Toolkit.UI.ToolTipSpawner>().toolTipText = dataPointTooltipText; if (renderPrefabsWithColor == true) { // Sets color according to x/y/z value //dataPoint.GetComponent<Renderer>().material.color = new Color(x, y, z, 1.0f); //// Activate emission color keyword so we can modify emission color dataPoint.GetComponent <Renderer>().material.EnableKeyword("_EMISSION"); dataPoint.GetComponent <Renderer>().material.SetColor("_EmissionColor", new Color(0.0f, 0.0f, 0.0f, 1.0f)); string s = pointList[i][status] as string; if (s == "Severe Outlier") { dataPoint.GetComponent <Renderer>().material.color = new Color(1.0f, 0.0f, 0.0f, 1.0f); } else if (s == "Moderate Outlier") { dataPoint.GetComponent <Renderer>().material.color = new Color(0.5f, 0.0f, 0.5f, 1.0f); } else if (s == "Moderate Inlier") { dataPoint.GetComponent <Renderer>().material.color = new Color(0.0f, 1.0f, 0.3f, 1.0f); } else if (s == "Severe Inlier") { dataPoint.GetComponent <Renderer>().material.color = new Color(1.0f, 1.0f, 0.0f, 1.0f); } else { dataPoint.GetComponent <Renderer>().material.color = new Color(0.0f, 0.0f, 1.0f, 1.0f); } } //Form arrays by status in PCA (used to filter points by status) if (method_name == "PCA") { string st = pointList[i][status] as string; if (st == "Severe Outlier") { severeOutlier.Add(dataPoint); } else if (st == "Moderate Outlier") { moderateOutlier.Add(dataPoint); } else if (st == "Moderate Inlier") { moderateInlier.Add(dataPoint); } else if (st == "Severe Inlier") { severeInlier.Add(dataPoint); } else { withinRange.Add(dataPoint); } } //AssignLabels(); } }