Move marker label anchor to anchors mod
parent
0ddeded03d
commit
2d42da6f1a
|
@ -21,6 +21,7 @@ Anchor funtions for UI placement of annotions.
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from PyQt5.QtCore import QPointF
|
from PyQt5.QtCore import QPointF
|
||||||
|
from PyQt5.QtGui import QGraphicsPathItem
|
||||||
|
|
||||||
from ._label import Label
|
from ._label import Label
|
||||||
|
|
||||||
|
@ -155,3 +156,18 @@ def update_pp_nav(
|
||||||
|
|
||||||
# re-anchor label (i.e. trigger call of ``arrow_tr()`` from above
|
# re-anchor label (i.e. trigger call of ``arrow_tr()`` from above
|
||||||
label.update()
|
label.update()
|
||||||
|
|
||||||
|
|
||||||
|
def path_topright(
|
||||||
|
gpath: QGraphicsPathItem,
|
||||||
|
label: Label, # noqa
|
||||||
|
|
||||||
|
) -> QPointF:
|
||||||
|
# get actual arrow graphics path
|
||||||
|
path_br = gpath.mapToScene(
|
||||||
|
gpath.path()
|
||||||
|
).boundingRect()
|
||||||
|
|
||||||
|
# vb.locate(arrow_path) #, children=True)
|
||||||
|
|
||||||
|
return path_br.topRight() - QPointF(0, label.h / 3)
|
||||||
|
|
|
@ -26,6 +26,7 @@ import pyqtgraph as pg
|
||||||
from pyqtgraph import Point, functions as fn
|
from pyqtgraph import Point, functions as fn
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
from PyQt5.QtCore import QPointF
|
from PyQt5.QtCore import QPointF
|
||||||
|
from PyQt5.QtGui import QGraphicsPathItem
|
||||||
|
|
||||||
from ._annotate import mk_marker, qgo_draw_markers
|
from ._annotate import mk_marker, qgo_draw_markers
|
||||||
from ._anchors import (
|
from ._anchors import (
|
||||||
|
@ -33,6 +34,7 @@ from ._anchors import (
|
||||||
vbr_left,
|
vbr_left,
|
||||||
right_axis,
|
right_axis,
|
||||||
update_pp_nav,
|
update_pp_nav,
|
||||||
|
path_topright,
|
||||||
)
|
)
|
||||||
from ._label import Label
|
from ._label import Label
|
||||||
from ._style import hcolor, _font
|
from ._style import hcolor, _font
|
||||||
|
@ -767,17 +769,11 @@ def position_line(
|
||||||
)
|
)
|
||||||
arrow_path.label = marker_label
|
arrow_path.label = marker_label
|
||||||
|
|
||||||
def arrow_tr():
|
marker_label.scene_anchor = partial(
|
||||||
# get actual arrow graphics path
|
path_topright,
|
||||||
path_br = arrow_path.mapToScene(
|
gpath=arrow_path,
|
||||||
arrow_path.path()
|
label=marker_label,
|
||||||
).boundingRect()
|
)
|
||||||
|
|
||||||
# vb.locate(arrow_path) #, children=True)
|
|
||||||
|
|
||||||
return path_br.topRight() - QPointF(0, marker_label.h / 3)
|
|
||||||
|
|
||||||
marker_label.scene_anchor = arrow_tr
|
|
||||||
|
|
||||||
line._labels.append(marker_label)
|
line._labels.append(marker_label)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue