Commits

German Larrain committed 06bf634

replaced 'get_actor' method with 'actor' property in graphics.Body, graphics.Axes and simulator.SimulatedObject.

Comments (0)

Files changed (9)

ars/graphics/__init__.py

 	def __init__(self, position=(0,0,0), cylinder_radius=0.05):
 		self._actor = None
 
-	def get_actor(self):
+	@property
+	def actor(self):
 		return self._actor
 
 class Body:
 		self._rotation = rotation
 		self.adapter._update_body(self._actor, position, rotation)
 
-	def get_actor(self):
+	@property
+	def actor(self):
 		return self._actor
 
 	@abstractmethod

ars/graphics/adapters.py

 		self.ren.SetBackground(background_color)
 
 	def add_object(self, object_):
-		self.ren.AddActor(object_.get_actor())
+		self.ren.AddActor(object_.actor)
 
 	def start_window(self, on_idle_callback=None, on_reset_callback=None, on_key_press_callback=None):
 		# TODO: refactor according to restart_window(), reset() and the desired behavior

ars/model/simulator/__init__.py

 		"""Returns a dictionary with each object actor indexed by its name"""
 		actors = {}
 		for key_ in self._objects:
-			actor = self._objects[key_].get_actor()
+			actor = self._objects[key_].actor
 			if actor:
 				actors[key_] = actor
 		return actors
 	def set_name(self, name):
 		self._name = name
 
-	def get_actor(self):
+	@property
+	def actor(self):
 		return self._actor
 
 	def has_actor(self):

bin/IROS/example1_bouncing_balls-no_data.py

 		ball2 = self.sim.add_sphere(0.1, (2,1.5 + 0.1,2), 1.0)
 		ball3 = self.sim.add_sphere(0.1, (3,2 + 0.1,3), 1.0)
 		
-		print(self.sim.get_object(ball1).get_actor().set_color((1,1,1)))
-		print(self.sim.get_object(ball2).get_actor().set_color((0,0.8,0.8)))
-		print(self.sim.get_object(ball3).get_actor().set_color((0.7,0.5,0)))
+		print(self.sim.get_object(ball1).actor.set_color((1,1,1)))
+		print(self.sim.get_object(ball2).actor.set_color((0,0.8,0.8)))
+		print(self.sim.get_object(ball3).actor.set_color((0.7,0.5,0)))
 
 if __name__ == '__main__':
 	sim_program = Example1NoData()

bin/IROS/example2_conical_pendulum.py

 							mut.add3(self.OFFSET, self.JOINT2_ANCHOR),
 							self.JOINT2_AXIS)
 		
-		#self.sim.get_object(box).get_actor().set_color(cts.COLOR_RED)
-		self.sim.get_object(pole).get_actor().set_color(cts.COLOR_YELLOW)
-		self.sim.get_object(arm).get_actor().set_color(cts.COLOR_NAVY)
+		#self.sim.get_object(box).actor.set_color(cts.COLOR_RED)
+		self.sim.get_object(pole).actor.set_color(cts.COLOR_YELLOW)
+		self.sim.get_object(arm).actor.set_color(cts.COLOR_NAVY)
 		
 		self.box = box
 		self.pole = pole

bin/IROS/example3_speed_profile.py

 	def __init__(self):
 		"""Constructor, calls the superclass constructor first"""
 		VehicleWithArm.__init__(self)
-		self.sim.get_object(self.chassis).get_actor().set_color((0.8,0,0))
+		self.sim.get_object(self.chassis).actor.set_color((0.8,0,0))
 
 		self.r1_angle_rate_prev = 0.0
 		self.r2_angle_rate_prev = 0.0
 		self.sim.get_object(chassis).offset_by_position(offset)
 
 		# test
-		#print(self.sim.get_object(wheelR).get_actor().set_color((0.8,0,0)))
+		#print(self.sim.get_object(wheelR).actor.set_color((0.8,0,0)))
 
 
 	def go_forwards(self):

bin/VehicleWithArm.py

 							self.sim.get_object(link2),
 							r2_anchor, cts.Z_AXIS)
 
-		self.sim.get_object(chassis).get_actor().set_color(cts.COLOR_RED)
-		self.sim.get_object(link1).get_actor().set_color(cts.COLOR_YELLOW)
-		self.sim.get_object(link2).get_actor().set_color(cts.COLOR_NAVY)
+		self.sim.get_object(chassis).actor.set_color(cts.COLOR_RED)
+		self.sim.get_object(link1).actor.set_color(cts.COLOR_YELLOW)
+		self.sim.get_object(link2).actor.set_color(cts.COLOR_NAVY)
 
 		self.chassis = chassis
 		self.wheelR = wheelR

tests/graphics_adapters.py

 	vtk_matrix3.SetElement(2, 2, 0.60)
 	
 	#box.bodyObject.SetUserMatrix(vtk_matrix) # concatenates the transform
-	sphere.get_actor().PokeMatrix(vtk_matrix1) # sets the final transform
-	cone.get_actor().PokeMatrix(vtk_matrix2)
-	axes1.get_actor().PokeMatrix(vtk_matrix3)
-	caps.get_actor().PokeMatrix(vtk_matrix3)
+	sphere.actor.PokeMatrix(vtk_matrix1) # sets the final transform
+	cone.actor.PokeMatrix(vtk_matrix2)
+	axes1.actor.PokeMatrix(vtk_matrix3)
+	caps.actor.PokeMatrix(vtk_matrix3)
 	
 	gAdapter.start_window()