private void SelectObject()
 {
     if (!currentPlaceableObject)
     {
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hitInfo;
         if (Physics.Raycast(ray, out hitInfo, 999f, collisionMaskPlaceables))
         {
             //Don't immediately select the just placed object
             if (hitInfo.collider.gameObject != currentPlaceableObject)
             {
                 DeselectCurrentPlaceable();
                 currentSelectedObject = hitInfo.collider.gameObject;
                 ColorManager colorManager = currentSelectedObject.GetComponent <ColorManager>();
                 colorManager.ChangeColor(Color.yellow);
                 selectionIndex  = 0;
                 nothingSelected = true;
                 if (currentPlaceableObject)
                 {
                     Destroy(currentPlaceableObject);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
    private void PlotData(int column, int columnPos)
    {
        columnName = featureList[column];

        // Sets the correct X-Axis position for each column
        float xPos = SetColumnPosition(columnPos);

        //Loop through Pointlist & Render dataset
        for (var i = 0; i < pointList.Count; i++)
        {
            int index = targetFeatures.IndexOf(pointList[i][columnList[columnList.Count - 1]].ToString());

            // Get original value
            string valueString = pointList[i][columnName].ToString();
            // Set normalized Y-value
            float y = (float.Parse(valueString, CultureInfo.InvariantCulture) - yMin) / (yMax - yMin);

            // Set correct color
            // Classification
            if (targetFeatures.Count <= 10)
            {
                targetColor = ColorManager.ChangeColor(index);
            }
            // Regression
            else
            {
                targetColor = new Color(xPos, y, 0, 1.0f);
                targetColorList[columnPos - 1, i] = targetColor;
            }

            InstantiateAndRenderDatapoints(xPos, i, y, columnPos);

            InstantiateAndRenderLines(columnPos, xPos, i, y);
        }
    }
Exemplo n.º 3
0
    private void InstantiateTargetFeatureList()
    {
        float targetXpos = 17f;
        float targetYpos = 8f;
        float targetZpos = 0f;
        Color targetColor;

        // Instantiate a list of targetFeatures to the side of the plot
        foreach (var targetFeature in targetFeatures)
        {
            // Instantiate targetFeaturePoint and name it
            GameObject targetFeaturePoint = Instantiate(TargetFeaturePrefab, new Vector3(targetXpos, targetYpos, targetZpos), Quaternion.identity);
            targetFeaturePoint.name = targetFeature;

            int index = targetFeatures.IndexOf(targetFeature.ToString());
            // Set correct color
            targetColor = ColorManager.ChangeColor(index);

            // Set color and text
            targetFeaturePoint.GetComponentInChildren <Renderer>().material.color = targetColor;
            TextMeshPro text = targetFeaturePoint.GetComponentInChildren <TextMeshPro>();
            text.text  = targetFeature;
            text.color = targetColor;

            // Change Y-Position for next targetFeature in the loop
            targetYpos -= 1f;
        }
    }
Exemplo n.º 4
0
    public void OnClick()
    {
        // Ändra targetfeature
        selTarget.GetComponent <StoreIndexInDataBall>().TargetFeature = CSVläsare.targetFeatures[changeTargetFeature.GetComponent <Dropdown>().value];

        // Lägg in den nya feature i pointlist och spara

        CSVläsare.pointList[selTarget.GetComponent <StoreIndexInDataBall>().Index][CSVläsare.columnList[CSVläsare.columnList.Count - 1]] = selTarget.GetComponent <StoreIndexInDataBall>().TargetFeature;

        if (SceneManager.GetActiveScene().name != "ValfriTeknik")
        {
            ColorManager.ChangeColor(selTarget, changeTargetFeature.GetComponent <Dropdown>().value);
        }
        TargetingScript.colorOff = selTarget.GetComponent <Renderer>().material.color;
        colorOfTargetFeature.GetComponent <Image>().color = selTarget.GetComponent <Renderer>().material.color;

        targetFeatureText.text = selTarget.GetComponent <StoreIndexInDataBall>().TargetFeature;
    }
 private void SetColor()
 {
     if (currentSelectedObject != null)
     {
         ColorManager colorManager = currentSelectedObject.GetComponent <ColorManager>();
         colorManager.ChangeColor(Color.yellow);
     }
     if (currentPlaceableObject != null)
     {
         ColorManager colorManager = currentPlaceableObject.GetComponent <ColorManager>();
         if (!canPlace)
         {
             colorManager.ChangeColor(new Color(2f, 0f, 0f));
         }
         else
         {
             colorManager.ResetColor();
         }
     }
 }
Exemplo n.º 6
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);
            }
        }
    }
Exemplo n.º 7
0
 static public void SwitchColor(Color mainColor, Color secondaryColor, float transitionLength)
 {
     instance.StartCoroutine(instance.ChangeColor(mainColor, secondaryColor, transitionLength));
 }
Exemplo n.º 8
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);
        }
    }