diff --git a/meshroom/ui/qml/Viewer/HdrImageToolbar.qml b/meshroom/ui/qml/Viewer/HdrImageToolbar.qml index 0945b80735..643841dad7 100644 --- a/meshroom/ui/qml/Viewer/HdrImageToolbar.qml +++ b/meshroom/ui/qml/Viewer/HdrImageToolbar.qml @@ -12,22 +12,37 @@ FloatingPane { property real gainDefaultValue: 1.0 property real gammaDefaultValue: 1.0 + property string pixelCoordinatesPlaceholder: "--" - function resetDefaultValues() { - gainCtrl.value = root.gainDefaultValue - gammaCtrl.value = root.gammaDefaultValue - } property real slidersPowerValue: 4.0 property real gainValue: Math.pow(gainCtrl.value, slidersPowerValue) property real gammaValue: Math.pow(gammaCtrl.value, slidersPowerValue) property alias channelModeValue: channelsCtrl.value property variant colorRGBA: null + property variant mousePosition: ({x:0, y:0}) property bool colorPickerVisible: true + property variant userDefinedXPixel: null + property variant userDefinedYPixel: null + background: Rectangle { color: root.palette.window } + function resetDefaultValues() { + gainCtrl.value = root.gainDefaultValue + gammaCtrl.value = root.gammaDefaultValue + } + + function resetPixelCoordinates() { + if(userDefinedXPixel !== null) { userDefinedXPixel = null } + if(userDefinedYPixel !== null) { userDefinedYPixel = null } + } + + onMousePositionChanged: { + resetPixelCoordinates() + } + DoubleValidator { id: doubleValidator locale: 'C' // Use '.' decimal separator disregarding of the system locale @@ -136,6 +151,39 @@ FloatingPane { } } + RowLayout { + + Label { + text: "x" + } + TextField { + id: xPixel + text: root.mousePosition ? root.mousePosition.x : null + Layout.preferredWidth: 40 + placeholderText: pixelCoordinatesPlaceholder + validator: IntValidator { bottom: 0 } + onTextEdited: { + const xPixelValue = parseInt(xPixel.text) + userDefinedXPixel = Number.isNaN(xPixelValue) ? null : xPixelValue + } + } + Label { + text: "y" + } + TextField { + id: yPixel + text: root.mousePosition ? root.mousePosition.y : null + Layout.preferredWidth: 40 + placeholderText: pixelCoordinatesPlaceholder + validator: IntValidator { bottom: 0 } + onTextEdited: { + const yPixelValue = parseInt(yPixel.text) + userDefinedYPixel = Number.isNaN(yPixelValue) ? null : yPixelValue + } + } + + } + Rectangle { visible: colorPickerVisible Layout.preferredWidth: 20 @@ -148,6 +196,7 @@ FloatingPane { RowLayout { spacing: 1 visible: colorPickerVisible + TextField { id: red property real value: root.colorRGBA ? root.colorRGBA.x : 0.0 diff --git a/meshroom/ui/qml/Viewer/Viewer2D.qml b/meshroom/ui/qml/Viewer/Viewer2D.qml index 48a672e76c..6da2ba26e7 100644 --- a/meshroom/ui/qml/Viewer/Viewer2D.qml +++ b/meshroom/ui/qml/Viewer/Viewer2D.qml @@ -427,17 +427,30 @@ FocusScope { } colorRGBA: { + if (!floatImageViewerLoader.item || floatImageViewerLoader.item.imageStatus !== Image.Ready) { return null } - if (floatImageViewerLoader.item.containsMouse === false) { + + /// Get the pixel color value at mouse position (when mouse hover the image) + if (mousePosition && floatImageViewerLoader.item.containsMouse === true) { + return floatImageViewerLoader.item.pixelValueAt( mousePosition.x, mousePosition.y ) + } + + if ( !Number.isInteger(userDefinedXPixel) || !Number.isInteger(userDefinedYPixel) ) { return null } - var pix = floatImageViewerLoader.item.pixelValueAt(Math.floor(floatImageViewerLoader.item.mouseX), - Math.floor(floatImageViewerLoader.item.mouseY)) - return pix + + // Get the pixel color value from text field value (let the possibility to user to set the x,y from ui) + return floatImageViewerLoader.item.pixelValueAt( parseInt(userDefinedXPixel) , parseInt(userDefinedYPixel) ) + } + + mousePosition: (floatImageViewerLoader.item.containsMouse ? { + x: Math.floor(floatImageViewerLoader.item.mouseX), + y: Math.floor(floatImageViewerLoader.item.mouseY) + } : null) } LensDistortionToolbar {