-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainView.qml
192 lines (165 loc) · 6.42 KB
/
MainView.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtCharts 2.14
import QtQuick.Controls.Material 2.14
import QtQuick 2.14
Item {
property LineSeries theoreticalSeries: qtheoreticalSeries
property LineSeries experimentalSeries: qexperimentalSeries
property LineSeries errorSeries: qerrorSeries
id: root
function setB(b) {
inputB.text = b.toFixed(8)
}
function setC(c) {
inputC.text = c.toFixed(8)
}
function generateTheoreticalProfile() {
var b = inputB.text
var c = inputC.text
var step = inputStep.text
var type = (inputType.currentText === "Pendant" ? 0 : 1)
backend.generateTheoreticalProfile(b, c, type, step)
}
GridLayout {
anchors.fill: parent
columns: isHorizontal ? 2 : 1
Item {
clip: true
Layout.preferredWidth: (isHorizontal ? root.width - controls.width : root.width) - 16
Layout.preferredHeight: (isHorizontal ? root.height : root.height - controls.height) - 16
Layout.fillWidth: true
Layout.fillHeight: true
SwipeView {
id: view
anchors.bottom: parent.bottom
anchors.left: parent.left
width: parent.width
height: parent.height - tabBar.height
currentIndex: tabBar.currentIndex
ChartView {
id: profilesChart
theme: Material.theme === Material.Light ? ChartView.ChartThemeLight : ChartView.ChartThemeDark
antialiasing: true
LineSeries {
id: qtheoreticalSeries
color: Material.color(Material.Blue)
name: "Theoretical"
width: 2
}
LineSeries {
id: qexperimentalSeries
color: Material.color(Material.Green)
name: "Experimental"
width: 2
}
}
ChartView {
id: errorChart
theme: ChartView.ChartThemeLight
antialiasing: true
LineSeries {
id: qerrorSeries
color: Material.color(Material.Red)
name: "Error"
width: 2
}
}
}
TabBar {
id: tabBar
currentIndex: view.currentIndex
anchors.bottom: view.top
anchors.left: view.left
width: view.width
TabButton {
text: "Profiles"
}
TabButton {
text: "Error"
}
}
}
ScrollView {
Layout.minimumWidth: isHorizontal ? controls.width : 50
Layout.minimumHeight: isHorizontal ? 50 : root.height / 3
Layout.preferredWidth: isHorizontal ? Layout.minimumWidth : root.width
Layout.preferredHeight: isHorizontal ? root.height : Layout.minimumHeight
contentWidth: controls.width
contentHeight: controls.height
clip: true
Item {
id: controls
property real margin: 16
width: isHorizontal ? controlsGrid.width + 2 * margin : Math.max(root.width, controlsGrid.width + 2 * margin)
height: isHorizontal ? Math.max(root.height, controlsGrid.height + 2 * margin) : controlsGrid.height + 2 * margin
GridLayout {
id: controlsGrid
columns: 2
width: children.width
height: children.height
anchors.centerIn: parent
Label { text: "Type: " }
ComboBox {
id: inputType
model: ["Pendant", "Rotating"]
Layout.fillWidth: true
}
Label { text: "Step: " }
TextField {
id: inputStep
text: "0.1"
inputMethodHints: Qt.ImhFormattedNumbersOnly
horizontalAlignment: Qt.AlignRight
}
Label { text: "b: " }
TextField {
id: inputB
text: "1.8"
inputMethodHints: Qt.ImhFormattedNumbersOnly
horizontalAlignment: Qt.AlignRight
}
Label { text: "c: " }
TextField {
id: inputC
text: "-2.9"
inputMethodHints: Qt.ImhFormattedNumbersOnly
horizontalAlignment: Qt.AlignRight
}
Button {
text: "Generate theoretical profile"
Layout.columnSpan: 2
Layout.alignment: Qt.AlignCenter
onClicked: {
generateTheoreticalProfile()
}
}
Button {
text: "Minimize theoretical error"
Layout.columnSpan: 2
Layout.alignment: Qt.AlignCenter
onClicked: {
var step = inputStep.text
var type = (inputType.currentText === "Pendant" ? 0 : 1)
if (backend.minimizeError(type, step)) {
progressPopup.open()
} else {
errorMessagePopup.errorMessage = backend.lastError()
errorMessagePopup.open()
}
}
}
Button {
text: "Load experimental"
Layout.columnSpan: 2
Layout.alignment: Qt.AlignCenter
onClicked: {
experimentalSelectPopup.open()
}
}
}
}
}
}
}