Ejemplo n.º 1
0
    public void PlottData()
    {
        Max      = new float[dropDownList.Length - 1];
        Min      = new float[dropDownList.Length - 1];
        nameList = new string[dropDownList.Length - 1];

        if (TargetingScript.selectedTarget != null)
        {
            selectedIndex = TargetingScript.selectedTarget.GetComponent <StoreIndexInDataBall>().Index;
        }

        foreach (GameObject dataValues in GameObject.FindGameObjectsWithTag("DataBall"))
        {
            Destroy(dataValues);
        }

        foreach (var axisValue in GameObject.FindGameObjectsWithTag("3D_Axis_ValueText"))
        {
            Destroy(axisValue);
        }

        feature1Name = columnListDropDown[dropDownList[0].value];
        feature2Name = columnListDropDown[dropDownList[1].value];
        feature3Name = columnListDropDown[dropDownList[2].value];
        feature4Name = columnListDropDown[dropDownList[3].value];
        feature5Name = columnListDropDown[dropDownList[4].value];

        for (int i = 0; i < dropDownList.Length - 1; i++)
        {
            nameList[i]      = columnList[dropDownList[i].value + 1];
            textList[i].text = nameList[i];
            Min[i]           = CalculationHelpers.FindMinValue(nameList[i], pointList);
            Max[i]           = CalculationHelpers.FindMaxValue(nameList[i], pointList);
        }

        InstantiateDataPoint(Max, Min, nameList);

        RenderAxisValues(Max, Min);

        // Focus camera on new dataPoint
        if (CameraBehavior.teleportCamera)
        {
            CameraBehavior.RefocusCamera(pointList);
        }

        if (KNN.kPoints != null)
        {
            if (KNN.kPoints.Count > 0)
            {
                ColorManager.Blink(KNN.kPoints, pointList);
            }
        }
    }
Ejemplo n.º 2
0
    public void PlottData()
    {
        if (TargetingScript.selectedTarget != null)
        {
            selectedIndex = TargetingScript.selectedTarget.GetComponent <StoreIndexInDataBall>().Index;
        }

        DestroyDataBallsAndAxisValues();

        xName = columnList[xList.value + 1];
        yName = columnList[yList.value + 1];

        xAxisText.text = xName;
        yAxisText.text = yName;

        // Get maxes of each axis
        xMax = CalculationHelpers.FindMaxValue(xName, pointList);
        yMax = CalculationHelpers.FindMaxValue(yName, pointList);
        zMax = 0f;

        // Get minimums of each axis
        xMin = CalculationHelpers.FindMinValue(xName, pointList);
        yMin = CalculationHelpers.FindMinValue(yName, pointList);
        zMin = 0f;

        // If renderMode is 3D
        if (MainMenu.renderMode == 1)
        {
            zName          = columnList[zList.value + 1];
            zAxisText.text = zName;
            zMax           = CalculationHelpers.FindMaxValue(zName, pointList);
            zMin           = CalculationHelpers.FindMinValue(zName, pointList);
        }

        string valueString;

        // If renderMode is 2D
        if (MainMenu.renderMode == 0)
        {
            // Destroy all dataValues before plotting new ones
            foreach (GameObject dataValues in GameObject.FindGameObjectsWithTag("dataValues"))
            {
                Destroy(dataValues);
            }

            DrawBackgroundGridAndValues();
        }

        // If renderMode is 3D
        if (MainMenu.renderMode == 1)
        {
            RenderAxisValues();
        }

        // Loop through Pointlist
        for (var i = 0; i < pointList.Count; i++)
        {
            GameObject dataPoint;

            // Get value in poinList at ith "row", in "column" Name, normalize
            valueString = pointList[i][xName].ToString();
            float x = (float.Parse(valueString, CultureInfo.InvariantCulture) - xMin) / (xMax - xMin);

            valueString = pointList[i][yName].ToString();
            float y = (float.Parse(valueString, CultureInfo.InvariantCulture) - yMin) / (yMax - yMin);

            float z = 1;

            //Instantiate datapoints
            if (MainMenu.renderMode == 0)
            {
                dataPoint = Instantiate(PointPrefab, new Vector3(x, y, 0) * plotScale, Quaternion.identity);
                dataPoint.transform.name   = pointList[i][columnList[0]] + " " + pointList[i][xName] + " " + pointList[i][yName] + " " + pointList[i][columnList[columnList.Count() - 1]];
                dataPoint.transform.parent = PointHolder.transform;
            }
            else
            {
                valueString = pointList[i][zName].ToString();
                z           = (float.Parse(valueString, CultureInfo.InvariantCulture) - zMin) / (zMax - zMin);
                dataPoint   = Instantiate(PointPrefab, new Vector3(x, y, z) * plotScale, Quaternion.identity);
                dataPoint.transform.name   = pointList[i][columnList[0]] + " " + pointList[i][xName] + " " + pointList[i][yName] + " " + pointList[i][zName] + " " + pointList[i][columnList[columnList.Count() - 1]];
                dataPoint.transform.parent = PointHolder.transform;
            }

            if (!pointList[i].ContainsKey("DataBall"))
            {
                pointList[i].Add("DataBall", dataPoint);
            }
            else
            {
                pointList[i]["DataBall"] = dataPoint;
            }

            //Store values in dataPoint
            dataPoint.GetComponent <StoreIndexInDataBall>().Index         = i;
            dataPoint.GetComponent <StoreIndexInDataBall>().TargetFeature = pointList[i][columnList[columnList.Count - 1]].ToString();
            dataPoint.GetComponent <StoreIndexInDataBall>().Feature1      = xName;
            dataPoint.GetComponent <StoreIndexInDataBall>().Feature2      = yName;
            if (zName != null)
            {
                dataPoint.GetComponent <StoreIndexInDataBall>().Feature3 = zName;
            }

            //Assign color to dataPoint
            int index = targetFeatures.IndexOf(pointList[i][columnList[columnList.Count - 1]].ToString());
            if (targetFeatures.Count() <= 10)
            {
                ColorManager.ChangeColor(dataPoint, index);
            }
            else
            {
                dataPoint.GetComponent <Renderer>().material.color = new Color(x, y, z, 1.0f);
            }

            //Reselect target if one was selected before.
            if (selectedIndex == i)
            {
                TargetingScript.selectedTarget = dataPoint;
                TargetingScript.colorOff       = TargetingScript.selectedTarget.GetComponent <Renderer>().material.color;
                TargetingScript.selectedTarget.GetComponent <Renderer>().material.color = Color.white;
                TargetingScript.selectedTarget.transform.localScale += new Vector3(+0.01f, +0.01f, +0.01f);
                selectedIndex = -1;
            }
        }

        // Focus camera on new dataPoint
        if (CameraBehavior.teleportCamera)
        {
            CameraBehavior.RefocusCamera(pointList);
        }

        if (KNN.kPoints != null)
        {
            if (KNN.kPoints.Count > 0)
            {
                ColorManager.Blink(KNN.kPoints, pointList);
            }
        }
    }
Ejemplo n.º 3
0
    public void PlottData()
    {
        if (TargetingScript.selectedTarget != null)
        {
            selectedIndex  = TargetingScript.selectedTarget.GetComponent <StoreIndexInDataBall>().Index;
            selectedRow    = TargetingScript.selectedTarget.GetComponent <StoreIndexInDataBall>().Row;
            selectedColumn = TargetingScript.selectedTarget.GetComponent <StoreIndexInDataBall>().Column;
        }

        ResetDataPlot();

        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                try
                {
                    feature1Name = featureList[columnDropdownList[j].value];
                    feature2Name = featureList[columnDropdownList[k].value];
                    feature1     = featureList[columnDropdownList[0].value];
                    feature2     = featureList[columnDropdownList[1].value];
                    feature3     = featureList[columnDropdownList[2].value];
                    feature4     = featureList[columnDropdownList[3].value];

                    if (j == k)
                    {
                        GameObject summonPlane = Instantiate(planePointBackground,
                                                             new Vector3(k * 1.2F + 0.5F, j * 1.2F + 0.5F, 0) * plotScale,
                                                             Quaternion.Euler(0, 90, -90));

                        //Le textfält
                        TMP_Text textField = Instantiate(ScatterplotMatrixText,
                                                         new Vector3(k * 1.2F + 1, j * 1.2F + 0.3F, -0.01f) * plotScale,
                                                         Quaternion.identity);

                        textField.text = featureList[columnDropdownList[j].value];
                    }
                    else if (k < j)
                    {
                        GameObject summonPlane = Instantiate(planePointBackground,
                                                             new Vector3(k * 1.2F + 0.5F, j * 1.2F + 0.5F, 0) * plotScale,
                                                             Quaternion.Euler(0, 90, -90));

                        // Get maxes of each axis
                        float xMax = CalculationHelpers.FindMaxValue(feature1Name, pointList);
                        float yMax = CalculationHelpers.FindMaxValue(feature2Name, pointList);

                        // Get minimums of each axis
                        float xMin = CalculationHelpers.FindMinValue(feature1Name, pointList);
                        float yMin = CalculationHelpers.FindMinValue(feature2Name, pointList);

                        string valueString;

                        //Loop through Pointlist
                        for (var i = 0; i < pointList.Count; i++)
                        {
                            GameObject dataPoint;

                            // Get value in poinList at ith "row", in "column" Name, normalize
                            valueString = pointList[i][feature1Name].ToString();
                            float x = (float.Parse(valueString, CultureInfo.InvariantCulture) - xMin) / (xMax - xMin);

                            valueString = pointList[i][feature2Name].ToString();
                            float y = (float.Parse(valueString, CultureInfo.InvariantCulture) - yMin) / (yMax - yMin);

                            int index = targetFeatures.IndexOf(pointList[i][columnList[columnList.Count - 1]].ToString());

                            // Instantiate dataPoint
                            dataPoint = Instantiate(PointPrefab,
                                                    new Vector3(x + k * 1.2F, y + j * 1.2F, 0) * plotScale,
                                                    Quaternion.identity);
                            // Set transform name
                            dataPoint.transform.name = pointList[i][feature1Name] + " " + pointList[i][feature2Name];
                            // Set parent
                            dataPoint.transform.parent = PointHolder.transform;

                            dataPoint.GetComponent <StoreIndexInDataBall>().Index         = i;
                            dataPoint.GetComponent <StoreIndexInDataBall>().TargetFeature =
                                pointList[i][columnList[columnList.Count - 1]].ToString();

                            dataPoint.GetComponent <StoreIndexInDataBall>().Feature1 = feature1;
                            dataPoint.GetComponent <StoreIndexInDataBall>().Feature2 = feature2;
                            dataPoint.GetComponent <StoreIndexInDataBall>().Column   = featureList[columnDropdownList[j].value];
                            dataPoint.GetComponent <StoreIndexInDataBall>().Row      = featureList[columnDropdownList[k].value];
                            dataPoint.GetComponent <StoreIndexInDataBall>().Feature3 = feature3;
                            dataPoint.GetComponent <StoreIndexInDataBall>().Feature4 = feature4;
                            dataPoint.GetComponent <StoreIndexInDataBall>().ScatterPlotMatrixPositionFinder  = new Vector3(k * 1.2F + 0.5F, j * 1.2F + 0.5F, 0) * plotScale;
                            dataPoint.GetComponent <StoreIndexInDataBall>().ScatterPlotMatrixPositionFinder += new Vector3(-5, -5, 0);


                            if (!pointList[i].ContainsKey("DataBall"))
                            {
                                pointList[i].Add("DataBall", dataPoint);
                            }
                            else
                            {
                                pointList[i]["DataBall"] = dataPoint;
                            }

                            // Set color
                            if (targetFeatures.Count() <= 10)
                            {
                                ColorManager.ChangeColor(dataPoint, index);
                            }
                            else
                            {
                                dataPoint.GetComponent <Renderer>().material.color = new Color(x, y, y, 1.0f);
                            }

                            //Reselect target if one was selected before.
                            if (selectedIndex == i && dataPoint.GetComponent <StoreIndexInDataBall>().Column == selectedColumn && dataPoint.GetComponent <StoreIndexInDataBall>().Row == selectedRow)
                            {
                                TargetingScript.selectedTarget = dataPoint;
                                TargetingScript.colorOff       = TargetingScript.selectedTarget.GetComponent <Renderer>().material.color;
                                TargetingScript.selectedTarget.GetComponent <Renderer>().material.color = Color.white;
                                TargetingScript.selectedTarget.transform.localScale += new Vector3(+0.01f, +0.01f, +0.01f);
                                selectedIndex = -1;
                            }
                            if (KNN.KNNMode && i == pointList.Count() - 1)
                            {
                                dataPoint.GetComponent <Renderer>().material.color = Color.white;
                                dataPoint.transform.localScale += new Vector3(-0.01f, -0.01f, -0.01f);
                            }
                        }
                    }
                }
                catch (Exception) { }

                if (KNN.kPoints != null)
                {
                    if (KNN.kPoints.Count > 0)
                    {
                        ColorManager.Blink(KNN.kPoints, pointList);
                    }
                }
            }
        }

        // Focus camera on new dataPoint
        if (CameraBehavior.teleportCamera)
        {
            CameraBehavior.RefocusCamera(pointList);
        }
    }