Add a cursor to graph in Spline UI
This connects the graph to the robot that gets drawn along the spline.
As you move your mouse along the spline, you can see what part of the
graph it affects, and when you move your mouse along the graph, the
robot traces out the path of the spline.
This change lays the groundwork for being able to apply velocity limits
at specific points along the spline in the future.
Change-Id: I7d850f27fb25104c0b9d678b6701d5d74a11b05f
Signed-off-by: Ravago Jones <ravagojones@gmail.com>
diff --git a/frc971/control_loops/python/path_edit.py b/frc971/control_loops/python/path_edit.py
index 8573257..f0b84a4 100755
--- a/frc971/control_loops/python/path_edit.py
+++ b/frc971/control_loops/python/path_edit.py
@@ -36,6 +36,7 @@
self.points = Points()
self.graph = Graph()
+ self.graph.cursor_watcher = self
self.set_vexpand(True)
self.set_hexpand(True)
# list of multisplines
@@ -232,6 +233,14 @@
# if the mouse is close enough, draw the robot to show its width
if result and result.fun < 2:
self.draw_robot_at_point(cr, distance_spline, result.x)
+ self.graph.place_cursor(result.x[0])
+ elif self.graph.cursor:
+ x = self.graph.find_cursor()
+ self.draw_robot_at_point(cr, distance_spline, x)
+
+ # clear the cursor each draw so that it does not persist
+ # after you move off the spline
+ self.graph.cursor = None
def export_json(self, file_name):
self.path_to_export = os.path.join(