コード例 #1
0
    def __init__(self, parent):
        # OpenGL Widget setup
        f = QGLFormat()
        f.setSampleBuffers(True)
        f.setVersion(3,3)
        f.setProfile(QGLFormat.CoreProfile)
        QGLFormat.setDefaultFormat(f)

        if not QGLFormat.hasOpenGL():
            QMessageBox.information(None, "OpenGL samplebuffers",
                    "This system does not support OpenGL.")
            sys.exit(0)
        super(GLWidget, self).__init__(f, parent)
        self.setFocusPolicy(Qt.StrongFocus)
        self.list_ = []
        self.width = 640.0
        self.height = 480.0
        self.startTimer(40)
        self.setWindowTitle("Sample Buffers")
        self.fov = 60.0
        self.deltaTime = 0.0
        self.lastFrame = None
        self.sketching = False
        self.sketchType = 0
        self.sketchPoints = []
コード例 #2
0
def start():
    # Start the Qt main object
    app = QApplication([])

    # Start the bluesky network client
    client = GuiClient()

    # Enable HiDPI support (Qt5 only)
    if QT_VERSION >= 0x050000:
        app.setAttribute(Qt.AA_UseHighDpiPixmaps)

    splash = Splash()

    # Register our custom pan/zoom event
    for etype in range(1000, 1000 + NUMCUSTOMEVENTS):
        reg_etype = QEvent.registerEventType(etype)
        if reg_etype != etype:
            print((
                'Warning: Registered event type differs from requested type id (%d != %d)'
                % (reg_etype, etype)))

    splash.show()

    # Install error message handler
    handler = QErrorMessage.qtHandler()
    handler.setWindowFlags(Qt.WindowStaysOnTopHint)

    # Check and set OpenGL capabilities
    if not QGLFormat.hasOpenGL():
        raise RuntimeError('No OpenGL support detected for this system!')
    else:
        f = QGLFormat()
        f.setVersion(3, 3)
        f.setProfile(QGLFormat.CoreProfile)
        f.setDoubleBuffer(True)
        QGLFormat.setDefaultFormat(f)
        print(('QGLWidget initialized for OpenGL version %d.%d' %
               (f.majorVersion(), f.minorVersion())))

    splash.showMessage('Constructing main window')
    app.processEvents()
    win = MainWindow()
    win.show()
    splash.showMessage('Done!')
    app.processEvents()
    splash.finish(win)
    # If this instance of the gui is started in client-only mode, show
    # server selection dialog
    if bs.settings.is_client:
        dialog = DiscoveryDialog(win)
        dialog.show()
        bs.net.start_discovery()

    else:
        client.connect(event_port=bs.settings.event_port,
                       stream_port=bs.settings.stream_port)

    # Start the Qt main loop
    app.exec_()
コード例 #3
0
ファイル: gui.py プロジェクト: thobson88/bluesky
def start(mode):
    # Install message handler for Qt messages
    qInstallMessageHandler(gui_msg_handler)

    # Start the Qt main object
    app = QApplication([])

    # Start the bluesky network client
    client = GuiClient()

    # Enable HiDPI support (Qt5 only)
    if QT_VERSION >= 0x050000:
        app.setAttribute(Qt.AA_UseHighDpiPixmaps)

    splash = Splash()

    # Register our custom pan/zoom event
    for etype in range(1000, 1000 + NUMCUSTOMEVENTS):
        reg_etype = QEvent.registerEventType(etype)
        if reg_etype != etype:
            print(('Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype)))

    splash.show()

    # Install error message handler
    handler = QErrorMessage.qtHandler()
    handler.setWindowFlags(Qt.WindowStaysOnTopHint)

    # Check and set OpenGL capabilities
    if not QGLFormat.hasOpenGL():
        raise RuntimeError('No OpenGL support detected for this system!')
    else:
        f = QGLFormat()
        f.setVersion(3, 3)
        f.setProfile(QGLFormat.CoreProfile)
        f.setDoubleBuffer(True)
        QGLFormat.setDefaultFormat(f)
        print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion())))

    splash.showMessage('Constructing main window')
    app.processEvents()
    win = MainWindow(mode)
    win.show()
    splash.showMessage('Done!')
    app.processEvents()
    splash.finish(win)
    # If this instance of the gui is started in client-only mode, show
    # server selection dialog
    if mode == 'client':
        dialog = DiscoveryDialog(win)
        dialog.show()
        bs.net.start_discovery()

    else:
        client.connect(event_port=bs.settings.event_port,
                       stream_port=bs.settings.stream_port)

    # Start the Qt main loop
    app.exec_()
コード例 #4
0
    def __init__(self, parent=None):
        self.first = True
        f = QGLFormat()
        f.setVersion(3, 3)
        f.setProfile(QGLFormat.OpenGLContextProfile.CoreProfile)
        f.setDoubleBuffer(True)
        QGLWidget.__init__(self, QGLContext(f), parent)

        print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion())))

        print("This script creates a file called 'opengl-test.txt', containing information about the opengl support of your computer. Useful when debugging problems with the opengl version of BlueSky.")
コード例 #5
0
ファイル: gltest.py プロジェクト: ProfHoekstra/bluesky
    def __init__(self, parent=None):
        self.first = True
        f = QGLFormat()
        f.setVersion(3, 3)
        f.setProfile(QGLFormat.CoreProfile)
        f.setDoubleBuffer(True)
        QGLWidget.__init__(self, QGLContext(f), parent)

        print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion())))

        print("This script creates a file called 'opengl-test.txt', containing information about the opengl support of your computer. Useful when debugging problems with the opengl version of BlueSky.")
コード例 #6
0
 def __init__(self, renderer, title):
     QApplication.__init__(self, sys.argv)
     self.window = QMainWindow()
     self.window.setWindowTitle(title)
     self.window.resize(800,600)
     # Get OpenGL 4.1 context
     glformat = QGLFormat()
     glformat.setVersion(4, 1)
     glformat.setProfile(QGLFormat.CoreProfile)
     glformat.setDoubleBuffer(False)
     self.glwidget = MyGlWidget(renderer, glformat, self)
     self.window.setCentralWidget(self.glwidget)
     self.window.show()
コード例 #7
0
    def __init__(self):
        super(Gui, self).__init__([])
        self.acdata = ACDataEvent()
        self.birddata = BirdDataEvent()
        self.navdb = None
        self.radarwidget = []
        self.command_history = []
        self.cmd = ''
        self.args = []
        self.history_pos = 0
        self.command_mem = ''
        self.command_line = ''
        self.prev_cmdline = ''
        self.mousedragged = False
        self.mousepos = (0, 0)
        self.prevmousepos = (0, 0)
        self.panzoomchanged = False
        self.simt = 0.0

        # Register our custom pan/zoom event
        for etype in range(1000, 1000 + NUMEVENTS):
            reg_etype = QEvent.registerEventType(etype)
            if reg_etype != etype:
                print(
                    'Warning: Registered event type differs from requested type id (%d != %d)'
                    % (reg_etype, etype))

        self.splash = Splash()
        self.splash.show()

        # Install error message handler
        handler = QErrorMessage.qtHandler()
        handler.setWindowFlags(Qt.WindowStaysOnTopHint)

        # Check and set OpenGL capabilities
        if not QGLFormat.hasOpenGL():
            raise RuntimeError('No OpenGL support detected for this system!')
        else:
            f = QGLFormat()
            f.setVersion(3, 3)
            f.setProfile(QGLFormat.CoreProfile)
            f.setDoubleBuffer(True)
            QGLFormat.setDefaultFormat(f)
            print('QGLWidget initialized for OpenGL version %d.%d' %
                  (f.majorVersion(), f.minorVersion()))

        # Enable HiDPI support (Qt5 only)
        if QT_VERSION == 5:
            self.setAttribute(Qt.AA_UseHighDpiPixmaps)
コード例 #8
0
ファイル: gui.py プロジェクト: mvanhorssen/bluesky
    def __init__(self):
        super(Gui, self).__init__([])
        self.acdata          = ACDataEvent()
        self.routedata       = RouteDataEvent()
        self.navdb           = None
        self.radarwidget     = []
        self.command_history = []
        self.cmd             = ''
        self.args            = []
        self.history_pos     = 0
        self.command_mem     = ''
        self.command_line    = ''
        self.prev_cmdline    = ''
        self.mousedragged    = False
        self.mousepos        = (0, 0)
        self.prevmousepos    = (0, 0)
        self.panzoomchanged  = False
        self.simt            = 0.0

        # Register our custom pan/zoom event
        for etype in range(1000, 1000 + NUMEVENTS):
            reg_etype = QEvent.registerEventType(etype)
            if reg_etype != etype:
                print('Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype))

        self.splash = Splash()
        self.splash.show()

        # Install error message handler
        handler = QErrorMessage.qtHandler()
        handler.setWindowFlags(Qt.WindowStaysOnTopHint)

        # Check and set OpenGL capabilities
        if not QGLFormat.hasOpenGL():
            raise RuntimeError('No OpenGL support detected for this system!')
        else:
            f = QGLFormat()
            f.setVersion(3, 3)
            f.setProfile(QGLFormat.CoreProfile)
            f.setDoubleBuffer(True)
            QGLFormat.setDefaultFormat(f)
            print('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion()))

        # Enable HiDPI support (Qt5 only)
        if QT_VERSION == 5:
            self.setAttribute(Qt.AA_UseHighDpiPixmaps)
コード例 #9
0
    def __init__(self):
        super(StimCanvas, self).__init__()

        self.control = TrialControl()
        self.control.show()
        self.t = time.time()
        glformat = QGLFormat()
        glformat.setVersion(4, 1)
        glformat.setProfile(QGLFormat.CoreProfile)

        glformat.setDoubleBuffer(True)
        self.drawtimer = QTimer(self)
        self.drawtimer.timeout.connect(self.update)
        self.drawtimer.start(1000 / 60)
        self.curframe = 0
        self.curtrial = 0

        self.trial_seq = [0]
コード例 #10
0
ファイル: engine.py プロジェクト: WendyHanzer/7c
    def initWindow(self):
        self.window = MainWindow(self)
        self.window.setWindowTitle('CS791a')

        glFormat = QGLFormat()
        glFormat.setDoubleBuffer(True)
        glFormat.setDirectRendering(True)
        glFormat.setProfile(QGLFormat.CoreProfile)
        glFormat.setVersion(3,3)
        QGLFormat.setDefaultFormat(glFormat)

        #glFormat.setOption(QGLFormat.OpenGL_Version_3_3)

        self.graphics = GraphicsManager(self)
        self.graphics.makeCurrent()
        self.window.setCentralWidget(self.graphics)
        self.window.resize(1600,900)

        print(glGetString(GL_VERSION))
コード例 #11
0
ファイル: blipdriver.py プロジェクト: ProfHoekstra/bluesky
            self.selValues[4] += int(val) * increment
            self.remainder = val - int(val)

        self.update_lcd()
        if self.btn_pressed is not None:
            QTimer.singleShot(200, self.updateAPValues)


if __name__ == "__main__":
    qapp = QApplication([])

    # Check and set OpenGL capabilities
    if not QGLFormat.hasOpenGL():
        raise RuntimeError('No OpenGL support detected for this system!')
    else:
        f = QGLFormat()
        f.setVersion(3, 3)
        f.setProfile(QGLFormat.CoreProfile)
        f.setDoubleBuffer(True)
        QGLFormat.setDefaultFormat(f)
        print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion())))

    blip = BlipDriver()
    blip.show()

    gltimer          = QTimer(qapp)
    gltimer.timeout.connect(blip.updateGL)
    gltimer.start(50)

    qapp.exec_()
コード例 #12
0
    def __init__(self):
        super(DrawingWindow, self).__init__()
        self.history = []
        self.userDefinedPoints = []
        self.setMouseTracking(True)

        #SURFACE setup
        self.ctrPnt = [[
            QVector3D(10, 0, 10),
            QVector3D(5, 0, 10),
            QVector3D(-5, 0, 10),
            QVector3D(-10, 0, 10)
        ],
                       [
                           QVector3D(10, 0, 5),
                           QVector3D(5, 10, 5),
                           QVector3D(-5, 10, 5),
                           QVector3D(-10, 0, 5)
                       ],
                       [
                           QVector3D(10, 0, -5),
                           QVector3D(5, 10, -5),
                           QVector3D(-5, 10, -5),
                           QVector3D(-10, 0, -5)
                       ],
                       [
                           QVector3D(10, 0, -10),
                           QVector3D(5, 0, -10),
                           QVector3D(-5, 0, -10),
                           QVector3D(-10, 0, -10)
                       ]]

        self.vtr = []
        self.vertices = []
        self.indices = []

        self.controlPoints = []
        self.rotationAxis = None

        for row in self.ctrPnt:
            for vector in row:
                self.controlPoints.append(float(vector.x()))
                self.controlPoints.append(float(vector.y()))
                self.controlPoints.append(float(vector.z()))

        self.surface = NURBSSurface(controlNet=self.ctrPnt,
                                    Udegree=3,
                                    Wdegree=3,
                                    Uknots=[0, 0, 0, 0, 1, 1, 1, 1],
                                    Wknots=[0, 0, 0, 0, 1, 1, 1, 1])

        self.surface.setWeights([[1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0],
                                 [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]])
        self.surface.compute()
        self.vtr = self.surface.surfacePoints

        self.indices = triangleRenderer(row=12, col=11)
        normalsList = normalsPerTriangle(self.vtr, self.indices)
        self.surfaceNormals = []
        self.normals = normalsPerVertex(normalsList, len(self.vtr))

        for value in self.vtr:
            self.vertices.append(float(value.x()))
            self.vertices.append(float(value.y()))
            self.vertices.append(float(value.z()))

        for value in self.normals:
            self.surfaceNormals.append(float(value.x()))
            self.surfaceNormals.append(float(value.y()))
            self.surfaceNormals.append(float(value.z()))

        #QTsetting
        glFormat = QGLFormat()
        glFormat.setVersion(3, 2)
        glFormat.setProfile(QGLFormat.CoreProfile)
        QGLFormat.setDefaultFormat(glFormat)
        print(glFormat)

        #camera
        self.camera = Camera(position=QVector3D(0, 7, 20),
                             direction=QVector3D(0, 0, 0),
                             up=QVector3D(0, 1, 0))

        self.normalMatrix = QMatrix4x4()

        #interaction
        self.selectedPoint = None
        self.editFlag = False
        self.showControlPoints = False
コード例 #13
0
def start(mode):
    # Install message handler for Qt messages
    qInstallMessageHandler(gui_msg_handler)

    # Start the Qt main object
    app = QApplication([])

    # Start the bluesky network client
    client = GuiClient()

    # Enable HiDPI support (Qt5 only)
    if QT_VERSION >= 0x050000:
        app.setAttribute(Qt.AA_UseHighDpiPixmaps)

    splash = Splash()

    # Register our custom pan/zoom event
    for etype in range(1000, 1000 + NUMCUSTOMEVENTS):
        reg_etype = QEvent.registerEventType(etype)
        if reg_etype != etype:
            print((
                'Warning: Registered event type differs from requested type id (%d != %d)'
                % (reg_etype, etype)))

    splash.show()

    # Install error message handler
    handler = QErrorMessage.qtHandler()
    handler.setWindowFlags(Qt.WindowStaysOnTopHint)

    # Check and set OpenGL capabilities
    if not QGLFormat.hasOpenGL():
        raise RuntimeError('No OpenGL support detected for this system!')
    else:
        f = QGLFormat()
        f.setVersion(3, 3)
        f.setProfile(QGLFormat.CoreProfile)
        f.setDoubleBuffer(True)
        QGLFormat.setDefaultFormat(f)
        print(('QGLWidget initialized for OpenGL version %d.%d' %
               (f.majorVersion(), f.minorVersion())))

    splash.showMessage('Constructing main window')
    app.processEvents()
    win = MainWindow(mode)
    splash.showMessage('Done!')
    app.processEvents()
    splash.finish(win)

    # Quick hack to connect to a remote simulation
    import sys
    arg = '--bluesky_host='
    host = next((x for x in sys.argv if x.startswith(arg)), None)
    if host is not None:
        host = host[len(arg):]
        try:
            print('Attempting connection to BlueSky at: {}'.format(host))
            client.connect(hostname=host,
                           event_port=bs.settings.event_port,
                           stream_port=bs.settings.stream_port,
                           timeout=5)
        except TimeoutError:
            print('Failed to connect to BlueSky server at {}, exiting'.format(
                host))
            QApplication.quit()
            sys.exit(0)
        win.show()
        app.exec_()
        return

    win.show()

    # If this instance of the gui is started in client-only mode, show
    # server selection dialog
    if mode == 'client':
        dialog = DiscoveryDialog(win)
        dialog.show()
        bs.net.start_discovery()

    else:
        client.connect(event_port=bs.settings.event_port,
                       stream_port=bs.settings.stream_port)

    # Start the Qt main loop
    app.exec_()
コード例 #14
0
ファイル: gui.py プロジェクト: AlexanderFSX/bluesky
    def __init__(self, navdb):
        super(Gui, self).__init__([])
        self.acdata          = ACDataEvent()
        self.navdb           = navdb
        self.radarwidget     = []
        self.command_history = []
        self.cmdargs         = []
        self.history_pos     = 0
        self.command_mem     = ''
        self.command_line    = ''
        self.prev_cmdline    = ''
        self.simevent_target = 0
        self.mousedragged    = False
        self.mousepos        = (0, 0)
        self.prevmousepos    = (0, 0)
        self.panzoomchanged  = False
        self.simt            = 0.0

        # Register our custom pan/zoom event
        for etype in [PanZoomEventType, ACDataEventType, SimInfoEventType,
                      StackTextEventType, ShowDialogEventType,
                      DisplayFlagEventType, RouteDataEventType,
                      DisplayShapeEventType, SimQuitEventType,
                      AMANEventType]:
            reg_etype = QEvent.registerEventType(etype)
            if reg_etype != etype:
                print('Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype))

        self.splash = Splash()
        self.splash.show()

        self.splash.showMessage('Constructing main window')
        self.processEvents()

        # Install error message handler
        handler = QErrorMessage.qtHandler()
        handler.setWindowFlags(Qt.WindowStaysOnTopHint)

        # Check and set OpenGL capabilities
        if not QGLFormat.hasOpenGL():
            raise RuntimeError('No OpenGL support detected for this system!')
        else:
            f = QGLFormat()
            f.setVersion(3, 3)
            f.setProfile(QGLFormat.CoreProfile)
            f.setDoubleBuffer(True)
            QGLFormat.setDefaultFormat(f)
            print('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion()))

        # Create the main window and related widgets
        self.radarwidget = RadarWidget(navdb)
        self.win  = MainWindow(self, self.radarwidget)
        self.nd   = ND(shareWidget=self.radarwidget)
        #self.aman = AMANDisplay(shareWidget=self.radarwidget)

        # Enable HiDPI support (Qt5 only)
        if QT_VERSION == 5:
            self.setAttribute(Qt.AA_UseHighDpiPixmaps)

        timer = QTimer(self)
        timer.timeout.connect(self.radarwidget.updateGL)
        timer.timeout.connect(self.nd.updateGL)
        #timer.timeout.connect(self.aman.updateGL)
        timer.start(50)
コード例 #15
0
def set_default_context(major_version, minor_version, profile):
    f = QGLFormat()
    f.setVersion(major_version, minor_version)
    f.setProfile(profile)
    QGLFormat.setDefaultFormat(f)
コード例 #16
0
            self.remainder = val - int(val)

        self.update_lcd()
        if self.btn_pressed is not None:
            QTimer.singleShot(200, self.updateAPValues)


if __name__ == "__main__":
    qapp = QApplication([])

    # Check and set OpenGL capabilities
    if not QGLFormat.hasOpenGL():
        raise RuntimeError('No OpenGL support detected for this system!')
    else:
        f = QGLFormat()
        f.setVersion(3, 3)
        f.setProfile(QGLFormat.CoreProfile)
        f.setDoubleBuffer(True)
        QGLFormat.setDefaultFormat(f)
        print('QGLWidget initialized for OpenGL version %d.%d' %
              (f.majorVersion(), f.minorVersion()))

    blip = BlipDriver()
    blip.show()

    gltimer = QTimer(qapp)
    gltimer.timeout.connect(blip.updateGL)
    gltimer.start(50)

    qapp.exec_()
コード例 #17
0
ファイル: blipdriver.py プロジェクト: andubadea/bluesky
            self.remainder = val - int(val)

        self.update_lcd()
        if self.btn_pressed is not None:
            QTimer.singleShot(200, self.updateAPValues)


if __name__ == "__main__":
    qapp = QApplication([])

    # Check and set OpenGL capabilities
    if not QGLFormat.hasOpenGL():
        raise RuntimeError('No OpenGL support detected for this system!')
    else:
        f = QGLFormat()
        f.setVersion(3, 3)
        f.setProfile(QGLFormat.OpenGLContextProfile.CoreProfile)
        f.setDoubleBuffer(True)
        QGLFormat.setDefaultFormat(f)
        print(('QGLWidget initialized for OpenGL version %d.%d' %
               (f.majorVersion(), f.minorVersion())))

    blip = BlipDriver()
    blip.show()

    gltimer = QTimer(qapp)
    gltimer.timeout.connect(blip.updateGL)
    gltimer.start(50)

    qapp.exec_()