diff --git a/meshroom/ui/qml/Viewer/CameraResponseGraph.qml b/meshroom/ui/qml/Viewer/CameraResponseGraph.qml index 88b8608a..64faa15e 100644 --- a/meshroom/ui/qml/Viewer/CameraResponseGraph.qml +++ b/meshroom/ui/qml/Viewer/CameraResponseGraph.qml @@ -38,17 +38,14 @@ FloatingPane { // note: We need to use csvData.getNbColumns() slot instead of the csvData.nbColumns property to avoid a crash on linux. property bool crfReady: csvData && csvData.ready && (csvData.getNbColumns() >= 4) onCrfReadyChanged: { - if(crfReady) - { + if (crfReady) { redCurve.clear() greenCurve.clear() blueCurve.clear() csvData.getColumn(1).fillChartSerie(redCurve) csvData.getColumn(2).fillChartSerie(greenCurve) csvData.getColumn(3).fillChartSerie(blueCurve) - } - else - { + } else { redCurve.clear() greenCurve.clear() blueCurve.clear() @@ -125,7 +122,7 @@ FloatingPane { checkState: legend.buttonGroup.checkState onClicked: { const _checked = checked - for(let i = 0; i < responseChart.count; ++i) { + for (let i = 0; i < responseChart.count; ++i) { responseChart.series(i).visible = _checked } } diff --git a/meshroom/ui/qml/Viewer/CircleGizmo.qml b/meshroom/ui/qml/Viewer/CircleGizmo.qml index ff072f72..7a13cedd 100644 --- a/meshroom/ui/qml/Viewer/CircleGizmo.qml +++ b/meshroom/ui/qml/Viewer/CircleGizmo.qml @@ -51,27 +51,27 @@ Item { property bool controlModifierEnabled: false onPositionChanged: { mArea.controlModifierEnabled = (mouse.modifiers & Qt.ControlModifier) - mouse.accepted = false; + mouse.accepted = false } acceptedButtons: Qt.LeftButton hoverEnabled: true drag.target: circle drag.onActiveChanged: { - if(!drag.active) { - root.moved(circle.x - (root.width - circle.width) / 2, circle.y - (root.height - circle.height) / 2); + if (!drag.active) { + root.moved(circle.x - (root.width - circle.width) / 2, circle.y - (root.height - circle.height) / 2) } } onPressed: { - forceActiveFocus(); + forceActiveFocus() } onWheel: { mArea.controlModifierEnabled = (wheel.modifiers & Qt.ControlModifier) if (wheel.modifiers & Qt.ControlModifier) { - root.incrementRadius(wheel.angleDelta.y / 120.0); - wheel.accepted = true; + root.incrementRadius(wheel.angleDelta.y / 120.0) + wheel.accepted = true } else { - wheel.accepted = false; + wheel.accepted = false } } } diff --git a/meshroom/ui/qml/Viewer/ColorCheckerEntity.qml b/meshroom/ui/qml/Viewer/ColorCheckerEntity.qml index a9811dff..214a84c8 100644 --- a/meshroom/ui/qml/Viewer/ColorCheckerEntity.qml +++ b/meshroom/ui/qml/Viewer/ColorCheckerEntity.qml @@ -36,7 +36,7 @@ Item { m[0][0], m[0][1], 0, m[0][2], m[1][0], m[1][1], 0, m[1][2], 0, 0, 1, 0, - m[2][0], m[2][1], 0, m[2][2] ) + m[2][0], m[2][1], 0, m[2][2]) } } diff --git a/meshroom/ui/qml/Viewer/ColorCheckerPane.qml b/meshroom/ui/qml/Viewer/ColorCheckerPane.qml index a91fad46..16420006 100644 --- a/meshroom/ui/qml/Viewer/ColorCheckerPane.qml +++ b/meshroom/ui/qml/Viewer/ColorCheckerPane.qml @@ -30,8 +30,8 @@ FloatingPane { Rectangle { id: cell - width: root.width / grid.columns - grid.spacing * (grid.columns+1) / grid.columns - height: root.height / grid.rows - grid.spacing * (grid.rows+1) / grid.rows + width: root.width / grid.columns - grid.spacing * (grid.columns + 1) / grid.columns + height: root.height / grid.rows - grid.spacing * (grid.rows + 1) / grid.rows color: Qt.rgba(modelData.r, modelData.g, modelData.b, 1.0) } diff --git a/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml b/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml index 8b51aa5b..151339f7 100644 --- a/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml +++ b/meshroom/ui/qml/Viewer/ColorCheckerViewer.qml @@ -17,60 +17,60 @@ Item { property var ccheckers: [] property int selectedCChecker: -1 - Component.onCompleted: { readSourceFile(); } - onSourceChanged: { readSourceFile(); } - onViewpointChanged: { loadCCheckers(); } + Component.onCompleted: { readSourceFile() } + onSourceChanged: { readSourceFile() } + onViewpointChanged: { loadCCheckers() } property var updatePane: null function getColors() { if (ccheckers[selectedCChecker] === undefined) - return null; + return null if (ccheckers[selectedCChecker].colors === undefined) - return null; + return null - return ccheckers[selectedCChecker].colors; + return ccheckers[selectedCChecker].colors } function readSourceFile() { - var xhr = new XMLHttpRequest; + var xhr = new XMLHttpRequest // console.warn("readSourceFile: " + root.source) - xhr.open("GET", root.source); + xhr.open("GET", root.source) xhr.onreadystatechange = function() { if (xhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) { try { - root.json = null; + root.json = null // console.warn("readSourceFile: update json from " + root.source) - root.json = JSON.parse(xhr.responseText); + root.json = JSON.parse(xhr.responseText) // console.warn("readSourceFile: root.json.checkers.length=" + root.json.checkers.length) - } - catch(exc) - { - console.warn("Failed to parse ColorCheckerDetection JSON file: " + source); - return; + } catch(exc) { + console.warn("Failed to parse ColorCheckerDetection JSON file: " + source) + return } } - loadCCheckers(); - }; - xhr.send(); + loadCCheckers() + } + xhr.send() } function loadCCheckers() { - emptyCCheckers(); - if (root.json === null) - { - return; + emptyCCheckers() + if (root.json === null) { + return } - var currentImagePath = (root.viewpoint && root.viewpoint.attribute && root.viewpoint.attribute.childAttribute("path")) ? root.viewpoint.attribute.childAttribute("path").value : null - var viewId = (root.viewpoint && root.viewpoint.attribute && root.viewpoint.attribute.childAttribute("viewId")) ? root.viewpoint.attribute.childAttribute("viewId").value : null + var currentImagePath = (root.viewpoint && root.viewpoint.attribute && root.viewpoint.attribute.childAttribute("path")) + ? root.viewpoint.attribute.childAttribute("path").value : null + var viewId = (root.viewpoint && root.viewpoint.attribute && root.viewpoint.attribute.childAttribute("viewId")) + ? root.viewpoint.attribute.childAttribute("viewId").value : null + for (var i = 0; i < root.json.checkers.length; i++) { // Only load ccheckers for the current view var checker = root.json.checkers[i] if (checker.viewId === viewId || checker.imagePath === currentImagePath) { - var cpt = Qt.createComponent("ColorCheckerEntity.qml"); + var cpt = Qt.createComponent("ColorCheckerEntity.qml") var obj = cpt.createObject(root, { x: ccheckerSizeX / 2, @@ -78,20 +78,20 @@ Item { sizeX: root.ccheckerSizeX, sizeY: root.ccheckerSizeY, colors: root.json.checkers[i].colors - }); - obj.applyTransform(root.json.checkers[i].transform); - ccheckers.push(obj); - selectedCChecker = ccheckers.length-1; - break; + }) + obj.applyTransform(root.json.checkers[i].transform) + ccheckers.push(obj) + selectedCChecker = ccheckers.length - 1 + break } } - updatePane(); + updatePane() } function emptyCCheckers() { for (var i = 0; i < ccheckers.length; i++) - ccheckers[i].destroy(); - ccheckers = []; - selectedCChecker = -1; + ccheckers[i].destroy() + ccheckers = [] + selectedCChecker = -1 } } diff --git a/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml b/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml index 57f8f8dd..750aa9e5 100644 --- a/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml +++ b/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml @@ -52,9 +52,9 @@ FloatingPane { from: 0 to: 1 first.value: 0 - first.onMoved: { root.featuresViewer.featureMinScaleFilter = Math.pow(first.value,4); } + first.onMoved: { root.featuresViewer.featureMinScaleFilter = Math.pow(first.value,4) } second.value: 1 - second.onMoved: { root.featuresViewer.featureMaxScaleFilter = Math.pow(second.value,4); } + second.onMoved: { root.featuresViewer.featureMaxScaleFilter = Math.pow(second.value,4) } stepSize: 0.01 } } @@ -120,7 +120,7 @@ FloatingPane { } RowLayout { Label { - text: "Display 3d Tracks:" + text: "Display 3D Tracks:" } CheckBox { id: display3dTracksCB @@ -163,20 +163,20 @@ FloatingPane { editable: true textFromValue: function(value, locale) { - if (value === -1) return "No Limit"; - if (value === 0) return "Disable"; - return value; + if (value === -1) return "No Limit" + if (value === 0) return "Disable" + return value } valueFromText: function(text, locale) { - if (text === "No Limit") return -1; - if (text === "Disable") return 0; - return Number.fromLocaleString(locale, text); + if (text === "No Limit") return -1 + if (text === "Disable") return 0 + return Number.fromLocaleString(locale, text) } onValueChanged: { if (root.featuresViewer) - root.featuresViewer.timeWindow = timeWindowSB.value; + root.featuresViewer.timeWindow = timeWindowSB.value } } } @@ -212,7 +212,7 @@ FloatingPane { text: MaterialIcons.center_focus_strong ToolTip.text: "Display Extracted Features" onClicked: { - featureType.viewer.displayFeatures = featuresVisibilityButton.checked; + featureType.viewer.displayFeatures = featuresVisibilityButton.checked } font.pointSize: 10 opacity: featureType.viewer.visible ? 1.0 : 0.6 @@ -225,8 +225,8 @@ FloatingPane { text: MaterialIcons.timeline ToolTip.text: "Display Tracks" onClicked: { - featureType.viewer.displayTracks = tracksVisibilityButton.checked; - root.featuresViewer.enableTimeWindow = tracksVisibilityButton.checked; + featureType.viewer.displayTracks = tracksVisibilityButton.checked + root.featuresViewer.enableTimeWindow = tracksVisibilityButton.checked } font.pointSize: 10 } @@ -238,7 +238,7 @@ FloatingPane { text: MaterialIcons.sync ToolTip.text: "Display Matches" onClicked: { - featureType.viewer.displayMatches = matchesVisibilityButton.checked; + featureType.viewer.displayMatches = matchesVisibilityButton.checked } font.pointSize: 10 } @@ -250,7 +250,7 @@ FloatingPane { text: MaterialIcons.fiber_manual_record ToolTip.text: "Display Landmarks" onClicked: { - featureType.viewer.displayLandmarks = landmarksVisibilityButton.checked; + featureType.viewer.displayLandmarks = landmarksVisibilityButton.checked } font.pointSize: 10 } diff --git a/meshroom/ui/qml/Viewer/FloatImage.qml b/meshroom/ui/qml/Viewer/FloatImage.qml index 4fc6b8b0..662273ce 100644 --- a/meshroom/ui/qml/Viewer/FloatImage.qml +++ b/meshroom/ui/qml/Viewer/FloatImage.qml @@ -19,27 +19,26 @@ AliceVision.FloatImageViewer { property int paintedWidth: sourceSize.width property int paintedHeight: sourceSize.height property var status: { - if(root.loading) + if (root.loading) return Image.Loading; - else if((root.source === "") || - (root.sourceSize.height <= 0) || - (root.sourceSize.width <= 0)) - return Image.Null; + else if ((root.source === "") || + (root.sourceSize.height <= 0) || + (root.sourceSize.width <= 0)) + return Image.Null - return Image.Ready; + return Image.Ready } onStatusChanged: { if (viewerTypeString === "panorama") { - var activeNode = _reconstruction.activeNodes.get('SfMTransform').node; + var activeNode = _reconstruction.activeNodes.get('SfMTransform').node } root.surface.setIdView(idView); } property string channelModeString : "rgba" channelMode: { - switch(channelModeString) - { + switch (channelModeString) { case "rgb": return AliceVision.FloatImageViewer.EChannelMode.RGB case "r": return AliceVision.FloatImageViewer.EChannelMode.R case "g": return AliceVision.FloatImageViewer.EChannelMode.G @@ -51,8 +50,7 @@ AliceVision.FloatImageViewer { property string viewerTypeString : "hdr" surface.viewerType: { - switch(viewerTypeString) - { + switch (viewerTypeString) { case "hdr": return AliceVision.Surface.EViewerType.HDR; case "distortion": return AliceVision.Surface.EViewerType.DISTORTION; case "panorama": return AliceVision.Surface.EViewerType.PANORAMA; @@ -60,7 +58,7 @@ AliceVision.FloatImageViewer { } } - property int pointsNumber: (surface.subdivisions + 1) * (surface.subdivisions + 1); + property int pointsNumber: (surface.subdivisions + 1) * (surface.subdivisions + 1) property int idView: 0; @@ -78,20 +76,20 @@ AliceVision.FloatImageViewer { } function isMouseOver(mx, my) { - return root.surface.isMouseInside(mx, my); + return root.surface.isMouseInside(mx, my) } function getMouseCoordinates(mx, my) { if (isMouseOver(mx, my)) { root.surface.mouseOver = true - return true; + return true } else { root.surface.mouseOver = false - return false; + return false } } - function onChangedHighlightState(isHighlightable){ + function onChangedHighlightState(isHighlightable) { if (!isHighlightable) root.surface.mouseOver = false } @@ -101,12 +99,12 @@ AliceVision.FloatImageViewer { */ function updatePrincipalPoint() { - var pp = root.surface.getPrincipalPoint(); - ppRect.x = pp.x; - ppRect.y = pp.y; + var pp = root.surface.getPrincipalPoint() + ppRect.x = pp.x + ppRect.y = pp.y } - property bool isPrincipalPointsDisplayed : false; + property bool isPrincipalPointsDisplayed : false Item { id: principalPoint diff --git a/meshroom/ui/qml/Viewer/HdrImageToolbar.qml b/meshroom/ui/qml/Viewer/HdrImageToolbar.qml index 8c3a0f29..10b4aba8 100644 --- a/meshroom/ui/qml/Viewer/HdrImageToolbar.qml +++ b/meshroom/ui/qml/Viewer/HdrImageToolbar.qml @@ -13,9 +13,9 @@ FloatingPane { property real gainDefaultValue: 1.0 property real gammaDefaultValue: 1.0 - function resetDefaultValues(){ - gainCtrl.value = root.gainDefaultValue; - gammaCtrl.value = root.gammaDefaultValue; + function resetDefaultValues() { + gainCtrl.value = root.gainDefaultValue + gammaCtrl.value = root.gammaDefaultValue } property real slidersPowerValue: 4.0 @@ -65,7 +65,7 @@ FloatingPane { ToolTip.text: "Reset Gain" onClicked: { - gainCtrl.value = gainDefaultValue; + gainCtrl.value = gainDefaultValue } } TextField { @@ -80,7 +80,7 @@ FloatingPane { selectByMouse: true validator: doubleValidator onAccepted: { - gainCtrl.value = Math.pow(Number(gainLabel.text), 1.0/slidersPowerValue) + gainCtrl.value = Math.pow(Number(gainLabel.text), 1.0 / slidersPowerValue) } } Slider { @@ -120,7 +120,7 @@ FloatingPane { selectByMouse: true validator: doubleValidator onAccepted: { - gammaCtrl.value = Math.pow(Number(gammaLabel.text), 1.0/slidersPowerValue) + gammaCtrl.value = Math.pow(Number(gammaLabel.text), 1.0 / slidersPowerValue) } } Slider { @@ -148,7 +148,7 @@ FloatingPane { TextField { id: red property real value: root.colorRGBA ? root.colorRGBA.x : 0.0 - property real value_gamma: Math.pow(value, 1.0/2.2) + property real value_gamma: Math.pow(value, 1.0 / 2.2) text: root.colorRGBA ? value.toFixed(6) : "--" Layout.preferredWidth: textMetrics_colorValue.width @@ -192,7 +192,7 @@ FloatingPane { TextField { id: blue property real value: root.colorRGBA ? root.colorRGBA.z : 0.0 - property real value_gamma: Math.pow(value, 1.0/2.2) + property real value_gamma: Math.pow(value, 1.0 / 2.2) text: root.colorRGBA ? value.toFixed(6) : "--" Layout.preferredWidth: textMetrics_colorValue.width @@ -214,7 +214,7 @@ FloatingPane { TextField { id: alpha property real value: root.colorRGBA ? root.colorRGBA.w : 0.0 - property real value_gamma: Math.pow(value, 1.0/2.2) + property real value_gamma: Math.pow(value, 1.0 / 2.2) text: root.colorRGBA ? value.toFixed(6) : "--" Layout.preferredWidth: textMetrics_colorValue.width diff --git a/meshroom/ui/qml/Viewer/ImageMetadataView.qml b/meshroom/ui/qml/Viewer/ImageMetadataView.qml index d69b05b6..e951a84e 100644 --- a/meshroom/ui/qml/Viewer/ImageMetadataView.qml +++ b/meshroom/ui/qml/Viewer/ImageMetadataView.qml @@ -9,7 +9,7 @@ import Controls 1.0 import Utils 1.0 /** - * ImageMetadataView displays a JSON model representing an image"s metadata as a ListView. + * ImageMetadataView displays a JSON model representing an image's metadata as a ListView. */ FloatingPane { id: root @@ -27,12 +27,10 @@ FloatingPane { * GPS coordinates in metadata can be store in 3 forms: * (degrees), (degrees, minutes), (degrees, minutes, seconds) */ - function gpsMetadataToCoordinates(value, ref) - { + function gpsMetadataToCoordinates(value, ref) { var values = value.split(",") var result = 0 - for(var i=0; i < values.length; ++i) - { + for (var i = 0; i < values.length; ++i) { // divide each component by the corresponding power of 60 // 1 for degree, 60 for minutes, 3600 for seconds result += Number(values[i]) / Math.pow(60, i) @@ -42,19 +40,14 @@ FloatingPane { } /// Try to get GPS coordinates from metadata - function getGPSCoordinates(metadata) - { + function getGPSCoordinates(metadata) { // GPS data available - if(metadata && metadata["GPS:Longitude"] !== undefined && metadata["GPS:Latitude"] !== undefined) - { + if (metadata && metadata["GPS:Longitude"] !== undefined && metadata["GPS:Latitude"] !== undefined) { var latitude = gpsMetadataToCoordinates(metadata["GPS:Latitude"], metadata["GPS:LatitudeRef"]) var longitude = gpsMetadataToCoordinates(metadata["GPS:Longitude"], metadata["GPS:LongitudeRef"]) var altitude = metadata["GPS:Altitude"] || 0 return QtPositioning.coordinate(latitude, longitude, altitude) - } - // GPS data unavailable: reset coordinates to default value - else - { + } else { // GPS data unavailable: reset coordinates to default value return QtPositioning.coordinate() } } @@ -74,22 +67,18 @@ FloatingPane { metadataModel.clear() var entries = [] // prepare data to populate the model from the input metadata object - for(var key in metadata) - { + for (var key in metadata) { var entry = {} // split on ":" to get group and key var i = key.lastIndexOf(":") - if(i === -1) - { + if (i === -1) { i = key.lastIndexOf("/") } - if(i !== -1) - { + + if (i !== -1) { entry["group"] = key.substr(0, i) entry["key"] = key.substr(i+1) - } - else - { + } else { // set default group to something convenient for sorting entry["group"] = "-" entry["key"] = key @@ -110,15 +99,6 @@ FloatingPane { } } -// Button { -// onClicked: { -// if(sortedMetadataModel.sortOrder == Qt.DescendingOrder) -// sortedMetadataModel.sortOrder = Qt.AscendingOrder -// else -// sortedMetadataModel.sortOrder = Qt.DescendingOrder -// } -// } - // Background WheelEvent grabber MouseArea { anchors.fill: parent @@ -126,7 +106,6 @@ FloatingPane { onWheel: wheel.accepted = true } - // Main Layout ColumnLayout { anchors.fill: parent @@ -144,16 +123,15 @@ FloatingPane { Label { id: exposureLabel text: { - if(metadata["ExposureTime"] === undefined) - return ""; - var expStr = metadata["ExposureTime"]; - var exp = parseFloat(expStr); - if(exp < 1.0) - { - var invExp = 1.0 / exp; - return "1/" + invExp.toFixed(0); + if (metadata["ExposureTime"] === undefined) + return "" + var expStr = metadata["ExposureTime"] + var exp = parseFloat(expStr) + if (exp < 1.0) { + var invExp = 1.0 / exp + return "1/" + invExp.toFixed(0) } - return expStr; + return expStr } elide: Text.ElideRight horizontalAlignment: Text.AlignHLeft diff --git a/meshroom/ui/qml/Viewer/LensDistortionToolbar.qml b/meshroom/ui/qml/Viewer/LensDistortionToolbar.qml index 46e9abed..10c783e9 100644 --- a/meshroom/ui/qml/Viewer/LensDistortionToolbar.qml +++ b/meshroom/ui/qml/Viewer/LensDistortionToolbar.qml @@ -77,7 +77,7 @@ FloatingPane { ToolTip.text: "Reset Opacity" onClicked: { - opacityCtrl.value = opacityDefaultValue; + opacityCtrl.value = opacityDefaultValue } } TextField { @@ -118,7 +118,7 @@ FloatingPane { ToolTip.text: "Reset Subdivisions" onClicked: { - subdivisionsCtrl.value = subdivisionsDefaultValue; + subdivisionsCtrl.value = subdivisionsDefaultValue } } TextField { diff --git a/meshroom/ui/qml/Viewer/PanoramaToolbar.qml b/meshroom/ui/qml/Viewer/PanoramaToolbar.qml index b8538ed8..2ef67715 100644 --- a/meshroom/ui/qml/Viewer/PanoramaToolbar.qml +++ b/meshroom/ui/qml/Viewer/PanoramaToolbar.qml @@ -26,7 +26,7 @@ FloatingPane { background: Rectangle { color: root.palette.window } function updateDownscaleValue(level) { - downscaleSpinBox.value = level; + downscaleSpinBox.value = level } DoubleValidator { @@ -79,7 +79,7 @@ FloatingPane { ToolTip.text: "Reset Subdivisions" onClicked: { - subdivisionsCtrl.value = subdivisionsDefaultValue; + subdivisionsCtrl.value = subdivisionsDefaultValue } } TextField { @@ -119,7 +119,7 @@ FloatingPane { ToolTip.text: "Reset the mouse multiplier" onClicked: { - speedSpinBox.value = 1; + speedSpinBox.value = 1 } } SpinBox { @@ -134,7 +134,7 @@ FloatingPane { validator: DoubleValidator { bottom: Math.min(speedSpinBox.from, speedSpinBox.to) - top: Math.max(speedSpinBox.from, speedSpinBox.to) + top: Math.max(speedSpinBox.from, speedSpinBox.to) } textFromValue: function(value, locale) { @@ -152,7 +152,7 @@ FloatingPane { ToolTip.text: "Reset the downscale" onClicked: { - downscaleSpinBox.value = downscaleDefaultValue; + downscaleSpinBox.value = downscaleDefaultValue } } SpinBox { @@ -167,17 +167,15 @@ FloatingPane { validator: DoubleValidator { bottom: Math.min(downscaleSpinBox.from, downscaleSpinBox.to) - top: Math.max(downscaleSpinBox.from, downscaleSpinBox.to) + top: Math.max(downscaleSpinBox.from, downscaleSpinBox.to) } textFromValue: function(value, locale) { - if(value === 0){ + if (value === 0){ return 1 + } else { + return "1/" + Math.pow(2, value).toString() } - else{ - return "1/" + Math.pow(2,value).toString() - } - } } } @@ -188,5 +186,4 @@ FloatingPane { font: subdivisionsLabel.font text: "100.00" } - } diff --git a/meshroom/ui/qml/Viewer/PanoramaViewer.qml b/meshroom/ui/qml/Viewer/PanoramaViewer.qml index 0d1c0bfc..eb4ce481 100644 --- a/meshroom/ui/qml/Viewer/PanoramaViewer.qml +++ b/meshroom/ui/qml/Viewer/PanoramaViewer.qml @@ -21,10 +21,9 @@ AliceVision.PanoramaViewer { property int paintedHeight: sourceSize.height property var status: { if (readyToLoad === Image.Ready) { - return Image.Ready; - } - else { - return Image.Null; + return Image.Ready + } else { + return Image.Null } } @@ -44,9 +43,9 @@ AliceVision.PanoramaViewer { property int idSelected : -1 - onIsHighlightableChanged:{ + onIsHighlightableChanged: { for (var i = 0; i < repeater.model; ++i) { - repeater.itemAt(i).item.onChangedHighlightState(isHighlightable); + repeater.itemAt(i).item.onChangedHighlightState(isHighlightable) } } @@ -67,44 +66,43 @@ AliceVision.PanoramaViewer { property double pitch: 0; property double roll: 0; - property var activeNode: _reconstruction.activeNodes.get('SfMTransform').node; + property var activeNode: _reconstruction.activeNodes.get('SfMTransform').node // Yaw and Pitch in Degrees from SfMTransform node sliders - property double yawNode: activeNode ? activeNode.attribute("manualTransform.manualRotation.y").value : 0; - property double pitchNode: activeNode ? activeNode.attribute("manualTransform.manualRotation.x").value : 0; - property double rollNode: activeNode ? activeNode.attribute("manualTransform.manualRotation.z").value : 0; + property double yawNode: activeNode ? activeNode.attribute("manualTransform.manualRotation.y").value : 0 + property double pitchNode: activeNode ? activeNode.attribute("manualTransform.manualRotation.x").value : 0 + property double rollNode: activeNode ? activeNode.attribute("manualTransform.manualRotation.z").value : 0 //Convert angle functions - function toDegrees(radians){ - return radians * (180/Math.PI) + function toDegrees(radians) { + return radians * (180 / Math.PI) } - function toRadians(degrees){ - return degrees * (Math.PI/180) + function toRadians(degrees) { + return degrees * (Math.PI / 180) } - function fmod(a,b) { return Number((a - (Math.floor(a / b) * b)).toPrecision(8)); } + function fmod(a,b) { return Number((a - (Math.floor(a / b) * b)).toPrecision(8)) } // Limit angle between -180 and 180 - function limitAngle(angle){ - if (angle > 180) angle = -180.0 + (angle - 180.0); - if (angle < -180) angle = 180.0 - (Math.abs(angle) - 180); - return angle; + function limitAngle(angle) { + if (angle > 180) angle = -180.0 + (angle - 180.0) + if (angle < -180) angle = 180.0 - (Math.abs(angle) - 180) + return angle } - function limitPitch(angle) - { - return (angle > 180 || angle < -180) ? root.pitch : angle; + function limitPitch(angle) { + return (angle > 180 || angle < -180) ? root.pitch : angle } onYawNodeChanged: { - root.yaw = yawNode; + root.yaw = yawNode } onPitchNodeChanged: { - root.pitch = pitchNode; + root.pitch = pitchNode } onRollNodeChanged: { - root.roll = rollNode; + root.roll = rollNode } Item { @@ -125,26 +123,24 @@ AliceVision.PanoramaViewer { } onPositionChanged: { // Send Mouse Coordinates to Float Images Viewers - idSelected = -1; + idSelected = -1 for (var i = 0; i < repeater.model && isHighlightable; ++i) { - var highlight = repeater.itemAt(i).item.getMouseCoordinates(mouse.x, mouse.y); + var highlight = repeater.itemAt(i).item.getMouseCoordinates(mouse.x, mouse.y) repeater.itemAt(i).z = highlight ? 2 : 0 - if(highlight){ + if (highlight) { idSelected = root.msfmData.viewsIds[i] } } // Rotate Panorama if (isRotating && isEditable) { - var nx = Math.min(width - 1, mouse.x) var ny = Math.min(height - 1, mouse.y) var xoffset = nx - lastX; var yoffset = ny - lastY; - if (xoffset != 0 || yoffset !=0) - { + if (xoffset != 0 || yoffset !=0) { var latitude_start = (yStart / height) * Math.PI - (Math.PI / 2); var longitude_start = ((xStart / width) * 2 * Math.PI) - Math.PI; var latitude_end = (ny / height) * Math.PI - ( Math.PI / 2); @@ -156,56 +152,49 @@ AliceVision.PanoramaViewer { var previous_euler = Qt.vector3d(previous_yaw, previous_pitch, previous_roll) var result - if (mouse.modifiers & Qt.ControlModifier) - { + if (mouse.modifiers & Qt.ControlModifier) { result = Transformations3DHelper.updatePanoramaInPlane(previous_euler, start_pt, end_pt) root.pitch = result.x root.yaw = result.y - root.roll = result.z - } - else - { + root.roll = result.z + } else { result = Transformations3DHelper.updatePanorama(previous_euler, start_pt, end_pt) root.pitch = result.x root.yaw = result.y root.roll = result.z - } - - + } } - _reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.x"), Math.round(root.pitch)); - _reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.y"), Math.round(root.yaw)); - _reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.z"), Math.round(root.roll)); + _reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.x"), Math.round(root.pitch)) + _reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.y"), Math.round(root.yaw)) + _reconstruction.setAttribute(activeNode.attribute("manualTransform.manualRotation.z"), Math.round(root.roll)) } } onPressed:{ - _reconstruction.beginModification("Panorama Manual Rotation"); - isRotating = true; - lastX = mouse.x; - lastY = mouse.y; + _reconstruction.beginModification("Panorama Manual Rotation") + isRotating = true + lastX = mouse.x + lastY = mouse.y - xStart = mouse.x; - yStart = mouse.y; + xStart = mouse.x + yStart = mouse.y - previous_yaw = yaw; - previous_pitch = pitch; - previous_roll = roll; + previous_yaw = yaw + previous_pitch = pitch + previous_roll = roll } onReleased: { - _reconstruction.endModification(); - isRotating = false; + _reconstruction.endModification() + isRotating = false lastX = 0 lastY = 0 - //Select the image in the image gallery if clicked - if(xStart == mouse.x && yStart == mouse.y && idSelected != -1){ + // Select the image in the image gallery if clicked + if (xStart == mouse.x && yStart == mouse.y && idSelected != -1) { _reconstruction.selectedViewId = idSelected } - - } } @@ -220,16 +209,16 @@ AliceVision.PanoramaViewer { ctx.lineWidth = 1.0 ctx.shadowBlur = 0 ctx.strokeStyle = "grey" - var nrows = height/wgrid; - for(var i=0; i < nrows+1; ++i){ - ctx.moveTo(0, wgrid*i); - ctx.lineTo(width, wgrid*i); + var nrows = height / wgrid + for (var i = 0; i < nrows + 1; ++i) { + ctx.moveTo(0, wgrid * i) + ctx.lineTo(width, wgrid * i) } - var ncols = width/wgrid - for(var j=0; j < ncols+1; ++j){ - ctx.moveTo(wgrid*j, 0); - ctx.lineTo(wgrid*j, height); + var ncols = width / wgrid + for (var j = 0; j < ncols + 1; ++j) { + ctx.moveTo(wgrid * j, 0) + ctx.lineTo(wgrid * j, height) } ctx.closePath() @@ -242,15 +231,13 @@ AliceVision.PanoramaViewer { property int imagesLoaded: 0 property bool allImagesLoaded: false - function loadRepeaterImages(index) - { + function loadRepeaterImages(index) { if (index < repeater.model) - repeater.itemAt(index).loadItem(); + repeater.itemAt(index).loadItem() else - allImagesLoaded = true; + allImagesLoaded = true } - Item { id: panoImages width: root.width @@ -262,25 +249,25 @@ AliceVision.PanoramaViewer { id: floatOneLoader active: root.readyToLoad visible: (floatOneLoader.status === Loader.Ready) - z:0 + z: 0 property bool imageLoaded: false property bool loading: false onImageLoadedChanged: { - imagesLoaded++; - loadRepeaterImages(imagesLoaded); + imagesLoaded++ + loadRepeaterImages(imagesLoaded) } function loadItem() { - if(!active) - return; + if (!active) + return if (loading) { loadRepeaterImages(index + 1) - return; + return } - loading = true; + loading = true var idViewItem = msfmData.viewsIds[index] var sourceItem = Filepath.stringToUrl(msfmData.getUrlFromViewId(idViewItem)) @@ -288,22 +275,22 @@ AliceVision.PanoramaViewer { setSource("FloatImage.qml", { 'surface.viewerType': AliceVision.Surface.EViewerType.PANORAMA, 'viewerTypeString': 'panorama', - 'surface.subdivisions': Qt.binding(function() { return subdivisionsPano; }), - 'cropFisheye' : Qt.binding(function(){ return cropFisheyePano; }), - 'surface.pitch': Qt.binding(function() { return root.pitch; }), - 'surface.yaw': Qt.binding(function() { return root.yaw; }), - 'surface.roll': Qt.binding(function() { return root.roll; }), - 'idView': Qt.binding(function() { return idViewItem; }), - 'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue; }), - 'gain': Qt.binding(function() { return hdrImageToolbar.gainValue; }), - 'channelModeString': Qt.binding(function() { return hdrImageToolbar.channelModeValue; }), - 'downscaleLevel' : Qt.binding(function() { return downscale; }), - 'source': Qt.binding(function() { return sourceItem; }), + 'surface.subdivisions': Qt.binding(function() { return subdivisionsPano }), + 'cropFisheye' : Qt.binding(function(){ return cropFisheyePano }), + 'surface.pitch': Qt.binding(function() { return root.pitch }), + 'surface.yaw': Qt.binding(function() { return root.yaw }), + 'surface.roll': Qt.binding(function() { return root.roll }), + 'idView': Qt.binding(function() { return idViewItem }), + 'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue }), + 'gain': Qt.binding(function() { return hdrImageToolbar.gainValue }), + 'channelModeString': Qt.binding(function() { return hdrImageToolbar.channelModeValue }), + 'downscaleLevel' : Qt.binding(function() { return downscale }), + 'source': Qt.binding(function() { return sourceItem }), 'surface.msfmData': Qt.binding(function() { return root.msfmData }), 'canBeHovered': true, 'useSequence': false }) - imageLoaded = Qt.binding(function() { return repeater.itemAt(index).item.status === Image.Ready ? true : false; }) + imageLoaded = Qt.binding(function() { return repeater.itemAt(index).item.status === Image.Ready ? true : false }) } } @@ -317,7 +304,7 @@ AliceVision.PanoramaViewer { Connections { target: root function onDownscaleReady() { - root.imagesLoaded = 0; + root.imagesLoaded = 0 // Retrieve downscale value from C++ panoramaViewerToolbar.updateDownscaleValue(root.downscale) @@ -325,22 +312,19 @@ AliceVision.PanoramaViewer { //Changing the repeater model (number of elements) panoImages.updateRepeater() - root.readyToLoad = Image.Ready; + root.readyToLoad = Image.Ready // Load images two by two - loadRepeaterImages(0); - loadRepeaterImages(1); + loadRepeaterImages(0) + loadRepeaterImages(1) } } function updateRepeater() { - if(repeater.model !== root.msfmData.viewsIds.length){ - repeater.model = 0; + if (repeater.model !== root.msfmData.viewsIds.length) { + repeater.model = 0 } - repeater.model = root.msfmData.viewsIds.length; + repeater.model = root.msfmData.viewsIds.length } } - - - } diff --git a/meshroom/ui/qml/Viewer/SfmGlobalStats.qml b/meshroom/ui/qml/Viewer/SfmGlobalStats.qml index ed50dd54..6a99a430 100644 --- a/meshroom/ui/qml/Viewer/SfmGlobalStats.qml +++ b/meshroom/ui/qml/Viewer/SfmGlobalStats.qml @@ -115,9 +115,8 @@ FloatingPane { checkState: residualsPerViewLegend.buttonGroup.checkState onClicked: { var _checked = checked; - for(var i = 0; i < residualsPerViewChart.count; ++i) - { - residualsPerViewChart.series(i).visible = _checked; + for (var i = 0; i < residualsPerViewChart.count; ++i) { + residualsPerViewChart.series(i).visible = _checked } } } @@ -214,9 +213,8 @@ FloatingPane { checkState: observationsLengthsPerViewLegend.buttonGroup.checkState onClicked: { var _checked = checked; - for(var i = 0; i < observationsLengthsPerViewChart.count; ++i) - { - observationsLengthsPerViewChart.series(i).visible = _checked; + for (var i = 0; i < observationsLengthsPerViewChart.count; ++i) { + observationsLengthsPerViewChart.series(i).visible = _checked } } } @@ -225,7 +223,6 @@ FloatingPane { id: observationsLengthsPerViewLegend chartView: observationsLengthsPerViewChart } - } } @@ -278,7 +275,6 @@ FloatingPane { anchors.leftMargin: landmarksPerViewChart.width * 0.25 RowLayout { - ChartViewCheckBox { id: allFeatures text: "ALL" @@ -286,9 +282,8 @@ FloatingPane { checkState: landmarksFeatTracksPerViewLegend.buttonGroup.checkState onClicked: { var _checked = checked; - for(var i = 0; i < landmarksPerViewChart.count; ++i) - { - landmarksPerViewChart.series(i).visible = _checked; + for (var i = 0; i < landmarksPerViewChart.count; ++i) { + landmarksPerViewChart.series(i).visible = _checked } } } @@ -297,7 +292,6 @@ FloatingPane { id: landmarksFeatTracksPerViewLegend chartView: landmarksPerViewChart } - } } @@ -308,20 +302,20 @@ FloatingPane { mTracks: root.mTracks onAxisChanged: { - fillLandmarksPerViewSerie(landmarksPerViewLineSerie); - fillTracksPerViewSerie(tracksPerViewLineSerie); - fillResidualsMinPerViewSerie(residualsMinPerViewLineSerie); - fillResidualsMaxPerViewSerie(residualsMaxPerViewLineSerie); - fillResidualsMeanPerViewSerie(residualsMeanPerViewLineSerie); - fillResidualsMedianPerViewSerie(residualsMedianPerViewLineSerie); - fillResidualsFirstQuartilePerViewSerie(residualsFirstQuartilePerViewLineSerie); - fillResidualsThirdQuartilePerViewSerie(residualsThirdQuartilePerViewLineSerie); - fillObservationsLengthsMinPerViewSerie(observationsLengthsMinPerViewLineSerie); - fillObservationsLengthsMaxPerViewSerie(observationsLengthsMaxPerViewLineSerie); - fillObservationsLengthsMeanPerViewSerie(observationsLengthsMeanPerViewLineSerie); - fillObservationsLengthsMedianPerViewSerie(observationsLengthsMedianPerViewLineSerie); - fillObservationsLengthsFirstQuartilePerViewSerie(observationsLengthsFirstQuartilePerViewLineSerie); - fillObservationsLengthsThirdQuartilePerViewSerie(observationsLengthsThirdQuartilePerViewLineSerie); + fillLandmarksPerViewSerie(landmarksPerViewLineSerie) + fillTracksPerViewSerie(tracksPerViewLineSerie) + fillResidualsMinPerViewSerie(residualsMinPerViewLineSerie) + fillResidualsMaxPerViewSerie(residualsMaxPerViewLineSerie) + fillResidualsMeanPerViewSerie(residualsMeanPerViewLineSerie) + fillResidualsMedianPerViewSerie(residualsMedianPerViewLineSerie) + fillResidualsFirstQuartilePerViewSerie(residualsFirstQuartilePerViewLineSerie) + fillResidualsThirdQuartilePerViewSerie(residualsThirdQuartilePerViewLineSerie) + fillObservationsLengthsMinPerViewSerie(observationsLengthsMinPerViewLineSerie) + fillObservationsLengthsMaxPerViewSerie(observationsLengthsMaxPerViewLineSerie) + fillObservationsLengthsMeanPerViewSerie(observationsLengthsMeanPerViewLineSerie) + fillObservationsLengthsMedianPerViewSerie(observationsLengthsMedianPerViewLineSerie) + fillObservationsLengthsFirstQuartilePerViewSerie(observationsLengthsFirstQuartilePerViewLineSerie) + fillObservationsLengthsThirdQuartilePerViewSerie(observationsLengthsThirdQuartilePerViewLineSerie) } } } diff --git a/meshroom/ui/qml/Viewer/SfmStatsView.qml b/meshroom/ui/qml/Viewer/SfmStatsView.qml index 62863409..86d89ece 100644 --- a/meshroom/ui/qml/Viewer/SfmStatsView.qml +++ b/meshroom/ui/qml/Viewer/SfmStatsView.qml @@ -88,9 +88,8 @@ FloatingPane { checkState: residualLegend.buttonGroup.checkState onClicked: { var _checked = checked; - for(var i = 0; i < residualChart.count; ++i) - { - residualChart.series(i).visible = _checked; + for (var i = 0; i < residualChart.count; ++i) { + residualChart.series(i).visible = _checked } } } @@ -141,8 +140,7 @@ FloatingPane { axisY: observationsLengthsvalueAxisY name: "Current" } - - } + } Item { id: observationsLengthsBtnContainer @@ -162,9 +160,8 @@ FloatingPane { checkState: observationsLengthsLegend.buttonGroup.checkState onClicked: { var _checked = checked; - for(var i = 0; i < observationsLengthsChart.count; ++i) - { - observationsLengthsChart.series(i).visible = _checked; + for (var i = 0; i < observationsLengthsChart.count; ++i) { + observationsLengthsChart.series(i).visible = _checked } } } @@ -173,7 +170,6 @@ FloatingPane { id: observationsLengthsLegend chartView: observationsLengthsChart } - } } @@ -232,9 +228,8 @@ FloatingPane { checkState: observationsScaleLegend.buttonGroup.checkState onClicked: { var _checked = checked; - for(var i = 0; i < observationsScaleChart.count; ++i) - { - observationsScaleChart.series(i).visible = _checked; + for (var i = 0; i < observationsScaleChart.count; ++i) { + observationsScaleChart.series(i).visible = _checked } } } @@ -252,12 +247,12 @@ FloatingPane { msfmData: (root.visible && root.msfmData && root.msfmData.status === AliceVision.MSfMData.Ready) ? root.msfmData : null viewId: root.viewId onViewStatsChanged: { - fillResidualFullSerie(residualFullLineSerie); - fillResidualViewSerie(residualViewLineSerie); - fillObservationsLengthsFullSerie(observationsLengthsFullLineSerie); - fillObservationsLengthsViewSerie(observationsLengthsViewLineSerie); - fillObservationsScaleFullSerie(observationsScaleFullLineSerie); - fillObservationsScaleViewSerie(observationsScaleViewLineSerie); + fillResidualFullSerie(residualFullLineSerie) + fillResidualViewSerie(residualViewLineSerie) + fillObservationsLengthsFullSerie(observationsLengthsFullLineSerie) + fillObservationsLengthsViewSerie(observationsLengthsViewLineSerie) + fillObservationsScaleFullSerie(observationsScaleFullLineSerie) + fillObservationsScaleViewSerie(observationsScaleViewLineSerie) } } } diff --git a/meshroom/ui/qml/Viewer/Viewer2D.qml b/meshroom/ui/qml/Viewer/Viewer2D.qml index 958a134a..70c9aa45 100644 --- a/meshroom/ui/qml/Viewer/Viewer2D.qml +++ b/meshroom/ui/qml/Viewer/Viewer2D.qml @@ -34,24 +34,24 @@ FocusScope { // Metadata from viewpoint attribute // Read from the reconstruction object if (_reconstruction) { - let vp = getViewpoint(_reconstruction.selectedViewId); + let vp = getViewpoint(_reconstruction.selectedViewId) if (vp) { - return JSON.parse(vp.childAttribute("metadata").value); + return JSON.parse(vp.childAttribute("metadata").value) } } - return {}; + return {} } property variant imgMetadata: { // Metadata from FloatImage viewer // Directly read from the image file on disk if (floatImageViewerLoader.active) { - return floatImageViewerLoader.item.metadata; + return floatImageViewerLoader.item.metadata } // Use viewpoint metadata for the special case of the 8-bit viewer if (qtImageViewerLoader.active) { - return viewpointMetadata; + return viewpointMetadata } - return {}; + return {} } } @@ -64,48 +64,43 @@ FocusScope { readonly property bool aliceVisionPluginAvailable: aliceVisionPluginLoader.status === Component.Ready Component.onCompleted: { - if(!aliceVisionPluginAvailable) { + if (!aliceVisionPluginAvailable) { console.warn("Missing plugin qtAliceVision.") displayHDR.checked = false } } property string loadingModules: { - if(!imgContainer.image) - return ""; - var res = ""; - if(imgContainer.image.status === Image.Loading) - { - res += " Image"; + if (!imgContainer.image) + return "" + var res = "" + if (imgContainer.image.status === Image.Loading) { + res += " Image" } - if(mfeaturesLoader.status === Loader.Ready) - { - if(mfeaturesLoader.item && mfeaturesLoader.item.status === MFeatures.Loading) - res += " Features"; + if (mfeaturesLoader.status === Loader.Ready) { + if (mfeaturesLoader.item && mfeaturesLoader.item.status === MFeatures.Loading) + res += " Features" } - if(mtracksLoader.status === Loader.Ready) - { - if(mtracksLoader.item && mtracksLoader.item.status === MTracks.Loading) - res += " Tracks"; + if (mtracksLoader.status === Loader.Ready) { + if (mtracksLoader.item && mtracksLoader.item.status === MTracks.Loading) + res += " Tracks" } - if(msfmDataLoader.status === Loader.Ready) - { - if(msfmDataLoader.item && msfmDataLoader.item.status === MSfMData.Loading) - res += " SfMData"; + if (msfmDataLoader.status === Loader.Ready) { + if (msfmDataLoader.item && msfmDataLoader.item.status === MSfMData.Loading) + res += " SfMData" } - return res; + return res } - function clear() - { + function clear() { source = '' } // slots Keys.onPressed: { - if(event.key === Qt.Key_F) { - root.fit(); - event.accepted = true; + if (event.key === Qt.Key_F) { + root.fit() + event.accepted = true } } @@ -116,85 +111,85 @@ FocusScope { acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton onPressed: { imgContainer.forceActiveFocus() - if(mouse.button & Qt.MiddleButton || (mouse.button & Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier)) + if (mouse.button & Qt.MiddleButton || (mouse.button & Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier)) drag.target = imgContainer // start drag } onReleased: { drag.target = undefined // stop drag - if(mouse.button & Qt.RightButton) { - var menu = contextMenu.createObject(root); - menu.x = mouse.x; - menu.y = mouse.y; + if (mouse.button & Qt.RightButton) { + var menu = contextMenu.createObject(root) + menu.x = mouse.x + menu.y = mouse.y menu.open() } } onWheel: { - var zoomFactor = wheel.angleDelta.y > 0 ? factor : 1/factor; + var zoomFactor = wheel.angleDelta.y > 0 ? factor : 1 / factor - if(Math.min(imgContainer.width, imgContainer.image.height) * imgContainer.scale * zoomFactor < 10) - return; - var point = mapToItem(imgContainer, wheel.x, wheel.y); - imgContainer.x += (1-zoomFactor) * point.x * imgContainer.scale; - imgContainer.y += (1-zoomFactor) * point.y * imgContainer.scale; - imgContainer.scale *= zoomFactor; + if (Math.min(imgContainer.width, imgContainer.image.height) * imgContainer.scale * zoomFactor < 10) + return + var point = mapToItem(imgContainer, wheel.x, wheel.y) + imgContainer.x += (1-zoomFactor) * point.x * imgContainer.scale + imgContainer.y += (1-zoomFactor) * point.y * imgContainer.scale + imgContainer.scale *= zoomFactor } } onEnable8bitViewerChanged: { if (!enable8bitViewer) { - displayHDR.checked = true; + displayHDR.checked = true } } // functions function fit() { // make sure the image is ready for use - if(!imgContainer.image) - return; + if (!imgContainer.image) + return // for Exif orientation tags 5 to 8, a 90 degrees rotation is applied // therefore image dimensions must be inverted - let dimensionsInverted = ["5", "6", "7", "8"].includes(imgContainer.orientationTag); - let orientedWidth = dimensionsInverted ? imgContainer.image.height : imgContainer.image.width; - let orientedHeight = dimensionsInverted ? imgContainer.image.width : imgContainer.image.height; + let dimensionsInverted = ["5", "6", "7", "8"].includes(imgContainer.orientationTag) + let orientedWidth = dimensionsInverted ? imgContainer.image.height : imgContainer.image.width + let orientedHeight = dimensionsInverted ? imgContainer.image.width : imgContainer.image.height // fit oriented image - imgContainer.scale = Math.min(imgLayout.width / orientedWidth, root.height / orientedHeight); - imgContainer.x = Math.max((imgLayout.width - orientedWidth * imgContainer.scale)*0.5, 0); - imgContainer.y = Math.max((imgLayout.height - orientedHeight * imgContainer.scale)*0.5, 0); + imgContainer.scale = Math.min(imgLayout.width / orientedWidth, root.height / orientedHeight) + imgContainer.x = Math.max((imgLayout.width - orientedWidth * imgContainer.scale) * 0.5, 0) + imgContainer.y = Math.max((imgLayout.height - orientedHeight * imgContainer.scale) * 0.5, 0) // correct position when image dimensions are inverted // so that container center corresponds to image center - imgContainer.x += (orientedWidth - imgContainer.image.width) * 0.5 * imgContainer.scale; - imgContainer.y += (orientedHeight - imgContainer.image.height) * 0.5 * imgContainer.scale; + imgContainer.x += (orientedWidth - imgContainer.image.width) * 0.5 * imgContainer.scale + imgContainer.y += (orientedHeight - imgContainer.image.height) * 0.5 * imgContainer.scale } function tryLoadNode(node) { - useExternal = false; + useExternal = false // safety check if (!node) { - return false; + return false } // node must be computed or at least running if (!node.isPartiallyFinished()) { - return false; + return false } // node must have at least one output attribute with the image semantic if (!node.hasImageOutput) { - return false; + return false } - displayedNode = node; - return true; + displayedNode = node + return true } function loadExternal(path) { - useExternal = true; - sourceExternal = path; - displayedNode = null; + useExternal = true + sourceExternal = path + displayedNode = null } function getViewpoint(viewId) { @@ -202,13 +197,13 @@ FocusScope { // This requires to loop over all viewpoints for (var i = 0; i < _reconstruction.viewpoints.count; i++) { - var vp = _reconstruction.viewpoints.at(i); + var vp = _reconstruction.viewpoints.at(i) if (vp.childAttribute("viewId").value == viewId) { - return vp; + return vp } } - return undefined; + return undefined } function getAttributeByName(node, attrName) { @@ -216,13 +211,13 @@ FocusScope { // This requires to loop over all atributes for (var i = 0; i < node.attributes.count; i++) { - var attr = node.attributes.at(i); + var attr = node.attributes.at(i) if (attr.name == attrName) { - return attr; + return attr } } - return undefined; + return undefined } function resolve(path, vp) { @@ -234,11 +229,11 @@ FocusScope { "": vp.childAttribute("poseId").value, "": vp.childAttribute("path").value, "": Filepath.removeExtension(Filepath.basename(vp.childAttribute("path").value)), - }; + } let resolved = path; for (let key in replacements) { - resolved = resolved.replace(key, replacements[key]); + resolved = resolved.replace(key, replacements[key]) } return resolved; @@ -248,24 +243,24 @@ FocusScope { // Entry point for getting the image file URL if (useExternal) { - return sourceExternal; + return sourceExternal } if (_reconstruction && (!displayedNode || outputAttribute.name == "gallery")) { - let vp = getViewpoint(_reconstruction.pickedViewId); - let path = vp ? vp.childAttribute("path").value : ""; - return Filepath.stringToUrl(path); + let vp = getViewpoint(_reconstruction.pickedViewId) + let path = vp ? vp.childAttribute("path").value : "" + return Filepath.stringToUrl(path) } if (_reconstruction) { - let vp = getViewpoint(_reconstruction.pickedViewId); - let attr = getAttributeByName(displayedNode, outputAttribute.name); - let path = attr ? attr.value : ""; - let resolved = vp ? resolve(path, vp) : ""; - return Filepath.stringToUrl(resolved); + let vp = getViewpoint(_reconstruction.pickedViewId) + let attr = getAttributeByName(displayedNode, outputAttribute.name) + let path = attr ? attr.value : "" + let resolved = vp ? resolve(path, vp) : "" + return Filepath.stringToUrl(resolved) } - return undefined; + return undefined } function buildOrderedSequence(path_template) { @@ -274,66 +269,66 @@ FocusScope { let objs = [] for (let i = 0; i < _reconstruction.viewpoints.count; i++) { - objs.push(_reconstruction.viewpoints.at(i)); + objs.push(_reconstruction.viewpoints.at(i)) } - objs.sort((a, b) => { return a.childAttribute("path").value < b.childAttribute("path").value ? -1 : 1; }); + objs.sort((a, b) => { return a.childAttribute("path").value < b.childAttribute("path").value ? -1 : 1; }) let seq = []; for (let i = 0; i < objs.length; i++) { - seq.push(resolve(path_template, objs[i])); + seq.push(resolve(path_template, objs[i])) } - return seq; + return seq } function getSequence() { // Entry point for getting the current image sequence if (useExternal) { - return []; + return [] } if (_reconstruction && (!displayedNode || outputAttribute.name == "gallery")) { - return buildOrderedSequence(""); + return buildOrderedSequence("") } if (_reconstruction) { - let attr = getAttributeByName(displayedNode, outputAttribute.name); - let path_template = attr ? attr.value : ""; - return buildOrderedSequence(path_template); + let attr = getAttributeByName(displayedNode, outputAttribute.name) + let path_template = attr ? attr.value : "" + return buildOrderedSequence(path_template) } - return []; + return [] } onDisplayedNodeChanged: { if (!displayedNode) { - root.source = ""; + root.source = "" } // update output attribute names - var names = []; + var names = [] if (displayedNode) { // store attr name for output attributes that represent images for (var i = 0; i < displayedNode.attributes.count; i++) { - var attr = displayedNode.attributes.at(i); + var attr = displayedNode.attributes.at(i) if (attr.isOutput && attr.desc.semantic === "image" && attr.enabled) { - names.push(attr.name); + names.push(attr.name) } } } - names.push("gallery"); - outputAttribute.names = names; + names.push("gallery") + outputAttribute.names = names - root.source = getImageFile(); + root.source = getImageFile() } Connections { target: _reconstruction function onSelectedViewIdChanged() { - root.source = getImageFile(); + root.source = getImageFile() if (useExternal) - useExternal = false; + useExternal = false } } @@ -343,6 +338,7 @@ FocusScope { tryLoadNode(displayedNode) } } + // context menu property Component contextMenu: Menu { MenuItem { @@ -353,8 +349,8 @@ FocusScope { text: "Zoom 100%" onTriggered: { imgContainer.scale = 1 - imgContainer.x = Math.max((imgLayout.width-imgContainer.width*imgContainer.scale)*0.5, 0) - imgContainer.y = Math.max((imgLayout.height-imgContainer.height*imgContainer.scale)*0.5, 0) + imgContainer.x = Math.max((imgLayout.width - imgContainer.width * imgContainer.scale) * 0.5, 0) + imgContainer.y = Math.max((imgLayout.height - imgContainer.height * imgContainer.scale) * 0.5, 0) } } } @@ -368,26 +364,23 @@ FocusScope { visible: displayImageToolBarAction.checked && displayImageToolBarAction.enabled Layout.fillWidth: true onVisibleChanged: { - resetDefaultValues(); + resetDefaultValues() } colorPickerVisible: { return !displayPanoramaViewer.checked } colorRGBA: { - if(!floatImageViewerLoader.item || - floatImageViewerLoader.item.status !== Image.Ready) - { - return null; + if (!floatImageViewerLoader.item || + floatImageViewerLoader.item.status !== Image.Ready) { + return null } - if(floatImageViewerLoader.item.containsMouse === false) - { - return null; + if (floatImageViewerLoader.item.containsMouse === false) { + return null } - var pix = floatImageViewerLoader.item.pixelValueAt(Math.floor(floatImageViewerLoader.item.mouseX), Math.floor(floatImageViewerLoader.item.mouseY)); - return pix; + var pix = floatImageViewerLoader.item.pixelValueAt(Math.floor(floatImageViewerLoader.item.mouseX), Math.floor(floatImageViewerLoader.item.mouseY)) + return pix } - } LensDistortionToolbar { @@ -439,7 +432,7 @@ FocusScope { property bool fittedOnce: false property int previousWidth: 0 property int previousHeight: 0 - property real targetSize: Math.max(width, height) * imgContainer.scale; + property real targetSize: Math.max(width, height) * imgContainer.scale onHeightChanged: { /* Image size is not updated through a single signal with the floatImage viewer, unlike * the simple QML image viewer: instead of updating straight away the width and height to x and @@ -454,39 +447,39 @@ FocusScope { * performed */ if ((!fittedOnce && imgContainer.image && imgContainer.image.height > 0) || (fittedOnce && ((width > 1 && previousWidth != width) || (height > 1 && previousHeight != height)))) { - fit(); - fittedOnce = true; - previousWidth = width; - previousHeight = height; + fit() + fittedOnce = true + previousWidth = width + previousHeight = height } } onActiveChanged: { if (active) { - // instantiate and initialize a FLoatImage component dynamically using Loader.setSource + // Instantiate and initialize a FLoatImage component dynamically using Loader.setSource // Note: It does not work to use previously created component, so we re-create it with setSource. setSource("FloatImage.qml", { - 'source': Qt.binding(function() { return getImageFile(); }), - 'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue; }), - 'gain': Qt.binding(function() { return hdrImageToolbar.gainValue; }), - 'channelModeString': Qt.binding(function() { return hdrImageToolbar.channelModeValue; }), - 'isPrincipalPointsDisplayed' : Qt.binding(function(){ return lensDistortionImageToolbar.displayPrincipalPoint;}), - 'surface.displayGrid' : Qt.binding(function(){ return lensDistortionImageToolbar.visible && lensDistortionImageToolbar.displayGrid;}), - 'surface.gridOpacity' : Qt.binding(function(){ return lensDistortionImageToolbar.opacityValue;}), - 'surface.gridColor' : Qt.binding(function(){ return lensDistortionImageToolbar.color;}), - 'surface.subdivisions' : Qt.binding(function(){ return root.useFloatImageViewer ? 1 : lensDistortionImageToolbar.subdivisionsValue;}), - 'viewerTypeString': Qt.binding(function(){ return displayLensDistortionViewer.checked ? "distortion" : "hdr";}), - 'sfmRequired': Qt.binding(function(){ return displayLensDistortionViewer.checked ? true : false;}), - 'surface.msfmData': Qt.binding(function() { return (msfmDataLoader.status === Loader.Ready && msfmDataLoader.item != null && msfmDataLoader.item.status === 2) ? msfmDataLoader.item : null; }), + 'source': Qt.binding(function() { return getImageFile() }), + 'gamma': Qt.binding(function() { return hdrImageToolbar.gammaValue }), + 'gain': Qt.binding(function() { return hdrImageToolbar.gainValue }), + 'channelModeString': Qt.binding(function() { return hdrImageToolbar.channelModeValue }), + 'isPrincipalPointsDisplayed' : Qt.binding(function() { return lensDistortionImageToolbar.displayPrincipalPoint }), + 'surface.displayGrid' : Qt.binding(function() { return lensDistortionImageToolbar.visible && lensDistortionImageToolbar.displayGrid }), + 'surface.gridOpacity' : Qt.binding(function() { return lensDistortionImageToolbar.opacityValue }), + 'surface.gridColor' : Qt.binding(function() { return lensDistortionImageToolbar.color }), + 'surface.subdivisions' : Qt.binding(function() { return root.useFloatImageViewer ? 1 : lensDistortionImageToolbar.subdivisionsValue }), + 'viewerTypeString': Qt.binding(function() { return displayLensDistortionViewer.checked ? "distortion" : "hdr" }), + 'sfmRequired': Qt.binding(function() { return displayLensDistortionViewer.checked ? true : false }), + 'surface.msfmData': Qt.binding(function() { return (msfmDataLoader.status === Loader.Ready && msfmDataLoader.item != null && msfmDataLoader.item.status === 2) ? msfmDataLoader.item : null }), 'canBeHovered': false, - 'idView': Qt.binding(function() { return (_reconstruction ? _reconstruction.selectedViewId : -1); }), + 'idView': Qt.binding(function() { return (_reconstruction ? _reconstruction.selectedViewId : -1) }), 'cropFisheye': false, - 'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && _reconstruction && _reconstruction.viewpoints.count > 0) ? getSequence() : []); }), - 'targetSize': Qt.binding(function() { return floatImageViewerLoader.targetSize; }), - 'useSequence': Qt.binding(function() { return root.enableSequencePlayer && !useExternal && _reconstruction; }), + 'sequence': Qt.binding(function() { return ((root.enableSequencePlayer && _reconstruction && _reconstruction.viewpoints.count > 0) ? getSequence() : []) }), + 'targetSize': Qt.binding(function() { return floatImageViewerLoader.targetSize }), + 'useSequence': Qt.binding(function() { return root.enableSequencePlayer && !useExternal && _reconstruction }), }) } else { - // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 + // Forcing the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 setSource("", {}) fittedOnce = false } @@ -501,22 +494,22 @@ FocusScope { anchors.centerIn: parent onActiveChanged: { - if(active) { + if (active) { setSource("PanoramaViewer.qml", { - 'subdivisionsPano': Qt.binding(function(){ return panoramaViewerToolbar.subdivisionsValue;}), - 'cropFisheyePano': Qt.binding(function(){ return root.cropFisheye;}), - 'downscale': Qt.binding(function(){ return panoramaViewerToolbar.downscaleValue;}), - 'isEditable': Qt.binding(function(){ return panoramaViewerToolbar.enableEdit;}), - 'isHighlightable': Qt.binding(function(){ return panoramaViewerToolbar.enableHover;}), - 'displayGridPano': Qt.binding(function(){ return panoramaViewerToolbar.displayGrid;}), - 'mouseMultiplier': Qt.binding(function(){ return panoramaViewerToolbar.mouseSpeed;}), + 'subdivisionsPano': Qt.binding(function() { return panoramaViewerToolbar.subdivisionsValue }), + 'cropFisheyePano': Qt.binding(function() { return root.cropFisheye }), + 'downscale': Qt.binding(function() { return panoramaViewerToolbar.downscaleValue }), + 'isEditable': Qt.binding(function() { return panoramaViewerToolbar.enableEdit }), + 'isHighlightable': Qt.binding(function() { return panoramaViewerToolbar.enableHover }), + 'displayGridPano': Qt.binding(function() { return panoramaViewerToolbar.displayGrid }), + 'mouseMultiplier': Qt.binding(function() { return panoramaViewerToolbar.mouseSpeed }), 'msfmData': Qt.binding(function() { return (msfmDataLoader && msfmDataLoader.item && msfmDataLoader.status === Loader.Ready - && msfmDataLoader.item.status === 2) ? msfmDataLoader.item : null; }), + && msfmDataLoader.item.status === 2) ? msfmDataLoader.item : null }), }) } else { - // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 + // Forcing the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 setSource("", {}) - displayPanoramaViewer.checked = false; + displayPanoramaViewer.checked = false } } } @@ -534,11 +527,11 @@ FocusScope { asynchronous: true smooth: false fillMode: Image.PreserveAspectFit - onWidthChanged: if(status==Image.Ready) fit() + onWidthChanged: if (status==Image.Ready) fit() source: getImageFile() onStatusChanged: { // update cache source when image is loaded - if(status === Image.Ready) + if (status === Image.Ready) qtImageViewerCache.source = source } @@ -583,32 +576,31 @@ FocusScope { yOrigin: imgContainer.height / 2 onActiveChanged: { - if(active) { - - // instantiate and initialize a FeaturesViewer component dynamically using Loader.setSource + if (active) { + // Instantiate and initialize a FeaturesViewer component dynamically using Loader.setSource setSource("FeaturesViewer.qml", { - 'model': Qt.binding(function() { return activeNode ? activeNode.attribute("describerTypes").value : ""; }), - 'currentViewId': Qt.binding(function() { return _reconstruction.selectedViewId; }), - 'features': Qt.binding(function() { return mfeaturesLoader.status === Loader.Ready ? mfeaturesLoader.item : null; }), - 'tracks': Qt.binding(function() { return mtracksLoader.status === Loader.Ready ? mtracksLoader.item : null; }), - 'sfmData': Qt.binding(function() { return msfmDataLoader.status === Loader.Ready ? msfmDataLoader.item : null; }), + 'model': Qt.binding(function() { return activeNode ? activeNode.attribute("describerTypes").value : "" }), + 'currentViewId': Qt.binding(function() { return _reconstruction.selectedViewId }), + 'features': Qt.binding(function() { return mfeaturesLoader.status === Loader.Ready ? mfeaturesLoader.item : null }), + 'tracks': Qt.binding(function() { return mtracksLoader.status === Loader.Ready ? mtracksLoader.item : null }), + 'sfmData': Qt.binding(function() { return msfmDataLoader.status === Loader.Ready ? msfmDataLoader.item : null }), }) } else { - // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 + // Forcing the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 setSource("", {}) } } } // FisheyeCircleViewer: display fisheye circle - // note: use a Loader to evaluate if a PanoramaInit node exist and displayFisheyeCircle checked at runtime + // Note: use a Loader to evaluate if a PanoramaInit node exist and displayFisheyeCircle checked at runtime ExifOrientedViewer { anchors.centerIn: parent orientationTag: imgContainer.orientationTag xOrigin: imgContainer.width / 2 yOrigin: imgContainer.height / 2 property var activeNode: _reconstruction ? _reconstruction.activeNodes.get("PanoramaInit").node : null - active: (displayFisheyeCircleLoader.checked && activeNode) + active: displayFisheyeCircleLoader.checked && activeNode sourceComponent: CircleGizmo { width: imgContainer.width @@ -627,17 +619,15 @@ FocusScope { circleBorder.width: Math.max(1, (3.0 / imgContainer.scale)) onMoved: { - if(!useAuto) - { + if (!useAuto) { _reconstruction.setAttribute( activeNode.attribute("fisheyeCenterOffset"), JSON.stringify([xoffset, yoffset]) - ); + ) } } onIncrementRadius: { - if(!useAuto) - { + if (!useAuto) { _reconstruction.setAttribute(activeNode.attribute("fisheyeRadius"), activeNode.attribute("fisheyeRadius").value + radiusOffset) } } @@ -651,7 +641,7 @@ FocusScope { xOrigin: imgContainer.width / 2 yOrigin: imgContainer.height / 2 property var activeNode: _reconstruction.activeNodes.get("SphereDetection").node - active: (displayLightingCircleLoader.checked && activeNode) + active: displayLightingCircleLoader.checked && activeNode sourceComponent: CircleGizmo { width: imgContainer.width @@ -668,7 +658,7 @@ FocusScope { _reconstruction.setAttribute( activeNode.attribute("sphereCenter"), JSON.stringify([xoffset, yoffset]) - ); + ) } onIncrementRadius: { _reconstruction.setAttribute(activeNode.attribute("sphereRadius"), activeNode.attribute("sphereRadius").value + radiusOffset) @@ -774,13 +764,12 @@ FocusScope { metadata: { if (visible) { if (root.useExternal || outputAttribute.name != "gallery") { - return m.imgMetadata; - } - else { - return m.viewpointMetadata; + return m.imgMetadata + } else { + return m.viewpointMetadata } } - return {}; + return {} } } @@ -801,50 +790,49 @@ FocusScope { property bool isUsed: displayFeatures.checked property var activeNode: { if (!root.aliceVisionPluginAvailable) { - return null; + return null } - return _reconstruction ? _reconstruction.activeNodes.get("featureProvider").node : null; + return _reconstruction ? _reconstruction.activeNodes.get("featureProvider").node : null } property bool isComputed: activeNode && activeNode.isComputed active: isUsed && isComputed onActiveChanged: { - if(active) { + if (active) { // instantiate and initialize a MFeatures component dynamically using Loader.setSource // so it can fail safely if the c++ plugin is not available setSource("MFeatures.qml", { 'describerTypes': Qt.binding(function() { - return activeNode ? activeNode.attribute("describerTypes").value : {}; + return activeNode ? activeNode.attribute("describerTypes").value : {} }), 'featureFolders': Qt.binding(function() { - let result = []; + let result = [] if (activeNode) { if (activeNode.nodeType == "FeatureExtraction" && isComputed) { - result.push(activeNode.attribute("output").value); + result.push(activeNode.attribute("output").value) } else if (activeNode.hasAttribute("featuresFolders")) { for (let i = 0; i < activeNode.attribute("featuresFolders").value.count; i++) { - let attr = activeNode.attribute("featuresFolders").value.at(i); - result.push(attr.value); + let attr = activeNode.attribute("featuresFolders").value.at(i) + result.push(attr.value) } } } - return result; + return result }), 'viewIds': Qt.binding(function() { if (_reconstruction) { let result = []; for (let i = 0; i < _reconstruction.viewpoints.count; i++) { - let vp = _reconstruction.viewpoints.at(i); - result.push(vp.childAttribute("viewId").value); + let vp = _reconstruction.viewpoints.at(i) + result.push(vp.childAttribute("viewId").value) } - return result; + return result } - return {}; + return {} }), }) - } else { - // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 + // Forcing the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 setSource("", {}) } } @@ -852,43 +840,44 @@ FocusScope { Loader { id: msfmDataLoader - property bool isUsed: displayFeatures.checked || displaySfmStatsView.checked || displaySfmDataGlobalStats.checked || displayPanoramaViewer.checked || displayLensDistortionViewer.checked + property bool isUsed: displayFeatures.checked || displaySfmStatsView.checked || displaySfmDataGlobalStats.checked + || displayPanoramaViewer.checked || displayLensDistortionViewer.checked property var activeNode: { - if(!root.aliceVisionPluginAvailable){ - return null; + if (!root.aliceVisionPluginAvailable) { + return null } - var nodeType = "sfm"; + var nodeType = "sfm" if (displayLensDistortionViewer.checked) { - nodeType = "sfmData"; + nodeType = "sfmData" } - var sfmNode = _reconstruction ? _reconstruction.activeNodes.get(nodeType).node : null; - if(sfmNode === null){ - return null; + var sfmNode = _reconstruction ? _reconstruction.activeNodes.get(nodeType).node : null + if (sfmNode === null) { + return null } - if(displayPanoramaViewer.checked){ - sfmNode = _reconstruction.activeNodes.get('SfMTransform').node; - var previousNode = sfmNode.attribute("input").rootLinkParam.node; - return previousNode; + if (displayPanoramaViewer.checked) { + sfmNode = _reconstruction.activeNodes.get('SfMTransform').node + var previousNode = sfmNode.attribute("input").rootLinkParam.node + return previousNode } - return sfmNode; + return sfmNode } property bool isComputed: activeNode && activeNode.isComputed property string filepath: { - var sfmValue = ""; + var sfmValue = "" if (isComputed && activeNode.hasAttribute("output")) { - sfmValue = activeNode.attribute("output").value; + sfmValue = activeNode.attribute("output").value } - return Filepath.stringToUrl(sfmValue); + return Filepath.stringToUrl(sfmValue) } active: isUsed && isComputed onActiveChanged: { - if(active) { + if (active) { // instantiate and initialize a SfmStatsView component dynamically using Loader.setSource // so it can fail safely if the c++ plugin is not available setSource("MSfMData.qml", { - 'sfmDataPath': Qt.binding(function() { return filepath; }), + 'sfmDataPath': Qt.binding(function() { return filepath }), }) } else { // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 @@ -902,36 +891,36 @@ FocusScope { property bool isUsed: displayFeatures.checked || displaySfmStatsView.checked || displaySfmDataGlobalStats.checked || displayPanoramaViewer.checked property var activeNode: { if (!root.aliceVisionPluginAvailable) { - return null; + return null } - return _reconstruction ? _reconstruction.activeNodes.get("matchProvider").node : null; + return _reconstruction ? _reconstruction.activeNodes.get("matchProvider").node : null } property bool isComputed: activeNode && activeNode.isComputed active: isUsed && isComputed onActiveChanged: { - if(active) { + if (active) { // instantiate and initialize a SfmStatsView component dynamically using Loader.setSource // so it can fail safely if the c++ plugin is not available setSource("MTracks.qml", { 'matchingFolders': Qt.binding(function() { - let result = []; + let result = [] if (activeNode) { if (activeNode.nodeType == "FeatureMatching" && isComputed) { - result.push(activeNode.attribute("output").value); + result.push(activeNode.attribute("output").value) } else if (activeNode.hasAttribute("matchesFolders")) { for (let i = 0; i < activeNode.attribute("matchesFolders").value.count; i++) { - let attr = activeNode.attribute("matchesFolders").value.at(i); - result.push(attr.value); + let attr = activeNode.attribute("matchesFolders").value.at(i) + result.push(attr.value) } } } - return result; + return result }), }) } else { - // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 + // Forcing the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14 setSource("", {}) } } @@ -946,8 +935,8 @@ FocusScope { // (necessary since Qt 5.14, Component.onCompleted cannot be used anymore to load the data once and for all) if (active) { setSource("SfmStatsView.qml", { - "msfmData": Qt.binding(function() { return msfmDataLoader.item; }), - "viewId": Qt.binding(function() { return _reconstruction.selectedViewId; }), + "msfmData": Qt.binding(function() { return msfmDataLoader.item }), + "viewId": Qt.binding(function() { return _reconstruction.selectedViewId }), }) } else { setSource("", {}) @@ -964,8 +953,8 @@ FocusScope { // (necessary since Qt 5.14, Component.onCompleted cannot be used anymore to load the data once and for all) if (active) { setSource("SfmGlobalStats.qml", { - 'msfmData': Qt.binding(function() { return msfmDataLoader.item; }), - 'mTracks': Qt.binding(function() { return mtracksLoader.item; }), + 'msfmData': Qt.binding(function() { return msfmDataLoader.item }), + 'mTracks': Qt.binding(function() { return mtracksLoader.item }), }) } else { @@ -1024,14 +1013,13 @@ FocusScope { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { - if(mouse.button & Qt.LeftButton) { + if (mouse.button & Qt.LeftButton) { fit() - } - else if(mouse.button & Qt.RightButton) { - var menu = contextMenu.createObject(root); + } else if (mouse.button & Qt.RightButton) { + var menu = contextMenu.createObject(root) var point = mapToItem(root, mouse.x, mouse.y) - menu.x = point.x; - menu.y = point.y; + menu.x = point.x + menu.y = point.y menu.open() } } @@ -1062,7 +1050,7 @@ FocusScope { visible: root.enable8bitViewer onCheckedChanged : { if (displayLensDistortionViewer.checked && checked) { - displayLensDistortionViewer.checked = false; + displayLensDistortionViewer.checked = false } root.useFloatImageViewer = !root.useFloatImageViewer } @@ -1071,19 +1059,17 @@ FocusScope { id: displayLensDistortionViewer property var activeNode: root.aliceVisionPluginAvailable && _reconstruction ? _reconstruction.activeNodes.get('sfmData').node : null property bool isComputed: { - if(!activeNode) - return false; - if(activeNode.isComputed) - { - return true; - } - if(!activeNode.hasAttribute("input")) - return false; - var inputAttr = activeNode.attribute("input"); - var inputAttrLink = inputAttr.rootLinkParam; - if(!inputAttrLink) - return false; - return inputAttrLink.node.isComputed; + if (!activeNode) + return false + if (activeNode.isComputed) + return true + if (!activeNode.hasAttribute("input")) + return false + var inputAttr = activeNode.attribute("input") + var inputAttrLink = inputAttr.rootLinkParam + if (!inputAttrLink) + return false + return inputAttrLink.node.isComputed } ToolTip.text: "Lens Distortion Viewer" + (isComputed ? (": " + activeNode.label) : "") @@ -1096,10 +1082,10 @@ FocusScope { enabled: activeNode && isComputed onCheckedChanged : { if ((displayHDR.checked || displayPanoramaViewer.checked) && checked) { - displayHDR.checked = false; - displayPanoramaViewer.checked = false; + displayHDR.checked = false + displayPanoramaViewer.checked = false } else if (!checked) { - displayHDR.checked = true; + displayHDR.checked = true } } } @@ -1107,17 +1093,17 @@ FocusScope { id: displayPanoramaViewer property var activeNode: root.aliceVisionPluginAvailable && _reconstruction ? _reconstruction.activeNodes.get('SfMTransform').node : null property bool isComputed: { - if(!activeNode) - return false; - if(activeNode.attribute("method").value !== "manual") - return false; - var inputAttr = activeNode.attribute("input"); - if(!inputAttr) - return false; - var inputAttrLink = inputAttr.rootLinkParam; - if(!inputAttrLink) - return false; - return inputAttrLink.node.isComputed; + if (!activeNode) + return false + if (activeNode.attribute("method").value !== "manual") + return false + var inputAttr = activeNode.attribute("input") + if (!inputAttr) + return false + var inputAttrLink = inputAttr.rootLinkParam + if (!inputAttrLink) + return false + return inputAttrLink.node.isComputed } ToolTip.text: activeNode ? "Panorama Viewer " + activeNode.label : "Panorama Viewer" @@ -1130,15 +1116,15 @@ FocusScope { enabled: activeNode && isComputed onCheckedChanged : { if (displayLensDistortionViewer.checked && checked) { - displayLensDistortionViewer.checked = false; + displayLensDistortionViewer.checked = false } if (displayFisheyeCircleLoader.checked && checked) { - displayFisheyeCircleLoader.checked = false; + displayFisheyeCircleLoader.checked = false } } onEnabledChanged : { if (!enabled) { - checked = false; + checked = false } } } @@ -1152,7 +1138,7 @@ FocusScope { checked: false enabled: root.aliceVisionPluginAvailable && !displayPanoramaViewer.checked onEnabledChanged : { - if(enabled == false) checked = false; + if (enabled == false) checked = false } } MaterialToolButton { @@ -1193,12 +1179,11 @@ FocusScope { checked: false visible: activeNode onEnabledChanged: { - if(enabled == false) + if (enabled == false) checked = false } onCheckedChanged: { - if(checked == true) - { + if (checked == true) { displaySfmDataGlobalStats.checked = false displaySfmStatsView.checked = false metadataCB.checked = false @@ -1220,7 +1205,7 @@ FocusScope { visible: activeNode onIsComputedChanged: { - if(!isComputed) + if (!isComputed) checked = false } } @@ -1252,7 +1237,7 @@ FocusScope { Layout.preferredWidth: model.reduce((acc, label) => Math.max(acc, fontMetrics.boundingRect(label).width), 0) + 3.0 * Qt.application.font.pixelSize onNameChanged: { - root.source = getImageFile(); + root.source = getImageFile() } } @@ -1268,7 +1253,7 @@ FocusScope { root.viewIn3D( root.source, displayedNode.name + ":" + outputAttribute.name + " " + String(_reconstruction.selectedViewId) - ); + ) } } @@ -1290,7 +1275,7 @@ FocusScope { checkable: enabled enabled: activeNode && activeNode.isComputed && _reconstruction.selectedViewId >= 0 onCheckedChanged: { - if(checked == true) { + if (checked == true) { displaySfmDataGlobalStats.checked = false metadataCB.checked = false displayColorCheckerViewerLoader.checked = false @@ -1316,7 +1301,7 @@ FocusScope { checkable: enabled enabled: activeNode && activeNode.isComputed onCheckedChanged: { - if(checked == true) { + if (checked == true) { displaySfmStatsView.checked = false metadataCB.checked = false displayColorCheckerViewerLoader.checked = false @@ -1338,15 +1323,13 @@ FocusScope { flat: true checkable: enabled onCheckedChanged: { - if(checked == true) - { + if (checked == true) { displaySfmDataGlobalStats.checked = false displaySfmStatsView.checked = false displayColorCheckerViewerLoader.checked = false } } } - } } @@ -1370,7 +1353,7 @@ FocusScope { Component.onCompleted: { running = Qt.binding(function() { return (root.usePanoramaViewer === true && imgContainer.image && imgContainer.image.allImagesLoaded === false) - || (imgContainer.image && imgContainer.image.status === Image.Loading) + || (imgContainer.image && imgContainer.image.status === Image.Loading) }) } // disable the visibility when unused to avoid stealing the mouseEvent to the image color picker @@ -1378,7 +1361,7 @@ FocusScope { onVisibleChanged: { if (panoramaViewerLoader.active) - fit(); + fit() } } }