Python PySide2.QtCore.QRectF() Examples
The following are 30
code examples of PySide2.QtCore.QRectF().
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: geometry.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def get_right_side_rect(rect): """ this function return a manipulator rect for the transform handler. __________________________ | | | |* |________________________| """ if not rect: return None top = rect.top() + (rect.height() / 2.0) return QtCore.QRectF( rect.right() + (POINT_RADIUS / 2.0) - POINT_OFFSET, top - (POINT_RADIUS / 2.0) , POINT_RADIUS, POINT_RADIUS)
Example #2
Source File: tileGAN_client.py From tileGAN with GNU General Public License v3.0 | 6 votes |
def fitInView(self, scale=True): rect = self.getImageDims() if not rect.isNull(): self.setSceneRect(rect) unity = self.transform().mapRect(QRectF(0, 0, 1, 1)) self.scale(1 / unity.width(), 1 / unity.height()) viewrect = self.viewport().rect() scenerect = self.transform().mapRect(rect) factor = min(viewrect.width() / scenerect.width(), viewrect.height() / scenerect.height()) self.scale(factor, factor) if self.hasImage(): self.updateIndicatorSize() self._zoom = 0
Example #3
Source File: GraphicsItemsCollection.py From PyAero with MIT License | 6 votes |
def __init__(self, name=None): pen = QtGui.QPen(QtCore.Qt.SolidLine) pen.setColor(QtGui.QColor(0, 0, 0, 255)) pen.setWidthF(0.2) pen.setJoinStyle(QtCore.Qt.MiterJoin) self.pen = pen self.brush = QtGui.QBrush(QtGui.QColor(255, 255, 0, 255)) self.font = QtGui.QFont('Decorative', 12) self.rect = QtCore.QRectF() self.shape = QtGui.QPainterPath() self.path = QtGui.QPainterPath() self.scale = (1, 1) self.tooltip = '' self.method = '' self.args = []
Example #4
Source File: geometry.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def get_combined_rects(rects): """ this function analyse list of rects and return a rect with the smaller top and left and highest right and bottom __________________________________ ? | | A | | | | |______________| ___________| B | | | |_____________________|__________| """ if not rects: return None left = min([rect.left() for rect in rects]) right = max([rect.right() for rect in rects]) top = min([rect.top() for rect in rects]) bottom = max([rect.bottom() for rect in rects]) return QtCore.QRectF(left, top, right - left, bottom - top)
Example #5
Source File: geometry.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def get_bottom_side_rect(rect): """ this function return a manipulator rect for the transform handler. __________________________ | | | | |________________________| * """ if not rect: return None return QtCore.QRectF( rect.left() + (rect.width() / 2.0) - (POINT_RADIUS / 2.0), rect.bottom() + (POINT_RADIUS / 2.0) - POINT_OFFSET, POINT_RADIUS, POINT_RADIUS)
Example #6
Source File: geometry.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def get_left_side_rect(rect): """ this function return a manipulator rect for the transform handler. __________________________ | | *| | |________________________| """ if not rect: return None top = rect.top() + (rect.height() / 2.0) return QtCore.QRectF( rect.left() - (POINT_RADIUS / 2.0) - POINT_OFFSET, top - (POINT_RADIUS / 2.0), POINT_RADIUS, POINT_RADIUS)
Example #7
Source File: geometry.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def get_bottomright_rect(rect): """ this function return a manipulator rect for the transform handler. __________________________ | | | | |________________________| * """ if not rect: return None point = rect.bottomRight() return QtCore.QRectF( point.x() + (POINT_RADIUS / 2.0) - POINT_OFFSET, point.y() + (POINT_RADIUS / 2.0) - POINT_OFFSET, POINT_RADIUS, POINT_RADIUS)
Example #8
Source File: geometry.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def get_bottomleft_rect(rect): """ this function return a manipulator rect for the transform handler. __________________________ | | | | |________________________| * """ if not rect: return None point = rect.bottomLeft() return QtCore.QRectF( point.x() - (POINT_RADIUS / 2.0) - POINT_OFFSET, point.y() + (POINT_RADIUS / 2.0) - POINT_OFFSET, POINT_RADIUS, POINT_RADIUS)
Example #9
Source File: geometry.py From hotbox_designer with BSD 3-Clause Clear License | 6 votes |
def get_topleft_rect(rect): """ this function return a manipulator rect for the transform handler. *__________________________ | | | | |________________________| """ if not rect: return None point = rect.topLeft() return QtCore.QRectF( point.x() - (POINT_RADIUS / 2.0) - POINT_OFFSET, point.y() - (POINT_RADIUS / 2.0) - POINT_OFFSET, POINT_RADIUS, POINT_RADIUS)
Example #10
Source File: qunknown_block.py From angr-management with BSD 2-Clause "Simplified" License | 6 votes |
def _boundingRect(self): height, width = 0, 0 width += self._addr_width width += self.LINEAR_INSTRUCTION_OFFSET if self._bytes_text: height += Conf.disasm_font_height * len(self._bytes_text) * self.currentDevicePixelRatioF() else: height += Conf.disasm_font_height * self.currentDevicePixelRatioF() if self._bytes_text: width += max(len(line) for line in self._bytes_text) * Conf.disasm_font_width * self.currentDevicePixelRatioF() else: width += Conf.disasm_font_metrics.width(QUnknownBlock.DEFAULT_TEXT) * self.currentDevicePixelRatioF() return QRectF(0, 0, width, height) # # Private methods #
Example #11
Source File: GraphicsItem.py From PyAero with MIT License | 5 votes |
def __init__(self, item): """ Args: item (object): GraphicsItemsCollection object """ super().__init__() # get MainWindow instance (overcomes handling parents) self.mainwindow = QtCore.QCoreApplication.instance().mainwindow self.scene = self.mainwindow.scene self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False) self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False) self.setFlag(QtWidgets.QGraphicsItem.ItemIsFocusable, True) # docs: For performance reasons, these notifications # are disabled by default. # needed for : ItemScaleHasChanged self.setFlag(QtWidgets.QGraphicsItem.ItemSendsGeometryChanges, True) self.setAcceptHoverEvents(True) # method of QPainter self.method = item.method self.args = item.args self.pen = item.pen self.penwidth = item.pen.width() self.brush = item.brush self.rect = QtCore.QRectF(item.rect) self.setToolTip(item.tooltip) self.scale = item.scale self.font = item.font self.item_shape = item.shape self.hoverstyle = QtCore.Qt.SolidLine self.hoverwidth = 0.1 if hasattr(item, 'name'): self.name = item.name # initialize bounding rectangle (including penwidth) self.setBoundingRect()
Example #12
Source File: qfunction_header.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _boundingRect(self): height = self._config.disasm_font_height * self.currentDevicePixelRatioF() if self._args_str: height += self._config.disasm_font_height * self.currentDevicePixelRatioF() width = max( self._prototype_width, self._args_str_width, ) return QRectF(0, 0, width, height)
Example #13
Source File: qinstruction.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _boundingRect(self): return QRectF(0, 0, self._width, self._height)
Example #14
Source File: qvariable.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _boundingRect(self): return QRectF(0, 0, self._width, self._height)
Example #15
Source File: qblock.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _boundingRect(self): return QRectF(0, 0, self._width, self._height)
Example #16
Source File: GraphicsItem.py From PyAero with MIT License | 5 votes |
def setBoundingRect(self): # FIXME # FIXME how to calculate penwidth here since scene at the beginning # FIXME is not knwon pw = 0.0 self.boundingrect = QtCore.QRectF(self.rect.left()-pw/2, self.rect.top()-pw/2, self.rect.width()+pw, self.rect.height()+pw)
Example #17
Source File: GraphicsItemsCollection.py From PyAero with MIT License | 5 votes |
def Line(self, x1, y1, x2, y2): eps = 0.01 p1 = QtCore.QPointF(x1-eps, y1-eps) p2 = QtCore.QPointF(x2+eps, y2+eps) self.rect = QtCore.QRectF(p1, p2) self.shape.addRect(self.rect) self.method = 'drawLine' self.args = [x1, y1, x2, y2]
Example #18
Source File: qfeature_map.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _paint_insn_indicators(self, **kwargs): scene = self.view.scene() # type: QGraphicsScene for item in self._insn_indicators: scene.removeItem(item) self._insn_indicators.clear() for selected_insn_addr in self.disasm_view.infodock.selected_insns: pos = self._get_pos_from_addr(selected_insn_addr) if pos is None: continue pos -= 1 # this is the top-left x coordinate of our arrow body (the rectangle) pen = QPen(Qt.yellow) brush = QBrush(Qt.yellow) rect = QRectF(pos, 0, 2, 5) # rectangle item = scene.addRect(rect, pen, brush) self._insn_indicators.append(item) # triangle triangle = QPolygonF() triangle.append(QPointF(pos - 1, 5)) triangle.append(QPointF(pos + 3, 5)) triangle.append(QPointF(pos + 1, 7)) triangle.append(QPointF(pos - 1, 5)) item = scene.addPolygon(triangle, pen, brush) self._insn_indicators.append(item)
Example #19
Source File: qdisasm_graph.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _update_scene_boundary(self): scene = self.scene() # Leave some margins rect = scene.itemsBoundingRect() # type: QRectF scene.setSceneRect(QRectF(rect.x() - 200, rect.y() - 200, rect.width() + 400, rect.height() + 400))
Example #20
Source File: qdepgraph_block.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _boundingRect(self): return QRectF(0, 0, self._width, self._height) # # Private methods #
Example #21
Source File: qlinear_viewer.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def resizeEvent(self, event): old_height = event.oldSize().height() new_height = event.size().height() self._viewer._scene.setSceneRect(QRectF(0, 0, event.size().width(), new_height)) if new_height > old_height: # we probably need more objects generated curr_offset = self._offset self._offset = None # force a re-generation of objects self.prepare_objects(curr_offset, start_line=self._start_line_in_object) self.redraw() super().resizeEvent(event)
Example #22
Source File: qmemory_data_block.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _boundingRect(self): return QRectF(0, 0, self._width, self._height)
Example #23
Source File: qphivariable.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _boundingRect(self): return QRectF(0, 0, self._width, self._height)
Example #24
Source File: qblock_label.py From angr-management with BSD 2-Clause "Simplified" License | 5 votes |
def _boundingRect(self): width = self._config.disasm_font_metrics.width(self.text) * self.currentDevicePixelRatioF() height = self._config.disasm_font_height * self.currentDevicePixelRatioF() return QRectF(0, 0, width, height)
Example #25
Source File: GraphicsView.py From PyAero with MIT License | 5 votes |
def getSceneFromView(self): """Cache view to be able to keep it during resize""" # map view rectangle to scene coordinates polygon = self.mapToScene(self.rect()) # sceneview describes the rectangle which is currently # being viewed in scene coordinates # this is needed during resizing to be able to keep the view self.sceneview = QtCore.QRectF(polygon[0], polygon[2])
Example #26
Source File: GraphicsView.py From PyAero with MIT License | 5 votes |
def adjustMarkerSize(self): """Adjust marker size during zoom. Marker items are circles which are otherwise affected by zoom. Using MARKERSIZE from Settings a fixed markersize (e.g. 3 pixels) can be kept. This method immitates the behaviour of pen.setCosmetic() """ if not self.parent.airfoil: return # markers are drawn in GraphicsItem using scene coordinates # in order to keep them constant size, also when zooming # a fixed pixel size (MARKERSIZE from settings) is mapped to # scene coordinates # depending on the zoom, this leads to always different # scene coordinates # map a square with side length of MARKERSIZE to the scene coords mappedMarker = self.mapToScene( QtCore.QRect(0, 0, MARKERSIZE, MARKERSIZE)) mappedMarkerWidth = mappedMarker.boundingRect().width() if self.parent.airfoil.contourPolygon: markers = self.parent.airfoil.polygonMarkers x, y = self.parent.airfoil.raw_coordinates for i, marker in enumerate(markers): # in case of circle, args is a QRectF marker.args = [QtCore.QRectF(x[i] - mappedMarkerWidth, y[i] - mappedMarkerWidth, 2. * mappedMarkerWidth, 2. * mappedMarkerWidth)] # if self.parent.airfoil.contourSpline: if hasattr(self.parent.airfoil, 'contourSpline'): markers = self.parent.airfoil.splineMarkers x, y = self.parent.airfoil.spline_data[0] for i, marker in enumerate(markers): # in case of circle, args is a QRectF marker.args = [QtCore.QRectF(x[i] - mappedMarkerWidth, y[i] - mappedMarkerWidth, 2. * mappedMarkerWidth, 2. * mappedMarkerWidth)]
Example #27
Source File: GraphicsItemsCollection.py From PyAero with MIT License | 5 votes |
def Rectangle(self, x, y, w, h): self.rect = QtCore.QRectF(x, y, w, h) self.shape.addRect(self.rect) self.method = 'drawRect' self.args = [self.rect]
Example #28
Source File: GraphicsItemsCollection.py From PyAero with MIT License | 5 votes |
def Circle(self, x, y, r): self.rect = QtCore.QRectF(x-r, y-r, 2.*r, 2.*r) self.shape.addEllipse(self.rect) self.method = 'drawEllipse' self.args = [self.rect]
Example #29
Source File: application.py From torba with MIT License | 5 votes |
def boundingRect(self): extra = (self.pen().width() + 20) / 2.0 p1 = self.line().p1() p2 = self.line().p2() size = QtCore.QSizeF(p2.x() - p1.x(), p2.y() - p1.y()) return QtCore.QRectF(p1, size).normalized().adjusted(-extra, -extra, extra, extra)
Example #30
Source File: GraphicsItemsCollection.py From PyAero with MIT License | 5 votes |
def Point(self, x, y): # add some pixels to the point rect, so that it can be selected eps = 0.02 self.rect = QtCore.QRectF(x-eps, y-eps, 2.*eps, 2.*eps) self.shape.addRect(self.rect) self.method = 'drawPoint' self.args = [x, y]