Skip to content

Commit 4ef1ff4

Browse files
authored
Merge pull request #392 from alicevision/fix_locator3d
Viewer3D: use DepthMapEntity 2.0 + various fixes
2 parents 66fbcf5 + da1b842 commit 4ef1ff4

File tree

6 files changed

+31
-14
lines changed

6 files changed

+31
-14
lines changed

meshroom/ui/qml/Viewer3D/DefaultCameraController.qml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Entity {
1414
property real translateSpeed: 75.0
1515
property real tiltSpeed: 500.0
1616
property real panSpeed: 500.0
17-
property bool moving: pressed || (actionAlt.active && keyboardHandler._pressed)
17+
readonly property bool moving: actionLMB.active
18+
readonly property bool panning: (keyboardHandler._pressed && actionLMB.active && actionShift.active) || actionMMB.active
19+
readonly property bool zooming: keyboardHandler._pressed && actionRMB.active && actionAlt.active
1820
property alias focus: keyboardHandler.focus
1921
readonly property bool pickingActive: actionControl.active && keyboardHandler._pressed
2022
property alias rotationSpeed: trackball.rotationSpeed
@@ -44,15 +46,16 @@ Entity {
4446
sourceDevice: mouseSourceDevice
4547
onPressed: {
4648
_pressed = true;
47-
currentPosition = lastPosition = Qt.point(mouse.x, mouse.y);
49+
currentPosition.x = lastPosition.x = mouse.x;
50+
currentPosition.y = lastPosition.y = mouse.y;
4851
mousePressed(mouse);
4952
}
5053
onReleased: {
5154
_pressed = false;
5255
mouseReleased(mouse);
5356
}
5457
onClicked: mouseClicked(mouse)
55-
onPositionChanged: { currentPosition = Qt.point(mouse.x, mouse.y) }
58+
onPositionChanged: { currentPosition.x = mouse.x; currentPosition.y = mouse.y }
5659
onDoubleClicked: mouseDoubleClicked(mouse)
5760
onWheel: {
5861
var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.2;
@@ -158,19 +161,19 @@ Entity {
158161
components: [
159162
FrameAction {
160163
onTriggered: {
161-
if(actionMMB.active || (actionLMB.active && actionShift.active)) { // translate
164+
if(panning) { // translate
162165
var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.03;
163166
var tx = axisMX.value * root.translateSpeed * d;
164167
var ty = axisMY.value * root.translateSpeed * d;
165168
root.camera.translate(Qt.vector3d(-tx, -ty, 0).times(dt))
166169
return;
167170
}
168-
if(actionLMB.active){ // trackball rotation
171+
if(moving){ // trackball rotation
169172
trackball.rotate(mouseHandler.lastPosition, mouseHandler.currentPosition, dt);
170173
mouseHandler.lastPosition = mouseHandler.currentPosition;
171174
return;
172175
}
173-
if(actionAlt.active && actionRMB.active) { // zoom with alt + RMD
176+
if(zooming) { // zoom with alt + RMD
174177
var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.1;
175178
var tz = axisMX.value * root.translateSpeed * d;
176179
root.camera.translate(Qt.vector3d(0, 0, tz).times(dt), Camera.DontTranslateViewCenter)
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import DepthMapEntity 1.0
1+
import DepthMapEntity 2.0
22

33
/**
44
* Support for Depth Map files (EXR) in Qt3d.
55
* Create this component dynamically to test for DepthMapEntity plugin availability.
66
*/
77
DepthMapEntity {
88
id: root
9+
10+
pointSize: Viewer3DSettings.pointSize * (Viewer3DSettings.fixedPointSize ? 1.0 : 0.001)
11+
// map render modes to custom visualization modes
12+
displayMode: Viewer3DSettings.renderMode == 1 ? DepthMapEntity.Points : DepthMapEntity.Triangles
13+
displayColor: Viewer3DSettings.renderMode == 2
914
}

meshroom/ui/qml/Viewer3D/Inspector3D.qml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ FloatingPane {
4040
columnSpacing: 6
4141
rowSpacing: 3
4242

43-
Label { text: "Points"; padding: 2 }
43+
MaterialLabel { font.family: MaterialIcons.fontFamily; text: MaterialIcons.grain; padding: 2 }
4444
RowLayout {
4545
Slider {
46-
Layout.fillWidth: true; from: 0; to: 10; stepSize: 0.1
46+
Layout.fillWidth: true; from: 0; to: 5; stepSize: 0.1
4747
value: Viewer3DSettings.pointSize
4848
onValueChanged: Viewer3DSettings.pointSize = value
49+
ToolTip.text: "Point Size: " + value.toFixed(2)
50+
ToolTip.visible: hovered || pressed
51+
ToolTip.delay: 150
4952
}
5053
MaterialToolButton {
5154
text: MaterialIcons.center_focus_strong
@@ -57,7 +60,7 @@ FloatingPane {
5760
}
5861

5962
}
60-
Label { text: "Cameras"; padding: 2 }
63+
MaterialLabel { font.family: MaterialIcons.fontFamily; text: MaterialIcons.videocam; padding: 2 }
6164
Slider {
6265
value: Viewer3DSettings.cameraScale
6366
from: 0
@@ -66,6 +69,9 @@ FloatingPane {
6669
Layout.fillWidth: true
6770
padding: 0
6871
onMoved: Viewer3DSettings.cameraScale = value
72+
ToolTip.text: "Camera Scale: " + value.toFixed(2)
73+
ToolTip.visible: hovered || pressed
74+
ToolTip.delay: 150
6975
}
7076
Flow {
7177
Layout.columnSpan: 2

meshroom/ui/qml/Viewer3D/Locator3D.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Entity {
2020
name: defaultPositionAttributeName
2121
buffer: Buffer {
2222
type: Buffer.VertexBuffer
23-
data: Float32Array([
23+
data: new Float32Array([
2424
0.0, 0.001, 0.0,
2525
1.0, 0.001, 0.0,
2626
0.0, 0.001, 0.0,
@@ -38,7 +38,7 @@ Entity {
3838
name: defaultColorAttributeName
3939
buffer: Buffer {
4040
type: Buffer.VertexBuffer
41-
data: Float32Array([
41+
data: new Float32Array([
4242
Colors.red.r, Colors.red.g, Colors.red.b,
4343
Colors.red.r, Colors.red.g, Colors.red.b,
4444
Colors.green.r, Colors.green.g, Colors.green.b,

meshroom/ui/qml/Viewer3D/MediaLibrary.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Entity {
3030

3131
QtObject {
3232
id: m
33-
property ListModel mediaModel: ListModel {}
33+
property ListModel mediaModel: ListModel { dynamicRoles: true }
3434
property var sourceToEntity: ({})
3535

3636
readonly property var mediaElement: ({

meshroom/ui/qml/Viewer3D/Viewer3D.qml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ FocusScope {
130130

131131
DefaultCameraController {
132132
id: cameraController
133-
windowSize: Qt.size(root.width, root.height)
133+
windowSize {
134+
width: root.width
135+
height: root.height
136+
}
134137
rotationSpeed: 10
135138
trackballSize: 0.4
136139

0 commit comments

Comments
 (0)