Skip to content

Commit

Permalink
Use color names as display color
Browse files Browse the repository at this point in the history
In the display mode showing all available rods, it is now attempted to use the color given by the rod class.
If matplotlib does not support a color name, a different color is chosen.
  • Loading branch information
a-niem committed Jul 11, 2024
1 parent 9f700dd commit 7d4cf2b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions RodTracker/src/RodTracker/ui/rodimagewidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,10 +1302,20 @@ def extract_rods(self, data: pd.DataFrame, color: str) -> None:
ident.setObjectName(f"rn_{no}_{rod_color}")
ident.seen = seen
if len(colors_present) > 1:
color_idx = np.where(colors_present == rod_color)[0][0]
ident._rod_color = QtGui.QColor.fromRgbF(
*_colors[color_idx]
).getRgb()[:-1]
try:
rgb_color = QtGui.QColor.fromRgbF(
*mpl.colors.to_rgba(rod_color, alpha=1.0)
).getRgb()[:-1]
except ValueError as e:
_logger.warning(
f"Unknown color for 2D display!\n{e.args}\n"
f"Using a different color instead."
)
color_idx = np.where(colors_present == rod_color)[0][0]
rgb_color = QtGui.QColor.fromRgbF(
*_colors[color_idx]
).getRgb()[:-1]
ident._rod_color = rgb_color
# Rods should not be interactable if all are displayed
ident.setDisabled(True)
new_rods.append(ident)
Expand Down

0 comments on commit 7d4cf2b

Please sign in to comment.