mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-28 05:11:02 -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
|
@property
|
||||||
def X(cls) -> Axis:
|
def X(cls) -> Axis:
|
||||||
"""X Axis"""
|
"""X Axis"""
|
||||||
return Axis((0, 0, 0), (1, 0, 0))
|
return cls((0, 0, 0), (1, 0, 0))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Y(cls) -> Axis:
|
def Y(cls) -> Axis:
|
||||||
"""Y Axis"""
|
"""Y Axis"""
|
||||||
return Axis((0, 0, 0), (0, 1, 0))
|
return cls((0, 0, 0), (0, 1, 0))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Z(cls) -> Axis:
|
def Z(cls) -> Axis:
|
||||||
"""Z Axis"""
|
"""Z Axis"""
|
||||||
return Axis((0, 0, 0), (0, 0, 1))
|
return cls((0, 0, 0), (0, 0, 1))
|
||||||
|
|
||||||
|
|
||||||
class Axis(metaclass=AxisMeta):
|
class Axis(metaclass=AxisMeta):
|
||||||
|
|
@ -690,7 +690,7 @@ class Axis(metaclass=AxisMeta):
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
"""Display self"""
|
"""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:
|
def __eq__(self, other: object) -> bool:
|
||||||
if not isinstance(other, Axis):
|
if not isinstance(other, Axis):
|
||||||
|
|
@ -833,7 +833,7 @@ class Axis(metaclass=AxisMeta):
|
||||||
|
|
||||||
def reverse(self) -> Axis:
|
def reverse(self) -> Axis:
|
||||||
"""Return a copy of self with the direction reversed"""
|
"""Return a copy of self with the direction reversed"""
|
||||||
return Axis(self.wrapped.Reversed())
|
return type(self)(self.wrapped.Reversed())
|
||||||
|
|
||||||
def __neg__(self) -> Axis:
|
def __neg__(self) -> Axis:
|
||||||
"""Flip direction operator -"""
|
"""Flip direction operator -"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue