/// <summary> Show a simple text panel with the data point info </summary> /// <param name="triData"></param> public void ShowDataInspector(TriDataPoint triData) { string str = ""; str += "row, col #: " + triData.row + ", " + triData.col; if (triData.rowHeader != "") { str += "\nrow hdr: " + triData.rowHeader; } if (triData.colHeader != "") { str += "\ncol hdr : " + triData.colHeader; } str += "\n\n" + triData.heightValue.ToString("F3") + " - " + triData.heightLabel + "\n" + triData.topValue.ToString("F3") + " - " + triData.topLabel + "\n" + triData.sideValue.ToString("F3") + " - " + triData.sideLabel; if (showDataInspectorDesktop) { displayPanelHandler.Show(str); } if (showDataInspectorVR) { displayPanelVRHandler.Show(str); } }
/// <summary> /// Get TriDataPoint data object from a screen position, and optionally show UI features for the selected point. /// Returned object will have isValid field set true if valid. /// </summary> /// <param name="pointerPosition">Screen position, expected from mouse or touch</param> /// <param name="showDataIndicator">True to highlight the data column that's being inspected</param> /// <param name="showDataInspector">True to show data point info in UI</param> /// <returns>TriDataPoint. If not valid or graph not showing, returns empty TryDataPoint</returns> public TriDataPoint InspectDataAtScreenPosition(Vector3 pointerPosition) { if (!Graph.I.GraphIsShowing) { return(new TriDataPoint()); } TriDataPoint triData = GetDataAtScreenPosition(pointerPosition); UpdateVisualFeedback(triData); return(triData); }
public TriDataPoint InspectDataWithRay(Ray ray, bool showRay) { if (!Graph.I.GraphIsShowing) { return(new TriDataPoint()); } ; TriDataPoint triData = GetDataWithRay(ray, showRay); UpdateVisualFeedback(triData); return(triData); }
private TriDataPoint GetDataWithRay(Ray ray, bool showRay) { int row, col; if (!SelectWithRayUsingGridIntersection(ray, out row, out col, showRay)) { //Hide any ui elements Hide(); //Return empty data object, with isValid = false return(new TriDataPoint()); } TriDataPoint result = new TriDataPoint(row, col); //This will hold the data for the data variables at [row,col] return(result); }
/// <summary> /// Raycast from pointer position to data to get a data point. /// Check returned object 'isValid' property to test for success. /// </summary> /// <param name="pointerPosition"></param> /// <returns></returns> private TriDataPoint GetDataAtScreenPosition(Vector3 pointerPosition) { int row, col; if (!SelectAtScreenPositionUsingGridIntersection(pointerPosition, out row, out col)) { //Hide any ui elements Hide(); //Return empty data object, with isValid = false return(new TriDataPoint()); } TriDataPoint result = new TriDataPoint(row, col); //This will hold the data for the data variables at [row,col] return(result); }
// Update is called once per frame // void Update () { // } private void UpdateVisualFeedback(TriDataPoint triData) { if (triData.isValid) { if (showDataIndicator) { ShowDataIndicator(triData); } else { HideDataIndicator(); } if (showDataInspectorDesktop || showDataInspectorVR) { ShowDataInspector(triData); } else { HideDataInspector(); } } }
/// <summary> /// Show a graphic on top of a data column. Intended for showing which column was selected/clicked for inspection. /// Adapated from ShowPointedData() in original code. /// </summary> private void ShowDataIndicator(TriDataPoint triData) { if (!triData.isValid) { return; } //If we're already showing this block, skeedaddle so the start time doesn't get reset and flash fast if (indicatorIsShowing && indicatorTriData.row == triData.row && indicatorTriData.col == triData.col) { return; } //Store what we're currently showing indicatorTriData = triData; indicatorStartTime = Time.time; indicatorIsShowing = true; PrepareBlockOverlay(dataIndicatorCube, triData.row, triData.col, triData.bin, 1.01f); dataIndicatorCube.SetActive(true); StartCoroutine(DataIndicatorAnimate()); }
private void CheckForMouse() { //Check for single click. Stash time and swallow if found. if (Input.GetMouseButtonDown(0)) { leftMouseButtonDownTime = Time.time; return; } if (Input.GetMouseButtonUp(0)) { //Look for single click if (Time.time - leftMouseButtonDownTime < mouseSingleClickThreshold) { //Process single click //Initiate a data inspection TriDataPoint triPoint = DataInspector.I.InspectDataAtScreenPosition(Input.mousePosition); //If we get a valid point, lock the data inspection to this point by setting this flag. contDataInpectionTempDisable = triPoint.isValid; //triPoint.DebugDump(); } return; } //Translate if (Input.GetMouseButton(0 /*left button*/)) { // Read the mouse input axis float trX = Input.GetAxis("Mouse X"); //delta position, from what I understand float trY = Input.GetAxis("Mouse Y"); CameraManager.I.TranslateView(-trX * translationScaleMouse, -trY * translationScaleMouse); return; } //Rotation - mouse if (Input.GetMouseButton(1 /*right mouse button held down*/)) { // Read the mouse input axis float rotX = Input.GetAxis("Mouse X"); float rotY = Input.GetAxis("Mouse Y"); CameraManager.I.RotateView(-rotY * rotationScaleMouse, rotX * rotationScaleMouse); return; } //Scroll wheel for zoom //NOTE - this isn't picking up scroll from trackpad - why not? float scroll = Input.GetAxis("Mouse ScrollWheel"); if (scroll != 0) { CameraManager.I.Zoom(scroll * zoomScaleScrollWheel); return; } //No mouse button or scroll-wheel activity and no button held // //Do continuous data inspector //But only if // - not temporarily disabled // - time interval has passed // - we're not in VR and following the headset (which triggers inspection if mouse is over data while headset moves) if (contDataInspectionEnabled && !contDataInpectionTempDisable && (Time.time - contDataInspectionPrevTime) > contDataInspectionInterval && !CameraManager.I.followHmdEnabled) { if (Graph.I.GraphIsShowing) { DataInspector.I.InspectDataAtScreenPosition(Input.mousePosition); } contDataInspectionPrevTime = Time.time; } }