aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/NotoSerifCJKjp-Medium.otfbin23900156 -> 0 bytes
-rw-r--r--src/gui/dpg.ini15
-rwxr-xr-xsrc/gui/gui.py328
-rwxr-xr-xsrc/gui/gui_v2.py336
-rw-r--r--src/gui/lena512color.pngbin786572 -> 474775 bytes
-rw-r--r--src/gui/logo.pngbin9317 -> 0 bytes
-rw-r--r--src/gui/net.py64
-rw-r--r--src/gui/test.py40
-rw-r--r--src/gui/test2.py22
9 files changed, 230 insertions, 575 deletions
diff --git a/src/gui/NotoSerifCJKjp-Medium.otf b/src/gui/NotoSerifCJKjp-Medium.otf
deleted file mode 100644
index 1a37d19..0000000
--- a/src/gui/NotoSerifCJKjp-Medium.otf
+++ /dev/null
Binary files differ
diff --git a/src/gui/dpg.ini b/src/gui/dpg.ini
deleted file mode 100644
index 8fd9e9b..0000000
--- a/src/gui/dpg.ini
+++ /dev/null
@@ -1,15 +0,0 @@
-[Window][Debug##Default]
-Pos=60,60
-Size=400,400
-Collapsed=0
-
-[Window][###21]
-Pos=60,60
-Size=129,100
-Collapsed=0
-
-[Window][###23]
-Pos=258,161
-Size=100,100
-Collapsed=0
-
diff --git a/src/gui/gui.py b/src/gui/gui.py
index 3f5b986..d3ada9c 100755
--- a/src/gui/gui.py
+++ b/src/gui/gui.py
@@ -30,21 +30,38 @@ logger = logging.getLogger(__name__)
#================================================
# Initialize DearPyGUI
-
-
create_context()
-create_viewport(title="Fading Demonstrator")
+create_viewport(title="Fading Demonstrator",width=1920, height=1200)
setup_dearpygui()
-
# Show demo for dev
show_demo()
-show_documentation()
+show_debug()
+
+#================================================
+# Set up theme and looks
+
+# Font
+# with font_registry():
+# # first argument ids the path to the .ttf or .otf file
+# default_font = add_font("NotoSerifCJKjp-Medium.otf", 20)
+# second_font = add_font("NotoSerifCJKjp-Medium.otf", 10)
+# test = add_font("NotoSerifCJKjp-Medium.otf", 30)
+
+# Constellation diagrams
+with theme(tag="constellation_series_theme"):
+ with theme_component(mvScatterSeries):
+ # add_theme_style(mvPlotStyleVar_Marker, mvPlotMarker_Asterisk, category=mvThemeCat_Plots)
+ add_theme_style(mvPlotStyleVar_MarkerSize, 3, category=mvThemeCat_Plots)
#================================================
# GUI Callback functions
+# Menu Bar
+def exit(sender, data):
+ stop_dearpygui()
+
# Flow graph window
def on_rx_node_link(sender, app_data):
link_id_1, link_id_2 = app_data
@@ -52,193 +69,202 @@ def on_rx_node_link(sender, app_data):
def on_rx_node_delink(sender, app_data):
link_id = app_data
- delete_item(link_id)
+ # do nothing
+ # delete_item(link_id)
-#================================================
-#Setting Window Test
-# with window(label="Dear", width=800, height=800, on_close=_on_demo_close, pos=(100, 100)):
-
- with menu_bar():
- with menu(label="Settings"):
- add_menu_item(label="Option 1", callback=_log)
- add_menu_item(label="Option 2", check=True, callback=_log)
- add_menu_item(label="Option 3", check=True, default_value=True, callback=_log)
+# add and load images
+def add_and_load_image(image_path):
+ width, height, channels, data = load_image(image_path)
+ with texture_registry() as reg_id:
+ texture_id = add_static_texture(width, height, data, parent=reg_id)
+ return add_image(texture_id)
+#================================================
+# Primary Window
-# Settings Window
-def exit(sender, data):
- stop_dearpygui()
+with window(tag="primary_window"):
+ # Grössere Schrifftart/ Grösse für das ganze Dokument definiert
+ # bind_font(default_font)
-# def _hsv_to_rgb(h, s, v):
-# if s == 0.0: return (v, v, v)
-# i = int(h*6.) # XXX assume int() truncates!
-# f = (h*6.)-i; p,q,t = v*(1.-s), v*(1.-s*f), v*(1.-s*(1.-f)); i%=6
-# if i == 0: return (255*v, 255*t, 255*p)
-# if i == 1: return (255*q, 255*v, 255*p)
-# if i == 2: return (255*p, 255*v, 255*t)
-# if i == 3: return (255*p, 255*q, 255*v)
-# if i == 4: return (255*t, 255*p, 255*v)
-# if i == 5: return (255*v, 255*p, 255*q)
-
-with window(label="Settings", width=200, height=400, pos=(25, 25), tag="sim_win",
- no_close=True,no_background= True):
with menu_bar():
with menu(label="Settings"):
- add_menu_item(label="Option 1")
- add_menu_item(label="Option 2", check=True)
- add_menu_item(label="Option 3", check=True, default_value=True)
+ add_menu_item(label="Toggle Fullscreen",callback=toggle_viewport_fullscreen)
+ add_menu_item(label="Minimize",callback=minimize_viewport)
+ add_menu_item(label="Close", callback=exit)
- #Farbwahl in schleife und mit def?
- with theme(tag= "button_window"):
- with theme_component(mvButton):
- add_theme_color(mvThemeCol_Button,(135, 206, 255))#Blau
- add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
- add_theme_style(mvStyleVar_FrameRounding, 5)
+ with theme(tag="close"):
+ with theme_component():
+ add_theme_color(mvThemeCol_Text,(255, 64, 64))
+ add_theme_style(mvStyleVar_Alpha, 5)
+ bind_item_theme(last_item(),"close")
- add_button(label="Toggle Fullscreen", height=50, width=150,callback= toggle_viewport_fullscreen)
- bind_item_theme(last_item(),"button_window")
-
- with theme(tag= "button_minimize"):
- with theme_component(mvButton):
- #add_theme_color(mvThemeCol_Button,(135, 206, 255))#Blau
- #add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
- add_theme_style(mvStyleVar_FrameRounding, 5)
- add_button(label="Minimize",height=50, width=150, callback= minimize_viewport)
- bind_item_theme(last_item(),"button_minimize")
-
- #with child_window(autosize_x=True, height=100)as close:
- add_button(label="Maximize",height=50, width=150, callback= maximize_viewport) #Befehl nötig ?
-
- with theme(tag= "button_close"):
- with theme_component(mvButton):
- add_theme_color(mvThemeCol_Button,(255, 64, 64))#Rot
- add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
- add_theme_style(mvStyleVar_FrameRounding, 5)
-
- add_button(label="Close", height=50, width=150, callback= exit)
- bind_item_theme(last_item(),"button_close")
-
-
-
-
-# #================================================
-# # Flow Graph Window
-
-# with window(label="RX DSP Flow Graph", width=800, height=400, pos=(25,25), tag="rx_win"):
-# with node_editor(callback=on_rx_node_link, delink_callback=on_rx_node_delink):
-# with node(label="USRP Source", pos=(20,100)):
-# with node_attribute(tag="src_out", attribute_type=mvNode_Attr_Output):
-# add_text("Signal from antenna")
-
-# with node(label="Clock Sync", pos=(200,200)):
-# with node_attribute(tag="clksync_in", attribute_type=mvNode_Attr_Input):
-# add_text("Input")
-
-# with node_attribute(tag="clksync_out", attribute_type=mvNode_Attr_Output):
-# add_text("Synchronized")
+#================================================
+# Flow Graph Window
-# with node(label="Equalizer", pos=(350,100)):
-# with node_attribute(tag="eq_in", attribute_type=mvNode_Attr_Input):
-# add_text("Input")
+with window(label="RX DSP Flow Graph", width=800, height=400, pos=(0,25), tag="rx_win"):
+ with node_editor(callback=on_rx_node_link, delink_callback=on_rx_node_delink):
+ with node(label="USRP Source", pos=(20,100)):
+ with node_attribute(tag="src_out", attribute_type=mvNode_Attr_Output):
+ add_text("Signal from antenna")
-# with node_attribute(attribute_type=mvNode_Attr_Static):
-# add_knob_float(label="Gain")
+ with node(label="Clock Sync", pos=(200,200)):
+ with node_attribute(tag="clksync_in", attribute_type=mvNode_Attr_Input):
+ add_text("Input")
-# with node_attribute(tag="eq_out", attribute_type=mvNode_Attr_Output):
-# add_text("Equalized")
+ with node_attribute(tag="clksync_out", attribute_type=mvNode_Attr_Output):
+ add_text("Synchronized")
-# with node(label="Phase Locked Loop", pos=(600, 200)):
-# with node_attribute(tag="pll_in", attribute_type=mvNode_Attr_Input):
-# add_text("Input")
+ with node(label="Equalizer", pos=(350,100)):
+ with node_attribute(tag="eq_in", attribute_type=mvNode_Attr_Input):
+ add_text("Input")
-# with node_attribute(tag="pll_out", attribute_type=mvNode_Attr_Output):
-# add_text("Locked")
-# add_knob_float(label="Loop BW")
+ with node_attribute(tag="eq_out", attribute_type=mvNode_Attr_Output):
+ add_text("Equalized")
+ with node(label="Phase Locked Loop", pos=(600, 200)):
+ with node_attribute(tag="pll_in", attribute_type=mvNode_Attr_Input):
+ add_text("Input")
-# add_node_link(get_alias_id("src_out"), get_alias_id("clksync_in"))
-# add_node_link(get_alias_id("clksync_out"), get_alias_id("eq_in"))
-# add_node_link(get_alias_id("eq_out"), get_alias_id("pll_in"))
+ with node_attribute(tag="pll_out", attribute_type=mvNode_Attr_Output):
+ add_text("Locked")
-# #================================================
-# Network plots Window
-recv_plot = net.network_plot(url="udp://localhost:31415", dtype=float, nsamples=100, \
- label="Test", height=300, width=800)
+ add_node_link(get_alias_id("src_out"), get_alias_id("clksync_in"))
+ add_node_link(get_alias_id("clksync_out"), get_alias_id("eq_in"))
+ add_node_link(get_alias_id("eq_out"), get_alias_id("pll_in"))
-plots = {
- # recv_plot: "plt_ampl"
+#================================================
+# Network plots
+
+time_plot = net.network_plot(url="udp://localhost:31415", dtype=float, \
+ nsamples=100, tag="time_plot", label="Time plot")
+channel_plot = net.network_constellation_plot(url="udp://localhost:31416", \
+ nsamples=80, tag="channel_plot", label="Channel")
+synchronized_plot = net.network_constellation_plot(url="udp://localhost:31417", \
+ nsamples=100, tag="synchronized_plot", label="Synchronized")
+equalized_plot = net.network_constellation_plot(url="udp://localhost:31418", \
+ nsamples=100, tag="equalized_plot", label="Equalized")
+locked_plot = net.network_constellation_plot(url="udp://localhost:31419", \
+ nsamples=100, tag="locked_plot", label="Locked")
+
+network_plots = {
+ time_plot: "time_plot_series",
+ channel_plot: "channel_plot_series",
+ synchronized_plot: "synchronized_plot_series",
+ equalized_plot: "equalized_plot_series",
+ locked_plot: "locked_plot_series",
}
-with window(label="Time domain plots", width=800, height=350, pos=(25,450)):
- with recv_plot:
- add_plot_axis(mvXAxis, label="Time")
- add_plot_axis(mvYAxis, label="Amplitude", tag="axis")
-
- add_line_series(recv_plot.xdata, recv_plot.ydata, parent="axis", tag="plt_ampl")
+with window(label="Time domain", width=800, height=350, pos=(0,425)):
+ with time_plot:
+ add_plot_axis(mvXAxis, label="Time", tag="xaxis_time")
+ add_plot_axis(mvYAxis, label="Amplitude", tag="yaxis_time")
+ add_line_series(time_plot.xdata, time_plot.ydata, parent="yaxis_time", tag=network_plots[time_plot])
+
+with window(label="Channel", width=560, height=400, pos=(800,25)):
+ with channel_plot:
+ add_plot_axis(mvXAxis, label="In-Phase", tag="inphase_channel")
+ add_plot_axis(mvYAxis, label="Quadrature", tag="quadrature_channel")
+
+ add_plot_legend()
+ set_axis_limits("inphase_channel", -2.5, 2.5)
+ set_axis_limits("quadrature_channel", -2.5, 2.5)
+
+ series_tag = network_plots[channel_plot]
+ add_scatter_series(channel_plot.xdata, channel_plot.ydata, \
+ label = "Channel", parent="inphase_channel", tag=series_tag)
+ bind_item_theme(series_tag, "constellation_series_theme")
+ # bind_colormap("channel_plot", mvPlotColormap_Spectral)
+
+with window(label="Synchronized", width=560, height=400, pos=(1360,25)):
+ with synchronized_plot:
+ add_plot_axis(mvXAxis, label="In-Phase", tag="inphase_synchronized")
+ add_plot_axis(mvYAxis, label="Quadrature", tag="quadrature_synchronized")
+
+ add_plot_legend()
+ set_axis_limits("inphase_synchronized", -2.5, 2.5)
+ set_axis_limits("quadrature_synchronized", -2.5, 2.5)
+
+ series_tag = network_plots[synchronized_plot]
+ add_scatter_series(synchronized_plot.xdata, synchronized_plot.ydata, \
+ label="Synchronized", parent="inphase_synchronized", tag=series_tag)
+ bind_item_theme(series_tag, "constellation_series_theme")
+
+with window(label="Equalized", width=560, height=400, pos=(800,425)):
+ with equalized_plot:
+ add_plot_legend()
+ add_plot_axis(mvXAxis, label="In-Phase", tag="inphase_equalized")
+ add_plot_axis(mvYAxis, label="Quadrature", tag="quadrature_equalized")
+
+ add_plot_legend()
+ set_axis_limits("inphase_equalized", -1.5, 1.5)
+ set_axis_limits("quadrature_equalized", -1.5, 1.5)
+
+ series_tag = network_plots[equalized_plot]
+ add_scatter_series(equalized_plot.xdata, equalized_plot.ydata, \
+ label="Equalized", parent="inphase_equalized", tag=series_tag)
+ bind_item_theme(series_tag, "constellation_series_theme")
+
+with window(label="Locked", width=560, height=400, pos=(1360,425)):
+ with locked_plot:
+ add_plot_legend()
+ add_plot_axis(mvXAxis, label="In-Phase", tag="inphase_locked")
+ add_plot_axis(mvYAxis, label="Quadrature", tag="quadrature_locked")
+
+ add_plot_legend()
+ set_axis_limits("inphase_locked", -1.5, 1.5)
+ set_axis_limits("quadrature_locked", -1.5, 1.5)
+
+ series_tag = network_plots[locked_plot]
+ add_scatter_series(locked_plot.xdata, locked_plot.ydata, \
+ label="Locked", parent="inphase_locked", tag=series_tag)
+ bind_item_theme(series_tag, "constellation_series_theme")
#================================================
-# Byte Error Rate Window
-#TO DO:
+# Bit Error Rate Window
-with window(label="Byte Error Rate ", width=300, height=150, pos=(850,25),tag="__ber_id",no_move=True, no_collapse= True):
- add_text("The Byte Error Rate is:")
+#TO DO:BER von GNU Radio anzeigen
+with theme(tag= "ber_window"):
+ with theme_component(mvAll):
+ add_theme_style(mvStyleVar_WindowTitleAlign, 0.5)
+ add_theme_style(mvStyleVar_WindowRounding, 5)
+ add_theme_style(mvStyleVar_WindowBorderSize, 1)#Rad ein und aus Schalten
-#================================================
-# Channel Window
-#TO DO:
-# recv_plot = net.network_plot(url="udp://localhost:31415", nsamples=100, label="Test", height=300, width=800)
-
-# plots = {
-# recv_plot: "plt_ampl"
-# }
-
-# with window(label="Channel ", width=600, height=600, pos=(850,25)):
-# with child_window(autosize_x=True, height=100):
-# add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
-# with recv_plot:
-# add_plot_axis(mvXAxis, label="In-phase")
-# add_plot_axis(mvYAxis, label="Quadrature", tag="plt_ampl")
-
-# add_scatter_series(recv_plot.x_data, recv_plot.y_data, parent="plt_ampl")
-# #================================================
-# # Synchronized Window
-# #TO DO:
-# with window(label="Synchronized ", width=600, height=600, pos=(850,25)):
-# with child_window(autosize_x=True, height=100):
-# add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
-
-# #================================================
-# # Equalized Window
-# #TO DO:
-# with window(label="Equalized ", width=600, height=600, pos=(850,25)):
-# with child_window(autosize_x=True, height=100):
-# add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
-
-# #================================================
-# # Locked Window
-# #TO DO:
-# with window(label="Locked ", width=600, height=600, pos=(850,25)):
-# with child_window(autosize_x=True, height=100):
-# add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
+with window(label="Bit Error Rate ", width=300, height=150, pos=(1200,875), no_title_bar = True, no_move=True, no_collapse= True) as ber_window :
+
+ add_text("The Bit Error Rate is:", pos=(35,10))
+ with theme(tag= "button_ber"):
+ with theme_component(mvButton):
+ add_theme_color(mvThemeCol_Button,(135, 206, 255))#Blau
+ add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
+ add_theme_style(mvStyleVar_FrameRounding, 5)
+ add_button(label="BER", height=60, width=150,pos=(75,60))
+ bind_item_theme(last_item(),"button_ber")
+# bind_item_theme(ber_window, "ber_window")
+# bind_item_font(ber_window, test)
#================================================
+# Picture Window
+with window(label="Picture", width=400, height=300, pos=(0,825)) as picture_window :
+ add_and_load_image("lena512color.png") #TO DO Problem lösen
+#================================================
# Start GUI and main loop
# Start window and main loop
show_viewport()
+set_primary_window("primary_window", True)
# Main loop
while is_dearpygui_running():
- for plt, tag in plots.items():
+ for plt, tag in network_plots.items():
plt.refresh_series(tag)
render_dearpygui_frame()
diff --git a/src/gui/gui_v2.py b/src/gui/gui_v2.py
deleted file mode 100755
index 4513322..0000000
--- a/src/gui/gui_v2.py
+++ /dev/null
@@ -1,336 +0,0 @@
-#!/usr/bin/env python3
-
-# Python stdlib
-import sys
-
-# Grahical libraries
-
-from dearpygui.dearpygui import *
-import dearpygui._dearpygui as internal_dpg
-from dearpygui.demo import show_demo
-
-# Detect (unix) signals
-import signal
-
-# Mathematics
-import numpy as np
-
-# For debugging
-import logging
-
-# Remote resources
-import net
-
-#================================================
-# Debugging tools
-
-logging.basicConfig(format="[%(levelname)s] %(asctime)s %(message)s", level=logging.DEBUG)
-logger = logging.getLogger(__name__)
-
-#================================================
-# Initialize DearPyGUI
-
-
-create_context()
-create_viewport(title="Fading Demonstrator",width=1920, height=1200)
-setup_dearpygui()
-
-# Show demo for dev
-show_demo()
-#show_font_manager()
-
-#================================================
-# add a font registry
-with font_registry():
- # first argument ids the path to the .ttf or .otf file
- default_font = add_font("NotoSerifCJKjp-Medium.otf", 20)
- second_font = add_font("NotoSerifCJKjp-Medium.otf", 10)
- test = add_font("NotoSerifCJKjp-Medium.otf", 30)
-
-#================================================
-# GUI Callback functions
-
-# Menu Bar
-def exit(sender, data):
- stop_dearpygui()
-
-# Flow graph window
-def on_rx_node_link(sender, app_data):
- link_id_1, link_id_2 = app_data
- add_node_link(link_id_1, link_id_2, parent=sender)
-
-def on_rx_node_delink(sender, app_data):
- link_id = app_data
- delete_item(link_id)
-
-# add and load images
-def add_and_load_image(image_path):
- width, height, channels, data = load_image(image_path)
-
- with texture_registry() as reg_id:
- texture_id = add_static_texture(width, height, data, parent=reg_id)
-
- return add_image(texture_id)
-
-
-#================================================
-#Setting Primary Window
-
-with window(tag="Primary Window"):
- bind_font(default_font) # Grössere Schrifftart/ Grösse für das ganze Dokument definiert
-
-#================================================
-#Setting Window in Menu
- with menu_bar():
- with menu(label="Settings"):
-
- with theme(tag= "close"):
- with theme_component():
- add_theme_color(mvThemeCol_Text,(255, 64, 64))#Rot
- add_theme_style(mvStyleVar_Alpha, 5)
-
- add_menu_item(label="Toggle Fullscreen",callback= toggle_viewport_fullscreen)
- add_menu_item(label="Minimize",callback= minimize_viewport)
- add_menu_item(label="Close", callback= exit)
- bind_item_theme(last_item(),"close")
-
- with menu(label="Plot"):
- add_menu_item(label="unlock x limits", callback=lambda: set_axis_limits_auto("xaxis_channel"))
- add_menu_item(label="unlock y limits", callback=lambda: set_axis_limits_auto("yaxis_channel"))
-
-
-#================================================
-# Flow Graph Window
-
-with window(label="RX DSP Flow Graph", width=800, height=400, pos=(0,25), tag="rx_win",
- no_title_bar = True, no_move=True, no_collapse= True):
- with node_editor(callback=on_rx_node_link, delink_callback=on_rx_node_delink):
- with node(label="USRP Source", pos=(20,100)):
- with node_attribute(tag="src_out", attribute_type=mvNode_Attr_Output):
- add_text("Signal from antenna")
-
- with node(label="Clock Sync", pos=(200,200)):
- with node_attribute(tag="clksync_in", attribute_type=mvNode_Attr_Input):
- add_text("Input")
-
- with node_attribute(tag="clksync_out", attribute_type=mvNode_Attr_Output):
- add_text("Synchronized")
-
- with node(label="Equalizer", pos=(350,100)):
- with node_attribute(tag="eq_in", attribute_type=mvNode_Attr_Input):
- add_text("Input")
-
- with node_attribute(attribute_type=mvNode_Attr_Static):
- add_knob_float(label="Gain")
-
- with node_attribute(tag="eq_out", attribute_type=mvNode_Attr_Output):
- add_text("Equalized")
-
- with node(label="Phase Locked Loop", pos=(600, 200)):
- with node_attribute(tag="pll_in", attribute_type=mvNode_Attr_Input):
- add_text("Input")
-
- with node_attribute(tag="pll_out", attribute_type=mvNode_Attr_Output):
- add_text("Locked")
- add_knob_float(label="Loop BW")
-
-
- add_node_link(get_alias_id("src_out"), get_alias_id("clksync_in"))
- add_node_link(get_alias_id("clksync_out"), get_alias_id("eq_in"))
- add_node_link(get_alias_id("eq_out"), get_alias_id("pll_in"))
-
-#================================================
-# Network plots Window
-
-recv_plot = net.network_plot(url="udp://localhost:31415", dtype=float, nsamples=100, \
- label="Test", height=300, width=800)
-
-plots = {
- # recv_plot: "plt_ampl"
-}
-
-with window(label="Time domain plots", width=800, height=350, pos=(0,425),
- no_title_bar = True, no_move=True, no_collapse= True):
- with recv_plot:
- add_plot_axis(mvXAxis, label="Time")
- add_plot_axis(mvYAxis, label="Amplitude", tag="axis")
-
- add_line_series(recv_plot.xdata, recv_plot.ydata, parent="axis", tag="plt_ampl")
-
-#================================================
-# Byte Error Rate Window
-
-#TO DO:BER von GNU Radio anzeigen
-
-with theme(tag= "ber_window"):
- with theme_component(mvAll):
- add_theme_style(mvStyleVar_WindowTitleAlign, 0.5)
- add_theme_style(mvStyleVar_WindowRounding, 5)
- add_theme_style(mvStyleVar_WindowBorderSize, 1)#Rad ein und aus Schalten
-
-with window(label="Byte Error Rate ", width=300, height=150, pos=(1200,875)
- ,no_title_bar = True, no_move=True, no_collapse= True) as ber_window :
-
- add_text("The Byte Error Rate is:",pos=(35,10))
-
- with theme(tag= "button_ber"):
- with theme_component(mvButton):
- add_theme_color(mvThemeCol_Button,(135, 206, 255))#Blau
- add_theme_color(mvThemeCol_Text,(0,0,0))#Schwarz
- add_theme_style(mvStyleVar_FrameRounding, 5)
-
- add_button(label="BER", height=60, width=150,pos=(75,60))
- bind_item_theme(last_item(),"button_ber")
-
-bind_item_theme(ber_window,"ber_window")
-bind_item_font(ber_window,test)
-
-#================================================
-# Picture Window
-with window(label="Picture", width=400, height=300, pos=(0,825),
- no_title_bar = True, no_move=True, no_collapse= True) as picture_window :
- #with child_window(width=400, height=400):
- add_and_load_image("logo.png")
- add_text("Picture 1")
- #add_and_load_image("lena512color.png") #TO DO Problem lösen
-
-with window(label="Picture_2", width=400, height=300, pos=(400,825),
- no_title_bar = True, no_move=True, no_collapse= True) as picture_window :
- #with child_window(width=400, height=400):
- add_and_load_image("logo.png")
- add_text("Picture 2")
- #add_and_load_image("l
-
-#================================================
-# Channel Window
-# TO DO: Change Data to Real Data from the GUI
-
-# Some Data to plot
-sindatax = []
-sindatay = []
-for i in range(-2, 100):
- sindatax.append(i / 100)
- sindatay.append(0.5 + 0.5 * np.sin(50 * i / 100))
-sindatay2 = []
-for i in range(-2, 100):
- sindatay2.append(2 + 0.5 * np.sin(50 * i / 100))
-
-with window(label="Channel ", width=560, height=400, pos=(800,25),
- no_title_bar = True, no_move=True, no_collapse= True):
-
- # create a theme for the plot
- with theme(tag="plot_theme"):
- with theme_component(mvScatterSeries):
- add_theme_color(mvPlotCol_Line, (135, 206, 255), category=mvThemeCat_Plots)
- add_theme_style(mvPlotStyleVar_Marker,mvPlotMarker_Asterisk, category=mvThemeCat_Plots) #TO DO: change to mvPlotMarker_Circle
- add_theme_style(mvPlotStyleVar_MarkerSize, 3, category=mvThemeCat_Plots)
-
- # Plot
- with plot(tag="plot", label="Channel", height=-1, width=-1):
-
- # optionally create legend
- add_plot_legend()
-
- # REQUIRED: create x and y axes
- add_plot_axis(mvXAxis, label="In-phase",tag="xaxis_channel")
- set_axis_limits("xaxis_channel", -2, 2)
-
- add_plot_axis(mvYAxis, label= "Quadrature", tag="yaxis_channel")
- set_axis_limits("yaxis_channel", -2, 2)
-
- # series belong to a y axis
- add_scatter_series(sindatax, sindatay2, label="Some Data", parent="yaxis_channel", tag="series_data2")
- #add_button(label="Delete Series 1", parent=last_item(), callback=lambda: delete_item("series_data2"))
-
- # apply theme to series
- bind_item_theme("series_data2", "plot_theme")
-
-
-
-#================================================
-# Synchronized Window
-with window(label="Synchronized", width=560, height=400, pos=(1360,25),
- no_title_bar = True, no_move=True, no_collapse= True):
- add_text("TO DO Synchronized")
-
- # with child_window(autosize_x=True, height=100):
- # add_button(label="Toggle Fullscreen", callback= toggle_viewport_fullscreen)
-# #================================================
-# # Equalized Window
-with window(label="Equalized", width=560, height=400, pos=(800,425),
- no_title_bar = True, no_move=True, no_collapse= True):
- add_text("TO DO Equalized")
-
-#================================================
-# Locked Window
-# TO DO: Change Data to Real Data from the GUI
-
-# Some Data to plot
-sindatax = []
-sindatay = []
-for i in range(-2, 100):
- sindatax.append(i / 100)
- sindatay.append(0.5 + 0.5 * np.sin(50 * i / 100))
-sindatay2 = []
-for i in range(-2, 100):
- sindatay2.append(2 + 0.5 * np.sin(50 * i / 100))
-
-with window(label="Locked ", width=560, height=400, pos=(1360,425),
- no_title_bar = True, no_move=True, no_collapse= True):
-
- # create a theme for the plot
- with theme(tag="plot_theme_locked"):
- with theme_component(mvScatterSeries):
- add_theme_color(mvPlotCol_Line, (135, 206, 255), category=mvThemeCat_Plots)
- add_theme_style(mvPlotStyleVar_Marker,mvPlotMarker_Asterisk, category=mvThemeCat_Plots) #TO DO: change to mvPlotMarker_Circle
- add_theme_style(mvPlotStyleVar_MarkerSize, 3, category=mvThemeCat_Plots)
-
- # Plot
- with plot(tag="plot_locked", label="Locked", height=-1, width=-1):
-
- # optionally create legend
- add_plot_legend()
-
- # REQUIRED: create x and y axes
- add_plot_axis(mvXAxis, label="In-phase",tag="xaxis_locked")
- set_axis_limits("xaxis_locked", -2, 2)
-
- add_plot_axis(mvYAxis, label= "Quadrature", tag="yaxis_locked")
- set_axis_limits("yaxis_locked", -2, 2)
-
- # series belong to a y axis
- add_scatter_series(sindatax, sindatay2, label="Some Data", parent="yaxis_locked", tag="series_data2_locked")
- #add_button(label="Delete Series 1", parent=last_item(), callback=lambda: delete_item("series_data2"))
-
- # apply theme to series
- bind_item_theme("series_data2_locked", "plot_theme_locked")
-
-#TO DO: find a better way to do that
- with group(horizontal=True):
- add_button(label="unlock x limits", callback=lambda: set_axis_limits_auto("xaxis_locked"))
- add_button(label="unlock y limits", callback=lambda: set_axis_limits_auto("yaxis_locked"))
-
-
-
-
-
-#================================================
-
-# Start GUI and main loop
-
-# Start window and main loop
-show_viewport()
-set_primary_window("Primary Window", True)
-
-# Main loop
-while is_dearpygui_running():
- for plt, tag in plots.items():
- plt.refresh_series(tag)
-
- render_dearpygui_frame()
-
-#================================================
-# Close everything
-
-# clean up gui
-destroy_context()
diff --git a/src/gui/lena512color.png b/src/gui/lena512color.png
index ffe5c83..7d364e0 100644
--- a/src/gui/lena512color.png
+++ b/src/gui/lena512color.png
Binary files differ
diff --git a/src/gui/logo.png b/src/gui/logo.png
deleted file mode 100644
index f972f98..0000000
--- a/src/gui/logo.png
+++ /dev/null
Binary files differ
diff --git a/src/gui/net.py b/src/gui/net.py
index c7008cd..264c9d8 100644
--- a/src/gui/net.py
+++ b/src/gui/net.py
@@ -12,10 +12,11 @@ class udpsource:
"""
Creates an UDP listening socket
"""
- def __init__(self, url, dtype):
+ def __init__(self, url, dtype, timeout=0.05):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.url = urlparse(url)
self.dtype = dtype
+ self.timeout = timeout
def __del__(self):
self.sock.close()
@@ -26,7 +27,8 @@ class udpsource:
# self.sock.listen()
def read(self, nblocks):
- ready, _, _ = select.select([self.sock], [], [])
+ # TODO: run in a separate thread (it will be painful to implement)
+ ready, _w, _x = select.select([self.sock], [], [], self.timeout)
if not ready:
return None
@@ -40,7 +42,10 @@ class udpsource:
def chunk_to_samples(chunk):
samples = chunk.split(",")
if samples:
- return list(map(self.dtype, samples))
+ try:
+ return list(map(self.dtype, samples))
+ except ValueError:
+ return []
# convert each chunk into a list of samples
chunk_values = map(chunk_to_samples, chunks)
@@ -51,18 +56,29 @@ class udpsource:
return values
class network_plot(udpsource):
- def __init__(self, url, dtype, nsamples, **kwargs):
+ """
+ Wraps a udpsource while at the same time intefacing with DearPyGUI as a plot element.
+ """
+ def __init__(self, url, dtype, nsamples , **kwargs):
udpsource.__init__(self, url, dtype)
+ self.nsamples = nsamples
+
+ self._init_buffers()
+ self._init_dpg_plot(**kwargs)
+
+ # listen for connections
+ self.bind()
+ def _init_buffers(self):
# create buffers for x and y values
- self.nsamples = nsamples
- self.xvalues = np.arange(0, self.nsamples)
- self.yvalues = RingBuffer(capacity=self.nsamples, dtype=np.dtype(dtype))
+ self.xvalues = RingBuffer(capacity=self.nsamples, dtype=np.dtype(self.dtype))
+ self.yvalues = RingBuffer(capacity=self.nsamples, dtype=np.dtype(self.dtype))
+
+ self.xvalues.extend(np.arange(0, self.nsamples))
self.yvalues.extend(np.zeros(self.nsamples))
- # create a plot
+ def _init_dpg_plot(self, **kwargs):
self.plot = dpg.plot(**kwargs)
- self.bind()
# Map `with' expressions to the underlying plot
def __enter__(self):
@@ -73,15 +89,41 @@ class network_plot(udpsource):
@property
def xdata(self):
- return self.xvalues
+ # unwrap ringbuffer
+ return np.array(self.xvalues)
@property
def ydata(self):
+ # unwrap ringbuffer
return np.array(self.yvalues)
def refresh_series(self, tag):
- new_values = self.read(1)
+ new_values = self.read(10)
if new_values:
self.yvalues.extendleft(new_values)
dpg.set_value(tag, [self.xdata, self.ydata])
+
+
+class network_constellation_plot(network_plot):
+ """
+ Special case of a plot, where complex numbers are drawn into a scatter plot
+ """
+ def __init__(self, url, nsamples, **kwargs):
+ network_plot.__init__(self, url, np.complex64, nsamples)
+
+ def _init_buffers(self):
+ self.xvalues = RingBuffer(capacity=self.nsamples, dtype=np.float32)
+ self.yvalues = RingBuffer(capacity=self.nsamples, dtype=np.float32)
+
+ self.xvalues.extend(np.zeros(self.nsamples))
+ self.yvalues.extend(np.zeros(self.nsamples))
+
+ def refresh_series(self, tag):
+ new_values = self.read(1)
+
+ if new_values:
+ self.xvalues.extendleft(np.real(new_values))
+ self.yvalues.extendleft(np.imag(new_values))
+
+ dpg.set_value(tag, [self.xdata, self.ydata])
diff --git a/src/gui/test.py b/src/gui/test.py
deleted file mode 100644
index f3accf3..0000000
--- a/src/gui/test.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import dearpygui.dearpygui as dpg
-
-# Callbacks
-def cb_nextpic(sender, app_data, user_data):
- dpg.set_value(texture_id, user_data['textures'][user_data['next_key']])
-
- # Set key for next Image. Rotate back to 1 when last image has been shown
- if user_data['next_key'] < 11:
- user_data['next_key'] = user_data['next_key']+1
- else:
- user_data['next_key'] = 1
-
-
-# Load in the Logo and add it to the texture_registry
-# TODO: Find out, what that thing is actually doing. It is not really clear atm.
-width, height, channels, data = dpg.load_image("logo.png")
-with dpg.texture_registry():
- texture_id = dpg.add_dynamic_texture(width, height, data)
-
-# Next, load in the rest of the pictures
-# Important: We are only interested in the data part here!
-# Important: All the images must have the same size, because they are
-# displayed on the image that will be created from the
-# texture_id of the registry
-img_dict = {}
-for a in range(11):
- width, height, channels, data = dpg.load_image(f"resources\img{a+1}.png")
- img_dict[a+1] = data
-
-img_handler_dict = {
- 'next_key': 1,
- 'textures': img_dict
-}
-
-with dpg.window(label="Hangman") as main_window:
- dpg.add_image(texture_id)
- dpg.add_button(label="Next IMG", callback=cb_nextpic, user_data=img_handler_dict)
-
-dpg.set_primary_window(main_window, True)
-dpg.start_dearpygui() \ No newline at end of file
diff --git a/src/gui/test2.py b/src/gui/test2.py
deleted file mode 100644
index f339af8..0000000
--- a/src/gui/test2.py
+++ /dev/null
@@ -1,22 +0,0 @@
-import dearpygui.dearpygui as dpg
-
-dpg.create_context()
-
-with dpg.window(label="about", width=400, height=400):
- dpg.add_button(label="Press me")
- dpg.draw_line((0, 10), (100, 100), color=(255, 0, 0, 255), thickness=1)
-
-# print children
-print(dpg.get_item_children(dpg.last_root()))
-
-# print children in slot 1
-print(dpg.get_item_children(dpg.last_root(), 1))
-
-# check draw_line's slot
-print(dpg.get_item_slot(dpg.last_item()))
-
-dpg.create_viewport(title='Custom Title', width=800, height=600)
-dpg.setup_dearpygui()
-dpg.show_viewport()
-dpg.start_dearpygui()
-dpg.destroy_context()