blob: 9a3fc0c195f247b607b1da91988cda1873c7e71c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick3D
import RobotArm
Item {
id: root
property real size: 100
property bool isFocused: true
property View3D view3D: parent
property vector3d scenePosition
property vector3d screenPosition
property alias label: label.text
x: screenPosition.x
y: screenPosition.y
visible: x > 0 && y > 0
Label {
id: label
enabled: root.isFocused
anchors.bottom: rect.top
anchors.horizontalCenter: rect.horizontalCenter
}
Rectangle {
id: rect
width: root.size
height: root.size
color: "Transparent"
radius: width / 2
border.width: 2
border.color: root.isFocused ? Material.accentColor : Material.secondaryTextColor
anchors.horizontalCenter: parent.left
anchors.verticalCenter: parent.top
}
Component.onCompleted: {
screenPosition = Qt.binding(function() {
let w = view3D.width // force the binding to update when width or height changes
let h = view3D.height
return view3D.mapFrom3DScene(scenePosition)
} )
}
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/
|