diff --git a/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml b/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml index 1992ca28..0dc4f848 100644 --- a/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml +++ b/meshroom/ui/qml/Viewer3D/DefaultCameraController.qml @@ -23,6 +23,8 @@ Entity { property alias windowSize: trackball.windowSize property alias trackballSize: trackball.trackballSize + property bool loseMouseFocus: false // Must be changed by other entities when they want to take mouse focus + readonly property alias pressed: mouseHandler._pressed signal mousePressed(var mouse) signal mouseReleased(var mouse, var moved) @@ -166,6 +168,8 @@ Entity { components: [ FrameAction { onTriggered: { + if(loseMouseFocus) return + if(panning) { // translate var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.03; var tx = axisMX.value * root.translateSpeed * d; diff --git a/meshroom/ui/qml/Viewer3D/EntityWithGizmo.qml b/meshroom/ui/qml/Viewer3D/EntityWithGizmo.qml new file mode 100644 index 00000000..3a6eaa5d --- /dev/null +++ b/meshroom/ui/qml/Viewer3D/EntityWithGizmo.qml @@ -0,0 +1,32 @@ +import Qt3D.Core 2.0 +import Qt3D.Render 2.9 +import Qt3D.Input 2.0 +import Qt3D.Extras 2.10 +import QtQuick 2.9 +import Qt3D.Logic 2.0 + +Entity { + id: root + property DefaultCameraController cameraController + property Layer frontLayerComponent + + readonly property Camera camera : cameraController.camera + readonly property var windowSize: cameraController.windowSize + readonly property alias objectTransform : transformGizmo.objectTransform // The Transform the object should use + + signal pickedChanged(bool pressed) + + onPickedChanged: { + cameraController.loseMouseFocus = pressed // Notify the camera if the transform takes/releases the focus + } + + TransformGizmo { + id: transformGizmo + camera: root.camera + windowSize: root.windowSize + frontLayerComponent: root.frontLayerComponent + onPickedChanged: { + root.pickedChanged(pressed) + } + } +} \ No newline at end of file diff --git a/meshroom/ui/qml/Viewer3D/TransformGizmo.qml b/meshroom/ui/qml/Viewer3D/TransformGizmo.qml index 750c0ed5..27a341d0 100644 --- a/meshroom/ui/qml/Viewer3D/TransformGizmo.qml +++ b/meshroom/ui/qml/Viewer3D/TransformGizmo.qml @@ -7,14 +7,15 @@ import Qt3D.Logic 2.0 Entity { id: root - property real gizmoScale: 0.20 + property real gizmoScale: 0.15 property Camera camera property var windowSize + property var frontLayerComponent readonly property Transform objectTransform : Transform {} signal pickedChanged(bool pressed) - components: [gizmoDisplayTransform, mouseHandler] + components: [gizmoDisplayTransform, mouseHandler, frontLayerComponent] /***** ENUMS *****/ @@ -194,7 +195,7 @@ Entity { Entity { id: centerSphereEntity - components: [centerSphereMesh, centerSphereMaterial] + components: [centerSphereMesh, centerSphereMaterial, frontLayerComponent] SphereMesh { id: centerSphereMesh @@ -238,7 +239,7 @@ Entity { Entity { id: axisCylinder - components: [cylinderMesh, cylinderTransform, scaleMaterial] + components: [cylinderMesh, cylinderTransform, scaleMaterial, frontLayerComponent] CylinderMesh { id: cylinderMesh @@ -275,7 +276,7 @@ Entity { Entity { id: axisScaleBox - components: [cubeScaleMesh, cubeScaleTransform, scaleMaterial, scalePicker] + components: [cubeScaleMesh, cubeScaleTransform, scaleMaterial, scalePicker, frontLayerComponent] CuboidMesh { id: cubeScaleMesh @@ -334,7 +335,7 @@ Entity { // POSITION ENTITY Entity { id: positionEntity - components: [coneMesh, coneTransform, positionMaterial, positionPicker] + components: [coneMesh, coneTransform, positionMaterial, positionPicker, frontLayerComponent] ConeMesh { id: coneMesh @@ -394,7 +395,7 @@ Entity { // ROTATION ENTITY Entity { id: rotationEntity - components: [torusMesh, torusTransform, rotationMaterial, rotationPicker] + components: [torusMesh, torusTransform, rotationMaterial, rotationPicker, frontLayerComponent] TorusMesh { id: torusMesh diff --git a/meshroom/ui/qml/Viewer3D/Viewer3D.qml b/meshroom/ui/qml/Viewer3D/Viewer3D.qml index 8451fda7..7bbcf1cf 100644 --- a/meshroom/ui/qml/Viewer3D/Viewer3D.qml +++ b/meshroom/ui/qml/Viewer3D/Viewer3D.qml @@ -207,6 +207,17 @@ FocusScope { ] } } + LayerFilter { + filterMode: LayerFilter.DiscardAnyMatchingLayers + layers: Layer {id: drawOnFront} + } + LayerFilter { + filterMode: LayerFilter.AcceptAnyMatchingLayers + layers: [drawOnFront] + RenderStateSet { + renderStates: DepthTest { depthFunction: DepthTest.Equal } + } + } } } }