本文整理汇总了Python中PyQt4.QtCore.QPoint类的典型用法代码示例。如果您正苦于以下问题:Python QPoint类的具体用法?Python QPoint怎么用?Python QPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_camera_vars
def _init_camera_vars (self):
'''
static method. It initializes the math variables.
'''
self.__compo_mtools = MathTools.Tools ()
self.__curr_angles = QPoint (0,0)
self.__last_pos = QPoint (0,0)
self.__delta = QPoint (0,0)
self.__orig = QVector3D (0.0, 0.0, 0.0)
self.__cam_dist = 0.0
self.__z_near = 0.1
self.__z_far = 2000.0
self.__fovy = 45.0
self.__angle = self.__compo_mtools.getAngle (self.__fovy)
self.__norm_mtx = QMatrix4x4 () #(GLdouble * 16)()
self.__norm_mtx.setToIdentity ()
self.__mtx = QMatrix4x4 () #(GLdouble * 16)()
self.__mtx.setToIdentity ()
self.__aspect_ratio = float(self.__w)/float(self.__h)
self.__camera_list = []
示例2: NotificationServer
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)
示例3: showPopup
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()
示例4: open_link
def open_link(self, x, y):
self.__upostda_condition.acquire()
p = QPoint()
p.setX(int(x))
p.setY(int(y))
self.emit(QtCore.SIGNAL('signalUPosDA(QPoint *)'), p)
self.__upostda_condition.wait()
self.__upostda_condition.release()
示例5: contains
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
示例6: get_border
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
示例7: __init__
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)
示例8: drawNetwork
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()
示例9: eventFilter
def eventFilter( self, watched, event ):
if event.type() == QEvent.MouseButtonPress:
pos = [int(i) for i in self.posModel.cursorPos]
pos = [self.posModel.time] + pos + [self.posModel.channel]
if event.button() == Qt.LeftButton:
self.origin = QPoint(event.pos())
self.originpos = pos
self.rubberBand.setGeometry(QRect(self.origin, QSize()))
self.rubberBand.show()
gPos = watched.mapToGlobal( event.pos() )
self.leftClickReceived.emit( pos, gPos )
if event.button() == Qt.RightButton:
gPos = watched.mapToGlobal( event.pos() )
self.rightClickReceived.emit( pos, gPos )
if event.type() == QEvent.MouseMove:
if not self.origin.isNull():
self.rubberBand.setGeometry(QRect(self.origin,
event.pos()).normalized())
if event.type() == QEvent.MouseButtonRelease:
pos = [int(i) for i in self.posModel.cursorPos]
pos = [self.posModel.time] + pos + [self.posModel.channel]
if event.button() == Qt.LeftButton:
self.rubberBand.hide()
self.leftClickReleased.emit( self.originpos,pos )
# Event is always forwarded to the navigation interpreter.
return self.baseInterpret.eventFilter(watched, event)
示例10: __init__
def __init__(self, navigationInterpreter, positionModel, BoxContr, widget):
'''
Class which interacts directly with the image scene
:param navigationInterpreter:
:param positionModel:
:param BoxContr:
:param widget: The main widget
'''
QObject.__init__(self)
self.baseInterpret = navigationInterpreter
self._posModel = positionModel
self.rubberBand = RedRubberBand(QRubberBand.Rectangle, widget)
self.boxController=BoxContr
self.leftClickReleased.connect(BoxContr.addNewBox)
self.rightClickReceived.connect(BoxContr.onChangedPos)
#self.deleteSelectedItemsSignal.connect(BoxContr.deleteSelectedItems)
self.origin = QPoint()
self.originpos = object()
示例11: __init__
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()
示例12: __init__
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.setWindowFlags(Qt.FramelessWindowHint)
self.rubberBand = QRubberBand(QRubberBand.Rectangle, self)
self.origin = QPoint()
self.repaint()
示例13: drawQuad
def drawQuad(self):
'''change to accept arguments pass'''
glColor( 0., 0., 1.)
glLineWidth(4.0)
pointer_x = self.lastpos.x()/200.#self.corner
pointer_y = self.lastpos.y()/200.#/(self.corner)
norm_dx = dx/200.#/(self.corner)
norm_dy = dy/200.#/(self.corner)
#print -self.corner, pointer_x, pointer_y, norm_dx, norm_dy
glBegin(GL_QUADS)
glVertex3f(-self.corner + pointer_x,
-self.corner + pointer_y,
-self.near+2*self.corner)
glVertex3f(-self.corner + pointer_x+ norm_dx,
-self.corner + pointer_y,
-self.near+2*self.corner)
glVertex3f(-self.corner + pointer_x+ norm_dx,
-self.corner + pointer_y + norm_dy,
-self.near+2*self.corner)
glVertex3f(-self.corner + pointer_x,
-self.corner + pointer_y,
-self.near+2*self.corner)
glEnd()
self.lastpos = QPoint(event.pos())
#redraw eachtime mouse 's moving
self.updateGL()
示例14: Window
class Window(QMainWindow):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.setWindowFlags(Qt.FramelessWindowHint)
self.rubberBand = QRubberBand(QRubberBand.Rectangle, self)
self.origin = QPoint()
self.repaint()
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.origin = QPoint(event.pos())
self.rubberBand.setGeometry(QRect(self.origin, QSize()))
self.rubberBand.show()
def mouseMoveEvent(self, event):
if not self.origin.isNull():
self.rubberBand.setGeometry(QRect(self.origin, event.pos()).normalized())
def mouseReleaseEvent(self, event):
if event.button() == Qt.LeftButton:
self.rubberBand.hide()
示例15: mousePressEvent
def mousePressEvent(self, event):
if self.mode == "ZOOMING":
self.mode = "None"
self.computeSelection()
else:
self.lastpos = QPoint(event.pos())
self.setCursor(QCursor(Qt.ClosedHandCursor))