Skip to content

Commit 815d520

Browse files
committed
Bug Fix Closed Loop
1 parent 64c3316 commit 815d520

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/software/thunderscope/gl/graphics/gl_polygon.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def __init__(
2121
outline_color: QtGui.QColor = Colors.DEFAULT_GRAPHICS_COLOR,
2222
fill_color: Optional[QtGui.QColor] = None,
2323
line_width: float = LINE_WIDTH,
24+
closed: bool = False
2425
) -> None:
2526
"""Initialize the GLPolygon
2627
@@ -30,6 +31,7 @@ def __init__(
3031
:param outline_color: The color of the polygon's outline
3132
:param fill_color: The color used to fill the polygon, or None if no fill
3233
:param line_width: The line width of the polygon's outline
34+
:param closed: whether the GLPolygon is closed or not
3335
"""
3436
super().__init__(
3537
parent_item=parent_item,
@@ -39,6 +41,7 @@ def __init__(
3941
)
4042

4143
self.set_points(points)
44+
self.is_closed = closed
4245

4346
def set_points(self, points: list[tuple[float, float]]) -> None:
4447
"""Update the point data representing the polygon to display.
@@ -62,7 +65,8 @@ def _update_shape_data(self) -> None:
6265
if not self.points:
6366
return
6467

65-
vertices = [(point[0], point[1], 0) for point in self.points + [self.points[0]]]
68+
render_points = self.points + [self.points[0]] if self.is_closed else self.points
69+
vertices = [(point[0], point[1], 0) for point in render_points]
6670
self.setData(pos=vertices)
6771

6872
if self.fill_graphic:

src/software/thunderscope/gl/graphics/gl_robot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import numpy as np
1212

13-
1413
ROBOT_SHADER = shaders.ShaderProgram(
1514
"robot-shader",
1615
[

src/software/thunderscope/gl/layers/gl_draw_polygon_obstacle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, name: str, friendly_io: ProtoUnixIO) -> None:
3939
self.rendering_polygons = ObservableList(self._graphics_changed)
4040

4141
# The current polygon being edited (not visible yet)
42-
self.current_polygon = GLPolygon(parent_item=self, line_width=2)
42+
self.current_polygon = GLPolygon(parent_item=self, line_width=2, closed=True)
4343

4444
self.can_double_click = False
4545

@@ -75,7 +75,7 @@ def __push_polygon_to_list(self):
7575
self.points.clear()
7676

7777
self.rendering_polygons.append(self.current_polygon)
78-
self.current_polygon = GLPolygon(parent_item=self, line_width=2)
78+
self.current_polygon = GLPolygon(parent_item=self, line_width=2, closed=True)
7979

8080
def __add_one_point(self, point: Point) -> None:
8181
"""Adding one points to a polygon

0 commit comments

Comments
 (0)