Exemple #1
0
        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);
        }