3D view now shows lights and added double spinbox
This commit is contained in:
@ -3,63 +3,13 @@ import QtDataVisualization
|
||||
import QtQuick.Controls
|
||||
|
||||
Item {
|
||||
|
||||
property int selectedAxisLabel: -1
|
||||
property real dragSpeedModifier: 100.0
|
||||
property real dragSpeedModifier: 25.0
|
||||
property int currentMouseX: -1
|
||||
property int currentMouseY: -1
|
||||
property int previousMouseX: -1
|
||||
property int previousMouseY: -1
|
||||
|
||||
ListModel {
|
||||
id: graphModel
|
||||
ListElement{ xPos: 0.0; yPos: 0.0; zPos: 0.0; rotation: "@0,0,0,0" }
|
||||
ListElement{ xPos: 1.0; yPos: 1.0; zPos: 1.0; rotation: "@45,1,1,1" }
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: dataTimer
|
||||
interval: 1
|
||||
running: true
|
||||
repeat: true
|
||||
property bool isIncreasing: true
|
||||
property real rotationAngle: 0
|
||||
|
||||
function generateQuaternion() {
|
||||
return "@" + Math.random() * 360 + "," + Math.random() + ","
|
||||
+ Math.random() + "," + Math.random()
|
||||
}
|
||||
|
||||
function appendRow() {
|
||||
graphModel.append({"xPos": Math.random(),
|
||||
"yPos": Math.random(),
|
||||
"zPos": Math.random(),
|
||||
"rotation": generateQuaternion()
|
||||
});
|
||||
}
|
||||
|
||||
//! [10]
|
||||
onTriggered: {
|
||||
rotationAngle = rotationAngle + 1
|
||||
qtCube.setRotationAxisAndAngle(Qt.vector3d(1,0,1), rotationAngle)
|
||||
//! [10]
|
||||
scatterSeries.setMeshAxisAndAngle(Qt.vector3d(1,1,1), rotationAngle)
|
||||
if (isIncreasing) {
|
||||
for (var i = 0; i < 10; i++)
|
||||
appendRow()
|
||||
if (graphModel.count > 2002) {
|
||||
scatterGraph.theme = isabelleTheme
|
||||
isIncreasing = false
|
||||
}
|
||||
} else {
|
||||
graphModel.remove(2, 10);
|
||||
if (graphModel.count == 2) {
|
||||
scatterGraph.theme = dynamicColorTheme
|
||||
isIncreasing = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
property alias model: itemModelScatterDataProxy.itemModel
|
||||
|
||||
ThemeColor {
|
||||
id: dynamicColor
|
||||
@ -108,6 +58,12 @@ Item {
|
||||
scene.activeCamera.yRotation: 45.0
|
||||
scene.activeCamera.xRotation: 45.0
|
||||
scene.activeCamera.zoomLevel: 75.0
|
||||
axisX.min: -10
|
||||
axisX.max: 10
|
||||
axisY.min: -10
|
||||
axisY.max: 10
|
||||
axisZ.min: -10
|
||||
axisZ.max: 10
|
||||
|
||||
Scatter3DSeries {
|
||||
id: scatterSeries
|
||||
@ -115,25 +71,13 @@ Item {
|
||||
mesh: Abstract3DSeries.MeshCube
|
||||
|
||||
ItemModelScatterDataProxy {
|
||||
itemModel: graphModel
|
||||
xPosRole: "xPos"
|
||||
yPosRole: "yPos"
|
||||
zPosRole: "zPos"
|
||||
rotationRole: "rotation"
|
||||
id: itemModelScatterDataProxy
|
||||
xPosRole: "positionX"
|
||||
yPosRole: "positionY"
|
||||
zPosRole: "positionZ"
|
||||
//rotationRole: "rotation"
|
||||
}
|
||||
}
|
||||
//! [9]
|
||||
customItemList: [
|
||||
Custom3DItem {
|
||||
id: qtCube
|
||||
meshFile: ":/scheincommander/models/cube.obj"
|
||||
textureFile: ":/scheincommander/textures/cubetexture.png"
|
||||
position: Qt.vector3d(0.65,0.35,0.65)
|
||||
scaling: Qt.vector3d(0.3,0.3,0.3)
|
||||
}
|
||||
]
|
||||
//! [9]
|
||||
//! [5]
|
||||
onSelectedElementChanged: {
|
||||
if (selectedElement >= AbstractGraph3D.ElementAxisXLabel
|
||||
&& selectedElement <= AbstractGraph3D.ElementAxisZLabel)
|
||||
@ -141,36 +85,27 @@ Item {
|
||||
else
|
||||
selectedAxisLabel = -1
|
||||
}
|
||||
//! [5]
|
||||
}
|
||||
|
||||
//! [1]
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton
|
||||
//! [1]
|
||||
|
||||
//! [3]
|
||||
onPositionChanged: (mouse)=> {
|
||||
currentMouseX = mouse.x;
|
||||
currentMouseY = mouse.y;
|
||||
//! [3]
|
||||
//! [6]
|
||||
|
||||
if (pressed && selectedAxisLabel != -1)
|
||||
dragAxis();
|
||||
//! [6]
|
||||
//! [4]
|
||||
|
||||
previousMouseX = currentMouseX;
|
||||
previousMouseY = currentMouseY;
|
||||
}
|
||||
//! [4]
|
||||
|
||||
//! [2]
|
||||
onPressed: (mouse)=> {
|
||||
scatterGraph.scene.selectionQueryPosition = Qt.point(mouse.x, mouse.y);
|
||||
}
|
||||
//! [2]
|
||||
|
||||
onReleased: {
|
||||
// We need to clear mouse positions and selected axis, because touch devices cannot
|
||||
@ -184,7 +119,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
//! [7]
|
||||
function dragAxis() {
|
||||
// Do nothing if previous mouse position is uninitialized
|
||||
if (previousMouseX === -1)
|
||||
@ -235,11 +169,10 @@ Item {
|
||||
break
|
||||
}
|
||||
}
|
||||
//! [7]
|
||||
|
||||
Button {
|
||||
id: rangeToggle
|
||||
width: parent.width / 3 // We're adding 3 buttons and want to divide them equally
|
||||
width: parent.width / 2 // We're adding 3 buttons and want to divide them equally
|
||||
text: "Use Preset Range"
|
||||
anchors.left: parent.left
|
||||
property bool autoRange: true
|
||||
@ -265,10 +198,9 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
//! [8]
|
||||
Button {
|
||||
id: orthoToggle
|
||||
width: parent.width / 3
|
||||
width: parent.width / 2
|
||||
text: "Display Orthographic"
|
||||
anchors.left: rangeToggle.right
|
||||
onClicked: {
|
||||
@ -283,13 +215,4 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
//! [8]
|
||||
|
||||
Button {
|
||||
id: exitButton
|
||||
width: parent.width / 3
|
||||
text: "Quit"
|
||||
anchors.left: orthoToggle.right
|
||||
onClicked: Qt.quit();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user