def draw_map_from_file(self, filename): with open(filename, 'r') as f: for line in f: if line[0] != '#': line.strip() coord_list = line.split(' ') x_1, y_1, x_2, y_2 = [float(num) for num in coord_list] line_item = QtGui.QGraphicsLineItem(x_1, y_1, x_2, y_2) line_item.setZValue(10) self.scene().addItem(line_item) self.line_item_map.append(line_item) line = mod.get_line_dict(x_1, y_1, x_2, y_2) self.line_map.append(line)
def draw_map_from_file(self, filename): with open(filename, 'r') as f: for line in f: if line[0] != '#': line.strip() coord_list = line.split(' ') x_1, y_1, x_2, y_2 = [float(num) for num in coord_list] line_item = QtGui.QGraphicsLineItem(x_1, y_1, x_2, y_2) line_item.setZValue(10) self.scene().addItem(line_item) self.line_item_map.append(line_item) line = mod.get_line_dict(x_1, y_1, x_2, y_2) self.line_map.append(line)
def draw_polygon(self, x, y, num_edges, diameter, angle): poly = QtGui.QPolygonF() vertices = [] for i in range(num_edges): theta = i * 2 * math.pi / num_edges x_v = x + diameter / 2.0 * math.cos(theta) y_v = y + diameter / 2.0 * math.sin(theta) poly.append(QtCore.QPointF(x_v, y_v)) vertices.append((x_v, y_v)) obstacle = QtGui.QGraphicsPolygonItem(poly, scene=self.scene()) obstacle.setZValue(10) obs_color = QtGui.QColor(220, 220, 220) obstacle.setBrush(obs_color) self.obstacle_items.append(obstacle) # Add lines making up polygon to line map for ind, vert in enumerate(vertices): x_1, y_1 = vert x_2, y_2 = vertices[ind - 1] line = mod.get_line_dict(x_1, y_1, x_2, y_2) self.line_map.append(line)
def draw_polygon(self, x, y, num_edges, diameter, angle): poly = QtGui.QPolygonF() vertices = [] for i in range(num_edges): theta = i * 2*math.pi/num_edges x_v = x + diameter/2.0 * math.cos(theta) y_v = y + diameter/2.0 * math.sin(theta) poly.append(QtCore.QPointF(x_v, y_v)) vertices.append((x_v, y_v)) obstacle = QtGui.QGraphicsPolygonItem(poly, scene=self.scene()) obstacle.setZValue(10) obs_color = QtGui.QColor(220, 220, 220) obstacle.setBrush(obs_color) self.obstacle_items.append(obstacle) # Add lines making up polygon to line map for ind, vert in enumerate(vertices): x_1, y_1 = vert x_2, y_2 = vertices[ind-1] line = mod.get_line_dict(x_1, y_1, x_2, y_2) self.line_map.append(line)