浏览代码

Point list returns.

Neal Wilson 11 年前
父节点
当前提交
f35d2f00d2
共有 1 个文件被更改,包括 61 次插入21 次删除
  1. 61
    21
      qml/BrewPlot/main.qml

+ 61
- 21
qml/BrewPlot/main.qml 查看文件

@@ -19,33 +19,43 @@ Rectangle {
19 19
         width: 450; height: 600
20 20
         anchors {right: parent.right; rightMargin: 20; top: parent.top; topMargin: 20}
21 21
     }
22
-    ListView {
23
-        spacing: 3
24
-        height: 400
25
-        width: 100
26
-        z: -1
27
-        contentHeight: dataViewModel.count * 35
22
+    Item {
23
+        anchors {left: parent.left; leftMargin: 10; top: parent.top; topMargin: 10}
28 24
 
29
-        model: ListModel {
30
-            id: dataViewModel
31
-        }
32
-        delegate: Row {
33
-            spacing: 3
25
+        Column {
26
+            spacing: 8
34 27
 
35
-            Rectangle {
36
-                width: 30; height: 30
37
-                color: dataViewModel.get(index).color
38
-            }
39
-            Column {
40
-                Text {
41
-                    text: "Strength: " + dataViewModel.get(index).ptds + "% TDS"
28
+            ListView {
29
+                spacing: 3
30
+                height: 400
31
+                width: 100
32
+                z: -1
33
+                contentHeight: dataViewModel.count * 35
34
+
35
+                model: ListModel {
36
+                    id: dataViewModel
42 37
                 }
43
-                Text {
44
-                    text: "Extraction: " + Number(dataViewModel.get(index).extraction * 100).toFixed(2) + "%"
38
+                delegate: Row {
39
+                    spacing: 3
40
+
41
+                    Rectangle {
42
+                        width: 30; height: 30
43
+                        color: dataViewModel.get(index).color
44
+                    }
45
+                    Column {
46
+                        Text {
47
+                            text: "Strength: " + dataViewModel.get(index).ptds + "% TDS"
48
+                        }
49
+                        Text {
50
+                            text: "Extraction: " + Number(dataViewModel.get(index).extraction * 100).toFixed(2) + "%"
51
+                        }
52
+                    }
45 53
                 }
46 54
             }
47 55
         }
48 56
     }
57
+
58
+
49 59
     Component.onCompleted: {
50 60
         var quitItem = window.addMenuItem("File", "Quit");
51 61
         quitItem.shortcut = "Ctrl+Q";
@@ -73,7 +83,37 @@ Rectangle {
73 83
             graph.plotPoint(pointDescription.extraction,
74 84
                             pointDescription.ptds / 100,
75 85
                             pointDescription.color)
76
-            dataviewModel.append(pointDescription)
86
+            dataViewModel.append(pointDescription)
87
+            root.n += 1
88
+            root.sumy += pointDescription.ptds / 100
89
+            root.sumx += pointDescription.extraction
90
+            root.sumxy += ((pointDescription.ptds / 100) * extraction)
91
+            root.sumxsq += Math.pow(extraction, 2)
92
+            if(root.n > 1) {
93
+                var a = ((root.sumy * root.sumxsq)-(root.sumx * root.sumxy))/((root.n * root.sumxsq)-Math.pow(root.sumx, 2))
94
+                var b = ((root.n * root.sumxy)-(root.sumx * root.sumy))/((root.n * root.sumxsq) - Math.pow(root.sumx, 2))
95
+                var x1 = 0.14
96
+                var x2 = 0.26
97
+                var y1 = a + (b * x1)
98
+                var y2 = a + (b * x2)
99
+                if(y1 < 0.008) {
100
+                    x1 = (0.008 - a) / b
101
+                    y1 = 0.008
102
+                }
103
+                if(y2 < 0.008) {
104
+                    x2 = (0.008 - a) / b
105
+                    y2 = 0.008
106
+                }
107
+                if(y1 > 0.016) {
108
+                    x1 = (0.016 - a) / b
109
+                    y2 = 0.016
110
+                }
111
+                if(y2 > 0.016) {
112
+                    x2 = (0.016 - a) / b
113
+                    y2 = 0.016
114
+                }
115
+                graph.setFit(x1, y1, x2, y2)
116
+            }
77 117
         });
78 118
     }
79 119
 }

正在加载...
取消
保存