- function moveToCenterIfNeeded(x, y) {
- if (x >= centerRect.x && y >= centerRect.y &&
- x <= centerRect.x + centerRect.width &&
- y <= centerRect.y + centerRect.height) {
- reticle.x = reticle.center.x
- reticle.y = reticle.center.y
- }
+ // TODO: rework this and move to unnormalized coordinates
+ // in terms of video resolution:
+ var rx = (videoResolution.width * reticle.x) / mouse.width
+ var rwidth = (videoResolution.width * reticle.width) / mouse.width
+ var ry = (videoResolution.height * reticle.y) / mouse.height
+ var rheight = (videoResolution.height * reticle.height) / mouse.height
+
+ // Translate to normalized coordinates (1x1 square) as expected by our C++ backend
+ rx = rx / videoResolution.width
+ rwidth = rwidth / videoResolution.width
+ ry = ry / videoResolution.height
+ rheight = rheight / videoResolution.height
+
+ // console.log("Setting ROI to: " + rx + "x" + ry)
+ cam.roi.setRegionOfInterest(Qt.rect(rx, ry, rwidth, rheight))
+ }
+
+ function calculateTouchPoint(x, y) {
+ if (x >= centerRect.x && y >= centerRect.y &&
+ x <= centerRect.x + centerRect.width &&
+ y <= centerRect.y + centerRect.height) {
+ touchMode = false
+ touchPoint = Qt.point(mouse.width / 2, mouse.height / 2)
+ return