Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color by instance group preference saving #1999

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def closeEvent(self, event):
prefs["color predicted"] = self.state["color predicted"]
prefs["trail shade"] = self.state["trail_shade"]
prefs["share usage data"] = self.state["share usage data"]
prefs["distinctly_color"] = self.state["distinctly_color"]

# Save preferences.
prefs.save()
Expand Down Expand Up @@ -298,6 +299,8 @@ def labels(self, value):
def _initialize_gui(self):
"""Creates menus, dock windows, starts timers to update gui state."""

self.state["distinctly_color"] = prefs["distinctly_color"]

self._create_color_manager()
self._create_video_player()
self.statusBar()
Expand Down Expand Up @@ -655,7 +658,7 @@ def prev_vid():
key="palette",
)

distinctly_color_options = ("instance_groups", "instances", "nodes", "edges")
distinctly_color_options = ("instance groups", "instances", "nodes", "edges")

add_submenu_choices(
menu=viewMenu,
Expand All @@ -665,7 +668,7 @@ def prev_vid():
)

self.state["palette"] = prefs["palette"]
self.state["distinctly_color"] = "instances"
self.state["distinctly_color"] = prefs["distinctly_color"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed this line to use the saved preference.


viewMenu.addSeparator()

Expand Down
2 changes: 1 addition & 1 deletion sleap/gui/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def get_item_color(

return (128, 128, 128)

if self.distinctly_color == "instance_groups" and parent_instance:
if self.distinctly_color == "instance groups" and parent_instance:

if parent_frame is None and parent_instance:
parent_frame = parent_instance.frame
Expand Down
2 changes: 1 addition & 1 deletion sleap/gui/dataviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def item_to_data(self, obj, item: InstanceGroup):

def get_item_color(self, instance_group: InstanceGroup, key: str):
color_manager = self.context.app.color_manager
if color_manager.distinctly_color == "instance_groups" and key == "name":
if color_manager.distinctly_color == "instance groups" and key == "name":

# Get the RecordingSession
state = self.context.state
Expand Down
7 changes: 4 additions & 3 deletions sleap/io/visuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def _plot_instance_cv(
)

if self.show_edges:
for (src, dst) in instance.skeleton.edge_inds:
for src, dst in instance.skeleton.edge_inds:
# Get points for the nodes connected by this edge
src_x, src_y = points_array[src]
dst_x, dst_y = points_array[dst]
Expand Down Expand Up @@ -542,8 +542,9 @@ def save_labeled_video(
for what instance/node/edge
palette: SLEAP color palette to use. Options include: "alphabet", "five+",
"solarized", or "standard". Only used if `color_manager` is None.
distinctly_color: Specify how to color instances. Options include: "instances",
"edges", and "nodes". Only used if `color_manager` is None.
distinctly_color: Specify how to color instances. Options include:
"instance groups", "instances", "edges", and "nodes". Only used if
`color_manager` is None.
gui_progress: Whether to show Qt GUI progress dialog.

Returns:
Expand Down
1 change: 1 addition & 0 deletions sleap/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Preferences(object):
"medium step size": 10,
"large step size": 100,
"color predicted": False,
"distinctly_color": "instances",
"propagate track labels": True,
"palette": "standard",
"bold lines": False,
Expand Down
Loading