コード例 #1
0
ファイル: numpy_widget.py プロジェクト: duke-iml/ece490-s2016
    def __init__(self, **kwargs):
        QGLWidget.__init__(self, **kwargs)
        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)

        self.opengl_resize = kwargs.get('resize', True)
        self.opengl_keep_aspect = kwargs.get('keep_aspect', True)
        self.opengl_data = None
コード例 #2
0
ファイル: SkyRenderer.py プロジェクト: NBor/SkyPython
    def __init__(self, debug_mode=None):
        '''
        Constructor
        '''
        QGLWidget.__init__(self)
        
        self.DEBUG_MODE = debug_mode
        
        self.texture_manager = TextureManager()
        self.render_state = RenderState()
        
        self.projection_matrix = None
        self.view_matrix = None
        
        self.update_closures = []

        self.all_managers = []
        self.managers_to_reload = []
        self.layers_to_managers = {}
        
        def queue_for_reload(rom, full_reload):
            self.managers_to_reload.append(self.ManagerReloadData(rom, full_reload))
        
        self.update_listener = queue_for_reload
    
        # The skybox should go behind everything.
        self.sky_box = SkyBox(0x10000000, self.texture_manager)
        self.sky_box.enabled = False
        self.add_object_manager(self.sky_box)
    
        #The overlays go on top of everything.
        self.overlay_manager = OverlayManager(0xEFFFFFFF, self.texture_manager)
        self.add_object_manager(self.overlay_manager)
        
        
コード例 #3
0
ファイル: worldview.py プロジェクト: cagatayikim/mcedit2
    def __init__(self, dimension, textureAtlas=None, geometryCache=None, sharedGLWidget=None):
        """

        :param dimension:
        :type dimension: WorldEditorDimension
        :param textureAtlas:
        :type textureAtlas: TextureAtlas
        :param geometryCache:
        :type geometryCache: GeometryCache
        :param sharedGLWidget:
        :type sharedGLWidget: QGLWidget
        :return:
        :rtype:
        """
        QGLWidget.__init__(self, shareWidget=sharedGLWidget)
        self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding)
        self.setFocusPolicy(Qt.ClickFocus)

        self.layerToggleGroup = LayerToggleGroup()
        self.layerToggleGroup.layerToggled.connect(self.setLayerVisible)

        self.dimension = None
        self.worldScene = None
        self.loadableChunksNode = None
        self.textureAtlas = None

        self.mouseRay = Ray(Vector(0, 1, 0), Vector(0, -1, 0))

        self.setMouseTracking(True)

        self.lastAutoUpdate = time.time()
        self.autoUpdateInterval = 0.5  # frequency of screen redraws in response to loaded chunks

        self.compassNode = self.createCompass()
        self.compassOrthoNode = scenegraph.OrthoNode((1, float(self.height()) / self.width()))
        self.compassOrthoNode.addChild(self.compassNode)

        self.viewActions = []
        self.pressedKeys = set()

        self.setTextureAtlas(textureAtlas)

        if geometryCache is None and sharedGLWidget is not None:
            geometryCache = sharedGLWidget.geometryCache
        if geometryCache is None:
            geometryCache = GeometryCache()
        self.geometryCache = geometryCache

        self.matrixNode = None
        self.overlayNode = scenegraph.Node()

        self.sceneGraph = None
        self.renderGraph = None

        self.frameSamples = deque(maxlen=500)
        self.frameSamples.append(time.time())

        self.cursorNode = None

        self.setDimension(dimension)
コード例 #4
0
    def testIt(self):
        w = QGLWidget()
        w.makeCurrent()

        b = QGLBuffer()
        b.setUsagePattern(QGLBuffer.DynamicDraw)

        self.assertTrue(b.create())
        self.assertTrue(b.bufferId() != 0)
        self.assertTrue(b.bind())

        data = QByteArray("12345")
        b.allocate(data)
        self.assertEqual(b.size(), data.size())

        m = b.map(QGLBuffer.ReadOnly)
        if m:
            self.assertEqual(m, py3k.buffer(py3k.b(data.data())))
            b.unmap()

            m = b.map(QGLBuffer.ReadWrite)
            m[3] = py3k.b('A')
            b.unmap()
            result, rdata = b.read(3, 1)
            self.assertTrue(result)
            self.assertEqual(py3k.b('A'), rdata.data())
        else:
            print(
                " memory mapping is not possible in this OpenGL implementation."
            )
        b.release()
コード例 #5
0
ファイル: qglbuffer_test.py プロジェクト: Hasimir/PySide
    def testIt(self):
        w = QGLWidget()
        w.makeCurrent()

        b = QGLBuffer()
        b.setUsagePattern(QGLBuffer.DynamicDraw)

        self.assertTrue(b.create())
        self.assertTrue(b.bufferId() != 0)
        self.assertTrue(b.bind())

        data = QByteArray("12345")
        b.allocate(data)
        self.assertEqual(b.size(), data.size())

        m = b.map(QGLBuffer.ReadOnly)
        if m:
            self.assertEqual(m, py3k.buffer(py3k.b(data.data())))
            b.unmap()

            m = b.map(QGLBuffer.ReadWrite)
            m[3] = py3k.b('A')
            b.unmap()
            result, rdata = b.read(3, 1)
            self.assertTrue(result)
            self.assertEqual(py3k.b('A'), rdata.data())
        else:
            print(" memory mapping is not possible in this OpenGL implementation.")
        b.release()
コード例 #6
0
ファイル: ImageObjectManager.py プロジェクト: NBor/SkyPython
 def reload(self, gl, full_reload):
     imgs = self.images
     reload_buffers = False
     reload_images = False
     
     if full_reload:
         reload_buffers =True
         reload_images = True
         # If this is a full reload, all the textures were automatically deleted,
         # so just create new arrays so we won't try to delete the old ones again.
         self.textures = [None] * len(imgs)
         self.red_textures = [None] * len(imgs)
     else:
         # Process any queued updates.
         reset = self.update_type.Reset in self.updates
         reload_buffers = reload_buffers or reset or self.update_type.UpdatePositions in self.updates
         reload_images = reload_images or reset or self.update_type.UpdateImages in self.updates
         self.updates = set()
         
     if reload_buffers:
         self.vertex_buffer.reload()
         self.text_coord_buffer.reload()
     if reload_images:
         for i in range(0, len(self.textures)):
             #If the image is already allocated, delete it.
             if self.textures[i] != None:
                 self.textures[i].delete(gl)
                 self.red_textures[i].delete(gl)
                 
             bmp = self.images[i].pixmap
             self.textures[i] = TextureManager().create_texture(gl)
             self.textures[i].bind(gl)
             gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
             gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
             gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
             gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
             
             '''
             IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
             The image has to be mirrored for some reason
             '''
             q_img = QImage(bmp.toImage()).mirrored()
             img = QGLWidget.convertToGLFormat(q_img)
             
             gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA, 
                             gl.GL_UNSIGNED_BYTE, str(img.bits()))
             
             
             self.red_textures[i] = TextureManager().create_texture(gl)
             self.red_textures[i].bind(gl)
             gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
             gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
             gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
             gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
             
             red_pixels = self.create_red_image(q_img)
             red_pixels = QGLWidget.convertToGLFormat(red_pixels)
             
             gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, red_pixels.width(), red_pixels.height(), 
                             0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, str(red_pixels.bits()))
コード例 #7
0
ファイル: painting.py プロジェクト: xkronosua/snippets
 def __init__(self, parent=None):
     QGLWidget.__init__(self, parent)
     self.timer = QTimer(self)
     # the timer, which drives the animation
     self.timer.timeout.connect(self.update)
     # the angle, by which the spiral is rotated
     self.angle = 0
     self.spiral = self.update_spiral()
コード例 #8
0
ファイル: cinemol_canvas.py プロジェクト: harry159821/cinemol
 def __init__(self, parent=None):
     QGLWidget.__init__(self, parent)
     self.setAutoBufferSwap(False)
     self.resize(640, 480)
     self.opengl_thread = QThread()
     QCoreApplication.instance().aboutToQuit.connect(self.clean_up_before_quit)
     self.trackball = Trackball()
     self.preferredSize = None
     self.setFocusPolicy(Qt.WheelFocus)
コード例 #9
0
ファイル: __init__.py プロジェクト: AnadoluPanteri/BitPurse
class BitPurse(QApplication):
    ''' Application class '''
    def __init__(self):
        QApplication.__init__(self, sys.argv)
        self.setOrganizationName("Khertan Software")
        self.setOrganizationDomain("khertan.net")
        self.setApplicationName("BitPurse")

        self.view = QtDeclarative.QDeclarativeView()
        # Are we on mer ? So don't use opengl
        # As it didn't works on all devices
        if os.path.exists('/etc/mer-release'):
            fullscreen = True
        elif os.path.exists('/etc/aegis'):
            fullscreen = True
            self.glformat = QGLFormat().defaultFormat()
            self.glformat.setSampleBuffers(False)
            self.glw = QGLWidget(self.glformat)
            self.glw.setAutoFillBackground(False)
            self.view.setViewport(self.glw)
        else:
            fullscreen = False

        self.walletController = WalletController()
        self.rootContext = self.view.rootContext()
        self.rootContext.setContextProperty("argv", sys.argv)
        self.rootContext.setContextProperty("__version__", __version__)
        self.rootContext.setContextProperty("__upgrade__", __upgrade__
                                            .replace('\n', '<br />'))
        self.rootContext.setContextProperty('WalletController',
                                            self.walletController)
        self.rootContext.setContextProperty('AddressesModel',
                                            self.walletController
                                            .addressesModel)
        self.rootContext.setContextProperty('TransactionsModel',
                                            self.walletController
                                            .transactionsModel)
        self.rootContext.setContextProperty('Settings',
                                            self.walletController
                                            .settings)

        self.view.setSource(QUrl.fromLocalFile(
            os.path.join(os.path.dirname(__file__),
                         'qml', 'main.qml')))

        self.rootObject = self.view.rootObject()
        if fullscreen:
            self.view.showFullScreen()
        else:
            self.view.show()
        # self.loginPage = self.rootObject.findChild(QObject, "loginPage")
        self.sendPage = self.rootObject.findChild(QObject, "sendPage")
        self.aboutPage = self.rootObject.findChild(QObject, "aboutPage")
        self.walletController.onError.connect(self.rootObject.onError)
        # self.walletController.onConnected.connect(self.loginPage.onConnected)
        self.walletController.onTxSent.connect(self.sendPage.onTxSent)
コード例 #10
0
  def __init__(self, parent=None):

      QGLWidget.__init__(self, parent)
      self.object = 0
      self.xRot = 0
      self.yRot = 0
      self.zRot = 0
      self.lastPos = QtCore.QPoint()
      self.trolltechGreen = QtGui.QColor.fromCmykF(0.40, 0.0, 1.0, 0.0)
      self.trolltechPurple = QtGui.QColor.fromCmykF(0.39, 0.39, 0.0, 0.0)
コード例 #11
0
    def __init__(self, parent=None):

        QGLWidget.__init__(self, parent)
        self.object = 0
        self.xRot = 0
        self.yRot = 0
        self.zRot = 0
        self.lastPos = QtCore.QPoint()
        self.trolltechGreen = QtGui.QColor.fromCmykF(0.40, 0.0, 1.0, 0.0)
        self.trolltechPurple = QtGui.QColor.fromCmykF(0.39, 0.39, 0.0, 0.0)
コード例 #12
0
ファイル: __init__.py プロジェクト: khertan/KhtNotes
class KhtNotes(QApplication):
    ''' Application class '''
    def __init__(self):
        QApplication.__init__(self, sys.argv)
        self.setOrganizationName("Khertan Software")
        self.setOrganizationDomain("khertan.net")
        self.setApplicationName("KhtNotes")

        self.settings = Settings()
        self.view = FilteredDeclarativeView(settings=self.settings)
        if os.path.exists('/etc/mer-release'):
            fullscreen = True
        elif os.path.exists('/etc/aegis'):
            fullscreen = True
            self.glformat = QGLFormat().defaultFormat()
            self.glformat.setSampleBuffers(False)
            self.glw = QGLWidget(self.glformat)
            self.glw.setAutoFillBackground(False)
            self.view.setViewport(self.glw)
        else:
            fullscreen = False

        self.notesModel = NotesModel()
        self.note = Note(settings=self.settings)
        self.conboyImporter = TomboyImporter()
        self.syncer = Sync()
        self.rootContext = self.view.rootContext()
        self.rootContext.setContextProperty("argv", sys.argv)
        self.rootContext.setContextProperty("__version__", __version__)
        self.rootContext.setContextProperty("__upgrade__", __upgrade__
                                            .replace('\n', '<br />'))
        self.rootContext.setContextProperty("Settings", self.settings)
        self.rootContext.setContextProperty("Sync", self.syncer)
        self.rootContext.setContextProperty("Importer", self.conboyImporter)
        self.rootContext.setContextProperty('notesModel', self.notesModel)
        self.rootContext.setContextProperty('Note', self.note)

        try:
            self.view.setSource(QUrl.fromLocalFile(
                os.path.join(os.path.dirname(__file__),
                             'qml', 'Harmattan_main.qml')))
        except:
            self.view.setSource(QUrl.fromLocalFile(
                os.path.join(os.path.dirname(__file__),
                             'qml', 'Desktop_main.qml')))

        self.rootObject = self.view.rootObject()
        if fullscreen:
            self.view.showFullScreen()
        else:
            self.view.show()
        self.note.on_error.connect(self.rootObject.onError)
        self.syncer.on_error.connect(self.rootObject.onError)
        self.syncer.on_finished.connect(self.rootObject.refresh)
        self.conboyImporter.on_finished.connect(self.notesModel.reload)
コード例 #13
0
ファイル: pymolWidget.py プロジェクト: cadmuxe/biovis
    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()
        self.setFocusPolicy(Qt.ClickFocus)
        #self.Parser = self.

        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)
        
        # inFile = "./data/scTIM.pdb"
        
        if(File[-9:-1] == "scTIM.pdb"):
            self.cmd.show("cartoon", "chain B")
            self.cmd.hide("lines", "chain B")
        else:
            self.cmd.hide("all")
            self.cmd.cartoon("tube")
            self.cmd.show("cartoon")
            
        
        #self.cmd.show("cartoon")
        #self.cmd.cartoon("putty")
        self.cmd.set("cartoon_highlight_color", 1)
        #self.cmd.hide("lines")
        #self.cmd.hide("chain ")
        self.color_obj(0)
        #self.cmd.color("marine")
        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()
        define_color(self.cmd.set_color)

        # used for save the color of residues
        self._color_cache = {}
        self._selected =[]
コード例 #14
0
ファイル: cinemol_canvas.py プロジェクト: harry159821/cinemol
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Left:        
         r = Rotation().set_from_angle_about_unit_vector(-0.05, [0, 0, -1])
         self.trackball.rotation_incremented.emit(r)
     elif event.key() == Qt.Key_Right:
         r = Rotation().set_from_angle_about_unit_vector( 0.05, [0, 0, -1])
         self.trackball.rotation_incremented.emit(r)
     elif event.key() == Qt.Key_Up:
         self.trackball.pixel_translated.emit(0, 0, 50);
     elif event.key() == Qt.Key_Down:
         self.trackball.pixel_translated.emit(0, 0, -50);
     QGLWidget.keyPressEvent(self, event) # not my event
コード例 #15
0
ファイル: __init__.py プロジェクト: harmattan/KhtSimpleText
    def __init__(self):
        QApplication.__init__(self, sys.argv)
        self.setOrganizationName("Khertan Software")
        self.setOrganizationDomain("khertan.net")
        self.setApplicationName("KhtSimpleText")

        self.view = QtDeclarative.QDeclarativeView()

        #Are we on mer ? So don't use opengl
        #As it didn't works on all devices
        if not os.path.exists('/etc/mer-release'):
            self.glformat = QGLFormat().defaultFormat()
            self.glformat.setSampleBuffers(False)
            self.glw = QGLWidget(self.glformat)
            self.glw.setAutoFillBackground(False)
            self.view.setViewport(self.glw)

        self.document = Document('~')
        self.documentsModel= DocumentsModel(currentDoc=self.document)

        self.rootContext = self.view.rootContext()
        self.rootContext.setContextProperty("argv", sys.argv)
        self.rootContext.setContextProperty("__version__", __version__)
        self.rootContext.setContextProperty("__upgrade__", __upgrade__
                                            .replace('\n', '<br>'))
        self.rootContext.setContextProperty("Settings", Settings())
        self.rootContext.setContextProperty("DocumentsModel",
                                            self.documentsModel)
        self.rootContext.setContextProperty("Document",
                                            self.document)
        self.view.setSource(QUrl.fromLocalFile(
                os.path.join(os.path.dirname(__file__), 'qml',  'main.qml')))
        self.rootObject = self.view.rootObject()
        self.view.showFullScreen()
コード例 #16
0
    def __init__(self, verts_object):
        self.verts = verts_object
        self.vert_options = args_to_dict(self.verts.draw)
        self.gl_options = args_to_dict(self.set_options)

        fmt = QGLFormat()
        fmt.setRgba(True)
        fmt.setDoubleBuffer(False)
        QGLWidget.__init__(self, fmt)
        self.glInit()

        self.setMouseTracking(True)

        self.camera = camera()
        self.camera.setSceneRadius(2)
        self.camera.reset()
        self.isPressed = False
        self.oldx = self.oldy = 0
コード例 #17
0
ファイル: app.py プロジェクト: olinord/AlgorithmVisualizer
    def __init__(self):
        QGLWidget.__init__(self)
        self.triangleCount = 0
        self.edgeCount = 0
        self.pointCount = 0
        self.triangleVertexArrayObject = None
        self.edgeVertexArrayObject = None
        self.pointVertexArrayObject = None

        self.drawTriangles = False
        self.drawLines = False
        self.drawPoints = False

        self.lastMouseX = 0
        self.lastMouseY = 0
        self.camera = Camera([0.0, 0.0, -1.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0])
        self.WVPMatrix = None
        self.setProperty("class", "AlgorithmVisualizerWidget")
        self.UpdateWVPMatrix()
コード例 #18
0
def main(argv):
    app = QApplication(argv)

    display_widget = QDeclarativeView()
    display_widget.setViewport(QGLWidget())

    display_widget.setResizeMode(QDeclarativeView.SizeRootObjectToView)
    display_widget.setSource(QUrl('drawer_demo.qml'))
    display_widget.show()
    display_widget.resize(640, 480)

    sys.exit(app.exec_())
コード例 #19
0
ファイル: load_png.py プロジェクト: metehanboy/mcedit2
def loadPNGImage(img):
    glImg = QGLWidget.convertToGLFormat(img)
    if glImg is None:
        raise ValueError, "Loading png file %s: Conversion to GL format failed." % img

    ndata = numpy.fromstring(glImg.bits(), dtype='uint8')
    w = glImg.width()
    h = glImg.height()
    b = glImg.depth() / 8

    assert len(ndata) == w * h * b
    return w, h, ndata.reshape((h, w, b))
コード例 #20
0
ファイル: LabelMaker.py プロジェクト: NBor/SkyPython
 def end_adding(self, gl):
     self.texture.bind(gl)
     
     '''
     IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
     The image has to be mirrored for some reason
     '''
     img = QImage(self.bitmap.toImage()).mirrored()
     img = QGLWidget.convertToGLFormat(img)
     
     gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA, 
                     gl.GL_UNSIGNED_BYTE, str(img.bits()))
     
     # This particular bitmap is no longer needed
     self.bitmap = None
コード例 #21
0
 def create_texture_from_resource(self, gl, resource_id):
     '''
     Unlike the original java source, convertToGLFormat is used
     '''
     text = self.create_texture_internal(gl)
     
     img = QImage("assets/drawable/" + self.images[resource_id] + ".png")
     img = QGLWidget.convertToGLFormat(img)
     
     text.bind(gl)
     gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
     gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
     gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE);
     gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE);
     
     gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA, 
                     gl.GL_UNSIGNED_BYTE, str(img.bits()))
     
     return text
コード例 #22
0
    def __init__(self):
        QApplication.__init__(self, sys.argv)
        self.setOrganizationName("Khertan Software")
        self.setOrganizationDomain("khertan.net")
        self.setApplicationName("Wleux")

        self.view = QtDeclarative.QDeclarativeView()
        self.glw = QGLWidget()
        self.view.setViewport(self.glw)
        self.wallpapersModel = WallpapersModel()
        self.wallpaper = Wallpaper()
        self.rootContext = self.view.rootContext()
        self.rootContext.setContextProperty("argv", sys.argv)
        self.rootContext.setContextProperty("__version__", __version__)
        self.rootContext.setContextProperty('wallpapersModel', self.wallpapersModel)
        self.rootContext.setContextProperty('wallpaper', self.wallpaper)
        self.view.setSource(QUrl.fromLocalFile( \
                os.path.join(os.path.dirname(__file__), 'qml', 'main.qml')))
        self.rootObject = self.view.rootObject()
        self.view.showFullScreen()
        self.wallpapersModel.on_error.connect(self.rootObject.onError)
コード例 #23
0
 def __init__(self):
     QGLWidget.__init__(self)
     self.camera = Camera(self)
     self.mouse = Mouse(self)
     self.clear_color = QColor.fromRgb(255, 255, 255)
コード例 #24
0
ファイル: cinemol_canvas.py プロジェクト: harry159821/cinemol
 def sizeHint(self):
     if self.preferredSize is None:
         return QGLWidget.sizeHint(self)
     return self.preferredSize
コード例 #25
0
 def __init__(self, parent):
     QGLWidget.__init__(self, parent)
コード例 #26
0
ファイル: __init__.py プロジェクト: khertan/BitPurse
    def __init__(self):
        QApplication.__init__(self, sys.argv)
        self.setOrganizationName("Khertan Software")
        self.setOrganizationDomain("khertan.net")
        self.setApplicationName("BitPurse")

        self.view = QtDeclarative.QDeclarativeView()
        # Are we on mer ? So don't use opengl
        # As it didn't works on all devices
        if os.path.exists('/etc/mer-release'):
            fullscreen = True
        elif os.path.exists('/etc/aegis'):
            fullscreen = True
            self.glformat = QGLFormat().defaultFormat()
            self.glformat.setSampleBuffers(False)
            self.glw = QGLWidget(self.glformat)
            self.glw.setAutoFillBackground(False)
            self.view.setViewport(self.glw)
        else:
            fullscreen = False

        self.walletController = WalletController()
        self.rootContext = self.view.rootContext()
        self.rootContext.setContextProperty("argv", sys.argv)
        self.rootContext.setContextProperty("__version__", __version__)
        self.rootContext.setContextProperty("__upgrade__", __upgrade__
                                            .replace('\n', '<br />'))
        self.rootContext.setContextProperty('WalletController',
                                            self.walletController)
        self.rootContext.setContextProperty('AddressesModel',
                                            self.walletController
                                            .addressesModel)
        self.rootContext.setContextProperty('TransactionsModel',
                                            self.walletController
                                            .transactionsModel)
        self.rootContext.setContextProperty('Settings',
                                            self.walletController
                                            .settings)

        self.view.setSource(QUrl.fromLocalFile(
            os.path.join(os.path.dirname(__file__),
                         'qml', 'main.qml')))

        self.rootObject = self.view.rootObject()
        if fullscreen:
            self.view.showFullScreen()
        else:
            self.view.show()
        self.sendPage = self.rootObject.findChild(QObject, "sendPage")
        self.aboutPage = self.rootObject.findChild(QObject, "aboutPage")
        self.walletController.onError.connect(self.rootObject.onError)
        self.walletController.onTxSent.connect(self.sendPage.onTxSent)
        if len(sys.argv) >= 2:
            if sys.argv[1].startswith('bitcoin:'):
                params = sys.argv[1][8:].split('?')
                addr = params[0].strip('/')
                amount = 0
                if params > 1:
                    for param in params:
                        if param.startswith('amount='):
                            if len(param.split('=')) > 1:
                                amount = param.split('=')[1]
                self.rootObject.sendTo(addr, amount)
        if self.walletController.settings.numberOfLaunch == 25:
            self.rootObject.showDonation()
        self.walletController.settings.numberOfLaunch += 1
コード例 #27
0
ファイル: __init__.py プロジェクト: topiasv/BitPurse
    def __init__(self):
        QApplication.__init__(self, sys.argv)
        self.setOrganizationName("Khertan Software")
        self.setOrganizationDomain("khertan.net")
        self.setApplicationName("BitPurse")

        self.view = QtDeclarative.QDeclarativeView()
        # Are we on mer ? So don't use opengl
        # As it didn't works on all devices
        if os.path.exists('/etc/mer-release'):
            fullscreen = True
        elif os.path.exists('/etc/aegis'):
            fullscreen = True
            self.glformat = QGLFormat().defaultFormat()
            self.glformat.setSampleBuffers(False)
            self.glw = QGLWidget(self.glformat)
            self.glw.setAutoFillBackground(False)
            self.view.setViewport(self.glw)
        else:
            fullscreen = False

        self.walletController = WalletController()
        self.rootContext = self.view.rootContext()
        self.rootContext.setContextProperty("argv", sys.argv)
        self.rootContext.setContextProperty("__version__", __version__)
        self.rootContext.setContextProperty(
            "__upgrade__", __upgrade__.replace('\n', '<br />'))
        self.rootContext.setContextProperty('WalletController',
                                            self.walletController)
        self.rootContext.setContextProperty(
            'AddressesModel', self.walletController.addressesModel)
        self.rootContext.setContextProperty(
            'TransactionsModel', self.walletController.transactionsModel)
        self.rootContext.setContextProperty('Settings',
                                            self.walletController.settings)

        self.view.setSource(
            QUrl.fromLocalFile(
                os.path.join(os.path.dirname(__file__), 'qml', 'main.qml')))

        self.rootObject = self.view.rootObject()
        if fullscreen:
            self.view.showFullScreen()
        else:
            self.view.show()
        self.sendPage = self.rootObject.findChild(QObject, "sendPage")
        self.aboutPage = self.rootObject.findChild(QObject, "aboutPage")
        self.walletController.onError.connect(self.rootObject.onError)
        self.walletController.onTxSent.connect(self.sendPage.onTxSent)
        if len(sys.argv) >= 2:
            if sys.argv[1].startswith('bitcoin:'):
                params = sys.argv[1][8:].split('?')
                addr = params[0].strip('/')
                amount = 0
                if params > 1:
                    for param in params:
                        if param.startswith('amount='):
                            if len(param.split('=')) > 1:
                                amount = param.split('=')[1]
                self.rootObject.sendTo(addr, amount)
        if self.walletController.settings.numberOfLaunch == 25:
            self.rootObject.showDonation()
        self.walletController.settings.numberOfLaunch += 1
コード例 #28
0
ファイル: QtOpenGL.py プロジェクト: fabioz/pyvmmonitor-qt
 def create_gl_widget():
     from PySide.QtOpenGL import QGLWidget
     from PySide.QtOpenGL import QGL
     from PySide.QtOpenGL import QGLFormat
     return QGLWidget(QGLFormat(QGL.SampleBuffers))
コード例 #29
0
    def __init__(self,
                 dimension,
                 textureAtlas=None,
                 geometryCache=None,
                 sharedGLWidget=None):
        """

        :param dimension:
        :type dimension: WorldEditorDimension
        :param textureAtlas:
        :type textureAtlas: TextureAtlas
        :param geometryCache:
        :type geometryCache: GeometryCache
        :param sharedGLWidget:
        :type sharedGLWidget: QGLWidget
        :return:
        :rtype:
        """
        QGLWidget.__init__(self, shareWidget=sharedGLWidget)
        self.dimension = None
        self.worldScene = None
        self.loadableChunksNode = None
        self.textureAtlas = None

        validateWidgetQGLContext(self)

        self.bufferSwapDone = True

        if THREADED_BUFFER_SWAP:
            self.setAutoBufferSwap(False)
            self.bufferSwapThread = QtCore.QThread()
            self.bufferSwapper = BufferSwapper(self)
            self.bufferSwapper.moveToThread(self.bufferSwapThread)
            self.doSwapBuffers.connect(self.bufferSwapper.swap)
            self.bufferSwapThread.start()

        self.setAcceptDrops(True)
        self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding,
                           QtGui.QSizePolicy.Policy.Expanding)
        self.setFocusPolicy(Qt.ClickFocus)

        self.layerToggleGroup = LayerToggleGroup()
        self.layerToggleGroup.layerToggled.connect(self.setLayerVisible)

        self.mouseRay = Ray(Vector(0, 1, 0), Vector(0, -1, 0))

        self.setMouseTracking(True)

        self.lastAutoUpdate = time.time()
        self.autoUpdateInterval = 0.5  # frequency of screen redraws in response to loaded chunks

        self.compassNode = self.createCompass()
        self.compassOrtho = Ortho((1, float(self.height()) / self.width()))
        self.compassNode.addState(self.compassOrtho)

        self.viewActions = []
        self.pressedKeys = set()

        self.setTextureAtlas(textureAtlas)

        if geometryCache is None and sharedGLWidget is not None:
            geometryCache = sharedGLWidget.geometryCache
        if geometryCache is None:
            geometryCache = GeometryCache()
        self.geometryCache = geometryCache

        self.worldNode = None
        self.skyNode = None
        self.overlayNode = scenenode.Node("WorldView Overlay")

        self.sceneGraph = None
        self.renderGraph = None

        self.frameSamples = deque(maxlen=500)
        self.frameSamples.append(time.time())

        self.cursorNode = None

        self.setDimension(dimension)
コード例 #30
0
ファイル: test.py プロジェクト: nickpope/cs355-drawing-app
def fname_to_tex(file_name):
        img = QImage()
        img.load(file_name)
        img2 = QGLWidget.convertToGLFormat(img)
        img3 = str(img2.bits())
        return img3
コード例 #31
0
ファイル: fremantle.py プロジェクト: harmattan/fremantleline
 def __init__(self, *args, **kwargs):
     super(FremantleView, self).__init__(*args, **kwargs)
     self.setViewport(QGLWidget())
コード例 #32
0
    def reload(self, gl, full_reload):
        imgs = self.images
        reload_buffers = False
        reload_images = False

        if full_reload:
            reload_buffers = True
            reload_images = True
            # If this is a full reload, all the textures were automatically deleted,
            # so just create new arrays so we won't try to delete the old ones again.
            self.textures = [None] * len(imgs)
            self.red_textures = [None] * len(imgs)
        else:
            # Process any queued updates.
            reset = self.update_type.Reset in self.updates
            reload_buffers = reload_buffers or reset or self.update_type.UpdatePositions in self.updates
            reload_images = reload_images or reset or self.update_type.UpdateImages in self.updates
            self.updates = set()

        if reload_buffers:
            self.vertex_buffer.reload()
            self.text_coord_buffer.reload()
        if reload_images:
            for i in range(0, len(self.textures)):
                #If the image is already allocated, delete it.
                if self.textures[i] != None:
                    self.textures[i].delete(gl)
                    self.red_textures[i].delete(gl)

                bmp = self.images[i].pixmap
                self.textures[i] = TextureManager().create_texture(gl)
                self.textures[i].bind(gl)
                gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER,
                                   gl.GL_LINEAR)
                gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER,
                                   gl.GL_LINEAR)
                gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S,
                                   gl.GL_CLAMP_TO_EDGE)
                gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T,
                                   gl.GL_CLAMP_TO_EDGE)
                '''
                IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
                The image has to be mirrored for some reason
                '''
                q_img = QImage(bmp.toImage()).mirrored()
                img = QGLWidget.convertToGLFormat(q_img)

                gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(),
                                img.height(), 0, gl.GL_RGBA,
                                gl.GL_UNSIGNED_BYTE, str(img.bits()))

                self.red_textures[i] = TextureManager().create_texture(gl)
                self.red_textures[i].bind(gl)
                gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER,
                                   gl.GL_LINEAR)
                gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER,
                                   gl.GL_LINEAR)
                gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S,
                                   gl.GL_CLAMP_TO_EDGE)
                gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T,
                                   gl.GL_CLAMP_TO_EDGE)

                red_pixels = self.create_red_image(q_img)
                red_pixels = QGLWidget.convertToGLFormat(red_pixels)

                gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA,
                                red_pixels.width(), red_pixels.height(), 0,
                                gl.GL_RGBA, gl.GL_UNSIGNED_BYTE,
                                str(red_pixels.bits()))
コード例 #33
0
 def __init__(self, *args, **kwargs):
     super(HarmattanView, self).__init__(*args, **kwargs)
     self.setViewport(QGLWidget())
コード例 #34
0
ファイル: worldview.py プロジェクト: qtx0213/mcedit2
    def __init__(self, dimension, textureAtlas=None, geometryCache=None, sharedGLWidget=None):
        """

        :param dimension:
        :type dimension: WorldEditorDimension
        :param textureAtlas:
        :type textureAtlas: TextureAtlas
        :param geometryCache:
        :type geometryCache: GeometryCache
        :param sharedGLWidget:
        :type sharedGLWidget: QGLWidget
        :return:
        :rtype:
        """
        QGLWidget.__init__(self, shareWidget=sharedGLWidget)
        self.dimension = None
        self.worldScene = None
        self.loadableChunksNode = None
        self.textureAtlas = None

        validateWidgetQGLContext(self)


        self.bufferSwapDone = True

        if THREADED_BUFFER_SWAP:
            self.setAutoBufferSwap(False)
            self.bufferSwapThread = QtCore.QThread()
            self.bufferSwapper = BufferSwapper(self)
            self.bufferSwapper.moveToThread(self.bufferSwapThread)
            self.doSwapBuffers.connect(self.bufferSwapper.swap)
            self.bufferSwapThread.start()

        self.setAcceptDrops(True)
        self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding)
        self.setFocusPolicy(Qt.ClickFocus)

        self.layerToggleGroup = LayerToggleGroup()
        self.layerToggleGroup.layerToggled.connect(self.setLayerVisible)

        self.mouseRay = Ray(Vector(0, 1, 0), Vector(0, -1, 0))

        self.setMouseTracking(True)

        self.lastAutoUpdate = time.time()
        self.autoUpdateInterval = 0.5  # frequency of screen redraws in response to loaded chunks

        self.compassNode = self.createCompass()
        self.compassOrtho = Ortho((1, float(self.height()) / self.width()))
        self.compassNode.addState(self.compassOrtho)

        self.viewActions = []
        self.pressedKeys = set()

        self.setTextureAtlas(textureAtlas)

        if geometryCache is None and sharedGLWidget is not None:
            geometryCache = sharedGLWidget.geometryCache
        if geometryCache is None:
            geometryCache = GeometryCache()
        self.geometryCache = geometryCache

        self.worldNode = None
        self.skyNode = None
        self.overlayNode = scenenode.Node("WorldView Overlay")

        self.sceneGraph = None
        self.renderGraph = None

        self.frameSamples = deque(maxlen=500)
        self.frameSamples.append(time.time())

        self.cursorNode = None

        self.setDimension(dimension)
コード例 #35
0
 def __init__(self, _keyframe, _object, parent=None):
     QGLWidget.__init__(self, parent)
     self.frame = _keyframe
     self.object = _object
     self.texture = None
     self.object_drawer = None