Skip to content

Commit

Permalink
gui: add a short timer-based delay before re-acting to GUI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bwinkel committed Apr 21, 2019
1 parent 5570830 commit 81de829
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
13 changes: 11 additions & 2 deletions pycraf/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ def __init__(self, **kwargs):
self.setup_gui()

# want that at start, user is presented with a plot
# we will also use this timer to implement a short delay between
# gui parameter changes and calling the plotting routine; this is
# because Qt will otherwise go through all intermediate steps
# (e.g., if one changes multiple digits in a spinbox), which
# is usually undesired
self.timer = QtCore.QTimer()
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.on_any_param_changed)
Expand Down Expand Up @@ -218,14 +223,14 @@ def setup_signals(self):
self.ui.rxLatDoubleSpinBox,
self.ui.rxHeightDoubleSpinBox,
]:
w.valueChanged.connect(self.on_any_param_changed)
w.valueChanged.connect(self.on_any_param_changed_initiated)

for w in [
self.ui.versionComboBox,
self.ui.txClutterComboBox,
self.ui.rxClutterComboBox,
]:
w.currentIndexChanged.connect(self.on_any_param_changed)
w.currentIndexChanged.connect(self.on_any_param_changed_initiated)

@QtCore.pyqtSlot(object)
def setup_workers(self):
Expand Down Expand Up @@ -351,6 +356,10 @@ def _get_parameters(self):

return job_dict

@QtCore.pyqtSlot()
def on_any_param_changed_initiated(self):
self.timer.start(250)

@QtCore.pyqtSlot()
def on_any_param_changed(self):

Expand Down
15 changes: 0 additions & 15 deletions pycraf/gui/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,6 @@ def cached_height_path_data(*args, **kwargs):
return pathprof.height_path_data(*args, **kwargs)


# @lru_cache(maxsize=10, typed=False)
# def cached_height_path_data_generic(*args, **kwargs):
# # height_path_data_generic has a different signature;
# # need to find mid point
# lon_t, lat_t, lon_r, lat_r, step = args
# distance, bearing, _ = pathprof.geoid_inverse(
# lon_t, lat_t, lon_r, lat_r
# )
# lon_mid, lat_mid, _ = pathprof.geoid_direct(
# lon_t, lat_r, bearing, distance / 2,
# )
# args = distance, step, lon_mid, lat_mid
# return pathprof.height_path_data_generic(*args, **kwargs)


@lru_cache(maxsize=10, typed=False)
def cached_height_path_data_generic(*args, **kwargs):
# height_path_data_generic has no backbearings, etc.
Expand Down

0 comments on commit 81de829

Please sign in to comment.