WIP: make libraries and names first-class!
This commit is contained in:
parent
f834ec6be5
commit
7aaf73cb37
34 changed files with 1780 additions and 1812 deletions
|
|
@ -6,14 +6,14 @@ from numpy.typing import ArrayLike, NDArray
|
|||
|
||||
from .repetition import Repetition
|
||||
from .utils import rotation_matrix_2d, layer_t, AutoSlots, annotations_t
|
||||
from .traits import PositionableImpl, LayerableImpl, Copyable, Pivotable, LockableImpl, RepeatableImpl
|
||||
from .traits import PositionableImpl, LayerableImpl, Copyable, Pivotable, RepeatableImpl
|
||||
from .traits import AnnotatableImpl
|
||||
|
||||
|
||||
L = TypeVar('L', bound='Label')
|
||||
|
||||
|
||||
class Label(PositionableImpl, LayerableImpl, LockableImpl, RepeatableImpl, AnnotatableImpl,
|
||||
class Label(PositionableImpl, LayerableImpl, RepeatableImpl, AnnotatableImpl,
|
||||
Pivotable, Copyable, metaclass=AutoSlots):
|
||||
"""
|
||||
A text annotation with a position and layer (but no size; it is not drawn)
|
||||
|
|
@ -49,32 +49,28 @@ class Label(PositionableImpl, LayerableImpl, LockableImpl, RepeatableImpl, Annot
|
|||
layer: layer_t = 0,
|
||||
repetition: Optional[Repetition] = None,
|
||||
annotations: Optional[annotations_t] = None,
|
||||
locked: bool = False,
|
||||
identifier: Tuple = (),
|
||||
) -> None:
|
||||
LockableImpl.unlock(self)
|
||||
self.identifier = identifier
|
||||
self.string = string
|
||||
self.offset = numpy.array(offset, dtype=float, copy=True)
|
||||
self.layer = layer
|
||||
self.repetition = repetition
|
||||
self.annotations = annotations if annotations is not None else {}
|
||||
self.set_locked(locked)
|
||||
|
||||
def __copy__(self: L) -> L:
|
||||
return type(self)(string=self.string,
|
||||
offset=self.offset.copy(),
|
||||
layer=self.layer,
|
||||
repetition=self.repetition,
|
||||
locked=self.locked,
|
||||
identifier=self.identifier)
|
||||
return type(self)(
|
||||
string=self.string,
|
||||
offset=self.offset.copy(),
|
||||
layer=self.layer,
|
||||
repetition=self.repetition,
|
||||
identifier=self.identifier,
|
||||
)
|
||||
|
||||
def __deepcopy__(self: L, memo: Dict = None) -> L:
|
||||
memo = {} if memo is None else memo
|
||||
new = copy.copy(self)
|
||||
LockableImpl.unlock(new)
|
||||
new._offset = self._offset.copy()
|
||||
new.set_locked(self.locked)
|
||||
return new
|
||||
|
||||
def rotate_around(self: L, pivot: ArrayLike, rotation: float) -> L:
|
||||
|
|
@ -106,17 +102,3 @@ class Label(PositionableImpl, LayerableImpl, LockableImpl, RepeatableImpl, Annot
|
|||
Bounds [[xmin, xmax], [ymin, ymax]]
|
||||
"""
|
||||
return numpy.array([self.offset, self.offset])
|
||||
|
||||
def lock(self: L) -> L:
|
||||
PositionableImpl._lock(self)
|
||||
LockableImpl.lock(self)
|
||||
return self
|
||||
|
||||
def unlock(self: L) -> L:
|
||||
LockableImpl.unlock(self)
|
||||
PositionableImpl._unlock(self)
|
||||
return self
|
||||
|
||||
def __repr__(self) -> str:
|
||||
locked = ' L' if self.locked else ''
|
||||
return f'<Label "{self.string}" l{self.layer} o{self.offset}{locked}>'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue