(calibration, reloadTool)
| 22 | |
| 23 | wpd.AxesCornersTool = (function() { |
| 24 | var Tool = function(calibration, reloadTool) { |
| 25 | var pointCount = 0, |
| 26 | _calibration = calibration, |
| 27 | isCapturingCorners = true; |
| 28 | |
| 29 | if (reloadTool) { |
| 30 | pointCount = _calibration.maxPointCount; |
| 31 | isCapturingCorners = false; |
| 32 | } else { |
| 33 | pointCount = 0; |
| 34 | isCapturingCorners = true; |
| 35 | wpd.graphicsWidget.resetData(); |
| 36 | } |
| 37 | |
| 38 | this.onMouseClick = function(ev, pos, imagePos) { |
| 39 | if (isCapturingCorners) { |
| 40 | pointCount = pointCount + 1; |
| 41 | |
| 42 | _calibration.addPoint(imagePos.x, imagePos.y, 0, 0); |
| 43 | _calibration.unselectAll(); |
| 44 | _calibration.selectPoint(pointCount - 1); |
| 45 | wpd.graphicsWidget.forceHandlerRepaint(); |
| 46 | |
| 47 | if (pointCount === _calibration.maxPointCount) { |
| 48 | isCapturingCorners = false; |
| 49 | wpd.alignAxes.calibrationCompleted(); |
| 50 | } |
| 51 | |
| 52 | wpd.graphicsWidget.updateZoomOnEvent(ev); |
| 53 | } else { |
| 54 | _calibration.unselectAll(); |
| 55 | // cal.selectNearestPoint(imagePos.x, |
| 56 | // imagePos.y, 15.0/wpd.graphicsWidget.getZoomRatio()); |
| 57 | _calibration.selectNearestPoint(imagePos.x, imagePos.y); |
| 58 | wpd.graphicsWidget.forceHandlerRepaint(); |
| 59 | wpd.graphicsWidget.updateZoomOnEvent(ev); |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | this.onKeyDown = function(ev) { |
| 64 | if (_calibration.getSelectedPoints().length === 0) { |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | var selPoint = _calibration.getPoint(_calibration.getSelectedPoints()[0]), |
| 69 | pointPx = selPoint.px, |
| 70 | pointPy = selPoint.py, |
| 71 | stepSize = ev.shiftKey === true ? 5 / wpd.graphicsWidget.getZoomRatio() : |
| 72 | 0.5 / wpd.graphicsWidget.getZoomRatio(); |
| 73 | |
| 74 | // rotate to current rotation |
| 75 | const currentRotation = wpd.graphicsWidget.getRotation(); |
| 76 | let { |
| 77 | x, |
| 78 | y |
| 79 | } = wpd.graphicsWidget.getRotatedCoordinates(0, currentRotation, pointPx, pointPy); |
| 80 | |
| 81 | if (wpd.keyCodes.isUp(ev.keyCode)) { |
nothing calls this directly
no test coverage detected