Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpcs
dfss
Commits
9f90c21c
Commit
9f90c21c
authored
Apr 12, 2016
by
Loïck Bonniot
Browse files
Merge branch '211_demo_speed' into 'master'
211 demo speed See merge request
!49
parents
a8d781d7
c4d3b49c
Pipeline
#574
passed with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
dfssd/gui/events.go
View file @
9f90c21c
...
...
@@ -11,10 +11,6 @@ import (
"github.com/visualfc/goqt/ui"
)
// TEMPORARY
const
quantum
=
100
// discretization argument for events (ns)
const
speed
=
1000
// duration of a quantum (ms)
// AddEvent interprets an incoming event into a graphic one.
// Expected format:
//
...
...
@@ -72,9 +68,11 @@ func (w *Window) PrintQuantumInformation() {
return
}
quantum
:=
float64
(
w
.
quantumField
.
Value
())
beginning
:=
w
.
scene
.
Events
[
0
]
.
Date
.
UnixNano
()
totalDuration
:=
w
.
scene
.
Events
[
len
(
w
.
scene
.
Events
)
-
1
]
.
Date
.
UnixNano
()
-
beginning
nbQuantum
:=
math
.
Max
(
1
,
math
.
Ceil
(
float64
(
totalDuration
)
/
quantum
)
)
nbQuantum
:=
math
.
Floor
(
float64
(
totalDuration
)
/
quantum
)
+
1
durationFromBeginning
:=
w
.
scene
.
currentTime
.
UnixNano
()
-
beginning
currentQuantum
:=
math
.
Ceil
(
float64
(
durationFromBeginning
)
/
quantum
)
+
1
...
...
@@ -115,6 +113,7 @@ func (w *Window) initTimer() {
w
.
scene
.
currentTime
=
w
.
scene
.
Events
[
0
]
.
Date
}
quantum
:=
time
.
Duration
(
w
.
quantumField
.
Value
())
endOfQuantum
:=
w
.
scene
.
currentTime
.
Add
(
quantum
*
time
.
Nanosecond
)
for
i
:=
w
.
scene
.
currentEvent
;
i
<
nbEvents
;
i
++
{
...
...
dfssd/gui/structures.go
View file @
9f90c21c
...
...
@@ -20,6 +20,8 @@ type Window struct {
playButton
*
ui
.
QPushButton
stopButton
*
ui
.
QPushButton
replayButton
*
ui
.
QPushButton
quantumField
*
ui
.
QSpinBox
speedSlider
*
ui
.
QSlider
scene
*
Scene
circleSize
float64
pixmaps
map
[
string
]
*
ui
.
QPixmap
...
...
dfssd/gui/widget.ui
View file @
9f90c21c
...
...
@@ -140,10 +140,13 @@
</sizepolicy>
</property>
<property
name=
"focusPolicy"
>
<enum>
Qt::TabFocus
</enum>
<enum>
Qt::ClickFocus
</enum>
</property>
<property
name=
"correctionMode"
>
<enum>
QAbstractSpinBox::CorrectToNearestValue
</enum>
</property>
<property
name=
"suffix"
>
<string>
u
s
</string>
<string>
n
s
</string>
</property>
<property
name=
"minimum"
>
<number>
1
</number>
...
...
@@ -183,6 +186,18 @@
<property
name=
"focusPolicy"
>
<enum>
Qt::TabFocus
</enum>
</property>
<property
name=
"minimum"
>
<number>
1
</number>
</property>
<property
name=
"maximum"
>
<number>
20
</number>
</property>
<property
name=
"pageStep"
>
<number>
2
</number>
</property>
<property
name=
"value"
>
<number>
4
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
...
...
@@ -190,7 +205,7 @@
<enum>
QSlider::TicksBothSides
</enum>
</property>
<property
name=
"tickInterval"
>
<number>
5
</number>
<number>
1
</number>
</property>
</widget>
</item>
...
...
dfssd/gui/window.go
View file @
9f90c21c
...
...
@@ -38,6 +38,9 @@ func NewWindow() *Window {
w
.
stopButton
=
ui
.
NewPushButtonFromDriver
(
widget
.
FindChild
(
"stopButton"
))
w
.
replayButton
=
ui
.
NewPushButtonFromDriver
(
widget
.
FindChild
(
"replayButton"
))
w
.
quantumField
=
ui
.
NewSpinBoxFromDriver
(
widget
.
FindChild
(
"quantumField"
))
w
.
speedSlider
=
ui
.
NewSliderFromDriver
(
widget
.
FindChild
(
"speedSlider"
))
// Load pixmaps
w
.
pixmaps
=
map
[
string
]
*
ui
.
QPixmap
{
"ttp"
:
ui
.
NewPixmapWithFilenameFormatFlags
(
":/images/server_key.png"
,
""
,
ui
.
Qt_AutoColor
),
...
...
@@ -119,6 +122,7 @@ func (w *Window) addActions() {
w
.
playButton
.
OnClicked
(
func
()
{
w
.
playButton
.
SetDisabled
(
true
)
w
.
stopButton
.
SetDisabled
(
false
)
speed
:=
2000
/
w
.
speedSlider
.
Value
()
w
.
timer
.
StartWithMsec
(
speed
)
})
...
...
@@ -134,6 +138,17 @@ func (w *Window) addActions() {
w
.
scene
.
currentEvent
=
0
w
.
PrintQuantumInformation
()
})
w
.
quantumField
.
OnValueChanged
(
func
(
_
string
)
{
w
.
replayButton
.
Click
()
})
w
.
speedSlider
.
OnValueChanged
(
func
(
_
int32
)
{
if
!
w
.
playButton
.
IsEnabled
()
{
// playing right now
w
.
stopButton
.
Click
()
w
.
playButton
.
Click
()
}
})
}
// initScene creates the Qt graphic scene associated to our custom scene.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment