diff --git a/inc/leptonvariation.h b/inc/leptonvariation.h index 126f83c..38c0ffb 100644 --- a/inc/leptonvariation.h +++ b/inc/leptonvariation.h @@ -96,12 +96,13 @@ class LeptonVariation : public AbstractCCInterface Q_PROPERTY(unsigned int radSpotmeterInKelvinX100 READ getRadSpotmeterObjInKelvinX100 NOTIFY radSpotmeterInKelvinX100Changed) unsigned int getRadSpotmeterObjInKelvinX100(); - Q_PROPERTY(const QRect& radSpotmeterRoi READ getRadSpotmeterRoi NOTIFY radSpotmeterRoiChanged) + Q_PROPERTY(const QRect& radSpotmeterRoi READ getRadSpotmeterRoi WRITE setRadSpotmeterRoi NOTIFY radSpotmeterRoiChanged) const QRect getRadSpotmeterRoi() { return QRect(m_spotmeterRoi.startCol, m_spotmeterRoi.startRow, m_spotmeterRoi.endCol - m_spotmeterRoi.startCol, m_spotmeterRoi.endRow - m_spotmeterRoi.startRow); } + void setRadSpotmeterRoi(const QRect& roi); SDK_ENUM_PROPERTY(RAD_TLINEAR_RESOLUTION_E, radTLinearResolution, RadTLinearResolution) diff --git a/qml/ViewerForm.ui.qml b/qml/ViewerForm.ui.qml index aae9c7d..dd014d9 100644 --- a/qml/ViewerForm.ui.qml +++ b/qml/ViewerForm.ui.qml @@ -54,7 +54,6 @@ Item { acq: acq anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - roi: acq.cci.radSpotmeterRoi } } } diff --git a/qml/controls/VideoRoi.qml b/qml/controls/VideoRoi.qml index 8a948e5..8e02992 100644 --- a/qml/controls/VideoRoi.qml +++ b/qml/controls/VideoRoi.qml @@ -5,18 +5,58 @@ import GetThermal 1.0 Item { id: root - width: parent.width - height: (parent.width * acq.videoSize.height) / acq.videoSize.width + anchors.fill: parent property UvcAcquisition acq: null - property var roi: null - - Rectangle { - x: (roi.x * parent.width) / acq.videoSize.width - y: (roi.y * parent.height) / acq.videoSize.height - width: (roi.width * parent.width) / acq.videoSize.width - height: (roi.height * parent.height) / acq.videoSize.height - color: "#80ffffff" - border.color: "#80000000" + property rect roi: acq && acq.cci ? acq.cci.radSpotmeterRoi : Qt.rect(0, 0, 80, 60) + property size videoSize: acq ? acq.videoSize : Qt.size(80, 60) + + function moveUnscaledRoiTo(dispX, dispY) { + var nx = Math.floor(dispX * (videoSize.width / scaledvid.width)) + var ny = Math.floor(dispY * (videoSize.height / scaledvid.height)) + if (roi.x === nx && roi.y === ny) { + return + } + acq.cci.radSpotmeterRoi = Qt.rect(nx, ny, roi.width, roi.height) + } + + Item { + id: scaledvid + + width: root.width + height: (root.width * videoSize.height) / videoSize.width + anchors.centerIn: root + + MouseArea { + cursorShape: Qt.CrossCursor + anchors.fill: parent + onClicked: { + moveUnscaledRoiTo(mouse.x, mouse.y) + } + } + + Rectangle { + id: roidisp + + x: roi.x * (scaledvid.width / videoSize.width) + y: roi.y * (scaledvid.height / videoSize.height) + width: roi.width * (scaledvid.width / videoSize.width) + height: roi.height * (scaledvid.height / videoSize.height) + + color: "#80ffffff" + border.color: "#80000000" + + MouseArea { + cursorShape: drag.active ? Qt.ClosedHandCursor : Qt.OpenHandCursor + anchors.fill: parent + drag.target: roidisp + drag.axis: Drag.XAndYAxis + drag.smoothed: false + drag.threshold: 1 + onPositionChanged: { + moveUnscaledRoiTo(roidisp.x, roidisp.y) + } + } + } } } diff --git a/src/leptonvariation.cpp b/src/leptonvariation.cpp index 33a48c8..65a3e81 100644 --- a/src/leptonvariation.cpp +++ b/src/leptonvariation.cpp @@ -173,6 +173,24 @@ unsigned int LeptonVariation::getRadSpotmeterObjInKelvinX100() return 0; } +void LeptonVariation::setRadSpotmeterRoi(const QRect& roi) +{ + LEP_RAD_ROI_T newSpot = { + static_cast(roi.y()), + static_cast(roi.x()), + static_cast(roi.y() + roi.height()), + static_cast(roi.x() + roi.width()) + }; + + if (LEP_SetRadSpotmeterRoi(&m_portDesc, newSpot) != LEP_OK) { + printf("LEP_SetRadSpotmeterRoi failed"); + return; + } + + m_spotmeterRoi = newSpot; + emit radSpotmeterRoiChanged(); + emit radSpotmeterInKelvinX100Changed(); +} void LeptonVariation::performFfc() {