Ejemplo n.º 1
0
    def __init__(self, user_gesture, standard_gesture, parent=None):
        super(ResultDialog, self).__init__(parent=parent)
        self.setupUi(self)
        self.standard_timer = QTimer()
        self.standard_timer.timeout.connect(self.get_standard_frame)
        self.user_timer = QTimer()
        self.user_timer.timeout.connect(self.get_user_frame)
        self.user_gesture = user_gesture
        self.standard_gesture = standard_gesture
        self.standard_timer.start(int(1000 / 10))
        self.user_timer.start(int(1000 / 10))
        self.standard_it = iter(self.standard_gesture)
        self.user_it = iter(self.user_gesture)

        self.pauseButton.clicked.connect(self.start_pause)
        self.is_paused = False
        self.user_graph = HandModel()
        self.standard_graph = HandModel()

        self.user_pose_container = QWidget.createWindowContainer(
            self.user_graph.scatter_graph)
        self.userLayout.addWidget(self.user_pose_container)
        self.setLayout(self.userLayout)

        self.standard_pose_container = QWidget.createWindowContainer(
            self.standard_graph.scatter_graph)
        self.standardLayout.addWidget(self.standard_pose_container)
        self.setLayout(self.standardLayout)

        dists = self.get_dtw()

        self.set_dist(dists)
        self.tipLabel.setEnabled(True)
        self.set_tips(dists)
Ejemplo n.º 2
0
    def __init__(self, user_gesture, standard_gesture, type_id, parent=None):
        super(ResultDialog, self).__init__(parent)
        self.setupUi(self)

        self.time_warped = False
        self.type_id = type_id
        self.user_stopped = False
        self.standard_stopped = False
        self.standard_timer = QTimer()
        self.standard_timer.timeout.connect(self.get_standard_frame)
        self.user_timer = QTimer()
        self.user_timer.timeout.connect(self.get_user_frame)
        self.user_gesture = user_gesture
        self.standard_gesture = standard_gesture
        self.standard_timer.start(int(1000 / 10))
        self.user_timer.start(int(1000 / 10))
        self.standard_it = iter(self.standard_gesture)
        self.user_it = iter(self.user_gesture)

        self.is_paused = False
        self.pauseButton.clicked.connect(self.start_pause)
        self.backButton.clicked.connect(self.close)
        self.saveButton.clicked.connect(self.save)

        # if res[]
        self.user_graph = HandPose()
        self.standard_graph = HandPose()

        self.user_pose_container = QWidget.createWindowContainer(
            self.user_graph.scatter_graph)
        self.userLayout.addWidget(self.user_pose_container)
        self.setLayout(self.userLayout)

        self.standard_pose_container = QWidget.createWindowContainer(
            self.standard_graph.scatter_graph)
        self.standardLayout.addWidget(self.standard_pose_container)
        self.setLayout(self.standardLayout)

        self.dist_too_large = False

        t1 = time.time()
        self.res = get_dtw(self.user_gesture, self.standard_gesture)
        t2 = time.time()
        print('calc time: {}'.format(t2 - t1))
        self.set_dist(self.res)
        self.tipLabel.setEnabled(True)
        self.set_tips(self.res)
        self.timeWarpingButton.toggled.connect(self.warp)
        if self.dist_too_large:
            self.timeWarpingButton.setDisabled(True)
Ejemplo n.º 3
0
    def load_ui(self):
        loader = QUiLoader()
        path = os.path.join(os.path.dirname(__file__), "form.ui")
        ui_file = QFile(path)
        ui_file.open(QFile.ReadOnly)
        self.ui = loader.load(ui_file, self)
        ui_file.close()

        #        self.chartView = QtCharts.QChartView()
        #        self.chartView.setMinimumWidth(450)
        #        self.graphicsView = self.ui.findChild(QGraphicsView, "graphicsView")

        # graphics
        self.tab_summary = self.ui.findChild(QWidget, "tab_summary")

        #        QtDataVisualization.QAbstract3DGraph

        self.scatter3d = QtDataVisualization.Q3DScatter()
        self.container = QWidget.createWindowContainer(self.scatter3d)
        self.container.setMinimumWidth(450)

        self.scatterProxy = QtDataVisualization.QScatterDataProxy()
        self.scatterSeries = QtDataVisualization.QScatter3DSeries(
            self.scatterProxy)

        self.scatter3d.axisX().setTitle("x")
        self.scatter3d.axisY().setTitle("y")
        self.scatter3d.axisZ().setTitle("z")

        self.scatter3d.addSeries(self.scatterSeries)

        self.find_widgets()
Ejemplo n.º 4
0
    def __init__(self):
        __metaclass__ = ABCMeta
        super().__init__()

        self._stylesheet_filepath = Path(__file__).parent / ".." / "blender_stylesheet.qss"
        self._settings_key_geometry = "Geometry"
        self._settings_key_maximized = "IsMaximized"
        self._settings_key_full_screen = "IsFullScreen"
        self._settings_key_window_group_name = "MainWindow"

        # QApplication
        if self._stylesheet_filepath.exists():
            self.setStyleSheet(self._stylesheet_filepath.read_text())

        QApplication.setWindowIcon(self._get_application_icon())

        # Blender Window
        self._hwnd = self._get_application_hwnd()
        self._blender_window = QWindow.fromWinId(self._hwnd)
        self.blender_widget = QWidget.createWindowContainer(self._blender_window)
        self.blender_widget.setWindowTitle("Blender")

        # Variables
        self.should_close = False

        # Runtime
        self._set_window_geometry()
        self.just_focused = False
        self.focusObjectChanged.connect(self._on_focus_object_changed)
Ejemplo n.º 5
0
    def __init__(self, g_type, parent=None):
        super(TargetGestureLearningDialog, self).__init__(parent=parent)
        self.setupUi(self)
        self.startButton.clicked.connect(self.start)
        self.stopButton.clicked.connect(self.stop)
        self.backButton.clicked.connect(self.back)

        self.startButton.setDisabled(False)
        self.backButton.setDisabled(False)
        self.stopButton.setDisabled(True)

        self.standard_gesture = g_type
        self.standard_it = iter(self.standard_gesture)

        self.is_running = False
        self.pose_timer = QTimer()
        self.model_timer = QTimer()
        self.standard_graph = HandModel()
        self.standard_pose_container = QWidget.createWindowContainer(
            self.standard_graph.scatter_graph)
        self.standardGestureLayout.addWidget(self.standard_pose_container)
        self.setLayout(self.standardGestureLayout)

        self.q = Queue()
        self.worker = Process(target=run, args=(self.q, ))
        self.worker.start()
        # print('sc: ', os.getpid())
        self.pose_timer.start(int(1000 / 30))
        self.model_timer.start(int(1000 / 20))
        self.pose_timer.timeout.connect(self.get_pose)
        self.model_timer.timeout.connect(self.get_model_frame)
        self.recorded_data = []
Ejemplo n.º 6
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.window3d = Window()

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(QWidget.createWindowContainer(
            self.window3d, self))
        mainLayout.setContentsMargins(0, 0, 0, 0)

        bottomLayout = QHBoxLayout()
        bottomLayout.setContentsMargins(20, 0, 20, 20)
        bottomLayout.addStretch()
        openHoodCB = QCheckBox("Open Hood", self)
        openHoodCB.toggled.connect(self.window3d.toggleHood)
        bottomLayout.addWidget(openHoodCB)
        bottomLayout.addStretch()
        openLeftDoorCB = QCheckBox("Open Left Door", self)
        openLeftDoorCB.toggled.connect(self.window3d.toggleLeftDoor)
        bottomLayout.addWidget(openLeftDoorCB)
        bottomLayout.addStretch()
        openRightDoorCB = QCheckBox("Open Right Door", self)
        openRightDoorCB.toggled.connect(self.window3d.toggleRightDoor)
        bottomLayout.addWidget(openRightDoorCB)
        bottomLayout.addStretch()
        self.toggleCameraAnimationPB = QPushButton("Play", self)
        self.toggleCameraAnimationPB.setCheckable(True)
        self.toggleCameraAnimationPB.toggled.connect(
            self.toggleCameraAnimation)
        bottomLayout.addWidget(self.toggleCameraAnimationPB)
        bottomLayout.addStretch()
        mainLayout.addLayout(bottomLayout)

        self.setLayout(mainLayout)
        self.resize(1024, 768)
Ejemplo n.º 7
0
 def setSource(self, url):
     if isinstance(url, string_types):
         url = QUrl.fromLocalFile(os.path.abspath(url))
     self.view.setSource(url)
     size = self.view.size()
     self.widget = QWidget.createWindowContainer(self.view, self)
     self.setCentralWidget(self.widget)
     self.setFocusProxy(self.widget)
     self.resize(size)
Ejemplo n.º 8
0
 def __init__(self):
     super(MainWindow, self).__init__()
     hBoxLayout = QHBoxLayout(self)
     self.plainTextEdit = QPlainTextEdit()
     self.plainTextEdit.setMinimumWidth(400)
     self.plainTextEdit.setReadOnly(True)
     hBoxLayout.addWidget(self.plainTextEdit)
     self.renderWindow = RenderWindow(QSurfaceFormat())
     container = QWidget.createWindowContainer(self.renderWindow)
     container.setMinimumSize(QSize(400, 400))
     hBoxLayout.addWidget(container)
Ejemplo n.º 9
0
    def __init__(self) -> None:
        super().__init__()
        self.setMinimumSize(640, 480)
        self._build_menus()
        self.view = Qt3DExtras.Qt3DWindow()
        self.view.defaultFrameGraph().setClearColor(QColor(0, 0, 0))
        self.widget = QWidget.createWindowContainer(self.view)
        self.sphere_vc = SphereVC(self.view)
        self.setCentralWidget(self.widget)

        self._textures = AlbedoTextureMapper()
Ejemplo n.º 10
0
 def __init__(self):
     super(MainWindow, self).__init__()
     hBoxLayout = QHBoxLayout(self)
     self.plainTextEdit = QPlainTextEdit()
     self.plainTextEdit.setMinimumWidth(400)
     self.plainTextEdit.setReadOnly(True)
     hBoxLayout.addWidget(self.plainTextEdit)
     self.renderWindow = RenderWindow(QSurfaceFormat())
     container = QWidget.createWindowContainer(self.renderWindow)
     container.setMinimumSize(QSize(400, 400))
     hBoxLayout.addWidget(container)
Ejemplo n.º 11
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.setupUi(self)
     self.startButton.clicked.connect(self.start)
     self.standardCaptureButton.clicked.connect(self.standard_capture)
     self.exitButton.clicked.connect(self.exit)
     self.front_icon = np.load('src/Grad/MainWindow/front_icon.npy')
     self.handgraph = HandModel(self.front_icon)
     self.poseContainer = QWidget.createWindowContainer(
         self.handgraph.scatter_graph)
     self.poseLayout.addWidget(self.poseContainer)
     self.setLayout(self.poseLayout)
Ejemplo n.º 12
0
 def __init__(self, parent):
     super(StudentMainWindow, self).__init__(parent=parent)
     self.setupUi(self)
     self.freeTrainingButton.clicked.connect(self.free_training)
     self.comparedLearningButton.clicked.connect(self.compared_learning)
     self.historyButton.clicked.connect(self.history_data)
     self.exitButton.clicked.connect(self.exit)
     icon_path = os.path.join(os.path.dirname(__file__), 'front_icon.npy')
     self.hand_pose = HandPose(path=icon_path)
     self.poseContainer = QWidget.createWindowContainer(
         self.hand_pose.scatter_graph)
     self.poseLayout.addWidget(self.poseContainer)
     self.setLayout(self.poseLayout)
Ejemplo n.º 13
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.setWindowTitle('Qt DataVisualization 3D Bars')

        self.bars = QtDataVisualization.Q3DBars()

        self.columnAxis = QtDataVisualization.QCategory3DAxis()
        self.columnAxis.setTitle('Columns')
        self.columnAxis.setTitleVisible(True)
        self.columnAxis.setLabels(['Column1', 'Column2'])
        self.columnAxis.setLabelAutoRotation(30)

        self.rowAxis = QtDataVisualization.QCategory3DAxis()
        self.rowAxis.setTitle('Rows')
        self.rowAxis.setTitleVisible(True)
        self.rowAxis.setLabels(['Row1', 'Row2'])
        self.rowAxis.setLabelAutoRotation(30)

        self.valueAxis = QtDataVisualization.QValue3DAxis()
        self.valueAxis.setTitle('Values')
        self.valueAxis.setTitleVisible(True)
        self.valueAxis.setRange(0, 5)

        self.bars.setRowAxis(self.rowAxis)
        self.bars.setColumnAxis(self.columnAxis)
        self.bars.setValueAxis(self.valueAxis)

        self.series = QtDataVisualization.QBar3DSeries()
        self.arrayData = [[1, 2], [3, 4]]
        self.series.dataProxy().addRows(dataToBarDataArray(self.arrayData))

        self.bars.setPrimarySeries(self.series)

        self.container = QWidget.createWindowContainer(self.bars)

        if not self.bars.hasContext():
            print("Couldn't initialize the OpenGL context.")
            sys.exit(-1)

        camera = self.bars.scene().activeCamera()
        camera.setYRotation(22.5)

        geometry = QGuiApplication.primaryScreen().geometry()
        size = geometry.height() * 3 / 4
        self.container.setMinimumSize(size, size)

        self.container.setSizePolicy(QSizePolicy.Expanding,
                                     QSizePolicy.Expanding)
        self.container.setFocusPolicy(Qt.StrongFocus)
        self.setCentralWidget(self.container)
Ejemplo n.º 14
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.setWindowTitle('Qt DataVisualization 3D Bars')

        self.bars = QtDataVisualization.Q3DBars()

        self.columnAxis = QtDataVisualization.QCategory3DAxis()
        self.columnAxis.setTitle('Columns')
        self.columnAxis.setTitleVisible(True)
        self.columnAxis.setLabels(['Column1', 'Column2'])
        self.columnAxis.setLabelAutoRotation(30)

        self.rowAxis = QtDataVisualization.QCategory3DAxis()
        self.rowAxis.setTitle('Rows')
        self.rowAxis.setTitleVisible(True)
        self.rowAxis.setLabels(['Row1', 'Row2'])
        self.rowAxis.setLabelAutoRotation(30)

        self.valueAxis = QtDataVisualization.QValue3DAxis()
        self.valueAxis.setTitle('Values')
        self.valueAxis.setTitleVisible(True)
        self.valueAxis.setRange(0, 5)

        self.bars.setRowAxis(self.rowAxis)
        self.bars.setColumnAxis(self.columnAxis)
        self.bars.setValueAxis(self.valueAxis)

        self.series = QtDataVisualization.QBar3DSeries()
        self.arrayData = [[1, 2], [3, 4]]
        self.series.dataProxy().addRows(dataToBarDataArray(self.arrayData))

        self.bars.setPrimarySeries(self.series)

        self.container = QWidget.createWindowContainer(self.bars)

        if not self.bars.hasContext():
            print("Couldn't initialize the OpenGL context.")
            sys.exit(-1)

        camera = self.bars.scene().activeCamera()
        camera.setYRotation(22.5)

        geometry = QGuiApplication.primaryScreen().geometry()
        size = geometry.height() * 3 / 4
        self.container.setMinimumSize(size, size)

        self.container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.container.setFocusPolicy(Qt.StrongFocus)
        self.setCentralWidget(self.container)
Ejemplo n.º 15
0
    def __init__(self, parent):
        super(TeacherMainWindow, self).__init__(parent=parent)
        self.setupUi(self)
        icon_path = os.path.join(os.path.dirname(__file__), 'front_icon.npy')
        self.hand_pose = HandPose(path=icon_path)
        self.poseContainer = QWidget.createWindowContainer(
            self.hand_pose.scatter_graph)
        self.poseLayout.addWidget(self.poseContainer)
        self.setLayout(self.poseLayout)

        self.standardRecordButton.clicked.connect(self.standard_rec)
        self.tmplMgrButton.clicked.connect(self.fingering_manage)
        self.dataViewerButton.clicked.connect(self.data_viewer)
        self.addUserButton.clicked.connect(self.add_user)
        self.exitButton.clicked.connect(self.on_exit)
Ejemplo n.º 16
0
 def __init__(self):
     QWidget.__init__(self)
     self.resize(1440, 900)
     # 设置主窗口标题
     self.setWindowTitle('Test')
     self.layout = QGridLayout()
     self.handgraph = HandModel()
     self.container = QWidget.createWindowContainer(
         self.handgraph.scatter_graph)
     self.layout.addWidget(self.container)
     self.btn = QPushButton('sss')
     self.layout.addWidget(self.btn)
     self.setLayout(self.layout)
     self.handgraph.test()
     pass
Ejemplo n.º 17
0
    def __init__(self, gesture, parent=None):
        super(TmplViewDialog, self).__init__(parent)
        self.setupUi(self)
        self.gesture = gesture
        self.timer = QTimer()
        self.timer.timeout.connect(self.get_frame_show)

        self.ctrlButton.clicked.connect(self.start_pause)
        self.exitButton.clicked.connect(self.close)
        self.is_paused = False
        self.graph = HandPose()

        self.pose_container = QWidget.createWindowContainer(
            self.graph.scatter_graph)
        self.gridLayout.addWidget(self.pose_container)
        self.setLayout(self.gridLayout)
        self.timer.start(int(1000 / 10))

        self.gesture_iter = iter(self.gesture)
Ejemplo n.º 18
0
    def __init__(self, data, type_id, parent=None):
        super(ComparedLearningDialog, self).__init__(parent)
        self.setupUi(self)
        self.cw = CaptureWidget(parent=self)
        # self.sig_close.emit()
        self.standard_gesture = data
        self.type_id = type_id
        self.userGestureLayout.addWidget(self.cw)
        self.cw.sig_stop.connect(self.on_stop)

        self.model_timer = QTimer()
        self.standard_it = iter(self.standard_gesture)
        self.standard_graph = HandPose()
        self.standard_pose_container = QWidget.createWindowContainer(
            self.standard_graph.scatter_graph)
        self.standardGestureLayout.addWidget(self.standard_pose_container)
        self.setLayout(self.standardGestureLayout)
        self.model_timer.start(int(1000 / 20))
        self.model_timer.timeout.connect(self.get_model_frame)
Ejemplo n.º 19
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.setWindowTitle("Molecular dynamics visualization")
        self.scatter = QtDataVisualization.Q3DScatter()
        self.container = QWidget.createWindowContainer(self.scatter)
        self.scatter.setAspectRatio(1.0)
        self.scatter.setHorizontalAspectRatio(1.0)

        # Setting of plot limits
        self.scatter.axisX().setRange(0.0, 1.0)
        self.scatter.axisY().setRange(0.0, 1.0)
        self.scatter.axisZ().setRange(0.0, 1.0)

        if (not self.scatter.hasContext()):
            msgBox = QMessageBox()
            msgBox.setText("Couldn't initialze the OpenGL context.")
            msgBox.exec()
            sys.exit(-1)

        screenSize = self.scatter.screen().size()
        self.container.setMinimumSize(
            QSize(screenSize.width() / 2.0,
                  screenSize.height() / 1.5))
        self.container.setMaximumSize(screenSize)
        self.container.setSizePolicy(QSizePolicy.Expanding,
                                     QSizePolicy.Expanding)
        self.container.setFocusPolicy(Qt.StrongFocus)

        self.setCentralWidget(self.container)

        self.menu = self.menuBar()
        self.file_menu = self.menu.addMenu("File")

        self.open_action = QAction("Open file", self)
        self.open_action.setShortcut("Ctrl+O")
        self.quit_action = QAction("Quit", self)
        self.quit_action.setShortcut("Ctrl+Q")

        self.file_menu.addAction(self.open_action)
        self.open_action.triggered.connect(self.openFileDialog)
        self.file_menu.addAction(self.quit_action)
        self.quit_action.triggered.connect(self.exit_app)
Ejemplo n.º 20
0
    def __init__(self, parent=None):
        super().__init__(parent)
        ui = self.__load_ui(parent)
        self.setCentralWidget(ui)
        self.resize(ui.frameSize())

        self.setWindowTitle('Qt DataVisualization 3D Bars')

        self.bars = BarsMap3D()

        self.container = QWidget.createWindowContainer(self.bars)

        if not self.bars.hasContext():
            print("Couldn't initialize the OpenGL context.")
            sys.exit(-1)

        # self.container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.container.setFocusPolicy(Qt.StrongFocus)
        self.container.setParent(ui.widget)

        self.__ui = ui
Ejemplo n.º 21
0
    def __init__(self):
        super().__init__()
        self.setWindowTitle("pppGCS : Plural Python Parrot GCS")

        self.DeviceInfo = ppDeviceInfoWidget()
        self.DeviceList = ppDiscoverWidget()
        self.leftcol_layout = QVBoxLayout()
        self.leftcol_layout.addWidget(self.DeviceInfo)
        self.leftcol_layout.addWidget(self.DeviceList)

        self.VideoViewer = ppVideoWidget()

        self.tabs = QTabWidget()
        self.tabs.addTab(self.VideoViewer, "Video stream")
        self.mapview = QQuickView()
        self.mapcontainer = QWidget.createWindowContainer(self.mapview, self)
        url = QUrl("map.qml")
        self.mapview.setSource(url)
        self.mapview.show()
        self.tabs.addTab(self.mapcontainer, "map view")

        self.FlightInfo = ppFlightInfoWidget()
        self.ControlInfo = ppControlWidget()
        self.rightcol_layout = QVBoxLayout()
        self.rightcol_layout.addWidget(self.tabs)
        self.lowrightcol_layout = QHBoxLayout()
        self.lowrightcol_layout.addWidget(self.FlightInfo)
        self.lowrightcol_layout.addWidget(self.ControlInfo)
        self.rightcol_layout.addLayout(self.lowrightcol_layout)

        self.layout = QHBoxLayout()
        self.layout.addLayout(self.leftcol_layout)
        self.layout.addLayout(self.rightcol_layout)

        self.setLayout(self.layout)

        self.DeviceList.DeviceChanged.connect(self.on_device_changed)
Ejemplo n.º 22
0
 def __init__(self) -> None:
     self.view = Qt3DExtras.Qt3DWindow()
     self._configure_view()
     self.widget = QWidget.createWindowContainer(self.view)
     self.sphere_mgr = SphereVC(self.view)
     self.albedo_mapper = AlbedoTextureMapper()
Ejemplo n.º 23
0
    def __init__(self, args, parent=None):
        super().__init__(parent)
        ##############################################################################
        # UI初期化処理
        self.ui = MainWindowUi.loader(os.path.join(os.getcwd(), 'ui/main.ui'))
        self.setWindowTitle('self.viewer test')
        self.setCentralWidget(self.ui.widgets)

        self.view = Qt3DExtras.Qt3DWindow()
        self.view.defaultFrameGraph().setClearColor(QtGui.QColor(0, 0, 0))
        self.container = QWidget.createWindowContainer(self.view)

        screen_size = self.view.screen().size()
        self.ui.viewer.addWidget(self.container)
        self.container.setMinimumSize(QtCore.QSize(400, 600))
        self.container.setMaximumSize(screen_size)

        # QSize screenSize = self.view -> screen() -> size();
        # container -> setMinimumSize(QSize(200, 100));
        # container -> setMaximumSize(screenSize);

        # vLayout -> setAlignment(Qt: : AlignTop);
        # hLayout -> addWidget(container, 1);
        # hLayout -> addLayout(vLayout);

        # input_aspect = Qt3DInput.QInputAspect()
        # self.view.registerAspect(input_aspect)

        # root entity
        self.root_entity: Qt3DCore.QEntity = Qt3DCore.QEntity()

        # draw grid and axis
        """
        self.x_axis: Qt3DRender.QGeometry = Qt3DRender.QGeometry(self.root_entity)
        x_axis_pos: QtCore.QByteArray = QtCore.QByteArray()
        x_axis_pos.append(0)
        x_axis_pos.append(0)
        x_axis_pos.append(0)
        x_axis_pos.append(10)
        x_axis_pos.append(0)
        x_axis_pos.append(0)
        x_axis_buf: Qt3DRender.QBuffer = Qt3DRender.QBuffer(self.x_axis)
        x_axis_buf.setData(x_axis_pos)

        x_axis_attr: Qt3DRender.QAttribute = Qt3DRender.QAttribute(self.x_axis)
        x_axis_attr.setVertexBaseType(Qt3DRender.QAttribute.Float)
        x_axis_attr.setVertexSize(3)
        x_axis_attr.setAttributeType(Qt3DRender.QAttribute.VertexAttribute)
        x_axis_attr.setBuffer(x_axis_buf)
        x_axis_attr.setByteStride(3)
        x_axis_attr.setCount(2)
        self.x_axis.addAttribute(x_axis_attr)
        """

        test_mtl = Qt3DExtras.QTextureMaterial(self.root_entity)

        self.test = Qt3DCore.QEntity(self.root_entity)
        self.test_mesh: Qt3DExtras.QTorusMesh = Qt3DExtras.QTorusMesh()
        self.test_mesh.setRadius(5)
        self.test_mesh.setMinorRadius(1)
        self.test_mesh.setRings(100)
        self.test_mesh.setSlices(20)
        self.test_tr = Qt3DCore.QTransform()
        self.test_tr.setTranslation(QtGui.QVector3D(0, 0, 0))
        # test_tr.setScale3D()
        self.test.addComponent(self.test_mesh)
        self.test.addComponent(self.test_tr)
        self.test.addComponent(self.test_mtl)

        # camera entity
        camera_entity: Qt3DRender.QCamera = self.view.camera()

        camera_entity.lens().setPerspectiveProjection(45.0, 16.0 / 9.0, 0.1, 1000.0)
        camera_entity.setPosition(QtGui.QVector3D(0, 0, 20.0))
        camera_entity.setUpVector(QtGui.QVector3D(0, 1, 0))
        camera_entity.setViewCenter(QtGui.QVector3D(0, 0, 0))

        light_entity = Qt3DCore.QEntity(self.root_entity)
        light = Qt3DRender.QPointLight(light_entity)
        light.setColor("white")
        light.setIntensity(1)
        light_entity.addComponent(light)

        light_transform = Qt3DCore.QTransform(light_entity)
        light_transform.setTranslation(camera_entity.position())
        light_entity.addComponent(light_transform)

        # for camera controls
        cam_controller = Qt3DExtras.QFirstPersonCameraController(self.root_entity)
        cam_controller.setCamera(camera_entity)

        # set root object of the scene
        self.view.setRootEntity(self.root_entity)
Ejemplo n.º 24
0
    def __init__(self, ui_fil, parent=None):
        super(MainWindow, self).__init__(parent)
        self.ui_file = QFile(ui_fil)
        self.ui_file.open(QFile.ReadOnly)
        self.loader = QUiLoader()
        self.loader.setLanguageChangeEnabled(True)
        self.window = self.loader.load(self.ui_file)
        self.window.setGeometry(50, 50, 860, 640)
        self.window.setWindowIcon(QIcon('icons/icons8-wi-fi-64.png'))
        self.ui_file.close()

        self.trans = QTranslator()
        self.trans.load('lang/pl_PL.qm')
        self.conn_baudrates = [
            "9600", "115200", "300", "1200", "2400", "4800", "14400", "19200",
            "31250", "38400", "57600"
        ]
        self.conn_boards = ["ESP32", "ESP8266"]

        self.widget_tab = self.window.findChild(QTabWidget, 'tabWidget')
        self.widget_tab.setIconSize(QSize(36, 36))
        self.widget_tab.setTabIcon(0, QIcon('icons/icons8-automatic-64.png'))
        self.widget_tab.setTabIcon(1, QIcon('icons/icons8-bar-chart-50.png'))
        self.widget_tab.setTabIcon(2, QIcon('icons/icons8-menu-64.png'))
        self.widget_tab.setTabIcon(3, QIcon('icons/icons8-timeline-64.png'))
        self.widget_tab.setTabIcon(4, QIcon('icons/icons8-bluetooth-50.png'))
        self.widget_tab.setTabIcon(5, QIcon('icons/icons8-console-64.png'))

        self.lang_combo_box = self.window.findChild(QComboBox,
                                                    'lang_combo_box')
        self.lang_combo_box.addItem("English")
        self.lang_combo_box.addItem("Polski")
        self.lang_combo_box.currentTextChanged.connect(self.change_language)
        self.serial_port_box = self.window.findChild(QComboBox,
                                                     'serial_port_box')
        self.baud_rate_box = self.window.findChild(QComboBox, 'baud_rate_box')
        self.select_board_box = self.window.findChild(QComboBox,
                                                      'select_board_box')
        self.scan_time_edit = self.window.findChild(QTimeEdit,
                                                    'scan_time_edit')
        self.wifi_scan_box = self.window.findChild(QCheckBox, 'wifi_scan_box')
        self.blue_scan_box = self.window.findChild(QCheckBox, 'blue_scan_box')
        self.save_data_check = self.window.findChild(QCheckBox,
                                                     'save_data_check')
        self.connection_status_edit = self.window.findChild(
            QLineEdit, 'connection_status_edit')
        self.start_button = self.window.findChild(QPushButton, 'start_button')
        self.stop_button = self.window.findChild(QPushButton, 'stop_button')
        self.stop_button.setEnabled(False)
        self.vertical_wifi_layout = self.window.findChild(
            QVBoxLayout, 'verticalLayout_5')
        self.wifi_list_view = self.window.findChild(QListWidget,
                                                    'wifi_list_view')
        self.wifi_list_view.setIconSize(QSize(64, 64))
        self.vertical_timeline_layout = self.window.findChild(
            QVBoxLayout, 'verticalLayout_7')
        self.blue_list_view = self.window.findChild(QListWidget,
                                                    'blue_list_view')
        self.blue_list_view.setIconSize(QSize(64, 64))
        self.console_logging_check = self.window.findChild(
            QCheckBox, 'console_logging_check')
        self.console_autoscroll_check = self.window.findChild(
            QCheckBox, 'console_autoscroll_check')
        self.console_text_edit = self.window.findChild(QTextEdit,
                                                       'console_text_edit')

        self.select_board_box.activated[str].connect(self.change_board)

        #Settings tab
        for i in self.conn_baudrates:
            self.baud_rate_box.addItem(i)
        for i in self.conn_boards:
            self.select_board_box.addItem(i)
        self.connection_status_edit.setText('Not connected')
        self.connection_status_edit.setStyleSheet(
            "background: red; color: white; font-size: 14px; border-width: 1px; \
            border-style: solid; border-radius: 2px; border-color: red;")

        thread1 = ReadSerialPortsThread.ReadSerialPortsThread(self)
        thread1.add_serial_port.connect(
            lambda p: self.serial_port_box.addItem(p))
        thread1.remove_serial_port.connect(
            lambda p: self.serial_port_box.removeItem(
                self.serial_port_box.findText(p)))
        thread1.start()
        thread2 = MakeSerialConnection.MakeSerialConnection(self)
        thread4 = WriteToDatabase.WriteToDatabase(self)

        self.serial_port_box.currentTextChanged.connect(thread2.get_curr_port)
        self.baud_rate_box.activated[str].connect(thread2.get_curr_baud)
        self.select_board_box.activated[str].connect(thread2.get_curr_board)
        self.scan_time_edit.timeChanged.connect(thread2.get_curr_time)
        self.start_button.clicked.connect(thread2.start)
        self.stop_button.clicked.connect(thread2.stop_serial_communication)
        self.wifi_scan_box.clicked.connect(thread2.get_wifi_check)
        self.blue_scan_box.clicked.connect(thread2.get_blue_check)
        self.save_data_check.clicked.connect(thread2.enable_saving_to_db)
        self.save_data_check.clicked.connect(thread4.enable_saving_data_func)
        self.lang_combo_box.currentTextChanged.connect(
            lambda s: thread2.get_current_lang(s))

        thread2.baud_box_state.connect(
            lambda b: self.baud_rate_box.setEnabled(b))
        thread2.port_box_state.connect(
            lambda b: self.serial_port_box.setEnabled(b))
        thread2.board_box_state.connect(
            lambda b: self.select_board_box.setEnabled(b))
        thread2.time_edit_state.connect(
            lambda b: self.scan_time_edit.setEnabled(b))
        thread2.wifi_check_state.connect(
            lambda b: self.wifi_scan_box.setEnabled(b))
        thread2.blue_check_state.connect(
            lambda b: self.blue_scan_box.setEnabled(b))
        thread2.serial_port_placeholder.connect(
            lambda t: self.serial_port_box.addItem(t))
        thread2.serial_port_clear.connect(self.serial_port_box.clear)
        thread2.send_text_signal.connect(
            lambda t: self.console_text_edit.append(t))
        thread2.start_btn_state.connect(
            lambda b: self.start_button.setEnabled(b))
        thread2.stop_btn_state.connect(
            lambda b: self.stop_button.setEnabled(b))
        thread2.conn_stat_text.connect(
            lambda t: self.connection_status_edit.setText(t))
        thread2.conn_stat_style.connect(
            lambda s: self.connection_status_edit.setStyleSheet(s))

        #Wi-Fi Chart tab
        self.chart = QtCharts.QChart()
        self.axis_x = QtCharts.QValueAxis()
        self.axis_y = QtCharts.QValueAxis()

        self.line_series = QtCharts.QLineSeries()
        self.line_series.append(QPoint(0, 0))
        self.chart.setAxisX(self.axis_x, self.line_series)
        self.axis_x.setRange(2400, 2483)
        self.axis_x.setTickCount(10)
        self.axis_x.setMinorTickCount(4)
        self.axis_x.applyNiceNumbers()
        self.axis_x.setTitleText("Frequency [MHz]")
        self.chart.setAxisY(self.axis_y, self.line_series)
        self.axis_y.setRange(-100, -30)
        self.axis_y.applyNiceNumbers()
        self.axis_y.setTickCount(9)
        self.axis_y.setMinorTickCount(4)
        self.axis_y.setTitleText("RSSI [dBm]")
        self.chart.legend().setVisible(True)
        self.chart.legend().setAlignment(Qt.AlignRight)
        self.chart.setBackgroundRoundness(0)
        self.chart_view = QtCharts.QChartView(self.chart)
        self.chart_view.setRenderHint(QPainter.Antialiasing)
        self.vertical_wifi_layout.addWidget(self.chart_view)

        #WiFi List tab
        thread2.clear_wifi_list.connect(self.wifi_list_view.clear)
        thread2.append_wifi_list_item.connect(
            lambda i: self.wifi_list_view.addItem(i))
        thread2.append_wifi_timeline_data.connect(
            lambda d: self.append_data(d))
        thread2.save_wifi_timeline_data.connect(
            lambda t: thread4.update_db_file(t))
        thread2.clear_wifi_series.connect(self.chart.removeAllSeries)
        thread2.add_wifi_series.connect(lambda s: self.chart.addSeries(s))
        thread2.set_axis_x_series.connect(
            lambda s: self.chart.setAxisX(self.axis_x, s))
        thread2.set_axis_y_series.connect(
            lambda s: self.chart.setAxisY(self.axis_y, s))
        thread2.wifi_data_to_func.connect(
            lambda d: thread2.append_wifi_data(d))
        thread2.wifi_data_to_func.connect(
            lambda d: thread2.append_data_to_wifi_graph(d))
        thread2.wifi_data_to_func.connect(
            lambda d: thread2.append_data_to_wifi_timeline(d))
        thread2.blue_data_to_func.connect(
            lambda d: thread2.append_blue_data(d))

        #Wi-Fi Timeline tab
        self.wifi_channels_occupancy_array = []
        self.wifi_channels_timestamps = []
        self.deleted_empty_vals = False
        self.freeze_graph_bool_val = False
        self.last_item = 0
        self.graph_item_color = QColor(255, 195, 0)

        self.bars = QtDataVisualization.Q3DBars()
        self.column_axis = QtDataVisualization.QCategory3DAxis()
        self.column_axis.setTitle('Channels')
        self.column_axis.setTitleVisible(True)
        self.column_axis.setLabels([
            'Channel 1', 'Channel 2', 'Channel 3', 'Channel 4', 'Channel 5',
            'Channel 6', 'Channel 7', 'Channel 8', 'Channel 9', 'Channel 10',
            'Channel 11', 'Channel 12', 'Channel 13'
        ])
        self.column_axis.setLabelAutoRotation(45)
        self.column_axis.setAutoAdjustRange(True)
        self.row_axis = QtDataVisualization.QCategory3DAxis()
        self.row_axis.setTitle('Timeline')
        self.row_axis.setTitleVisible(True)
        self.value_axis = QtDataVisualization.QValue3DAxis()
        self.value_axis.setTitle('RSSI [dBm]')
        self.value_axis.setTitleVisible(True)
        self.value_axis.setRange(-100, -10)

        self.bars.setRowAxis(self.row_axis)
        self.bars.setColumnAxis(self.column_axis)
        self.bars.setValueAxis(self.value_axis)
        self.bars.setBarSpacingRelative(False)
        self.bars.setFloorLevel(-100)

        self.series = QtDataVisualization.QBar3DSeries()
        self.array_data = [[]]
        self.series.dataProxy().addRows(
            self.data_to_bar_data_array(self.array_data))
        self.series.setBaseColor(self.graph_item_color)

        self.bars.setPrimarySeries(self.series)
        self.container = QWidget.createWindowContainer(self.bars)

        if not self.bars.hasContext():
            print("Couldn't initialize the OpenGL context")
            sys.exit(-1)

        camera = self.bars.scene().activeCamera()
        camera.setXRotation(-45.0)
        camera.setYRotation(22.5)

        geometry = QGuiApplication.primaryScreen().geometry()
        size = geometry.height() * 3 / 4
        self.container.setMinimumSize(size, size)
        self.container.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.container.setFocusPolicy(Qt.StrongFocus)
        self.append_data([
            -100, -80, -100, -80, -100, -80, -100, -80, -100, -80, -100, -80,
            -100
        ])
        self.nav_layout_h = QHBoxLayout()
        self.freeze_check = QCheckBox()
        self.freeze_check.setText("Freeze")
        self.freeze_check.clicked.connect(self.enable_scrolling_data)
        self.freeze_check.stateChanged.connect(self.freeze_graph)
        self.prev_button = QPushButton()
        self.prev_button.setText("Previous")
        self.prev_button.setEnabled(False)
        self.prev_button.clicked.connect(self.previous_data)
        self.next_button = QPushButton()
        self.next_button.setText("Next")
        self.next_button.setEnabled(False)
        self.next_button.clicked.connect(self.next_data)
        self.nav_layout_h.addWidget(self.freeze_check)
        self.nav_layout_h.addWidget(self.prev_button)
        self.nav_layout_h.addWidget(self.next_button)

        self.load_data_check = QCheckBox()
        self.load_data_check.setText("Load archival data")
        self.load_data_check.clicked.connect(self.enable_load_data)
        self.load_data_combo = QComboBox()
        self.load_data_combo.addItem("No data found")
        self.load_data_combo.setEnabled(False)
        self.load_data_btn = QPushButton()
        self.load_data_btn.setText("Load")
        self.load_data_btn.setEnabled(False)
        self.nav_layout_h2 = QHBoxLayout()
        self.nav_layout_h2.addWidget(self.load_data_check)
        self.nav_layout_h2.addWidget(self.load_data_combo)
        self.nav_layout_h2.addWidget(self.load_data_btn)
        thread4.start()
        thread4.remove_defualt_item.connect(
            lambda: self.load_data_combo.clear())
        thread4.append_available_day.connect(
            lambda s: self.load_data_combo.addItem(s))
        thread4.send_data_from_database.connect(
            lambda t: self.append_data_from_database(t))
        self.load_data_combo.currentTextChanged.connect(
            lambda t: thread4.get_curr_table(t))
        self.load_data_btn.clicked.connect(thread4.load_data_button)

        self.vertical_timeline_layout.addWidget(self.container)
        self.vertical_timeline_layout.addLayout(self.nav_layout_h)
        self.vertical_timeline_layout.addLayout(self.nav_layout_h2)

        #Bluetooth tab
        thread2.clear_blue_list.connect(self.blue_list_view.clear)
        thread2.append_blue_list_item.connect(
            lambda i: self.blue_list_view.addItem(i))

        #Console tab
        self.console_autoscroll_check.stateChanged.connect(
            self.enable_auto_scroll)
        thread3 = WriteToFile.WriteToFile(self)
        self.console_logging_check.stateChanged.connect(thread3.enable_logging)
        thread2.send_text_signal.connect(lambda t: thread3.write_to_file(t))

        self.window.show()
Ejemplo n.º 25
0
    def __init__(self, parent):
        super().__init__()

        self.root_entity = Qt3DCore.QEntity()

        # Make additional entities for the gnomon and instrument components
        self.combined_component_axes_entity = Qt3DCore.QEntity(
            self.root_entity)
        self.component_root_entity = Qt3DCore.QEntity(
            self.combined_component_axes_entity)
        self.axes_root_entity = Qt3DCore.QEntity(
            self.combined_component_axes_entity)
        self.gnomon_root_entity = Qt3DCore.QEntity(self.root_entity)

        # Create the 3DWindow and place it in a widget with a layout
        lay = QVBoxLayout(self)
        self.view = InstrumentZooming3DWindow(self.component_root_entity)
        self.view.defaultFrameGraph().setClearColor(QColor("lightgrey"))
        self.view.setRootEntity(self.root_entity)
        container = QWidget.createWindowContainer(self.view)
        lay.addWidget(container)

        # Set the properties of the instrument camera controller
        camera_entity = self.view.camera()
        cam_controller = Qt3DExtras.QFirstPersonCameraController(
            self.root_entity)
        cam_controller.setLinearSpeed(20)
        cam_controller.setCamera(camera_entity)

        # Enable the camera to see a large distance by giving it a small nearView and large farView
        self.view.camera().lens().setPerspectiveProjection(
            45, 16 / 9, 0.01, 1000)

        # Set the camera view centre as the origin and position the camera so that it looks down at the initial sample
        self.view.camera().setPosition(QVector3D(6, 8, 30))
        self.view.camera().setViewCenter(QVector3D(0, 0, 0))

        # Make sure that the size of the gnomon stays the same when the 3D view is resized
        self.view.heightChanged.connect(self.update_gnomon_size)
        self.view.widthChanged.connect(self.update_gnomon_size)

        # Keep a reference to the gnomon viewport so that it can be resized to preserve the original size of the gnomon
        self.gnomon_viewport = None

        # Choose a fixed height and width for the gnomon so that this can be preserved when the 3D view is resized
        self.gnomon_height = self.gnomon_width = 140

        # Create the gnomon resources
        self.gnomon = Gnomon(self.gnomon_root_entity, self.view.camera())

        # Create the axes lines objects
        InstrumentViewAxes(self.axes_root_entity,
                           self.view.camera().farPlane())

        # Dictionary of components and transformations so that we can delete them later
        self.component_entities: Dict[str, EntityCollection] = {}
        self.transformations = {}

        # Create layers in order to allow one camera to only see the gnomon and one camera to only see the
        # components and axis lines
        self.create_layers()
        self.initialise_view()

        # Insert the beam cylinder last. This ensures that the semi-transparency works correctly.
        self.gnomon.setup_beam_cylinder()

        # Move the gnomon when the camera view changes
        self.view.camera().viewVectorChanged.connect(self.gnomon.update_gnomon)
Ejemplo n.º 26
0
    def __init__(self, ui_filepath=default_ui_path):
        super().__init__(None)
        UiLoader.populateUI(self, ui_filepath)

        self.centralWidget().setAttribute(Qt.WA_AcceptTouchEvents, False)
        #self.centralWidget().setAttribute(Qt.WA_TransparentForMouseEvents, True)
        self.toolresults = None

        self.statusMsg = QLabel("Ready.")
        self.statusBar().addWidget(self.statusMsg)

        self.logWindow = logwindow.LogWindow(self)
        self.actionShowLogWindow.triggered.connect(self.logWindow.show)
        self.actionShowInputSidebar.toggled.connect(
            self.inputSidebar.setVisible)
        self.actionShowOutputSidebar.toggled.connect(
            self.outputSidebar.setVisible)

        self.actionShowInputSidebar.setShortcut(
            QKeySequence(Qt.CTRL + Qt.Key_BracketLeft))
        self.actionShowOutputSidebar.setShortcut(
            QKeySequence(Qt.CTRL + Qt.Key_BracketRight))

        # Menu shortcuts cannot be set up in a cross-platform way within Qt Designer,
        # so do that here.
        self.actionOpen.setShortcut(QKeySequence.StandardKey.Open)
        self.actionQuit.setShortcut(QKeySequence.StandardKey.Quit)

        self.actionOverlayResults.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_1))
        self.actionSeparateResults.setShortcut(QKeySequence(Qt.CTRL +
                                                            Qt.Key_2))

        self.resetScaffoldBox()

        self.geomView = viewer.AthenaViewer()
        self.viewerWidget_dummy.deleteLater()
        del self.viewerWidget_dummy
        self.geomViewWidget = QWidget.createWindowContainer(
            self.geomView, self, Qt.SubWindow)
        self.upperLayout.insertWidget(1, self.geomViewWidget)
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(1)
        self.geomViewWidget.setSizePolicy(sizePolicy)
        self.geomViewWidget.setFocusPolicy(Qt.NoFocus)

        self.screenshotDialog = screenshot.ScreenshotDialog(
            self, self.geomView)
        self.actionScreenshot.triggered.connect(self.screenshotDialog.show)
        self.screenshotDialog.screenshotSaved.connect(
            self.notifyScreenshotDone)

        self.setupToolDefaults()
        self.enable2DControls()

        self.toolRunButton.clicked.connect(self.runTool)
        self.saveButton.clicked.connect(self.saveOutput)

        self.actionQuit.triggered.connect(self.close)
        self.actionNew.triggered.connect(self.newSession)
        self.actionAbout.triggered.connect(self.showAbout)
        self.actionOpen.triggered.connect(self.selectAndAddFileToGeomList)
        self.actionAddScaffold.triggered.connect(self.selectAndAddScaffoldFile)
        self.actionResetViewerOptions.triggered.connect(
            self.resetDisplayOptions)
        self.actionResetCamera.triggered.connect(self.geomView.resetCamera)

        # action groups cannot be set up in Qt Designer, so do that here
        self.resultsActionGroup = QActionGroup(self)
        self.resultsActionGroup.addAction(self.actionOverlayResults)
        self.resultsActionGroup.addAction(self.actionSeparateResults)
        self.resultsActionGroup.triggered.connect(self._setViewSplit)

        # Likewise for button groups
        self.projectionButtonGroup = QButtonGroup(self)
        self.projectionButtonGroup.addButton(self.orthoCamButton)
        self.projectionButtonGroup.addButton(self.perspectiveCamButton)
        self.projectionButtonGroup.buttonClicked.connect(self.selectProjection)

        self.camMotionButtonGroup = QButtonGroup(self)
        self.camMotionButtonGroup.addButton(self.rotateButton)
        self.camMotionButtonGroup.addButton(self.rotateButton)
        self.camMotionButtonGroup.addButton(self.panButton)
        self.camMotionButtonGroup.addButton(self.zoomButton)
        self.camMotionButtonGroup.buttonClicked.connect(self.selectCameraTool)

        # On Windows, flat some QGroupBox's ... it looks better there,
        # but worse on OSX.
        if platform.system() == 'Windows':
            self.controls_wireframe.setFlat(True)
            self.controls_2D.setFlat(True)
            self.controls_3D.setFlat(True)

        # On OSX, add a separator to the bottom of the view menu, which
        # will isolate the appkit default "full screen" option on its own.
        if platform.system() == 'Darwin':
            self.menuView.setSeparatorsCollapsible(False)
            self.menuView.addSeparator()

        self.displayCylinderBox.toggled.connect(self.geomView.toggleCylDisplay)
        self.geomView.toggleCylDisplay(self.displayCylinderBox.isChecked())

        self.displayRoutingBox.toggled.connect(self.toggleRoutingDisplay)
        self.routingColorButtonGroup.setId(self.routingMulticolorButton, 0)
        self.routingColorButtonGroup.setId(self.routingBicolorButton, 1)
        self.routingColorButtonGroup.buttonClicked[int].connect(
            self.toggleRoutingDisplayVariant)
        self.toggleRoutingDisplay(self.displayRoutingBox.isChecked())

        self.displayPAtomBox.toggled.connect(self.toggleAtomicDisplay)
        self.atomicColorButtonGroup.setId(self.atomicMulticolorButton, 0)
        self.atomicColorButtonGroup.setId(self.atomicBicolorButton, 1)
        self.atomicColorButtonGroup.buttonClicked[int].connect(
            self.toggleAtomicDisplayVariant)
        self.toggleAtomicDisplay(self.displayPAtomBox.isChecked())

        self.geometryList.newFileSelected.connect(self.newMesh)

        def _setupColorButton(button, setter, signal, init_value):
            button.colorChosen.connect(setter)
            signal.connect(button.setColor)
            button.setColor(init_value)

        _setupColorButton(self.lineColorButton, self.geomView.setLineColor,
                          self.geomView.lineColorChanged,
                          self.geomView.lineColor())
        _setupColorButton(self.flatColorButton, self.geomView.setFlatColor,
                          self.geomView.flatColorChanged,
                          self.geomView.flatColor())
        _setupColorButton(self.bgColorButton, self.geomView.setBackgroundColor,
                          self.geomView.backgroundColorChanged,
                          self.geomView.backgroundColor())
        _setupColorButton(self.warmColorButton, self.geomView.setWarmColor,
                          self.geomView.warmColorChanged,
                          self.geomView.warmColor())
        _setupColorButton(self.coolColorButton, self.geomView.setCoolColor,
                          self.geomView.coolColorChanged,
                          self.geomView.coolColor())

        self.alphaSlider.valueChanged.connect(self.setViewerAlpha)
        self.geomView.alphaChanged.connect(self.handleAlphaChanged)

        self.lineWidthSlider.valueChanged.connect(self.setViewerLinewidth)
        self.geomView.lineWidthChanged.connect(
            self.handleViewerLinewidthChanged)

        self.lightDial.valueChanged.connect(self.geomView.setLightOrientation)
        self.geomView.lightOrientationChanged.connect(self.lightDial.setValue)

        self.controls_2D.toggled.connect(self.geomView.toggleFaceRendering)
        self.controls_3D.toggled.connect(self.geomView.toggleFaceRendering)
        self.controls_wireframe.toggled.connect(
            self.geomView.toggleWireframeRendering)
        self.geomView.faceRenderingEnabledChanged.connect(
            self.controls_2D.setChecked)
        self.geomView.faceRenderingEnabledChanged.connect(
            self.controls_3D.setChecked)
        self.geomView.wireframeRenderingEnabledChanged.connect(
            self.controls_wireframe.setChecked)

        self.newMesh(None)
        self.show()
        self.log("Athena version {}".format(__version__))
Ejemplo n.º 27
0
 def convertWndToWidget(hwnd):
     native_wnd = QWindow.fromWinId(hwnd)
     return QWidget.createWindowContainer(native_wnd)
Ejemplo n.º 28
0
    child7k.setText(0, '以面积求多边形')
    child7l = QTreeWidgetItem(child7)
    child7l.setText(0, '将2根线在交点断开')
    child7l.setData(0,)

    tree.addTopLevelItem(root)
    # root.connect(root,SIN)
    mainFrame.gridLayout.addWidget(tree, 0, 0, 1, 1)

    # 显示surpac的tab
    # 设置surpac窗口为主窗口的子窗口
    # 方法1
    # win32gui.SetParent(hwnds[0], mainWindow.winId())
    # 方法2
    native_wnd = QWindow.fromWinId(hwnds[0])
    surpacWidget = QWidget.createWindowContainer(native_wnd)
    # 方法2.1
    # mainWindow.setCentralWidget(centralWidget)
    # 方法2.2
    mainFrame.gridLayout.addWidget(surpacWidget, 0, 1, 1, 10)

    time.sleep(1)

    # 隐含窗口标题栏win32con.GW_CHILD &
    ISTYLE = win32gui.GetWindowLong(hwnds[0], win32con.GWL_STYLE)
    win32gui.SetWindowLong(hwnds[0], win32con.GWL_STYLE,
                           ISTYLE & ~win32con.WS_CAPTION & win32con.SWP_NOSIZE & win32con.SWP_NOMOVE)

    # 退出应用
    sys.exit(app.exec_())
Ejemplo n.º 29
0
    c1.setRange(0, 1000)
    c1.setValue(1000)
    c2 = QSlider(Qt.Horizontal)
    c2.setRange(0, 1000)
    c2.setValue(1000)
    c3 = QSlider(Qt.Horizontal)
    c3.setRange(0, 100)
    c3.setValue(100)

    controlLay.addRow("Point light", c1)
    controlLay.addRow("Spot light", c2)
    controlLay.addRow("Directional light", c3)

    # We use QWidget.createWindowContainer to host the 3D content without any indirection.
    view3d = Window()
    container = QWidget.createWindowContainer(view3d, view)
    container.setSizePolicy(QSizePolicy.MinimumExpanding,
                            QSizePolicy.MinimumExpanding)
    container.setMinimumWidth(500)
    container.setMinimumHeight(500)

    mainLay.addWidget(controlWidg)
    mainLay.addWidget(container)

    view.setCentralWidget(mainWidg)

    view.show()

    # Communication between the QWidget UI and the 3D scene
    c1.valueChanged.connect(lambda val: view3d.enablePointLight(val))
    c2.valueChanged.connect(lambda val: view3d.enableSpotLight(val))
Ejemplo n.º 30
0
 def setupUi(self, LotsOfSpheresDialog):
     super().setupUi(LotsOfSpheresDialog)
     self.horizontalLayout.replaceWidget(
         self.widget, QWidget.createWindowContainer(self.window))
     self.pushButton.clicked.connect(self.add_spheres)
Ejemplo n.º 31
0
 def setupUi(self, CylinderDialog):
     super().setupUi(CylinderDialog)
     self.horizontalLayout.replaceWidget(
         self.widget, QWidget.createWindowContainer(self.window))
     self.pushButton.clicked.connect(self.add_cylinder)