Commits

German Larrain  committed 2eff4f6

graphics.base: refactored code of Axes and Body into new (super) class Entity.

  • Participants
  • Parent commits 121dba0

Comments (0)

Files changed (1)

File ars/graphics/base.py

 from abc import ABCMeta, abstractmethod
 
 
-class Axes(object):
+class Entity(object):
 
-	__metaclass__ = ABCMeta
+	"""Renderable and movable object.
 
-	@abstractmethod
-	def __init__(self, pos=(0, 0, 0), rot=None, cylinder_radius=0.05):
-		self._actor = None
-
-	@property
-	def actor(self):
-		return self._actor
-
-
-class Body(object):
-
-	"""
-	Abstract class. Not coupled (at all) with VTK or any other graphics library
+	It has position and orientation. The underlying object is :attr:`actor`,
+	which connects to the real entity handled by the graphics library in use.
 
 	"""
 
 	adapter = None
 
 	@abstractmethod
-	def __init__(self, center, rot):
-		self._position = center
+	def __init__(self, pos, rot):
+		self._position = pos
 		self._rotation = rot
-		self._color = None
 		self._actor = None
 
 	def set_pose(self, pos, rot):
 	def actor(self):
 		return self._actor
 
+
+class Axes(Entity):
+
+	__metaclass__ = ABCMeta
+
+	@abstractmethod
+	def __init__(self, pos=(0, 0, 0), rot=None, cylinder_radius=0.05):
+		super(Axes, self).__init__(pos, rot)
+
+
+class Body(Entity):
+
+	"""Entity representing a defined body with a given color."""
+
+	__metaclass__ = ABCMeta
+
+	@abstractmethod
+	def __init__(self, center, rot):  # TODO: rename 'center' to 'pos'
+		super(Body, self).__init__(center, rot)
+		self._color = None
+
 	@abstractmethod
 	def get_color(self):
 		return self._color