Skip to content
Snippets Groups Projects
Commit 37933354 authored by R. Keoni Garcia's avatar R. Keoni Garcia
Browse files

Merge remote-tracking branch 'origin/feature-graph-selection' into develop

parents 2d3f2f76 c2f3723a
Branches
No related tags found
No related merge requests found
......@@ -419,24 +419,15 @@ class Main(QtGui.QMainWindow):
self.scene_manager.newProbePoint.connect(update_probe_point)
def update_probe_polygon(uuid, points, layerlist=self.behaviorLayersList):
selected_uuids = list(layerlist.current_selected_uuids())
LOG.debug("selected UUID set is {0!r:s}".format(selected_uuids))
# if the layer list doesn't have any selected UUIDs, use the one passed in
if len(selected_uuids) <= 0:
selected_uuids = [uuid]
# if we have more than two uuids, just plot the very first one
elif len(selected_uuids) > 2 :
selected_uuids = selected_uuids[0:1]
# now we must have 1 or 2 UUIDs in our list
top_uuids = list(self.document.current_visible_layers(2))
LOG.debug("top visible UUID is {0!r:s}".format(top_uuids))
# TODO, when the plots manage their own layer selection, change this call
# FUTURE, once the polygon is a layer, this will need to change
# set the selection for the probe plot to the top visible layer
self.graphManager.set_layer_selections(*top_uuids)
# update our current plot with the new polygon
polygon_name = self.graphManager.currentPolygonChanged (polygonPoints=points)
polygon_name = self.graphManager.currentPolygonChanged(polygonPoints=points)
# do whatever other updates the scene manager needs
self.scene_manager.on_new_polygon(polygon_name, points)
......
......@@ -302,6 +302,15 @@ class Document(QObject):
return x.uuid
return None
def current_visible_layers(self, max_layers=None):
count = 0
for x in self.current_layer_set:
if x.visible:
count += 1
yield x.uuid
if max_layers is not None and count >= max_layers:
break
def select_layer_set(self, layer_set_index):
"""
change the selected layer set, 0..N (typically 0..3), cloning the old set if needed
......
......@@ -131,6 +131,11 @@ class ProbeGraphManager (QObject) :
return self.graphs[self.selected_graph_index].setPolygon (polygonPoints)
def set_layer_selections(self, *uuids):
"""Set the UUIDs for the current graph.
"""
return self.graphs[self.selected_graph_index].set_layer_selections(*uuids)
def handle_tab_change (self, ) :
"""deal with the fact that the tab changed in the tab widget
"""
......@@ -298,6 +303,26 @@ class ProbeGraphDisplay (object) :
# Rebuild the plot (stale is used to determine if actual rebuild is needed)
self.rebuildPlot()
def set_layer_selections(self, *layer_uuids):
if len(layer_uuids) > 2:
raise ValueError("Probe graphs can handle a maximum of 2 layers (got %d)", len(layer_uuids))
if len(layer_uuids) >= 1:
xIndex = self.xDropDown.findData(str(layer_uuids[0]))
if xIndex >= 0:
self.xDropDown.setCurrentIndex(xIndex)
self.xSelectedUUID = layer_uuids[0]
else:
LOG.error("Tried to set probe graph to non-existent layer: %s", layer_uuids[0])
if len(layer_uuids) >= 2:
yIndex = self.xDropDown.findData(str(layer_uuids[1]))
if yIndex >= 0:
self.yDropDown.setCurrentIndex(yIndex)
self.ySelectedUUID = layer_uuids[1]
else:
LOG.error("Tried to set probe graph to non-existent layer: %s", layer_uuids[1])
def xSelected (self) :
"""The user selected something in the X layer list.
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment