def __init__(self, parent = None): self.stimulusWindow = self format = QGLFormat() format.setSwapInterval(1) super().__init__(format, parent) #super().__init__(parent) self.setFocusPolicy(Qt.NoFocus) self.updateSignal.connect(self.updateGL) self.setStyleSheet(""" QWidget{ background-color: black; border-color: red; border-style: solid; border-width: 1px; border-radius: 0px; font: bold 14px; color: red; padding: 0px; font-family: "Candara"; font-size: 14px; } """ ) self.setCursor(Qt.BlankCursor) self.fpsWarningSound = QSound("./Project/Media/airhorn.wav") self.finishedSound = QSound("./Project/Media/FANFARE.WAV") self.handle = None self.dllref = None
def __init__(self, parent, launcher): format = QGLFormat() format.setSwapInterval(1) super().__init__(format, parent) self.makeCurrent() gears.shareCurrent() #super().__init__(parent) self.launcher = launcher
def setRenderer(self, renderer): self.renderer = renderer if self.renderer == SvgView.OpenGL: if QGLFormat.hasOpenGL(): self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) else: self.setViewport(QWidget())
def init(self): """Initialize GL context.""" if not self.glcontext: self.glformat = QGLFormat() self.glcontext = self.widget.context() self.glcontext.setFormat(self.glformat) self.glcontext.create() return M64ERR_SUCCESS
def __init__(self, parent, editor): format = QGLFormat() format.setSwapInterval(1) super().__init__(format, parent) self.makeCurrent() gears.shareCurrent() self.sFrame = 0 self.editor = editor self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
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.")
def setRenderer(self, action): if QGLFormat.hasOpenGL(): self.highQualityAntialiasingAction.setEnabled(False) if action == self.nativeAction: self.view.setRenderer(SvgView.Native) elif action == self.glAction: if QGLFormat.hasOpenGL(): self.highQualityAntialiasingAction.setEnabled(True) self.view.setRenderer(SvgView.OpenGL) elif action == self.imageAction: self.view.setRenderer(SvgView.Image)
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.")
def __init__(self, parent, scene): super().__init__(parent) self.setScene(scene) if QGLFormat.hasOpenGL(): self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) self.numScrolls = 0
def __init__(self, scene, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) # self.windowTitleChanged.connect(self.onWindowTitleChange) self.setWindowTitle("timeline0") toolbar = QToolBar("och") toolbar.setIconSize(QSize(20, 20)) self.addToolBar(toolbar) button_action = QAction(QIcon("balance.png"), "ochtuse", self) button_action.setStatusTip("och, just do something") button_action.triggered.connect(self.onMyToolBarButtonClick) button_action.setCheckable(True) # button_action.setShortcut(QKeySequence("Ctrl+p")) # button_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_P)) button_action.setShortcut(QKeySequence.Print) toolbar.addAction(button_action) toolbar.addWidget(QLabel("OCH")) toolbar.addWidget(QCheckBox()) self.setStatusBar(QStatusBar(self)) menu = self.menuBar() file_menu = menu.addMenu("&File") file_menu.addAction(button_action) file_menu.addSeparator() file_menu.addMenu("Do not push") # file_menu.addAction() self._scene = scene gfx = self._gfx = QGraphicsView(self) # label = QLabel("och!") # label.setAlignment(Qt.AlignCenter) # ref https://doc.qt.io/archives/qq/qq26-openglcanvas.html self.setCentralWidget(gfx) fmt = QGLFormat(QGL.SampleBuffers) wdgt = QGLWidget(fmt) assert (wdgt.isValid()) gfx.setViewport(wdgt) gfx.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) gfx.setScene(scene) # populate fills the scene with interesting stuff. self.populate() # Make it bigger self.setWindowState(Qt.WindowMaximized) # Well... it's going to have an animation, ok? # So, I set a timer to 1 second self.animator = QTimer() # And when it triggers, it calls the animate method self.animator.timeout.connect(self.animate) # And I animate it once manually. self.animate()
def __init__(self, parent): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.list_ = [] self.startTimer(40) self.setWindowTitle("Sample Buffers")
def __init__(self, parent=None): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) midnight = QTime(0, 0, 0) random.seed(midnight.secsTo(QTime.currentTime())) self.object = 0 self.xRot = 0 self.yRot = 0 self.zRot = 0 self.image = QImage() self.bubbles = [] self.lastPos = QPoint() self.trolltechGreen = QColor.fromCmykF(0.40, 0.0, 1.0, 0.0) self.trolltechPurple = QColor.fromCmykF(0.39, 0.39, 0.0, 0.0) self.animationTimer = QTimer() self.animationTimer.setSingleShot(False) self.animationTimer.timeout.connect(self.animate) self.animationTimer.start(25) self.setAutoFillBackground(False) self.setMinimumSize(200, 200) self.setWindowTitle("Overpainting a Scene")
def __init__(self, helper, parent): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.helper = helper self.elapsed = 0 self.setFixedSize(200, 200) self.setAutoFillBackground(False)
def __init_ui(self): # set up the scene self.scene = QGraphicsScene() self.scene.setSceneRect(0, 0, 650, 560) self.scene.setBackgroundBrush(Qt.darkGray) # set up the view self.setScene(self.scene) # these 10 additional pixels are for the margin self.setFixedSize(660, 570) # optimization self.setOptimizationFlag(QGraphicsView.DontAdjustForAntialiasing) self.setOptimizationFlag(QGraphicsView.DontSavePainterState) self.setCacheMode(QGraphicsView.CacheBackground) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setInteractive(False) self.setViewport(QGLWidget(QGLFormat())) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) # set the background backgroundPixmap = QPixmap(self.texture) background = QGraphicsPixmapItem(backgroundPixmap) self.scene.addItem(background) # menu selector selectorPixmap = QPixmap(self.config.mainMenuSelector) self.selector = QGraphicsPixmapItem(selectorPixmap) self.selector.setPos(self.selectorPositions[self.selectedOption]) self.scene.addItem(self.selector)
def __init__(self, parent): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.test_option = gl.GL_SCISSOR_TEST self.func_option = gl.GL_GREATER self.sfactor_option = gl.GL_SRC_ALPHA self.dfactor_option = gl.GL_ONE_MINUS_SRC_ALPHA self.ref = 0.2 self.move(0, 0) self.resize(canvas_width, canvas_height)
def setUseOpenGL(self, useOpenGL): if not QT_NO_OPENGL: if (useOpenGL and QGLFormat.hasOpenGL()): if (not self.viewport()): format = QGLFormat.defaultFormat() format.setDepth(False) # No need for a depth buffer format.setSampleBuffers(True) # Enable anti-aliasing self.setViewport(QGLWidget(format)) else: if self.viewport(): self.setViewport(None) v = self.viewport() if (self.mMode == MapViewMode.StaticContents): v.setAttribute(Qt.WA_StaticContents) v.setMouseTracking(True) else: pass
def __init__(self, *args, **kwargs): super(QFramesInTracksView, self).__init__(*args, **kwargs) fmt = QGLFormat(QGL.SampleBuffers) wdgt = QGLWidget(fmt) assert (wdgt.isValid()) self.setViewport(wdgt) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setRenderHints(QPainter.Antialiasing)
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()
def __init__(self): super().__init__() self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) scene = QGraphicsScene(self) self.setScene(scene) self.setSceneRect(0, 0, 600, 600) # self.setStyleSheet('background-color: rgba(255, 0, 0, 255)') for _ in range(10): pos = random.sample(range(0, 600), 2) circle = Circle(*pos, 100) circle.create_random_point() self.scene().addItem(circle)
def __init__(self, parent=None): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.setFocusPolicy(Qt.StrongFocus) #keyboard support self.startTimer(1000 / 144) self.camera = True self.w = self.width() self.h = self.height() self.zoom = 20 self.xRot = 0 # roll self.yRot = 0 # pitch self.zRot = 0 # yaw self.R_MIN = 4.5 self.R_MAX = 60 self.lastPos = QPoint()
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]
def __init__(self, parent) -> None: """ CONSTRUCTOR """ super().__init__(parent) self.ui = frm_lego_designer.Ui_Dialog(self) self.setWindowTitle("Lego Diagram Editor") # # Graphics view # self.ctrl_graphics_view = InteractiveGraphicsView() v = self.ctrl_graphics_view sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHeightForWidth(v.sizePolicy().hasHeightForWidth()) v.setSizePolicy(sizePolicy) v.setObjectName("graphicsView") v.setBackgroundBrush(QBrush(QColor(255, 255, 255))) v.setInteractive(True) layout = QGridLayout() self.ui.FRA_MAIN.setLayout(layout) layout.addWidget(v) # Open GL rendering if groot.data.config.options().opengl: v.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) # Default (empty) scene scene = QGraphicsScene() scene.addRect(QRectF(-10, -10, 20, 20)) v.setScene(scene) # # Create our model view! # self.model_view: ModelView = None self.update_view() self.toggle_show_edit(False) # Button clicks for x in (self.ui.BTN_S_EDGES_, self.ui.BTN_S_COMPS_, self.ui.BTN_S_GENES_, self.ui.BTN_S_MINCOMPS_, self.ui.BTN_S_DOMAINS_): x.clicked[bool].connect(self.on_btn_click)
def __init__(self, parent=None): """ On initialization, we need to bind the Ctrl/command key to enable manipulation of the view. """ QGraphicsView.__init__(self, parent) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setRubberBandSelectionMode(Qt.IntersectsItemShape) self.setStyleSheet( "QGraphicsView { background-color: rgb(96.5%, 96.5%, 96.5%); }") self._no_drag = QGraphicsView.RubberBandDrag self._yes_drag = QGraphicsView.ScrollHandDrag # reset things that are state dependent self.clearGraphicsView() self._x0 = 0 self._y0 = 0 self._scale_size = 1.0 self._scale_limit_max = 3.0 self._scale_limit_min = 0.41 self._scale_up_rate = 0.01 self._scale_down_rate = 0.01 self._scale_fit_factor = 1 # sets initial zoom level self._show_details = True self._last_scale_factor = 0.0 self.scene_root_item = None # the item to transform # Keyboard panning self._key_pan_delta_x = styles.PATH_BASE_WIDTH * 21 self._key_pan_delta_y = styles.PATH_HELIX_HEIGHT + styles.PATH_HELIX_PADDING / 2 # Modifier keys and buttons self._key_mod = Qt.Key_Control self._button_pan = Qt.LeftButton self._button_pan_alt = Qt.MidButton self._button_zoom = Qt.RightButton self.toolbar = None # custom hack for the paint tool palette self._name = None if GL: self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) else: self.setViewportUpdateMode(QGraphicsView.MinimalViewportUpdate)
def __init__(self, *args, **kwargs): super(GraphicsView, self).__init__(*args, **kwargs) self.resize(800, 600) # 设置背景颜色 self.setBackgroundBrush(self.backgroundColor) # 缓存背景 self.setCacheMode(self.CacheBackground) # 设置拖拽样式 # self.setDragMode(self.ScrollHandDrag) self.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) # opengl if QGLFormat.hasOpenGL(): self.setRenderHint(QPainter.HighQualityAntialiasing) # 尝试通过分析需要重绘的区域来找到最佳的更新模式 self.setViewportUpdateMode(self.SmartViewportUpdate) self._scene = QGraphicsScene(-400, -300, 800, 600, self) self.setScene(self._scene) # 图片item self._itemImage = None
def __init__(self, parent = None): super().__init__(parent) self.mUi = Ui_PreferencesDialog() self.mLanguages = LanguageManager.instance().availableLanguages() self.mUi.setupUi(self) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.mUi.openGL.setEnabled(QGLFormat.hasOpenGL()) for name in self.mLanguages: locale = QLocale(name) string = "%s (%s)"%(QLocale.languageToString(locale.language()), QLocale.countryToString(locale.country())) self.mUi.languageCombo.addItem(string, name) self.mUi.languageCombo.model().sort(0) self.mUi.languageCombo.insertItem(0, self.tr("System default")) self.mObjectTypesModel = ObjectTypesModel(self) self.mUi.objectTypesTable.setModel(self.mObjectTypesModel) self.mUi.objectTypesTable.setItemDelegateForColumn(1, ColorDelegate(self)) horizontalHeader = self.mUi.objectTypesTable.horizontalHeader() horizontalHeader.setSectionResizeMode(QHeaderView.Stretch) Utils.setThemeIcon(self.mUi.addObjectTypeButton, "add") Utils.setThemeIcon(self.mUi.removeObjectTypeButton, "remove") self.fromPreferences() self.mUi.languageCombo.currentIndexChanged.connect(self.languageSelected) self.mUi.openGL.toggled.connect(self.useOpenGLToggled) self.mUi.gridColor.colorChanged.connect(preferences.Preferences.instance().setGridColor) self.mUi.gridFine.valueChanged.connect(preferences.Preferences.instance().setGridFine) self.mUi.objectLineWidth.valueChanged.connect(self.objectLineWidthChanged) self.mUi.objectTypesTable.selectionModel().selectionChanged.connect(self.selectedObjectTypesChanged) self.mUi.objectTypesTable.doubleClicked.connect(self.objectTypeIndexClicked) self.mUi.addObjectTypeButton.clicked.connect(self.addObjectType) self.mUi.removeObjectTypeButton.clicked.connect(self.removeSelectedObjectTypes) self.mUi.importObjectTypesButton.clicked.connect(self.importObjectTypes) self.mUi.exportObjectTypesButton.clicked.connect(self.exportObjectTypes) self.mObjectTypesModel.dataChanged.connect(self.applyObjectTypes) self.mObjectTypesModel.rowsRemoved.connect(self.applyObjectTypes) self.mUi.autoMapWhileDrawing.toggled.connect(self.useAutomappingDrawingToggled) self.mUi.openLastFiles.toggled.connect(self.openLastFilesToggled)
def __init__(self, *args, **kwargs): super(SimpleImageView, self).__init__(*args, **kwargs) # 设置背景颜色 self.setBackgroundBrush(self.backgroundColor) # 缓存背景 self.setCacheMode(self.CacheBackground) # 设置拖拽样式 # self.setDragMode(self.ScrollHandDrag) self.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing | QPainter.SmoothPixmapTransform) # opengl if hasOpenGL and QGLFormat.hasOpenGL(): # self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers), self)) self.setRenderHint(QPainter.HighQualityAntialiasing) self.setViewportUpdateMode(self.FullViewportUpdate) else: # 尝试通过分析需要重绘的区域来找到最佳的更新模式 self.setViewportUpdateMode(self.SmartViewportUpdate) self._scene = QGraphicsScene(self) self.setScene(self._scene) # 图片item self._itemImage = None
def setHighQualityAntialiasing(self, highQualityAntialiasing): if QGLFormat.hasOpenGL(): self.setRenderHint(QPainter.HighQualityAntialiasing, highQualityAntialiasing)
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)
def __init__(self, size, parent=None): super(PadNavigator, self).__init__(parent) self.form = Ui_Form() splash = SplashItem() splash.setZValue(1) pad = FlippablePad(size) flipRotation = QGraphicsRotation(pad) xRotation = QGraphicsRotation(pad) yRotation = QGraphicsRotation(pad) flipRotation.setAxis(Qt.YAxis) xRotation.setAxis(Qt.YAxis) yRotation.setAxis(Qt.XAxis) pad.setTransformations([flipRotation, xRotation, yRotation]) backItem = QGraphicsProxyWidget(pad) widget = QWidget() self.form.setupUi(widget) self.form.hostName.setFocus() backItem.setWidget(widget) backItem.setVisible(False) backItem.setFocus() backItem.setCacheMode(QGraphicsItem.ItemCoordinateCache) r = backItem.rect() backItem.setTransform(QTransform().rotate(180, Qt.YAxis).translate(-r.width()/2, -r.height()/2)) selectionItem = RoundRectItem(QRectF(-60, -60, 120, 120), QColor(Qt.gray), pad) selectionItem.setZValue(0.5) smoothSplashMove = QPropertyAnimation(splash, b'y') smoothSplashOpacity = QPropertyAnimation(splash, b'opacity') smoothSplashMove.setEasingCurve(QEasingCurve.InQuad) smoothSplashMove.setDuration(250) smoothSplashOpacity.setDuration(250) smoothXSelection = QPropertyAnimation(selectionItem, b'x') smoothYSelection = QPropertyAnimation(selectionItem, b'y') smoothXRotation = QPropertyAnimation(xRotation, b'angle') smoothYRotation = QPropertyAnimation(yRotation, b'angle') smoothXSelection.setDuration(125) smoothYSelection.setDuration(125) smoothXRotation.setDuration(125) smoothYRotation.setDuration(125) smoothXSelection.setEasingCurve(QEasingCurve.InOutQuad) smoothYSelection.setEasingCurve(QEasingCurve.InOutQuad) smoothXRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothYRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipRotation = QPropertyAnimation(flipRotation, b'angle') smoothFlipScale = QPropertyAnimation(pad, b'scale') smoothFlipXRotation = QPropertyAnimation(xRotation, b'angle') smoothFlipYRotation = QPropertyAnimation(yRotation, b'angle') flipAnimation = QParallelAnimationGroup(self) smoothFlipScale.setDuration(500) smoothFlipRotation.setDuration(500) smoothFlipXRotation.setDuration(500) smoothFlipYRotation.setDuration(500) smoothFlipScale.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipXRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipYRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipScale.setKeyValueAt(0, 1.0) smoothFlipScale.setKeyValueAt(0.5, 0.7) smoothFlipScale.setKeyValueAt(1, 1.0) flipAnimation.addAnimation(smoothFlipRotation) flipAnimation.addAnimation(smoothFlipScale) flipAnimation.addAnimation(smoothFlipXRotation) flipAnimation.addAnimation(smoothFlipYRotation) setVariablesSequence = QSequentialAnimationGroup() setFillAnimation = QPropertyAnimation(pad, b'fill') setBackItemVisibleAnimation = QPropertyAnimation(backItem, b'visible') setSelectionItemVisibleAnimation = QPropertyAnimation(selectionItem, b'visible') setFillAnimation.setDuration(0) setBackItemVisibleAnimation.setDuration(0) setSelectionItemVisibleAnimation.setDuration(0) setVariablesSequence.addPause(250) setVariablesSequence.addAnimation(setBackItemVisibleAnimation) setVariablesSequence.addAnimation(setSelectionItemVisibleAnimation) setVariablesSequence.addAnimation(setFillAnimation) flipAnimation.addAnimation(setVariablesSequence) stateMachine = QStateMachine(self) splashState = QState(stateMachine) frontState = QState(stateMachine) historyState = QHistoryState(frontState) backState = QState(stateMachine) frontState.assignProperty(pad, "fill", False) frontState.assignProperty(splash, "opacity", 0.0) frontState.assignProperty(backItem, "visible", False) frontState.assignProperty(flipRotation, "angle", 0.0) frontState.assignProperty(selectionItem, "visible", True) backState.assignProperty(pad, "fill", True) backState.assignProperty(backItem, "visible", True) backState.assignProperty(xRotation, "angle", 0.0) backState.assignProperty(yRotation, "angle", 0.0) backState.assignProperty(flipRotation, "angle", 180.0) backState.assignProperty(selectionItem, "visible", False) stateMachine.addDefaultAnimation(smoothXRotation) stateMachine.addDefaultAnimation(smoothYRotation) stateMachine.addDefaultAnimation(smoothXSelection) stateMachine.addDefaultAnimation(smoothYSelection) stateMachine.setInitialState(splashState) anyKeyTransition = QEventTransition(self, QEvent.KeyPress, splashState) anyKeyTransition.setTargetState(frontState) anyKeyTransition.addAnimation(smoothSplashMove) anyKeyTransition.addAnimation(smoothSplashOpacity) enterTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Enter, backState) returnTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Return, backState) backEnterTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Enter, frontState) backReturnTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Return, frontState) enterTransition.setTargetState(historyState) returnTransition.setTargetState(historyState) backEnterTransition.setTargetState(backState) backReturnTransition.setTargetState(backState) enterTransition.addAnimation(flipAnimation) returnTransition.addAnimation(flipAnimation) backEnterTransition.addAnimation(flipAnimation) backReturnTransition.addAnimation(flipAnimation) columns = size.width() rows = size.height() stateGrid = [] for y in range(rows): stateGrid.append([QState(frontState) for _ in range(columns)]) frontState.setInitialState(stateGrid[0][0]) selectionItem.setPos(pad.iconAt(0, 0).pos()) for y in range(rows): for x in range(columns): state = stateGrid[y][x] rightTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Right, state) leftTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Left, state) downTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Down, state) upTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Up, state) rightTransition.setTargetState(stateGrid[y][(x + 1) % columns]) leftTransition.setTargetState(stateGrid[y][((x - 1) + columns) % columns]) downTransition.setTargetState(stateGrid[(y + 1) % rows][x]) upTransition.setTargetState(stateGrid[((y - 1) + rows) % rows][x]) icon = pad.iconAt(x, y) state.assignProperty(xRotation, "angle", -icon.x() / 6.0) state.assignProperty(yRotation, "angle", icon.y() / 6.0) state.assignProperty(selectionItem, "x", icon.x()) state.assignProperty(selectionItem, "y", icon.y()) frontState.assignProperty(icon, "visible", True) backState.assignProperty(icon, "visible", False) setIconVisibleAnimation = QPropertyAnimation(icon, b'visible') setIconVisibleAnimation.setDuration(0) setVariablesSequence.addAnimation(setIconVisibleAnimation) scene = QGraphicsScene(self) scene.setBackgroundBrush(QBrush(QPixmap(":/images/blue_angle_swirl.jpg"))) scene.setItemIndexMethod(QGraphicsScene.NoIndex) scene.addItem(pad) scene.setSceneRect(scene.itemsBoundingRect()) self.setScene(scene) sbr = splash.boundingRect() splash.setPos(-sbr.width() / 2, scene.sceneRect().top() - 2) frontState.assignProperty(splash, "y", splash.y() - 100.0) scene.addItem(splash) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setMinimumSize(50, 50) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) self.setCacheMode(QGraphicsView.CacheBackground) self.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform | QPainter.TextAntialiasing) if QGLFormat.hasOpenGL(): self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) stateMachine.start()
def quad(self, primitive, x1, y1, x2, y2, x3, y3, x4, y4): GL.glBegin(primitive) GL.glVertex2d(x1, y1) GL.glVertex2d(x2, y2) GL.glVertex2d(x3, y3) GL.glVertex2d(x4, y4) GL.glEnd() if __name__ == '__main__': app = QApplication(sys.argv) f = QGLFormat.defaultFormat() f.setSampleBuffers(True) QGLFormat.setDefaultFormat(f) if not QGLFormat.hasOpenGL(): QMessageBox.information(None, "OpenGL samplebuffers", "This system does not support OpenGL.") sys.exit(0) widget = GLWidget(None) if not widget.format().sampleBuffers(): QMessageBox.information(None, "OpenGL samplebuffers", "This system does not have sample buffer support.") sys.exit(0)
def __init__(self): super(Gui, self).__init__([]) self.acdata = ACDataEvent() self.routedata = RouteDataEvent() self.radarwidget = None 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 >= 0x050000: self.setAttribute(Qt.AA_UseHighDpiPixmaps)
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_()
print("[FAIL]") else: v = OpenGL.__version__.split('.') ver = float(v[0]) + 0.1 * int(v[1]) gl = (ver >= 3.1) if gl: print('[OK]') else: print('[FAIL]') print('OpenGL module version should be at least 3.1.0') print('OpenGL module version is [%s]' % OpenGL.__version__) print("Checking GL capabilities ", end=' ') app = QApplication([]) if not QGLFormat.hasOpenGL(): print('[FAIL]') else: print('[OK]') print('GL Version at least 3.3 ', end=' ') try: f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.CoreProfile) f.setDoubleBuffer(True) QGLFormat.setDefaultFormat(f) class GLTest(QGLWidget): gl_version = 0.0 def __init__(self):
def __init__(self): super(Gui, self).__init__([]) self.acdata = ACDataEvent() self.routedata = RouteDataEvent() self.radarwidget = None 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 >= 0x050000: self.setAttribute(Qt.AA_UseHighDpiPixmaps)
def __init__(self): super(MainWindow, self).__init__() self.currentPath = "" self.view = SvgView() fileMenu = QMenu("&File", self) openAction = fileMenu.addAction("&Open...") openAction.setShortcut("Ctrl+O") quitAction = fileMenu.addAction("E&xit") quitAction.setShortcut("Ctrl+Q") self.menuBar().addMenu(fileMenu) viewMenu = QMenu("&View", self) self.backgroundAction = viewMenu.addAction("&Background") self.backgroundAction.setEnabled(False) self.backgroundAction.setCheckable(True) self.backgroundAction.setChecked(False) self.backgroundAction.toggled.connect(self.view.setViewBackground) self.outlineAction = viewMenu.addAction("&Outline") self.outlineAction.setEnabled(False) self.outlineAction.setCheckable(True) self.outlineAction.setChecked(True) self.outlineAction.toggled.connect(self.view.setViewOutline) self.menuBar().addMenu(viewMenu) rendererMenu = QMenu("&Renderer", self) self.nativeAction = rendererMenu.addAction("&Native") self.nativeAction.setCheckable(True) self.nativeAction.setChecked(True) if QGLFormat.hasOpenGL(): self.glAction = rendererMenu.addAction("&OpenGL") self.glAction.setCheckable(True) self.imageAction = rendererMenu.addAction("&Image") self.imageAction.setCheckable(True) if QGLFormat.hasOpenGL(): rendererMenu.addSeparator() self.highQualityAntialiasingAction = rendererMenu.addAction( "&High Quality Antialiasing") self.highQualityAntialiasingAction.setEnabled(False) self.highQualityAntialiasingAction.setCheckable(True) self.highQualityAntialiasingAction.setChecked(False) self.highQualityAntialiasingAction.toggled.connect( self.view.setHighQualityAntialiasing) rendererGroup = QActionGroup(self) rendererGroup.addAction(self.nativeAction) if QGLFormat.hasOpenGL(): rendererGroup.addAction(self.glAction) rendererGroup.addAction(self.imageAction) self.menuBar().addMenu(rendererMenu) openAction.triggered.connect(self.openFile) quitAction.triggered.connect(QApplication.instance().quit) rendererGroup.triggered.connect(self.setRenderer) self.setCentralWidget(self.view) self.setWindowTitle("SVG Viewer")
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_()
def __init__(self): super(MainWindow, self).__init__() self.currentPath = '' self.view = SvgView() fileMenu = QMenu("&File", self) openAction = fileMenu.addAction("&Open...") openAction.setShortcut("Ctrl+O") quitAction = fileMenu.addAction("E&xit") quitAction.setShortcut("Ctrl+Q") self.menuBar().addMenu(fileMenu) viewMenu = QMenu("&View", self) self.backgroundAction = viewMenu.addAction("&Background") self.backgroundAction.setEnabled(False) self.backgroundAction.setCheckable(True) self.backgroundAction.setChecked(False) self.backgroundAction.toggled.connect(self.view.setViewBackground) self.outlineAction = viewMenu.addAction("&Outline") self.outlineAction.setEnabled(False) self.outlineAction.setCheckable(True) self.outlineAction.setChecked(True) self.outlineAction.toggled.connect(self.view.setViewOutline) self.menuBar().addMenu(viewMenu) rendererMenu = QMenu("&Renderer", self) self.nativeAction = rendererMenu.addAction("&Native") self.nativeAction.setCheckable(True) self.nativeAction.setChecked(True) if QGLFormat.hasOpenGL(): self.glAction = rendererMenu.addAction("&OpenGL") self.glAction.setCheckable(True) self.imageAction = rendererMenu.addAction("&Image") self.imageAction.setCheckable(True) if QGLFormat.hasOpenGL(): rendererMenu.addSeparator() self.highQualityAntialiasingAction = rendererMenu.addAction("&High Quality Antialiasing") self.highQualityAntialiasingAction.setEnabled(False) self.highQualityAntialiasingAction.setCheckable(True) self.highQualityAntialiasingAction.setChecked(False) self.highQualityAntialiasingAction.toggled.connect(self.view.setHighQualityAntialiasing) rendererGroup = QActionGroup(self) rendererGroup.addAction(self.nativeAction) if QGLFormat.hasOpenGL(): rendererGroup.addAction(self.glAction) rendererGroup.addAction(self.imageAction) self.menuBar().addMenu(rendererMenu) openAction.triggered.connect(self.openFile) quitAction.triggered.connect(QApplication.instance().quit) rendererGroup.triggered.connect(self.setRenderer) self.setCentralWidget(self.view) self.setWindowTitle("SVG Viewer")
increment = 10 val = self.remainder + self.rate / 0.02 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)
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))
def __init__(self, parent): super(GLWidget, self).__init__(QGLFormat(QGL.SampleBuffers), parent) self.move(0, 0) self.resize(int(parent.width() / 1.61803398875), parent.height()) self.fig = Figure(self)
increment = 10 val = self.remainder + self.rate / 0.02 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)