def _init_specific(self, p, kwargs): # Deal with config glformat = _set_config(p.context.config) glformat.setSwapInterval(1 if p.vsync else 0) # Deal with context widget = kwargs.pop('shareWidget', None) or self p.context.shared.add_ref('qt', widget) if p.context.shared.ref is widget: if widget is self: widget = None # QGLWidget does not accept self ;) else: widget = p.context.shared.ref if 'shareWidget' in kwargs: raise RuntimeError('Cannot use vispy to share context and ' 'use built-in shareWidget.') # first arg can be glformat, or a gl context if p.always_on_top or not p.decorate: hint = 0 hint |= 0 if p.decorate else QtCore.Qt.FramelessWindowHint hint |= QtCore.Qt.WindowStaysOnTopHint if p.always_on_top else 0 else: hint = QtCore.Qt.Widget # can also be a window type QGLWidget.__init__(self, glformat, p.parent, widget, hint) self._initialized = True if not self.isValid(): raise RuntimeError('context could not be created') self.setAutoBufferSwap(False) # to make consistent with other backends self.setFocusPolicy(QtCore.Qt.WheelFocus)
def __init__(self, figure): FigureCanvasQT.__init__(self, figure) QGLWidget.__init__(self) self.drawRect = False self.rect = [] self.blitbox = None self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
def __init__(self, motor, lista_actores, ancho, alto, gestor_escenas, permitir_depuracion): QGLWidget.__init__(self, None) self.painter = QtGui.QPainter() self.setMouseTracking(True) self.pausa_habilitada = False self.mouse_x = 0 self.mouse_y = 0 self.motor = motor self.lista_actores = lista_actores self.fps = fps.FPS(60, True) if permitir_depuracion: self.depurador = depurador.Depurador(motor.obtener_lienzo(), self.fps) else: self.depurador = depurador.DepuradorDeshabilitado() self.original_width = ancho self.original_height = alto self.escala = 1 self.startTimer(1000 / 100.0) self.gestor_escenas = gestor_escenas
def __init__(self, parent): QGLWidget.__init__(self, parent) self.setMinimumSize(400, 300) self.angle = 0.0 self.graphicsDevice = None self.meshSubset = None
def _init_specific(self, vsync, dec, fs, parent, context, kwargs): # Deal with context if not context.istaken: widget = kwargs.pop('shareWidget', None) or self context.take('qt', widget) glformat = _set_config(context.config) glformat.setSwapInterval(1 if vsync else 0) if widget is self: widget = None # QGLWidget does not accept self ;) elif context.istaken == 'qt': widget = context.backend_canvas glformat = QGLFormat.defaultFormat() if 'shareWidget' in kwargs: raise RuntimeError('Cannot use vispy to share context and ' 'use built-in shareWidget.') else: raise RuntimeError('Different backends cannot share a context.') # first arg can be glformat, or a gl context f = QtCore.Qt.Widget if dec else QtCore.Qt.FramelessWindowHint QGLWidget.__init__(self, glformat, parent, widget, f) self._initialized = True if not self.isValid(): raise RuntimeError('context could not be created') self.setAutoBufferSwap(False) # to make consistent with other backends
def __init__(self, parent=None, name=None): QGLWidget.__init__(self, parent, name) self.parent = parent self.vertices = [(-0.5, -0.5, -0.5), (0.5, -0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, 0.5, -0.5), (-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, 0.5)] self.normals = [ (1, 0, 0), (0, 1, 0), (0, 0, 1), (-1, 0, 0), (0, -1, 0), (0, 0, -1), ] self.m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] self.rel_x = 0 self.rel_y = 0 self.rel_z = 0 self.rel_w = 0 self.save_orientation_flag = False self.has_save_orientation = False self.display_list = None
def glDraw(self): QGLWidget.glDraw(self) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity() # glTranslatef(0.0, -26.0, -100.0) fps = time() - self.timer self.renderText(20, 20, "Test! %d" % fps) glRotatef(self.rotation['x'], 1, 0, 0) glRotatef(self.rotation['y'], 0, 1, 0) glRotatef(self.rotation['z'], 0, 0, 1) glScalef(self.scale, self.scale, self.scale) # # glBegin(GL_QUADS) # glVertex2f(0, 0) # glVertex2f(10, 0) # glVertex2f(10, 10) # glVertex2f(0, 10) # glEnd() self.timer = time() self.drawfloor() for s in self.stl: s.draw()
def __init__(self, parent=None, name=None): QGLWidget.__init__(self, parent, name) self.parent = parent self.vertices = ( (-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,-1.0,1.0), (1.0,1.0,1.0), (-1.0,1.0,1.0) ) self.pins = [(-0.8, -0.9), (-0.8, -0.65), (-0.8, -0.4), (-0.6, -0.9), (-0.6, -0.65), (-0.6, -0.4), (0.9, 0.8), (0.65, 0.8), (0.4, 0.8), (0.15, 0.8), (0.9, 0.6), (0.65, 0.6), (0.4, 0.6), (0.15, 0.6)] self.m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] self.rel_x = 0 self.rel_y = 0 self.rel_z = 0 self.rel_w = 0 self.save_orientation_flag = False self.has_save_orientation = False self.display_list = None
def __init__(self, parent=None): QGLWidget.__init__(self, parent) self._image2Display = [] self._texture = [] #: Opengl texture variable self._zoom = 1.0 self._mouseX = 0.0 self._mouseY = 0.0 self._width = 1.0 self._height = 1.0 self._glX = 0.0 self._glY = 0.0 self._glZ = 0.0 self._x = 0.0 self._y = 0.0 self._lastGlX = 0.0 self._lastGlY = 0.0 self._mouseDown = False self._mouseLeftDown = False self._mouseRightDown = False self._mouseStartDragPoint = None self.setMinimumHeight(100) self.setMouseTracking(True)
def __init__(self, viewer, parent, texture_file): QGLWidget.__init__(self) threading.Thread.__init__(self) self.texture_file = texture_file self.program_active = True self.mouse_origin = 0 self.alpha = .2 self.mouse_pos = None self.x_ticks = 0 self.y_ticks = 0 self.view = viewer.get_View() self.data_sets = viewer.get_Data() self.title = viewer.get_Title() self.tool_qb = ToolQB() self.rubberband = RectRubberband() self.setMouseTracking(True) self.prevView = None self.kd_tree = [] self.kd_tree_active = False self.graphicsProxyWidget() self.scale_x = 0 self.scale_y = 0 self.width = 0 self.height = 0 self.ratio = 0 self.orig_kd_tree = None self.lock = thread.allocate_lock() self.parent = parent # Starts the thread of anything inside of the run() method self.start()
def _get_bg_image_comparison_data(self): """ """ data = ( self.graphicsMode, # often too conservative, but not always # bug: some graphicsModes use prefs or PM settings to decide # how much of the model to display; this ignores those # bug: some GMs do extra drawing in .Draw; this ignores prefs etc that affect that self._fog_test_enable, self.displayMode, # display style self.part, self.part.assy.all_change_indicators( ), # TODO: fix view change indicator for this to work fully # note: that's too conservative, since it notices changes in other parts (e.g. from Copy Selection) # KLUGE until view change indicator is fixed -- include view data # directly; should be ok indefinitely +self. quat, # this hit a bug in same_vals (C version), fixed by Eric M 080922 in samevalshelp.c rev 14311 ## + self.quat.vec, # workaround for that bug (works) +self.pov, self.scale, self.zoomFactor, self.width, self.height, QGLWidget.width(self), # in case it disagrees with self.width QGLWidget.height(self), self. _resize_counter, # redundant way to force new grab after resize # (tho it might be safer to completely disable the feature # for a frame, after resize ### TRYIT) self.ortho, ) return data
def __init__(self): # init the widget #QWidget.__init__(self, parent) # set up the scene self.scene = QGraphicsScene() self.scene.setSceneRect(0, 0, 800, 600) # add a view of that scene self.view = QGraphicsView() self.view.setScene(self.scene) self.view.setRenderHint(QPainter.Antialiasing) self.view.setFixedSize(800, 600) self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # set the screen sync to vertical retrace val = "1" # Set for nVidia linux os.environ["__GL_SYNC_TO_VBLANK"] = val # Set for recent linux Mesa DRI Radeon os.environ["LIBGL_SYNC_REFRESH"] = val qglf = QGLFormat() qglf.setSampleBuffers(True) self.glw = QGLWidget(qglf) self.glw.setAutoBufferSwap(False) self.view.setViewport(self.glw) #self.view.showFullScreen() self.view.show() self.last_finish = 0 QTimer.singleShot(0, self.glw.swapBuffers)
def __init__(self): if not QGLWidget: print "Lo siento, OpenGL no esta disponible..." QGLWidget.__init__(self) QtBase.__init__(self) self._pintar_fondo_negro()
def __init__(self, parent=None): QGLWidget.__init__(self, parent) self.image2Display = [] self.texture = [] self.setMouseTracking(True) self.zoom = 1.0 self._mouseX = 0.0 self._mouseY = 0.0 self._glX = 0.0 self._glY = 0.0 self._glZ = 0.0 self._lastGlX = 0.0 self._lastGlY = 0.0 self._mouseDown = False self._mouseLeftDown = False self._mouseRightDown = False self._width = 1.0 self._height = 1.0 self._x = 0 self._y = 0 self.imgWidth = 1 self.imgHeight = 1 self._rotateZ = 0 self._rotateX = 0 self._mouseStartDragPoint = None # Message to show on the left corner of the screen self._helpText = None self.setMinimumHeight(100) self._point = None self._pendingFrames = None
def mousePressEvent(self, event): if event.button() == QtCore.Qt.LeftButton: self.mousePressEventLeft(event) elif event.button() == QtCore.Qt.RightButton: self.mousePressEventRight(event) QGLWidget.mousePressEvent(self, event)
def __init__(self, parent, enableUi,File=""): f = QGLFormat() f.setStencil(True) f.setRgba(True) f.setDepth(True) f.setDoubleBuffer(True) QGLWidget.__init__(self, f, parent=parent) self.setMinimumSize(500, 500) self._enableUi=enableUi self.pymol = pymol2.PyMOL()# _pymolPool.getInstance() self.pymol.start() self.cmd = self.pymol.cmd # self.toPymolName = self.pymol.toPymolName ### Attribute Error self._pymolProcess() if not self._enableUi: self.pymol.cmd.set("internal_gui",0) self.pymol.cmd.set("internal_feedback",0) self.pymol.cmd.button("double_left","None","None") self.pymol.cmd.button("single_right","None","None") self.pymol.cmd.load(File) self.pymol.reshape(self.width(),self.height()) self._timer = QtCore.QTimer() self._timer.setSingleShot(True) self._timer.timeout.connect(self._pymolProcess) self.resizeGL(self.width(),self.height()) #globalSettings.settingsChanged.connect(self._updateGlobalSettings) self._updateGlobalSettings()
def __init__(self,parent=None): QGLWidget.__init__(self,parent) self.setMouseTracking(True) # self.setMinimumSize(500, 500) self.camera = Camera() self.camera.setSceneRadius( 2 ) self.camera.reset() self.isPressed = False self.inFullscreen = False self.oldx = 0 self.oldy = 0 self.decalage=-10 self.sizef=1.0 self.taille=0 self.virtualNao = None#Nao3D() self.size(0) self.font = QtGui.QFont("Helvetica",5) self.font_offset=[20,20,20] self.background = QtGui.QColor(125,125,255)
def __init__(self, parent=None): self.logger = logging.getLogger('pyforms') QGLWidget.__init__(self, parent) self.image2Display = [] self.texture = [] self.setMouseTracking(True) self.zoom = 1.0 self._mouseX = 0.0 self._mouseY = 0.0 self._glX = 0.0 self._glY = 0.0 self._glZ = 0.0 self._lastGlX = 0.0 self._lastGlY = 0.0 self._mouseDown = False self._mouseLeftDown = False self._mouseRightDown = False self._width = 1.0 self._height = 1.0 self._x = 0 self._y = 0 self.imgWidth = 1 self.imgHeight = 1 self._rotateZ = 0 self._rotateX = 0 self._mouseStartDragPoint = None # Message to show on the left corner of the screen self._helpText = None self.setMinimumHeight(100) self._point = None self._pendingFrames = None
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 _get_bg_image_comparison_data(self): """ """ data = ( self.graphicsMode, # often too conservative, but not always # bug: some graphicsModes use prefs or PM settings to decide # how much of the model to display; this ignores those # bug: some GMs do extra drawing in .Draw; this ignores prefs etc that affect that self._fog_test_enable, self.displayMode, # display style self.part, self.part.assy.all_change_indicators(), # TODO: fix view change indicator for this to work fully # note: that's too conservative, since it notices changes in other parts (e.g. from Copy Selection) # KLUGE until view change indicator is fixed -- include view data # directly; should be ok indefinitely + self.quat, # this hit a bug in same_vals (C version), fixed by Eric M 080922 in samevalshelp.c rev 14311 ## + self.quat.vec, # workaround for that bug (works) + self.pov, self.scale, self.zoomFactor, self.width, self.height, QGLWidget.width(self), # in case it disagrees with self.width QGLWidget.height(self), self._resize_counter, # redundant way to force new grab after resize # (tho it might be safer to completely disable the feature # for a frame, after resize ### TRYIT) self.ortho, ) return data
def __init__(self, parent=None): QGLWidget.__init__(self, parent) self._zoom = 1.0 self._scene = None self._rotation = [0, 0, 0] self._mouseLeftDown = False self._mouseRightDown = False self._mouseGLPosition = [0,0,0] self._lastMouseGLPosition = [0,0,0] self._mousePosition = [0,0] #Current mouse position self._lastMousePosition = [0,0] #Last mouse position self._mouseStartDragPoint = None self._clear_color = None self.setMinimumHeight(100) self.setMinimumWidth(100) self.setMouseTracking(True) self.setAcceptDrops(True) self.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding);
def __init__(self, motor, ancho, alto, gestor_escenas, permitir_depuracion, rendimiento): QGLWidget.__init__(self, None) self.painter = QtGui.QPainter() self.pausa_habilitada = False self.setMouseTracking(True) self.mouse_x = 0 self.mouse_y = 0 self.motor = motor self.fps = fps.FPS(rendimiento, True) if permitir_depuracion: self.depurador = depurador.Depurador(motor.obtener_lienzo(), self.fps) else: self.depurador = depurador.DepuradorDeshabilitado() self.original_width = ancho self.original_height = alto self.escala = 1 self.startTimer(1000/100.0) self.gestor_escenas = gestor_escenas
def _init_specific(self, p, kwargs): # Deal with config glformat = _set_config(p.context.config) glformat.setSwapInterval(1 if p.vsync else 0) # Deal with context widget = kwargs.pop('shareWidget', None) or self p.context.shared.add_ref('qt', widget) if p.context.shared.ref is widget: if widget is self: widget = None # QGLWidget does not accept self ;) else: widget = p.context.shared.ref if 'shareWidget' in kwargs: raise RuntimeError('Cannot use vispy to share context and ' 'use built-in shareWidget.') qt_window_types = QtCore.Qt.WindowType if PYQT6_API else QtCore.Qt if p.always_on_top or not p.decorate: hint = 0 hint |= 0 if p.decorate else qt_window_types.FramelessWindowHint hint |= qt_window_types.WindowStaysOnTopHint if p.always_on_top else 0 else: hint = qt_window_types.Widget # can also be a window type if QT5_NEW_API or PYSIDE6_API or PYQT6_API: # Qt5 >= 5.4.0 - sharing is automatic QGLWidget.__init__(self, p.parent, hint) # Need to create an offscreen surface so we can get GL parameters # without opening/showing the Widget. PyQt5 >= 5.4 will create the # valid context later when the widget is shown. self._secondary_context = QtGui.QOpenGLContext() self._secondary_context.setShareContext(self.context()) self._secondary_context.setFormat(glformat) self._secondary_context.create() self._surface = QtGui.QOffscreenSurface() self._surface.setFormat(glformat) self._surface.create() self._secondary_context.makeCurrent(self._surface) else: # Qt4 and Qt5 < 5.4.0 - sharing is explicitly requested QGLWidget.__init__(self, p.parent, widget, hint) # unused with this API self._secondary_context = None self._surface = None self.setFormat(glformat) self._initialized = True if not QT5_NEW_API and not PYSIDE6_API and not PYQT6_API and not self.isValid( ): # On Qt5 >= 5.4.0, isValid is only true once the widget is shown raise RuntimeError('context could not be created') if not QT5_NEW_API and not PYSIDE6_API and not PYQT6_API: # to make consistent with other backends self.setAutoBufferSwap(False) qt_focus_policies = QtCore.Qt.FocusPolicy if PYQT6_API else QtCore.Qt self.setFocusPolicy(qt_focus_policies.WheelFocus)
def __init__(self): QGLWidget.__init__(self) self.setFocusPolicy(QtCore.Qt.StrongFocus) self.count = 0 self.makeData() self.idleTimer = QtCore.QTimer() self.idleTimer.timeout.connect(self.iterate) self.idleTimer.start(0)
def __init__(self, parent=None): QGLWidget.__init__(self, parent) self.setWindowFlags(Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground, True) # self.setGeometry(200, 100, 640, 480) self.showFullScreen() self.root = Folder('/') self.root.read() print self.root.files
def changeRendering(self): if parameters.instance.use_OpenGL: self.ui.previousData.setViewport( QGLWidget(QGLFormat(QGL.SampleBuffers))) self.ui.currentData.setViewport( QGLWidget(QGLFormat(QGL.SampleBuffers))) else: self.ui.previousData.setViewport(QWidget()) self.ui.currentData.setViewport(QWidget())
def mousePressEvent(self, event): QGLWidget.mousePressEvent(self, event) self.__updateMouse(event, pressed = True) self.repaint() if self._mouseLeftDown: self._mouseStartDragPoint = self._mouseGLPosition if self._mouseRightDown: self._lastMouseGLPosition = self._mouseGLPosition self.onPress( event.button(), self._mousePosition, self._mouseGLPosition )
def __init__(self, parent): QGLWidget.__init__(self, parent) cfg = Config('game', 'OpenGL') self.fps = cfg.get('fps') self.clearColor = cfg.get('clear_color') self.adjust_widget() self.adjust_timer()
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, parent): QGLWidget.__init__(self, parent) self.setMinimumSize(200, 200) # glutInit()#sys.argv) self.coords = {1: None, 2: None} self.minima = {1: None, 2: None} self.last_mouse_pos = QtCore.QPointF(0., 0.) self.rotation = rot.aa2mx(np.array([0., 0., 0.])) # np.array([0., 0.]) self.zoom = 1.0 self._fatal_error = False # don't try to plot if it won't work
def __init__(self, parent): QGLWidget.__init__(self, parent) self.setMinimumSize(200, 200) # glutInit()#sys.argv) self.coords = {1:None, 2:None} self.minima = {1:None, 2:None} self.last_mouse_pos = QtCore.QPointF(0., 0.) self.rotation = rot.aa2mx(np.array([0.,0.,0.])) # np.array([0., 0.]) self.zoom = 1.0 self._fatal_error = False # don't try to plot if it won't work
def __init__(self, parent): #print "GLPlotWidget.__init__" QGLWidget.__init__(self, parent) self.setMinimumSize(self.width, self.height) self.frameCount = 0 # Set up a timer to call updateGL() every 0 ms self.timer = QTimer() self.timer.setInterval(10) #self.timer.timeout.connect(self.updateWidget) self.timer.timeout.connect(self.updateGL)
def __init__(self): QGLWidget.__init__(self) self.setFocusPolicy(QtCore.Qt.StrongFocus) # Window space to M-space transform parameters. self.zoom = 1. self.offset = [-0.5, 0.] # Set a timer to evaluate more iterations when idle. self.idleTimer = QtCore.QTimer() self.idleTimer.timeout.connect(self.updateGL) self.idleTimer.start(0)
def mouseMoveEvent(self, event): QGLWidget.mouseMoveEvent(self, event) self._mouseX = event.x() self._mouseY = event.y() self.repaint() self.onMove( (self._glX - self._x, self._height-self._glY + self._y ) ) if self._mouseDown: if self._mouseLeftDown: self.onDrag( self._mouseStartDragPoint, (self._glX - self._x, self._height-self._glY + self._y ) )
def __init__(self, parent): QGLWidget.__init__(self, parent) cfg = Config('game','OpenGL') self.fps = cfg.get('fps') self.clearColor = cfg.get('clear_color') self.adjust_widget() self.adjust_timer()
def _init_specific(self, p, kwargs): # Deal with config glformat = _set_config(p.context.config) glformat.setSwapInterval(1 if p.vsync else 0) # Deal with context widget = kwargs.pop('shareWidget', None) or self p.context.shared.add_ref('qt', widget) if p.context.shared.ref is widget: if widget is self: widget = None # QGLWidget does not accept self ;) else: widget = p.context.shared.ref if 'shareWidget' in kwargs: raise RuntimeError('Cannot use vispy to share context and ' 'use built-in shareWidget.') if p.always_on_top or not p.decorate: hint = 0 hint |= 0 if p.decorate else QtCore.Qt.FramelessWindowHint hint |= QtCore.Qt.WindowStaysOnTopHint if p.always_on_top else 0 else: hint = QtCore.Qt.Widget # can also be a window type if QT5_NEW_API: # Qt5 >= 5.4.0 - sharing is automatic QGLWidget.__init__(self, p.parent, hint) # Need to create an offscreen surface so we can get GL parameters # without opening/showing the Widget. PyQt5 >= 5.4 will create the # valid context later when the widget is shown. self._secondary_context = QtGui.QOpenGLContext() self._secondary_context.setShareContext(self.context()) self._secondary_context.setFormat(glformat) self._secondary_context.create() self._surface = QtGui.QOffscreenSurface() self._surface.setFormat(glformat) self._surface.create() self._secondary_context.makeCurrent(self._surface) else: # Qt4 and Qt5 < 5.4.0 - sharing is explicitly requested QGLWidget.__init__(self, p.parent, widget, hint) # unused with this API self._secondary_context = None self._surface = None self.setFormat(glformat) self._initialized = True if not QT5_NEW_API and not self.isValid(): # On Qt5 >= 5.4.0, isValid is only true once the widget is shown raise RuntimeError('context could not be created') if not QT5_NEW_API: # to make consistent with other backends self.setAutoBufferSwap(False) self.setFocusPolicy(QtCore.Qt.WheelFocus)
def __init__(self, stlfile, parent=None): QGLWidget.__init__(self, parent) self.setMinimumSize(500, 500) if isinstance(stlfile, (list, tuple)): self.stl = stlfile else: self.stl = (stlfile, ) self.timer = time() self.rotation = {'x': 0, 'y': 0, 'z': 0} self.scale = 1
def __init__(self, parent = None): if hasattr(QGLFormat, 'setVersion'): # Modern OpenGL f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.CoreProfile) c = QGLContext(f, None) QGLWidget.__init__(self, c, parent) print "Version is set to 3.3" else: QGLWidget.__init__(self, parent)
def __init__(self, parent=None, name=None): QGLWidget.__init__(self, parent, name) self.parent = parent col = parent.palette().background().color() self.color_background = (col.redF(), col.greenF(), col.blueF(), 1.0) self.color_led_red = (1.0, 0.0, 0.0) self.color_led_green = (0.0, 1.0, 0.0) self.color_board = (0.0, 0.7, 0.0) self.color_connector = (0.0, 0.0, 0.0) self.vertices = ( (-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,-1.0,1.0), (1.0,1.0,1.0), (-1.0,1.0,1.0) ) self.pins = [(-0.8, -0.9), (-0.8, -0.65), (-0.8, -0.4), (-0.6, -0.9), (-0.6, -0.65), (-0.6, -0.4), (0.9, 0.8), (0.65, 0.8), (0.4, 0.8), (0.15, 0.8), (0.9, 0.6), (0.65, 0.6), (0.4, 0.6), (0.15, 0.6)] self.initializeGL() self.roll = 0 self.pitch = 0 self.yaw = 0 self.m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] # self.rel_x = 0.5 # self.rel_y = 0.5 # self.rel_z = 0.5 # self.rel_w = -0.5 #-0.298943519592 0.347722858191 0.643775999546 -0.612596035004 #-0.338646441698 -0.623645305634 0.64221572876 0.289730906487 self.rel_x = -0.338646441698 self.rel_y = -0.623645305634 self.rel_z = 0.64221572876 self.rel_w = 0.289730906487 self.rel_roll = -180 self.rel_pitch = -90 self.rel_yaw = -60 self.save_orientation_flag = False
def __init__(self, parent): # Inizializza Antenato QGLWidget.__init__(self, parent) self.xyRotation = 0.0 self.rotationAroundX = 0.0 self.zoom = 1.0 self.eye = lib.Vectorial.Point3d([-20, -20, 20]) self.target = lib.Vectorial.Point3d([0, -60, 0])
def mouseMoveEvent(self, event): QGLWidget.mouseMoveEvent(self, event) self._mouseX = event.x() self._mouseY = event.y() self.repaint() self.onMove((self._glX - self._x, self._height - self._glY + self._y)) if self._mouseDown: if self._mouseLeftDown: self.onDrag( self._mouseStartDragPoint, (self._glX - self._x, self._height - self._glY + self._y))
def __init__(self, parent = None): QGLWidget.__init__(self, parent) self.setMinimumSize( 200, 200 ) self.models = [] self.dockwidgets = [] self.cameraRotate = [0, 0, 0] self.cameraTranslate = [0 ,0, -20] self.oldx = 0.0 self.oldy = 0.0 self.x = 1 self.y = 1 self.lastColor = 0
def __init__(self): QGLWidget.__init__(self) self.setMinimumSize(self.width, self.height) self.x = None self.y = None self.lines = [] self.points = [] self.timer = QtCore.QTimer() QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.repaint) self.timer.start(100)
def resizeGL(self, width, height): QGLWidget.resizeGL(self, width, height) glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() cfg = Config('game', 'OpenGL') fovy = cfg.get('y_field_of_view') z_near = cfg.get('z_near') z_far = cfg.get('z_far') gluPerspective(fovy, float(width) / height, z_near, z_far)
def resizeGL(self, width, height): QGLWidget.resize(self, width, height) glViewport(0, 0, self.width(), self.height()) # glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(70, 1.0 * self.width() / self.height(), 0.1, 1000.0) gluLookAt(100, 100, 100, 0, 0, 0, 0, 1, 0) glMatrixMode(GL_MODELVIEW) glLoadIdentity()
def resizeGL(self, width, height): """ Called upon window resizing: reinitialize the viewport. """ # update the window size self.width, self.height = width, height self.x_ticks = int(self.width / 80) self.y_ticks = int(self.height / 14) if self.y_ticks > 6: self.y_ticks = int(self.y_ticks / 1.5) self.setOrtho(self.view.view()) #print "Resizing" QGLWidget.resizeGL(self, width, height)
def resizeGL(self, width, height): QGLWidget.resizeGL(self,width,height) glViewport(0,0,width,height) glMatrixMode(GL_PROJECTION) glLoadIdentity() cfg = Config('game','OpenGL') fovy = cfg.get('y_field_of_view') z_near = cfg.get('z_near') z_far = cfg.get('z_far') gluPerspective(fovy,float(width)/height,z_near,z_far)
def __init__(self, images, viewManager, shape, sharedOpenGLWidget): QGLWidget.__init__(self, shareWidget = sharedOpenGLWidget) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.viewManger = viewManager self.images = images self.sceneShape = shape self.sceneItems = [] self.initialized = False self.tex = [] self.tex.append(-1) self.tex.append(-1) self.tex.append(-1)
def mouseMoveEvent(self, event): QGLWidget.mouseMoveEvent(self, event) self.__updateMouse(event) self.repaint() self.onMove( (self._mouseGLPosition[0], self._mouseGLPosition[1] ) ) if self.mouseDown: if self._mouseLeftDown: #p = self._mouseGLPosition[0] - self._x, self._mouseGLPosition[1] + self._y #p = self._mouseGLPosition[0], self._mouseGLPosition[1] self.onDrag(self._lastMousePosition, self._mousePosition) self._lastMousePosition = list(self._mousePosition)
def __init__(self, parent=None): self.logger = logging.getLogger('pyforms') QGLWidget.__init__(self, parent) self.image_2_display = [] self.textures = [] self.setMouseTracking(True) self.zoom = 0.0 self._mouseX = 0.0 self._mouseY = 0.0 #These variable are updated everytime the opengl scene is rendered #and a mouse button is down self._glX = 0.0 self._glY = 0.0 self._glZ = 0.0 #Last mouse opengl calculated position #This variable is updated everytime the opengl scene is rendered #and a mouse button is down self._last_mouse_gl_pos = None self._lastGlX = 0.0 #Last self._lastGlY = 0.0 self._mouseDown = False self._mouseLeftDown = False self._move_img = False self._width = 1.0 self._height = 1.0 self._x = 0 self._y = 0 self.imgWidth = 1 self.imgHeight = 1 self._rotateZ = 0 self._rotateX = 0 self._mouseStartDragPoint = None # Message to show on the left corner of the screen self._helpText = None self.setMinimumHeight(100) self._point = None self._pending_frames = None self._tmp_msg = None self._font = QtGui.QFont() self._font.setPointSize(conf.PYFORMS_CONTROLPLAYER_FONT)
def __init__(self, parent=None, label=None, width=None, height=None): QGLWidget.__init__(self, parent) self.width = width self.height = height self.label = QtGui.QLabel( label) if label is not None else QtGui.QLabel() # self.label.setStyleSheet('color: red') self.grid = GridWidget(self, width, height) self.console = QDbgConsole(self) gridLayout = QtGui.QGridLayout() gridLayout.addWidget(self.label, 0, 0, 1, 1) # gridLayout.addWidget(QtGui.QLabel("Red Square"), 0, 1, 1, 1) gridLayout.addWidget(self.grid, 1, 0, 1, 1) gridLayout.addWidget(self.console, 2, 0, 1, 1) self.setLayout(gridLayout)