public void EnableLegendToggleFilter(GameObject legendGameObject) { HoloToolkit.Examples.InteractiveElements.InteractiveSet checkBoxSet = legendGameObject.GetComponent <HoloToolkit.Examples.InteractiveElements.InteractiveSet>(); if (checkBoxSet == null) { return; } checkBoxSet.SelectedIndices.Clear(); string fieldName = ""; List <string> domain = new List <string>(); // Go through each checkbox and set them to active: int checkBoxIndex = 0; for (int i = 0; i < legendGameObject.transform.childCount; i++) { Transform child = legendGameObject.transform.GetChild(i); if (child.GetComponent <LegendValue>() != null) { fieldName = child.GetComponent <LegendValue>().dataFieldName; domain.Add(child.GetComponent <LegendValue>().categoryName); Transform box = child.Find("Title/CheckBox"); if (box != null) { box.gameObject.SetActive(true); HoloToolkit.Examples.InteractiveElements.InteractiveToggle toggle = box.gameObject.GetComponent <HoloToolkit.Examples.InteractiveElements.InteractiveToggle>(); if (toggle != null) { checkBoxSet.Interactives.Add(toggle); checkBoxSet.SelectedIndices.Add(checkBoxIndex); checkBoxIndex++; } } } } // Add the call back function to update marks visibility when any checkbox is updated. checkBoxSet.OnSelectionEvents.AddListener(LegendToggleFilterUpdated); domains.Add(fieldName, domain); // Update the results vector int numMarks = targetVis.markInstances.Count; List <bool> results = new List <bool>(new bool[numMarks]); for (int j = 0; j < results.Count; j++) { results[j] = true; } filterResults.Add(fieldName, results); }
private void UpdateFilterResultsForCategoryFromLegend(GameObject legendObject, string field, string category) { if (legendObject == null) { return; } List <string> visibleCategories = new List <string>(); for (int i = 0; i < legendObject.transform.childCount; i++) { LegendValue legendValue = legendObject.transform.GetChild(i).gameObject.GetComponent <LegendValue>(); if (legendValue != null) { Transform box = legendObject.transform.GetChild(i).Find("Title/CheckBox"); HoloToolkit.Examples.InteractiveElements.InteractiveToggle toggle = box.gameObject.GetComponent <HoloToolkit.Examples.InteractiveElements.InteractiveToggle>(); // BUG: HasSelection is not up-to-date upon calling this function!!! if (toggle.HasSelection) { visibleCategories.Add(legendValue.categoryName); } } } Debug.Log("Updating filter results for field, category " + field + ", " + category); List <bool> res = filterResults[field]; for (int b = 0; b < res.Count; b++) { if (visibleCategories.Contains(targetVis.markInstances[b].GetComponent <Mark>().datum[field])) { res[b] = true; } else { res[b] = false; } } filterResults[field] = res; if (targetVis.GetIsLinked()) { for (int i = 0; i < DxRVisObjects.Length; i++) { if (DxRVisObjects[i].GetComponent <Vis>().GetIsLinked()) { if (DxRVisObjects[i].GetComponent <Vis>().GetDataName() == targetVis.GetDataName()) { GameObject DxRInteraction = DxRVisObjects[i].transform.Find("DxRInteractions").gameObject; List <bool> t_res = new List <bool>(new bool[res.Count]); if (!DxRInteraction.GetComponent <Interactions>().filterResults.ContainsKey(field)) { DxRInteraction.GetComponent <Interactions>().filterResults.Add(field, t_res); } for (int b = 0; b < t_res.Count; b++) { if (visibleCategories.Contains(DxRVisObjects[i].GetComponent <Vis>().markInstances[b].GetComponent <Mark>().datum[field])) { t_res[b] = true; } else { t_res[b] = false; } } DxRInteraction.GetComponent <Interactions>().filterResults[field] = t_res; DxRVisObjects[i].GetComponent <Vis>().FiltersUpdated(); } } } } // if (targetVis.GetIsLinked()) Synchronize(field); }