-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
75 lines (67 loc) · 2.29 KB
/
gui.py
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
# Draw a line separating independent channel groups.
def drawSplit(fig, freq):
fig.add_shape(type="rect",
x0=freq, y0=0, x1=freq, y1=1,
line=dict(
color="rgba(150,150,150,0.8)",
width=3,
dash="dash",
),
fillcolor="rgba(150,150,150,0.6)",
)
# Draw a channel.
def drawChannel(fig, channel):
fig.add_shape(type="rect",
x0=channel.freqLow, y0=0, x1=channel.freqHigh, y1=0.5,
line=dict(
color="rgba(20,100,50,0.8)",
width=2,
),
fillcolor="rgba(150,200,100,0.6)",
)
# Draw an indicator for a channel that is not passed.
def drawUncoveredChannel(fig, channel):
fig.add_shape(type="rect",
x0=channel.freqLow, y0=0.51, x1=channel.freqHigh, y1=0.54,
line=dict(
color="rgba(25,41,88,0.8)",
width=2,
),
fillcolor="rgba(135,206,250,0.6)",
)
# Draw filter.
def drawFilter(fig, filter):
fig.add_shape(type="rect",
x0=filter.freqLow, y0=0.55, x1=filter.freqHigh, y1=0.75,
line=dict(
color="rgba(25,41,88,0.8)",
width=2,
),
fillcolor="rgba(135,206,250,0.6)",
)
# Draw an indicator for a filter that overlaps with another filter.
def drawConflict(fig, filter):
fig.add_shape(type="rect",
x0=filter.freqLow, y0=0.80, x1=filter.freqHigh, y1=0.95,
line=dict(
color="rgba(70,13,13,0.8)",
width=2,
),
fillcolor="rgba(200,50,31,0.6)",
)
def renderGUI(fig, channels, filters):
plotFreqMargin = 200000 # Padding to add to sides of plot
freqRange = [min(min(channels, key=lambda channel: channel.freqCenter).freqCenter,\
min(filters, key=lambda filter: filter.freqCenter).freqCenter) - plotFreqMargin,\
max(max(channels, key=lambda channel: channel.freqCenter).freqCenter,\
max(filters, key=lambda filter: filter.freqCenter).freqCenter) + plotFreqMargin]
# Set axes properties
fig.update_xaxes(range=freqRange, showgrid=False)
fig.update_yaxes(range=[0, 1], visible=False)
for channel in channels:
drawChannel(fig, channel)
for filter in filters:
drawFilter(fig, filter)
fig.update_shapes(dict(xref='x', yref='y'))
fig.show()
return