From 161448c31aba48bbb347131f5ea54b1ab9dd081a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 7 Sep 2022 11:30:41 -0400 Subject: [PATCH] Support order staging from slow chart using `.get_cursor()` --- piker/ui/_editors.py | 6 +++--- piker/ui/order_mode.py | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/piker/ui/_editors.py b/piker/ui/_editors.py index 31d7b7b8..e7e1bdf0 100644 --- a/piker/ui/_editors.py +++ b/piker/ui/_editors.py @@ -110,11 +110,11 @@ class LineEditor(Struct): line: LevelLine, ) -> LevelLine: - """Stage a line at the current chart's cursor position + ''' + Stage a line at the current chart's cursor position and return it. - """ - + ''' # add a "staged" cursor-tracking line to view # and cash it in a a var if self._active_staged_line: diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index af72900a..d1031d38 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -112,6 +112,7 @@ class OrderMode: mouse click and drag -> modify current order under cursor ''' + godw: GodWidget feed: Feed chart: ChartPlotWidget # type: ignore # noqa hist_chart: ChartPlotWidget # type: ignore # noqa @@ -251,12 +252,15 @@ class OrderMode: action: str, trigger_type: str, - ) -> None: - '''Stage an order for submission. + ) -> list[LevelLine]: + ''' + Stage an order for submission by showing level lines and + configuring the order request message dynamically based on + allocator settings. ''' # not initialized yet - chart = self.chart + chart = self.godw.get_cursor().linked.chart cursor = chart.linked.cursor if not (chart and cursor and cursor.active_plot): @@ -277,7 +281,7 @@ class OrderMode: exec_mode=trigger_type, # dark or live ) - line = self.line_from_order( + lines = self.lines_from_order( order, show_markers=True, # just for the stage line to avoid @@ -290,15 +294,15 @@ class OrderMode: # prevent flickering of marker while moving/tracking cursor only_show_markers_on_hover=False, ) - line = self.lines.stage_line(line) + for line in lines: + line = self.lines.stage_line(line) + # add line to cursor trackers + cursor._trackers.add(line) # hide crosshair y-line and label cursor.hide_xhair() - # add line to cursor trackers - cursor._trackers.add(line) - - return line + return lines def submit_order( self, @@ -770,6 +774,7 @@ async def open_order_mode( # top level abstraction which wraps all this crazyness into # a namespace.. mode = OrderMode( + godw, feed, chart, hist_chart,