示例#1
0
    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
示例#2
0
    def __init__(self, parent):
        QGLWidget.__init__(self, parent)

        self.setMinimumSize(400, 300)
        self.angle = 0.0
        self.graphicsDevice = None
        self.meshSubset = None
    def __init__(self):
        if not QGLWidget:
            print "Lo siento, OpenGL no esta disponible..."

        QGLWidget.__init__(self)
        QtBase.__init__(self)
        self._pintar_fondo_negro()
示例#4
0
文件: _qt.py 项目: Peque/vispy
 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
示例#5
0
    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=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
示例#7
0
 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)
示例#8
0
     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()
示例#9
0
    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
示例#10
0
文件: _qt.py 项目: bdurin/vispy
    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
示例#11
0
    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
示例#12
0
    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
示例#13
0
    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)
示例#14
0
	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);
示例#15
0
    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()
示例#16
0
文件: _qt.py 项目: Eric89GXL/vispy
    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)
示例#17
0
	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)
示例#18
0
文件: _qt.py 项目: rossant/vispy
    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
示例#19
0
 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)
示例#20
0
    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)
示例#21
0
    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)
示例#22
0
 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)
示例#23
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
示例#24
0
    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()
示例#25
0
    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
示例#26
0
 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)
示例#27
0
 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()
示例#28
0
 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
示例#29
0
 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)
示例#30
0
文件: _qt.py 项目: rougier/vispy
    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)
示例#31
0
 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)
示例#32
0
	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])	
示例#33
0
    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
示例#34
0
    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
示例#35
0
 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
示例#36
0
文件: glpen.py 项目: pmitros/x2
 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)
示例#37
0
 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)
示例#38
0
    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)
示例#39
0
    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_background = (0.85, 0.85, 0.85, 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.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
示例#40
0
    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)
示例#41
0
 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)
示例#42
0
    def __init__(
        self,
        vertexes,
        colors,
        parent=None,
        **kw
    ):  #vertexes, colors, texturePath='graphics/Texture-Example.jpg', parent=None):#spl, peak=None, parent=None):
        """
        Constructor, initialization
        kw:
            -texturePath:pathway to the file to text
            -textures: coord textures to apply
            -parent:the parent widget
        """
        QGLWidget.__init__(self, parent)
        self.setFormat(QGLFormat(QGL.SampleBuffers))
        self.setMinimumSize(500, 300)
        self.setMouseTracking(True)
        self.setFocusPolicy(Qt.StrongFocus)

        #        if not 'texturePath'in kw.keys() and not 'textures' in kw.keys():
        #            pass
        #            #print ('Could not apply texture, no coordinates')
        #        else:
        #            try:
        #                self._imageID = self.loadImage(kw.get('texturePath'))
        #                self.textures = textures
        #            except OSError:
        #                print ('Could not apply texture, no coordinates')

        self.vertexes = vertexes
        self.colors = colors

        #self.axes=None
        self.zoom_mode = False
        self.pan_mode = True
        #self.axes = self.makeAxes()

        self.parameters = {
            'axes_color': 'b',
            'axes_line_width': 3.,
            'draw_line_width': 1.,
            'colormap': True,
            'fish_eye': False,
            'cell_shading': False
        }
        self.lastpos = QPoint()
示例#43
0
文件: motor_qt.py 项目: ramalho/pilas
    def __init__(self, motor, lista_actores, ancho, alto):
        QGLWidget.__init__(self, None)
        self.painter = QtGui.QPainter()

        self.pausa_habilitada = False
        self.mouse_x = 0
        self.mouse_y = 0
        self.motor = motor
        self.depurador = depurador
        self.lista_actores = lista_actores
        self.fps = fps.FPS(60, True)
        self.depurador = depurador.Depurador(motor.obtener_lienzo(), self.fps)

        self.original_width = ancho
        self.original_height = alto
        self.escala = 1
        self.startTimer(1000/100.0)
示例#44
0
 def __init__(self, parent, triangles):
     '''
     @param triangles: Lista de triangulos a mostrar en pantalla. 
     La inicializacion de la malla de OpenGL se hace en el metodo 'initializeGL'
     '''
     QGLWidget.__init__(self, parent)
     
     self.setMinimumSize(400, 300)
     # self.__angle = 0.0
     self.__graphicsDevice = None    # Dispositivo grafico
     self.__meshSubset = None        # Objeto a visualizar
     self.__triangles = triangles    # Lista temporal de triangulos usada para inicializar el objeto
     
     self.__lastMousePosition = None
     
     self.__yaw = 0.0
     self.__pitch = 0.0
示例#45
0
    def __init__(self, parent):
        QGLWidget.__init__(self, parent)
        self.width = 640
        self.height = 480
        self.lenght = 640

        self.actors = []
        self.eye, self.at, self.up = 0, 0, 0
        self.camera = None
        self.axes = None

        # To update camera position from absolute values
        self.last_elev_factor = 0
        self.last_azim_factor = 0
        self.last_zoom_factor = 0

        self.l0_pos = []
示例#46
0
    def __init__(self, motor, lista_actores, ancho, alto):
        QGLWidget.__init__(self, None)
        self.painter = QtGui.QPainter()

        self.pausa_habilitada = False
        self.mouse_x = 0
        self.mouse_y = 0
        self.motor = motor
        self.depurador = depurador
        self.lista_actores = lista_actores
        self.fps = fps.FPS(60, True)
        self.depurador = depurador.Depurador(motor.obtener_lienzo(), self.fps)

        self.original_width = ancho
        self.original_height = alto
        self.escala = 1
        self.startTimer(1000 / 100.0)
示例#47
0
    def __init__(self, data, parent=None, **kw):
        """
        Constructor, initialization
        """

        QGLWidget.__init__(self, parent)
        self.setFormat(QGLFormat(QGL.SampleBuffers))
        self.setMinimumSize(500, 300)  #300
        self.setMouseTracking(True)
        self.setFocusPolicy(Qt.StrongFocus)

        self.data = data
        vertexes = []
        colors = []
        from utils.misc import IceAndFire
        maxY = max(map(max, [log10(el.y_data) for el in data]))
        maxX = max(map(max, [el.x_data for el in data]))
        rtmax = max([z.rtmin for z in data])
        for el in data:
            for i, x in enumerate(el.x_data):
                c = IceAndFire.getQColor(log10(el.y_data[i]) / maxY)
                colors.append(c)
                vertexes.append([(x * 2 * self.corner_) / maxX,
                                 (el.rt * 2 * self.corner_) / rtmax])
        from OpenGL.arrays.vbo import VBO

        self.vertexes = VBO(array(vertexes, 'f'))
        self.colors = VBO(array(colors, 'f'))

        self.mode = "None"  # "ZOOMING", "PANNING", "NONE"
        self.lastpos = QPoint()

        self.counter_trans_x = 0
        self.counter_trans_y = 0

        self.defaultColors = {
            'ticks': (0., 0., 0., 0.),
            'axes': (0., 0., 0., 0.),
            'curves': (0., 0., 1., 0.),
            'backgroundColor': (1., 1., 1., 1.)
        }

        #self.axes=self.drawAxes()
        self.transformationMatrix = self.setupTransformationMatrix(
            self.width(), self.height())
    def __init__(self, parent, shareWidget, useStencilBuffer):
        """
        If shareWidget is specified, useStencilBuffer is ignored: set it in the widget you're sharing with.
        """

        if shareWidget:
            self.shareWidget = shareWidget  #bruce 051212
            glformat = shareWidget.format()
            QGLWidget.__init__(self, glformat, parent, shareWidget)
            if not self.isSharing():
                print "Request of display list sharing is failed."
                return
        else:
            glformat = QGLFormat()
            if (useStencilBuffer):
                glformat.setStencil(True)
                # set gl format to request stencil buffer
                # (needed for mouseover-highlighting of objects of general
                #  shape in depositMode.bareMotion) [bruce 050610]

            QGLWidget.__init__(self, glformat, parent)

        # Current view attributes (sometimes saved in or loaded from
        #  the currently displayed part or its mmp file):

        # rotation
        self.quat = Q(1, 0, 0, 0)

        # point of view (i.e. negative of center of view)
        self.pov = V(0.0, 0.0, 0.0)

        # half-height of window in Angstroms (reset by certain view-changing operations)
        self.scale = float(env.prefs[startup_GLPane_scale_prefs_key])

        # zoom factor
        self.zoomFactor = 1.0

        self.trackball = Trackball(10, 10)

        self._functions_to_call_when_gl_context_is_current = []

        # piotr 080714: Defined this attribute here in case
        # chunk.py accesses it in ThumbView.
        self.lastNonReducedDisplayMode = default_display_mode
        return
示例#49
0
    def __init__(self, parent, shareWidget, useStencilBuffer):
        """
        If shareWidget is specified, useStencilBuffer is ignored: set it in the widget you're sharing with.
        """

        if shareWidget:
            self.shareWidget = shareWidget  # bruce 051212
            glformat = shareWidget.format()
            QGLWidget.__init__(self, glformat, parent, shareWidget)
            if not self.isSharing():
                print "Request of display list sharing is failed."
                return
        else:
            glformat = QGLFormat()
            if useStencilBuffer:
                glformat.setStencil(True)
                # set gl format to request stencil buffer
                # (needed for mouseover-highlighting of objects of general
                #  shape in depositMode.bareMotion) [bruce 050610]

            QGLWidget.__init__(self, glformat, parent)

        # Current view attributes (sometimes saved in or loaded from
        #  the currently displayed part or its mmp file):

        # rotation
        self.quat = Q(1, 0, 0, 0)

        # point of view (i.e. negative of center of view)
        self.pov = V(0.0, 0.0, 0.0)

        # half-height of window in Angstroms (reset by certain view-changing operations)
        self.scale = float(env.prefs[startup_GLPane_scale_prefs_key])

        # zoom factor
        self.zoomFactor = 1.0

        self.trackball = Trackball(10, 10)

        self._functions_to_call_when_gl_context_is_current = []

        # piotr 080714: Defined this attribute here in case
        # chunk.py accesses it in ThumbView.
        self.lastNonReducedDisplayMode = default_display_mode
        return
示例#50
0
 def __init__(self, filename, quality, parent=None, name=None):
     QGLWidget.__init__(self, parent, name)
     # load molecule and read from xyz file
     self.mol = Molecule()
     self.mol.readxyz(filename)
     self.mol.genbonds()
     # adjust quality to sanity
     # set display quality
     if self.mol.natoms > 10000:
         self.quality = min(2, quality)
     else:
         self.quality = quality
     print(quality)
     self.atom_size = 0.4
     self.bond_size = 0.1
     self.offset = -self.mol.box[0] - self.mol.box[1]
     # set initial coordinates
     self.x, self.y = self.lastx, self.lasty = [0, 0]
示例#51
0
文件: gui.py 项目: steabert/molito
 def __init__(self, filename, quality, parent=None, name=None):
     QGLWidget.__init__(self,parent,name)
     # load molecule and read from xyz file
     self.mol = Molecule()
     self.mol.readxyz(filename)
     self.mol.genbonds()
     # adjust quality to sanity
     # set display quality
     if self.mol.natoms > 10000:
         self.quality = min(2,quality)
     else:
         self.quality = quality
     print(quality)
     self.atom_size = 0.4
     self.bond_size = 0.1
     self.offset = -self.mol.box[0]-self.mol.box[1]
     # set initial coordinates
     self.x,self.y = self.lastx,self.lasty = [0,0]
示例#52
0
    def __init__(self, data, parent=None, **kw):
        """
        Constructor, initialization
        """
        
        QGLWidget.__init__(self, parent)
        self.setFormat(QGLFormat(QGL.SampleBuffers))
        self.setMinimumSize(500,300)#300
        self.setMouseTracking(True) 
        self.setFocusPolicy(Qt.StrongFocus)
        
        self.data=data
        vertexes=[]
        colors=[]
        from utils.misc import IceAndFire
        maxY=max(map(max, [log10(el.y_data) for el in data]))
        maxX=max(map(max, [el.x_data for el in data]))
        rtmax=max([z.rtmin for z in data])
        for el in data:
            for i, x in enumerate(el.x_data):
                c=IceAndFire.getQColor(log10(el.y_data[i])/maxY)
                colors.append(c)
                vertexes.append([(x*2*self.corner_)/maxX, (el.rt*2*self.corner_)/rtmax])
        from OpenGL.arrays.vbo import VBO
        
        self.vertexes= VBO(array(vertexes,'f'))
        self.colors=VBO(array(colors,'f'))
        
        self.mode = "None" # "ZOOMING", "PANNING", "NONE"
        self.lastpos = QPoint()
        
        self.counter_trans_x = 0
        self.counter_trans_y = 0

        
        self.defaultColors = {'ticks':(0.,0.,0.,0.),
                              'axes':(0.,0.,0.,0.),
                              'curves':(0.,0.,1.,0.),
                              'backgroundColor':(1.,1.,1.,1.)
                              }
     
        #self.axes=self.drawAxes()
        self.transformationMatrix = self.setupTransformationMatrix(self.width(), 
                                                                   self.height())
    def __init__(self, parent, timerInterval):
        QGLWidget.__init__(self, parent)
        self.setMinimumSize(800, 600)
        
        self.initializeAL()
        
        self.rtri = 0
        self.rquad = 0
        self.hits = 0
        self.deaths = 0
        
        if timerInterval == 0: 
            self.m_timer = 0;
        else:
            self.m_timer = QTimer()
            self.connect( self.m_timer, SIGNAL("timeout()"), self.timeOut)
            self.m_timer.start(timerInterval)

        self.populateGameWorld()
    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._mouseStartDragPoint = None

        self.setMinimumHeight(100)
示例#55
0
    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)
        else:
            # Qt4 and Qt5 < 5.4.0 - sharing is explicitly requested
            QGLWidget.__init__(self, p.parent, widget, hint)
        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)
示例#56
0
 def __init__(self, parent):
     if (GLController.instance is None):
         GLController.instance = self
     
     QGLWidget.__init__(self, parent)
     
     self.painter = QPainter()
     
     cfg = Config('game','OpenGL')
     
     self.clearColor = cfg.get('clear_color')
     
     self.fps = cfg.get('fps')
     self.fps_sum = 0.
     self.fps_count = 0
     self.show_fps = 0.
     self.fps_elapsed = 0.
     
     self.adjust_widget()
     self.adjust_timer()
     
     self.to_hook = None
     self.hooks = {}
示例#57
0
 def __init__(self, width, height, world, *args):
     QGLWidget.__init__(self, *args)
     self.width = width
     self.height = height
     self.world = world