Skip to content

Commit d64a66e

Browse files
[ui] Viewer2D: The pixel coordinates set by user are now reset when mouse hovered the image, to avoid ghost values
1 parent c8720af commit d64a66e

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

meshroom/ui/qml/Viewer/HdrImageToolbar.qml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ FloatingPane {
1414
property real gammaDefaultValue: 1.0
1515
property string pixelCoordinatesPlaceholder: "--"
1616

17-
function resetDefaultValues() {
18-
gainCtrl.value = root.gainDefaultValue
19-
gammaCtrl.value = root.gammaDefaultValue
20-
}
2117

2218
property real slidersPowerValue: 4.0
2319
property real gainValue: Math.pow(gainCtrl.value, slidersPowerValue)
@@ -28,11 +24,25 @@ FloatingPane {
2824

2925
property bool colorPickerVisible: true
3026

31-
property variant pixelX: null
32-
property variant pixelY: null
27+
property variant userDefinedXPixel: null
28+
property variant userDefinedYPixel: null
3329

3430
background: Rectangle { color: root.palette.window }
3531

32+
function resetDefaultValues() {
33+
gainCtrl.value = root.gainDefaultValue
34+
gammaCtrl.value = root.gammaDefaultValue
35+
}
36+
37+
function resetPixelCoordinates() {
38+
if(userDefinedXPixel !== null) { userDefinedXPixel = null }
39+
if(userDefinedYPixel !== null) { userDefinedYPixel = null }
40+
}
41+
42+
onMousePositionChanged: {
43+
resetPixelCoordinates()
44+
}
45+
3646
DoubleValidator {
3747
id: doubleValidator
3848
locale: 'C' // Use '.' decimal separator disregarding of the system locale
@@ -154,7 +164,7 @@ FloatingPane {
154164
validator: IntValidator {}
155165
onTextEdited: {
156166
const xPixelValue = parseInt(xPixel.text)
157-
pixelX = Number.isNaN(xPixelValue) ? null : xPixelValue
167+
userDefinedXPixel = Number.isNaN(xPixelValue) ? null : xPixelValue
158168
}
159169
}
160170
Label {
@@ -168,7 +178,7 @@ FloatingPane {
168178
validator: IntValidator {}
169179
onTextEdited: {
170180
const yPixelValue = parseInt(yPixel.text)
171-
pixelY = Number.isNaN(yPixelValue) ? null : yPixelValue
181+
userDefinedYPixel = Number.isNaN(yPixelValue) ? null : yPixelValue
172182
}
173183
}
174184

meshroom/ui/qml/Viewer/Viewer2D.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,12 @@ FocusScope {
438438
return floatImageViewerLoader.item.pixelValueAt( mousePosition.x, mousePosition.y )
439439
}
440440

441-
if ( !Number.isInteger(pixelX) || !Number.isInteger(pixelY) ) {
441+
if ( !Number.isInteger(userDefinedXPixel) || !Number.isInteger(userDefinedYPixel) ) {
442442
return null
443443
}
444444

445445
// Get the pixel color value from text field value (let the possibility to user to set the x,y from ui)
446-
return floatImageViewerLoader.item.pixelValueAt( parseInt(pixelX) , parseInt(pixelY) )
446+
return floatImageViewerLoader.item.pixelValueAt( parseInt(userDefinedXPixel) , parseInt(userDefinedYPixel) )
447447

448448
}
449449

0 commit comments

Comments
 (0)