From b916a923e1e1dc79b76fb2a1eabf95b8da5a9521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Mon, 16 Oct 2023 16:39:28 +0200 Subject: [PATCH 01/13] [GraphEditor] AttributeItemDelegate: Fix binding loop warning --- meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml b/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml index f64fc6fa27..dbb1d6ff81 100644 --- a/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml +++ b/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml @@ -496,7 +496,7 @@ RowLayout { || ((object.isDefault && GraphEditorSettings.showDefaultAttributes || !object.isDefault && GraphEditorSettings.showModifiedAttributes) && (object.isLinkNested && GraphEditorSettings.showLinkAttributes || !object.isLinkNested && GraphEditorSettings.showNotLinkAttributes)) visible: active - height: item ? implicitHeight : -spacing // compensate for spacing if item is hidden + height: implicitHeight sourceComponent: RowLayout { id: item property var childAttrib: object From 9249615bafb3d6c13e41ff22c2d9015b40098e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 11:15:20 +0200 Subject: [PATCH 02/13] [Viewer] ImageMetadataView: Check that value is set before assigning it This commit fixes the following errors: - ": Can't assign to existing role 'value' of different type [VariantMap -> String]" which occurs whenever the metadata view is enabled and appears if at least one of the metadata keys has an empty value; - "Unable to assign [undefined] to QString" which occurs whenever the search bar is cleared. --- meshroom/ui/qml/Viewer/ImageMetadataView.qml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/meshroom/ui/qml/Viewer/ImageMetadataView.qml b/meshroom/ui/qml/Viewer/ImageMetadataView.qml index 82d86e8ea2..d69b05b6c3 100644 --- a/meshroom/ui/qml/Viewer/ImageMetadataView.qml +++ b/meshroom/ui/qml/Viewer/ImageMetadataView.qml @@ -94,7 +94,13 @@ FloatingPane { entry["group"] = "-" entry["key"] = key } - entry["value"] = metadata[key] + + // If a key has an empty corresponding value, set it as an empty string. + // Otherwise it will be considered as a Variant Map. + if (typeof(metadata[key]) != "string") + entry["value"] = "" + else + entry["value"] = metadata[key] entry["raw"] = entry["group"] + ":" + entry["key"] + "=" + entry["value"] entries.push(entry) } @@ -199,7 +205,7 @@ FloatingPane { elide: Text.ElideRight } Label { - text: value + text: value != undefined ? value : "" Layout.fillWidth: true wrapMode: Label.WrapAtWordBoundaryOrAnywhere } From 9d2974d2823fe5d6f400eb4658f67d0306b11ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 11:25:37 +0200 Subject: [PATCH 03/13] [Viewer3D] Clean-up: Harmonize syntax across all the files --- .../qml/Viewer3D/DefaultCameraController.qml | 62 +++---- meshroom/ui/qml/Viewer3D/Grid3D.qml | 2 +- meshroom/ui/qml/Viewer3D/Inspector3D.qml | 18 +-- meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml | 10 +- .../Materials/SphericalHarmonicsMaterial.qml | 31 ++-- .../Viewer3D/Materials/WireframeEffect.qml | 12 +- .../Viewer3D/Materials/WireframeMaterial.qml | 8 +- meshroom/ui/qml/Viewer3D/MediaCache.qml | 66 ++++---- meshroom/ui/qml/Viewer3D/MediaLibrary.qml | 151 +++++++++--------- meshroom/ui/qml/Viewer3D/MediaLoader.qml | 120 +++++++------- .../ui/qml/Viewer3D/MeshingBoundingBox.qml | 2 +- .../ui/qml/Viewer3D/SfMTransformGizmo.qml | 2 +- meshroom/ui/qml/Viewer3D/TrackballGizmo.qml | 2 +- meshroom/ui/qml/Viewer3D/TransformGizmo.qml | 71 ++++---- .../ui/qml/Viewer3D/TransformGizmoPicker.qml | 5 +- meshroom/ui/qml/Viewer3D/Viewer3D.qml | 48 +++--- meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml | 14 +- meshroom/ui/qml/Viewer3D/ViewpointCamera.qml | 4 +- 18 files changed, 307 insertions(+), 321 deletions(-) diff --git a/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml b/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml index e4aa175a38..ff25ba1d67 100644 --- a/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml +++ b/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml @@ -48,50 +48,50 @@ Entity { property bool hasMoved sourceDevice: loseMouseFocus ? null : mouseSourceDevice onPressed: { - _pressed = true; - currentPosition.x = lastPosition.x = mouse.x; - currentPosition.y = lastPosition.y = mouse.y; - hasMoved = false; - mousePressed(mouse); + _pressed = true + currentPosition.x = lastPosition.x = mouse.x + currentPosition.y = lastPosition.y = mouse.y + hasMoved = false + mousePressed(mouse) } onReleased: { - _pressed = false; - mouseReleased(mouse, hasMoved); + _pressed = false + mouseReleased(mouse, hasMoved) } onClicked: mouseClicked(mouse) onPositionChanged: { - currentPosition.x = mouse.x; - currentPosition.y = mouse.y; + currentPosition.x = mouse.x + currentPosition.y = mouse.y - const dt = 0.02; - var d; + const dt = 0.02 + var d - if(panning) { // translate - d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.03; - var tx = axisMX.value * root.translateSpeed * d; - var ty = axisMY.value * root.translateSpeed * d; - mouseHandler.hasMoved = true; - root.camera.translate(Qt.vector3d(-tx, -ty, 0).times(dt)); - return; + if (panning) { // translate + d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.03 + var tx = axisMX.value * root.translateSpeed * d + var ty = axisMY.value * root.translateSpeed * d + mouseHandler.hasMoved = true + root.camera.translate(Qt.vector3d(-tx, -ty, 0).times(dt)) + return } - if(moving){ // trackball rotation - trackball.rotate(mouseHandler.lastPosition, mouseHandler.currentPosition, dt); - mouseHandler.lastPosition = mouseHandler.currentPosition; - mouseHandler.hasMoved = true; - return; + if (moving){ // trackball rotation + trackball.rotate(mouseHandler.lastPosition, mouseHandler.currentPosition, dt) + mouseHandler.lastPosition = mouseHandler.currentPosition + mouseHandler.hasMoved = true + return } - if(zooming) { // zoom with alt + RMD - d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.1; - var tz = axisMX.value * root.translateSpeed * d; - mouseHandler.hasMoved = true; + if (zooming) { // zoom with alt + RMD + d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.1 + var tz = axisMX.value * root.translateSpeed * d + mouseHandler.hasMoved = true root.camera.translate(Qt.vector3d(0, 0, tz).times(dt), Camera.DontTranslateViewCenter) - return; + return } } onDoubleClicked: mouseDoubleClicked(mouse) onWheel: { - var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.2; - var tz = (wheel.angleDelta.y / 120) * d; + var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.2 + var tz = (wheel.angleDelta.y / 120) * d root.camera.translate(Qt.vector3d(0, 0, tz), Camera.DontTranslateViewCenter) } } @@ -105,7 +105,7 @@ Entity { // stays active, even when it's released. // Handle this issue manually by keeping an additional _pressed state // which is cleared when focus changes (used for 'pickingActive' property). - onFocusChanged: if(!focus) _pressed = false + onFocusChanged: if (!focus) _pressed = false onPressed: _pressed = true onReleased: _pressed = false } diff --git a/meshroom/ui/qml/Viewer3D/Grid3D.qml b/meshroom/ui/qml/Viewer3D/Grid3D.qml index f636d8a844..1d6ddfc321 100644 --- a/meshroom/ui/qml/Viewer3D/Grid3D.qml +++ b/meshroom/ui/qml/Viewer3D/Grid3D.qml @@ -23,7 +23,7 @@ Entity { function buildGrid(first, last, offset, attribute) { var vertexCount = (((last-first)/offset)+1)*4; var f32 = new Float32Array(vertexCount*3); - for(var id = 0, i = first; i <= last; i += offset, id++) + for (var id = 0, i = first; i <= last; i += offset, id++) { f32[12*id] = i; f32[12*id+1] = 0.0; diff --git a/meshroom/ui/qml/Viewer3D/Inspector3D.qml b/meshroom/ui/qml/Viewer3D/Inspector3D.qml index 5b03ad209a..64299ba3f3 100644 --- a/meshroom/ui/qml/Viewer3D/Inspector3D.qml +++ b/meshroom/ui/qml/Viewer3D/Inspector3D.qml @@ -234,14 +234,14 @@ FloatingPane { } hoverEnabled: true - onEntered: { if(model.attribute) uigraph.hoveredNode = model.attribute.node } - onExited: { if(model.attribute) uigraph.hoveredNode = null } + onEntered: { if (model.attribute) uigraph.hoveredNode = model.attribute.node } + onExited: { if (model.attribute) uigraph.hoveredNode = null } onClicked: { - if(model.attribute) + if (model.attribute) uigraph.selectedNode = model.attribute.node; else uigraph.selectedNode = null; - if(mouse.button == Qt.RightButton) + if (mouse.button == Qt.RightButton) contextMenu.popup(); mediaListView.currentIndex = index; } @@ -269,9 +269,9 @@ FloatingPane { Layout.fillHeight: true width: 2 color: { - if(mediaListView.currentIndex == index || mediaDelegate.isSelectedNode) + if (mediaListView.currentIndex == index || mediaDelegate.isSelectedNode) return label.palette.highlight; - if(mediaDelegate.hovered) + if (mediaDelegate.hovered) return Qt.darker(label.palette.highlight, 1.5); return "transparent"; } @@ -287,7 +287,7 @@ FloatingPane { flat: true opacity: model.visible ? 1.0 : 0.6 onClicked: { - if(hoverArea.modifiers & Qt.ControlModifier) + if (hoverArea.modifiers & Qt.ControlModifier) mediaLibrary.solo(index); else model.visible = !model.visible @@ -364,7 +364,7 @@ FloatingPane { Connections { target: mediaLibrary function onLoadRequest(idx) { - if(idx === index) + if (idx === index) focusAnim.restart() } } @@ -387,7 +387,7 @@ FloatingPane { RowLayout { spacing: 1 visible: model.vertexCount - MaterialLabel { text: MaterialIcons.grain } + MaterialLabel { text: MaterialIcons.grain } Label { text: Format.intToString(model.vertexCount) } } RowLayout { diff --git a/meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml b/meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml index 108c22abcb..9c451e62e1 100644 --- a/meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml +++ b/meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml @@ -35,19 +35,17 @@ Entity { function removeComponentsByType(entity, type) { - if(!entity) + if (!entity) return - for(var i=0; i < entity.components.length; ++i) + for (var i = 0; i < entity.components.length; ++i) { - if(entity.components[i].toString().indexOf(type) !== -1) - { + if (entity.components[i].toString().indexOf(type) !== -1) { //entity.components[i].enabled = false; - Scene3DHelper.removeComponent(entity, entity.components[i]); + Scene3DHelper.removeComponent(entity, entity.components[i]) } } } - StateGroup { id: modeState state: Viewer3DSettings.renderModes[mode].name diff --git a/meshroom/ui/qml/Viewer3D/Materials/SphericalHarmonicsMaterial.qml b/meshroom/ui/qml/Viewer3D/Materials/SphericalHarmonicsMaterial.qml index bb7c350567..00f7af0d26 100644 --- a/meshroom/ui/qml/Viewer3D/Materials/SphericalHarmonicsMaterial.qml +++ b/meshroom/ui/qml/Viewer3D/Materials/SphericalHarmonicsMaterial.qml @@ -33,24 +33,23 @@ Material { return; } Request.get(Filepath.urlToString(shlSource), function(xhr) { - if(xhr.readyState === XMLHttpRequest.DONE) { - var coeffs = []; - var lines = xhr.responseText.split("\n"); - lines.forEach(function(l){ - var lineCoeffs = []; - l.split(" ").forEach(function(v){ - if(v) { lineCoeffs.push(v); } + if (xhr.readyState === XMLHttpRequest.DONE) { + var coeffs = [] + var lines = xhr.responseText.split("\n") + lines.forEach(function(l) { + var lineCoeffs = [] + l.split(" ").forEach(function(v) { + if (v) { lineCoeffs.push(v) } }) - if(lineCoeffs.length == 3) - coeffs.push(Qt.vector3d(lineCoeffs[0], lineCoeffs[1], lineCoeffs[2])); - }); + if (lineCoeffs.length == 3) + coeffs.push(Qt.vector3d(lineCoeffs[0], lineCoeffs[1], lineCoeffs[2])) + }) - if(coeffs.length == 9) { - coefficients = coeffs; - } - else { - console.warn("Invalid SHL file: " + shlSource + " with " + coeffs.length + " coefficients."); - coefficients = noCoeffs; + if (coeffs.length == 9) { + coefficients = coeffs + } else { + console.warn("Invalid SHL file: " + shlSource + " with " + coeffs.length + " coefficients.") + coefficients = noCoeffs } } }) diff --git a/meshroom/ui/qml/Viewer3D/Materials/WireframeEffect.qml b/meshroom/ui/qml/Viewer3D/Materials/WireframeEffect.qml index 61d1e8ba4f..0e37b2a30b 100644 --- a/meshroom/ui/qml/Viewer3D/Materials/WireframeEffect.qml +++ b/meshroom/ui/qml/Viewer3D/Materials/WireframeEffect.qml @@ -5,9 +5,9 @@ Effect { id: root parameters: [ - Parameter { name: "ka"; value: Qt.vector3d( 0.1, 0.1, 0.1 ) }, - Parameter { name: "kd"; value: Qt.vector3d( 0.7, 0.7, 0.7 ) }, - Parameter { name: "ks"; value: Qt.vector3d( 0.95, 0.95, 0.95 ) }, + Parameter { name: "ka"; value: Qt.vector3d(0.1, 0.1, 0.1) }, + Parameter { name: "kd"; value: Qt.vector3d(0.7, 0.7, 0.7) }, + Parameter { name: "ks"; value: Qt.vector3d(0.95, 0.95, 0.95) }, Parameter { name: "shininess"; value: 150.0 } ] @@ -23,10 +23,10 @@ Effect { filterKeys: [ FilterKey { name: "renderingStyle"; value: "forward" } ] parameters: [ - Parameter { name: "light.position"; value: Qt.vector4d( 0.0, 0.0, 0.0, 1.0 ) }, - Parameter { name: "light.intensity"; value: Qt.vector3d( 1.0, 1.0, 1.0 ) }, + Parameter { name: "light.position"; value: Qt.vector4d(0.0, 0.0, 0.0, 1.0) }, + Parameter { name: "light.intensity"; value: Qt.vector3d(1.0, 1.0, 1.0) }, Parameter { name: "line.width"; value: 1.0 }, - Parameter { name: "line.color"; value: Qt.vector4d( 1.0, 1.0, 1.0, 1.0 ) } + Parameter { name: "line.color"; value: Qt.vector4d(1.0, 1.0, 1.0, 1.0) } ] renderPasses: [ diff --git a/meshroom/ui/qml/Viewer3D/Materials/WireframeMaterial.qml b/meshroom/ui/qml/Viewer3D/Materials/WireframeMaterial.qml index cdebc3dcc0..bfe090a9dc 100644 --- a/meshroom/ui/qml/Viewer3D/Materials/WireframeMaterial.qml +++ b/meshroom/ui/qml/Viewer3D/Materials/WireframeMaterial.qml @@ -4,12 +4,12 @@ import Qt3D.Render 2.15 Material { id: root - property color ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) - property color diffuse: Qt.rgba( 0.7, 0.7, 0.7, 1.0 ) - property color specular: Qt.rgba( 0.95, 0.95, 0.95, 1.0 ) + property color ambient: Qt.rgba(0.05, 0.05, 0.05, 1.0) + property color diffuse: Qt.rgba(0.7, 0.7, 0.7, 1.0) + property color specular: Qt.rgba(0.95, 0.95, 0.95, 1.0) property real shininess: 1.0 property real lineWidth: 0.8 - property color lineColor: Qt.rgba( 0.2, 0.2, 0.2, 1.0 ) + property color lineColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) property vector3d lightIntensity: Qt.vector3d(0.7, 0.7, 0.7) property vector4d lightPosition: Qt.vector4d(0.0, 0.0, 0.0, 1.0) diff --git a/meshroom/ui/qml/Viewer3D/MediaCache.qml b/meshroom/ui/qml/Viewer3D/MediaCache.qml index d5dee74283..131b1613d8 100644 --- a/meshroom/ui/qml/Viewer3D/MediaCache.qml +++ b/meshroom/ui/qml/Viewer3D/MediaCache.qml @@ -41,65 +41,63 @@ Entity { /// The current number of managed entities function currentSize() { - return Object.keys(mediaCache).length; + return Object.keys(mediaCache).length } /// Whether the cache contains an entity for the given source function contains(source) { - return mediaCache[source] !== undefined; + return mediaCache[source] !== undefined } /// Add an entity to the cache - function add(source, object){ - if(!Filepath.exists(source)) - return false; - if(contains(source)) - return true; - if(debug) { console.log("[cache] add: " + source); } - mediaCache[source] = object; - object.parent = root; + function add(source, object) { + if (!Filepath.exists(source)) + return false + if (contains(source)) + return true + if (debug) { console.log("[cache] add: " + source) } + mediaCache[source] = object + object.parent = root // remove oldest entry in cache - if(currentSize() > cacheSize) - shrink(); - return true; + if (currentSize() > cacheSize) + shrink() + return true } /// Pop an entity from the cache based on its source - function pop(source){ - if(!contains(source)) - return undefined; + function pop(source) { + if (!contains(source)) + return undefined - var obj = mediaCache[source]; - delete mediaCache[source]; - if(debug) { console.log("[cache] pop: " + source); } + var obj = mediaCache[source] + delete mediaCache[source] + if (debug) { console.log("[cache] pop: " + source) } // delete cached obj if file does not exist on disk anymore - if(!Filepath.exists(source)) - { - if(debug){ console.log("[cache] destroy: " + source); } - obj.destroy(); - obj = undefined; + if (!Filepath.exists(source)) { + if (debug) { console.log("[cache] destroy: " + source) } + obj.destroy() + obj = undefined } - return obj; + return obj } /// Remove and destroy an entity from cache function destroyEntity(source) { - var obj = pop(source); - if(obj) - obj.destroy(); + var obj = pop(source) + if (obj) + obj.destroy() } - // Shrink cache to fit max size function shrink() { - while(currentSize() > cacheSize) - destroyEntity(Object.keys(mediaCache)[0]); + while (currentSize() > cacheSize) + destroyEntity(Object.keys(mediaCache)[0]) } // Clear cache and destroy all managed entities function clear() { - Object.keys(mediaCache).forEach(function(key){ - destroyEntity(key); - }); + Object.keys(mediaCache).forEach(function(key) { + destroyEntity(key) + }) } } diff --git a/meshroom/ui/qml/Viewer3D/MediaLibrary.qml b/meshroom/ui/qml/Viewer3D/MediaLibrary.qml index 0b5d49bffa..e636614fc5 100644 --- a/meshroom/ui/qml/Viewer3D/MediaLibrary.qml +++ b/meshroom/ui/qml/Viewer3D/MediaLibrary.qml @@ -26,11 +26,11 @@ Entity { /// True while at least one media is being loaded readonly property bool loading: { - for(var i=0; i= 0) + if (!alive && index >= 0) remove(index) } // 'visible' property drives media loading request onVisibleChanged: { // always request media loading if visible - if(model.visible) - model.requested = true; + if (model.visible) + model.requested = true // only cancel loading request if media is not valid // (a media won't be unloaded if already loaded, only hidden) - else if(!model.valid) - model.requested = false; + else if (!model.valid) + model.requested = false } function updateCacheAndModel(forceRequest) { // don't cache explicitly unloaded media - if(model.requested && object && dependencyReady) { + if (model.requested && object && dependencyReady) { // cache current object - if(cache.add(Filepath.urlToString(mediaLoader.source), object)); - object = null; + if (cache.add(Filepath.urlToString(mediaLoader.source), object)) + object = null } - updateModel(forceRequest); + updateModel(forceRequest) } function updateModel(forceRequest) { // update model's source path if input is an attribute - if(attribute) { - model.source = rawSource; + if (attribute) { + model.source = rawSource } // auto-restore entity if raw source is in cache - model.requested = forceRequest || (!model.valid && model.requested) || cache.contains(rawSource); - model.valid = Filepath.exists(rawSource) && dependencyReady; + model.requested = forceRequest || (!model.valid && model.requested) || cache.contains(rawSource) + model.valid = Filepath.exists(rawSource) && dependencyReady } Component.onCompleted: { // keep 'source' -> 'entity' reference - m.sourceToEntity[modelSource] = instantiatedEntity; + m.sourceToEntity[modelSource] = instantiatedEntity // always request media loading when delegate has been created - updateModel(true); + updateModel(true) // if external media failed to open, remove element from model - if(!attribute && !object) + if (!attribute && !object) remove(index) } @@ -285,36 +284,36 @@ Entity { updateCacheAndModel(false) // Avoid the bounding box to disappear when we move it after a mesh already computed - if(instantiatedEntity.hasBoundingBox && !currentSource) + if (instantiatedEntity.hasBoundingBox && !currentSource) model.visible = true } onFinalSourceChanged: { // update media visibility // (useful if media was explicitly unloaded or hidden but loaded back from cache) - model.visible = model.requested; + model.visible = model.requested - var cachedObject = cache.pop(rawSource); - cached = cachedObject !== undefined; - if(cached) { - object = cachedObject; + var cachedObject = cache.pop(rawSource) + cached = cachedObject !== undefined + if (cached) { + object = cachedObject // only change cached object parent if mediaLoader has been fully instantiated // by the NodeInstantiator; otherwise re-parenting will fail silently and the object will disappear... // see "onFullyInstantiatedChanged" and parent NodeInstantiator's "onObjectAdded" - if(fullyInstantiated) { - object.parent = mediaLoader; + if (fullyInstantiated) { + object.parent = mediaLoader } } - mediaLoader.source = Filepath.stringToUrl(finalSource); - if(object) { + mediaLoader.source = Filepath.stringToUrl(finalSource) + if (object) { // bind media info to corresponding model roles // (test for object validity to avoid error messages right after object has been deleted) - var boundProperties = ["vertexCount", "faceCount", "cameraCount", "textureCount"]; - boundProperties.forEach( function(prop){ - model[prop] = Qt.binding(function() { return object ? object[prop] : 0; }); + var boundProperties = ["vertexCount", "faceCount", "cameraCount", "textureCount"] + boundProperties.forEach(function(prop) { + model[prop] = Qt.binding(function() { return object ? object[prop] : 0 }) }) } - else if(finalSource && status === Component.Ready) { + else if (finalSource && status === Component.Ready) { // source was valid but no loader was created, remove element // check if component is ready to avoid removing element from the model before adding instance to the node remove(index) @@ -323,15 +322,15 @@ Entity { onFullyInstantiatedChanged: { // delayed reparenting of object coming from the cache - if(object) - object.parent = mediaLoader; + if (object) + object.parent = mediaLoader } onStatusChanged: { model.status = status // remove model entry for external media that failed to load - if(status === SceneLoader.Error && !model.attribute) - remove(index); + if (status === SceneLoader.Error && !model.attribute) + remove(index) } components: [ @@ -384,11 +383,11 @@ Entity { onObjectAdded: { // notify object that it is now fully instantiated - object.fullyInstantiated = true; + object.fullyInstantiated = true } onObjectRemoved: { - if(m.sourceToEntity[object.modelSource]) + if (m.sourceToEntity[object.modelSource]) delete m.sourceToEntity[object.modelSource] } } diff --git a/meshroom/ui/qml/Viewer3D/MediaLoader.qml b/meshroom/ui/qml/Viewer3D/MediaLoader.qml index ba1ab58204..a767cf5426 100644 --- a/meshroom/ui/qml/Viewer3D/MediaLoader.qml +++ b/meshroom/ui/qml/Viewer3D/MediaLoader.qml @@ -26,43 +26,46 @@ import Utils 1.0 property bool cached: false onSourceChanged: { - if(cached) { - root.status = SceneLoader.Ready; - return; + if (cached) { + root.status = SceneLoader.Ready + return } // clear previously created object if any - if(object) { - object.destroy(); - object = null; + if (object) { + object.destroy() + object = null } - var component = undefined; - status = SceneLoader.Loading; + var component = undefined + status = SceneLoader.Loading - if(!Filepath.exists(source)) { - status = SceneLoader.None; - return; + if (!Filepath.exists(source)) { + status = SceneLoader.None + return } - switch(Filepath.extension(source)) { + switch (Filepath.extension(source)) { case ".abc": case ".json": case ".sfm": - if(Viewer3DSettings.supportSfmData) - { - component = sfmDataLoaderEntityComponent; - } - break; - case ".exr": if(Viewer3DSettings.supportDepthMap) component = exrLoaderComponent; break; + if (Viewer3DSettings.supportSfmData) + component = sfmDataLoaderEntityComponent + break + case ".exr": + if (Viewer3DSettings.supportDepthMap) + component = exrLoaderComponent + break case ".obj": case ".stl": - default: component = sceneLoaderEntityComponent; break; + default: + component = sceneLoaderEntityComponent + break } // Media loader available - if(component) { - object = component.createObject(root, {"source": source}); + if (component) { + object = component.createObject(root, {"source": source}) } } @@ -76,8 +79,8 @@ import Utils 1.0 SceneLoader { source: parent.source onStatusChanged: { - if(status == SceneLoader.Ready) { - textureCount = sceneLoaderPostProcess(sceneLoaderEntity); + if (status == SceneLoader.Ready) { + textureCount = sceneLoaderPostProcess(sceneLoaderEntity) faceCount = Scene3DHelper.faceCount(sceneLoaderEntity) } root.status = status; @@ -92,18 +95,16 @@ import Utils 1.0 MediaLoaderEntity { id: sfmDataLoaderEntity Component.onCompleted: { - var obj = Viewer3DSettings.sfmDataLoaderComp.createObject(sfmDataLoaderEntity, { 'source': source, 'pointSize': Qt.binding(function() { return 0.01 * Viewer3DSettings.pointSize }), 'locatorScale': Qt.binding(function() { return Viewer3DSettings.cameraScale }), 'cameraPickingEnabled': Qt.binding(function() { return root.enabled }) - }); + }) obj.statusChanged.connect(function() { - - if(obj.status === SceneLoader.Ready) { - for(var i = 0; i < obj.pointClouds.length; ++i) { + if (obj.status === SceneLoader.Ready) { + for (var i = 0; i < obj.pointClouds.length; ++i) { vertexCount += Scene3DHelper.vertexCount(obj.pointClouds[i]); } cameraCount = obj.spawnCameraSelectors(); @@ -120,38 +121,37 @@ import Utils 1.0 id: exrLoaderEntity Component.onCompleted: { var fSize = Filepath.fileSizeMB(source) - if(fSize > 500) - { + if (fSize > 500) { // Do not load images that are larger than 500MB console.warn("Viewer3D: Do not load the EXR in 3D as the file size is too large: " + fSize + "MB") - root.status = SceneLoader.Error; - return; + root.status = SceneLoader.Error + return } + // EXR loading strategy: // - [1] as a depth map var obj = Viewer3DSettings.depthMapLoaderComp.createObject( exrLoaderEntity, { 'source': source - }); + }) - if(obj.status === SceneLoader.Ready) - { - faceCount = Scene3DHelper.faceCount(obj); - root.status = SceneLoader.Ready; - return; + if (obj.status === SceneLoader.Ready) { + faceCount = Scene3DHelper.faceCount(obj) + root.status = SceneLoader.Ready + return } // - [2] as an environment map - obj.destroy(); - root.status = SceneLoader.Loading; + obj.destroy() + root.status = SceneLoader.Loading obj = Qt.createComponent("EnvironmentMapEntity.qml").createObject( exrLoaderEntity, { 'source': source, 'position': Qt.binding(function() { return root.camera.position }) - }); + }) obj.statusChanged.connect(function() { root.status = obj.status; - }); + }) } } } @@ -165,25 +165,25 @@ import Utils 1.0 // instantiate a MaterialSwitcher instead. Returns the faceCount function sceneLoaderPostProcess(rootEntity) { - var materials = Scene3DHelper.findChildrenByProperty(rootEntity, "diffuse"); - var entities = []; - var texCount = 0; - materials.forEach(function(mat){ - entities.push(mat.parent); + var materials = Scene3DHelper.findChildrenByProperty(rootEntity, "diffuse") + var entities = [] + var texCount = 0 + materials.forEach(function(mat) { + entities.push(mat.parent) }) entities.forEach(function(entity) { - var mats = []; - var componentsToRemove = []; + var mats = [] + var componentsToRemove = [] // Create as many MaterialSwitcher as individual materials for this entity // NOTE: we let each MaterialSwitcher modify the components of the entity // and therefore remove the default material spawned by the sceneLoader - for(var i = 0; i < entity.components.length; ++i) + for (var i = 0; i < entity.components.length; ++i) { var comp = entity.components[i] // handle DiffuseMapMaterials created by SceneLoader - if(comp.toString().indexOf("QDiffuseMapMaterial") > -1) { + if (comp.toString().indexOf("QDiffuseMapMaterial") > -1) { // store material definition var m = { "diffuseMap": comp.diffuse.data[0].source, @@ -192,29 +192,29 @@ import Utils 1.0 "ambient": comp.ambient, "mode": root.renderMode } - texCount++; + texCount++ mats.push(m) - componentsToRemove.push(comp); + componentsToRemove.push(comp) } - if(comp.toString().indexOf("QPhongMaterial") > -1) { + if (comp.toString().indexOf("QPhongMaterial") > -1) { // create MaterialSwitcher with default colors mats.push({}) - componentsToRemove.push(comp); + componentsToRemove.push(comp) } } - mats.forEach(function(m){ + mats.forEach(function(m) { // create a material switcher for each material definition var matSwitcher = materialSwitcherComponent.createObject(entity, m) matSwitcher.mode = Qt.binding(function(){ return root.renderMode }) }) // remove replaced components - componentsToRemove.forEach(function(comp){ - Scene3DHelper.removeComponent(entity, comp); - }); + componentsToRemove.forEach(function(comp) { + Scene3DHelper.removeComponent(entity, comp) + }) }) - return texCount; + return texCount } } diff --git a/meshroom/ui/qml/Viewer3D/MeshingBoundingBox.qml b/meshroom/ui/qml/Viewer3D/MeshingBoundingBox.qml index 5e63311061..3f9e0b7a3a 100644 --- a/meshroom/ui/qml/Viewer3D/MeshingBoundingBox.qml +++ b/meshroom/ui/qml/Viewer3D/MeshingBoundingBox.qml @@ -28,7 +28,7 @@ Entity { var rotationEuler_cv = Qt.vector3d(rotation.x, rotation.y, rotation.z) var rotation_gl = Transformations3DHelper.convertRotationFromCV2GL(rotationEuler_cv) - switch(type) { + switch (type) { case TransformGizmo.Type.TRANSLATION: { _reconstruction.setAttribute( root.currentMeshingNode.attribute("boundingBox.bboxTranslation"), diff --git a/meshroom/ui/qml/Viewer3D/SfMTransformGizmo.qml b/meshroom/ui/qml/Viewer3D/SfMTransformGizmo.qml index ae467d2916..c40bcccdd2 100644 --- a/meshroom/ui/qml/Viewer3D/SfMTransformGizmo.qml +++ b/meshroom/ui/qml/Viewer3D/SfMTransformGizmo.qml @@ -27,7 +27,7 @@ Entity { // Update node SfMTransform slider values when the gizmo has changed: translation, rotation, scale, type transformGizmo.onGizmoChanged: { - switch(type) { + switch (type) { case TransformGizmo.Type.TRANSLATION: { _reconstruction.setAttribute( root.currentSfMTransformNode.attribute("manualTransform.manualTranslation"), diff --git a/meshroom/ui/qml/Viewer3D/TrackballGizmo.qml b/meshroom/ui/qml/Viewer3D/TrackballGizmo.qml index 6b4d2ec17d..123a2b42b8 100644 --- a/meshroom/ui/qml/Viewer3D/TrackballGizmo.qml +++ b/meshroom/ui/qml/Viewer3D/TrackballGizmo.qml @@ -49,7 +49,7 @@ Entity { }, DiffuseSpecularMaterial { ambient: { - switch(index) { + switch (index) { case 0: return xColor; case 1: return yColor; case 2: return zColor; diff --git a/meshroom/ui/qml/Viewer3D/TransformGizmo.qml b/meshroom/ui/qml/Viewer3D/TransformGizmo.qml index 0ee5731a4a..eb2953c1d2 100644 --- a/meshroom/ui/qml/Viewer3D/TransformGizmo.qml +++ b/meshroom/ui/qml/Viewer3D/TransformGizmo.qml @@ -65,7 +65,7 @@ Entity { } function convertAxisEnum(axis) { - switch(axis) { + switch (axis) { case TransformGizmo.Axis.X: return Qt.vector3d(1,0,0) case TransformGizmo.Axis.Y: return Qt.vector3d(0,1,0) case TransformGizmo.Axis.Z: return Qt.vector3d(0,0,1) @@ -73,7 +73,7 @@ Entity { } function convertTypeEnum(type) { - switch(type) { + switch (type) { case TransformGizmo.Type.TRANSLATION: return "TRANSLATION" case TransformGizmo.Type.ROTATION: return "ROTATION" case TransformGizmo.Type.SCALE: return "SCALE" @@ -216,7 +216,7 @@ Entity { const pickedAxis = convertAxisEnum(objectPicker.gizmoAxis) // TRANSLATION or SCALE transformation - if(objectPicker.gizmoType === TransformGizmo.Type.TRANSLATION || objectPicker.gizmoType === TransformGizmo.Type.SCALE) { + if (objectPicker.gizmoType === TransformGizmo.Type.TRANSLATION || objectPicker.gizmoType === TransformGizmo.Type.SCALE) { // Compute the vector PickedPosition -> CurrentMousePoint const pickedPosition = objectPicker.screenPoint const mouseVector = Qt.vector2d(mouse.x - pickedPosition.x, -(mouse.y - pickedPosition.y)) @@ -234,12 +234,11 @@ Entity { const offset = cosAngle * mouseVector.length() / objectPicker.scaleUnit // Do the transformation - if(objectPicker.gizmoType === TransformGizmo.Type.TRANSLATION && offset !== 0) { + if (objectPicker.gizmoType === TransformGizmo.Type.TRANSLATION && offset !== 0) { doRelativeTranslation(objectPicker.modelMatrix, pickedAxis.times(offset)) // Do a translation from the initial Object Model Matrix when we picked the gizmo - } - else if(objectPicker.gizmoType === TransformGizmo.Type.SCALE && offset !== 0) { - if(root.uniformScale) - doRelativeScale(objectPicker.modelMatrix, Qt.vector3d(1,1,1).times(offset)) // Do a uniform scale from the initial Object Model Matrix when we picked the gizmo + } else if (objectPicker.gizmoType === TransformGizmo.Type.SCALE && offset !== 0) { + if (root.uniformScale) + doRelativeScale(objectPicker.modelMatrix, Qt.vector3d(1, 1, 1).times(offset)) // Do a uniform scale from the initial Object Model Matrix when we picked the gizmo else doRelativeScale(objectPicker.modelMatrix, pickedAxis.times(offset)) // Do a scale on one axis from the initial Object Model Matrix when we picked the gizmo } @@ -247,7 +246,7 @@ Entity { return } // ROTATION transformation - else if(objectPicker.gizmoType === TransformGizmo.Type.ROTATION) { + else if (objectPicker.gizmoType === TransformGizmo.Type.ROTATION) { // Get Screen Coordinates of the gizmo center const gizmoCenterPoint = gizmoDisplayTransform.matrix.times(Qt.vector4d(0, 0, 0, 1)) const screenCenter2D = Transformations3DHelper.pointFromWorldToScreen(gizmoCenterPoint, camera, root.windowSize) @@ -259,25 +258,25 @@ Entity { const mouseVector = Qt.vector2d(mouse.x - screenCenter2D.x, -(mouse.y - screenCenter2D.y)) // Get the angle from the originalVector to the mouseVector - const angle = Math.atan2(-originalVector.y*mouseVector.x + originalVector.x*mouseVector.y, originalVector.x*mouseVector.x + originalVector.y*mouseVector.y) * 180 / Math.PI + const angle = Math.atan2(-originalVector.y * mouseVector.x + originalVector.x * mouseVector.y, originalVector.x * mouseVector.x + originalVector.y * mouseVector.y) * 180 / Math.PI // Get the orientation of the gizmo in function of the camera const gizmoLocalAxisVector = gizmoDisplayTransform.matrix.times(Qt.vector4d(pickedAxis.x, pickedAxis.y, pickedAxis.z, 0)) const gizmoToCameraVector = camera.position.toVector4d().minus(gizmoCenterPoint) const orientation = gizmoLocalAxisVector.dotProduct(gizmoToCameraVector) > 0 ? 1 : -1 - if (angle !== 0) doRelativeRotation(objectPicker.modelMatrix, pickedAxis, angle*orientation) // Do a rotation from the initial Object Model Matrix when we picked the gizmo + if (angle !== 0) doRelativeRotation(objectPicker.modelMatrix, pickedAxis, angle * orientation) // Do a rotation from the initial Object Model Matrix when we picked the gizmo return } } - if(objectPicker && objectPicker.button === Qt.RightButton) { + if (objectPicker && objectPicker.button === Qt.RightButton) { resetMenu.popup(window) } } onReleased: { - if(objectPicker && mouse.button === Qt.LeftButton) { + if (objectPicker && mouse.button === Qt.LeftButton) { const type = objectPicker.gizmoType objectPicker = null // To prevent going again in the onPositionChanged emitGizmoChanged(type) @@ -362,14 +361,14 @@ Entity { Entity { id: axisContainer property int axis : { - switch(index) { + switch (index) { case 0: return TransformGizmo.Axis.X case 1: return TransformGizmo.Axis.Y case 2: return TransformGizmo.Axis.Z } } property color baseColor: { - switch(axis) { + switch (axis) { case TransformGizmo.Axis.X: return "#e63b55" // Red case TransformGizmo.Axis.Y: return "#83c414" // Green case TransformGizmo.Axis.Z: return "#3387e2" // Blue @@ -395,12 +394,12 @@ Entity { Transform { id: cylinderTransform matrix: { - const offset = cylinderMesh.length/2 + centerSphereMesh.radius + const offset = cylinderMesh.length / 2 + centerSphereMesh.radius const m = Qt.matrix4x4() - switch(axis) { + switch (axis) { case TransformGizmo.Axis.X: { m.translate(Qt.vector3d(offset, 0, 0)) - m.rotate(90, Qt.vector3d(0,0,1)) + m.rotate(90, Qt.vector3d(0, 0, 1)) break } case TransformGizmo.Axis.Y: { @@ -409,7 +408,7 @@ Entity { } case TransformGizmo.Axis.Z: { m.translate(Qt.vector3d(0, 0, offset)) - m.rotate(90, Qt.vector3d(1,0,0)) + m.rotate(90, Qt.vector3d(1, 0, 0)) break } } @@ -437,7 +436,7 @@ Entity { switch(axis) { case TransformGizmo.Axis.X: { m.translate(Qt.vector3d(offset, 0, 0)) - m.rotate(90, Qt.vector3d(0,0,1)) + m.rotate(90, Qt.vector3d(0, 0, 1)) break } case TransformGizmo.Axis.Y: { @@ -446,7 +445,7 @@ Entity { } case TransformGizmo.Axis.Z: { m.translate(Qt.vector3d(0, 0, offset)) - m.rotate(90, Qt.vector3d(1,0,0)) + m.rotate(90, Qt.vector3d(1, 0, 0)) break } } @@ -486,23 +485,23 @@ Entity { ConeMesh { id: coneMesh - bottomRadius : 0.035 - topRadius : 0.001 - hasBottomEndcap : true - hasTopEndcap : true - length : 0.13 - rings : 2 - slices : 8 + bottomRadius: 0.035 + topRadius: 0.001 + hasBottomEndcap: true + hasTopEndcap: true + length: 0.13 + rings: 2 + slices: 8 } Transform { id: coneTransform matrix: { const offset = cylinderMesh.length + centerSphereMesh.radius + 0.4 const m = Qt.matrix4x4() - switch(axis) { + switch (axis) { case TransformGizmo.Axis.X: { m.translate(Qt.vector3d(offset, 0, 0)) - m.rotate(-90, Qt.vector3d(0,0,1)) + m.rotate(-90, Qt.vector3d(0, 0, 1)) break } case TransformGizmo.Axis.Y: { @@ -511,7 +510,7 @@ Entity { } case TransformGizmo.Axis.Z: { m.translate(Qt.vector3d(0, 0, offset)) - m.rotate(90, Qt.vector3d(1,0,0)) + m.rotate(90, Qt.vector3d(1, 0, 0)) break } } @@ -557,12 +556,12 @@ Entity { Transform { id: torusTransform matrix: { - const scaleDiff = 2*torusMesh.minorRadius + 0.01 // Just to make sure there is no face overlapping + const scaleDiff = 2 * torusMesh.minorRadius + 0.01 // Just to make sure there is no face overlapping const m = Qt.matrix4x4() - switch(axis) { - case TransformGizmo.Axis.X: m.rotate(90, Qt.vector3d(0,1,0)); break - case TransformGizmo.Axis.Y: m.rotate(90, Qt.vector3d(1,0,0)); m.scale(Qt.vector3d(1-scaleDiff, 1-scaleDiff, 1-scaleDiff)); break - case TransformGizmo.Axis.Z: m.scale(Qt.vector3d(1-2*scaleDiff, 1-2*scaleDiff, 1-2*scaleDiff)); break + switch (axis) { + case TransformGizmo.Axis.X: m.rotate(90, Qt.vector3d(0, 1, 0)); break + case TransformGizmo.Axis.Y: m.rotate(90, Qt.vector3d(1, 0, 0)); m.scale(Qt.vector3d(1 - scaleDiff, 1 - scaleDiff, 1 - scaleDiff)); break + case TransformGizmo.Axis.Z: m.scale(Qt.vector3d(1 - 2 * scaleDiff, 1 - 2 * scaleDiff, 1 - 2 * scaleDiff)); break } return m } diff --git a/meshroom/ui/qml/Viewer3D/TransformGizmoPicker.qml b/meshroom/ui/qml/Viewer3D/TransformGizmoPicker.qml index eedf0023c2..1d87cfec01 100644 --- a/meshroom/ui/qml/Viewer3D/TransformGizmoPicker.qml +++ b/meshroom/ui/qml/Viewer3D/TransformGizmoPicker.qml @@ -34,7 +34,8 @@ ObjectPicker { gizmoMaterial.ambient = "white" } onExited: { - if(!isPressed) gizmoMaterial.ambient = gizmoBaseColor + if (!isPressed) + gizmoMaterial.ambient = gizmoBaseColor } onReleased: { gizmoMaterial.ambient = gizmoBaseColor @@ -43,4 +44,4 @@ ObjectPicker { mouseController.enabled = false pickedChanged(this) } -} \ No newline at end of file +} diff --git a/meshroom/ui/qml/Viewer3D/Viewer3D.qml b/meshroom/ui/qml/Viewer3D/Viewer3D.qml index e8be470650..d389ae8a1d 100644 --- a/meshroom/ui/qml/Viewer3D/Viewer3D.qml +++ b/meshroom/ui/qml/Viewer3D/Viewer3D.qml @@ -31,30 +31,29 @@ FocusScope { // functions function resetCameraPosition() { - mainCamera.position = defaultCamPosition; - mainCamera.upVector = defaultCamUpVector; - mainCamera.viewCenter = defaultCamViewCenter; + mainCamera.position = defaultCamPosition + mainCamera.upVector = defaultCamUpVector + mainCamera.viewCenter = defaultCamViewCenter } function load(filepath, label = undefined) { - mediaLibrary.load(filepath, label); + mediaLibrary.load(filepath, label) } /// View 'attribute' in the 3D Viewer. Media will be loaded if needed. /// Returns whether the attribute can be visualized (matching type and extension). function view(attribute) { - if( attribute.desc.type === "File" - && Viewer3DSettings.supportedExtensions.indexOf(Filepath.extension(attribute.value)) > - 1 ) - { - mediaLibrary.view(attribute); - return true; + if (attribute.desc.type === "File" + && Viewer3DSettings.supportedExtensions.indexOf(Filepath.extension(attribute.value)) > - 1) { + mediaLibrary.view(attribute) + return true } - return false; + return false } /// Solo (i.e display only) the given attribute. function solo(attribute) { - mediaLibrary.solo(mediaLibrary.find(attribute)); + mediaLibrary.solo(mediaLibrary.find(attribute)) } function clear() { @@ -90,12 +89,9 @@ FocusScope { Keys.onPressed: { if (event.key === Qt.Key_F) { resetCameraPosition(); - } - else if(Qt.Key_1 <= event.key && event.key < Qt.Key_1 + Viewer3DSettings.renderModes.length) - { + } else if (Qt.Key_1 <= event.key && event.key < Qt.Key_1 + Viewer3DSettings.renderModes.length) { Viewer3DSettings.renderMode = event.key - Qt.Key_1; - } - else { + } else { event.accepted = false } } @@ -168,19 +164,16 @@ FocusScope { focus: scene3D.activeFocus onMousePressed: { scene3D.forceActiveFocus() - if(mouse.button === Qt.LeftButton) - { - if(!doubleClickTimer.running) + if (mouse.button === Qt.LeftButton) { + if (!doubleClickTimer.running) doubleClickTimer.restart() - } - else + } else doubleClickTimer.stop() } onMouseReleased: { - if(moving) + if (moving) return - if(!moved && mouse.button === Qt.RightButton) - { + if (!moved && mouse.button === Qt.RightButton) { contextMenu.popup() } } @@ -260,11 +253,10 @@ FocusScope { ] onPressed: { - if(pick.button === Qt.LeftButton) - { - mainCamera.viewCenter = pick.worldIntersection; + if (pick.button === Qt.LeftButton) { + mainCamera.viewCenter = pick.worldIntersection } - doubleClickTimer.stop(); + doubleClickTimer.stop() } } diff --git a/meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml b/meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml index 86a078c347..39fb2bf3ed 100644 --- a/meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml +++ b/meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml @@ -14,14 +14,14 @@ Item { // supported 3D files extensions readonly property var supportedExtensions: { var exts = ['.obj', '.stl', '.fbx', '.gltf']; - if(supportSfmData) - { - exts.push('.abc'); - exts.push('.json'); - exts.push('.sfm'); + if (supportSfmData) { + exts.push('.abc') + exts.push('.json') + exts.push('.sfm') } - if(supportDepthMap) - exts.push('.exr'); + if (supportDepthMap) + exts.push('.exr') + return exts; } diff --git a/meshroom/ui/qml/Viewer3D/ViewpointCamera.qml b/meshroom/ui/qml/Viewer3D/ViewpointCamera.qml index 313c24e900..f9e617e362 100644 --- a/meshroom/ui/qml/Viewer3D/ViewpointCamera.qml +++ b/meshroom/ui/qml/Viewer3D/ViewpointCamera.qml @@ -32,10 +32,10 @@ Entity { id: transform Behavior on rotation { - PropertyAnimation { duration: 200} + PropertyAnimation { duration: 200 } } Behavior on translation { - Vector3dAnimation { duration: 200} + Vector3dAnimation { duration: 200 } } } ] From 13b8266d14783a4c595c8b731c54fc9c61adfa92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 12:46:57 +0200 Subject: [PATCH 04/13] [Viewer] Clean-up: Harmonize syntax across all the files --- .../ui/qml/Viewer/CameraResponseGraph.qml | 9 +- meshroom/ui/qml/Viewer/CircleGizmo.qml | 14 +- meshroom/ui/qml/Viewer/ColorCheckerEntity.qml | 2 +- meshroom/ui/qml/Viewer/ColorCheckerPane.qml | 4 +- meshroom/ui/qml/Viewer/ColorCheckerViewer.qml | 68 +-- .../ui/qml/Viewer/FeaturesInfoOverlay.qml | 30 +- meshroom/ui/qml/Viewer/FloatImage.qml | 38 +- meshroom/ui/qml/Viewer/HdrImageToolbar.qml | 18 +- meshroom/ui/qml/Viewer/ImageMetadataView.qml | 60 +- .../ui/qml/Viewer/LensDistortionToolbar.qml | 4 +- meshroom/ui/qml/Viewer/PanoramaToolbar.qml | 21 +- meshroom/ui/qml/Viewer/PanoramaViewer.qml | 184 +++--- meshroom/ui/qml/Viewer/SfmGlobalStats.qml | 46 +- meshroom/ui/qml/Viewer/SfmStatsView.qml | 31 +- meshroom/ui/qml/Viewer/Viewer2D.qml | 523 +++++++++--------- 15 files changed, 489 insertions(+), 563 deletions(-) diff --git a/meshroom/ui/qml/Viewer/CameraResponseGraph.qml b/meshroom/ui/qml/Viewer/CameraResponseGraph.qml index 88b8608a84..64faa15e63 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 ff072f728b..7a13cedd9f 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 a9811dff09..214a84c8fe 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 a91fad4638..1642000645 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 8b51aa5bdc..151339f726 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 57f8f8dd43..750aa9e54c 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 4fc6b8b0fd..662273ce9d 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 8c3a0f2914..10b4aba83b 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 d69b05b6c3..e951a84e4b 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 46e9abede5..10c783e9cb 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 b8538ed864..2ef6771588 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 0d1c0bfc86..eb4ce4814d 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 ed50dd54fb..6a99a430d5 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 62863409f7..86d89ece45 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 958a134a39..70c9aa459a 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; - - 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; + 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 } } 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() } } } From d8709434a3a07a68b28f5c7db7a6bc2d5026b4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 12:49:30 +0200 Subject: [PATCH 05/13] [Viewer] FeaturesInfoOverlay: Ensure node exists before getting its label This fixes a "TypeError: Cannot read property 'label' of null" issue. --- meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml b/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml index 750aa9e54c..a649df11c1 100644 --- a/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml +++ b/meshroom/ui/qml/Viewer/FeaturesInfoOverlay.qml @@ -24,7 +24,7 @@ FloatingPane { RowLayout { // Node used to read features Label { - text: _reconstruction ? _reconstruction.activeNodes.get("featureProvider").node.label : "" + text: _reconstruction && _reconstruction.activeNodes.get("featureProvider").node ? _reconstruction.activeNodes.get("featureProvider").node.label : "" Layout.fillWidth: true } // Settings menu From 8313e42d8c70e2494277e338ef8fd38824270231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 12:57:17 +0200 Subject: [PATCH 06/13] [Utils] Clean-up: Harmonize syntax across all files --- meshroom/ui/qml/Utils/Colors.qml | 40 ++++++++----------- .../ui/qml/Utils/SortFilterDelegateModel.qml | 33 ++++++--------- meshroom/ui/qml/Utils/errorHandler.js | 4 +- meshroom/ui/qml/Utils/format.js | 6 +-- 4 files changed, 34 insertions(+), 49 deletions(-) diff --git a/meshroom/ui/qml/Utils/Colors.qml b/meshroom/ui/qml/Utils/Colors.qml index 901a568fec..51af70e25c 100644 --- a/meshroom/ui/qml/Utils/Colors.qml +++ b/meshroom/ui/qml/Utils/Colors.qml @@ -46,22 +46,14 @@ QtObject { {"time": 90, "color": red} ] - function getChunkColor(chunk, overrides) - { - if(overrides && chunk.statusName in overrides) - { + function getChunkColor(chunk, overrides) { + if (overrides && chunk.statusName in overrides) { return overrides[chunk.statusName] - } - else if(chunk.execModeName === "EXTERN" - && chunk.statusName in statusColorsExternOverrides) - { + } else if (chunk.execModeName === "EXTERN" && chunk.statusName in statusColorsExternOverrides) { return statusColorsExternOverrides[chunk.statusName] - } - else if(chunk.nodeName !== chunk.statusNodeName && chunk.statusName in ghostColors) { + } else if (chunk.nodeName !== chunk.statusNodeName && chunk.statusName in ghostColors) { return ghostColors[chunk.statusName] - } - else if(chunk.statusName in statusColors) - { + } else if (chunk.statusName in statusColors) { return statusColors[chunk.statusName] } console.warn("Unknown status : " + chunk.status) @@ -73,30 +65,30 @@ QtObject { parseInt(color.toString().substr(1, 2), 16) / 255, parseInt(color.toString().substr(3, 2), 16) / 255, parseInt(color.toString().substr(5, 2), 16) / 255 - ]; + ] } function interpolate(c1, c2, u) { - let rgb1 = toRgb(c1); - let rgb2 = toRgb(c2); + let rgb1 = toRgb(c1) + let rgb2 = toRgb(c2) return Qt.rgba( - rgb1[0] * (1-u) + rgb2[0] * u, - rgb1[1] * (1-u) + rgb2[1] * u, - rgb1[2] * (1-u) + rgb2[2] * u - ); + rgb1[0] * (1 - u) + rgb2[0] * u, + rgb1[1] * (1 - u) + rgb2[1] * u, + rgb1[2] * (1 - u) + rgb2[2] * u + ) } function durationColor(t) { if (t < durationColorScale[0].time) { - return durationColorScale[0].color; + return durationColorScale[0].color } if (t > durationColorScale[durationColorScale.length-1].time) { - return durationColorScale[durationColorScale.length-1].color; + return durationColorScale[durationColorScale.length-1].color } for (let idx = 1; idx < durationColorScale.length; idx++) { if (t < durationColorScale[idx].time) { - let u = (t - durationColorScale[idx-1].time) / (durationColorScale[idx].time - durationColorScale[idx-1].time); - return interpolate(durationColorScale[idx-1].color, durationColorScale[idx].color, u); + let u = (t - durationColorScale[idx - 1].time) / (durationColorScale[idx].time - durationColorScale[idx - 1].time) + return interpolate(durationColorScale[idx - 1].color, durationColorScale[idx].color, u) } } } diff --git a/meshroom/ui/qml/Utils/SortFilterDelegateModel.qml b/meshroom/ui/qml/Utils/SortFilterDelegateModel.qml index aacb01a95f..6b3a445762 100644 --- a/meshroom/ui/qml/Utils/SortFilterDelegateModel.qml +++ b/meshroom/ui/qml/Utils/SortFilterDelegateModel.qml @@ -46,8 +46,7 @@ DelegateModel { // no sorting: move everything from unsorted to sorted group if(sortRole == "") { unsortedItems.setGroups(0, unsortedItems.count, ["items"]) - } - else { + } else { sort() } // perform filter invalidation in both cases @@ -68,9 +67,8 @@ DelegateModel { /// Get the index of the first element which matches 'value' for the given 'roleName' function find(value, roleName) { - for(var i = 0; i < filteredItems.count; ++i) - { - if(modelData(filteredItems.get(i), roleName) == value) + for (var i = 0; i < filteredItems.count; ++i) { + if (modelData(filteredItems.get(i), roleName) == value) return i } return -1 @@ -89,12 +87,12 @@ DelegateModel { if (filter === undefined) { return true; } - switch(value.constructor.name) + switch (value.constructor.name) { - case "String": - return value.toLowerCase().indexOf(filter.toLowerCase()) > -1 - default: - return value === filter + case "String": + return value.toLowerCase().indexOf(filter.toLowerCase()) > -1 + default: + return value === filter } } @@ -114,7 +112,7 @@ DelegateModel { ] function invalidateSort() { - if(!sortFilterModel.model || !sortFilterModel.model.count) + if (!sortFilterModel.model || !sortFilterModel.model.count) return; // move everything from "items" to "unsorted @@ -124,15 +122,11 @@ DelegateModel { /// Invalidate filtering function invalidateFilters() { - for(var i=0; i < items.count; ++i) - { + for (var i = 0; i < items.count; ++i) { // if the property value contains filterText, add it to the filtered group - if(respectFilters(items.get(i))) - { + if (respectFilters(items.get(i))) { items.addGroups(items.get(i), 1, "filtered") - } - else // otherwise, remove it from the filtered group - { + } else { // otherwise, remove it from the filtered group items.removeGroups(items.get(i), 1, "filtered") } } @@ -146,7 +140,7 @@ DelegateModel { while (lower < upper) { var middle = Math.floor(lower + (upper - lower) / 2) var result = lessThan(item, items.get(middle)) - if(sortOrder == Qt.DescendingOrder) + if (sortOrder == Qt.DescendingOrder) result = !result if (result) { upper = middle @@ -168,5 +162,4 @@ DelegateModel { // if some items were actually sorted, filter will be correctly invalidated // as unsortedGroup 'changed' signal will be triggered } - } diff --git a/meshroom/ui/qml/Utils/errorHandler.js b/meshroom/ui/qml/Utils/errorHandler.js index 2b4cec255c..1b79a9568e 100644 --- a/meshroom/ui/qml/Utils/errorHandler.js +++ b/meshroom/ui/qml/Utils/errorHandler.js @@ -15,7 +15,7 @@ function analyseError(error) { // Group 2: ErrorType // Group 3: ErrorMessage const regex = /\[(.*)\]\s(.*):([^]*)/ - if(!regex.test(msg)) + if (!regex.test(msg)) return { context: "", type: "", @@ -29,4 +29,4 @@ function analyseError(error) { type: data[2], msg: data[3].startsWith("\n") ? data[3].slice(1) : data[3] } -} \ No newline at end of file +} diff --git a/meshroom/ui/qml/Utils/format.js b/meshroom/ui/qml/Utils/format.js index bd1ae8c689..fb56d9e697 100644 --- a/meshroom/ui/qml/Utils/format.js +++ b/meshroom/ui/qml/Utils/format.js @@ -10,12 +10,12 @@ function intToString(v) { // Convert a plain text to an html escaped string. function plainToHtml(t) { - var escaped = t.replace(/&/g, '&').replace(//g, '>'); // escape text - return escaped.replace(/\n/g, '
'); // replace line breaks + var escaped = t.replace(/&/g, '&').replace(//g, '>') // escape text + return escaped.replace(/\n/g, '
') // replace line breaks } function sec2time(time) { - var pad = function(num, size) { return ('000' + num).slice(size * -1); }, + var pad = function(num, size) { return ('000' + num).slice(size * -1) }, hours = Math.floor(time / 60 / 60), minutes = Math.floor(time / 60) % 60, seconds = Math.floor(time - minutes * 60); From 856641bc9dc25271062dc94a66da4c08e00f88d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 13:06:45 +0200 Subject: [PATCH 07/13] [Charts] Clean-up: Harmonize syntax across all files --- meshroom/ui/qml/Charts/ChartViewLegend.qml | 35 +++++++++---------- .../ui/qml/Charts/InteractiveChartView.qml | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/meshroom/ui/qml/Charts/ChartViewLegend.qml b/meshroom/ui/qml/Charts/ChartViewLegend.qml index 240208e46e..572b51a827 100644 --- a/meshroom/ui/qml/Charts/ChartViewLegend.qml +++ b/meshroom/ui/qml/Charts/ChartViewLegend.qml @@ -23,7 +23,7 @@ Flow { /// Shortcut function to clear legend function clear() { - seriesModel.clear(); + seriesModel.clear() } // Update internal ListModel when ChartView's series change @@ -33,19 +33,19 @@ Flow { seriesModel.append({"series": series}) } function onSeriesRemoved(series) { - for(var i = 0; i < seriesModel.count; ++i) { - if(seriesModel.get(i)["series"] === series) { - seriesModel.remove(i); - return; + for (var i = 0; i < seriesModel.count; ++i) { + if (seriesModel.get(i)["series"] === series) { + seriesModel.remove(i) + return } } } } onChartViewChanged: { - clear(); - for(var i = 0; i < chartView.count; ++i) - seriesModel.append({"series": chartView.series(i)}); + clear() + for (var i = 0; i < chartView.count; ++i) + seriesModel.append({"series": chartView.series(i)}) } Repeater { @@ -64,10 +64,10 @@ Flow { color: series.color onHoveredChanged: { - if(hovered && series.visible) - root.hoveredSeries = series; + if (hovered && series.visible) + root.hoveredSeries = series else - root.hoveredSeries = null; + root.hoveredSeries = null } // hovered serie properties override @@ -85,10 +85,10 @@ Flow { MouseArea { anchors.fill: parent onClicked: { - if(mouse.modifiers & Qt.ControlModifier) - root.soloSeries(index); + if (mouse.modifiers & Qt.ControlModifier) + root.soloSeries(index) else - series.visible = !series.visible; + series.visible = !series.visible } } } @@ -96,10 +96,9 @@ Flow { /// Hide all series but the one at index 'idx' function soloSeries(idx) { - for(var i = 0; i < seriesModel.count; i++) { - chartView.series(i).visible = false; + for (var i = 0; i < seriesModel.count; i++) { + chartView.series(i).visible = false } - chartView.series(idx).visible = true; + chartView.series(idx).visible = true } - } diff --git a/meshroom/ui/qml/Charts/InteractiveChartView.qml b/meshroom/ui/qml/Charts/InteractiveChartView.qml index f2566bc711..e569ef4556 100644 --- a/meshroom/ui/qml/Charts/InteractiveChartView.qml +++ b/meshroom/ui/qml/Charts/InteractiveChartView.qml @@ -48,7 +48,7 @@ ChartView { // root.zoomIn(r) // } onClicked: { - root.zoomReset(); + root.zoomReset() } } } From 2908aa94a3eda2de71f8c5e6cec8cd78280bbb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 13:07:03 +0200 Subject: [PATCH 08/13] [Controls] Clean-up: Harmonize syntax across all files --- meshroom/ui/qml/Controls/ColorChart.qml | 10 +- meshroom/ui/qml/Controls/MessageDialog.qml | 5 +- meshroom/ui/qml/Controls/TextFileViewer.qml | 146 ++++++++++---------- 3 files changed, 78 insertions(+), 83 deletions(-) diff --git a/meshroom/ui/qml/Controls/ColorChart.qml b/meshroom/ui/qml/Controls/ColorChart.qml index 072fd22c8e..fe75a47c52 100644 --- a/meshroom/ui/qml/Controls/ColorChart.qml +++ b/meshroom/ui/qml/Controls/ColorChart.qml @@ -29,11 +29,11 @@ ToolButton { padding: 4 // content width is missing side padding (hence the + padding*2) - implicitWidth: colorChart.contentItem.width + padding*2 + implicitWidth: colorChart.contentItem.width + padding * 2 // center the current color - y: - (root.height - padding) / 2 - x: - colorChart.currentItem.x - padding + y: -(root.height - padding) / 2 + x: -colorChart.currentItem.x - padding // Colors palette ListView { @@ -57,8 +57,8 @@ ToolButton { } onClicked: { - colorPicked(index); - palettePopup.close(); + colorPicked(index) + palettePopup.close() } } } diff --git a/meshroom/ui/qml/Controls/MessageDialog.qml b/meshroom/ui/qml/Controls/MessageDialog.qml index 32a28ec93d..4659576055 100644 --- a/meshroom/ui/qml/Controls/MessageDialog.qml +++ b/meshroom/ui/qml/Controls/MessageDialog.qml @@ -25,8 +25,8 @@ Dialog { return asString } - x: parent.width/2 - width/2 - y: parent.height/2 - height/2 + x: parent.width / 2 - width / 2 + y: parent.height / 2 - height / 2 modal: true padding: 15 @@ -128,5 +128,4 @@ Dialog { } ] } - } diff --git a/meshroom/ui/qml/Controls/TextFileViewer.qml b/meshroom/ui/qml/Controls/TextFileViewer.qml index f756c453d6..1e6d6dcb85 100644 --- a/meshroom/ui/qml/Controls/TextFileViewer.qml +++ b/meshroom/ui/qml/Controls/TextFileViewer.qml @@ -23,7 +23,7 @@ Item { onSourceChanged: loadSource() onAutoReloadChanged: loadSource() - onVisibleChanged: if(visible) loadSource() + onVisibleChanged: if (visible) loadSource() RowLayout { anchors.fill: parent @@ -67,16 +67,16 @@ Item { MenuItem { text: "Copy Visible Text" onTriggered: { - var t = ""; - for(var i = textView.firstVisibleIndex(); i < textView.lastVisibleIndex(); ++i) - t += textView.model.get(i).line + "\n"; - Clipboard.setText(t); + var t = "" + for (var i = textView.firstVisibleIndex(); i < textView.lastVisibleIndex(); ++i) + t += textView.model.get(i).line + "\n" + Clipboard.setText(t) } } MenuItem { text: "Copy All" onTriggered: { - Clipboard.setText(textView.text); + Clipboard.setText(textView.text) } } } @@ -120,54 +120,53 @@ Item { highlightFollowsCurrentItem: true highlightMoveDuration: 0 Keys.onPressed: { - switch(event.key) - { - case Qt.Key_Home: - textView.positionViewAtBeginning(); - break; - case Qt.Key_End: - textView.positionViewAtEnd(); - break; - case Qt.Key_Up: - currentIndex = firstVisibleIndex(); - decrementCurrentIndex(); - break; - case Qt.Key_Down: - currentIndex = lastVisibleIndex(); - incrementCurrentIndex(); - break; - case Qt.Key_PageUp: - textView.positionViewAtIndex(firstVisibleIndex(), ListView.End); - break; - case Qt.Key_PageDown: - textView.positionViewAtIndex(lastVisibleIndex(), ListView.Beginning); - break; + switch (event.key) { + case Qt.Key_Home: + textView.positionViewAtBeginning() + break + case Qt.Key_End: + textView.positionViewAtEnd() + break + case Qt.Key_Up: + currentIndex = firstVisibleIndex() + decrementCurrentIndex() + break; + case Qt.Key_Down: + currentIndex = lastVisibleIndex() + incrementCurrentIndex() + break; + case Qt.Key_PageUp: + textView.positionViewAtIndex(firstVisibleIndex(), ListView.End) + break + case Qt.Key_PageDown: + textView.positionViewAtIndex(lastVisibleIndex(), ListView.Beginning) + break } } function setText(value) { // store current first index - var topIndex = firstVisibleIndex(); + var topIndex = firstVisibleIndex() // store whether autoscroll to bottom is active - var scrollToBottom = atYEnd && autoscroll.checked; + var scrollToBottom = atYEnd && autoscroll.checked // replace text - text = value; + text = value // restore content position by either: // - autoscrolling to bottom - if(scrollToBottom) - positionViewAtEnd(); + if (scrollToBottom) + positionViewAtEnd() // - setting first visible index back (when possible) - else if(topIndex !== firstVisibleIndex()) - positionViewAtIndex(Math.min(topIndex, count-1), ListView.Beginning); + else if (topIndex !== firstVisibleIndex()) + positionViewAtIndex(Math.min(topIndex, count - 1), ListView.Beginning) } function firstVisibleIndex() { - return indexAt(contentX, contentY); + return indexAt(contentX, contentY) } function lastVisibleIndex() { - return indexAt(contentX, contentY + height - 2); + return indexAt(contentX, contentY + height - 2) } ScrollBar.vertical: ScrollBar { @@ -286,11 +285,11 @@ Item { color: { // color line according to log level - if(text.indexOf("[warning]") >= 0) - return Colors.orange; + if (text.indexOf("[warning]") >= 0) + return Colors.orange else if(text.indexOf("[error]") >= 0) - return Colors.red; - return palette.text; + return Colors.red + return palette.text } } } @@ -339,66 +338,63 @@ Item { // Load current source file and update ListView's model - function loadSource() - { - if(!visible) - return; + function loadSource() { + if (!visible) + return - loading = true; - var xhr = new XMLHttpRequest; + loading = true + var xhr = new XMLHttpRequest - xhr.open("GET", root.source); + xhr.open("GET", root.source) xhr.onreadystatechange = function() { // - can't rely on 'Last-Modified' header response to verify // that file has changed on disk (not always up-to-date) // - instead, let QML engine evaluate whether 'text' property value has changed - if(xhr.readyState === XMLHttpRequest.DONE) { - textView.setText(xhr.status === 200 ? xhr.responseText : ""); - loading = false; + if (xhr.readyState === XMLHttpRequest.DONE) { + textView.setText(xhr.status === 200 ? xhr.responseText : "") + loading = false // re-trigger reload source file - if(autoReload) - reloadTimer.restart(); + if (autoReload) + reloadTimer.restart() } - }; - xhr.send(); + } + xhr.send() } // Parse log-line to see if it contains a time indicator // and if yes then turn it into a time value (in seconds) - function getLogLineTime(line) - { - const regex = /[0-9]{2}:[0-9]{2}:[0-9]{2}/; - const found = line.match(regex); + function getLogLineTime(line) { + const regex = /[0-9]{2}:[0-9]{2}:[0-9]{2}/ + const found = line.match(regex) if (found && found.length > 0) { - let hh = parseInt(found[0].substring(0, 2)); - let mm = parseInt(found[0].substring(3, 5)); - let ss = parseInt(found[0].substring(6, 8)); - let time = ss + 60*mm + 3600*hh; + let hh = parseInt(found[0].substring(0, 2)) + let mm = parseInt(found[0].substring(3, 5)) + let ss = parseInt(found[0].substring(6, 8)) + let time = ss + 60 * mm + 3600 * hh; if (!isNaN(time)) { - return time; + return time } } - return -1; + return -1 } // Update a log-lines ListModel from a log-text by filling it with elements containing: // - a log-line (string) // - the elapsed time since the last log-line containing a time value and this one (if it also contains a time value) - function updateLogLinesModel(llm, text) - { - llm.clear(); - const lines = text.split('\n'); - const times = lines.map(line => getLogLineTime(line)); - let prev_idx = -1; + function updateLogLinesModel(llm, text) { + llm.clear() + const lines = text.split('\n') + const times = lines.map(line => getLogLineTime(line)) + let prev_idx = -1 for (let i = 0; i < lines.length; i++) { - let delta = -1; + let delta = -1 if (times[i] >= 0) { if (prev_idx >= 0) { - delta = times[i]-times[prev_idx]; + delta = times[i]-times[prev_idx] } - prev_idx = i; + prev_idx = i } - llm.append({"line": lines[i], "duration": delta}); + llm.append({"line": lines[i], "duration": delta}) } } } From 2bdf061d2e49f3e1513a59922dc33e69f68552cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 13:07:27 +0200 Subject: [PATCH 09/13] [ImageGallery] Clean-up: Harmonize syntax across all files --- .../ui/qml/ImageGallery/ImageDelegate.qml | 6 +- meshroom/ui/qml/ImageGallery/ImageGallery.qml | 148 ++++++++---------- .../ImageGallery/IntrinsicDisplayDelegate.qml | 10 +- .../qml/ImageGallery/IntrinsicsIndicator.qml | 5 +- 4 files changed, 76 insertions(+), 93 deletions(-) diff --git a/meshroom/ui/qml/ImageGallery/ImageDelegate.qml b/meshroom/ui/qml/ImageGallery/ImageDelegate.qml index db00346364..0f5ddf2fdd 100644 --- a/meshroom/ui/qml/ImageGallery/ImageDelegate.qml +++ b/meshroom/ui/qml/ImageGallery/ImageDelegate.qml @@ -36,10 +36,10 @@ Item { // update thumbnail location // can be called from the GridView when a new thumbnail has been written on disk function updateThumbnail() { - thumbnail.source = ThumbnailCache.thumbnail(root.source, root.cellID); + thumbnail.source = ThumbnailCache.thumbnail(root.source, root.cellID) } onSourceChanged: { - updateThumbnail(); + updateThumbnail() } // Send a new request after 5 seconds if thumbnail is not loaded @@ -49,7 +49,7 @@ Item { running: true onTriggered: { if (thumbnail.status == Image.Null) { - updateThumbnail(); + updateThumbnail() } } } diff --git a/meshroom/ui/qml/ImageGallery/ImageGallery.qml b/meshroom/ui/qml/ImageGallery/ImageGallery.qml index 4ca3aaea89..27a890a8b2 100644 --- a/meshroom/ui/qml/ImageGallery/ImageGallery.qml +++ b/meshroom/ui/qml/ImageGallery/ImageGallery.qml @@ -78,35 +78,33 @@ Panel { function parseIntr() { parsedIntrinsic = [] - if(!m.intrinsics) { + if (!m.intrinsics) { return } - //Loop through all intrinsics - for(var i = 0; i < m.intrinsics.count; ++i) { + // Loop through all intrinsics + for (var i = 0; i < m.intrinsics.count; ++i) { var intrinsic = {} - //Loop through all attributes - for(var j=0; j < m.intrinsics.at(i).value.count; ++j) { + // Loop through all attributes + for (var j = 0; j < m.intrinsics.at(i).value.count; ++j) { var currentAttribute = m.intrinsics.at(i).value.at(j) - if(currentAttribute.type === "GroupAttribute") { - for(var k=0; k < currentAttribute.value.count; ++k) { + if (currentAttribute.type === "GroupAttribute") { + for (var k = 0; k < currentAttribute.value.count; ++k) { intrinsic[currentAttribute.name + "." + currentAttribute.value.at(k).name] = currentAttribute.value.at(k) } - } - else if(currentAttribute.type === "ListAttribute") { + } else if (currentAttribute.type === "ListAttribute") { // not needed for now - } - else { + } else { intrinsic[currentAttribute.name] = currentAttribute } } // Table Model needs to contain an entry for each column. // In case of old file formats, some intrinsic keys that we display may not exist in the model. // So, here we create an empty entry to enforce that the key exists in the model. - for(var n = 0; n < intrinsicModel.columnNames.length; ++n) { + for (var n = 0; n < intrinsicModel.columnNames.length; ++n) { var name = intrinsicModel.columnNames[n] - if(!(name in intrinsic)) { + if (!(name in intrinsic)) { intrinsic[name] = {} } } @@ -219,14 +217,14 @@ Panel { function onThumbnailCreated(imgSource, callerID) { let item = grid.itemAtIndex(callerID); // item is an ImageDelegate if (item && item.source === imgSource) { - item.updateThumbnail(); - return; + item.updateThumbnail() + return } // fallback in case the ImageDelegate cellID changed for (let idx = 0; idx < grid.count; idx++) { - item = grid.itemAtIndex(idx); + item = grid.itemAtIndex(idx) if (item && item.source === imgSource) { - item.updateThumbnail(); + item.updateThumbnail() } } } @@ -252,18 +250,18 @@ Panel { // override modelData to return basename of viewpoint's path for sorting function modelData(item, roleName_) { - var roleNameAndCmd = roleName_.split("."); - var roleName = roleName_; - var cmd = ""; - if(roleNameAndCmd.length >= 2) { - roleName = roleNameAndCmd[0]; - cmd = roleNameAndCmd[1]; + var roleNameAndCmd = roleName_.split(".") + var roleName = roleName_ + var cmd = "" + if (roleNameAndCmd.length >= 2) { + roleName = roleNameAndCmd[0] + cmd = roleNameAndCmd[1] } - if(cmd == "isReconstructed") + if (cmd == "isReconstructed") return _reconstruction.isReconstructed(item.model.object); var value = item.model.object.childAttribute(roleName).value; - if(cmd == "basename") + if (cmd == "basename") return Filepath.basename(value); if (cmd == "asString") return value.toString(); @@ -374,43 +372,28 @@ Panel { // Keyboard shortcut to change current image group Keys.priority: Keys.BeforeItem Keys.onPressed: { - if(event.modifiers & Qt.AltModifier) - { - if(event.key === Qt.Key_Right) - { + if (event.modifiers & Qt.AltModifier) { + if (event.key === Qt.Key_Right) { _reconstruction.cameraInitIndex = Math.min(root.cameraInits.count - 1, root.cameraInitIndex + 1) event.accepted = true - } - else if(event.key === Qt.Key_Left) - { + } else if (event.key === Qt.Key_Left) { _reconstruction.cameraInitIndex = Math.max(0, root.cameraInitIndex - 1) event.accepted = true } - } - else - { - if(event.key === Qt.Key_Right) - { + } else { + if (event.key === Qt.Key_Right) { grid.moveCurrentIndexRight() event.accepted = true - } - else if(event.key === Qt.Key_Left) - { + } else if (event.key === Qt.Key_Left) { grid.moveCurrentIndexLeft() event.accepted = true - } - else if(event.key === Qt.Key_Up) - { + } else if (event.key === Qt.Key_Up) { grid.moveCurrentIndexUp() event.accepted = true - } - else if(event.key === Qt.Key_Down) - { + } else if (event.key === Qt.Key_Down) { grid.moveCurrentIndexDown() event.accepted = true - } - else if (event.key === Qt.Key_Tab) - { + } else if (event.key === Qt.Key_Tab) { searchBar.forceActiveFocus() event.accepted = true } @@ -513,7 +496,7 @@ Panel { MouseArea { anchors.fill: parent onPressed: { - if(mouse.button == Qt.LeftButton) + if (mouse.button == Qt.LeftButton) grid.forceActiveFocus() mouse.accepted = false } @@ -611,7 +594,10 @@ Panel { enabled: nodesCB.currentIndex > 0 onClicked: nodesCB.decrementCurrentIndex() } - Label { id: groupLabel; text: "Group " } + Label { + id: groupLabel + text: "Group " + } ComboBox { id: nodesCB model: { @@ -718,8 +704,8 @@ Panel { } } onEnabledChanged: { - if(!enabled) { - if(checked) + if (!enabled) { + if (checked) inputImagesFilterButton.checked = true checked = false } @@ -751,8 +737,8 @@ Panel { } } onEnabledChanged: { - if(!enabled) { - if(checked) + if (!enabled) { + if (checked) inputImagesFilterButton.checked = true checked = false } @@ -782,8 +768,8 @@ Panel { } } onEnabledChanged: { - if(!enabled) { - if(checked) + if (!enabled) { + if (checked) inputImagesFilterButton.checked = true checked = false } @@ -806,34 +792,34 @@ Panel { enabled: activeNode && activeNode.isComputed && (m.viewpoints ? m.viewpoints.count > 0 : false) property string nodeID: activeNode ? (activeNode.label + activeNode.isComputed) : "" onNodeIDChanged: { - if(checked) { - open(); + if (checked) { + open() } } onEnabledChanged: { // Reset the toggle to avoid getting stuck // with the HDR node checked but disabled. - if(checked) { - checked = false; - close(); + if (checked) { + checked = false + close() } } checkable: true checked: false onClicked: { - if(checked) { - open(); + if (checked) { + open() } else { - close(); + close() } } function open() { - if(imageProcessing.checked) - imageProcessing.checked = false; - _reconstruction.setupTempCameraInit(activeNode, "outSfMData"); + if (imageProcessing.checked) + imageProcessing.checked = false + _reconstruction.setupTempCameraInit(activeNode, "outSfMData") } function close() { - _reconstruction.clearTempCameraInit(); + _reconstruction.clearTempCameraInit() } } @@ -850,34 +836,34 @@ Panel { enabled: activeNode && activeNode.isComputed property string nodeID: activeNode ? (activeNode.label + activeNode.isComputed) : "" onNodeIDChanged: { - if(checked) { - open(); + if (checked) { + open() } } onEnabledChanged: { // Reset the toggle to avoid getting stuck // with the HDR node checked but disabled. - if(checked) { - checked = false; - close(); + if (checked) { + checked = false + close() } } checkable: true checked: false onClicked: { - if(checked) { - open(); + if (checked) { + open() } else { - close(); + close() } } function open() { - if(displayHDR.checked) - displayHDR.checked = false; - _reconstruction.setupTempCameraInit(activeNode, "outSfMData"); + if (displayHDR.checked) + displayHDR.checked = false + _reconstruction.setupTempCameraInit(activeNode, "outSfMData") } function close() { - _reconstruction.clearTempCameraInit(); + _reconstruction.clearTempCameraInit() } } diff --git a/meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml b/meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml index 14adc78a18..334f3380e3 100644 --- a/meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml +++ b/meshroom/ui/qml/ImageGallery/IntrinsicDisplayDelegate.qml @@ -48,8 +48,7 @@ RowLayout { sourceComponent: { if (!attribute) return undefined - switch (attribute.type) - { + switch (attribute.type) { case "ChoiceParam": return choice_component case "IntParam": return int_component case "FloatParam": return float_component @@ -115,7 +114,7 @@ RowLayout { _reconstruction.setAttribute(attribute, Number(text)) } Component.onDestruction: { - if(activeFocus) + if (activeFocus) _reconstruction.setAttribute(attribute, Number(text)) } } @@ -176,7 +175,7 @@ RowLayout { readOnly: root.readOnly enabled: !readOnly - clip: true; + clip: true autoScroll: activeFocus @@ -203,10 +202,9 @@ RowLayout { _reconstruction.setAttribute(attribute, Number(text)) } Component.onDestruction: { - if(activeFocus) + if (activeFocus) _reconstruction.setAttribute(attribute, Number(text)) } } } - } diff --git a/meshroom/ui/qml/ImageGallery/IntrinsicsIndicator.qml b/meshroom/ui/qml/ImageGallery/IntrinsicsIndicator.qml index e92683d500..c36492a28f 100644 --- a/meshroom/ui/qml/ImageGallery/IntrinsicsIndicator.qml +++ b/meshroom/ui/qml/ImageGallery/IntrinsicsIndicator.qml @@ -21,9 +21,8 @@ ImageBadge { function findMetadata(key) { var keyLower = key.toLowerCase() - for(var mKey in metadata) - { - if(mKey.toLowerCase().endsWith(keyLower)) + for (var mKey in metadata) { + if (mKey.toLowerCase().endsWith(keyLower)) return metadata[mKey] } return "" From e9d80611c7fe185623e5f276a41b7f2de23cb6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 15:42:14 +0200 Subject: [PATCH 10/13] [GraphEditor] Clean-up: Harmonize syntax across all files --- .../ui/qml/GraphEditor/AttributeEditor.qml | 2 +- .../qml/GraphEditor/AttributeItemDelegate.qml | 130 +++++------ meshroom/ui/qml/GraphEditor/AttributePin.qml | 79 ++++--- .../ui/qml/GraphEditor/ChunksListView.qml | 7 +- .../ui/qml/GraphEditor/CompatibilityBadge.qml | 2 - .../qml/GraphEditor/CompatibilityManager.qml | 13 +- meshroom/ui/qml/GraphEditor/Edge.qml | 8 +- meshroom/ui/qml/GraphEditor/GraphEditor.qml | 202 ++++++++---------- meshroom/ui/qml/GraphEditor/Node.qml | 26 ++- meshroom/ui/qml/GraphEditor/NodeChunks.qml | 2 +- meshroom/ui/qml/GraphEditor/NodeEditor.qml | 3 +- meshroom/ui/qml/GraphEditor/NodeStatus.qml | 49 ++--- meshroom/ui/qml/GraphEditor/StatViewer.qml | 124 +++++------ meshroom/ui/qml/GraphEditor/TaskManager.qml | 56 ++--- meshroom/ui/qml/GraphEditor/common.js | 17 +- 15 files changed, 343 insertions(+), 377 deletions(-) diff --git a/meshroom/ui/qml/GraphEditor/AttributeEditor.qml b/meshroom/ui/qml/GraphEditor/AttributeEditor.qml index b421b7a5a4..dd5528d070 100644 --- a/meshroom/ui/qml/GraphEditor/AttributeEditor.qml +++ b/meshroom/ui/qml/GraphEditor/AttributeEditor.qml @@ -31,7 +31,7 @@ ListView { && (object.isDefault && GraphEditorSettings.showDefaultAttributes || !object.isDefault && GraphEditorSettings.showModifiedAttributes) && (object.isOutput && GraphEditorSettings.showOutputAttributes || !object.isOutput && GraphEditorSettings.showInputAttributes) && (object.isLinkNested && GraphEditorSettings.showLinkAttributes || !object.isLink && GraphEditorSettings.showNotLinkAttributes)) - ) && object.matchText(filterText) + ) && object.matchText(filterText) visible: active sourceComponent: AttributeItemDelegate { diff --git a/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml b/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml index dbb1d6ff81..cb24a08e0d 100644 --- a/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml +++ b/meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml @@ -25,8 +25,7 @@ RowLayout { spacing: 2 - function updateAttributeLabel() - { + function updateAttributeLabel() { background.color = attribute.validValue ? Qt.darker(palette.window, 1.1) : Qt.darker(Colors.red, 1.5) if (attribute.desc) { @@ -40,7 +39,10 @@ RowLayout { } Pane { - background: Rectangle { id: background; color: object.validValue ? Qt.darker(parent.palette.window, 1.1) : Qt.darker(Colors.red, 1.5) } + background: Rectangle { + id: background + color: object.validValue ? Qt.darker(parent.palette.window, 1.1) : Qt.darker(Colors.red, 1.5) + } padding: 0 Layout.preferredWidth: labelWidth || implicitWidth Layout.fillHeight: true @@ -128,8 +130,7 @@ RowLayout { onClicked: { forceActiveFocus() - if(mouse.button == Qt.RightButton) - { + if (mouse.button == Qt.RightButton) { var menu = menuComp.createObject(parameterLabel) menu.parent = parameterLabel menu.popup() @@ -147,25 +148,23 @@ RowLayout { } } - function setTextFieldAttribute(value) - { + function setTextFieldAttribute(value) { // editingFinished called even when TextField is readonly - if(!editable) + if (!editable) return - switch(attribute.type) - { - case "IntParam": - case "FloatParam": - _reconstruction.setAttribute(root.attribute, Number(value)) - updateAttributeLabel() - break; - case "File": - _reconstruction.setAttribute(root.attribute, value) - break; - default: - _reconstruction.setAttribute(root.attribute, value.trim()) - updateAttributeLabel() - break; + switch (attribute.type) { + case "IntParam": + case "FloatParam": + _reconstruction.setAttribute(root.attribute, Number(value)) + updateAttributeLabel() + break + case "File": + _reconstruction.setAttribute(root.attribute, value) + break + default: + _reconstruction.setAttribute(root.attribute, value.trim()) + updateAttributeLabel() + break } } @@ -173,24 +172,28 @@ RowLayout { Layout.fillWidth: true sourceComponent: { - switch(attribute.type) - { - case "ChoiceParam": return attribute.desc.exclusive ? comboBox_component : multiChoice_component - case "IntParam": return slider_component - case "FloatParam": - if(attribute.desc.semantic === 'color/hue') - return color_hue_component - return slider_component - case "BoolParam": return checkbox_component - case "ListAttribute": return listAttribute_component - case "GroupAttribute": return groupAttribute_component - case "StringParam": - if (attribute.desc.semantic === 'multiline') - return textArea_component - return textField_component - case "ColorParam": - return color_component - default: return textField_component + switch (attribute.type) { + case "ChoiceParam": + return attribute.desc.exclusive ? comboBox_component : multiChoice_component + case "IntParam": return slider_component + case "FloatParam": + if (attribute.desc.semantic === 'color/hue') + return color_hue_component + return slider_component + case "BoolParam": + return checkbox_component + case "ListAttribute": + return listAttribute_component + case "GroupAttribute": + return groupAttribute_component + case "StringParam": + if (attribute.desc.semantic === 'multiline') + return textArea_component + return textField_component + case "ColorParam": + return color_component + default: + return textField_component } } @@ -206,16 +209,16 @@ RowLayout { root.forceActiveFocus() } Component.onDestruction: { - if(activeFocus) + if (activeFocus) setTextFieldAttribute(text) } DropArea { enabled: root.editable anchors.fill: parent onDropped: { - if(drop.hasUrls) + if (drop.hasUrls) setTextFieldAttribute(Filepath.urlToString(drop.urls[0])) - else if(drop.hasText && drop.text != '') + else if (drop.hasText && drop.text != '') setTextFieldAttribute(drop.text) } } @@ -282,7 +285,7 @@ RowLayout { checked: node && node.color === "" ? false : true text: "Custom Color" onClicked: { - if(checked) { + if (checked) { _reconstruction.setAttribute(attribute, "#0000FF") } else { _reconstruction.setAttribute(attribute, "") @@ -300,7 +303,7 @@ RowLayout { onEditingFinished: setTextFieldAttribute(text) onAccepted: setTextFieldAttribute(text) Component.onDestruction: { - if(activeFocus) + if (activeFocus) setTextFieldAttribute(text) } } @@ -366,8 +369,11 @@ RowLayout { checked: attribute.value.indexOf(modelData) >= 0 onToggled: { var t = attribute.value - if(!checked) { t.splice(t.indexOf(modelData), 1) } // remove element - else { t.push(modelData) } // add element + if (!checked) { + t.splice(t.indexOf(modelData), 1) // remove element + } else { + t.push(modelData) // add element + } _reconstruction.setAttribute(attribute, t) } } @@ -397,7 +403,7 @@ RowLayout { // When the value change keep the text align to the left to be able to read the most important part // of the number. When we are editing (item is in focus), the content should follow the editing. autoScroll: activeFocus - validator: attribute.type == "FloatParam" ? doubleValidator : intValidator + validator: attribute.type === "FloatParam" ? doubleValidator : intValidator onEditingFinished: setTextFieldAttribute(text) onAccepted: { setTextFieldAttribute(text) @@ -407,7 +413,7 @@ RowLayout { ensureVisible(0) } Component.onDestruction: { - if(activeFocus) + if (activeFocus) setTextFieldAttribute(text) } Component.onCompleted: { @@ -482,7 +488,7 @@ RowLayout { ListView { id: lv model: listAttribute_layout.expanded ? attribute.value : undefined - visible: model != undefined && count > 0 + visible: model !== undefined && count > 0 implicitHeight: Math.min(contentHeight, 300) Layout.fillWidth: true Layout.margins: 4 @@ -491,7 +497,7 @@ RowLayout { ScrollBar.vertical: ScrollBar { id: sb } - delegate: Loader{ + delegate: Loader { active: !objectsHideable || ((object.isDefault && GraphEditorSettings.showDefaultAttributes || !object.isDefault && GraphEditorSettings.showModifiedAttributes) && (object.isLinkNested && GraphEditorSettings.showLinkAttributes || !object.isLinkNested && GraphEditorSettings.showNotLinkAttributes)) @@ -505,14 +511,15 @@ RowLayout { Component.onCompleted: { var cpt = Qt.createComponent("AttributeItemDelegate.qml") var obj = cpt.createObject(item, - {'attribute': Qt.binding(function() { return item.childAttrib }), + { + 'attribute': Qt.binding(function() { return item.childAttrib }), 'readOnly': Qt.binding(function() { return !root.editable }) }) obj.Layout.fillWidth = true obj.label.text = index obj.label.horizontalAlignment = Text.AlignHCenter obj.label.verticalAlignment = Text.AlignVCenter - obj.doubleClicked.connect(function(attr) {root.doubleClicked(attr)}) + obj.doubleClicked.connect(function(attr) { root.doubleClicked(attr) }) } ToolButton { enabled: root.editable @@ -537,11 +544,12 @@ RowLayout { Component.onCompleted: { var cpt = Qt.createComponent("AttributeEditor.qml"); var obj = cpt.createObject(groupItem, - {'model': Qt.binding(function() { return attribute.value }), - 'readOnly': Qt.binding(function() { return root.readOnly }), - 'labelWidth': 100, // reduce label width for children (space gain) - 'objectsHideable': Qt.binding(function() { return root.objectsHideable }), - 'filterText': Qt.binding(function() { return root.filterText }), + { + 'model': Qt.binding(function() { return attribute.value }), + 'readOnly': Qt.binding(function() { return root.readOnly }), + 'labelWidth': 100, // reduce label width for children (space gain) + 'objectsHideable': Qt.binding(function() { return root.objectsHideable }), + 'filterText': Qt.binding(function() { return root.filterText }), }) obj.Layout.fillWidth = true; obj.attributeDoubleClicked.connect(function(attr) {root.doubleClicked(attr)}) @@ -565,7 +573,7 @@ RowLayout { onEditingFinished: setTextFieldAttribute(text) onAccepted: setTextFieldAttribute(text) Component.onDestruction: { - if(activeFocus) + if (activeFocus) setTextFieldAttribute(text) } } @@ -575,9 +583,9 @@ RowLayout { color: Qt.hsla(slider.pressed ? slider.formattedValue : attribute.value, 1, 0.5, 1) } Slider { + id: slider Layout.fillWidth: true - id: slider readonly property int stepDecimalCount: 2 readonly property real formattedValue: value.toFixed(stepDecimalCount) enabled: root.editable @@ -587,7 +595,7 @@ RowLayout { stepSize: 0.01 snapMode: Slider.SnapAlways onPressedChanged: { - if(!pressed) + if (!pressed) _reconstruction.setAttribute(attribute, formattedValue) } diff --git a/meshroom/ui/qml/GraphEditor/AttributePin.qml b/meshroom/ui/qml/GraphEditor/AttributePin.qml index effdf9202a..0d079e92e5 100755 --- a/meshroom/ui/qml/GraphEditor/AttributePin.qml +++ b/meshroom/ui/qml/GraphEditor/AttributePin.qml @@ -17,11 +17,11 @@ RowLayout { property bool displayOutputPinForInput: true // position of the anchor for attaching and edge to this attribute pin - readonly property point inputAnchorPos: Qt.point(inputAnchor.x + inputAnchor.width/2, - inputAnchor.y + inputAnchor.height/2) + readonly property point inputAnchorPos: Qt.point(inputAnchor.x + inputAnchor.width / 2, + inputAnchor.y + inputAnchor.height / 2) - readonly property point outputAnchorPos: Qt.point(outputAnchor.x + outputAnchor.width/2, - outputAnchor.y + outputAnchor.height/2) + readonly property point outputAnchorPos: Qt.point(outputAnchor.x + outputAnchor.width / 2, + outputAnchor.y + outputAnchor.height / 2) readonly property bool isList: attribute && attribute.type === "ListAttribute" @@ -39,8 +39,8 @@ RowLayout { Repeater { id: childrenRepeater model: isList && !attribute.isLink ? attribute.value : 0 - onItemAdded: {childPinCreated(item.childAttribute, item)} - onItemRemoved: {childPinDeleted(item.childAttribute, item)} + onItemAdded: childPinCreated(item.childAttribute, item) + onItemRemoved: childPinDeleted(item.childAttribute, item) delegate: Item { property var childAttribute: object } @@ -52,10 +52,10 @@ RowLayout { width: 8 height: width - radius: isList ? 0 : width/2 + radius: isList ? 0 : width / 2 Layout.alignment: Qt.AlignVCenter - border.color: Colors.sysPalette.mid + border.color: Colors.sysPalette.mid color: Colors.sysPalette.base Rectangle { @@ -64,7 +64,7 @@ RowLayout { anchors.fill: parent anchors.margins: 2 color: { - if(inputConnectMA.containsMouse || inputConnectMA.drag.active || (inputDropArea.containsDrag && inputDropArea.acceptableDrop)) + if (inputConnectMA.containsMouse || inputConnectMA.drag.active || (inputDropArea.containsDrag && inputDropArea.acceptableDrop)) return Colors.sysPalette.highlight return Colors.sysPalette.text } @@ -84,19 +84,17 @@ RowLayout { keys: [inputDragTarget.objectName] onEntered: { // Check if attributes are compatible to create a valid connection - if( root.readOnly // cannot connect on a read-only attribute - || drag.source.objectName != inputDragTarget.objectName // not an edge connector - || drag.source.baseType !== inputDragTarget.baseType // not the same base type - || drag.source.nodeItem === inputDragTarget.nodeItem // connection between attributes of the same node - || (drag.source.isList && !inputDragTarget.isList) // connection between a list and a simple attribute - || (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children - || drag.source.connectorType === "input" // refuse to connect an "input pin" on another one (input attr can be connected to input attr, but not the graphical pin) - ) - { + if (root.readOnly // cannot connect on a read-only attribute + || drag.source.objectName != inputDragTarget.objectName // not an edge connector + || drag.source.baseType !== inputDragTarget.baseType // not the same base type + || drag.source.nodeItem === inputDragTarget.nodeItem // connection between attributes of the same node + || (drag.source.isList && !inputDragTarget.isList) // connection between a list and a simple attribute + || (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children + || drag.source.connectorType === "input" // refuse to connect an "input pin" on another one (input attr can be connected to input attr, but not the graphical pin) + ) { // Refuse attributes connection drag.accepted = false - } - else if (inputDragTarget.attribute.isLink) { // already connected attribute + } else if (inputDragTarget.attribute.isLink) { // already connected attribute root.edgeAboutToBeRemoved(inputDragTarget.attribute) } inputDropArea.acceptableDrop = drag.accepted @@ -159,8 +157,8 @@ RowLayout { Edge { id: inputConnectEdge visible: false - point1x: inputDragTarget.x + inputDragTarget.width/2 - point1y: inputDragTarget.y + inputDragTarget.height/2 + point1x: inputDragTarget.x + inputDragTarget.width / 2 + point1y: inputDragTarget.y + inputDragTarget.height / 2 point2x: parent.width / 2 point2y: parent.width / 2 color: palette.highlight @@ -214,7 +212,7 @@ RowLayout { anchors.fill: parent anchors.margins: 2 color: { - if(outputConnectMA.containsMouse || outputConnectMA.drag.active || (outputDropArea.containsDrag && outputDropArea.acceptableDrop)) + if (outputConnectMA.containsMouse || outputConnectMA.drag.active || (outputDropArea.containsDrag && outputDropArea.acceptableDrop)) return Colors.sysPalette.highlight return Colors.sysPalette.text } @@ -234,18 +232,16 @@ RowLayout { keys: [outputDragTarget.objectName] onEntered: { // Check if attributes are compatible to create a valid connection - if( drag.source.objectName != outputDragTarget.objectName // not an edge connector - || drag.source.baseType !== outputDragTarget.baseType // not the same base type - || drag.source.nodeItem === outputDragTarget.nodeItem // connection between attributes of the same node - || (!drag.source.isList && outputDragTarget.isList) // connection between a list and a simple attribute - || (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children - || drag.source.connectorType === "output" // refuse to connect an output pin on another one - ) - { + if (drag.source.objectName != outputDragTarget.objectName // not an edge connector + || drag.source.baseType !== outputDragTarget.baseType // not the same base type + || drag.source.nodeItem === outputDragTarget.nodeItem // connection between attributes of the same node + || (!drag.source.isList && outputDragTarget.isList) // connection between a list and a simple attribute + || (drag.source.isList && childrenRepeater.count) // source/target are lists but target already has children + || drag.source.connectorType === "output" // refuse to connect an output pin on another one + ) { // Refuse attributes connection drag.accepted = false - } - else if (drag.source.attribute.isLink) { // already connected attribute + } else if (drag.source.attribute.isLink) { // already connected attribute root.edgeAboutToBeRemoved(drag.source.attribute) } outputDropArea.acceptableDrop = drag.accepted @@ -277,8 +273,8 @@ RowLayout { height: parent.height Drag.keys: [outputDragTarget.objectName] Drag.active: outputConnectMA.drag.active - Drag.hotSpot.x: width*0.5 - Drag.hotSpot.y: height*0.5 + Drag.hotSpot.x: width * 0.5 + Drag.hotSpot.y: height * 0.5 } MouseArea { @@ -304,8 +300,8 @@ RowLayout { visible: false point1x: parent.width / 2 point1y: parent.width / 2 - point2x: outputDragTarget.x + outputDragTarget.width/2 - point2y: outputDragTarget.y + outputDragTarget.height/2 + point2x: outputDragTarget.x + outputDragTarget.width / 2 + point2y: outputDragTarget.y + outputDragTarget.height / 2 color: palette.highlight thickness: outputDragTarget.dropAccepted ? 2 : 1 } @@ -354,8 +350,8 @@ RowLayout { script: { // Add the right offset if the initial click is not exactly at the center of the connection circle. var pos = inputDragTarget.mapFromItem(inputConnectMA, inputConnectMA.mouseX, inputConnectMA.mouseY); - inputDragTarget.x = pos.x - inputDragTarget.width/2; - inputDragTarget.y = pos.y - inputDragTarget.height/2; + inputDragTarget.x = pos.x - inputDragTarget.width / 2; + inputDragTarget.y = pos.y - inputDragTarget.height / 2; } } }, @@ -374,11 +370,10 @@ RowLayout { StateChangeScript { script: { var pos = outputDragTarget.mapFromItem(outputConnectMA, outputConnectMA.mouseX, outputConnectMA.mouseY); - outputDragTarget.x = pos.x - outputDragTarget.width/2; - outputDragTarget.y = pos.y - outputDragTarget.height/2; + outputDragTarget.x = pos.x - outputDragTarget.width / 2; + outputDragTarget.y = pos.y - outputDragTarget.height / 2; } } } ] - } diff --git a/meshroom/ui/qml/GraphEditor/ChunksListView.qml b/meshroom/ui/qml/GraphEditor/ChunksListView.qml index e359bcfaed..c8fd39cba8 100644 --- a/meshroom/ui/qml/GraphEditor/ChunksListView.qml +++ b/meshroom/ui/qml/GraphEditor/ChunksListView.qml @@ -18,7 +18,7 @@ ColumnLayout { onChunksChanged: { // When the list changes, ensure the current index is in the new range - if(currentIndex >= chunks.count) + if (currentIndex >= chunks.count) currentIndex = chunks.count-1 } @@ -39,8 +39,7 @@ ColumnLayout { focus: true currentIndex: root.currentIndex onCurrentIndexChanged: { - if(chunksLV.currentIndex !== root.currentIndex) - { + if (chunksLV.currentIndex !== root.currentIndex) { // When the list is resized, the currentIndex is reset to 0. // So here we force it to keep the binding. chunksLV.currentIndex = Qt.binding(function() { return root.currentIndex }) @@ -67,7 +66,7 @@ ColumnLayout { } highlight: Component { Rectangle { - visible: true // !root.chunksSummary + visible: true // !root.chunksSummary color: activePalette.highlight opacity: 0.3 z: 2 diff --git a/meshroom/ui/qml/GraphEditor/CompatibilityBadge.qml b/meshroom/ui/qml/GraphEditor/CompatibilityBadge.qml index 2b22683d71..396eeae93a 100644 --- a/meshroom/ui/qml/GraphEditor/CompatibilityBadge.qml +++ b/meshroom/ui/qml/GraphEditor/CompatibilityBadge.qml @@ -23,7 +23,6 @@ Loader { property Component iconDelegate: Component { Label { - text: MaterialIcons.warning font.family: MaterialIcons.fontFamily font.pointSize: 12 @@ -74,6 +73,5 @@ Loader { } } } - } } diff --git a/meshroom/ui/qml/GraphEditor/CompatibilityManager.qml b/meshroom/ui/qml/GraphEditor/CompatibilityManager.qml index aab731d0ea..f81da217f5 100644 --- a/meshroom/ui/qml/GraphEditor/CompatibilityManager.qml +++ b/meshroom/ui/qml/GraphEditor/CompatibilityManager.qml @@ -20,9 +20,8 @@ MessageDialog { // the number of CompatibilityNodes that can be upgraded readonly property int upgradableCount: { var count = 0 - for(var i=0; i 0 ? factor : 1/factor + var zoomFactor = wheel.angleDelta.y > 0 ? factor : 1 / factor var scale = draggable.scale * zoomFactor scale = Math.min(Math.max(minZoom, scale), maxZoom) - if(draggable.scale == scale) + if (draggable.scale == scale) return var point = mapToItem(draggable, wheel.x, wheel.y) - draggable.x += (1-zoomFactor) * point.x * draggable.scale - draggable.y += (1-zoomFactor) * point.y * draggable.scale + draggable.x += (1 - zoomFactor) * point.x * draggable.scale + draggable.y += (1 - zoomFactor) * point.y * draggable.scale draggable.scale = scale workspaceMoved() } @@ -197,16 +185,15 @@ Item { workspaceClicked() } onPositionChanged: { - if(drag.active) + if (drag.active) workspaceMoved() } onClicked: { - if(mouse.button == Qt.RightButton) - { + if (mouse.button == Qt.RightButton) { // store mouse click position in 'draggable' coordinates as new node spawn position - newNodeMenu.spawnPosition = mouseArea.mapToItem(draggable, mouse.x, mouse.y); - newNodeMenu.popup(); + newNodeMenu.spawnPosition = mouseArea.mapToItem(draggable, mouse.x, mouse.y) + newNodeMenu.popup() } } @@ -217,8 +204,7 @@ Item { property point spawnPosition property variant menuKeys: Object.keys(root.nodeTypesModel).concat(Object.values(MeshroomApp.pipelineTemplateNames)) - function createNode(nodeType) - { + function createNode(nodeType) { uigraph.clearNodeSelection() // Ensures that only the created node / imported pipeline will be selected // "nodeType" might be a pipeline (artificially added in the "Pipelines" category) instead of a node @@ -231,8 +217,7 @@ Item { close() } - function importPipeline(pipeline) - { + function importPipeline(pipeline) { if (MeshroomApp.pipelineTemplateNames.includes(pipeline)) { var url = MeshroomApp.pipelineTemplateFiles[MeshroomApp.pipelineTemplateNames.indexOf(pipeline)]["path"] var nodes = uigraph.importProject(Filepath.stringToUrl(url), spawnPosition) @@ -243,21 +228,20 @@ Item { return false } - function parseCategories() - { + function parseCategories() { // Organize nodes based on their category // {"category1": ["node1", "node2"], "category2": ["node3", "node4"]} let categories = {}; for (const [name, data] of Object.entries(root.nodeTypesModel)) { let category = data["category"]; if (categories[category] === undefined) { - categories[category] = []; + categories[category] = [] } categories[category].push(name) } // Add a "Pipelines" category, filled with the list of templates to create pipelines from the menu - categories["Pipelines"] = MeshroomApp.pipelineTemplateNames; + categories["Pipelines"] = MeshroomApp.pipelineTemplateNames return categories } @@ -287,27 +271,27 @@ Item { // Hide items that does not match the filter text visible: modelData.toLowerCase().indexOf(searchBar.text.toLowerCase()) > -1 // Reset menu currentIndex if highlighted items gets filtered out - onVisibleChanged: if(highlighted) newNodeMenu.currentIndex = 0 + onVisibleChanged: if (highlighted) newNodeMenu.currentIndex = 0 text: modelData // Forward key events to the search bar to continue typing seamlessly // even if this delegate took the activeFocus due to mouse hovering Keys.forwardTo: [searchBar.textField] Keys.onPressed: { event.accepted = false; - switch(event.key) { + switch (event.key) { case Qt.Key_Return: case Qt.Key_Enter: // create node on validation (Enter/Return keys) - newNodeMenu.createNode(modelData); - event.accepted = true; - break; + newNodeMenu.createNode(modelData) + event.accepted = true + break case Qt.Key_Up: case Qt.Key_Down: case Qt.Key_Left: case Qt.Key_Right: - break; // ignore if arrow key was pressed to let the menu be controlled + break // ignore if arrow key was pressed to let the menu be controlled default: - searchBar.forceActiveFocus(); + searchBar.forceActiveFocus() } } // Create node on mouse click @@ -339,7 +323,7 @@ Item { // Dynamically add the menu categories Instantiator { model: !(searchBar.text !== "") ? Object.keys(newNodeMenu.parseCategories()).sort() : undefined - onObjectAdded: newNodeMenu.insertMenu(index+1, object ) // add sub-menu under the search bar + onObjectAdded: newNodeMenu.insertMenu(index + 1, object ) // add sub-menu under the search bar onObjectRemoved: newNodeMenu.removeMenu(object) delegate: Menu { @@ -409,12 +393,10 @@ Item { onPressed: { const canEdit = !edge.dst.node.locked - if(event.button === Qt.RightButton) - { - if(canEdit && (event.modifiers & Qt.AltModifier)) { + if (event.button === Qt.RightButton) { + if (canEdit && (event.modifiers & Qt.AltModifier)) { uigraph.removeEdge(edge) - } - else { + } else { edgeMenu.currentEdge = edge edgeMenu.popup() } @@ -478,8 +460,8 @@ Item { ToolTip.text: "Copy selection to the clipboard and immediately paste it" ToolTip.visible: hovered onTriggered: { - copyNodes(); - pasteNodes(); + copyNodes() + pasteNodes() } } MenuItem { @@ -489,11 +471,14 @@ Item { MaterialToolButton { id: duplicateFollowingButton height: parent.height - anchors { right: parent.right; rightMargin: parent.padding } + anchors { + right: parent.right + rightMargin: parent.padding + } text: MaterialIcons.fast_forward onClicked: { - duplicateNode(true); - nodeMenu.close(); + duplicateNode(true) + nodeMenu.close() } } } @@ -504,11 +489,14 @@ Item { MaterialToolButton { id: removeFollowingButton height: parent.height - anchors { right: parent.right; rightMargin: parent.padding } + anchors { + right: parent.right + rightMargin: parent.padding + } text: MaterialIcons.fast_forward onClicked: { - uigraph.removeNodesFrom(uigraph.selectedNodes); - nodeMenu.close(); + uigraph.removeNodesFrom(uigraph.selectedNodes) + nodeMenu.close() } } } @@ -516,35 +504,38 @@ Item { MenuItem { text: "Delete Data" + (deleteFollowingButton.hovered ? " From Here" : "" ) + "..." enabled: { - if(!nodeMenu.currentNode) + if (!nodeMenu.currentNode) return false // Check if the current node is locked (needed because it does not belong to its own duplicates list) - if(nodeMenu.currentNode.locked) + if (nodeMenu.currentNode.locked) return false // Check if at least one of the duplicate nodes is locked - for(let i = 0; i < nodeMenu.currentNode.duplicates.count; ++i) { - if(nodeMenu.currentNode.duplicates.at(i).locked) + for (let i = 0; i < nodeMenu.currentNode.duplicates.count; ++i) { + if (nodeMenu.currentNode.duplicates.at(i).locked) return false } return true } function showConfirmationDialog(deleteFollowing) { - uigraph.forceNodesStatusUpdate(); + uigraph.forceNodesStatusUpdate() var obj = deleteDataDialog.createObject(root, { "node": nodeMenu.currentNode, "deleteFollowing": deleteFollowing - }); + }) obj.open() - nodeMenu.close(); + nodeMenu.close() } onTriggered: showConfirmationDialog(false) MaterialToolButton { id: deleteFollowingButton - anchors { right: parent.right; rightMargin: parent.padding } + anchors { + right: parent.right + rightMargin: parent.padding + } height: parent.height text: MaterialIcons.fast_forward onClicked: parent.showConfirmationDialog(true) @@ -566,10 +557,10 @@ Item { standardButtons: Dialog.Yes | Dialog.Cancel onAccepted: { - if(deleteFollowing) - uigraph.clearDataFrom(uigraph.selectedNodes); + if (deleteFollowing) + uigraph.clearDataFrom(uigraph.selectedNodes) else - uigraph.clearData(uigraph.selectedNodes); + uigraph.clearData(uigraph.selectedNodes) } onClosed: destroy() } @@ -611,7 +602,7 @@ Item { return } } else if (mouse.modifiers & Qt.AltModifier) { - if (!(mouse.modifiers & Qt.ControlModifier)){ + if (!(mouse.modifiers & Qt.ControlModifier)) { uigraph.clearNodeSelection() } uigraph.selectFollowing(node) @@ -796,10 +787,10 @@ Item { padding: 0 enabled: graphSearchBar.text !== "" onClicked: { - navigation.currentIndex--; + navigation.currentIndex-- if (navigation.currentIndex === -1) - navigation.currentIndex = filteredNodes.count - 1; - navigation.nextItem(); + navigation.currentIndex = filteredNodes.count - 1 + navigation.nextItem() } } @@ -808,10 +799,10 @@ Item { padding: 0 enabled: graphSearchBar.text !== "" onClicked: { - navigation.currentIndex++; + navigation.currentIndex++ if (navigation.currentIndex === filteredNodes.count) - navigation.currentIndex = 0; - navigation.nextItem(); + navigation.currentIndex = 0 + navigation.nextItem() } } @@ -839,38 +830,34 @@ Item { } } - function nextItem() - { + function nextItem() { // compute bounding box var node = nodeRepeater.itemAt(filteredNodes.itemAt(navigation.currentIndex).index_) var bbox = Qt.rect(node.x, node.y, node.width, node.height) // rescale to fit the bounding box in the view, zoom is limited to prevent huge text - draggable.scale = Math.min(Math.min(root.width/bbox.width, root.height/bbox.height),maxZoom) + draggable.scale = Math.min(Math.min(root.width / bbox.width, root.height / bbox.height),maxZoom) // recenter - draggable.x = bbox.x*draggable.scale*-1 + (root.width-bbox.width*draggable.scale)*0.5 - draggable.y = bbox.y*draggable.scale*-1 + (root.height-bbox.height*draggable.scale)*0.5 + draggable.x = bbox.x*draggable.scale * -1 + (root.width - bbox.width * draggable.scale) * 0.5 + draggable.y = bbox.y*draggable.scale * -1 + (root.height - bbox.height * draggable.scale) * 0.5 } } - function registerAttributePin(attribute, pin) - { + function registerAttributePin(attribute, pin) { root._attributeToDelegate[attribute] = pin } - function unregisterAttributePin(attribute, pin) - { + function unregisterAttributePin(attribute, pin) { delete root._attributeToDelegate[attribute] } - function boundingBox() - { + function boundingBox() { var first = nodeRepeater.itemAt(0) var bbox = Qt.rect(first.x, first.y, first.x + first.width, first.y + first.height) - for(var i=0; i 0 ? (100 / root.gpuTotalMemory) : 1; + var gpuMemoryRatio = root.gpuTotalMemory > 0 ? (100 / root.gpuTotalMemory) : 1 - if(gpuUsedMemory.length === 1) { + if (gpuUsedMemory.length === 1) { gpuUsedSerie.append(0, gpuUsed[0]) gpuUsedSerie.append(1 * root.deltaTime, gpuUsed[0]) @@ -282,9 +277,9 @@ Item { gpuTemperatureSerie.append(1 * root.deltaTime, gpuTemperature[0]) root.gpuMaxAxis = Math.max(gpuMaxAxis, gpuTemperature[0]) } else { - var displayLength = Math.min(maxDisplayLength, gpuUsedMemory.length); - var step = gpuUsedMemory.length / displayLength; - for(var ii = 0; ii < displayLength; ii+=step) { + var displayLength = Math.min(maxDisplayLength, gpuUsedMemory.length) + var step = gpuUsedMemory.length / displayLength + for (var ii = 0; ii < displayLength; ii += step) { var i = Math.floor(ii*step) gpuUsedSerie.append(i * root.deltaTime, gpuUsed[i]) @@ -356,7 +351,6 @@ Item { width: parent.width anchors.horizontalCenter: parent.horizontalCenter - ChartViewCheckBox { id: allCPU text: "ALL" @@ -365,9 +359,8 @@ Item { leftPadding: 0 onClicked: { var _checked = checked; - for(var i = 0; i < cpuChart.count; ++i) - { - cpuChart.series(i).visible = _checked; + for (var i = 0; i < cpuChart.count; ++i) { + cpuChart.series(i).visible = _checked } } } @@ -378,7 +371,6 @@ Item { Layout.fillHeight: true chartView: cpuChart } - } } @@ -386,7 +378,7 @@ Item { id: cpuChart Layout.fillWidth: true - Layout.preferredHeight: width/2 + Layout.preferredHeight: width / 2 margins.top: 0 margins.bottom: 0 antialiasing: true @@ -425,7 +417,6 @@ Item { shadesBorderColor: textColor labelsColor: textColor } - } } @@ -442,7 +433,7 @@ Item { margins.top: 0 margins.bottom: 0 Layout.fillWidth: true - Layout.preferredHeight: width/2 + Layout.preferredHeight: width / 2 antialiasing: true legend.color: textColor legend.labelColor: textColor @@ -491,7 +482,6 @@ Item { ColumnLayout { - InteractiveChartView { id: gpuChart @@ -537,8 +527,6 @@ Item { } } } - } } - } diff --git a/meshroom/ui/qml/GraphEditor/TaskManager.qml b/meshroom/ui/qml/GraphEditor/TaskManager.qml index a5735ba166..bcdade1900 100644 --- a/meshroom/ui/qml/GraphEditor/TaskManager.qml +++ b/meshroom/ui/qml/GraphEditor/TaskManager.qml @@ -150,8 +150,8 @@ Item { function getNbFinishedChunks(chunks) { var nbSuccess = 0 - for(var i = 0; i < chunks.count; i++) { - if(chunks.at(i).statusName === "SUCCESS") { + for (var i = 0; i < chunks.count; i++) { + if (chunks.at(i).statusName === "SUCCESS") { nbSuccess += 1 } } @@ -159,7 +159,7 @@ Item { } Label { - text: index+1 + text: index + 1 Layout.preferredWidth: nbMetrics.width + 20 Layout.preferredHeight: parent.height horizontalAlignment: Label.AlignHCenter @@ -253,36 +253,36 @@ Item { Layout.minimumWidth: progressMetrics.width + 20 Layout.preferredHeight: parent.height - ListView { - id: chunkList - width: parent.width - height: parent.height - orientation: ListView.Horizontal - model: object.chunks - property var node: object - - spacing: 3 - - delegate: Label { - width: (ListView.view.width / ListView.view.model.count) -3 - height: ListView.view.height - anchors.verticalCenter: parent.verticalCenter - background: Rectangle { - color: Colors.getChunkColor(object, {"NONE": bgColor}) - radius: 3 - border.width: 2 - border.color: chunkList.node === uigraph.selectedNode ? Colors.sysPalette.text : Colors.getChunkColor(object, {"NONE": bgColor}) + ListView { + id: chunkList + width: parent.width + height: parent.height + orientation: ListView.Horizontal + model: object.chunks + property var node: object + + spacing: 3 + + delegate: Label { + width: (ListView.view.width / ListView.view.model.count) - 3 + height: ListView.view.height + anchors.verticalCenter: parent.verticalCenter + background: Rectangle { + color: Colors.getChunkColor(object, {"NONE": bgColor}) + radius: 3 + border.width: 2 + border.color: chunkList.node === uigraph.selectedNode ? Colors.sysPalette.text : Colors.getChunkColor(object, {"NONE": bgColor}) - } + } - MouseArea { - anchors.fill: parent - onPressed: { - selectNode(chunkList.node) - } + MouseArea { + anchors.fill: parent + onPressed: { + selectNode(chunkList.node) } } } + } } } } diff --git a/meshroom/ui/qml/GraphEditor/common.js b/meshroom/ui/qml/GraphEditor/common.js index 52c24976d5..35c754ce29 100644 --- a/meshroom/ui/qml/GraphEditor/common.js +++ b/meshroom/ui/qml/GraphEditor/common.js @@ -12,21 +12,16 @@ var statusColorsExternOverrides = { "SUBMITTED": "#2196F3" } -function getChunkColor(chunk, overrides) -{ - if(overrides && chunk.statusName in overrides) - { +function getChunkColor(chunk, overrides) { + if (overrides && chunk.statusName in overrides) { return overrides[chunk.statusName] - } - else if(chunk.execModeName === "EXTERN" - && chunk.statusName in statusColorsExternOverrides) - { + } else if(chunk.execModeName === "EXTERN" + && chunk.statusName in statusColorsExternOverrides) { return statusColorsExternOverrides[chunk.statusName] - } - else if(chunk.statusName in statusColors) - { + } else if(chunk.statusName in statusColors) { return statusColors[chunk.statusName] } + console.warn("Unknown status : " + chunk.status) return "magenta" } From e463f0dce2455f47d5b066f9e9434ed94b2b282f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 15:42:51 +0200 Subject: [PATCH 11/13] [qml] Clean-up: Harmonize syntax across all files --- meshroom/ui/qml/AboutDialog.qml | 14 +- meshroom/ui/qml/LiveSfmView.qml | 2 +- .../qml/MaterialIcons/MaterialToolButton.qml | 9 +- .../MaterialIcons/MaterialToolLabelButton.qml | 9 +- meshroom/ui/qml/WorkspaceView.qml | 16 +- meshroom/ui/qml/main.qml | 143 +++++++++--------- 6 files changed, 99 insertions(+), 94 deletions(-) diff --git a/meshroom/ui/qml/AboutDialog.qml b/meshroom/ui/qml/AboutDialog.qml index 1bdce2ac57..67bdf0087c 100644 --- a/meshroom/ui/qml/AboutDialog.qml +++ b/meshroom/ui/qml/AboutDialog.qml @@ -14,7 +14,11 @@ Dialog { // Fade in transition enter: Transition { - NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 } + NumberAnimation { + property: "opacity" + from: 0.0 + to: 1.0 + } } modal: true @@ -173,14 +177,14 @@ Dialog { // try to load the local file var url = Filepath.stringToUrl(modelData.localUrl) // fallback to the online url if file is not found - if(!Filepath.exists(url)) + if (!Filepath.exists(url)) url = modelData.onlineUrl Request.get(url, - function(xhr){ - if(xhr.readyState === XMLHttpRequest.DONE) + function(xhr) { + if (xhr.readyState === XMLHttpRequest.DONE) { // status is OK - if(xhr.status === 200) + if (xhr.status === 200) textArea.text = MeshroomApp.markdownToHtml(xhr.responseText) else textArea.text = "Could not load license file. Available online at "+ url + "." diff --git a/meshroom/ui/qml/LiveSfmView.qml b/meshroom/ui/qml/LiveSfmView.qml index a242423c43..b4d2bf40a1 100644 --- a/meshroom/ui/qml/LiveSfmView.qml +++ b/meshroom/ui/qml/LiveSfmView.qml @@ -93,7 +93,7 @@ Panel { enabled: liveSfmManager ? liveSfmManager.running || folderPath.text.trim() != '' : false checked: liveSfmManager ? liveSfmManager.running : false onClicked: { - if(!liveSfmManager.running) + if (!liveSfmManager.running) liveSfmManager.start(folderPath.text, minImg_SB.value) else liveSfmManager.stop() diff --git a/meshroom/ui/qml/MaterialIcons/MaterialToolButton.qml b/meshroom/ui/qml/MaterialIcons/MaterialToolButton.qml index 9b9f819c2d..6f3d466d66 100644 --- a/meshroom/ui/qml/MaterialIcons/MaterialToolButton.qml +++ b/meshroom/ui/qml/MaterialIcons/MaterialToolButton.qml @@ -19,14 +19,13 @@ ToolButton { } background: Rectangle { color: { - if(pressed || checked || hovered) - { - if(pressed || checked) + if (pressed || checked || hovered) { + if (pressed || checked) return Qt.darker(parent.palette.base, 1.3) - if(hovered) + if (hovered) return Qt.darker(parent.palette.base, 0.6) } - return "transparent"; + return "transparent" } border.color: checked ? Qt.darker(parent.palette.base, 1.4) : "transparent" diff --git a/meshroom/ui/qml/MaterialIcons/MaterialToolLabelButton.qml b/meshroom/ui/qml/MaterialIcons/MaterialToolLabelButton.qml index 16699d9bbf..ebf1b58f2d 100644 --- a/meshroom/ui/qml/MaterialIcons/MaterialToolLabelButton.qml +++ b/meshroom/ui/qml/MaterialIcons/MaterialToolLabelButton.qml @@ -36,14 +36,13 @@ ToolButton { } background: Rectangle { color: { - if(pressed || checked || hovered) - { - if(pressed || checked) + if (pressed || checked || hovered) { + if (pressed || checked) return Qt.darker(parent.palette.base, 1.3) - if(hovered) + if (hovered) return Qt.darker(parent.palette.base, 0.6) } - return "transparent"; + return "transparent" } border.color: checked ? Qt.darker(parent.palette.base, 1.4) : "transparent" diff --git a/meshroom/ui/qml/WorkspaceView.qml b/meshroom/ui/qml/WorkspaceView.qml index e0ad984b51..f772ed5258 100644 --- a/meshroom/ui/qml/WorkspaceView.qml +++ b/meshroom/ui/qml/WorkspaceView.qml @@ -32,15 +32,15 @@ Item { // Load a 3D media file in the 3D viewer function load3DMedia(filepath, label = undefined) { - if(panel3dViewerLoader.active) { - panel3dViewerLoader.item.viewer3D.load(filepath, label); + if (panel3dViewerLoader.active) { + panel3dViewerLoader.item.viewer3D.load(filepath, label) } } Connections { target: reconstruction function onGraphChanged() { - if(panel3dViewerLoader.active) { + if (panel3dViewerLoader.active) { panel3dViewerLoader.item.viewer3D.clear() } } @@ -51,11 +51,11 @@ Item { // Load reconstruction's current SfM file function viewSfM() { - var activeNode = _reconstruction.activeNodes ? _reconstruction.activeNodes.get('sfm').node : null; - if(!activeNode) - return; - if(panel3dViewerLoader.active) { - panel3dViewerLoader.item.viewer3D.view(activeNode.attribute('output')); + var activeNode = _reconstruction.activeNodes ? _reconstruction.activeNodes.get('sfm').node : null + if (!activeNode) + return + if (panel3dViewerLoader.active) { + panel3dViewerLoader.item.viewer3D.view(activeNode.attribute('output')) } } diff --git a/meshroom/ui/qml/main.qml b/meshroom/ui/qml/main.qml index 4ce8b22757..bf62a00d92 100644 --- a/meshroom/ui/qml/main.qml +++ b/meshroom/ui/qml/main.qml @@ -34,9 +34,9 @@ ApplicationWindow { onClosing: { // make sure document is saved before exiting application close.accepted = false - if(!ensureNotComputing()) + if (!ensureNotComputing()) return - ensureSaved(function(){ Qt.quit() }) + ensureSaved(function() { Qt.quit() }) } palette: _PaletteManager.palette @@ -134,7 +134,7 @@ ApplicationWindow { onAccepted: { // save current file - if(saveAction.enabled) + if (saveAction.enabled) { saveAction.trigger() fireCallback() @@ -144,7 +144,7 @@ ApplicationWindow { { saveFileDialog.open() function _callbackWrapper(rc) { - if(rc === Platform.Dialog.Accepted) + if (rc === Platform.Dialog.Accepted) fireCallback() saveFileDialog.closed.disconnect(_callbackWrapper) } @@ -155,7 +155,7 @@ ApplicationWindow { function fireCallback() { // call the callback and reset it - if(_callback) + if (_callback) _callback() _callback = undefined } @@ -215,7 +215,7 @@ ApplicationWindow { false function compute(node, force) { - if(!force && warnIfUnsaved && !_reconstruction.graph.filepath) + if (!force && warnIfUnsaved && !_reconstruction.graph.filepath) { unsavedComputeDialog.currentNode = node; unsavedComputeDialog.open(); @@ -226,7 +226,7 @@ ApplicationWindow { } catch (error) { const data = ErrorHandler.analyseError(error) - if(data.context === "COMPUTATION") + if (data.context === "COMPUTATION") computeSubmitErrorDialog.openError(data.type, data.msg, node) } } @@ -241,7 +241,7 @@ ApplicationWindow { } catch (error) { const data = ErrorHandler.analyseError(error) - if(data.context === "SUBMITTING") + if (data.context === "SUBMITTING") computeSubmitErrorDialog.openError(data.type, data.msg, node) } } @@ -255,10 +255,18 @@ ApplicationWindow { function openError(type, msg, node) { errorType = type - switch(type) { - case "Already Submitted": this.setupPendingStatusError(msg, node); break - case "Compatibility Issue": this.setupCompatibilityIssue(msg); break - default: this.onlyDisplayError(msg) + switch (type) { + case "Already Submitted": { + this.setupPendingStatusError(msg, node) + break + } + case "Compatibility Issue": { + this.setupCompatibilityIssue(msg) + break + } + default: { + this.onlyDisplayError(msg) + } } this.open() @@ -291,7 +299,7 @@ ApplicationWindow { text: "" onAccepted: { - switch(errorType) { + switch (errorType) { case "Already Submitted": { close() _reconstruction.graph.clearSubmittedNodes() @@ -337,7 +345,11 @@ ApplicationWindow { standardButton(Dialog.Discard).text = "Continue without Saving" } - onDiscarded: { close(); computeManager.compute(currentNode, true) } + onDiscarded: { + close() + computeManager.compute(currentNode, true) + } + onAccepted: saveAsAction.trigger() } @@ -363,8 +375,7 @@ ApplicationWindow { title: "Open File" nameFilters: ["Meshroom Graphs (*.mg)"] onAccepted: { - if(_reconstruction.loadUrl(fileUrl)) - { + if (_reconstruction.loadUrl(fileUrl)) { MeshroomApp.addRecentProjectFile(fileUrl.toString()) } } @@ -413,13 +424,9 @@ ApplicationWindow { function ensureSaved(callback) { var saved = _reconstruction.undoStack.clean - // If current document is modified, open "unsaved dialog" - if(!saved) - { + if (!saved) { // If current document is modified, open "unsaved dialog" unsavedDialog.prompt(callback) - } - else // otherwise, directly call the callback - { + } else { // Otherwise, directly call the callback callback() } return saved @@ -438,7 +445,7 @@ ApplicationWindow { // Check and return whether no local computation is in progress function ensureNotComputing() { - if(_reconstruction.computingLocally) + if (_reconstruction.computingLocally) { // Open a warning dialog to ask for computation to be stopped computingAtExitDialog.open() @@ -578,23 +585,23 @@ ApplicationWindow { let folder = ""; if (imagesFolder.toString() === "" && workspaceView.imageGallery.galleryGrid.itemAtIndex(0) !== null) { - imagesFolder = Filepath.stringToUrl(Filepath.dirname(workspaceView.imageGallery.galleryGrid.itemAtIndex(0).source)); + imagesFolder = Filepath.stringToUrl(Filepath.dirname(workspaceView.imageGallery.galleryGrid.itemAtIndex(0).source)) } if (_reconstruction.graph && _reconstruction.graph.filepath) { - folder = Filepath.stringToUrl(Filepath.dirname(_reconstruction.graph.filepath)); + folder = Filepath.stringToUrl(Filepath.dirname(_reconstruction.graph.filepath)) } else { var projects = MeshroomApp.recentProjectFiles; if (projects.length > 0 && Filepath.exists(projects[0])) { - folder = Filepath.stringToUrl(Filepath.dirname(projects[0])); + folder = Filepath.stringToUrl(Filepath.dirname(projects[0])) } } if (importImages && imagesFolder.toString() !== "" && Filepath.exists(imagesFolder)) { - folder = imagesFolder; + folder = imagesFolder } - dialog.folder = folder; + dialog.folder = folder } header: MenuBar { @@ -609,8 +616,8 @@ ApplicationWindow { property int fullWidth: { var result = 0; for (var i = 0; i < count; ++i) { - var item = itemAt(i); - result = Math.max(item.implicitWidth + item.padding * 2, result); + var item = itemAt(i) + result = Math.max(item.implicitWidth + item.padding * 2, result) } return result; } @@ -641,8 +648,8 @@ ApplicationWindow { text: "Open" shortcut: "Ctrl+O" onTriggered: ensureSaved(function() { - initFileDialogFolder(openFileDialog); - openFileDialog.open(); + initFileDialogFolder(openFileDialog) + openFileDialog.open() }) } Menu { @@ -653,10 +660,10 @@ ApplicationWindow { property int fullWidth: { var result = 0; for (var i = 0; i < count; ++i) { - var item = itemAt(i); - result = Math.max(item.implicitWidth + item.padding * 2, result); + var item = itemAt(i) + result = Math.max(item.implicitWidth + item.padding * 2, result) } - return result; + return result } implicitWidth: fullWidth Repeater { @@ -664,14 +671,11 @@ ApplicationWindow { model: MeshroomApp.recentProjectFiles MenuItem { onTriggered: ensureSaved(function() { - openRecentMenu.dismiss(); - if(_reconstruction.loadUrl(modelData)) - { - MeshroomApp.addRecentProjectFile(modelData); - } - else - { - MeshroomApp.removeRecentProjectFile(modelData); + openRecentMenu.dismiss() + if (_reconstruction.loadUrl(modelData)) { + MeshroomApp.addRecentProjectFile(modelData) + } else { + MeshroomApp.removeRecentProjectFile(modelData) } }) @@ -692,13 +696,11 @@ ApplicationWindow { shortcut: "Ctrl+S" enabled: _reconstruction ? (_reconstruction.graph && !_reconstruction.graph.filepath) || !_reconstruction.undoStack.clean : false onTriggered: { - if(_reconstruction.graph.filepath) { - _reconstruction.save(); - } - else - { - initFileDialogFolder(saveFileDialog); - saveFileDialog.open(); + if (_reconstruction.graph.filepath) { + _reconstruction.save() + } else { + initFileDialogFolder(saveFileDialog) + saveFileDialog.open() } } } @@ -707,8 +709,8 @@ ApplicationWindow { text: "Save As..." shortcut: "Ctrl+Shift+S" onTriggered: { - initFileDialogFolder(saveFileDialog); - saveFileDialog.open(); + initFileDialogFolder(saveFileDialog) + saveFileDialog.open() } } MenuSeparator { } @@ -717,8 +719,8 @@ ApplicationWindow { text: "Import Images" shortcut: "Ctrl+I" onTriggered: { - initFileDialogFolder(importImagesDialog, true); - importImagesDialog.open(); + initFileDialogFolder(importImagesDialog, true) + importImagesDialog.open() } } @@ -743,8 +745,8 @@ ApplicationWindow { onActivated: saveAsTemplateAction.triggered() } onTriggered: { - initFileDialogFolder(saveTemplateDialog); - saveTemplateDialog.open(); + initFileDialogFolder(saveTemplateDialog) + saveTemplateDialog.open() } } @@ -763,8 +765,8 @@ ApplicationWindow { onActivated: importProjectAction.triggered() } onTriggered: { - initFileDialogFolder(importProjectDialog); - importProjectDialog.open(); + initFileDialogFolder(importProjectDialog) + importProjectDialog.open() } } @@ -896,7 +898,7 @@ ApplicationWindow { function onGraphChanged() { // open CompatibilityManager after file loading if any issue is detected - if(compatibilityManager.issueCount) + if (compatibilityManager.issueCount) compatibilityManager.open() // trigger fit to visualize all nodes graphEditor.fit() @@ -984,24 +986,25 @@ ApplicationWindow { function viewNode(node, mouse) { // 2D viewer - viewer2D.tryLoadNode(node); + viewer2D.tryLoadNode(node) // 3D viewer for (var i = 0; i < node.attributes.count; i++) { var attr = node.attributes.at(i) - if(attr.isOutput && attr.desc.semantic !== "image" && workspaceView.viewIn3D(attr, mouse)) - break; + if (attr.isOutput && attr.desc.semantic !== "image" && workspaceView.viewIn3D(attr, mouse)) + break } } function viewIn3D(attribute, mouse) { - if(!panel3dViewer || !attribute.node.has3DOutput) - return false; - var loaded = panel3dViewer.viewer3D.view(attribute); + if (!panel3dViewer || !attribute.node.has3DOutput) + return false + var loaded = panel3dViewer.viewer3D.view(attribute) + // solo media if Control modifier was held - if(loaded && mouse && mouse.modifiers & Qt.ControlModifier) - panel3dViewer.viewer3D.solo(attribute); - return loaded; + if (loaded && mouse && mouse.modifiers & Qt.ControlModifier) + panel3dViewer.viewer3D.solo(attribute) + return loaded } } } @@ -1203,8 +1206,8 @@ ApplicationWindow { readOnly: node ? node.locked : false onUpgradeRequest: { - var n = _reconstruction.upgradeNode(node); - _reconstruction.selectedNode = n; + var n = _reconstruction.upgradeNode(node) + _reconstruction.selectedNode = n } } } From f2d67706511954aa3e1c026ecc858beb8c08f938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 17 Oct 2023 15:43:34 +0200 Subject: [PATCH 12/13] [nodes] Clean-up: Harmonize nodes' descriptions --- meshroom/nodes/aliceVision/CameraInit.py | 14 ++--- .../nodes/aliceVision/CameraRigCalibration.py | 2 +- .../aliceVision/CheckerboardDetection.py | 46 ++++++++-------- meshroom/nodes/aliceVision/ConvertMesh.py | 4 +- .../nodes/aliceVision/ConvertSfMFormat.py | 4 +- meshroom/nodes/aliceVision/DepthMap.py | 28 +++++----- .../nodes/aliceVision/ExportAnimatedCamera.py | 2 +- .../nodes/aliceVision/ExportDistortion.py | 38 ++++++------- meshroom/nodes/aliceVision/ImageProcessing.py | 18 +++---- .../nodes/aliceVision/LdrToHdrCalibration.py | 12 ++--- meshroom/nodes/aliceVision/LdrToHdrMerge.py | 40 +++++++------- .../nodes/aliceVision/LdrToHdrSampling.py | 16 +++--- .../nodes/aliceVision/LightingCalibration.py | 2 +- .../nodes/aliceVision/LightingEstimation.py | 2 +- meshroom/nodes/aliceVision/MeshResampling.py | 2 +- meshroom/nodes/aliceVision/Meshing.py | 2 +- meshroom/nodes/aliceVision/NodalSfM.py | 54 +++++++++---------- meshroom/nodes/aliceVision/PanoramaMerging.py | 2 +- .../aliceVision/PanoramaPostProcessing.py | 2 +- meshroom/nodes/aliceVision/Publish.py | 2 +- .../aliceVision/SfMSplitReconstructed.py | 40 +++++++------- .../nodes/aliceVision/SfMTriangulation.py | 2 +- meshroom/nodes/aliceVision/Split360Images.py | 4 +- .../nodes/aliceVision/StructureFromMotion.py | 4 +- meshroom/nodes/aliceVision/Texturing.py | 4 +- 25 files changed, 173 insertions(+), 173 deletions(-) diff --git a/meshroom/nodes/aliceVision/CameraInit.py b/meshroom/nodes/aliceVision/CameraInit.py index 16460b3d0d..bb82a16d7e 100644 --- a/meshroom/nodes/aliceVision/CameraInit.py +++ b/meshroom/nodes/aliceVision/CameraInit.py @@ -38,8 +38,8 @@ value=-1.0, uid=[0], range=None), desc.FloatParam(name="focalLength", label="Focal Length", description="Known/calibrated focal length (in mm).", value=1000.0, uid=[0], range=(0.0, 10000.0, 1.0)), desc.FloatParam(name="pixelRatio", label="Pixel Ratio", description="Ratio between the pixel width and the pixel height.", value=1.0, uid=[0], range=(0.0, 10.0, 0.1)), - desc.BoolParam(name='pixelRatioLocked', label='Pixel Ratio Locked', - description='The pixel ratio value is locked for estimation.', + desc.BoolParam(name="pixelRatioLocked", label="Pixel Ratio Locked", + description="The pixel ratio value is locked for estimation.", value=True, uid=[0]), desc.ChoiceParam(name="type", label="Camera Type", description="Mathematical model used to represent a camera:\n" @@ -241,7 +241,7 @@ class CameraInit(desc.AVCommandLineNode, desc.InitNode): desc.ChoiceParam( name="allowedCameraModels", label="Allowed Camera Models", - description='List of the camera models that can be attributed.', + description="List of the camera models that can be attributed.", value=["pinhole", "radial1", "radial3", "brown", "fisheye4", "fisheye1", "3deanamorphic4", "3deradial4", "3declassicld"], values=["pinhole", "radial1", "radial3", "brown", "fisheye4", "fisheye1", "3deanamorphic4", "3deradial4", "3declassicld"], exclusive=False, @@ -320,10 +320,10 @@ class CameraInit(desc.AVCommandLineNode, desc.InitNode): outputs = [ desc.File( - name='output', - label='SfMData', - description='''Output SfMData.''', - value=desc.Node.internalFolder + 'cameraInit.sfm', + name="output", + label="SfMData", + description="Output SfMData.", + value=desc.Node.internalFolder + "cameraInit.sfm", uid=[], ), ] diff --git a/meshroom/nodes/aliceVision/CameraRigCalibration.py b/meshroom/nodes/aliceVision/CameraRigCalibration.py index ac04acf46e..54784dd45b 100644 --- a/meshroom/nodes/aliceVision/CameraRigCalibration.py +++ b/meshroom/nodes/aliceVision/CameraRigCalibration.py @@ -14,7 +14,7 @@ class CameraRigCalibration(desc.AVCommandLineNode): inputs = [ desc.File( name="sfmdata", - label='SfMData', + label="SfMData", description="Input SfMData file.", value="", uid=[0], diff --git a/meshroom/nodes/aliceVision/CheckerboardDetection.py b/meshroom/nodes/aliceVision/CheckerboardDetection.py index 0dcba781ff..4e2bb4c9ef 100644 --- a/meshroom/nodes/aliceVision/CheckerboardDetection.py +++ b/meshroom/nodes/aliceVision/CheckerboardDetection.py @@ -17,30 +17,30 @@ class CheckerboardDetection(desc.AVCommandLineNode): inputs = [ desc.File( - name='input', - label='Input', - description='SfMData File. Viewpoints must correspond to lens calibration grids.', - value='', + name="input", + label="Input", + description="Input SfMData file. Viewpoints must correspond to lens calibration grids.", + value="", uid=[0], ), desc.BoolParam( - name='useNestedGrids', - label='Nested calibration grid', - description='Images contain nested calibration grids. These grids must be centered on the image center.', + name="useNestedGrids", + label="Nested Calibration Grid", + description="Enable if images contain nested calibration grids. These grids must be centered on the image center.", value=False, uid=[0], ), desc.BoolParam( - name='doubleSize', - label='Double Size', - description='Double the image size prior to processing', + name="doubleSize", + label="Double Size", + description="Double the image size prior to processing.", value=False, uid=[0], ), desc.BoolParam( - name='exportDebugImages', - label='Export Debug Images', - description='Export Debug Images', + name="exportDebugImages", + label="Export Debug Images", + description="Export debug images.", value=False, uid=[0], ), @@ -48,20 +48,20 @@ class CheckerboardDetection(desc.AVCommandLineNode): outputs = [ desc.File( - name='output', - label='Folder', - description='', + name="output", + label="Folder", + description="Output folder.", value=desc.Node.internalFolder, uid=[], ), desc.File( - name='checkerLines', - enabled= lambda node: node.exportDebugImages.value, - label='Checker Lines', - description='Debug Images.', - semantic='image', - value=desc.Node.internalFolder + '.png', - group='', # do not export on the command line + name="checkerLines", + enabled=lambda node: node.exportDebugImages.value, + label="Checker Lines", + description="Debug images.", + semantic="image", + value=desc.Node.internalFolder + ".png", + group="", # do not export on the command line uid=[], ), ] diff --git a/meshroom/nodes/aliceVision/ConvertMesh.py b/meshroom/nodes/aliceVision/ConvertMesh.py index d76097a9a1..e3ef5e7a68 100644 --- a/meshroom/nodes/aliceVision/ConvertMesh.py +++ b/meshroom/nodes/aliceVision/ConvertMesh.py @@ -19,10 +19,10 @@ class ConvertMesh(desc.AVCommandLineNode): ), desc.ChoiceParam( name="outputMeshFileType", - label="File Type", + label="Output File Type", description="Output mesh format (*.obj, *.gltf, *.fbx, *.stl).", value="obj", - values=("gltf", "obj", "fbx", "stl"), + values=["gltf", "obj", "fbx", "stl"], exclusive=True, uid=[0], group="", diff --git a/meshroom/nodes/aliceVision/ConvertSfMFormat.py b/meshroom/nodes/aliceVision/ConvertSfMFormat.py index 9bd2a8156f..7b50a04676 100644 --- a/meshroom/nodes/aliceVision/ConvertSfMFormat.py +++ b/meshroom/nodes/aliceVision/ConvertSfMFormat.py @@ -17,7 +17,7 @@ class ConvertSfMFormat(desc.AVCommandLineNode): desc.File( name="input", label="Input", - description="SfMData file.", + description="Input SfMData file.", value="", uid=[0], ), @@ -45,7 +45,7 @@ class ConvertSfMFormat(desc.AVCommandLineNode): elementDesc=desc.File( name="imageId", label="Image ID", - description="UID or path of an image to add to the whitelist.", + description="UID or path of an image to add to the white list.", value="", uid=[0], ), diff --git a/meshroom/nodes/aliceVision/DepthMap.py b/meshroom/nodes/aliceVision/DepthMap.py index 0cae32d5f6..d418be8cf6 100644 --- a/meshroom/nodes/aliceVision/DepthMap.py +++ b/meshroom/nodes/aliceVision/DepthMap.py @@ -299,7 +299,7 @@ class DepthMap(desc.AVCommandLineNode): value=1, range=(-1, 10, 1), uid=[0], - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.IntParam( name="refineStepXY", @@ -308,7 +308,7 @@ class DepthMap(desc.AVCommandLineNode): value=1, range=(-1, 10, 1), uid=[0], - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.IntParam( name="refineMaxTCamsPerTile", @@ -317,7 +317,7 @@ class DepthMap(desc.AVCommandLineNode): value=4, range=(1, 20, 1), uid=[0], - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.IntParam( name="refineSubsampling", @@ -327,7 +327,7 @@ class DepthMap(desc.AVCommandLineNode): range=(1, 30, 1), uid=[0], advanced=True, - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.IntParam( name="refineHalfNbDepths", @@ -339,7 +339,7 @@ class DepthMap(desc.AVCommandLineNode): range=(1, 50, 1), uid=[0], advanced=True, - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.IntParam( name="refineWSH", @@ -349,7 +349,7 @@ class DepthMap(desc.AVCommandLineNode): range=(1, 20, 1), uid=[0], advanced=True, - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.FloatParam( name="refineSigma", @@ -359,7 +359,7 @@ class DepthMap(desc.AVCommandLineNode): range=(0.0, 30.0, 0.5), uid=[0], advanced=True, - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.FloatParam( name="refineGammaC", @@ -369,7 +369,7 @@ class DepthMap(desc.AVCommandLineNode): range=(0.0, 30.0, 0.5), uid=[0], advanced=True, - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.FloatParam( name="refineGammaP", @@ -379,7 +379,7 @@ class DepthMap(desc.AVCommandLineNode): range=(0.0, 30.0, 0.5), uid=[0], advanced=True, - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.BoolParam( name="refineInterpolateMiddleDepth", @@ -387,7 +387,7 @@ class DepthMap(desc.AVCommandLineNode): description="Enable middle depth bilinear interpolation.", value=False, uid=[0], - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), desc.BoolParam( name="refineUseConsistentScale", @@ -395,7 +395,7 @@ class DepthMap(desc.AVCommandLineNode): description="Compare patch with consistent scale for similarity volume computation.", value=False, uid=[0], - enabled= lambda node: node.refine.refineEnabled.value, + enabled=lambda node: node.refine.refineEnabled.value, ), ] ), @@ -420,7 +420,7 @@ class DepthMap(desc.AVCommandLineNode): range=(1, 500, 10), uid=[0], advanced=True, - enabled= lambda node: node.colorOptimization.colorOptimizationEnabled.value, + enabled=lambda node: node.colorOptimization.colorOptimizationEnabled.value, ), ] ), @@ -452,7 +452,7 @@ class DepthMap(desc.AVCommandLineNode): label="Subparts", description="User custom patch pattern subparts for similarity volume computation.", advanced=True, - enabled= lambda node: (node.customPatchPattern.sgmUseCustomPatchPattern.value or node.customPatchPattern.refineUseCustomPatchPattern.value), + enabled=lambda node: (node.customPatchPattern.sgmUseCustomPatchPattern.value or node.customPatchPattern.refineUseCustomPatchPattern.value), elementDesc=desc.GroupAttribute( name="customPatchPatternSubpart", label="Patch Pattern Subpart", @@ -511,7 +511,7 @@ class DepthMap(desc.AVCommandLineNode): value=False, uid=[0], advanced=True, - enabled= lambda node: (node.customPatchPattern.sgmUseCustomPatchPattern.value or node.customPatchPattern.refineUseCustomPatchPattern.value), + enabled=lambda node: (node.customPatchPattern.sgmUseCustomPatchPattern.value or node.customPatchPattern.refineUseCustomPatchPattern.value), ), ] ), diff --git a/meshroom/nodes/aliceVision/ExportAnimatedCamera.py b/meshroom/nodes/aliceVision/ExportAnimatedCamera.py index 6a79b1c561..fe4b650a30 100644 --- a/meshroom/nodes/aliceVision/ExportAnimatedCamera.py +++ b/meshroom/nodes/aliceVision/ExportAnimatedCamera.py @@ -59,7 +59,7 @@ class ExportAnimatedCamera(desc.AVCommandLineNode): values=["jpg", "png", "tif", "exr"], exclusive=True, uid=[0], - enabled= lambda node: node.exportUndistortedImages.value, + enabled=lambda node: node.exportUndistortedImages.value, ), desc.BoolParam( name="exportFullROD", diff --git a/meshroom/nodes/aliceVision/ExportDistortion.py b/meshroom/nodes/aliceVision/ExportDistortion.py index fa9d070fa9..fe36da67e8 100644 --- a/meshroom/nodes/aliceVision/ExportDistortion.py +++ b/meshroom/nodes/aliceVision/ExportDistortion.py @@ -12,38 +12,38 @@ class ExportDistortion(desc.AVCommandLineNode): inputs = [ desc.File( - name='input', - label='Input SfMData', - description='SfMData file.', - value='', + name="input", + label="Input SfMData", + description="Input SfMData file.", + value="", uid=[0], ), ] outputs = [ desc.File( - name='output', - label='Folder', - description='Output folder.', + name="output", + label="Folder", + description="Output folder.", value=desc.Node.internalFolder, uid=[], ), desc.File( - name='distoStMap', - label='Distortion ST Map', - description='Calibrated distortion ST map.', - semantic='image', - value=desc.Node.internalFolder + '_distort.exr', - group='', # do not export on the command line + name="distoStMap", + label="Distortion ST Map", + description="Calibrated distortion ST map.", + semantic="image", + value=desc.Node.internalFolder + "_distort.exr", + group="", # do not export on the command line uid=[], ), desc.File( - name='undistoStMap', - label='Undistortion ST Map', - description='Calibrated undistortion ST map.', - semantic='image', - value=desc.Node.internalFolder + '_undistort.exr', - group='', # do not export on the command line + name="undistoStMap", + label="Undistortion ST Map", + description="Calibrated undistortion ST map.", + semantic="image", + value=desc.Node.internalFolder + "_undistort.exr", + group="", # do not export on the command line uid=[], ), ] diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index ac5cc42ca6..f5d7b1d5a3 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -413,7 +413,7 @@ class ImageProcessing(desc.AVCommandLineNode): desc.BoolParam( name="nlmFilterEnabled", label="Enable", - description='Use Non-Local Mean Denoising from OpenCV to denoise images.', + description="Use Non-Local Mean Denoising from OpenCV to denoise images.", value=False, uid=[0], ), @@ -587,17 +587,17 @@ class ImageProcessing(desc.AVCommandLineNode): ), desc.File( - name='lensCorrectionProfileInfo', - label='Lens Correction Profile Info', - description='''Lens Correction Profile filepath or database directory.''', - value='${ALICEVISION_LENS_PROFILE_INFO}', + name="lensCorrectionProfileInfo", + label="Lens Correction Profile Info", + description="Lens Correction Profile filepath or database directory.", + value="${ALICEVISION_LENS_PROFILE_INFO}", uid=[], ), desc.BoolParam( - name='lensCorrectionProfileSearchIgnoreCameraModel', - label='LCP Generic Search', - description='The lens name and camera maker are used to match the LCP database, but the camera model is ignored.', + name="lensCorrectionProfileSearchIgnoreCameraModel", + label="LCP Generic Search", + description="The lens name and camera maker are used to match the LCP database, but the camera model is ignored.", value=True, uid=[0], advanced=True, @@ -689,7 +689,7 @@ class ImageProcessing(desc.AVCommandLineNode): label="Images", description="Output images.", semantic="image", - value= outputImagesValueFunct, + value=outputImagesValueFunct, group="", # do not export on the command line uid=[], ), diff --git a/meshroom/nodes/aliceVision/LdrToHdrCalibration.py b/meshroom/nodes/aliceVision/LdrToHdrCalibration.py index 27e1e784d4..c454f463a4 100644 --- a/meshroom/nodes/aliceVision/LdrToHdrCalibration.py +++ b/meshroom/nodes/aliceVision/LdrToHdrCalibration.py @@ -80,7 +80,7 @@ class LdrToHdrCalibration(desc.AVCommandLineNode): description="Bypass HDR creation and use the medium bracket as the source for the next steps.", value=False, uid=[0], - enabled= lambda node: node.nbBrackets.value != 1, + enabled=lambda node: node.nbBrackets.value != 1, ), desc.ChoiceParam( name="calibrationMethod", @@ -95,7 +95,7 @@ class LdrToHdrCalibration(desc.AVCommandLineNode): value="auto", exclusive=True, uid=[0], - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.ChoiceParam( name="calibrationWeight", @@ -109,7 +109,7 @@ class LdrToHdrCalibration(desc.AVCommandLineNode): values=["default", "gaussian", "triangle", "plateau"], exclusive=True, uid=[0], - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.IntParam( name="channelQuantizationPower", @@ -119,7 +119,7 @@ class LdrToHdrCalibration(desc.AVCommandLineNode): range=(8, 14, 1), uid=[0], advanced=True, - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.ChoiceParam( name="workingColorSpace", @@ -131,7 +131,7 @@ class LdrToHdrCalibration(desc.AVCommandLineNode): exclusive=True, uid=[], group="user", # not used directly on the command line - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.IntParam( name="maxTotalPoints", @@ -143,7 +143,7 @@ class LdrToHdrCalibration(desc.AVCommandLineNode): range=(8, 10000000, 1000), uid=[0], advanced=True, - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.ChoiceParam( name="verboseLevel", diff --git a/meshroom/nodes/aliceVision/LdrToHdrMerge.py b/meshroom/nodes/aliceVision/LdrToHdrMerge.py index 7431ff8b14..3e5ca2c19f 100644 --- a/meshroom/nodes/aliceVision/LdrToHdrMerge.py +++ b/meshroom/nodes/aliceVision/LdrToHdrMerge.py @@ -89,7 +89,7 @@ class LdrToHdrMerge(desc.AVCommandLineNode): value=1, range=(-4, 4, 1), uid=[0], - enabled= lambda node: (node.nbBrackets.value != 1 and node.offsetRefBracketIndexEnabled.value), + enabled=lambda node: (node.nbBrackets.value != 1 and node.offsetRefBracketIndexEnabled.value), ), desc.FloatParam( name="meanTargetedLumaForMerging", @@ -98,33 +98,33 @@ class LdrToHdrMerge(desc.AVCommandLineNode): value=0.4, range=(0.0, 1.0, 0.01), uid=[0], - enabled= lambda node: (node.nbBrackets.value != 1 and not node.offsetRefBracketIndexEnabled.value), + enabled=lambda node: (node.nbBrackets.value != 1 and not node.offsetRefBracketIndexEnabled.value), ), desc.FloatParam( - name='minSignificantValue', - label='Minimum Significant Value', - description='Minimum channel input value to be considered in advanced pixelwise merging.', + name="minSignificantValue", + label="Minimum Significant Value", + description="Minimum channel input value to be considered in advanced pixelwise merging.", value=0.05, range=(0.0, 1.0, 0.001), uid=[0], - enabled= lambda node: (node.nbBrackets.value != 1), + enabled=lambda node: (node.nbBrackets.value != 1), ), desc.FloatParam( - name='maxSignificantValue', - label='Maximum Significant Value', - description='Maximum channel input value to be considered in advanced pixelwise merging.', + name="maxSignificantValue", + label="Maximum Significant Value", + description="Maximum channel input value to be considered in advanced pixelwise merging.", value=0.995, range=(0.0, 1.0, 0.001), uid=[0], - enabled= lambda node: (node.nbBrackets.value != 1), + enabled=lambda node: (node.nbBrackets.value != 1), ), desc.BoolParam( - name='computeLightMasks', - label='Compute Light Masks', + name="computeLightMasks", + label="Compute Light Masks", description="Compute masks of low and high lights and missing info.", value=False, uid=[0], - enabled= lambda node: node.nbBrackets.value != 1, + enabled=lambda node: node.nbBrackets.value != 1, ), desc.BoolParam( name="byPass", @@ -132,7 +132,7 @@ class LdrToHdrMerge(desc.AVCommandLineNode): description="Bypass HDR creation and use the medium bracket as the source for the next steps.", value=False, uid=[0], - enabled= lambda node: node.nbBrackets.value != 1, + enabled=lambda node: node.nbBrackets.value != 1, ), desc.BoolParam( name="keepSourceImageName", @@ -152,7 +152,7 @@ class LdrToHdrMerge(desc.AVCommandLineNode): values=["gaussian", "triangle", "plateau"], exclusive=True, uid=[0], - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.IntParam( name="channelQuantizationPower", @@ -162,7 +162,7 @@ class LdrToHdrMerge(desc.AVCommandLineNode): range=(8, 14, 1), uid=[0], advanced=True, - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.ChoiceParam( name="workingColorSpace", @@ -173,7 +173,7 @@ class LdrToHdrMerge(desc.AVCommandLineNode): values=["auto", "sRGB", "Linear", "ACES2065-1", "ACEScg", "no_conversion"], exclusive=True, uid=[0], - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.BoolParam( name="enableHighlight", @@ -182,7 +182,7 @@ class LdrToHdrMerge(desc.AVCommandLineNode): value=False, uid=[0], group="user", # not used directly on the command line - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.FloatParam( name="highlightCorrectionFactor", @@ -195,7 +195,7 @@ class LdrToHdrMerge(desc.AVCommandLineNode): value=1.0, range=(0.0, 1.0, 0.01), uid=[0], - enabled= lambda node: node.enableHighlight.enabled and node.enableHighlight.value, + enabled=lambda node: node.enableHighlight.enabled and node.enableHighlight.value, ), desc.FloatParam( name="highlightTargetLux", @@ -218,7 +218,7 @@ class LdrToHdrMerge(desc.AVCommandLineNode): value=120000.0, range=(1000.0, 150000.0, 1.0), uid=[0], - enabled= lambda node: node.enableHighlight.enabled and node.enableHighlight.value and node.highlightCorrectionFactor.value != 0, + enabled=lambda node: node.enableHighlight.enabled and node.enableHighlight.value and node.highlightCorrectionFactor.value != 0, ), desc.ChoiceParam( name="storageDataType", diff --git a/meshroom/nodes/aliceVision/LdrToHdrSampling.py b/meshroom/nodes/aliceVision/LdrToHdrSampling.py index 1952f87387..2ce8fa1567 100644 --- a/meshroom/nodes/aliceVision/LdrToHdrSampling.py +++ b/meshroom/nodes/aliceVision/LdrToHdrSampling.py @@ -94,7 +94,7 @@ class LdrToHdrSampling(desc.AVCommandLineNode): description="Bypass HDR creation and use the medium bracket as the source for the next steps.", value=False, uid=[0], - enabled= lambda node: node.nbBrackets.value != 1, + enabled=lambda node: node.nbBrackets.value != 1, ), desc.ChoiceParam( name="calibrationMethod", @@ -109,7 +109,7 @@ class LdrToHdrSampling(desc.AVCommandLineNode): value="auto", exclusive=True, uid=[0], - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.IntParam( name="channelQuantizationPower", @@ -119,7 +119,7 @@ class LdrToHdrSampling(desc.AVCommandLineNode): range=(8, 14, 1), uid=[0], advanced=True, - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.ChoiceParam( name="workingColorSpace", @@ -130,7 +130,7 @@ class LdrToHdrSampling(desc.AVCommandLineNode): values=["auto", "sRGB", "Linear", "ACES2065-1", "ACEScg", "no_conversion"], exclusive=True, uid=[0], - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.IntParam( name="blockSize", @@ -140,7 +140,7 @@ class LdrToHdrSampling(desc.AVCommandLineNode): range=(8, 1024, 1), uid=[0], advanced=True, - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.IntParam( name="radius", @@ -150,7 +150,7 @@ class LdrToHdrSampling(desc.AVCommandLineNode): range=(0, 10, 1), uid=[0], advanced=True, - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.IntParam( name="maxCountSample", @@ -160,7 +160,7 @@ class LdrToHdrSampling(desc.AVCommandLineNode): range=(10, 1000, 10), uid=[0], advanced=True, - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.BoolParam( name="debug", @@ -168,7 +168,7 @@ class LdrToHdrSampling(desc.AVCommandLineNode): description="Export debug files to analyze the sampling strategy.", value=False, uid=[], - enabled= lambda node: node.byPass.enabled and not node.byPass.value, + enabled=lambda node: node.byPass.enabled and not node.byPass.value, ), desc.ChoiceParam( name="verboseLevel", diff --git a/meshroom/nodes/aliceVision/LightingCalibration.py b/meshroom/nodes/aliceVision/LightingCalibration.py index ddeb72ec92..718f4149af 100644 --- a/meshroom/nodes/aliceVision/LightingCalibration.py +++ b/meshroom/nodes/aliceVision/LightingCalibration.py @@ -14,7 +14,7 @@ class LightingCalibration(desc.CommandLineNode): inputs = [ desc.File( name="inputPath", - label="SfMData", + label="Input SfMData", description="Input SfMData file.", value="", uid=[0] diff --git a/meshroom/nodes/aliceVision/LightingEstimation.py b/meshroom/nodes/aliceVision/LightingEstimation.py index e7a4a8ccc6..6bd5275a8c 100644 --- a/meshroom/nodes/aliceVision/LightingEstimation.py +++ b/meshroom/nodes/aliceVision/LightingEstimation.py @@ -13,7 +13,7 @@ class LightingEstimation(desc.AVCommandLineNode): inputs = [ desc.File( name="input", - label="SfMData", + label="Input SfMData", description="Input SfMData file.", value="", uid=[0], diff --git a/meshroom/nodes/aliceVision/MeshResampling.py b/meshroom/nodes/aliceVision/MeshResampling.py index 5e9eda6fab..56c0048b34 100644 --- a/meshroom/nodes/aliceVision/MeshResampling.py +++ b/meshroom/nodes/aliceVision/MeshResampling.py @@ -39,7 +39,7 @@ class MeshResampling(desc.AVCommandLineNode): ), desc.IntParam( name="minVertices", - label='Min Vertices', + label="Min Vertices", description="Minimum number of output vertices.", value=0, range=(0, 1000000, 1), diff --git a/meshroom/nodes/aliceVision/Meshing.py b/meshroom/nodes/aliceVision/Meshing.py index 85452bbb65..9d85bc96ce 100644 --- a/meshroom/nodes/aliceVision/Meshing.py +++ b/meshroom/nodes/aliceVision/Meshing.py @@ -326,7 +326,7 @@ class Meshing(desc.AVCommandLineNode): ), desc.IntParam( name="helperPointsGridSize", - label='Helper Points Grid Size', + label="Helper Points Grid Size", description="Grid size for the helper points.", value=10, range=(0, 50, 1), diff --git a/meshroom/nodes/aliceVision/NodalSfM.py b/meshroom/nodes/aliceVision/NodalSfM.py index 1090cf7568..79aa5f4f78 100644 --- a/meshroom/nodes/aliceVision/NodalSfM.py +++ b/meshroom/nodes/aliceVision/NodalSfM.py @@ -14,10 +14,10 @@ class NodalSfM(desc.AVCommandLineNode): inputs = [ desc.File( - name='input', - label='SfMData', - description='SfMData file.', - value='', + name="input", + label="SfMData", + description="Input SfMData file.", + value="", uid=[0], ), desc.ListAttribute( @@ -33,35 +33,35 @@ class NodalSfM(desc.AVCommandLineNode): description="Folder(s) containing the extracted features and descriptors." ), desc.File( - name='tracksFilename', - label='Tracks file', - description='Tracks file.', - value='', + name="tracksFilename", + label="Tracks File", + description="Input tracks file.", + value="", uid=[0], ), desc.File( - name='pairs', - label='Pairs file', - description='Information on pairs.', - value='', + name="pairs", + label="Pairs File", + description="Information on pairs.", + value="", uid=[0], ), desc.ChoiceParam( - name='describerTypes', - label='Describer Types', - description='Describer types used to describe an image.', - value=['dspsift'], - values=['sift', 'sift_float', 'sift_upright', 'dspsift', 'akaze', 'akaze_liop', 'akaze_mldb', 'cctag3', 'cctag4', 'sift_ocv', 'akaze_ocv', 'tag16h5'], + name="describerTypes", + label="Describer Types", + description="Describer types used to describe an image.", + value=["dspsift"], + values=["sift", "sift_float", "sift_upright", "dspsift", "akaze", "akaze_liop", "akaze_mldb", "cctag3", "cctag4", "sift_ocv", "akaze_ocv", "tag16h5"], exclusive=False, uid=[0], - joinChar=',', + joinChar=",", ), desc.ChoiceParam( - name='verboseLevel', - label='Verbose Level', - description='Verbosity level (fatal, error, warning, info, debug, trace).', - value='info', - values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'], + name="verboseLevel", + label="Verbose Level", + description="Verbosity level (fatal, error, warning, info, debug, trace).", + value="info", + values=["fatal", "error", "warning", "info", "debug", "trace"], exclusive=True, uid=[], ) @@ -69,10 +69,10 @@ class NodalSfM(desc.AVCommandLineNode): outputs = [ desc.File( - name='output', - label='SfMData', - description='Path to the output sfmdata file', - value=desc.Node.internalFolder + 'sfm.abc', + name="output", + label="SfMData", + description="Path to the output SfMData file.", + value=desc.Node.internalFolder + "sfm.abc", uid=[], ) ] diff --git a/meshroom/nodes/aliceVision/PanoramaMerging.py b/meshroom/nodes/aliceVision/PanoramaMerging.py index 3e12c4e2cd..f55f58a66e 100644 --- a/meshroom/nodes/aliceVision/PanoramaMerging.py +++ b/meshroom/nodes/aliceVision/PanoramaMerging.py @@ -22,7 +22,7 @@ class PanoramaMerging(desc.AVCommandLineNode): name="input", label="Input SfMData", description="Input SfMData file.", - value='', + value="", uid=[0], ), desc.File( diff --git a/meshroom/nodes/aliceVision/PanoramaPostProcessing.py b/meshroom/nodes/aliceVision/PanoramaPostProcessing.py index 8052edba62..909eb96bd1 100644 --- a/meshroom/nodes/aliceVision/PanoramaPostProcessing.py +++ b/meshroom/nodes/aliceVision/PanoramaPostProcessing.py @@ -135,6 +135,6 @@ class PanoramaPostProcessing(desc.CommandLineNode): description="Downscaled versions of the generated panorama.", value=lambda attr: desc.Node.internalFolder + os.path.splitext(attr.node.panoramaName.value)[0] + "_level_*.exr", uid=[], - group='', + group="", ), ] diff --git a/meshroom/nodes/aliceVision/Publish.py b/meshroom/nodes/aliceVision/Publish.py index 9ec86f5e15..95578bf743 100644 --- a/meshroom/nodes/aliceVision/Publish.py +++ b/meshroom/nodes/aliceVision/Publish.py @@ -22,7 +22,7 @@ class Publish(desc.Node): elementDesc=desc.File( name="input", label="Input", - description="", + description="File or folder to publish.", value="", uid=[0], ), diff --git a/meshroom/nodes/aliceVision/SfMSplitReconstructed.py b/meshroom/nodes/aliceVision/SfMSplitReconstructed.py index f224c4114c..5e01846453 100644 --- a/meshroom/nodes/aliceVision/SfMSplitReconstructed.py +++ b/meshroom/nodes/aliceVision/SfMSplitReconstructed.py @@ -9,25 +9,25 @@ class SfMSplitReconstructed(desc.AVCommandLineNode): category = 'Utils' documentation = ''' - This nodes takes a sfmData file and split it in two - - One sfmData with the reconstructed views - - One sfmData with the non reconstructed views + This nodes takes a SfMData file as an input and splits it in two output SfMData files: + - One SfMData containing the reconstructed views + - One SfMData containing the non-reconstructed views ''' inputs = [ desc.File( - name='input', - label='Input', - description='''SfMData file .''', - value='', + name="input", + label="Input SfMData", + description="Input SfMData file.", + value="", uid=[0], ), desc.ChoiceParam( - name='verboseLevel', - label='Verbose Level', - description='''verbosity level (fatal, error, warning, info, debug, trace).''', - value='info', - values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'], + name="verboseLevel", + label="Verbose Level", + description="Verbosity level (fatal, error, warning, info, debug, trace).", + value="info", + values=["fatal", "error", "warning", "info", "debug", "trace"], exclusive=True, uid=[], ), @@ -35,17 +35,17 @@ class SfMSplitReconstructed(desc.AVCommandLineNode): outputs = [ desc.File( - name='reconstructedOutput', - label='Reconstructed SfMData File', - description='SfMData file with reconstructed cameras', - value=desc.Node.internalFolder + 'sfmReconstructed.abc', + name="reconstructedOutput", + label="Reconstructed SfMData File", + description="SfMData file containing the reconstructed cameras.", + value=desc.Node.internalFolder + "sfmReconstructed.abc", uid=[], ), desc.File( - name='notReconstructedOutput', - label='Not Reconstructed SfMData File', - description='SfMData file with non reconstructed cameras', - value=desc.Node.internalFolder + 'sfmNonReconstructed.abc', + name="notReconstructedOutput", + label="Not Reconstructed SfMData File", + description="SfMData file containing the non-reconstructed cameras.", + value=desc.Node.internalFolder + "sfmNonReconstructed.abc", uid=[], ) ] diff --git a/meshroom/nodes/aliceVision/SfMTriangulation.py b/meshroom/nodes/aliceVision/SfMTriangulation.py index d2d877f7ec..aeb369c346 100644 --- a/meshroom/nodes/aliceVision/SfMTriangulation.py +++ b/meshroom/nodes/aliceVision/SfMTriangulation.py @@ -131,7 +131,7 @@ class SfMTriangulation(desc.AVCommandLineNode): ), desc.ChoiceParam( name="interFileExtension", - label='Inter File Extension', + label="Inter File Extension", description="Extension of the intermediate file export.", value=".abc", values=(".abc", ".ply"), diff --git a/meshroom/nodes/aliceVision/Split360Images.py b/meshroom/nodes/aliceVision/Split360Images.py index 40197dbb11..76f1066e0f 100644 --- a/meshroom/nodes/aliceVision/Split360Images.py +++ b/meshroom/nodes/aliceVision/Split360Images.py @@ -31,7 +31,7 @@ class Split360Images(desc.AVCommandLineNode): name="input", label="Input", description="Single image, image folder or SfMData file.", - value='', + value="", uid=[0], ), desc.ChoiceParam( @@ -80,7 +80,7 @@ class Split360Images(desc.AVCommandLineNode): groupDesc=[ desc.IntParam( name="equirectangularNbSplits", - label='Nb Splits', + label="Nb Splits", description="Equirectangular number of splits.", value=2, range=(1, 100, 1), diff --git a/meshroom/nodes/aliceVision/StructureFromMotion.py b/meshroom/nodes/aliceVision/StructureFromMotion.py index 77a4a6bd76..77731b3662 100644 --- a/meshroom/nodes/aliceVision/StructureFromMotion.py +++ b/meshroom/nodes/aliceVision/StructureFromMotion.py @@ -65,7 +65,7 @@ class StructureFromMotion(desc.AVCommandLineNode): desc.File( name="input", label="SfMData", - description='SfMData file.', + description="Input SfMData file.", value="", uid=[0], ), @@ -323,7 +323,7 @@ class StructureFromMotion(desc.AVCommandLineNode): ), desc.IntParam( name="minNbCamerasToRefinePrincipalPoint", - label='Min Nb Cameras To Refine Principal Point', + label="Min Nb Cameras To Refine Principal Point", description="Minimum number of cameras to refine the principal point of the cameras (one of the intrinsic parameters of the camera).\n" "If we do not have enough cameras, the principal point is considered to be in the center of the image.\n" "If minNbCamerasToRefinePrincipalPoint <= 0, the principal point is never refined." diff --git a/meshroom/nodes/aliceVision/Texturing.py b/meshroom/nodes/aliceVision/Texturing.py index 392e1c200e..df5aa1234b 100644 --- a/meshroom/nodes/aliceVision/Texturing.py +++ b/meshroom/nodes/aliceVision/Texturing.py @@ -350,7 +350,7 @@ class Texturing(desc.AVCommandLineNode): ), desc.File( name="outputMaterial", - enabled= lambda node: node.outputMeshFileType.value == "obj", + enabled=lambda node: node.outputMeshFileType.value == "obj", label="Material", description="Output material file.", value=desc.Node.internalFolder + "texturedMesh.mtl", @@ -361,7 +361,7 @@ class Texturing(desc.AVCommandLineNode): name="outputTextures", label="Textures", description="Output texture files.", - value= lambda attr: desc.Node.internalFolder + "texture_*." + attr.node.colorMapping.colorMappingFileType.value if attr.node.colorMapping.enable.value else "", + value=lambda attr: desc.Node.internalFolder + "texture_*." + attr.node.colorMapping.colorMappingFileType.value if attr.node.colorMapping.enable.value else "", uid=[], group="" ) From 6d4c832df3534369055977862685091a6a434fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Mon, 6 Nov 2023 16:34:45 +0100 Subject: [PATCH 13/13] Add `.git-blame-ignore-revs` with initial SHA1s to ignore --- .git-blame-ignore-revs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000..901711b7ee --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,18 @@ +# [nodes] Clean-up: Harmonize nodes' descriptions +f2d67706511954aa3e1c026ecc858beb8c08f938 +# [qml] Clean-up: Harmonize syntax across all files +e463f0dce2455f47d5b066f9e9434ed94b2b282f +# [GraphEditor] Clean-up: Harmonize syntax across all files +e9d80611c7fe185623e5f276a41b7f2de23cb6fe +# [ImageGallery] Clean-up: Harmonize syntax across all files +2bdf061d2e49f3e1513a59922dc33e69f68552cf +# [Controls] Clean-up: Harmonize syntax across all files +2908aa94a3eda2de71f8c5e6cec8cd78280bbb09 +# [Charts] Clean-up: Harmonize syntax across all files +856641bc9dc25271062dc94a66da4c08e00f88d1 +# [Utils] Clean-up: Harmonize syntax across all files +8313e42d8c70e2494277e338ef8fd38824270231 +# [Viewer] Clean-up: Harmonize syntax across all files +13b8266d14783a4c595c8b731c54fc9c61adfa92 +# [Viewer3D] Clean-up: Harmonize syntax across all files +9d2974d2823fe5d6f400eb4658f67d0306b11ac8 \ No newline at end of file