Add a viewing mode for the spline graph to hide spline handles
Signed-off-by: Jason Anderson-Young <jase.w.andersonyoung@gmail.com>
Change-Id: I7cb6d3a2f01b2d46a22b5cb0e2b022b1e114d87a
diff --git a/frc971/control_loops/python/path_edit.py b/frc971/control_loops/python/path_edit.py
index 437b242..0a944e1 100755
--- a/frc971/control_loops/python/path_edit.py
+++ b/frc971/control_loops/python/path_edit.py
@@ -47,6 +47,7 @@
# add default spline for testing purposes
# init editing / viewing modes and pointer location
self.mode = Mode.kPlacing
+ self.previous_mode = Mode.kPlacing
self.mousex = 0
self.lastx = 0
self.mousey = 0
@@ -192,6 +193,9 @@
for multispline in self.multisplines:
for i, point in enumerate(multispline.staged_points):
draw_px_x(cr, point[0], point[1], self.pxToM(2))
+ if len(self.multisplines) != 0 and self.multisplines[0].getSplines(
+ ): #still in testing
+ self.draw_splines(cr)
elif self.mode == Mode.kEditing:
if len(self.multisplines) != 0 and self.multisplines[0].getSplines(
):
@@ -479,6 +483,11 @@
self.active_multispline_index = self.multisplines.index(
multispline)
+ elif self.mode == Mode.kViewing:
+
+ if self.control_point_index == None:
+ self.drag_start = (event.x, event.y)
+
self.queue_draw()
def do_motion_notify_event(self, event):
@@ -496,12 +505,13 @@
multispline.update_lib_spline()
self.graph.schedule_recalculate(self.multisplines)
- if self.mode == Mode.kEditing and self.drag_start != None and self.control_point_index == None:
+ if self.drag_start != None and self.control_point_index == None:
+ if self.mode == Mode.kEditing or self.mode == Mode.kViewing:
- self.zoom_transform.translate(event.x - self.lastx,
- event.y - self.lasty)
- self.lastx = event.x
- self.lasty = event.y
+ self.zoom_transform.translate(event.x - self.lastx,
+ event.y - self.lasty)
+ self.lastx = event.x
+ self.lasty = event.y
self.queue_draw()