当前位置: 首页>>代码示例>>Python>>正文


Python QPoint.x方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QPoint.x方法的典型用法代码示例。如果您正苦于以下问题:Python QPoint.x方法的具体用法?Python QPoint.x怎么用?Python QPoint.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.QPoint的用法示例。


在下文中一共展示了QPoint.x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_border

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
 def get_border(self, p: QPoint):
     if p.x() <= 2:
         return Alignment.Left
     elif p.x() >= self.width() - 2:
         return Alignment.Right
     elif p.y() <= 2:
         return Alignment.Top
     elif p.y() >= self.height() - 2:
         return Alignment.Bottom
     return None
开发者ID:Mandarancio,项目名称:OpenIris,代码行数:12,代码来源:OIWorkSpace.py

示例2: readSettings

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
	def readSettings(self):
		self.imageFolder = os.path.normpath(str(self.settings.value("imageFolder").toString()))
		self.ui.actionIgnore_Transparent_Pixels.setChecked( self.settings.value("ignoreAlpha", True).toBool())
		self.ui.actionCheck_for_update_at_start.setChecked( self.settings.value("checkupdate", True).toBool())
		self.ui.tolerance_le.setText( self.settings.value("tolerance").toString())
		self.settings.beginGroup("/geometry")
		p = QPoint()  # position
		s = QSize()  # size

		x = self.settings.value("X", -1).toInt()[0]
		y = self.settings.value("Y", -1).toInt()[0]
		# don't position outside current screen
		qRect = QtGui.QDesktopWidget.availableGeometry(app.desktop())
		if x > qRect.right():
			x = 10
		if y > qRect.bottom():
			y = 10
		p.setX(x)
		p.setY(y)
		s.setWidth(self.settings.value("W", -1).toInt()[0])
		s.setHeight(self.settings.value("H", -1).toInt()[0])
		self.settings.endGroup()
		if p.x() > 0 and p.y() > 0 and s.width() > 0 and s.height() > 0:
			self.resize(s)  # restore size
			self.move(p)  # restore position
开发者ID:iantestplant,项目名称:ImageDiff,代码行数:27,代码来源:ImageDiff.py

示例3: NotificationServer

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
class NotificationServer(QObject):
    def __init__(self, parent=None):
        QObject.__init__(self, parent)
        self.notifications = set()
        self.size = QSize(300, 100)
        self.margin = QPoint(10, 10)

    def notify(self, html):
        note = Notification(html)
        self.connect(note, SIGNAL("done"), self.noteDestroyed)

        desktop = QApplication.desktop().availableGeometry(note)
        me = QRect(QPoint(0, 0), self.size)
        me.moveBottomRight(desktop.bottomRight() - self.margin)
        while self.notePosTaken(me):
            me.translate(0, 0 - (self.size.height() + (self.margin.y() * 2)))
            if not desktop.contains(me):
                me.moveBottom(desktop.bottom() - self.margin.y())
                me.translate(0 - (self.size.width() + self.margin.x() * 2), 0)

        note.setGeometry(me)
        self.notifications.add(note)
        note.display()

    def notePosTaken(self, rect):
        for note in self.notifications:
            if note.geometry().intersects(rect):
                return True
        return False

    def noteDestroyed(self, note):
        self.notifications.remove(note)
开发者ID:bodil,项目名称:feedlol,代码行数:34,代码来源:Notification.py

示例4: MovingMessage

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
class MovingMessage(FadeMessage):
    def __init__(self, message, str = None, pos = None):
        cfg = Config('messages', message)
        
        if (pos is None):
            self.pos = QPoint(*cfg.get('position'))
        else:
            self.pos = QPoint(*pos)
        
        self.velocity = cfg.get('velocity') 
        
        FadeMessage.__init__(self, message, str)
    
    def with_controller(self):
        self.rect = QRect(0, 0, self.controller.width(), self.controller.height())
        self.rect.moveCenter(self.pos)

    def tick(self, elapsed):        
        FadeMessage.tick(self, elapsed)

        self.pos.setX(self.pos.x() + self.velocity[0] * elapsed)
        self.pos.setY(self.pos.y() + self.velocity[1] * elapsed)
        
        self.rect.moveCenter(self.pos)
    
    def draw(self):
        FadeMessage.draw(self)
        
        if (self.color.alpha() == 0):
            self.rect = self.bounding_text_rect
开发者ID:giulianoxt,项目名称:pyasteroids,代码行数:32,代码来源:messages.py

示例5: showPopup

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
 def showPopup(self):
     if not self.popup:
         return
     pos = QPoint(self.width(), self.height())
     pos = self.mapToGlobal(pos)
     size = self.popup.size()
     self.popup.move(pos.x() - size.width(), pos.y())
     self.popup.show()
开发者ID:LucaLanziani,项目名称:bluepass,代码行数:10,代码来源:passwordbutton.py

示例6: contains

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
 def contains(self, p: QPoint):
     d = self.size * Info.dpi
     pos = self.real_pos()
     dx = pos.x() - p.x()
     dy = pos.y() - p.y()
     if dx * dx + dy * dy <= d * d:
         return True
     return False
开发者ID:Mandarancio,项目名称:OpenIris,代码行数:10,代码来源:OIBlocks.py

示例7: kineticMove

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
    def kineticMove(self, oldx, oldy, newx, newy ):
        """Start a kinetic move from (oldx, oldy) to (newx, newy)"""
        if newx == oldx and newy == oldy:
            return
        
        speed = QPoint(0,0)
        # solve speed*(speed+1)/2 = delta to ensure 1+2+3+...+speed is as close as possible under delta..
        speed.setX((sqrt(1+8*abs(newx-oldx))-1)/2)
        speed.setY((sqrt(1+8*abs(newy-oldy))-1)/2)
        
        # compute the amount of displacement still needed because we're dealing with integer values.
        diff = QPoint(0,0)
        diff.setX(-abs(newx-oldx) + speed.x()*(speed.x()+1)/2)
        diff.setY(-abs(newy-oldy) + speed.y()*(speed.y()+1)/2)

        # Since this function is called for exact moves (not free scrolling)
        # limit the kinetic time to 2 seconds, which means 100 ticks, 5050 pixels.
        if speed.y() > 100:
            speed.setY(100)
            diff.setY(-abs(newy-oldy) + 5050)
            
        # Although it is less likely to go beyond that limit for horizontal scrolling,
        # do it for x as well.
        if speed.x() > 100:
            speed.setX(100)
            diff.setX(-abs(newx-oldx) + 5050)
        
        # move left or right, up or down
        if newx > oldx :
            speed.setX(-speed.x())
            diff.setX(-diff.x())
        if newy > oldy :
            speed.setY(-speed.y())
            diff.setY(-diff.y())
        
        # move immediately by the step that cannot be handled by kinetic scrolling.
        # By construction that step is smaller that the initial speed value.
        self.fastScrollBy(diff)
        
        self.kineticStart(speed)
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:42,代码来源:kineticscrollarea.py

示例8: drawNetwork

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
    def drawNetwork(self, qp):

    #for each vehicle
        for j in range(len(self.vehicleList)):
        #we check others vehicles
            for k in range(len(self.vehicleList)):
                #if we are testing the current vehicle
                if j == k:
                    continue
                # if we are testing an other vehicle
                else:
                    # calculating the distance between the 2 vehicles
                    xDiff = self.vehicleList[k].position.x() - self.vehicleList[j].position.x()
                    yDiff = self.vehicleList[k].position.y() - self.vehicleList[j].position.y()
                    dist = math.sqrt(math.pow(xDiff, 2) + math.pow(yDiff, 2))
                    if dist < globalvars.msg_distance:
                        # creating a connection between the 2 vehicles
                        qp.drawLine(
                            self.vehicleList[j].position.x(),
                            self.vehicleList[j].position.y(),
                            self.vehicleList[k].position.x(),
                            self.vehicleList[k].position.y()
                        )

            # creating a random movement
            if not self.isPause:
                isPosX = bool(random.getrandbits(1))
                isPosY = bool(random.getrandbits(1))
                if isPosX:
                    if self.vehicleList[j].position.x() < self.size.width() - 50:
                        self.vehicleList[j].position.setX(self.vehicleList[j].position.x() + 1)
                else:
                    if self.vehicleList[j].position.x() > 25:
                        self.vehicleList[j].position.setX(self.vehicleList[j].position.x() - 1)

                if isPosY:
                    if self.vehicleList[j].position.y() < self.size.height() - 50:
                        self.vehicleList[j].position.setY(self.vehicleList[j].position.y() + 1)
                else:
                    if self.vehicleList[j].position.y() > 25:
                       self.vehicleList[j].position.setY(self.vehicleList[j].position.y() - 1)

                
                pos = QPoint(self.vehicleList[j].position.x() - (self.vehicleImg[j].size().width()/2), 
                             self.vehicleList[j].position.y() - (self.vehicleImg[j].size().height()/2))
                self.vehicleImg[j].move(pos.x(), pos.y())


        time.sleep(0.001)
        # calling paintEvent
        self.update()
开发者ID:hkaj,项目名称:Distribus,代码行数:53,代码来源:movingarea.py

示例9: Circle

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
class Circle():

    def __init__(self, diameter, x, y):
        self.diameter = diameter
        self.radius = math.floor(diameter / 2.0)
        self.center = QPoint(x, y)

    def drawCircle(self, event, qp):
        qp.setBrush(QtGui.QColor(34, 34, 200))
        qp.drawEllipse(self.center, self.radius, self.radius)

    def isClicked(self, pos):
        result = math.pow((pos.x() - self.center.x()), 2) + math.pow((pos.y() - self.center.y()), 2)
        if result <= math.pow(self.radius, 2):
            return True
        else:
            return False

    def x(self):
        return self.center.x()

    def y(self):
        return self.center.y()
开发者ID:CrazyCrud,项目名称:interactiondesign-python,代码行数:25,代码来源:circle.py

示例10: __init__

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
 def __init__(self, level_number, level):
     self.level_number = level_number
     
     self.info = {}
     self.fields = set()
     
     self.level = level
     self.player_state = Player.get_instance()
             
     cfg = Config('interface', 'Settings')
     font_name = cfg.get('field_font')
     font_size = cfg.get('field_font_sz')
     self.field_font = FontManager.getFont(font_name)
     self.field_font.setPointSize(font_size)
     self.field_color = QColor.fromRgb(*cfg.get('field_color'))
     
     for f_name in ConfigManager.getOptions('interface', 'Fields'):
         s = ConfigManager.getVal('interface', 'Fields', f_name)
         s = map(str.strip, s.split('||'))
         
         img = QImage('resources/images/'+s[0])
         img_pos = QPoint(*eval(s[1]))
         info_rect = QRect(*eval(s[2]))
         scale = float(s[3])
         
         if (len(s) >= 5):
             font = QFont(self.field_font)
             font.setPointSize(int(s[4]))
         else:
             font = self.field_font
         
         img_w, img_h = img.width(), img.height()
         img_rect = QRect(
             img_pos.x(), img_pos.y(),
             int(img_w*scale), int(img_h*scale)
         )
         
         self.info[f_name] = ''
         
         self.fields.add(Field(f_name, img, img_rect, info_rect, font))
     
     self.radar = Radar.from_config('E-Radar', self)
     self.missile = GuidedMissile.from_config('GuidedMissile', self)
开发者ID:giulianoxt,项目名称:pyasteroids,代码行数:45,代码来源:interface.py

示例11: drawXInfos

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
  def drawXInfos(self):
    pen = self.painter.pen()
    i = 1
    scale = 6
    x = self.yLeftMargin
    y = self.ploter.height - self.m
    if not self.selDateMin:
      date = self.baseDateMin
      shift_date = (self.baseDateMax - self.baseDateMin) / scale
    else:
      date = self.selDateMin
      shift_date = (self.selDateMax - self.selDateMin) / scale
    while i <= scale + 1:
      pen.setColor(Qt.black)
      pen.setStyle(Qt.SolidLine)
      pos = QPoint(x - 40, y + 17)
      self.painter.setPen(pen)
# Draw vertical doted line
      self.painter.drawLine(x, y - 3, x, y + 3)
# Draw date
      self.painter.drawText(pos, str(self.timeline.fromUSec(date).strftime('%d.%m.%Y')))
# If number of days shown < scale, draw time
      if shift_date <= (86400 * 1000000):
        pos.setY(pos.y() + 15)
        pos.setX(pos.x() + 9)
# Draw time
        self.painter.drawText(pos, str(self.timeline.fromUSec(date).strftime('%H:%M:%S')))
      
      pen.setColor(Qt.gray)
      pen.setStyle(Qt.DotLine)
      self.painter.setPen(pen)
      if i != 1:
        self.painter.drawLine(x, y + 3, x, self.m / 3)
      x = self.yLeftMargin + (i * ((self.ploter.width - self.m - self.yLeftMargin) / (scale)))
      i += 1
      date += shift_date
    pen.setStyle(Qt.SolidLine)
    self.painter.setPen(pen)
开发者ID:halbbob,项目名称:dff,代码行数:40,代码来源:drawer.py

示例12: View

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
class View(KineticScrollArea):
    
    viewModeChanged = pyqtSignal(int)
    
    def __init__(self, parent=None):
        super(View, self).__init__(parent)
        
        self.setAlignment(Qt.AlignCenter)
        self.setBackgroundRole(QPalette.Dark)
        self.setMouseTracking(True)

        self._viewMode = FixedScale
        self._wheelZoomEnabled = True
        self._wheelZoomModifier = Qt.CTRL
        
        # delayed resize
        self._centerPos = False
        self._resizeTimer = QTimer(singleShot = True, timeout = self._resizeTimeout)
        
    def surface(self):
        """Returns our Surface, the widget drawing the page(s)."""
        sf = self.widget()
        if not sf:
            sf = surface.Surface(self)
            self.setSurface(sf)
        return sf
    
    def setSurface(self, sf):
        """Sets the given surface as our widget."""
        self.setWidget(sf)
        # For some reason mouse tracking *must* be enabled on the child as well...
        sf.setMouseTracking(True)
        self.kineticScrollingActive.connect(sf.updateKineticCursor)

    
    def viewMode(self):
        """Returns the current ViewMode."""
        return self._viewMode
        
    def setViewMode(self, mode):
        """Sets the current ViewMode."""
        if mode == self._viewMode:
            return
        self._viewMode = mode
        if mode:
            self.fit()
        self.viewModeChanged.emit(mode)
    
    def wheelZoomEnabled(self):
        """Returns whether wheel zoom is enabled."""
        return self._wheelZoomEnabled
        
    def setWheelZoomEnabled(self, enabled):
        """Sets whether wheel zoom is enabled.
        
        Wheel zoom is zooming using the mouse wheel and a keyboard modifier key
        (defaulting to Qt.CTRL).  Use setWheelZoomModifier() to set a key (or
        key combination).
        
        """
        self._wheelZoomEnabled = enabled
    
    def wheelZoomModifier(self):
        """Returns the modifier key to wheel-zoom with (defaults to Qt.CTRL)."""
        return self._wheelZoomModifier
        
    def setWheelZoomModifier(self, key):
        """Sets the modifier key to wheel-zoom with (defaults to Qt.CTRL).
        
        Can also be set to a ORed value, e.g. Qt.SHIFT|Qt.ALT.
        Only use Qt.ALT, Qt.CTRL, Qt.SHIFT and/or Qt.META.
        
        """
        self._wheelZoomModifier = key
        
    def load(self, document):
        """Convenience method to load all the pages from the given Poppler.Document."""
        self.surface().pageLayout().load(document)
        # dont do a fit() before the very first resize as the size is then bogus
        if self.viewMode():
            self.fit()
        self.surface().pageLayout().update()

    def clear(self):
        """Convenience method to clear the current layout."""
        self.surface().pageLayout().clear()
        self.surface().pageLayout().update()

    def scale(self):
        """Returns the scale of the pages in the View."""
        return self.surface().pageLayout().scale()
        
    def setScale(self, scale):
        """Sets the scale of all pages in the View."""
        self.surface().pageLayout().setScale(scale)
        self.surface().pageLayout().update()
        self.setViewMode(FixedScale)

    def visiblePages(self):
        """Yields the visible pages."""
#.........这里部分代码省略.........
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:103,代码来源:view.py

示例13: GLWidget

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
class GLWidget(QtOpenGL.QGLWidget):
    """
    This class renders something with OpenGL
    """

    def __init__(self, parent=None):
        """
        Constructor
        """
        self.__image_width = 250
        self.__image_height = 250

        self.__isMouseDown = False
        self.__zoomFactor = 1.0

        self.__scrollOffset = QPoint()

        if hasattr(QGLFormat, "setVersion"):
            # Modern OpenGL
            f = QGLFormat()
            f.setVersion(3, 3)
            f.setProfile(QGLFormat.CoreProfile)
            f.setSampleBuffers(True)
            c = QGLContext(f, None)

            QGLWidget.__init__(self, c, parent)
            print "Version is set to 3.3"
        else:
            QGLWidget.__init__(self, parent)

        # self.__svgItem = QtSvg.QGraphicsSvgItem("circle_star.svg")
        self.__mySvgTool = MySvgTool()

        self.__mySvgWriter = MySvgWriter()
        self.__mySvgWriter.DrawSomething()
        self.__myBufferPainter = MyBufferPainter()

    def initializeGL(self):

        glClearColor(0.5, 0.5, 0.5, 1.0)
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_CULL_FACE)
        glEnable(GL_LINE_SMOOTH)
        glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)

        self.__shaderProgram = QGLShaderProgram()
        if self.__shaderProgram.addShaderFromSourceFile(QGLShader.Vertex, "shader.vert"):
            print "Main - Vertex shader OK"
        if self.__shaderProgram.addShaderFromSourceFile(QGLShader.Fragment, "shader.frag"):
            print "Main - Fragment shader OK"
        self.__shaderProgram.link()

        self.__texCoordLocation = self.__shaderProgram.attributeLocation("uv")
        self.__vertexLocation = self.__shaderProgram.attributeLocation("position")
        self.__colorLocation = self.__shaderProgram.attributeLocation("color")
        self.__use_color_location = self.__shaderProgram.uniformLocation("use_color")
        self.__mvpMatrixLocation = self.__shaderProgram.uniformLocation("mvpMatrix")

        # Returns -1 if name is not a valid attribute for this shader program.
        print "\n__texCoordLocation   :", self.__texCoordLocation, " ", "\n__vertexLocation     :", self.__vertexLocation, " ", "\n__colorLocation      :", self.__colorLocation, " ", "\n__use_color_location :", self.__use_color_location, " ", "\n__mvpMatrixLocation  :", self.__mvpMatrixLocation

        self.__blurProgram = QGLShaderProgram()
        if self.__blurProgram.addShaderFromSourceFile(QGLShader.Vertex, "shader.vert"):
            print "Gaussian blur - Vertex shader OK"

        # if I use shader.frag it's okay ???
        # if self.__blurProgram.addShaderFromSourceFile(QGLShader.Fragment, "gaussian_blur.frag") :
        if self.__blurProgram.addShaderFromSourceFile(QGLShader.Fragment, "gaussian_blur.frag"):
            print "Gaussian blur - fragment shader OK"
        self.__blurProgram.link()

        self.__myBufferPainter.SetThings(self.__shaderProgram, self.__blurProgram)
        self.__myBufferPainter.initializeGL(self.bindTexture(QtGui.QPixmap("laughing_man.png")))
        self.__myBufferPainter.prepareFrameRect(
            self.__scrollOffset.x(), self.__scrollOffset.y(), self.width(), self.height(), self.__zoomFactor
        )

        """
        ### texture
        self.__ori_tex = self.bindTexture(QtGui.QPixmap("laughing_man.png"))

        vertexData = numpy.array([   0.0,   0.0, 0.0, 1.0,
                                     0.0, 250.0, 0.0, 1.0,
                                   250.0, 250.0, 0.0, 1.0,

                                     0.0,   0.0, 0.0, 1.0,
                                   250.0, 250.0, 0.0, 1.0,
                                   250.0,   0.0, 0.0, 1.0,

                                # uv
                                0, 1,
                                0, 0,
                                1, 0,

                                0, 1,
                                1, 0,
                                1, 1],
                                dtype = numpy.float32)

        colorData = numpy.array([1.0, 0.0, 0.0, 1.0,
#.........这里部分代码省略.........
开发者ID:azer89,项目名称:PyQtOpenGLCanvas,代码行数:103,代码来源:GLWidget.py

示例14: MSGLCanvas3D

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
class MSGLCanvas3D(QGLWidget):
    """Canvas GL plotting in 3 dimensions spectra"""
    
        
    corner=100.0
    near=0.0
    far=600.0
    zoom= 1.5
    xrot=220
    yrot = 220
    zrot=0
    trans_x =0.0
    trans_y = 0.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()

       
    
    def loadImage(self, imageName):		
        im = open(imageName)
        try:
            ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBA", 0, -1)
        except SystemError:
            ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBX", 0, -1)
        ID = glGenTextures(1)
        glBindTexture(GL_TEXTURE_2D, ID)
        glPixelStorei(GL_UNPACK_ALIGNMENT,1)
        glTexImage2D(GL_TEXTURE_2D, 0, 3, ix, iy, 0, GL_RGBA, GL_UNSIGNED_BYTE, image)
        return ID
    
    
    def setupTexture(self):
        glEnable(GL_TEXTURE_2D)
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
        glBindTexture(GL_TEXTURE_2D, self.imageID)
        
    
    
    def texturesCalc(self):
        from OpenGL.arrays.vbo import VBO
        basis = [[0.,0.], [0.,1.]]
        hola =[]        
        
        length = len(self.vertexes)
        for i in range(length/2):
            hola+=basis
        return VBO(array(hola))
    
    
    def recalcVertexesAndColors(self, colormap, **kwargs):
        pass
    
    def resizeGL(self, w, h):
        """called when window is being resized"""
        glViewport(0,0, w, h)     
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glOrtho(-self.corner*self.zoom, 
#.........这里部分代码省略.........
开发者ID:jerkos,项目名称:metms,代码行数:103,代码来源:MetGLCanvas3D.py

示例15: VisionneurImagePourEKD

# 需要导入模块: from PyQt4.QtCore import QPoint [as 别名]
# 或者: from PyQt4.QtCore.QPoint import x [as 别名]
class VisionneurImagePourEKD(QScrollArea):
	''' Classe pour l'affichage des images (avec des barres de
	défilement)'''
	def __init__(self, img=None):
		QScrollArea.__init__(self)

		# Déclaration du drapeau: a-t-on chargé un *.gif
		if img and os.path.splitext(img)[1]!=".gif":
			self.gif = 1
		else:
			self.gif = 0
		
		# Facteur de redimensionnement de l'image à afficher par rapport à la taille réelle de l'image
		self.factor = 1
		
		# Variables de paramètres
		self.modeTransformation=Qt.SmoothTransformation
		#self.modeTransformation=Qt.FastTransformation
		
		# widget qui contiendra l'image
		self.imageLabel = QLabel()
		self.imageLabel.setAlignment(Qt.AlignCenter)
		
		self.setBackgroundRole(QPalette.Dark)
		self.setWidget(self.imageLabel)
		# Indispensable pour ne pas avoir d'images tronquées, lors du chargement de nvll img
		self.setWidgetResizable(True)
		
		# Position du curseur dans le QScrollArea au moment du clic de la souris
		self.positionPresseeSourisIni = QPoint()
		# Position du point haut-gauche du QScrollArea par rapport au QPixMap entier au
		# moment du clic de la souris (par la suite appelée "position de la barre de défilement")
        	self.positionBarrePresseeSourisIni = QPoint()
		
		# Création du menu contextuel
		self.menuZoom=QMenu("Zoom")
		
		# Entrée zoom taille réelle
		self.menuTailleReelle=self.menuZoom.addAction(_(u'&Taille Réelle'))
		self.menuTailleReelle.setIcon(QIcon("Icones" + os.sep + "taillereelle.png"))
		self.connect(self.menuTailleReelle, SIGNAL("triggered()"), self.setTailleReelle)
		
		# Entrée zoom taille fenetre
		self.menuTailleFenetre=self.menuZoom.addAction(_(u'&Adapter à la fenêtre'))
		self.menuTailleFenetre.setIcon(QIcon("Icones" + os.sep + "fenetre.png"))
		self.connect(self.menuTailleFenetre, SIGNAL("triggered()"), self.setTailleFenetre)
	
		# Entrée zoom +
		self.menuZoomPlus=self.menuZoom.addAction(_(u'&Zoom Avant'))
		self.menuZoomPlus.setIcon(QIcon("Icones" + os.sep + "zoomplus.png"))
		self.connect(self.menuZoomPlus, SIGNAL("triggered()"), self.zoomAvant)
		
		# Entrée zoom - 
		self.menuZoomMoins=self.menuZoom.addAction(_(u'&Zoom Arrière'))
		self.menuZoomMoins.setIcon(QIcon("Icones" + os.sep + "zoommoins.png"))
		self.connect(self.menuZoomMoins, SIGNAL("triggered()"), self.zoomArriere)
		
		# Entrée mettre en pause/démarrer l'animation du gif
		self.menuStartPauseGif=self.menuZoom.addAction(_(u"Mettre en pause/démarrer l'animation"))
		self.menuStartPauseGif.setIcon(QIcon("Icones" + os.sep + "player_end.png"))
		self.connect(self.menuStartPauseGif, SIGNAL("triggered()"), self.startPauseGif)
			
		# Entrée mettre en pause/démarrer l'animation du gif
		self.menuStopGif=self.menuZoom.addAction(_(u"Arrêter l'animation"))
		self.menuStopGif.setIcon(QIcon("Icones" + os.sep + "player_stop.png"))
		self.connect(self.menuStopGif, SIGNAL("triggered()"), self.stopGif)
		
		# On cache les 2 menus de *.gif si on ne traite pas ce format
		if not self.gif:
			self.menuStartPauseGif.setVisible(False)
			self.menuStopGif.setVisible(False)
		
		# Si une image est en paramètre de classe, on l'affiche directement
		# sinon on pourra toujours l'afficher plus tard en appelant la
		# méthode setImage(), le moment venu
		if img:
			self.setImage(img)
			self.setToolTip(img)
		else:
			# image par défaut
			self.setImage("Icones" + os.sep + "avant-image.png")
			self.setToolTip(_(u"image d'accueil"))
			self.setTailleReelle()
	
	def mousePressEvent(self, event):
		"Menu contextuel et enregistrement de données préparant le déplacement de l'image par pincement"
		
		# Menu contextuel
		if event.button() == Qt.RightButton: 
			self.menuZoom.popup(event.globalPos())
		
		# On enregistre la position du curseur et de la barre de défilement au moment du clic
		elif event.button() == Qt.LeftButton:
			self.positionPresseeSourisIni = QPoint(event.pos())
			self.positionBarrePresseeSourisIni.setX(self.horizontalScrollBar().value())
			self.positionBarrePresseeSourisIni.setY(self.verticalScrollBar().value())
			if PYQT_VERSION_STR >= "4.1.0": 
				# curseur main fermée
				self.setCursor(Qt.ClosedHandCursor)
			else: self.setCursor(Qt.SizeAllCursor)
#.........这里部分代码省略.........
开发者ID:Ptaah,项目名称:Ekd,代码行数:103,代码来源:afficheurImage.py


注:本文中的PyQt4.QtCore.QPoint.x方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。