mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Making Axis friendly to sub-classing
This commit is contained in:
parent
b8dcad3bcb
commit
0e3dbbe15b
1 changed files with 5 additions and 5 deletions
|
|
@ -558,17 +558,17 @@ class AxisMeta(type):
|
|||
@property
|
||||
def X(cls) -> Axis:
|
||||
"""X Axis"""
|
||||
return Axis((0, 0, 0), (1, 0, 0))
|
||||
return cls((0, 0, 0), (1, 0, 0))
|
||||
|
||||
@property
|
||||
def Y(cls) -> Axis:
|
||||
"""Y Axis"""
|
||||
return Axis((0, 0, 0), (0, 1, 0))
|
||||
return cls((0, 0, 0), (0, 1, 0))
|
||||
|
||||
@property
|
||||
def Z(cls) -> Axis:
|
||||
"""Z Axis"""
|
||||
return Axis((0, 0, 0), (0, 0, 1))
|
||||
return cls((0, 0, 0), (0, 0, 1))
|
||||
|
||||
|
||||
class Axis(metaclass=AxisMeta):
|
||||
|
|
@ -690,7 +690,7 @@ class Axis(metaclass=AxisMeta):
|
|||
|
||||
def __str__(self) -> str:
|
||||
"""Display self"""
|
||||
return f"Axis: ({self.position.to_tuple()},{self.direction.to_tuple()})"
|
||||
return f"{type(self).__name__}: ({self.position.to_tuple()},{self.direction.to_tuple()})"
|
||||
|
||||
def __eq__(self, other: object) -> bool:
|
||||
if not isinstance(other, Axis):
|
||||
|
|
@ -833,7 +833,7 @@ class Axis(metaclass=AxisMeta):
|
|||
|
||||
def reverse(self) -> Axis:
|
||||
"""Return a copy of self with the direction reversed"""
|
||||
return Axis(self.wrapped.Reversed())
|
||||
return type(self)(self.wrapped.Reversed())
|
||||
|
||||
def __neg__(self) -> Axis:
|
||||
"""Flip direction operator -"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue