author | sl |
Mon, 02 Jun 2014 18:52:31 +0200 | |
changeset 27 | 3d3f781bf543 |
parent 25 | aec049087578 |
child 28 | 8297924aa384 |
permissions | -rw-r--r-- |
sl@0 | 1 |
import QtQuick 2.2 |
sl@0 | 2 |
import QtQuick.Controls 1.2 |
sl@15 | 3 |
import QtQuick.Window 2.1 |
sl@15 | 4 |
import MiniDisplay 1.0 |
sl@15 | 5 |
import QtQuick.Layouts 1.1 |
sl@15 | 6 |
|
sl@0 | 7 |
|
sl@0 | 8 |
Item { |
sl@17 | 9 |
id: testTab |
sl@15 | 10 |
//width: 100 |
sl@15 | 11 |
//height: 62 |
sl@0 | 12 |
//SystemPalette { id: palette } |
sl@0 | 13 |
clip: true |
sl@15 | 14 |
//anchors.fill:parent |
sl@0 | 15 |
|
sl@15 | 16 |
|
sl@18 | 17 |
//This window is our VFD frame |
sl@15 | 18 |
Window { |
sl@24 | 19 |
id: frameWindow |
sl@15 | 20 |
color: "transparent" |
sl@24 | 21 |
title: "VFD Window" |
sl@15 | 22 |
modality: Qt.NonModal |
sl@24 | 23 |
//Splash screen type do not have any border which is what we want |
sl@15 | 24 |
flags: Qt.SplashScreen |
sl@21 | 25 |
//24 FPS |
sl@21 | 26 |
//property int timeoutInterval: 41 |
sl@21 | 27 |
//32 FPS |
sl@21 | 28 |
property int timeoutInterval: 33 |
sl@15 | 29 |
signal timeout |
sl@15 | 30 |
//! [splash-properties] |
sl@15 | 31 |
//! [screen-properties] |
sl@24 | 32 |
//Here comes some trick to keep our display frame within our app. |
sl@24 | 33 |
//This make sure this window follows our app window. |
sl@17 | 34 |
x: appWindow.x+appWindow.width-256-13 |
sl@17 | 35 |
y: appWindow.y+appWindow.height-64-30 |
sl@17 | 36 |
|
sl@15 | 37 |
//! [screen-properties] |
sl@15 | 38 |
width: rectangleScreen.width |
sl@15 | 39 |
height: rectangleScreen.height |
sl@15 | 40 |
property int frameCounter:0; |
sl@15 | 41 |
property var startTime:new Date(); |
sl@15 | 42 |
|
sl@15 | 43 |
Rectangle { |
sl@15 | 44 |
id: rectangleScreen |
sl@15 | 45 |
anchors.centerIn: parent |
sl@15 | 46 |
width: 256 |
sl@15 | 47 |
height: 64 |
sl@15 | 48 |
color: "white" |
sl@15 | 49 |
border.width:1 |
sl@15 | 50 |
border.color: "black" |
sl@15 | 51 |
smooth: false |
sl@15 | 52 |
} |
sl@15 | 53 |
|
sl@16 | 54 |
GridLayout { |
sl@15 | 55 |
anchors.fill:parent |
sl@15 | 56 |
anchors.margins: 6 |
sl@16 | 57 |
//spacing: 4 |
sl@16 | 58 |
columns: 4 |
sl@16 | 59 |
|
sl@16 | 60 |
Label { |
sl@16 | 61 |
text: "Frames:" |
sl@16 | 62 |
antialiasing: false |
sl@16 | 63 |
} |
sl@16 | 64 |
|
sl@16 | 65 |
Label { |
sl@16 | 66 |
text: "Time (s):" |
sl@16 | 67 |
antialiasing: false |
sl@16 | 68 |
} |
sl@16 | 69 |
|
sl@16 | 70 |
Label { |
sl@16 | 71 |
text: "Time/Frame (ms):" |
sl@16 | 72 |
antialiasing: false |
sl@16 | 73 |
} |
sl@16 | 74 |
|
sl@16 | 75 |
Label { |
sl@16 | 76 |
text: "FPS:" |
sl@16 | 77 |
antialiasing: false |
sl@16 | 78 |
} |
sl@15 | 79 |
|
sl@15 | 80 |
Label { |
sl@15 | 81 |
id: labelFrameCount |
sl@15 | 82 |
text: "Frame Count" |
sl@15 | 83 |
antialiasing: false |
sl@15 | 84 |
} |
sl@15 | 85 |
|
sl@15 | 86 |
Label { |
sl@15 | 87 |
id: labelTime |
sl@15 | 88 |
text: "Time" |
sl@15 | 89 |
antialiasing: false |
sl@15 | 90 |
} |
sl@15 | 91 |
|
sl@16 | 92 |
Label { |
sl@16 | 93 |
id: labelTimePerFrame |
sl@16 | 94 |
text: "Time/Frame" |
sl@16 | 95 |
antialiasing: false |
sl@16 | 96 |
} |
sl@16 | 97 |
|
sl@16 | 98 |
Label { |
sl@16 | 99 |
id: labelFps |
sl@16 | 100 |
text: "FPS" |
sl@16 | 101 |
antialiasing: false |
sl@16 | 102 |
} |
sl@16 | 103 |
|
sl@15 | 104 |
} |
sl@15 | 105 |
|
sl@15 | 106 |
|
sl@15 | 107 |
|
sl@15 | 108 |
|
sl@15 | 109 |
|
sl@15 | 110 |
//! [timer] |
sl@15 | 111 |
Timer { |
sl@16 | 112 |
id: timer |
sl@24 | 113 |
interval: frameWindow.timeoutInterval; running: true; repeat: true |
sl@22 | 114 |
property bool doFill: true |
sl@15 | 115 |
onTriggered: { |
sl@15 | 116 |
//visible = false |
sl@15 | 117 |
|
sl@15 | 118 |
var current = new Date(); |
sl@24 | 119 |
var milliseconds = (current.getTime() - frameWindow.startTime.getTime()); |
sl@15 | 120 |
|
sl@24 | 121 |
frameWindow.frameCounter++; |
sl@24 | 122 |
labelFrameCount.text=frameWindow.frameCounter; |
sl@16 | 123 |
labelTime.text=milliseconds/1000; |
sl@24 | 124 |
labelTimePerFrame.text=(milliseconds/frameWindow.frameCounter).toFixed(3); |
sl@24 | 125 |
labelFps.text=(1000/(milliseconds/frameWindow.frameCounter)).toFixed(0); |
sl@16 | 126 |
|
sl@16 | 127 |
if (checkBoxDoClear.checked) |
sl@16 | 128 |
{ |
sl@16 | 129 |
display.clear(); |
sl@16 | 130 |
} |
sl@16 | 131 |
|
sl@16 | 132 |
if (checkBoxRenderToDisplay.checked) |
sl@16 | 133 |
{ |
sl@23 | 134 |
if (checkBoxFillAndClearOnly.checked) |
sl@16 | 135 |
{ |
sl@22 | 136 |
//Trying to make it a worse case scenario for our frame diff algo |
sl@22 | 137 |
if (doFill) |
sl@22 | 138 |
{ |
sl@22 | 139 |
display.fill(); |
sl@22 | 140 |
} |
sl@22 | 141 |
else |
sl@22 | 142 |
{ |
sl@22 | 143 |
display.clear(); |
sl@22 | 144 |
} |
sl@22 | 145 |
|
sl@24 | 146 |
if (frameWindow.frameCounter%2) |
sl@22 | 147 |
{ |
sl@22 | 148 |
doFill=!doFill; |
sl@22 | 149 |
} |
sl@16 | 150 |
} |
sl@16 | 151 |
else if (checkBoxOnePixelOnly.checked) |
sl@16 | 152 |
{ |
sl@24 | 153 |
display.setPixel(0,0,frameWindow.frameCounter%2); |
sl@16 | 154 |
} |
sl@16 | 155 |
else |
sl@16 | 156 |
{ |
sl@24 | 157 |
display.renderWindow(frameWindow); |
sl@16 | 158 |
} |
sl@16 | 159 |
|
sl@16 | 160 |
if (!checkBoxNoSwapBuffers.checked) |
sl@16 | 161 |
{ |
sl@16 | 162 |
display.swapBuffers(); |
sl@16 | 163 |
} |
sl@16 | 164 |
|
sl@16 | 165 |
} |
sl@16 | 166 |
|
sl@24 | 167 |
//Signal our timeout |
sl@24 | 168 |
frameWindow.timeout(); |
sl@15 | 169 |
} |
sl@15 | 170 |
} |
sl@15 | 171 |
//! [timer] |
sl@15 | 172 |
Component.onCompleted: { |
sl@15 | 173 |
visible = true |
sl@15 | 174 |
} |
sl@15 | 175 |
|
sl@15 | 176 |
} |
sl@15 | 177 |
|
sl@15 | 178 |
Column { |
sl@15 | 179 |
anchors.fill: parent |
sl@15 | 180 |
anchors.margins: 8 |
sl@15 | 181 |
spacing: 8 |
sl@15 | 182 |
|
sl@15 | 183 |
Button { |
sl@15 | 184 |
text: qsTr("Render Window") |
sl@15 | 185 |
onClicked: { |
sl@24 | 186 |
display.renderWindow(frameWindow); |
sl@15 | 187 |
display.swapBuffers(); |
sl@15 | 188 |
} |
sl@15 | 189 |
} |
sl@16 | 190 |
|
sl@16 | 191 |
Button { |
sl@16 | 192 |
text: qsTr("Reset stats") |
sl@16 | 193 |
onClicked: { |
sl@24 | 194 |
frameWindow.startTime = new Date(); |
sl@24 | 195 |
frameWindow.frameCounter = 0; |
sl@16 | 196 |
} |
sl@16 | 197 |
} |
sl@16 | 198 |
|
sl@16 | 199 |
CheckBox { |
sl@16 | 200 |
text: qsTr("Run timer") |
sl@16 | 201 |
checked: true |
sl@16 | 202 |
onCheckedChanged: { |
sl@16 | 203 |
(checked?timer.start():timer.stop()) |
sl@16 | 204 |
} |
sl@16 | 205 |
} |
sl@16 | 206 |
|
sl@16 | 207 |
CheckBox { |
sl@16 | 208 |
id: checkBoxDoClear |
sl@16 | 209 |
text: qsTr("Do clear") |
sl@16 | 210 |
checked: true |
sl@16 | 211 |
} |
sl@16 | 212 |
|
sl@16 | 213 |
CheckBox { |
sl@16 | 214 |
id: checkBoxRenderToDisplay |
sl@16 | 215 |
text: qsTr("Render to display") |
sl@16 | 216 |
checked: true |
sl@16 | 217 |
} |
sl@16 | 218 |
|
sl@16 | 219 |
CheckBox { |
sl@23 | 220 |
id: checkBoxFillAndClearOnly |
sl@21 | 221 |
text: qsTr("Only fill and clear") |
sl@16 | 222 |
checked: false |
sl@16 | 223 |
} |
sl@16 | 224 |
|
sl@16 | 225 |
CheckBox { |
sl@16 | 226 |
id: checkBoxNoSwapBuffers |
sl@16 | 227 |
text: qsTr("No swap buffers") |
sl@16 | 228 |
checked: false |
sl@16 | 229 |
} |
sl@16 | 230 |
|
sl@16 | 231 |
CheckBox { |
sl@16 | 232 |
id: checkBoxOnePixelOnly |
sl@16 | 233 |
text: qsTr("One pixel only") |
sl@16 | 234 |
checked: false |
sl@16 | 235 |
} |
sl@18 | 236 |
|
sl@18 | 237 |
CheckBox { |
sl@18 | 238 |
text: qsTr("Off-Screen") |
sl@18 | 239 |
checked: true |
sl@18 | 240 |
onCheckedChanged: {display.offScreenMode = checked;} |
sl@18 | 241 |
} |
sl@23 | 242 |
|
sl@23 | 243 |
CheckBox { |
sl@23 | 244 |
text: qsTr("Frame differencing") |
sl@23 | 245 |
checked: true |
sl@23 | 246 |
onCheckedChanged: {display.frameDifferencing = checked;} |
sl@23 | 247 |
} |
sl@23 | 248 |
|
sl@25 | 249 |
// |
sl@25 | 250 |
Rectangle { |
sl@26 | 251 |
border.width: 2 |
sl@26 | 252 |
border.color: "black" |
sl@26 | 253 |
color: "lightsteelblue" |
sl@26 | 254 |
anchors.horizontalCenter: parent.horizontalCenter |
sl@26 | 255 |
width: 250 |
sl@26 | 256 |
height: text.height + 10 |
sl@26 | 257 |
y:100 |
sl@26 | 258 |
MarqueeText { |
sl@26 | 259 |
id:text |
sl@26 | 260 |
width: 200 |
sl@26 | 261 |
pixelsPerSeconds:50 |
sl@26 | 262 |
anchors.verticalCenter: parent.verticalCenter |
sl@25 | 263 |
anchors.horizontalCenter: parent.horizontalCenter |
sl@26 | 264 |
text: "start ------ abcdefghijklmnopqrtaksdjfkdfjklsdjflksdjfklsjadfkljsad;flasjdlfjasdfjldsdfljf---- end" |
sl@26 | 265 |
//text: "start ------ end" |
sl@26 | 266 |
separator: " | " |
sl@25 | 267 |
} |
sl@26 | 268 |
} |
sl@25 | 269 |
|
sl@15 | 270 |
} |
sl@0 | 271 |
} |