public void GeneratePointPressed()
    {
        string[] newRecord = new string[createdRecordAttributes.Count];
        for (int i = 0; i < createdRecordAttributes.Count; i++)
        {
            newRecord[i] = createdRecordAttributes[i].AttributeValue.text;
        }
        GameObject newNode    = NodeHandler.Graphcontroller.GenerateNode();
        NodePhysX  nodeScript = newNode.GetComponent <NodePhysX>();

        // Debug.Log("found script: " + nodeScript.name);

        // adds the next record from persistantdata loaded data file
        nodeScript.setDataPoint(DataTypes.ADDED_DATA, NodeHandler.Persistantdata.MinMaxData, newRecord,
                                NodeHandler.Persistantdata.DatasetNames, NodeHandler.Persistantdata.Types, NodeHandler.DataCluster, NodeHandler);
        NodeHandler.AddedDataPointsCoordinator.OriginType = DataTypes.ADDED_DATA;
        NodeHandler.AddedDataPointsCoordinator.Records.Add(newNode);
        if (NodeHandler.ClusteringOn) // if in cluster, inform cluster
        {
            NodeHandler.DataCluster.PointsTotal++;
        }

        string newID = "Generated_" + (NodeHandler.AddedDataPointsCoordinator.Count + 1);

        foreach (CreateAttributeItemController controller in createdRecordAttributes)
        {
            if (controller.AttributeType.Contains(DataTypes.ID))
            {
                controller.AttributeValue.text = newID;
            }
        }
        RandomizeAllAttributeValues();
        AddSimulatedToList(newRecord, newNode);
        GeneratedCountText.text = NodeHandler.AddedDataPointsCoordinator.Count.ToString();
    }
Example #2
0
    // Update file data points on toggle clicks.
    // This only updates records loaded from data file.
    void UpdateRenderFileDataPoints()
    {
        MinMaxAttributes = Persistantdata.MinMaxData;

        Debug.Log("Updating points in nodehandler");
        // if file data points rendering turned off, destroy all the points and links
        if (!RenderFileDataPoints && DataPointsCoordinator.Count > 0)
        {
            while (DataPointsCoordinator.DestroyLastDataPoint())
            {
                if (ClusteringOn) // if clustering, inform cluster
                {
                    DataCluster.PointsTotal--;
                }
            }
            CheckForRenderDataUpdate = false;
        }
        // if points to render is lower than points already rendered, destroy last point
        else if (RenderFileDataPoints && DataPointsCoordinator.Count > MaxRenderDatapoints)
        {
            DataPointsCoordinator.DestroyLastDataPoint();

            if (ClusteringOn) // if in cluster, inform cluster
            {
                DataCluster.PointsTotal--;
            }

            if (DataPointsCoordinator.Count <= MaxRenderDatapoints)
            {
                CheckForRenderDataUpdate = false;
            }
        }
        // if points rendered is below max, create a point
        else if (RenderFileDataPoints && DataPointsCoordinator.Count < MaxRenderDatapoints)
        {
            // if no more file records
            if (Persistantdata.RecordValues.Count <= DataPointsCoordinator.Count)
            {
                CheckForRenderDataUpdate = false;
            }

            // else add a new record
            else
            {
                GameObject newNode    = Graphcontroller.GenerateNode();
                NodePhysX  nodeScript = newNode.GetComponent <NodePhysX>();
                // Debug.Log("found script: " + nodeScript.name);

                // adds the next record from persistantdata loaded data file
                nodeScript.setDataPoint(DataTypes.FILE_DATA, MinMaxAttributes, Persistantdata.RecordValues[DataPointsCoordinator.Count],
                                        Persistantdata.DatasetNames, Persistantdata.Types, DataCluster, this);

                DataPointsCoordinator.Records.Add(newNode);

                if (ClusteringOn) // if in cluster, inform cluster
                {
                    DataCluster.PointsTotal++;
                }

                // Debug.Log("Rendered: " + DataPointsCoordinator.Count + " of " + RenderDatapointsCount);

                if (DataPointsCoordinator.Count >= MaxRenderDatapoints)
                {
                    CheckForRenderDataUpdate = false;
                }

                if (PPLinksActive)
                {
                    nodeScript.UpdateDataDataAssociations();
                }

                if (PGLinksActive)
                {
                    nodeScript.UpdateDataGeneAssociations();
                }
            }
        }
        // if no change needed, stop updating
        else
        {
            CheckForRenderDataUpdate = false;
        }
    }