Beispiel #1
0
    private IEnumerator CheckForParentThenChildren()
    {
        if (parentSet == false)
        {
            if (axisType == "node")
            {
                Tag parent = new Tag();

                yield return(StartCoroutine(ViRMA_APIController.GetHierarchyParent(axisId, (response) => {
                    if (response != null)
                    {
                        parent = response;
                        parentAxisId = parent.Id;
                        parentAxisLabel = parent.Label;
                        //Debug.Log("Parent: " + parent.Label);
                    }
                    else
                    {
                        //Debug.Log("No parent!");
                    }
                })));

                StartCoroutine(ViRMA_APIController.GetHierarchyChildren(parent.Id, (response) => {
                    parent.Children     = response;
                    parentChildrenCount = parent.Children.Count;
                    parentSet           = true;
                }));
            }
        }
    }
Beispiel #2
0
 public void GetTimelineChildMetadata()
 {
     if (id != 0)
     {
         StartCoroutine(ViRMA_APIController.GetTimelineMetadata(id, (metadata) => {
             tags        = metadata;
             var testing = String.Join(" | ", tags.ToArray());
             //Debug.Log(id + " : " + testing);
         }));
     }
 }
Beispiel #3
0
 private void CheckForChildren()
 {
     if (childrenSet == false)
     {
         if (axisType == "node")
         {
             StartCoroutine(ViRMA_APIController.GetHierarchyChildren(axisPointId, (response) => {
                 List <Tag> children    = response;
                 axisPointChildrenCount = children.Count;
                 childrenSet            = true;
             }));
         }
     }
 }
Beispiel #4
0
    private void LoadContextTimelineData(ViRMA_TimelineChild targetTimelineChild)
    {
        if (isContextTimeline == false)
        {
            savedTimelineSection = currentTimelineSection;
            savedTimelineChildId = targetTimelineChild.id;
        }

        StartCoroutine(ViRMA_APIController.GetContextTimeline(targetTimelineChild.timestamp, contextTimelineTimespan, (results) => {
            contextTimelineResults = results;

            if (contextTimelineResults.Count > 0)
            {
                if (contextTimelineResults.Count >= resultsRenderSize)
                {
                    if (contextTimelineResults.Count % resultsRenderSize == 0)
                    {
                        totalContextTimelineSections = (contextTimelineResults.Count / resultsRenderSize);
                    }
                    else
                    {
                        totalContextTimelineSections = (contextTimelineResults.Count / resultsRenderSize) + 1;
                    }
                }
                else
                {
                    totalContextTimelineSections = 1;
                }

                int targetSection = 0;
                for (int i = 0; i < contextTimelineResults.Count; i++)
                {
                    if (contextTimelineResults[i].Key == targetTimelineChild.id)
                    {
                        targetContextTimelineChildId = contextTimelineResults[i].Key;
                        targetSection = i / resultsRenderSize;

                        //Debug.Log(i + " divided by " + resultsRenderSize + " --> Target Section: " + targetSection);

                        break;
                    }
                }

                isContextTimeline = true;
                LoadTimelineSection(targetSection, totalContextTimelineSections);
            }
        }));
    }
Beispiel #5
0
    // cell and axes generation
    public IEnumerator SubmitVizQuery(Query submittedQuery)
    {
        // unload unsed textures
        Resources.UnloadUnusedAssets();

        // set loading flags to true and fade controllers
        vizFullyLoaded = false;
        globals.queryController.vizQueryLoading = true;
        globals.ToggleControllerFade(Player.instance.leftHand, true);
        globals.ToggleControllerFade(Player.instance.rightHand, true);

        // get cell data from server (WAIT FOR)
        yield return(StartCoroutine(ViRMA_APIController.GetCells(submittedQuery, (cells) => {
            cellData = cells;
        })));

        // generate axes with axis labels (WAIT FOR)
        yield return(StartCoroutine(GenerateAxesFromLabels(submittedQuery)));

        // generate textures and texture arrays from local image storage
        GenerateTexturesAndTextureArrays(cellData);

        // generate cells and their posiitons, centered on a parent
        GenerateCells(cellData);

        // set center point of wrapper around cells and axes
        CenterParentOnCellsAndAxes();

        // calculate bounding box to set cells positional limits
        CalculateCellsAndAxesBounds();

        // DEBUG: show cells/axes bounds and bounds center
        //ToggleDebuggingBounds();

        // add cells and axes to final parent to set default starting scale and position
        SetupDefaultScaleAndPosition();

        // update main menu data to match new viz
        globals.mainMenu.FetchProjectedFilterMetadata();
        globals.mainMenu.FetchDirectFilterMetadata();

        // set loading flags to true and unfade controllers
        vizFullyLoaded = true;
        globals.queryController.vizQueryLoading = false;
        globals.ToggleControllerFade(Player.instance.leftHand, false);
        globals.ToggleControllerFade(Player.instance.rightHand, false);
    }
Beispiel #6
0
    private IEnumerator GetTimelineSectionMetadata()
    {
        foreach (GameObject timelineSectionChild in timelineSectionChildren)
        {
            if (timelineSectionChild != null)
            {
                int targetId = timelineSectionChild.GetComponent <ViRMA_TimelineChild>().id;
                yield return(metadataFetcher = StartCoroutine(ViRMA_APIController.GetTimelineMetadata(targetId, (metadata) => {
                    //var testing = String.Join(" | ", metadata.ToArray());
                    //Debug.Log(targetId + " : " + testing);

                    if (timelineSectionChild != null)
                    {
                        timelineSectionChild.GetComponent <ViRMA_TimelineChild>().tags = metadata;
                    }
                })));
            }
        }
        metadataFetcher = null;
    }
Beispiel #7
0
    private IEnumerator GetHierarchyParentChain(int targetId, string axis)
    {
        List <Tag> allParents = new List <Tag>();

        bool traveseringHierarchy = true;
        int  idChecker            = targetId;

        while (traveseringHierarchy)
        {
            yield return(StartCoroutine(ViRMA_APIController.GetHierarchyParent(idChecker, (newParent) => {
                if (newParent != null)
                {
                    allParents.Add(newParent);
                    idChecker = newParent.Id;
                }
                else
                {
                    traveseringHierarchy = false;
                }
            })));
        }

        if (axis == "X")
        {
            xParentChain.AddRange(allParents);
            xParentChainFetched = true;
        }
        if (axis == "Y")
        {
            yParentChain.AddRange(allParents);
            yParentChainFetched = true;
        }
        if (axis == "Z")
        {
            zParentChain.AddRange(allParents);
            zParentChainFetched = true;
        }
    }
Beispiel #8
0
 // node interaction (drill dowm, roll up, timeline for cell)
 public void DrillDownRollUp(SteamVR_Action_Boolean action, SteamVR_Input_Sources source)
 {
     if (focusedAxisPoint != null)
     {
         if (focusedAxisPoint.GetComponent <ViRMA_AxisPoint>())
         {
             ViRMA_AxisPoint axisPoint = focusedAxisPoint.GetComponent <ViRMA_AxisPoint>();
             if (axisPoint.axisType == "node")
             {
                 StartCoroutine(ViRMA_APIController.GetHierarchyChildren(axisPoint.axisPointId, (response) => {
                     List <Tag> children = response;
                     if (children.Count > 0)
                     {
                         string axisQueryType = "";
                         if (axisPoint.x)
                         {
                             axisQueryType = "X";
                         }
                         else if (axisPoint.y)
                         {
                             axisQueryType = "Y";
                         }
                         else if (axisPoint.z)
                         {
                             axisQueryType = "Z";
                         }
                         globals.queryController.buildingQuery.SetAxis(axisQueryType, axisPoint.axisPointId, "node");
                         // Debug.Log(children.Count + " children in " + axisPoint.axisPointLabel);
                     }
                     else
                     {
                         //Debug.Log("0 children in " + axisPoint.axisPointLabel);
                     }
                 }));
             }
         }
         else if (focusedAxisPoint.GetComponent <ViRMA_RollUpPoint>())
         {
             ViRMA_RollUpPoint axisPoint = focusedAxisPoint.GetComponent <ViRMA_RollUpPoint>();
             StartCoroutine(ViRMA_APIController.GetHierarchyParent(focusedAxisPoint.GetComponent <ViRMA_RollUpPoint>().axisId, (response) => {
                 Tag parent = response;
                 if (parent != null)
                 {
                     string axisQueryType = "";
                     if (axisPoint.x)
                     {
                         axisQueryType = "X";
                     }
                     else if (axisPoint.y)
                     {
                         axisQueryType = "Y";
                     }
                     else if (axisPoint.z)
                     {
                         axisQueryType = "Z";
                     }
                     globals.queryController.buildingQuery.SetAxis(axisQueryType, parent.Id, "node");
                     // Debug.Log("Parent: " + parent.Name);
                 }
                 else
                 {
                     //Debug.Log("No parent!");
                 }
             }));
         }
     }
 }
Beispiel #9
0
    private IEnumerator GenerateAxesFromLabels(Query submittedQuery)
    {
        activeAxesLabels = new AxesLabels();

        // get X label data from server
        if (submittedQuery.X != null)
        {
            string parentLabel = "";
            yield return(StartCoroutine(ViRMA_APIController.GetHierarchyTag(submittedQuery.X.Id, (Tag parentTag) => {
                parentLabel = parentTag.Label;
            })));

            yield return(StartCoroutine(ViRMA_APIController.GetHierarchyChildren(submittedQuery.X.Id, (List <Tag> childTags) => {
                activeAxesLabels.SetAxisLabsls("X", submittedQuery.X.Id, submittedQuery.X.Type, parentLabel, childTags);
            })));
        }

        // get Y label data from server
        if (submittedQuery.Y != null)
        {
            string parentLabel = "";
            yield return(StartCoroutine(ViRMA_APIController.GetHierarchyTag(submittedQuery.Y.Id, (Tag parentTag) => {
                parentLabel = parentTag.Label;
            })));

            yield return(StartCoroutine(ViRMA_APIController.GetHierarchyChildren(submittedQuery.Y.Id, (List <Tag> childTags) => {
                activeAxesLabels.SetAxisLabsls("Y", submittedQuery.Y.Id, submittedQuery.Y.Type, parentLabel, childTags);
            })));
        }

        // get Z label data from server
        if (submittedQuery.Z != null)
        {
            string parentLabel = "";
            yield return(StartCoroutine(ViRMA_APIController.GetHierarchyTag(submittedQuery.Z.Id, (Tag parentTag) => {
                parentLabel = parentTag.Label;
            })));

            yield return(StartCoroutine(ViRMA_APIController.GetHierarchyChildren(submittedQuery.Z.Id, (List <Tag> childTags) => {
                activeAxesLabels.SetAxisLabsls("Z", submittedQuery.Z.Id, submittedQuery.Z.Type, parentLabel, childTags);
            })));
        }

        // // global style for propety blocks
        Material transparentMaterial             = Resources.Load("Materials/BasicTransparent") as Material;
        MaterialPropertyBlock materialProperties = new MaterialPropertyBlock();
        float axisLineWidth = 0.005f;

        // origin point
        GameObject AxisOriginPoint = GameObject.CreatePrimitive(PrimitiveType.Cube);

        AxisOriginPoint.GetComponent <Renderer>().material = transparentMaterial;
        materialProperties.SetColor("_Color", new Color32(0, 0, 0, 255));
        AxisOriginPoint.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
        AxisOriginPoint.name = "AxisOriginPoint";
        AxisOriginPoint.transform.position   = Vector3.zero;
        AxisOriginPoint.transform.localScale = Vector3.one * 0.5f;
        AxisOriginPoint.transform.parent     = cellsandAxesWrapper.transform;

        // add origin block to all axis object lists
        axisXPointObjs.Add(AxisOriginPoint);
        axisYPointObjs.Add(AxisOriginPoint);
        axisZPointObjs.Add(AxisOriginPoint);

        // x axis points
        if (activeAxesLabels.X != null)
        {
            materialProperties.SetColor("_Color", ViRMA_Colors.axisFadeRed);
            for (int i = 0; i < activeAxesLabels.X.Labels.Count; i++)
            {
                // create gameobject to represent axis point
                GameObject axisXPoint = GameObject.CreatePrimitive(PrimitiveType.Cube);
                axisXPoint.GetComponent <Renderer>().material = transparentMaterial;
                axisXPoint.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
                axisXPoint.name = "AxisXPoint_" + i;
                axisXPoint.transform.position   = new Vector3(i + 1, 0, 0) * (defaultCellSpacingRatio + 1);
                axisXPoint.transform.localScale = Vector3.one * 0.5f;
                axisXPoint.transform.parent     = cellsandAxesWrapper.transform;
                axisXPoint.AddComponent <ViRMA_AxisPoint>().x = true;

                // apply metadata to axis point
                ViRMA_AxisPoint axisPoint = axisXPoint.GetComponent <ViRMA_AxisPoint>();
                axisPoint.axisId         = activeAxesLabels.X.Id;
                axisPoint.axisLabel      = activeAxesLabels.X.Label;
                axisPoint.axisType       = activeAxesLabels.X.Type;
                axisPoint.axisPointLabel = activeAxesLabels.X.Labels[i].Label;
                axisPoint.axisPointId    = activeAxesLabels.X.Labels[i].Id;

                // add gameobject to list
                axisXPointObjs.Add(axisXPoint);

                // x axis roll up axis point
                if (i == activeAxesLabels.X.Labels.Count - 1)
                {
                    GameObject axisXPointRollUp = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    axisXPointRollUp.GetComponent <Renderer>().material = transparentMaterial;
                    axisXPointRollUp.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
                    axisXPointRollUp.name = "AxisXPoint_RollUp";
                    axisXPointRollUp.transform.position = new Vector3(i + 2, 0, 0) * (defaultCellSpacingRatio + 1);
                    axisXPointRollUp.transform.parent   = cellsandAxesWrapper.transform;
                    axisXPointRollUp.AddComponent <ViRMA_RollUpPoint>().x         = true;
                    axisXPointRollUp.GetComponent <ViRMA_RollUpPoint>().axisId    = activeAxesLabels.X.Id;
                    axisXPointRollUp.GetComponent <ViRMA_RollUpPoint>().axisLabel = activeAxesLabels.X.Label;
                    axisXPointRollUp.GetComponent <ViRMA_RollUpPoint>().axisType  = activeAxesLabels.X.Type;
                }
            }

            // x axis line
            if (axisXPointObjs.Count > 2)
            {
                GameObject AxisXLineObj = new GameObject("AxisXLine");
                axisXLine = AxisXLineObj.AddComponent <LineRenderer>();
                axisXLine.GetComponent <Renderer>().material = transparentMaterial;
                axisXLine.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
                axisXLine.positionCount = 2;
                axisXLine.startWidth    = axisLineWidth;
                axisXLine.endWidth      = axisLineWidth;
            }
        }

        // y axis points
        if (activeAxesLabels.Y != null)
        {
            materialProperties.SetColor("_Color", ViRMA_Colors.axisFadeGreen);
            for (int i = 0; i < activeAxesLabels.Y.Labels.Count; i++)
            {
                // create gameobject to represent axis point
                GameObject axisYPoint = GameObject.CreatePrimitive(PrimitiveType.Cube);
                axisYPoint.GetComponent <Renderer>().material = transparentMaterial;
                axisYPoint.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
                axisYPoint.name = "AxisYPoint_" + i;
                axisYPoint.transform.position   = new Vector3(0, i + 1, 0) * (defaultCellSpacingRatio + 1);
                axisYPoint.transform.localScale = Vector3.one * 0.5f;
                axisYPoint.transform.parent     = cellsandAxesWrapper.transform;
                axisYPoint.AddComponent <ViRMA_AxisPoint>().y = true;

                // apply metadata to axis point
                ViRMA_AxisPoint axisPoint = axisYPoint.GetComponent <ViRMA_AxisPoint>();
                axisPoint.axisId         = activeAxesLabels.Y.Id;
                axisPoint.axisLabel      = activeAxesLabels.Y.Label;
                axisPoint.axisType       = activeAxesLabels.Y.Type;
                axisPoint.axisPointLabel = activeAxesLabels.Y.Labels[i].Label;
                axisPoint.axisPointId    = activeAxesLabels.Y.Labels[i].Id;

                // add gameobject to list
                axisYPointObjs.Add(axisYPoint);

                // y axis roll up axis point
                if (i == activeAxesLabels.Y.Labels.Count - 1)
                {
                    GameObject axisYPointRollUp = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    axisYPointRollUp.GetComponent <Renderer>().material = transparentMaterial;
                    axisYPointRollUp.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
                    axisYPointRollUp.name = "AxisYPoint_RollUp";
                    axisYPointRollUp.transform.position = new Vector3(0, i + 2, 0) * (defaultCellSpacingRatio + 1);
                    axisYPointRollUp.transform.parent   = cellsandAxesWrapper.transform;
                    axisYPointRollUp.AddComponent <ViRMA_RollUpPoint>().y         = true;
                    axisYPointRollUp.GetComponent <ViRMA_RollUpPoint>().axisId    = activeAxesLabels.Y.Id;
                    axisYPointRollUp.GetComponent <ViRMA_RollUpPoint>().axisLabel = activeAxesLabels.Y.Label;
                    axisYPointRollUp.GetComponent <ViRMA_RollUpPoint>().axisType  = activeAxesLabels.Y.Type;
                }
            }

            // y axis line
            if (axisYPointObjs.Count > 2)
            {
                GameObject AxisYLineObj = new GameObject("AxisYLine");
                axisYLine = AxisYLineObj.AddComponent <LineRenderer>();
                axisYLine.GetComponent <Renderer>().material = transparentMaterial;
                axisYLine.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
                axisYLine.positionCount = 2;
                axisYLine.startWidth    = axisLineWidth;
                axisYLine.endWidth      = axisLineWidth;
            }
        }

        // z axis points
        if (activeAxesLabels.Z != null)
        {
            materialProperties.SetColor("_Color", ViRMA_Colors.axisFadeBlue);
            for (int i = 0; i < activeAxesLabels.Z.Labels.Count; i++)
            {
                // create gameobject to represent axis point
                GameObject axisZPoint = GameObject.CreatePrimitive(PrimitiveType.Cube);
                axisZPoint.GetComponent <Renderer>().material = transparentMaterial;
                axisZPoint.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
                axisZPoint.name = "AxisZPoint_" + i;
                axisZPoint.transform.position   = new Vector3(0, 0, i + 1) * (defaultCellSpacingRatio + 1);
                axisZPoint.transform.localScale = Vector3.one * 0.5f;
                axisZPoint.transform.parent     = cellsandAxesWrapper.transform;
                axisZPoint.AddComponent <ViRMA_AxisPoint>().z = true;

                // apply metadata to axis point
                ViRMA_AxisPoint axisPoint = axisZPoint.GetComponent <ViRMA_AxisPoint>();
                axisPoint.axisId         = activeAxesLabels.Z.Id;
                axisPoint.axisLabel      = activeAxesLabels.Z.Label;
                axisPoint.axisType       = activeAxesLabels.Z.Type;
                axisPoint.axisPointLabel = activeAxesLabels.Z.Labels[i].Label;
                axisPoint.axisPointId    = activeAxesLabels.Z.Labels[i].Id;

                // add gameobject to list
                axisZPointObjs.Add(axisZPoint);

                // z axis roll up axis point
                if (i == activeAxesLabels.Z.Labels.Count - 1)
                {
                    GameObject axisZPointRollUp = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    axisZPointRollUp.GetComponent <Renderer>().material = transparentMaterial;
                    axisZPointRollUp.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
                    axisZPointRollUp.name = "AxisYPoint_RollUp";
                    axisZPointRollUp.transform.position = new Vector3(0, 0, i + 2) * (defaultCellSpacingRatio + 1);
                    axisZPointRollUp.transform.parent   = cellsandAxesWrapper.transform;
                    axisZPointRollUp.AddComponent <ViRMA_RollUpPoint>().z         = true;
                    axisZPointRollUp.GetComponent <ViRMA_RollUpPoint>().axisId    = activeAxesLabels.Z.Id;
                    axisZPointRollUp.GetComponent <ViRMA_RollUpPoint>().axisLabel = activeAxesLabels.Z.Label;
                    axisZPointRollUp.GetComponent <ViRMA_RollUpPoint>().axisType  = activeAxesLabels.Z.Type;
                }
            }

            // z axis line
            if (axisZPointObjs.Count > 2)
            {
                GameObject AxisZLineObj = new GameObject("AxisZLine");
                axisZLine = AxisZLineObj.AddComponent <LineRenderer>();
                axisZLine.GetComponent <Renderer>().material = transparentMaterial;
                axisZLine.GetComponent <Renderer>().SetPropertyBlock(materialProperties);
                axisZLine.positionCount = 2;
                axisZLine.startWidth    = axisLineWidth;
                axisZLine.endWidth      = axisLineWidth;
            }
        }
    }
Beispiel #10
0
    private void GenerateTexturesAndTextureArrays(List <Cell> cellData)
    {
        if (cellData.Count > 0)
        {
            //float before = Time.realtimeSinceStartup; // testing

            // make a list of all the unique image textures present in the current query
            List <KeyValuePair <string, Texture2D> > uniqueTextures = new List <KeyValuePair <string, Texture2D> >();
            foreach (var newCell in cellData)
            {
                if (!newCell.Filtered)
                {
                    int index = uniqueTextures.FindIndex(a => a.Key == newCell.ImageName);
                    if (index == -1)
                    {
                        //byte[] imageBytes = File.ReadAllBytes(ViRMA_APIController.imagesDirectory + newCell.ImageName);
                        byte[] imageBytes = new byte[0];
                        try
                        {
                            imageBytes           = File.ReadAllBytes(ViRMA_APIController.imagesDirectory + newCell.ImageName);
                            newCell.ImageTexture = ViRMA_APIController.ConvertImageFromDDS(imageBytes); // dds stuff
                            //newCell.ImageTexture = ViRMA_APIController.ConvertImageFromJPEG(imageBytes); // jpg stuff
                            KeyValuePair <string, Texture2D> uniqueTexture = new KeyValuePair <string, Texture2D>(newCell.ImageName, newCell.ImageTexture);
                            uniqueTextures.Add(uniqueTexture);
                        }
                        catch (FileNotFoundException e)
                        {
                            Debug.LogError(e.Message);
                            newCell.Filtered = true;
                        }
                    }
                    else
                    {
                        newCell.ImageTexture = uniqueTextures[index].Value;
                    }
                }
            }

            // calculate the number of texture arrays needed based on the size of the first texture in the list
            int textureWidth        = uniqueTextures[0].Value.width;       // e.g. 1024 or 684
            int textureHeight       = uniqueTextures[0].Value.height;      // e.g. 765 or 485
            int maxTextureArraySize = SystemInfo.maxTextureSize;           // e.g. 16384 (most GPUs)
            int maxTexturesPerArray = maxTextureArraySize / textureHeight; // e.g. 22 or 33
            int totalTextureArrays  = uniqueTextures.Count / maxTexturesPerArray + 1;

            for (int i = 0; i < totalTextureArrays; i++)
            {
                //Debug.Log("----------------- " + i + " -----------------"); // debugging

                if (i != totalTextureArrays - 1)
                {
                    Material  newtextureArrayMaterial = new Material(Resources.Load(cellMaterial) as Material);
                    Texture2D newTextureArray         = new Texture2D(textureWidth, textureHeight * maxTexturesPerArray, TextureFormat.DXT1, false); // dds stuff
                    //Texture2D newTextureArray = new Texture2D(textureWidth, textureHeight * maxTexturesPerArray, TextureFormat.RGB24, false); // jpg stuff
                    for (int j = 0; j < maxTexturesPerArray; j++)
                    {
                        int       uniqueTextureIndex = j + maxTexturesPerArray * i;
                        Texture2D targetTexture      = uniqueTextures[uniqueTextureIndex].Value;
                        if (targetTexture.width != textureWidth || targetTexture.height != textureHeight)
                        {
                            Debug.LogError("Texture " + uniqueTextures[uniqueTextureIndex].Key + " is not " + textureWidth + " x " + textureHeight + " and so will not fit properly in the texture array!");
                        }
                        Graphics.CopyTexture(targetTexture, 0, 0, 0, 0, targetTexture.width, targetTexture.height, newTextureArray, 0, 0, 0, targetTexture.height * j);

                        // Debug.Log(j + " | " + uniqueTextureIndex); // debugging

                        foreach (var cellDataObj in this.cellData)
                        {
                            if (cellDataObj.ImageName == uniqueTextures[uniqueTextureIndex].Key)
                            {
                                cellDataObj.TextureArrayId       = j;
                                cellDataObj.TextureArrayMaterial = newtextureArrayMaterial;
                                cellDataObj.TextureArraySize     = maxTexturesPerArray;
                            }
                        }
                    }
                    // newTextureArray.Compress(false);
                    newtextureArrayMaterial.mainTexture = newTextureArray;
                }
                else
                {
                    Material  newtextureArrayMaterial = new Material(Resources.Load(cellMaterial) as Material);
                    int       lastTextureArraySize    = uniqueTextures.Count - (maxTexturesPerArray * (totalTextureArrays - 1));
                    Texture2D newTextureArray         = new Texture2D(textureWidth, textureHeight * lastTextureArraySize, TextureFormat.DXT1, false); // dds stuff
                    //Texture2D newTextureArray = new Texture2D(textureWidth, textureHeight * lastTextureArraySize, TextureFormat.RGB24, false); // jpg stuff
                    for (int j = 0; j < lastTextureArraySize; j++)
                    {
                        int       uniqueTextureIndex = j + maxTexturesPerArray * i;
                        Texture2D targetTexture      = uniqueTextures[uniqueTextureIndex].Value;
                        if (targetTexture.width != textureWidth || targetTexture.height != textureHeight)
                        {
                            Debug.LogError("Texture " + uniqueTextures[uniqueTextureIndex].Key + " is not " + textureWidth + " x " + textureHeight + " and so will not fit properly in the texture array!");
                        }
                        Graphics.CopyTexture(targetTexture, 0, 0, 0, 0, targetTexture.width, targetTexture.height, newTextureArray, 0, 0, 0, targetTexture.height * j);

                        // Debug.Log(j + " | " + uniqueTextureIndex); // debugging

                        foreach (var cellDataObj in this.cellData)
                        {
                            if (cellDataObj.ImageName == uniqueTextures[uniqueTextureIndex].Key)
                            {
                                cellDataObj.TextureArrayId       = j;
                                cellDataObj.TextureArrayMaterial = newtextureArrayMaterial;
                                cellDataObj.TextureArraySize     = lastTextureArraySize;
                            }
                        }
                    }
                    // newTextureArray.Compress(false);
                    newtextureArrayMaterial.mainTexture = newTextureArray;
                }
            }

            //float after = Time.realtimeSinceStartup; // testing
            // Debug.Log("TEXTURE PARSE TIME ~ ~ ~ ~ ~ " + (after - before).ToString("n3") + " seconds"); // testing
        }
    }
Beispiel #11
0
    // time picker

    private IEnumerator SetupTimePicker()
    {
        // current targset time picker tagsets
        List <string> timeTagsets = new List <string> {
            "Day of week (string)", "Month (string)", "Year", "Hour", "Day within month"
        };

        // get all time tagsets corresponding to list above
        List <Tag> timeTagsetsData = new List <Tag>();

        yield return(StartCoroutine(ViRMA_APIController.GetTagset("", (tagsetsData) => {
            for (int i = tagsetsData.Count - 1; i > -1; i--)
            {
                if (!timeTagsets.Contains(tagsetsData[i].Label))
                {
                    tagsetsData.RemoveAt(i);
                }
            }
            timeTagsetsData = tagsetsData;
        })));

        // populate tagsets with their children
        foreach (Tag tagsetData in timeTagsetsData)
        {
            yield return(StartCoroutine(ViRMA_APIController.GetTagset(tagsetData.Id.ToString(), (tagData) => {
                tagsetData.Children = tagData;
            })));
        }

        foreach (Tag timeTagset in timeTagsetsData)
        {
            // generate day of the week options
            if (timeTagset.Label == "Day of week (string)")
            {
                foreach (Transform weekdayObj in ui_weekdays.transform)
                {
                    ViRMA_UiElement uiElement = weekdayObj.GetComponent <ViRMA_UiElement>();
                    allTimeOptions.Add(uiElement);

                    string weekdayLabel = weekdayObj.GetComponentInChildren <Text>().text;
                    foreach (Tag weekdayTag in timeTagset.Children)
                    {
                        if (weekdayTag.Label.Substring(0, 3) == weekdayLabel)
                        {
                            uiElement.buttonData = weekdayTag;
                            weekdayObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement));
                        }
                    }
                }
            }

            // generate hour options
            if (timeTagset.Label == "Hour")
            {
                foreach (Transform hourObj in ui_hours.transform)
                {
                    ViRMA_UiElement uiElement = hourObj.GetComponent <ViRMA_UiElement>();
                    allTimeOptions.Add(uiElement);
                    string hourLabel = hourObj.GetComponentInChildren <Text>().text;
                    int    hour      = int.Parse(hourLabel.Substring(0, hourLabel.IndexOf(":")));
                    foreach (Tag hourTag in timeTagset.Children)
                    {
                        if (hourTag.Label == hour.ToString())
                        {
                            uiElement.buttonData = hourTag;
                            hourObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement));
                        }
                    }
                }
            }

            // generate date options
            if (timeTagset.Label == "Day within month")
            {
                foreach (Transform dateObj in ui_dates.transform)
                {
                    ViRMA_UiElement uiElement = dateObj.GetComponent <ViRMA_UiElement>();
                    allTimeOptions.Add(uiElement);
                    string dateLabel = dateObj.GetComponentInChildren <Text>().text;
                    int    date      = int.Parse(dateLabel);
                    foreach (Tag dateTag in timeTagset.Children)
                    {
                        if (dateTag.Label == date.ToString())
                        {
                            uiElement.buttonData = dateTag;
                            dateObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement));
                        }
                    }
                }
            }

            // generate month options
            if (timeTagset.Label == "Month (string)")
            {
                foreach (Transform monthObj in ui_months.transform)
                {
                    ViRMA_UiElement uiElement = monthObj.GetComponent <ViRMA_UiElement>();
                    allTimeOptions.Add(uiElement);
                    string monthLabel = monthObj.GetComponentInChildren <Text>().text;
                    foreach (Tag monthTag in timeTagset.Children)
                    {
                        string shortMonthLabel = monthTag.Label.Substring(0, 3);
                        if (shortMonthLabel == monthLabel)
                        {
                            uiElement.buttonData = monthTag;
                            monthObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement));
                        }
                    }
                }
            }

            // generate year options
            if (timeTagset.Label == "Year")
            {
                foreach (Transform yearObj in ui_years.transform)
                {
                    ViRMA_UiElement uiElement = yearObj.GetComponent <ViRMA_UiElement>();
                    allTimeOptions.Add(uiElement);
                    string yearLabel = yearObj.GetComponentInChildren <Text>().text;
                    foreach (Tag yearTag in timeTagset.Children)
                    {
                        if (yearLabel == yearTag.Label)
                        {
                            uiElement.buttonData = yearTag;
                            yearObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement));
                        }
                    }
                }
            }

            // if any time options do not exist in the DB, then reflect that in the button style
            foreach (ViRMA_UiElement timeOption in allTimeOptions)
            {
                if (timeOption.buttonData == null)
                {
                    timeOption.GenerateBtnDefaults(ViRMA_Colors.lightGrey, Color.white, true);
                }
            }
        }
    }
Beispiel #12
0
    // direct filters
    public void FetchDirectFilterMetadata()
    {
        GameObject directFilterPrefab = Resources.Load("Prefabs/DirectFilterOptn") as GameObject;

        Transform directFilterParent = ui_directFilers.GetComponentInChildren <ViRMA_UIScrollable>().transform.GetChild(0);

        foreach (Transform child in directFilterParent)
        {
            Destroy(child.gameObject);
        }
        directFilterParent.DetachChildren();

        foreach (Query.Filter activeFilter in globals.queryController.activeFilters)
        {
            if (activeFilter.Type == "node")
            {
                int targetId = activeFilter.Ids[0];
                StartCoroutine(ViRMA_APIController.GetHierarchyTag(targetId, (tagData) => {
                    GameObject directFilterObj = Instantiate(directFilterPrefab, directFilterParent);
                    directFilterObj.GetComponent <ViRMA_DirectFilterOption>().directFilterData = tagData;
                    directFilterObj.GetComponent <ViRMA_DirectFilterOption>().labelText.text   = tagData.Label;
                    directFilterObj.GetComponent <ViRMA_DirectFilterOption>().filterType       = "node";
                }));
            }
            else if (activeFilter.Type == "tag")
            {
                int    parentIdIndex = activeFilter.FilterId.IndexOf("_");
                string parentId      = activeFilter.FilterId.Substring(parentIdIndex + 1);
                StartCoroutine(ViRMA_APIController.GetTagset(parentId, (tagsetData) => {
                    foreach (Tag tagData in tagsetData)
                    {
                        foreach (int id in activeFilter.Ids)
                        {
                            if (tagData.Id == id)
                            {
                                GameObject directFilterObj = Instantiate(directFilterPrefab, directFilterParent);
                                directFilterObj.GetComponent <ViRMA_DirectFilterOption>().filterType       = "tag";
                                directFilterObj.GetComponent <ViRMA_DirectFilterOption>().directFilterData = tagData;

                                string adjustLabel = tagData.Label;

                                // adjust appearance of hour tags as direct filters
                                if (tagData.Parent.Label == "Hour")
                                {
                                    if (tagData.Label.Length == 1)
                                    {
                                        adjustLabel = "0" + tagData.Label + ":00";
                                    }
                                    else
                                    {
                                        adjustLabel = tagData.Label + ":00";
                                    }
                                }

                                // adjust the appearance of date tags as direct filters
                                if (tagData.Parent.Label == "Day within month")
                                {
                                    if (tagData.Label == "1")
                                    {
                                        adjustLabel = "1st";
                                    }
                                    else if (tagData.Label == "2")
                                    {
                                        adjustLabel = "2nd";
                                    }
                                    else if (tagData.Label == "3")
                                    {
                                        adjustLabel = "3rd";
                                    }
                                    else
                                    {
                                        adjustLabel = tagData.Label + "th";
                                    }
                                }

                                directFilterObj.GetComponent <ViRMA_DirectFilterOption>().labelText.text = adjustLabel;
                            }
                        }
                    }
                }));
            }
        }
    }
Beispiel #13
0
    // deprecated
    public void LoadTimelineData(GameObject submittedCell)
    {
        isContextTimeline = false;

        if (submittedCell.GetComponent <ViRMA_Cell>())
        {
            // deep clone query filters for timeline API call
            List <Query.Filter> cellFiltersForTimeline = ObjectExtensions.Copy(globals.queryController.activeFilters);

            // get cell data and currently active viz axes labels
            timelineCellData = submittedCell.GetComponent <ViRMA_Cell>().thisCellData;
            activeVizLabels  = globals.vizController.activeAxesLabels;

            // if X axis exits, find location of submitted call on it and grab data
            if (activeVizLabels.X != null)
            {
                int    cellXPosition = (int)timelineCellData.Coordinates.x - 1;
                int    cellXAxisId   = activeVizLabels.X.Labels[cellXPosition].Id;
                string cellXAxisType = activeVizLabels.X.Type;

                Query.Filter projFilterX = new Query.Filter(cellXAxisType, new List <int>()
                {
                    cellXAxisId
                });
                cellFiltersForTimeline.Add(projFilterX);
            }

            // if Y axis exits, find location of submitted call on it and grab data
            if (activeVizLabels.Y != null)
            {
                int    cellYPosition = (int)timelineCellData.Coordinates.y - 1;
                int    cellYAxisId   = activeVizLabels.Y.Labels[cellYPosition].Id;
                string cellYAxisType = activeVizLabels.Y.Type;

                Query.Filter projFilterY = new Query.Filter(cellYAxisType, new List <int>()
                {
                    cellYAxisId
                });
                cellFiltersForTimeline.Add(projFilterY);
            }

            // if Z axis exits, find location of submitted call on it and grab data
            if (activeVizLabels.Z != null)
            {
                int    cellZPosition = (int)timelineCellData.Coordinates.z - 1;
                int    cellZAxisId   = activeVizLabels.Z.Labels[cellZPosition].Id;
                string cellZAxisType = activeVizLabels.Z.Type;

                Query.Filter projFilterZ = new Query.Filter(cellZAxisType, new List <int>()
                {
                    cellZAxisId
                });
                cellFiltersForTimeline.Add(projFilterZ);
            }

            // get timeline image data from server and load it
            StartCoroutine(ViRMA_APIController.GetTimeline(cellFiltersForTimeline, (results) => {
                cellContentResults = results;

                if (cellContentResults.Count > 0)
                {
                    if (cellContentResults.Count >= resultsRenderSize)
                    {
                        if (cellContentResults.Count % resultsRenderSize == 0)
                        {
                            totalTimeLineSections = (cellContentResults.Count / resultsRenderSize);
                        }
                        else
                        {
                            totalTimeLineSections = (cellContentResults.Count / resultsRenderSize) + 1;
                        }
                    }
                    else
                    {
                        totalTimeLineSections = 1;
                    }

                    LoadTimelineSection(0, totalTimeLineSections);
                }
            }));
        }
    }
Beispiel #14
0
    public void LoadCellContentTimelineData(GameObject submittedCell)
    {
        isContextTimeline = false;

        if (submittedCell.GetComponent <ViRMA_Cell>())
        {
            Query cellContentQuery = new Query();
            cellContentQuery.Filters = ObjectExtensions.Copy(globals.queryController.activeFilters);

            // get cell data and currently active viz axes labels
            timelineCellData = submittedCell.GetComponent <ViRMA_Cell>().thisCellData;
            activeVizLabels  = globals.vizController.activeAxesLabels;

            // if X axis exits, find location of submitted call on it and grab data
            if (activeVizLabels.X != null)
            {
                int    cellXPosition = (int)timelineCellData.Coordinates.x - 1;
                int    cellXAxisId   = activeVizLabels.X.Labels[cellXPosition].Id;
                string cellXAxisType = activeVizLabels.X.Type;

                cellContentQuery.SetAxis("X", cellXAxisId, cellXAxisType);
            }

            // if Y axis exits, find location of submitted call on it and grab data
            if (activeVizLabels.Y != null)
            {
                int    cellYPosition = (int)timelineCellData.Coordinates.y - 1;
                int    cellYAxisId   = activeVizLabels.Y.Labels[cellYPosition].Id;
                string cellYAxisType = activeVizLabels.Y.Type;

                cellContentQuery.SetAxis("Y", cellYAxisId, cellYAxisType);
            }

            // if Z axis exits, find location of submitted call on it and grab data
            if (activeVizLabels.Z != null)
            {
                int    cellZPosition = (int)timelineCellData.Coordinates.z - 1;
                int    cellZAxisId   = activeVizLabels.Z.Labels[cellZPosition].Id;
                string cellZAxisType = activeVizLabels.Z.Type;

                cellContentQuery.SetAxis("Z", cellZAxisId, cellZAxisType);
            }

            // get cell content image data from server and load it
            StartCoroutine(ViRMA_APIController.GetCellContents(cellContentQuery, (results) => {
                cellContentResults = results;

                if (cellContentResults.Count > 0)
                {
                    if (cellContentResults.Count >= resultsRenderSize)
                    {
                        if (cellContentResults.Count % resultsRenderSize == 0)
                        {
                            totalTimeLineSections = (cellContentResults.Count / resultsRenderSize);
                        }
                        else
                        {
                            totalTimeLineSections = (cellContentResults.Count / resultsRenderSize) + 1;
                        }
                    }
                    else
                    {
                        totalTimeLineSections = 1;
                    }

                    LoadTimelineSection(0, totalTimeLineSections);
                }
            }));
        }
    }
Beispiel #15
0
    private void SubmitKey(Button key)
    {
        string buttonName = key.gameObject.name;

        string submittedChar = "";
        if (key.GetComponentInChildren<Text>())
        {
            submittedChar = key.GetComponentInChildren<Text>().text;
        } 

        if (buttonName == "SUBMIT")
        {
            if (typedWordString.Length > 0)
            {
                if (activeQueryCoroutine != null)
                {
                    StopCoroutine(activeQueryCoroutine);
                }

                dimExQueryLoading = true;
                key.enabled = false;
                StartCoroutine(globals.dimExplorer.ClearDimExplorer());           

                activeQueryCoroutine = StartCoroutine(ViRMA_APIController.SearchHierachies(typedWordString.ToLower(), (nodes) => {
                    StartCoroutine(globals.dimExplorer.LoadDimExplorer(nodes));
                    activeQueryCoroutine = null;
                    key.enabled = true;
                }));
            }      
        }
        else if (buttonName == "CLOSE")
        {

            if (activeQueryCoroutine != null)
            {
                StopCoroutine(activeQueryCoroutine);
            }
            dimExQueryLoading = false;
            ToggleDimExKeyboard(false);
        }
        else if (buttonName == "BACKSPACE")
        {
            if (typedWordString.Length > 0)
            {
                typedWordString = typedWordString.Substring(0, typedWordString.Length - 1);
            }       
        }
        else if (buttonName == "CLEAR")
        {
            typedWordString = "";
        }
        else if (buttonName == "MOVE")
        {
            handInteractingWithKeyboard = key.GetComponent<ViRMA_UiElement>().handINteractingWithUi;
            keyboardMoving = true;
        }
        else if (buttonName == "SPACE")
        {
            if (typedWordString.Length > 0)
            {
                if (typedWordString.Substring(typedWordString.Length - 1) != " ")
                {
                    typedWordString += " ";
                }
            }             
        }
        else
        {
            typedWordString += submittedChar;
        }

        typedWordTMP.text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(typedWordString.ToLower());
    }
Beispiel #16
0
    private IEnumerator GetTraversedHierarchyNodes(Tag submittedTagData)
    {
        dimensionExpLorerLoaded = false;

        // assign parent groupings
        GameObject             parentGroupObj = hoveredTagBtn.transform.parent.GetComponent <ViRMA_DimExplorerGroup>().parentDimExGrp;
        ViRMA_DimExplorerGroup parentGroup    = parentGroupObj.GetComponent <ViRMA_DimExplorerGroup>();
        Tag parentTagData = new Tag();


        // assign children groupings
        GameObject             childrenGroupObj = hoveredTagBtn.transform.parent.GetComponent <ViRMA_DimExplorerGroup>().childrenDimExGrp;
        ViRMA_DimExplorerGroup childrenGroup    = childrenGroupObj.GetComponent <ViRMA_DimExplorerGroup>();
        List <Tag>             childrenTagData  = new List <Tag>();


        // assign siblings groupings
        GameObject             siblingsGroupObj = hoveredTagBtn.transform.parent.GetComponent <ViRMA_DimExplorerGroup>().siblingsDimExGrp;
        ViRMA_DimExplorerGroup siblingsGroup    = siblingsGroupObj.GetComponent <ViRMA_DimExplorerGroup>();
        List <Tag>             siblingsTagData  = new List <Tag>();


        // fetch and wait for parent data
        yield return(StartCoroutine(ViRMA_APIController.GetHierarchyParent(submittedTagData.Id, (response) => {
            parentTagData = response;
        })));

        // fetch and wait for children data
        yield return(StartCoroutine(ViRMA_APIController.GetHierarchyChildren(submittedTagData.Id, (response) => {
            childrenTagData = response;
        })));

        // fetch and wait for sibling data
        if (parentTagData.Id == 0)
        {
            // if the parent id is zero, it means we're at the top of hierarchy so replace normal siblings with previous parent instead
            yield return(StartCoroutine(ViRMA_APIController.GetHierarchyParent(childrenTagData[0].Id, (response) => {
                siblingsTagData = new List <Tag>()
                {
                    response
                };
            })));
        }
        else
        {
            // if parent isn't zero, then just get the normal siblings like always
            yield return(StartCoroutine(ViRMA_APIController.GetHierarchyChildren(parentTagData.Id, (response) => {
                siblingsTagData = response;
            })));
        }

        // reload parent dim ex group
        if (parentTagData.Label == null)
        {
            parentGroup.ClearDimExplorerGroup();
        }
        else
        {
            parentGroup.tagsInGroup = new List <Tag>()
            {
                parentTagData
            };
            StartCoroutine(parentGroup.LoadDimExplorerGroup());
        }

        // reload childen dim ex grouo
        if (childrenTagData.Count < 1)
        {
            childrenGroup.ClearDimExplorerGroup();
        }
        else
        {
            childrenGroup.tagsInGroup = childrenTagData;
            StartCoroutine(childrenGroup.LoadDimExplorerGroup());
        }

        // reload sibling dim ex grouo
        if (siblingsTagData.Count < 1)
        {
            siblingsGroup.ClearDimExplorerGroup();
        }
        else
        {
            siblingsGroup.searchedForTagData = submittedTagData;
            siblingsGroup.tagsInGroup        = siblingsTagData;
            StartCoroutine(siblingsGroup.LoadDimExplorerGroup());
        }

        dimensionExpLorerLoaded = true;
    }