在GraphicsWindow的特定位置插入GLViewWidget

时间:2019-07-29 11:44:11

标签: python qt pyqt vtk pyqtgraph

我目前正在构建一个同时显示列表和图像的GUI,我也想同时显示当前周围环境的点云,并能够访问该GUI中的所有内容。

我尝试过VTK可视化工具,问题是渲染循环会阻塞其他所有内容,直到窗口关闭。

我目前正在尝试使用PyQtGraph的GLViewWidget,但无法将其插入所需的位置,并且无法处理GUI中的其他项目。

我必须将窗口指定为父窗口,才能看到窗口小部件。但是它跳到了窗口的左上角。

    def init_gui(self, win_height=800, win_width=1800):
        #self.w = self
        #self.w.scene().sigMouseClicked.connect(self.mousePressEvent) #mouseMoveEvent
        #self.w.scene().sigMouseMoved.connect(self.mouseMoveEvent)
        pg.setConfigOptions(imageAxisOrder='row-major')
        pg.setConfigOption('background', 'w')
        pg.setConfigOption('foreground', 'k')
        self.w = pg.GraphicsWindow(size=(win_width,win_height), border=True)
        self.list_imgs       = QtGui.QListWidget()
        self.list_marks      = QtGui.QListWidget()
        self.btn_Del_Mark    = QtGui.QPushButton('Del Mark')
        self.btn_MarkPed     = QtGui.QPushButton('Mark ped')
        self.btn_MarkCycl    = QtGui.QPushButton('Mark cyc')
        self.btn_MarkCar     = QtGui.QPushButton('Mark car')
        self.btn_Rst         = QtGui.QPushButton('Reset JSON')
        self.btn_Save        = QtGui.QPushButton('Save JSON')
        self.btn_Next        = QtGui.QPushButton('Next ->')
        self.btn_Back        = QtGui.QPushButton('Back <-')
        self.btn_Predict_2D  = QtGui.QPushButton('Predict 2D')
        self.btn_Predict_3D  = QtGui.QPushButton('Predict 3D')
        self.btn_Pipeline    = QtGui.QPushButton('Run Pipeline')
        self.lbl_list1       = QtGui.QLabel()
        self.lbl_list2       = QtGui.QLabel()

        self.lbl_img_path    = QtGui.QLabel()
        self.lbl_list1.setText("Images")
        self.lbl_list2.setText("Markings")
        self.w.setWindowTitle('Visualizing traffic situation')
        self.vb = pg.ViewBox()
        self.vb.setAspectLocked()
        self.img = pg.ImageItem()
        self.vb.addItem(self.img)
        self.vb.invertY(True)
        layout = pg.GraphicsLayout()
        self.lbl_list1.setAlignment(QtCore.Qt.AlignCenter)
        self.lbl_list2.setAlignment(QtCore.Qt.AlignCenter)
        #self.qgwidg = QtGui.Qg
        self.graph_3d        = gl.GLViewWidget(parent=self.w)
        self.graph_3d.opts['distance'] = 20
        self.graph_3d.show()
        self.graph_3d.setParent(self.w)
        #self.graph_3d.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        self.graph_3d.setMinimumSize(800, 400)

        offset_grp_1 = 2
        offset_grp_2 = 3
        offset_grp_3 = 4

        layout.addItem(self.vb                             , 1,  9, 6,  20)
        layout.addItem(self.proxyWidget(self.graph_3d, width=(600), height=(500)), 10, 3, 10, 20)
        layout.addItem(self.proxyWidget(self.lbl_list1     , width=(int(1./10.*win_width)), height=(int(0.9/20.*win_height))),  0,1,1,1)   
        layout.addItem(self.proxyWidget(self.lbl_list2     , width=(int(1./10.*win_width)), height=(int(0.9/20.*win_height))),  0,2,1,1)  
        layout.addItem(self.proxyWidget(self.lbl_img_path  , height=(int(0.9/20.*win_height))),  0,3,1,20)  
        layout.addItem(self.proxyWidget(self.list_imgs     , width=(int(1./10.*win_width))),  1,1,20,1)   
        layout.addItem(self.proxyWidget(self.list_marks    , width=(int(1./10.*win_width))),  1,2,20,1)   
        layout.addItem(self.proxyWidget(self.btn_Next      , width=(int(1./10.*win_width))),  0+offset_grp_1,0)
        layout.addItem(self.proxyWidget(self.btn_Back      , width=(int(1./10.*win_width))),  1+offset_grp_1,0)
        layout.addItem(self.proxyWidget(self.btn_Predict_2D, width=(int(1./10.*win_width))),  2+offset_grp_2,0)
        layout.addItem(self.proxyWidget(self.btn_Predict_3D, width=(int(1./10.*win_width))),  3+offset_grp_2,0)
        layout.addItem(self.proxyWidget(self.btn_Pipeline  , width=(int(1./10.*win_width))),  4+offset_grp_2,0)
        layout.addItem(self.proxyWidget(self.btn_MarkPed   , width=(int(1./10.*win_width))),  5+offset_grp_3,0)
        layout.addItem(self.proxyWidget(self.btn_MarkCycl  , width=(int(1./10.*win_width))),  6+offset_grp_3,0)
        layout.addItem(self.proxyWidget(self.btn_MarkCar   , width=(int(1./10.*win_width))),  7+offset_grp_3,0)
        layout.addItem(self.proxyWidget(self.btn_Del_Mark  , width=(int(1./10.*win_width))),  8+offset_grp_3,0)
        layout.addItem(self.proxyWidget(self.btn_Rst       , width=(int(1./10.*win_width))),  9+offset_grp_3,0)
        layout.addItem(self.proxyWidget(self.btn_Save      , width=(int(1./10.*win_width))),  10+offset_grp_3,0)
        self.w.addItem(layout)
        self.setUp_pen_types()
        self.qt_connections()

结果看起来像这样-尽管我想将渲染的3D场景(具有黑色背景色)放置在2D图像小部件下方。

GUI

0 个答案:

没有答案
相关问题