Python PySide2.QtCore.QPoint() Examples
The following are 30
code examples of PySide2.QtCore.QPoint().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PySide2.QtCore
, or try the search function
.
Example #1
Source File: tileGAN_client.py From tileGAN with GNU General Public License v3.0 | 6 votes |
def mouseMoveEvent(self, event): if (event.pos() - self.dragStartPosition).manhattanLength() < QApplication.startDragDistance(): return event.accept() print('starting drag event') self.latentDragged.emit(self.latentCluster) self.setActive() width = self.mainWidget.getCurrentLatentSize() dragPix = self.image.scaled(width, width) drag = QDrag(self) drag.setMimeData(QMimeData(self)) drag.setPixmap(dragPix) drag.setHotSpot(QPoint(drag.pixmap().width() // 2, drag.pixmap().height() // 2)) self.mainWidget.viewer.setDrag(drag) dropAction = drag.start(QtCore.Qt.MoveAction) print('created drag with pixmap of size {}x{}'.format(width, width))
Example #2
Source File: colorwheel.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def color_point(self, point): if point.x() < self._rect.left(): x = self._rect.left() elif point.x() > self._rect.left() + self._rect.width(): x = self._rect.left() + self._rect.width() else: x = point.x() if point.y() < self._rect.top(): y = self._rect.top() elif point.y() > self._rect.top() + self._rect.height(): y = self._rect.top() + self._rect.height() else: y = point.y() self._color_point = QtCore.QPoint(x, y)
Example #3
Source File: lightmap.py From GridCal with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent=None): super(LightMaps, self).__init__(parent) self.pressed = False self.snapped = False self.zoomed = False self.invert = False self._normalMap = SlippyMap(self) self._largeMap = SlippyMap(self) self.pressPos = QPoint() self.dragPos = QPoint() self.tapTimer = QBasicTimer() self.zoomPixmap = QPixmap() self.maskPixmap = QPixmap() self._normalMap.updated.connect(self.updateMap) self._largeMap.updated.connect(self.update)
Example #4
Source File: colorwheel.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def set_current_color(self, color): [r, g, b] = color.getRgb()[:3] self._angle = 360.0 - (QtGui.QColor(r, g, b).getHslF()[0] * 360.0) self._angle = self._angle if self._angle != 720.0 else 0 x = (((( sorted([r, g, b], reverse=True)[0] - sorted([r, g, b])[0]) / 255.0) * self._rect.width()) + self._rect.left()) y = (((( 255 - (sorted([r, g, b], reverse=True)[0])) / 255.0) * self._rect.height()) + self._rect.top()) self._current_color = color self._color_point = QtCore.QPoint(x, y) self.repaint()
Example #5
Source File: lightmap.py From GridCal with GNU General Public License v3.0 | 6 votes |
def download(self): grab = None for x in range(self._tilesRect.width()): for y in range(self._tilesRect.height()): tp = Point(self._tilesRect.topLeft() + QPoint(x, y)) if tp not in self._tilePixmaps: grab = QPoint(tp) break if grab is None: self._url = QUrl() return path = 'http://tile.openstreetmap.org/%d/%d/%d.png' % (self.zoom, grab.x(), grab.y()) self._url = QUrl(path) self.request = QNetworkRequest() self.request.setUrl(self._url) self.request.setRawHeader(b'User-Agent', b'Nokia (PyQt) Graphics Dojo 1.0') self.request.setAttribute(QNetworkRequest.User, grab) self._manager.get(self.request)
Example #6
Source File: lightmap.py From GridCal with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent=None): super(SlippyMap, self).__init__(parent) self._offset = QPoint() self._tilesRect = QRect() self._tilePixmaps = {} # Point(x, y) to QPixmap mapping self._manager = QNetworkAccessManager() self._url = QUrl() # public vars self.width = 400 self.height = 300 self.zoom = 15 self.latitude = 59.9138204 self.longitude = 10.7387413 self._emptyTile = QPixmap(TDIM, TDIM) self._emptyTile.fill(Qt.lightGray) self.request = QNetworkRequest() self.cache = QNetworkDiskCache() self.cache.setCacheDirectory(QStandardPaths.writableLocation(QStandardPaths.CacheLocation)) self._manager.setCache(self.cache) self._manager.finished.connect(self.handleNetworkData)
Example #7
Source File: test_level_drawing.py From SMB3-Foundry with GNU General Public License v3.0 | 6 votes |
def test_level(level_info, qtbot): *level_info, transparent = level_info level_ref = LevelRef() level_ref.load_level(*level_info) Block._block_cache.clear() # monkeypatch level names, since the level name data is broken atm level_ref.level.name = current_test_name() level_view = LevelView(None, level_ref, ContextMenu(level_ref)) level_view.transparency = transparent level_view.draw_jumps = False level_view.draw_grid = False level_view.draw_autoscroll = True rect = QRect(QPoint(0, 0), QSize(*level_ref.level.size) * 16) level_view.setGeometry(rect) _test_level_against_reference(level_view, qtbot)
Example #8
Source File: draw.py From pyrdp with GNU General Public License v3.0 | 6 votes |
def polygonCb(self, state: PolygonCb): LOG.debug(state) p = self._paint(self.surface) self._brush(state.brush) p.brush().setColor(rgb_to_qcolor(state.fg)) p.setBackground(QBrush(rgb_to_qcolor(state.bg))) set_rop2(state.rop2, p) # Handle background mode. if state.brush.style in [BrushStyle.PATTERN, BrushStyle.HATCHED]: p.setBackgroundMode(Qt.TransparentMode if state.bgMode == BACKMODE_TRANSPARENT else Qt.OpaqueMode) polygon = QPolygon() polygon.append(QPoint(state.x0, state.y0)) for (x, y) in state.points: polygon.append(QPoint(x, y)) p.drawPolygon(polygon, _fill[state.fillMode]) self._end(p)
Example #9
Source File: tileGAN_client.py From tileGAN with GNU General Public License v3.0 | 6 votes |
def updateIndicatorPos(self, eventPos): """ move indicator cursor to correct position under mouse """ rect = self.getImageDims() gridSize = rect.width() / self.gridSize.width() latentSize = self.latentSize * gridSize centerOffset = latentSize // 2 scenePos = QGraphicsView.mapToScene(self, eventPos) scenePos -= QPointF(centerOffset, centerOffset) #center latentIndicator around mouse roundPos = QPoint(int(gridSize * round(scenePos.x()/gridSize)), int(gridSize * round(scenePos.y()/gridSize))) roundPos.setX(int(max(-centerOffset, min(roundPos.x(), rect.width() - ( latentSize - centerOffset ))))) roundPos.setY(int(max(-centerOffset, min(roundPos.y(), rect.height() - ( latentSize - centerOffset ))))) self._latentIndicator.setPos(roundPos)
Example #10
Source File: FileSystemWidget.py From pyrdp with GNU General Public License v3.0 | 6 votes |
def onCustomContextMenu(self, localPosition: QPoint): """ Show a custom context menu with a "Download file" action when a file is right-clicked. :param localPosition: position where the user clicked. """ selectedFile = self.selectedFile() if selectedFile is None: return globalPosition = self.listWidget.mapToGlobal(localPosition) downloadAction = QAction("Download file") downloadAction.setEnabled(selectedFile.type in [FileSystemItemType.File]) downloadAction.triggered.connect(self.downloadFile) downloadRecursiveAction = QAction("Download files recursively") downloadRecursiveAction.setEnabled(selectedFile.type in [FileSystemItemType.Directory]) downloadRecursiveAction.triggered.connect(self.downloadDirectoryRecursively) itemMenu = QMenu() itemMenu.addAction(downloadAction) itemMenu.addAction(downloadRecursiveAction) itemMenu.exec_(globalPosition)
Example #11
Source File: Level.py From SMB3-Foundry with GNU General Public License v3.0 | 5 votes |
def get_rect(self, block_length: int = 1): width, height = self.size return QRect(QPoint(0, 0), QSize(width, height) * block_length)
Example #12
Source File: ContourAnalysis.py From PyAero with MIT License | 5 votes |
def initUI(self): self.lineSeries = QtCharts.QLineSeries() # legend name # self.lineSeries.setName("trend") self.lineSeries.append(QtCore.QPoint(0, 0)) pen = QtGui.QPen(QtCore.Qt.red, 6, QtCore.Qt.SolidLine) self.lineSeries.setPen(pen) self.chart = QtCharts.QChart() self.chart.setAnimationOptions(QtCharts.QChart.AllAnimations) self.chart.setTitle("Airfoil contour analysis") self.chart.addSeries(self.lineSeries) self.chart.legend().setVisible(False) self.chart.legend().setAlignment(QtCore.Qt.AlignBottom) self.axisX = QtCharts.QValueAxis() self.axisY = QtCharts.QValueAxis() self.chart.setAxisX(self.axisX, self.lineSeries) self.chart.setAxisY(self.axisY, self.lineSeries) self.chartView = QtCharts.QChartView(self.chart) self.chartView.setRenderHint(QtGui.QPainter.Antialiasing) vlayout = QtWidgets.QVBoxLayout() vlayout.addWidget(self.chartView) self.setLayout(vlayout)
Example #13
Source File: draw.py From pyrdp with GNU General Public License v3.0 | 5 votes |
def polygonSc(self, state: PolygonSc): LOG.debug(state) p = self._paint(self.surface) p.setBrush(QBrush(rgb_to_qcolor(state.brushColor))) set_rop2(state.rop2, p) polygon = QPolygon() polygon.append(QPoint(state.x0, state.y0)) for (x, y) in state.points: polygon.append(QPoint(x, y)) p.drawPolygon(polygon, _fill[state.fillMode]) self._end(p)
Example #14
Source File: draw.py From pyrdp with GNU General Public License v3.0 | 5 votes |
def polyLine(self, state: PolyLine): LOG.debug(state) p = self._paint(self.surface) p.setPen(QPen(rgb_to_qcolor(state.penColor))) set_rop2(state.rop2, p) polygon = QPolygon() polygon.append(QPoint(state.x0, state.y0)) for (x, y) in state.points: polygon.append(QPoint(x, y)) p.drawPolyline(polygon) self._end(p)
Example #15
Source File: qt.py From pyrdp with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, e: QEvent): """ Call when Qt renderer engine estimate that is needed :param e: the event """ ratio = self.ratio if self.scaleToWindow else 1 qp = QPainter(self) qp.drawImage(0, 0, self._buffer.scaled(self.sessionWidth * ratio, self.sessionHeight * ratio, aspectMode=Qt.KeepAspectRatio)) qp.setBrush(QColor.fromRgb(255, 255, 0, 180)) qp.drawEllipse(QPoint(self.mouseX * ratio, self.mouseY * ratio), 5, 5)
Example #16
Source File: WorldMap.py From SMB3-Foundry with GNU General Public License v3.0 | 5 votes |
def object_at(self, x, y): point = QPoint(x, y) for obj in reversed(self.objects): if obj.rect.contains(point): return obj return None
Example #17
Source File: tileGAN_client.py From tileGAN with GNU General Public License v3.0 | 5 votes |
def drawForeground(self, painter, rect): """ override drawForeground method to paint latent grid cells """ if self._showGrid: rect = self.getImageDims() #draw all grid cells penNarrow = QPen(QColor(100, 100, 100, 150), 2) penNarrow.setStyle(QtCore.Qt.CustomDashLine) penNarrow.setDashPattern([1, 2]) penBold = QPen(QColor(styleColor[0], styleColor[1], styleColor[2], 150), 3) penBold.setStyle(QtCore.Qt.CustomDashLine) penBold.setDashPattern([1, 2]) painter.setPen(penNarrow) d = rect.width() / self.gridSize.width() for y in range(1, self.gridSize.height()): if y % self.latentSize == 0: #bold lines at more important grid positions painter.setPen(penBold) else: painter.setPen(penNarrow) painter.drawLine(QPoint(0, int(y * d)), QPoint(int(rect.width()), int(y * d))) for x in range(1, self.gridSize.width()): if x % self.latentSize == 0: painter.setPen(penBold) else: painter.setPen(penNarrow) painter.drawLine(QPoint(int(x*d), 0), QPoint(int(x*d), int(rect.height())))
Example #18
Source File: qtrace_viewer.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _to_logical_pos(self, pos): x_offset = self.view.horizontalScrollBar().value() y_offset = self.view.verticalScrollBar().value() return QPoint(pos.x() + x_offset, pos.y() + y_offset)
Example #19
Source File: lightmap.py From GridCal with GNU General Public License v3.0 | 5 votes |
def invalidate(self): if self.width <= 0 or self.height <= 0: return ct = tileForCoordinate(self.latitude, self.longitude, self.zoom) tx = ct.x() ty = ct.y() # top-left corner of the center tile xp = int(self.width / 2 - (tx - math.floor(tx)) * TDIM) yp = int(self.height / 2 - (ty - math.floor(ty)) * TDIM) # first tile vertical and horizontal xa = (xp + TDIM - 1) / TDIM ya = (yp + TDIM - 1) / TDIM xs = int(tx) - xa ys = int(ty) - ya # offset for top-left tile self._offset = QPoint(xp - xa * TDIM, yp - ya * TDIM) # last tile vertical and horizontal xe = int(tx) + (self.width - xp - 1) / TDIM ye = int(ty) + (self.height - yp - 1) / TDIM # build a rect self._tilesRect = QRect(xs, ys, xe - xs + 1, ye - ys + 1) if self._url.isEmpty(): self.download() self.updated.emit(QRect(0, 0, self.width, self.height))
Example #20
Source File: lightmap.py From GridCal with GNU General Public License v3.0 | 5 votes |
def keyPressEvent(self, event): if not self.zoomed: if event.key() == Qt.Key_Left: self._normalMap.pan(QPoint(20, 0)) if event.key() == Qt.Key_Right: self._normalMap.pan(QPoint(-20, 0)) if event.key() == Qt.Key_Up: self._normalMap.pan(QPoint(0, 20)) if event.key() == Qt.Key_Down: self._normalMap.pan(QPoint(0, -20)) if event.key() == Qt.Key_Z or event.key() == Qt.Key_Select: self.dragPos = QPoint(self.width() / 2, self.height() / 2) self.activateZoom() else: if event.key() == Qt.Key_Z or event.key() == Qt.Key_Select: self.zoomed = False self.update() delta = QPoint(0, 0) if event.key() == Qt.Key_Left: delta = QPoint(-15, 0) if event.key() == Qt.Key_Right: delta = QPoint(15, 0) if event.key() == Qt.Key_Up: delta = QPoint(0, -15) if event.key() == Qt.Key_Down: delta = QPoint(0, 15) if delta != QPoint(0, 0): self.dragPos += delta self.update()
Example #21
Source File: tileGAN_client.py From tileGAN with GNU General Public License v3.0 | 5 votes |
def mousePressEvent(self, e: QtGui.QMouseEvent): self.position = QPoint(e.globalX() - self.geometry().x(), e.globalY() - self.geometry().y()) if not self._isEditing: return if not self._inFocus: return if not e.buttons() and QtCore.Qt.LeftButton: self.setCursorShape(e.pos()) return if e.button() == QtCore.Qt.RightButton: self.popupShow(e.pos()) e.accept()
Example #22
Source File: colorwheel.py From hotbox_designer with BSD 3-Clause Clear License | 5 votes |
def mouse_update(self, event): if self._current_tool == 'rect': self.color_point = event.pos() else: center = self._get_center() a = QtCore.QPoint(event.pos().x(), center.y()) self._angle = get_absolute_angle_c(a=a, b=event.pos(), c=center) self.repaint() self.currentColorChanged.emit(self.current_color())
Example #23
Source File: colorwheel.py From hotbox_designer with BSD 3-Clause Clear License | 5 votes |
def _get_center(self): return QtCore.QPoint(self.width() / 2, self.height() / 2)
Example #24
Source File: painting.py From hotbox_designer with BSD 3-Clause Clear License | 5 votes |
def draw_editor_center(painter, rect, point): color = QtGui.QColor(200, 200, 200, 125) painter.setPen(QtGui.QPen(color)) painter.setBrush(QtGui.QBrush(color)) painter.drawRect(rect) path = get_center_path(QtCore.QPoint(*point)) pen = QtGui.QPen(QtGui.QColor(50, 125, 255)) pen.setWidth(2) painter.setPen(pen) painter.drawPath(path)
Example #25
Source File: painting.py From hotbox_designer with BSD 3-Clause Clear License | 5 votes |
def get_center_path(point): ext = 12 int_ = 5 path = QtGui.QPainterPath(point) path.moveTo(QtCore.QPoint(point.x() - ext, point.y())) path.lineTo(QtCore.QPoint(point.x() - int_, point.y())) path.moveTo(QtCore.QPoint(point.x() + int_, point.y())) path.lineTo(QtCore.QPoint(point.x() + ext, point.y())) path.moveTo(QtCore.QPoint(point.x(), point.y() - ext)) path.lineTo(QtCore.QPoint(point.x(), point.y() - int_)) path.moveTo(QtCore.QPoint(point.x(), point.y() + int_)) path.lineTo(QtCore.QPoint(point.x(), point.y() + ext)) path.addEllipse(point, 1, 1) return path
Example #26
Source File: geometry.py From hotbox_designer with BSD 3-Clause Clear License | 5 votes |
def get_relative_point(rect, point): x = point.x() - rect.left() y = point.y() - rect.top() return QtCore.QPoint(x, y)
Example #27
Source File: geometry.py From hotbox_designer with BSD 3-Clause Clear License | 5 votes |
def get_point_on_line(angle, ray): x = 50 + ray * math.cos(float(angle)) y = 50 + ray * math.sin(float(angle)) return QtCore.QPoint(x, y)
Example #28
Source File: tileGAN_client.py From tileGAN with GNU General Public License v3.0 | 5 votes |
def popupShow(self, pt: QPoint): if self.menu.isEmpty: return global_ = self.mapToGlobal(pt) self._showMenu = True self.menu.exec(global_) self._showMenu = False
Example #29
Source File: tileGAN_client.py From tileGAN with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, index, imageArray, customColor=None): super(LatentLabel, self).__init__(parent) self.mainWidget = parent self.latentCluster = index cp = imageArray.copy() image = QImage(cp, imageArray.shape[1], imageArray.shape[0], QImage.Format_RGB888) self.image = QPixmap(image) self.setPixmap(self.image.scaled(128, 128)) self.setGeometry(0, 0, 128, 128) self.dragStartPosition = QPoint() self.isActive = False self.setStyleSheet('border: none') self.customColor = customColor #RGB color tuple self.mouseDown = False
Example #30
Source File: tileGAN_client.py From tileGAN with GNU General Public License v3.0 | 5 votes |
def updateIndicatorSize(self, stroke=3, offset=2, crossSize=10): """ draw a box and crosshair under mouse cursor as rectangle of size latentSize """ multiplier = 1 #TODO optional: scale indicator with zoom level stroke *= multiplier offset *= multiplier crossSize *= multiplier halfStroke = stroke / 2 rect = self.getImageDims() latentSize = self.latentSize * rect.width() / self.gridSize.width() halfSize = latentSize / 2 crossSize = min(crossSize, int(halfSize - 3)) pixmap = QPixmap(QSize(int(latentSize + stroke + offset), int(latentSize + stroke + offset))) #fill rectangle with transparent color pixmap.fill(QColor(0,0,0,0)) #transparent painter = QPainter(pixmap) r = QRectF(QPoint(), QSizeF(latentSize, latentSize)) r.adjust(offset+halfStroke, offset+halfStroke, -halfStroke, -halfStroke) #draw shadow under rectangle pen = QPen(QColor(50, 50, 50, 100), stroke) #shadow painter.setPen(pen) painter.drawRect(r) if crossSize > 4: painter.drawLine(QPointF(offset+halfSize, offset+halfSize-crossSize), QPointF(offset+halfSize, offset+halfSize+crossSize)) painter.drawLine(QPointF(offset+halfSize-crossSize, offset+halfSize), QPointF(offset+halfSize+crossSize, offset+halfSize)) r.adjust(-offset, -offset, -offset, -offset) pen = QPen(QColor(styleColor[0], styleColor[1], styleColor[2], 200), stroke) painter.setPen(pen) painter.drawRect(r) if crossSize > 4: painter.drawLine(QPointF(halfSize, halfSize - crossSize), QPointF(halfSize, halfSize + crossSize)) painter.drawLine(QPointF(halfSize - crossSize, halfSize), QPointF(halfSize + crossSize, halfSize)) painter.end() self._latentIndicator.setPixmap(pixmap)