添加摄像头IP+3D显示添加一个是否显示线条备注的形参

This commit is contained in:
2026-03-04 20:39:29 +08:00
parent 7ea779acc8
commit e7e6693798
2 changed files with 10 additions and 5 deletions

View File

@ -6,6 +6,7 @@
# @File : 3D.py
# @Desc : 界面上的线条3D显示
'''
from re import T
import sys
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout
@ -85,9 +86,10 @@ class Target3DWidget(QWidget):
("f", 100, 2.75, 1, 'purple')
]
def __init__(self, index: int = 0, parent=None):
def __init__(self, anno: bool, index: int = 0, parent=None):
super().__init__(parent)
self._index = index
self._anno = anno
self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint) # 无边框窗口
self.setAttribute(Qt.WA_TranslucentBackground) # 设置背景为透明
@ -109,7 +111,8 @@ class Target3DWidget(QWidget):
# 绘制3D形状
self.draw_target_shape()
# 添加标注
self.add_annotations()
if self._anno:
self.add_annotations()
# ========== 核心修改X/Y/Z轴统一为1cm单位 ==========
self.ax.set_xlabel('X')
@ -165,7 +168,7 @@ def show(x: int, y: int, w: int, h: int, index: int):
raise ValueError("index must be 0 or 1")
app = QApplication(sys.argv)
window = Target3DWidget(index)
window = Target3DWidget(anno=True, index=index)
window.setGeometry(x, y, w, h)
window.show()
sys.exit(app.exec())
@ -173,5 +176,5 @@ def show(x: int, y: int, w: int, h: int, index: int):
# ----------测试接口----------
if __name__ == '__main__':
show(100, 100, 700, 700, 0) # 显示A视图窗口
# show(100, 100, 700, 700, 1) # 显示B视图窗口
# show(100, 100, 700, 700, 0) # 显示A视图窗口
show(100, 100, 700, 700, 1) # 显示B视图窗口