Ejemplo n.º 1
0
			def on_button_press(self, gdkevent):
				event_point = (gdkevent.x, gdkevent.y)
				route_drawn_i = len(self.layer.visible_objs)
				for route_drawn in reversed(self.layer.visible_objs):
					route_drawn_i -= 1		# interating in reverse
		
					# Step thru the (explicit) points.
					point_i = 0
					for point in route_drawn.explicit_pts:
						if points_close(point, event_point):
							path = (route_drawn.index, point_i)
							#print "Hit route point:", path
							if path == self.layer.selected_path:
								self.dragged_obj_i = route_drawn_i
								self.layer.containing_map.set_cursor(gtk.gdk.FLEUR)
							else:
								self.layer.select(path)
								self.layer.redraw()		# FIXME: really needed?
							return True
						point_i += 1

					# Nope? Then see whether one of the phantom points was hit.
					for point in route_drawn.phantom_points:
						x, y, point_i = point
						if points_close(point, event_point):
							print "Hit phantom route point"
		
							# Create a new point at the mouse position.
							lat, lon = self.layer.containing_map.unproject_point(*event_point)
							point = GpxRoutePoint(lat, lon)
							point.name = "Guide Point"
							point.type = "guide"
							point.src = "User Placed"
		
							print "New point comes after:", point_i
							route = self.layer.layer_objs[route_drawn.index]
							route[point_i].route_shape = []
							route.insert(point_i+1, point)
							route_drawn.explicit_pts.insert(point_i+1, event_point)
		
							self.layer.select((route_drawn.index, point_i+1))	# select new point
							self.layer.containing_map.set_cursor(gtk.gdk.FLEUR)
							self.dragged_obj_i = route_drawn_i
							return True

					# Nope? See if the whole thing was hit.
					points = route_drawn.explicit_pts
					i = 0
					limit = len(points) - 1
					while i < limit:
						if pykarta.geometry.plane_lineseg_distance(event_point, points[i], points[i+1]) < 10:
							self.layer.select((route_drawn.index,))
							return True
						i += 1

				return False
			def on_button_press(self, gdkevent):
				event_point = (gdkevent.x, gdkevent.y)
				for obj in reversed(self.layer.visible_objs):
					if points_close(obj.projected_point, event_point):
						del self.layer.layer_objs[obj.index]
						#self.layer.set_stale()
						return True
				return False
Ejemplo n.º 3
0
 def on_button_press(self, gdkevent):
     event_point = (gdkevent.x, gdkevent.y)
     for obj in reversed(self.layer.visible_objs):
         if points_close(obj.projected_point, event_point):
             del self.layer.layer_objs[obj.index]
             #self.layer.set_stale()
             return True
     return False
Ejemplo n.º 4
0
			def on_button_press(self, gdkevent):
				event_point = (gdkevent.x, gdkevent.y)
				for route_drawn in reversed(self.layer.visible_objs):
					for point in route_drawn.explicit_pts:
						if points_close(point, event_point):
							print "Deleting route %d" % route_drawn.index
							del self.layer.layer_objs[route_drawn.index]
							#self.layer.set_stale()
							return True
				return False
			def on_button_press(self, gdkevent):
				event_point = (gdkevent.x, gdkevent.y)
				for obj in reversed(self.layer.visible_objs):
					if points_close(obj.projected_point, event_point):
						if self.layer.selected_path is not None and self.layer.selected_path[0] == obj.index:
							self.dragged_obj = obj
							self.layer.containing_map.set_cursor(gtk.gdk.FLEUR)
						else:
							self.layer.select((obj.index,))
						return True
				return False
Ejemplo n.º 6
0
 def on_button_press(self, gdkevent):
     event_point = (gdkevent.x, gdkevent.y)
     for obj in reversed(self.layer.visible_objs):
         if points_close(obj.projected_point, event_point):
             if self.layer.selected_path is not None and self.layer.selected_path[
                     0] == obj.index:
                 self.dragged_obj = obj
                 self.layer.containing_map.set_cursor(gtk.gdk.FLEUR)
             else:
                 self.layer.select((obj.index, ))
             return True
     return False
			def on_button_press(self, gdkevent):
				if self.zoom >= self.layer.point_show_level:
					event_point = (gdkevent.x, gdkevent.y)
					for segment in self.layer.visible_objs:
						point_i = 0
						for point in segment.projected_points:
							if points_close(point, event_point):
								print "Hit track point"
								self.layer.select((segment.track_i, segment.trackseg_i, point_i))
								return True
							point_i += 1
				return False
Ejemplo n.º 8
0
 def on_button_press(self, gdkevent):
     if self.zoom >= self.layer.point_show_level:
         event_point = (gdkevent.x, gdkevent.y)
         for segment in self.layer.visible_objs:
             point_i = 0
             for point in segment.projected_points:
                 if points_close(point, event_point):
                     print "Hit track point"
                     self.layer.select(
                         (segment.track_i, segment.trackseg_i,
                          point_i))
                     return True
                 point_i += 1
     return False