rgb_preview_panel.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. """
  2. RGB Preview Panel
  3. Panel for displaying RGB camera feed (coming soon feature).
  4. """
  5. from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy
  6. from PyQt5.QtCore import Qt
  7. from PyQt5.QtGui import QFont, QPainter, QColor, QPen
  8. from ui.widgets.panel_header import PanelHeader
  9. from ui.widgets.coming_soon_overlay import ComingSoonOverlay
  10. class RGBPreviewPanel(QWidget):
  11. """
  12. Panel for RGB camera preview.
  13. Currently shows "COMING SOON" placeholder for future camera integration.
  14. """
  15. def __init__(self, parent=None):
  16. super().__init__(parent)
  17. self.init_ui()
  18. def init_ui(self):
  19. """Initialize the panel UI."""
  20. # Set size policy to expand equally
  21. self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  22. layout = QVBoxLayout(self)
  23. layout.setContentsMargins(0, 0, 0, 0)
  24. layout.setSpacing(0)
  25. # Main panel container with card styling
  26. self.setStyleSheet("""
  27. QWidget {
  28. background-color: white;
  29. border: 1px solid #ddd;
  30. }
  31. """)
  32. # Header
  33. header = QWidget()
  34. header.setFixedHeight(25)
  35. header.setStyleSheet("background-color: #3498db;")
  36. header_layout = QHBoxLayout(header)
  37. header_layout.setContentsMargins(10, 0, 10, 0)
  38. header_layout.setSpacing(0)
  39. title = QLabel("RGB Preview")
  40. title.setStyleSheet("color: white; font-weight: bold; font-size: 16px;")
  41. status_indicator = QWidget()
  42. status_indicator.setFixedSize(10, 10)
  43. status_indicator.setStyleSheet("background-color: #27ae60; border-radius: 5px;")
  44. header_layout.addWidget(title)
  45. header_layout.addStretch()
  46. header_layout.addWidget(status_indicator)
  47. # Content area
  48. content = QWidget()
  49. content.setMinimumSize(250, 250)
  50. # content.setMaximumSize(400, 400)
  51. content.setStyleSheet("""
  52. background-color: #2c3e50;
  53. border: 1px solid #34495e;
  54. border-top: none;
  55. """)
  56. content_layout = QVBoxLayout(content)
  57. content_layout.setAlignment(Qt.AlignCenter)
  58. content_layout.setSpacing(5)
  59. # Main text container
  60. text_container = QWidget()
  61. text_layout = QVBoxLayout(text_container)
  62. text_layout.setAlignment(Qt.AlignCenter)
  63. text_layout.setSpacing(2)
  64. # Live RGB Feed text
  65. feed_label = QLabel("RGB Live Feed")
  66. feed_label.setFont(QFont("Arial", 14))
  67. feed_label.setStyleSheet("color: #bdc3c7;")
  68. feed_label.setAlignment(Qt.AlignCenter)
  69. text_layout.addWidget(feed_label)
  70. # Resolution info
  71. res_label = QLabel("1920x1080 @ 30fps\n(Coming soon)")
  72. res_label.setFont(QFont("Arial", 11))
  73. res_label.setStyleSheet("color: #7f8c8d;")
  74. res_label.setAlignment(Qt.AlignCenter)
  75. text_layout.addWidget(res_label)
  76. content_layout.addWidget(text_container)
  77. layout.addWidget(header)
  78. layout.addWidget(content, 1)
  79. # Tooltip
  80. self.setToolTip("Live RGB camera feed - Coming with hardware integration")
  81. class CrosshairPreview(QWidget):
  82. """Widget showing crosshair placeholder for camera targeting."""
  83. def __init__(self, parent=None):
  84. super().__init__(parent)
  85. self.setAttribute(Qt.WA_TransparentForMouseEvents)
  86. def paintEvent(self, event):
  87. """Draw crosshair overlay."""
  88. painter = QPainter(self)
  89. painter.setRenderHint(QPainter.Antialiasing)
  90. # Draw crosshair
  91. pen = QPen(QColor("#e74c3c"), 2)
  92. painter.setPen(pen)
  93. center_x = self.width() // 2
  94. center_y = self.height() // 2
  95. # Horizontal line
  96. painter.drawLine(center_x - 20, center_y, center_x + 20, center_y)
  97. # Vertical line
  98. painter.drawLine(center_x, center_y - 20, center_x, center_y + 20)
  99. # Center circle
  100. painter.drawEllipse(center_x - 3, center_y - 3, 6, 6)