From be28d083e4ea4552ebbda9b59625ff09b884e353 Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 27 Jan 2026 16:20:23 -0500 Subject: [PATCH] Expose more `pg.ArrowItem` params thru annot-ctl API --- piker/tsp/_annotate.py | 9 +++++++-- piker/tsp/_history.py | 4 ++-- piker/ui/_editors.py | 23 +++++++++++++++++++---- piker/ui/_remote_ctl.py | 20 ++++++++++++++++++++ 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/piker/tsp/_annotate.py b/piker/tsp/_annotate.py index b42b317a..f333d4a4 100644 --- a/piker/tsp/_annotate.py +++ b/piker/tsp/_annotate.py @@ -127,7 +127,6 @@ async def markup_gaps( # BGM=0.16 is the normal diff from overlap between bars, SO # just go slightly "in" from that "between them". from_idx: int = BGM - .06 # = .10 - lc: tuple[float, float] = ( istart + 1 - from_idx, cls, @@ -162,14 +161,20 @@ async def markup_gaps( 'down' if sgn == 1 else 'up' ) + # TODO! mk this a `msgspec.Struct` which we deserialize + # on the server side! arrow_kwargs: dict[str, Any] = dict( fqme=fqme, timeframe=timeframe, x=iend, y=cls, color=color, - alpha=160, + alpha=169, pointing=direction, + # TODO: expose these as params to markup_gaps()? + headLen=10, + headWidth=2.222, + pxMode=True, ) aid: int = await actl.add_arrow( diff --git a/piker/tsp/_history.py b/piker/tsp/_history.py index e11f967d..54cbb3b4 100644 --- a/piker/tsp/_history.py +++ b/piker/tsp/_history.py @@ -243,8 +243,8 @@ async def maybe_fill_null_segments( ) if ( - from_timestamp( - array['time'][0] + frame_start_dt := ( + from_timestamp(array['time'][0]) ) < backfill_until_dt ): await tractor.pause() diff --git a/piker/ui/_editors.py b/piker/ui/_editors.py index 8b0ba19c..a560249d 100644 --- a/piker/ui/_editors.py +++ b/piker/ui/_editors.py @@ -94,6 +94,11 @@ class ArrowEditor(Struct): ] = None, alpha: int = 255, zval: float = 1e9, + headLen: float|None = None, + headWidth: float|None = None, + tailLen: float|None = None, + tailWidth: float|None = None, + pxMode: bool = True, ) -> pg.ArrowItem: ''' @@ -109,6 +114,15 @@ class ArrowEditor(Struct): # scale arrow sizing to dpi-aware font size = _font.font.pixelSize() * 0.8 + # allow caller override of head dimensions + if headLen is None: + headLen = size + if headWidth is None: + headWidth = size/2 + # tail params default to None (no tail) + if tailWidth is None: + tailWidth = 3 + color = color or 'default' color = QColor(hcolor(color)) color.setAlpha(alpha) @@ -117,10 +131,11 @@ class ArrowEditor(Struct): arrow = pg.ArrowItem( angle=angle, baseAngle=0, - headLen=size, - headWidth=size/2, - tailLen=None, - pxMode=True, + headLen=headLen, + headWidth=headWidth, + tailLen=tailLen, + tailWidth=tailWidth, + pxMode=pxMode, # coloring pen=pen, brush=brush, diff --git a/piker/ui/_remote_ctl.py b/piker/ui/_remote_ctl.py index 42f8a9b7..c1153e2b 100644 --- a/piker/ui/_remote_ctl.py +++ b/piker/ui/_remote_ctl.py @@ -183,6 +183,11 @@ async def serve_rc_annots( 'color': color, 'aid': str()|None as aid, 'alpha': int(alpha), + 'headLen': int()|float()|None as headLen, + 'headWidth': int()|float()|None as headWidth, + 'tailLen': int()|float()|None as tailLen, + 'tailWidth': int()|float()|None as tailWidth, + 'pxMode': bool(pxMode), }, # ?TODO? split based on method fn-sigs? # 'pointing', @@ -213,6 +218,11 @@ async def serve_rc_annots( pointing=pointing, color=color, alpha=alpha, + headLen=headLen, + headWidth=headWidth, + tailLen=tailLen, + tailWidth=tailWidth, + pxMode=pxMode, ) annots[aid] = arrow _editors[aid] = arrows @@ -441,6 +451,11 @@ class AnnotCtl(Struct): # domain: str = 'view', # or 'scene' color: str = 'dad_blue', alpha: int = 116, + headLen: float|None = None, + headWidth: float|None = None, + tailLen: float|None = None, + tailWidth: float|None = None, + pxMode: bool = True, from_acm: bool = False, @@ -464,6 +479,11 @@ class AnnotCtl(Struct): 'pointing': pointing, # up|down 'alpha': alpha, 'aid': None, + 'headLen': headLen, + 'headWidth': headWidth, + 'tailLen': tailLen, + 'tailWidth': tailWidth, + 'pxMode': pxMode, }, }) aid: int = await ipc.receive()