Skip to content

Commit 3113613

Browse files
authored
Merge pull request #186 from CWRUbotix/carp-animation
Carp animation
2 parents 4aa5c6b + 7fe1208 commit 3113613

11 files changed

+124
-2
lines changed
121 KB
Loading
424 KB
Loading
424 KB
Loading
424 KB
Loading
424 KB
Loading
423 KB
Loading

src/surface/gui/gui/operator_app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from gui.widgets.heartbeat import HeartbeatWidget
88
from gui.widgets.ip_widget import IPWidget
99
from gui.widgets.logger import Logger
10+
from gui.widgets.tabs.carp_model_tab import CarpModelTab
1011
from gui.widgets.tabs.general_debug_tab import GeneralDebugTab
1112
from gui.widgets.tabs.photosphere_tab import PhotosphereTab
1213
from gui.widgets.tabs.shipwreck import ShipwreckTab
@@ -22,7 +23,7 @@ class OperatorApp(App):
2223
def __init__(self) -> None:
2324
super().__init__('operator_gui_node')
2425

25-
self.setWindowTitle('Operator GUI - CWRUbotix ROV 2024')
26+
self.setWindowTitle('Operator GUI - CWRUbotix ROV 2025')
2627

2728
# Main tab
2829
main_tab = QWidget()
@@ -56,6 +57,7 @@ def __init__(self) -> None:
5657
self.tabs.addTab(main_tab, 'Main')
5758
self.tabs.addTab(GeneralDebugTab(), 'General Debug')
5859
self.tabs.addTab(PhotosphereTab(), 'Photosphere')
60+
self.tabs.addTab(CarpModelTab(), 'Carp Model')
5961
self.shipwreck_tab = ShipwreckTab()
6062
self.tabs.addTab(self.shipwreck_tab, SHIPWRECK_TEXT)
6163
self.tabs.currentChanged.connect(self.changed_tabs)
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
from pathlib import Path
2+
3+
from ament_index_python.packages import get_package_share_directory
4+
from PyQt6.QtCore import Qt, QTimer
5+
from PyQt6.QtGui import QColor, QFont, QPainter, QPen, QPixmap
6+
from PyQt6.QtWidgets import QComboBox, QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWidget
7+
8+
START_YEAR = 2016
9+
END_YEAR = 2025
10+
11+
12+
class AnimationLabel(QLabel):
13+
def __init__(self, year_list: list[int], interval: int = 2000) -> None:
14+
super().__init__()
15+
self.year = START_YEAR
16+
self.year_list = year_list
17+
18+
map_path = str(
19+
Path(get_package_share_directory('gui')) / 'images' / 'illinois_river_map_0.png'
20+
)
21+
map_pixmap = QPixmap(map_path)
22+
self.setPixmap(
23+
map_pixmap.scaled(
24+
750,
25+
750,
26+
Qt.AspectRatioMode.KeepAspectRatio,
27+
Qt.TransformationMode.SmoothTransformation,
28+
)
29+
)
30+
31+
self.timer = QTimer(self)
32+
self.timer.timeout.connect(self.update_frame)
33+
self.timer.start(interval) # in milliseconds
34+
35+
def update_frame(self) -> None:
36+
region = 0
37+
for year in self.year_list:
38+
if self.year >= year:
39+
region += 1
40+
41+
map_path = str(
42+
Path(get_package_share_directory('gui'))
43+
/ 'images'
44+
/ ('illinois_river_map_' + str(region) + '.png')
45+
)
46+
47+
map_pixmap = QPixmap(map_path)
48+
49+
painter = QPainter(map_pixmap)
50+
pen = QPen(QColor('black'))
51+
painter.setFont(QFont('Arial', 50))
52+
painter.setPen(pen)
53+
painter.drawText(20, 60, str(self.year))
54+
painter.end()
55+
self.setPixmap(
56+
map_pixmap.scaled(
57+
750,
58+
750,
59+
Qt.AspectRatioMode.KeepAspectRatio,
60+
Qt.TransformationMode.SmoothTransformation,
61+
)
62+
)
63+
64+
self.year += 1
65+
self.year = min(self.year, END_YEAR)
66+
67+
68+
class CarpAnimation(QWidget):
69+
def __init__(self) -> None:
70+
super().__init__()
71+
72+
self.root_layout = QHBoxLayout()
73+
74+
input_layout = QVBoxLayout()
75+
76+
self.dropdown_list: list[QComboBox] = []
77+
78+
for _ in range(5):
79+
dropdown = QComboBox()
80+
# List of years [2016,2025]
81+
options = list(map(str, range(2016, 2026)))
82+
options.append('9999')
83+
dropdown.addItems(options)
84+
dropdown.setCurrentIndex(len(options) - 1)
85+
self.dropdown_list.append(dropdown)
86+
input_layout.addWidget(dropdown)
87+
88+
self.setLayout(self.root_layout)
89+
90+
show_button = QPushButton('Show Animation', None)
91+
92+
input_layout.addWidget(show_button)
93+
input_layout.addStretch()
94+
95+
self.root_layout.addLayout(input_layout)
96+
97+
show_button.clicked.connect(self.show_animation)
98+
99+
self.animation_label: AnimationLabel | None = None
100+
101+
def show_animation(self) -> None:
102+
self.root_layout.removeWidget(self.animation_label)
103+
self.year_list = [int(dropdown.currentText()) for dropdown in self.dropdown_list]
104+
self.animation_label = AnimationLabel(self.year_list)
105+
self.root_layout.addWidget(self.animation_label)

src/surface/gui/gui/widgets/livestream_header.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self) -> None:
1313
root_layout = QHBoxLayout()
1414
self.setLayout(root_layout)
1515

16-
logo_path = str(Path(get_package_share_directory('gui')) / 'images' / 'CWRUbotix Logo.png')
16+
logo_path = str(Path(get_package_share_directory('gui')) / 'images' / 'cwrubotix_logo.png')
1717

1818
logo_pixmap = QPixmap(logo_path)
1919

0 commit comments

Comments
 (0)