-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
136 lines (122 loc) · 3.28 KB
/
main.qml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import QtCharts 2.15
ApplicationWindow {
id: root
visible: true
width: 640
height: 480
signal paste()
menuBar: MenuBar {
Menu {
title: qsTr("&Edit")
Action {
text: qsTr("&Paste")
shortcut: StandardKey.Paste
onTriggered: root.paste()
}
}
}
TableView {
id: matrix
anchors.left: parent.left
anchors.leftMargin: 15
anchors.top: parent.top
anchors.topMargin: 15
height: 370
width: 320
columnSpacing: 1
rowSpacing: 1
clip: true
model: tablemodel
delegate: Rectangle {
implicitWidth: 30
implicitHeight: 15
TextInput {
text: display
onAccepted: {
tablemodel.setData(row, column, displayText)
}
}
}
}
TableView {
id: conc
y: 100
anchors.left: matrix.left
anchors.top: matrix.bottom
anchors.bottom: parent.bottom
anchors.bottomMargin: 15
height: 30
width: 320
columnSpacing: 1
rowSpacing: 1
clip: true
model: concmodel
delegate: Rectangle {
implicitWidth: 30
implicitHeight: 15
TextInput {
text: display
onAccepted: {
concmodel.setData(row, column, displayText)
}
}
}
}
function refresh() {
console.log("Refresh")
var data = backend.result()
var dim = backend.dim()
var x = backend.x()
yAxis.max = Math.max(...data)
chart.removeAllSeries()
for(var i = 0; i < dim[1]; i++) {
var series = chart.createSeries(ChartView.SeriesTypeLine, "s"+ i, xAxis, yAxis);
series.pointsVisible = true;
series.color = Qt.rgba(Math.random(),Math.random(),Math.random(),1);
series.hovered.connect(function(point, state) {
var p = chart.mapToPosition(point);
tooltip.x = p.x
tooltip.y = p.y - tooltip.height
tooltip.text = qsTr("%1 { pH: %2, c: %3 }").arg(series.name).arg(point.x).arg(point.y)
tooltip.visible = true
})
for(var j = 0; j < dim[0]; j++)
{
series.append(x[j], data[j + i * dim[0]]);
}
}
}
ChartView {
id: chart
objectName: "chart"
title: "Concentration"
anchors.left: matrix.right
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
axes: [
ValueAxis{
id: xAxis
min: 1.0
max: 14.0
},
ValueAxis{
id: yAxis
min: 0.0
max: 1.0
}]
ToolTip {
id: tooltip
contentItem: Text{
color: "#21be2b"
text: tooltip.text
}
background: Rectangle {
border.color: "#21be2b"
}
}
}
}