private void EnableThresholdFilter(JSONNode axisSpecs, DxR.Scale scale) { Transform slider = gameObject.transform.Find("AxisLine/Slider"); slider.gameObject.SetActive(true); SetFilterLength(axisSpecs["length"].AsFloat); DxR.SliderGestureControlBothSide sliderControl = slider.GetComponent <DxR.SliderGestureControlBothSide>(); if (sliderControl == null) { return; } float domainMin = float.Parse(scale.domain[0]); float domainMax = float.Parse(scale.domain[1]); // TODO: Check validity of specs. sliderControl.SetSpan(domainMin, domainMax); sliderControl.SetSliderValue1(domainMin); sliderControl.SetSliderValue2(domainMax); slider.gameObject.name = dataField; interactionsObject.EnableAxisThresholdFilter(dataField); if (interactionsObject != null) { sliderControl.OnUpdateEvent.AddListener(interactionsObject.ThresholdFilterUpdated); } }
internal void AddThresholdFilter(JSONObject interactionSpecs) { GameObject thresholdFilterPrefab = Resources.Load("GUI/ThresholdFilter", typeof(GameObject)) as GameObject; if (thresholdFilterPrefab == null) { return; } GameObject thresholdFilterInstance = Instantiate(thresholdFilterPrefab, gameObject.transform); thresholdFilterInstance.transform.Find("ThresholdFilterLabel").gameObject.GetComponent <TextMesh>().text = interactionSpecs["field"].Value + ":"; thresholdFilterInstance.name = interactionSpecs["field"]; thresholdFilterInstance.transform.Find("ThresholdFilterMinLabel").gameObject.GetComponent <TextMesh>().text = interactionSpecs["domain"][0].Value; thresholdFilterInstance.transform.Find("ThresholdFilterMaxLabel").gameObject.GetComponent <TextMesh>().text = interactionSpecs["domain"][1].Value; DxR.SliderGestureControlBothSide sliderControl = thresholdFilterInstance.GetComponent <DxR.SliderGestureControlBothSide>(); if (sliderControl == null) { return; } float domainMin = float.Parse(interactionSpecs["domain"][0].Value); float domainMax = float.Parse(interactionSpecs["domain"][1].Value); // TODO: Check validity of specs. sliderControl.SetSpan(domainMin, domainMax); sliderControl.SetSliderValue1(domainMin); sliderControl.SetSliderValue2(domainMax); sliderControl.OnUpdateEvent.AddListener(ThresholdFilterUpdated); // 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(interactionSpecs["field"], results); thresholdFilterInstance.transform.Translate(0, -curYOffset / 2.0f, 0); curYOffset = curYOffset + (0.25f); }
public void ThresholdFilterUpdated() { GameObject selectedObject = EventSystem.current.currentSelectedGameObject; if (selectedObject == null) { return; } Debug.Log("Threshold updated"); string fieldName = ""; // If the selected object is not a slider, ignore. if (selectedObject.transform.Find("SliderBar") != null) { fieldName = selectedObject.name; } else if (selectedObject.name == "SliderBar") { fieldName = selectedObject.transform.parent.name; selectedObject = selectedObject.transform.parent.transform.gameObject; } else { return; } DxR.SliderGestureControlBothSide sliderControl = selectedObject.GetComponent <DxR.SliderGestureControlBothSide>(); if (sliderControl != null && targetVis != null) { // Update filter results for thresholded data field category. if (sliderControl.SliderValue1 < sliderControl.SliderValue2) { UpdateFilterResultsForThreshold(fieldName, sliderControl.SliderValue1, sliderControl.SliderValue2); } else { UpdateFilterResultsForThreshold(fieldName, sliderControl.SliderValue2, sliderControl.SliderValue1); } targetVis.FiltersUpdated(); Debug.Log("Filter updated! " + fieldName); } }