Browse Source

General cleanup.

Neal Wilson 12 years ago
parent
commit
d42375d587
2 changed files with 125 additions and 127 deletions
  1. 68
    70
      qml/BrewPlot/ColorPicker.qml
  2. 57
    57
      qml/BrewPlot/main.qml

+ 68
- 70
qml/BrewPlot/ColorPicker.qml View File

1
 import QtQuick 1.0
1
 import QtQuick 1.0
2
 
2
 
3
 Rectangle {
3
 Rectangle {
4
-	id: colorpicker
5
-	
6
-	color: "red"
7
-	Rectangle {
8
-		id: pickControl
9
-		
10
-		x: 40
11
-		y: 0
12
-		z: 10
13
-		width: 260
14
-		height: 50
15
-		color: "white"
16
-		border.color: "black"
17
-		border.width: 3
18
-		radius: 5
19
-		opacity: 0
20
-		
21
-		Behavior on opacity {
22
-			PropertyAnimation {
23
-				duration: 250
24
-			}
25
-		}
26
-		Repeater {
27
-			model: ListModel {
28
-			
29
-				ListElement {
30
-					theColor: "red"
31
-				}
32
-				ListElement {
33
-					theColor: "orange"
34
-				}
35
-				ListElement {
36
-					theColor: "yellow"
37
-				}
38
-				ListElement {
39
-					theColor: "green"
40
-				}
41
-				ListElement {
42
-					theColor: "blue"
43
-				}
44
-				ListElement {
45
-					theColor: "indigo"
46
-				}
47
-				ListElement {
48
-					theColor: "violet"
49
-				}
50
-			}
51
-			Rectangle {
52
-				width: 30
53
-				height: 30
54
-				x: (35*index)+10
55
-				y: 10
56
-				color: theColor
57
-				opacity: 1
58
-				MouseArea {
59
-					anchors.fill: parent
60
-					onClicked: {
61
-						pickControl.opacity = 0
62
-						colorpicker.color = parent.color
63
-					}
64
-				}
65
-			}
66
-		}
67
-	}
68
-	MouseArea {
69
-		anchors.fill: parent
70
-		onClicked: {
71
-			pickControl.opacity = 1
72
-		}
73
-	}
4
+    id: colorpicker
5
+
6
+    color: "red"
7
+    Rectangle {
8
+        id: pickControl
9
+
10
+        x: 40; y: 0; z: 10
11
+        width: 260; height: 50
12
+        color: "white"
13
+        border {color: "black"; width: 3}
14
+        radius: 5
15
+        opacity: 0
16
+
17
+        Repeater {
18
+            model: ListModel {
19
+
20
+                ListElement {
21
+                    theColor: "red"
22
+                }
23
+                ListElement {
24
+                    theColor: "orange"
25
+                }
26
+                ListElement {
27
+                    theColor: "yellow"
28
+                }
29
+                ListElement {
30
+                    theColor: "green"
31
+                }
32
+                ListElement {
33
+                    theColor: "blue"
34
+                }
35
+                ListElement {
36
+                    theColor: "indigo"
37
+                }
38
+                ListElement {
39
+                    theColor: "violet"
40
+                }
41
+            }
42
+            Rectangle {
43
+                width: 30; height: 30
44
+                x: (35*index)+10; y: 10
45
+                color: theColor
46
+                opacity: 1
47
+
48
+                MouseArea {
49
+                    anchors.fill: parent
50
+
51
+                    onClicked: {
52
+                        pickControl.opacity = 0
53
+                        colorpicker.color = parent.color
54
+                    }
55
+                }
56
+            }
57
+        }
58
+
59
+        Behavior on opacity {
60
+            PropertyAnimation {
61
+                duration: 250
62
+            }
63
+        }
64
+    }
65
+    MouseArea {
66
+        anchors.fill: parent
67
+
68
+        onClicked: {
69
+            pickControl.opacity = 1
70
+        }
71
+    }
74
 }
72
 }

+ 57
- 57
qml/BrewPlot/main.qml View File

12
 
12
 
13
     width: 720
13
     width: 720
14
     height: 680
14
     height: 680
15
-    Component.onCompleted: {
16
-        var quitItem = window.addMenuItem("File", "Quit");
17
-        quitItem.shortcut = "Ctrl+Q";
18
-        quitItem.triggered.connect(function() {
19
-                                       Qt.quit();
20
-                                   });
21
-        var clearItem = window.addMenuItem("Plotting", "Clear Data");
22
-        clearItem.triggered.connect(function() {
23
-                                        graph.clear();
24
-                                        dataViewModel.clear();
25
-                                        root.sumy = 0;
26
-                                        root.sumxsq = 0;
27
-                                        root.sumx = 0;
28
-                                        root.sumxy = 0;
29
-                                        root.n = 0;
30
-                                        graph.setFit(0, 0, 0, 0);
31
-                                    });
32
-        var showLeastSquares = window.addMenuItem("Plotting", "Least Squares Fit");
33
-        showLeastSquares.checkable = true;
34
-        showLeastSquares.triggered.connect(function() {
35
-                                               graph.setFitVisible(showLeastSquares.checked);
36
-                                               lsfrow.visible = showLeastSquares.checked;
37
-                                           });
38
-    }
15
+
39
     BrewingControlChart {
16
     BrewingControlChart {
40
         id: graph
17
         id: graph
41
 
18
 
42
-        width: 450
43
-        height: 600
44
-        anchors.right: parent.right
45
-        anchors.rightMargin: 20
46
-        anchors.top: parent.top
47
-        anchors.topMargin: 20
19
+        width: 450; height: 600
20
+        anchors {right: parent.right; rightMargin: 20; top: parent.top; topMargin: 20}
48
     }
21
     }
49
     Item {
22
     Item {
50
-        anchors.left: parent.left
51
-        anchors.leftMargin: 10
52
-        anchors.top: parent.top
53
-        anchors.topMargin: 10
23
+        anchors {left: parent.left; leftMargin: 10; top: parent.top; topMargin: 10}
24
+
54
         Column {
25
         Column {
55
             spacing: 8
26
             spacing: 8
27
+
56
             Row {
28
             Row {
57
                 spacing: 5
29
                 spacing: 5
30
+
58
                 Text {
31
                 Text {
59
                     text: "Mass of ground coffee: "
32
                     text: "Mass of ground coffee: "
60
                 }
33
                 }
69
                     }
42
                     }
70
 
43
 
71
                     Line {
44
                     Line {
72
-                        x1: -3
73
-                        x2: 33
74
-                        y1: groundMass.height
75
-                        y2: y1
45
+                        x1: -3; y1: groundMass.height
46
+                        x2: 33; y2: y1
76
                         penWidth: 1
47
                         penWidth: 1
77
                         color: "black"
48
                         color: "black"
78
                     }
49
                     }
80
             }
51
             }
81
             Row {
52
             Row {
82
                 spacing: 5
53
                 spacing: 5
54
+
83
                 Text {
55
                 Text {
84
                     text: "Mass of brewed coffee:"
56
                     text: "Mass of brewed coffee:"
85
                 }
57
                 }
94
                     }
66
                     }
95
 
67
 
96
                     Line {
68
                     Line {
97
-                        x1: -3
98
-                        x2: 33
99
-                        y1: brewedMass.height
100
-                        y2: y1
69
+                        x1: -3; y1: brewedMass.height
70
+                        x2: 33; y2: y1
101
                         penWidth: 1
71
                         penWidth: 1
102
                         color: "black"
72
                         color: "black"
103
                     }
73
                     }
105
             }
75
             }
106
             Row {
76
             Row {
107
                 spacing: 56
77
                 spacing: 56
78
+
108
                 Text {
79
                 Text {
109
                     text: "Percent TDS:"
80
                     text: "Percent TDS:"
110
                 }
81
                 }
111
                 TextInput {
82
                 TextInput {
112
                     id: ptds
83
                     id: ptds
84
+
113
                     width: 30
85
                     width: 30
114
                     validator: DoubleValidator {
86
                     validator: DoubleValidator {
115
                         bottom: 0
87
                         bottom: 0
117
                         decimals: 2
89
                         decimals: 2
118
                         notation: DoubleValidator.StandardNotation
90
                         notation: DoubleValidator.StandardNotation
119
                     }
91
                     }
92
+
120
                     Line {
93
                     Line {
121
-                        x1: -3
122
-                        x2: 33
123
-                        y1: ptds.height
124
-                        y2: y1
94
+                        x1: -3; y1: ptds.height
95
+                        x2: 33; y2: y1
125
                         penWidth: 1
96
                         penWidth: 1
126
                         color: "black"
97
                         color: "black"
127
                     }
98
                     }
129
             }
100
             }
130
             Row {
101
             Row {
131
                 spacing: 87
102
                 spacing: 87
103
+
132
                 Text {
104
                 Text {
133
                     id: colorlabel
105
                     id: colorlabel
106
+
134
                     text: "Color:"
107
                     text: "Color:"
135
                 }
108
                 }
136
                 ColorPicker {
109
                 ColorPicker {
137
                     id: colorpicker
110
                     id: colorpicker
138
-                    width: 37
139
-                    height: colorlabel.height
111
+
112
+                    width: 37; height: colorlabel.height
140
                 }
113
                 }
141
             }
114
             }
142
             Row {
115
             Row {
143
                 id: lsfrow
116
                 id: lsfrow
144
-                visible: false
145
 
117
 
118
+                visible: false
146
                 spacing: 1
119
                 spacing: 1
120
+
147
                 Text {
121
                 Text {
148
                     id: fitcolorlabel
122
                     id: fitcolorlabel
123
+
149
                     text: "Least Squares Fit Color:"
124
                     text: "Least Squares Fit Color:"
150
                 }
125
                 }
151
                 ColorPicker {
126
                 ColorPicker {
152
                     id: fitcolorpicker
127
                     id: fitcolorpicker
153
-                    width: 37
154
-                    height: colorlabel.height
128
+
129
+                    width: 37; height: colorlabel.height
130
+
155
                     onColorChanged: {
131
                     onColorChanged: {
156
                         graph.setFitColor(color)
132
                         graph.setFitColor(color)
157
                     }
133
                     }
160
             Rectangle {
136
             Rectangle {
161
                 z: 0
137
                 z: 0
162
                 anchors.horizontalCenter: parent.horizontalCenter
138
                 anchors.horizontalCenter: parent.horizontalCenter
163
-                height: buttonText.height + 20
164
-                width: buttonText.width + 40
139
+                height: buttonText.height + 20; width: buttonText.width + 40
165
                 border.color: "black"
140
                 border.color: "black"
166
                 radius: 10
141
                 radius: 10
142
+
167
                 Text {
143
                 Text {
168
                     id: buttonText
144
                     id: buttonText
169
 
145
 
170
                     text: "Plot This Brew"
146
                     text: "Plot This Brew"
171
-                    anchors.horizontalCenter: parent.horizontalCenter
172
-                    anchors.verticalCenter: parent.verticalCenter
147
+                    anchors {horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter}
173
                 }
148
                 }
174
                 MouseArea {
149
                 MouseArea {
175
                     anchors.fill: parent
150
                     anchors.fill: parent
151
+
176
                     onClicked: {
152
                     onClicked: {
177
                         var extraction = (brewedMass.text * (ptds.text / 100)) / groundMass.text
153
                         var extraction = (brewedMass.text * (ptds.text / 100)) / groundMass.text
178
                         graph.plotPoint(extraction, (ptds.text / 100), colorpicker.color)
154
                         graph.plotPoint(extraction, (ptds.text / 100), colorpicker.color)
218
                 }
194
                 }
219
                 delegate: Row {
195
                 delegate: Row {
220
                     spacing: 3
196
                     spacing: 3
197
+
221
                     Rectangle {
198
                     Rectangle {
222
-                        width: 30
223
-                        height: 30
199
+                        width: 30; height: 30
224
                         color: dataViewModel.get(index).color
200
                         color: dataViewModel.get(index).color
225
                     }
201
                     }
226
                     Column {
202
                     Column {
235
             }
211
             }
236
         }
212
         }
237
     }
213
     }
214
+    Component.onCompleted: {
215
+        var quitItem = window.addMenuItem("File", "Quit");
216
+        quitItem.shortcut = "Ctrl+Q";
217
+        quitItem.triggered.connect(function() {
218
+            Qt.quit();
219
+        });
220
+        var clearItem = window.addMenuItem("Plotting", "Clear Data");
221
+        clearItem.triggered.connect(function() {
222
+            graph.clear();
223
+            dataViewModel.clear();
224
+            root.sumy = 0;
225
+            root.sumxsq = 0;
226
+            root.sumx = 0;
227
+            root.sumxy = 0;
228
+            root.n = 0;
229
+            graph.setFit(0, 0, 0, 0);
230
+        });
231
+        var showLeastSquares = window.addMenuItem("Plotting", "Least Squares Fit");
232
+        showLeastSquares.checkable = true;
233
+        showLeastSquares.triggered.connect(function() {
234
+            graph.setFitVisible(showLeastSquares.checked);
235
+            lsfrow.visible = showLeastSquares.checked;
236
+        });
237
+    }
238
 }
238
 }

Loading…
Cancel
Save