Python PyQt4.QtCore.QPoint() Examples
The following are 22
code examples of PyQt4.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
PyQt4.QtCore
, or try the search function
.
Example #1
Source File: driverWindow.py From crazyflieROS with GNU General Public License v2.0 | 6 votes |
def readSettings(self): """ Load settings from previous session """ rospy.logdebug("Loading previous session settings") settings = QSettings("omwdunkley", "reset" if self.options.reset else "flieROS"+str(self.options.radio) ) self.resize(settings.value("size", QVariant(QSize(300, 500))).toSize()) self.move(settings.value("pos", QVariant(QPoint(200, 200))).toPoint()) self.ui.checkBox_reconnect.setChecked(settings.value("autoReconnect", QVariant(self.ui.checkBox_reconnect.isChecked())).toBool()) self.ui.checkBox_beep.setChecked(settings.value("beepOn", QVariant(self.ui.checkBox_beep.isChecked())).toBool()) self.ui.checkBox_xmode.setChecked(settings.value("xmodeOn", QVariant(self.ui.checkBox_xmode.isChecked())).toBool()) self.ui.checkBox_kill.setChecked(settings.value("killOn", QVariant(self.ui.checkBox_kill.isChecked())).toBool()) self.ui.checkBox_startupConnect.setChecked(settings.value("startConnect", QVariant(self.ui.checkBox_startupConnect)).toBool()) self.ui.checkBox_pktHZ.setChecked(settings.value("pktHzOn", QVariant(self.ui.checkBox_pktHZ.isChecked())).toBool()) self.ui.checkBox_logHZ.setChecked(settings.value("logHzOn", QVariant(self.ui.checkBox_logHZ.isChecked())).toBool()) self.ui.horizontalSlider_pktHZ.setValue(settings.value("pktHzVal", QVariant(self.ui.horizontalSlider_pktHZ.value())).toInt()[0]) self.ui.horizontalSlider_logHZ.setValue(settings.value("logHzVal", QVariant(self.ui.horizontalSlider_logHZ.value())).toInt()[0]) self.ui.horizontalSlider_guiHZ.setValue(settings.value("guiHzVal", QVariant(self.ui.horizontalSlider_guiHZ.value())).toInt()[0]) self.ui.horizontalSlider_AI.setValue(settings.value("aiHzVal", QVariant(self.ui.horizontalSlider_AI.value())).toInt()[0]) self.logManager.header().restoreState(settings.value("logTreeH", self.logManager.header().saveState()).toByteArray()) self.paramManager.header().restoreState(settings.value("paramTreeH", self.paramManager.header().saveState()).toByteArray())
Example #2
Source File: FrameLayout.py From pyqt-collapsible-widget with MIT License | 6 votes |
def __init__(self, parent=None, title="", collapsed=False): QtGui.QFrame.__init__(self, parent=parent) self.setMinimumHeight(24) self.move(QtCore.QPoint(24, 0)) self.setStyleSheet("border:1px solid rgb(41, 41, 41); ") self._hlayout = QtGui.QHBoxLayout(self) self._hlayout.setContentsMargins(0, 0, 0, 0) self._hlayout.setSpacing(0) self._arrow = None self._title = None self._hlayout.addWidget(self.initArrow(collapsed)) self._hlayout.addWidget(self.initTitle(title))
Example #3
Source File: gauge.py From tutorials with MIT License | 6 votes |
def centerScaleRect(rect, scale): """ centerScaleRect(QRect rect, float scale) -> QRect scaled Takes a QRect and a float scale value, and returns a copy of the rect that has been scaled around the center point. """ scaledRect = QtCore.QRect(rect) size = scaledRect.size() pos = scaledRect.center() offset = QtCore.QPoint( pos.x() - (size.width()*.5), pos.y() - (size.height()*.5)) scaledRect.moveCenter(offset) scaledRect.setSize(size * scale) scaledRect.moveCenter(pos) return scaledRect
Example #4
Source File: sliceviewwidget.py From segyviewer with GNU Lesser General Public License v3.0 | 5 votes |
def _subplot_clicked(self, event): keys = event['key'] if self._context.indicators and event['button'] == 1 and not keys: x = int(event['x']) y = int(event['y']) slice_model = self._get_slice_view(event).model() self._context.update_index_for_direction(slice_model.x_index_direction, x) self._context.update_index_for_direction(slice_model.y_index_direction, y) elif event['button'] == 3 and (not keys or keys.state(ctrl=True)): subplot_index = event['subplot_index'] context_menu = self._create_slice_view_context_menu(subplot_index) context_menu.exec_(self.mapToGlobal(QPoint(event['mx'], self.height() - event['my'])))
Example #5
Source File: FrameLayout.py From pyqt-collapsible-widget with MIT License | 5 votes |
def initTitle(self, title=None): self._title = QtGui.QLabel(title) self._title.setMinimumHeight(24) self._title.move(QtCore.QPoint(24, 0)) self._title.setStyleSheet("border:0px") return self._title
Example #6
Source File: rescaletime.py From cross3d with MIT License | 5 votes |
def minimizeWindows(self, id): hwnds = [] maxHwnd = GetWindowHandle() threadID = GetCurrentThreadId() EnumThreadWindows( threadID, self.EnumWindowsProc, hwnds) pnt = ClientToScreen(id,(5,5)) pnt = QPoint(pnt[0], pnt[1]) for hwnd in hwnds: if hwnd != maxHwnd: rect = GetWindowRect(hwnd) if QRect(QPoint(rect[0], rect[1]), QPoint(rect[2], rect[3])).contains(pnt) and IsWindowVisible(hwnd): # print hwnd, GetWindowRect(hwnd), GetWindowText(hwnd), GetClassName(hwnd), IsWindowVisible(hwnd) self.minimzedWindows.append(hwnd) ShowWindow( hwnd, win32con.SW_MINIMIZE )
Example #7
Source File: xmlelement.py From cross3d with MIT License | 5 votes |
def findPoint(self, name): return self._findPoint(name, QPoint, int)
Example #8
Source File: mapclient_qt.py From CrisisMappingToolkit with Apache License 2.0 | 5 votes |
def paintEvent(self, event): '''Rasterize each of the tiles on to the output image display''' painter = QtGui.QPainter() with self.qttiles_lock: painter.begin(self) for key in self.qttiles.keys(): if key[0] != self.level: continue image = self.qttiles[key] xpos = key[1] * image.width() + self.origin_x ypos = key[2] * image.height() + self.origin_y painter.drawImage(QtCore.QPoint(xpos, ypos), image) painter.end()
Example #9
Source File: Widget.py From pihud with GNU Lesser General Public License v2.1 | 5 votes |
def position(self): return QtCore.QPoint(self.config['x'], self.config['y'])
Example #10
Source File: Page.py From pihud with GNU Lesser General Public License v2.1 | 5 votes |
def dropEvent(self, e): # get relative position of mouse from mimedata mime = e.mimeData().text() x, y = map(int, mime.split(',')) e.source().move(e.pos() - QtCore.QPoint(x, y)) e.setDropAction(QtCore.Qt.MoveAction) e.accept()
Example #11
Source File: cityscapesLabelTool.py From TFSegmentation with Apache License 2.0 | 4 votes |
def drawLabelAtMouse(self, qp): # Nothing to do without a highlighted object if not self.highlightObjs: return # Also we do not want to draw the label, if we have a drawn polygon if not self.drawPoly.isEmpty(): return # Nothing to without a mouse position if not self.mousePos: return # Save QPainter settings to stack qp.save() # That is the mouse positiong mouse = self.mousePos # Will show zoom showZoom = self.config.zoom and not self.image.isNull() and self.w and self.h # The text that is written next to the mouse mouseText = self.highlightObjs[-1].label # Where to write the text # Depends on the zoom (additional offset to mouse to make space for zoom?) # The location in the image (if we are at the top we want to write below of the mouse) off = 36 if showZoom: off += self.config.zoomSize/2 if mouse.y()-off > self.toolbar.height(): top = mouse.y()-off btm = mouse.y() vAlign = QtCore.Qt.AlignTop else: # The height of the cursor if not showZoom: off += 20 top = mouse.y() btm = mouse.y()+off vAlign = QtCore.Qt.AlignBottom # Here we can draw rect = QtCore.QRect() rect.setTopLeft(QtCore.QPoint(mouse.x()-100,top)) rect.setBottomRight(QtCore.QPoint(mouse.x()+100,btm)) # The color qp.setPen(QtGui.QColor('white')) # The font to use font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold) qp.setFont(font) # Non-transparent qp.setOpacity(1) # Draw the text, horizontally centered qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText) # Restore settings qp.restore() # Draw the zoom
Example #12
Source File: cityscapesLabelTool.py From Detectron-PYTORCH with Apache License 2.0 | 4 votes |
def drawLabelAtMouse(self, qp): # Nothing to do without a highlighted object if not self.highlightObjs: return # Also we do not want to draw the label, if we have a drawn polygon if not self.drawPoly.isEmpty(): return # Nothing to without a mouse position if not self.mousePos: return # Save QPainter settings to stack qp.save() # That is the mouse positiong mouse = self.mousePos # Will show zoom showZoom = self.config.zoom and not self.image.isNull() and self.w and self.h # The text that is written next to the mouse mouseText = self.highlightObjs[-1].label # Where to write the text # Depends on the zoom (additional offset to mouse to make space for zoom?) # The location in the image (if we are at the top we want to write below of the mouse) off = 36 if showZoom: off += self.config.zoomSize/2 if mouse.y()-off > self.toolbar.height(): top = mouse.y()-off btm = mouse.y() vAlign = QtCore.Qt.AlignTop else: # The height of the cursor if not showZoom: off += 20 top = mouse.y() btm = mouse.y()+off vAlign = QtCore.Qt.AlignBottom # Here we can draw rect = QtCore.QRect() rect.setTopLeft(QtCore.QPoint(mouse.x()-100,top)) rect.setBottomRight(QtCore.QPoint(mouse.x()+100,btm)) # The color qp.setPen(QtGui.QColor('white')) # The font to use font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold) qp.setFont(font) # Non-transparent qp.setOpacity(1) # Draw the text, horizontally centered qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText) # Restore settings qp.restore() # Draw the zoom
Example #13
Source File: cityscapesLabelTool.py From Detectron-PYTORCH with Apache License 2.0 | 4 votes |
def drawDrawRect(self, qp): qp.save() qp.setBrush(QtGui.QBrush(QtCore.Qt.NoBrush)) qp.setFont(QtGui.QFont('QFont::AnyStyle', 14)) thickPen = QtGui.QPen() qp.setPen(thickPen) for c in self.corrections: rect = copy.deepcopy(c.bbox) width = rect.width() height = rect.height() rect.setX(c.bbox.x() * self.scale + self.xoff) rect.setY(c.bbox.y() * self.scale + self.yoff) rect.setWidth(width * self.scale) rect.setHeight(height * self.scale) if c.selected: thickPen.setColor(QtGui.QColor(0,0,0)) if c.type == CorrectionBox.types.QUESTION: descr = "QUESTION" elif c.type == CorrectionBox.types.RESOLVED: descr = "FIXED" else: descr = "ERROR" qp.setPen(thickPen) qp.drawText(QtCore.QPoint( self.xoff, self.yoff + self.h + 20 ), "(%s: %s)" % (descr, c.annotation)) pen_width = 6 else: pen_width = 3 colour = c.get_colour() thickPen.setColor(colour) thickPen.setWidth(pen_width) qp.setPen(thickPen) qp.drawRect(rect) if self.in_progress_bbox is not None: rect = copy.deepcopy(self.in_progress_bbox) width = rect.width() height = rect.height() rect.setX(self.in_progress_bbox.x() * self.scale + self.xoff) rect.setY(self.in_progress_bbox.y() * self.scale + self.yoff) rect.setWidth(width * self.scale) rect.setHeight(height * self.scale) thickPen.setColor(QtGui.QColor(255,0,0)) thickPen.setWidth(3) qp.setPen(thickPen) qp.drawRect(rect) qp.restore() # Draw the polygon that is drawn and edited by the user # Usually the polygon must be rescaled properly. However when drawing # The polygon within the zoom, this is not needed. Therefore the option transform.
Example #14
Source File: cityscapesViewer.py From TFSegmentation with Apache License 2.0 | 4 votes |
def drawLabelAtMouse(self, qp): # Nothing to do without a highlighted object if not self.highlightObj: return # Nothing to without a mouse position if not self.mousePosOrig: return # Save QPainter settings to stack qp.save() # That is the mouse positiong mouse = self.mousePosOrig # Will show zoom showZoom = self.zoom and not self.image.isNull() and self.w and self.h # The text that is written next to the mouse mouseText = self.highlightObj.label # Where to write the text # Depends on the zoom (additional offset to mouse to make space for zoom?) # The location in the image (if we are at the top we want to write below of the mouse) off = 36 if showZoom: off += self.zoomSize/2 if mouse.y()-off > self.toolbar.height(): top = mouse.y()-off btm = mouse.y() vAlign = QtCore.Qt.AlignTop else: # The height of the cursor if not showZoom: off += 20 top = mouse.y() btm = mouse.y()+off vAlign = QtCore.Qt.AlignBottom # Here we can draw rect = QtCore.QRect() rect.setTopLeft(QtCore.QPoint(mouse.x()-200,top)) rect.setBottomRight(QtCore.QPoint(mouse.x()+200,btm)) # The color qp.setPen(QtGui.QColor('white')) # The font to use font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold) qp.setFont(font) # Non-transparent qp.setOpacity(1) # Draw the text, horizontally centered qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText) # Restore settings qp.restore() # Draw the zoom
Example #15
Source File: cityscapesLabelTool.py From fcn8s_tensorflow with GNU General Public License v3.0 | 4 votes |
def drawDrawRect(self, qp): qp.save() qp.setBrush(QtGui.QBrush(QtCore.Qt.NoBrush)) qp.setFont(QtGui.QFont('QFont::AnyStyle', 14)) thickPen = QtGui.QPen() qp.setPen(thickPen) for c in self.corrections: rect = copy.deepcopy(c.bbox) width = rect.width() height = rect.height() rect.setX(c.bbox.x() * self.scale + self.xoff) rect.setY(c.bbox.y() * self.scale + self.yoff) rect.setWidth(width * self.scale) rect.setHeight(height * self.scale) if c.selected: thickPen.setColor(QtGui.QColor(0,0,0)) if c.type == CorrectionBox.types.QUESTION: descr = "QUESTION" elif c.type == CorrectionBox.types.RESOLVED: descr = "FIXED" else: descr = "ERROR" qp.setPen(thickPen) qp.drawText(QtCore.QPoint( self.xoff, self.yoff + self.h + 20 ), "(%s: %s)" % (descr, c.annotation)) pen_width = 6 else: pen_width = 3 colour = c.get_colour() thickPen.setColor(colour) thickPen.setWidth(pen_width) qp.setPen(thickPen) qp.drawRect(rect) if self.in_progress_bbox is not None: rect = copy.deepcopy(self.in_progress_bbox) width = rect.width() height = rect.height() rect.setX(self.in_progress_bbox.x() * self.scale + self.xoff) rect.setY(self.in_progress_bbox.y() * self.scale + self.yoff) rect.setWidth(width * self.scale) rect.setHeight(height * self.scale) thickPen.setColor(QtGui.QColor(255,0,0)) thickPen.setWidth(3) qp.setPen(thickPen) qp.drawRect(rect) qp.restore() # Draw the polygon that is drawn and edited by the user # Usually the polygon must be rescaled properly. However when drawing # The polygon within the zoom, this is not needed. Therefore the option transform.
Example #16
Source File: cityscapesLabelTool.py From TFSegmentation with Apache License 2.0 | 4 votes |
def drawDrawRect(self, qp): qp.save() qp.setBrush(QtGui.QBrush(QtCore.Qt.NoBrush)) qp.setFont(QtGui.QFont('QFont::AnyStyle', 14)) thickPen = QtGui.QPen() qp.setPen(thickPen) for c in self.corrections: rect = copy.deepcopy(c.bbox) width = rect.width() height = rect.height() rect.setX(c.bbox.x() * self.scale + self.xoff) rect.setY(c.bbox.y() * self.scale + self.yoff) rect.setWidth(width * self.scale) rect.setHeight(height * self.scale) if c.selected: thickPen.setColor(QtGui.QColor(0,0,0)) if c.type == CorrectionBox.types.QUESTION: descr = "QUESTION" elif c.type == CorrectionBox.types.RESOLVED: descr = "FIXED" else: descr = "ERROR" qp.setPen(thickPen) qp.drawText(QtCore.QPoint( self.xoff, self.yoff + self.h + 20 ), "(%s: %s)" % (descr, c.annotation)) pen_width = 6 else: pen_width = 3 colour = c.get_colour() thickPen.setColor(colour) thickPen.setWidth(pen_width) qp.setPen(thickPen) qp.drawRect(rect) if self.in_progress_bbox is not None: rect = copy.deepcopy(self.in_progress_bbox) width = rect.width() height = rect.height() rect.setX(self.in_progress_bbox.x() * self.scale + self.xoff) rect.setY(self.in_progress_bbox.y() * self.scale + self.yoff) rect.setWidth(width * self.scale) rect.setHeight(height * self.scale) thickPen.setColor(QtGui.QColor(255,0,0)) thickPen.setWidth(3) qp.setPen(thickPen) qp.drawRect(rect) qp.restore() # Draw the polygon that is drawn and edited by the user # Usually the polygon must be rescaled properly. However when drawing # The polygon within the zoom, this is not needed. Therefore the option transform.
Example #17
Source File: cityscapesViewer.py From LightNet with MIT License | 4 votes |
def drawLabelAtMouse(self, qp): # Nothing to do without a highlighted object if not self.highlightObj: return # Nothing to without a mouse position if not self.mousePosOrig: return # Save QPainter settings to stack qp.save() # That is the mouse positiong mouse = self.mousePosOrig # Will show zoom showZoom = self.zoom and not self.image.isNull() and self.w and self.h # The text that is written next to the mouse mouseText = self.highlightObj.label # Where to write the text # Depends on the zoom (additional offset to mouse to make space for zoom?) # The location in the image (if we are at the top we want to write below of the mouse) off = 36 if showZoom: off += self.zoomSize/2 if mouse.y()-off > self.toolbar.height(): top = mouse.y()-off btm = mouse.y() vAlign = QtCore.Qt.AlignTop else: # The height of the cursor if not showZoom: off += 20 top = mouse.y() btm = mouse.y()+off vAlign = QtCore.Qt.AlignBottom # Here we can draw rect = QtCore.QRect() rect.setTopLeft(QtCore.QPoint(mouse.x()-200,top)) rect.setBottomRight(QtCore.QPoint(mouse.x()+200,btm)) # The color qp.setPen(QtGui.QColor('white')) # The font to use font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold) qp.setFont(font) # Non-transparent qp.setOpacity(1) # Draw the text, horizontally centered qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText) # Restore settings qp.restore() # Draw the zoom
Example #18
Source File: cityscapesLabelTool.py From LightNet with MIT License | 4 votes |
def drawLabelAtMouse(self, qp): # Nothing to do without a highlighted object if not self.highlightObjs: return # Also we do not want to draw the label, if we have a drawn polygon if not self.drawPoly.isEmpty(): return # Nothing to without a mouse position if not self.mousePos: return # Save QPainter settings to stack qp.save() # That is the mouse positiong mouse = self.mousePos # Will show zoom showZoom = self.config.zoom and not self.image.isNull() and self.w and self.h # The text that is written next to the mouse mouseText = self.highlightObjs[-1].label # Where to write the text # Depends on the zoom (additional offset to mouse to make space for zoom?) # The location in the image (if we are at the top we want to write below of the mouse) off = 36 if showZoom: off += self.config.zoomSize/2 if mouse.y()-off > self.toolbar.height(): top = mouse.y()-off btm = mouse.y() vAlign = QtCore.Qt.AlignTop else: # The height of the cursor if not showZoom: off += 20 top = mouse.y() btm = mouse.y()+off vAlign = QtCore.Qt.AlignBottom # Here we can draw rect = QtCore.QRect() rect.setTopLeft(QtCore.QPoint(mouse.x()-100,top)) rect.setBottomRight(QtCore.QPoint(mouse.x()+100,btm)) # The color qp.setPen(QtGui.QColor('white')) # The font to use font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold) qp.setFont(font) # Non-transparent qp.setOpacity(1) # Draw the text, horizontally centered qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText) # Restore settings qp.restore() # Draw the zoom
Example #19
Source File: cityscapesLabelTool.py From LightNet with MIT License | 4 votes |
def drawDrawRect(self, qp): qp.save() qp.setBrush(QtGui.QBrush(QtCore.Qt.NoBrush)) qp.setFont(QtGui.QFont('QFont::AnyStyle', 14)) thickPen = QtGui.QPen() qp.setPen(thickPen) for c in self.corrections: rect = copy.deepcopy(c.bbox) width = rect.width() height = rect.height() rect.setX(c.bbox.x() * self.scale + self.xoff) rect.setY(c.bbox.y() * self.scale + self.yoff) rect.setWidth(width * self.scale) rect.setHeight(height * self.scale) if c.selected: thickPen.setColor(QtGui.QColor(0,0,0)) if c.type == CorrectionBox.types.QUESTION: descr = "QUESTION" elif c.type == CorrectionBox.types.RESOLVED: descr = "FIXED" else: descr = "ERROR" qp.setPen(thickPen) qp.drawText(QtCore.QPoint( self.xoff, self.yoff + self.h + 20 ), "(%s: %s)" % (descr, c.annotation)) pen_width = 6 else: pen_width = 3 colour = c.get_colour() thickPen.setColor(colour) thickPen.setWidth(pen_width) qp.setPen(thickPen) qp.drawRect(rect) if self.in_progress_bbox is not None: rect = copy.deepcopy(self.in_progress_bbox) width = rect.width() height = rect.height() rect.setX(self.in_progress_bbox.x() * self.scale + self.xoff) rect.setY(self.in_progress_bbox.y() * self.scale + self.yoff) rect.setWidth(width * self.scale) rect.setHeight(height * self.scale) thickPen.setColor(QtGui.QColor(255,0,0)) thickPen.setWidth(3) qp.setPen(thickPen) qp.drawRect(rect) qp.restore() # Draw the polygon that is drawn and edited by the user # Usually the polygon must be rescaled properly. However when drawing # The polygon within the zoom, this is not needed. Therefore the option transform.
Example #20
Source File: cityscapesViewer.py From rec-attend-public with MIT License | 4 votes |
def drawLabelAtMouse(self, qp): # Nothing to do without a highlighted object if not self.highlightObj: return # Nothing to without a mouse position if not self.mousePosOrig: return # Save QPainter settings to stack qp.save() # That is the mouse positiong mouse = self.mousePosOrig # Will show zoom showZoom = self.zoom and not self.image.isNull() and self.w and self.h # The text that is written next to the mouse mouseText = self.highlightObj.label # Where to write the text # Depends on the zoom (additional offset to mouse to make space for zoom?) # The location in the image (if we are at the top we want to write below of the mouse) off = 36 if showZoom: off += self.zoomSize/2 if mouse.y()-off > self.toolbar.height(): top = mouse.y()-off btm = mouse.y() vAlign = QtCore.Qt.AlignTop else: # The height of the cursor if not showZoom: off += 20 top = mouse.y() btm = mouse.y()+off vAlign = QtCore.Qt.AlignBottom # Here we can draw rect = QtCore.QRect() rect.setTopLeft(QtCore.QPoint(mouse.x()-200,top)) rect.setBottomRight(QtCore.QPoint(mouse.x()+200,btm)) # The color qp.setPen(QtGui.QColor('white')) # The font to use font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold) qp.setFont(font) # Non-transparent qp.setOpacity(1) # Draw the text, horizontally centered qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText) # Restore settings qp.restore() # Draw the zoom
Example #21
Source File: cityscapesViewer.py From fcn8s_tensorflow with GNU General Public License v3.0 | 4 votes |
def drawLabelAtMouse(self, qp): # Nothing to do without a highlighted object if not self.highlightObj: return # Nothing to without a mouse position if not self.mousePosOrig: return # Save QPainter settings to stack qp.save() # That is the mouse positiong mouse = self.mousePosOrig # Will show zoom showZoom = self.zoom and not self.image.isNull() and self.w and self.h # The text that is written next to the mouse mouseText = self.highlightObj.label # Where to write the text # Depends on the zoom (additional offset to mouse to make space for zoom?) # The location in the image (if we are at the top we want to write below of the mouse) off = 36 if showZoom: off += self.zoomSize/2 if mouse.y()-off > self.toolbar.height(): top = mouse.y()-off btm = mouse.y() vAlign = QtCore.Qt.AlignTop else: # The height of the cursor if not showZoom: off += 20 top = mouse.y() btm = mouse.y()+off vAlign = QtCore.Qt.AlignBottom # Here we can draw rect = QtCore.QRect() rect.setTopLeft(QtCore.QPoint(mouse.x()-200,top)) rect.setBottomRight(QtCore.QPoint(mouse.x()+200,btm)) # The color qp.setPen(QtGui.QColor('white')) # The font to use font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold) qp.setFont(font) # Non-transparent qp.setOpacity(1) # Draw the text, horizontally centered qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText) # Restore settings qp.restore() # Draw the zoom
Example #22
Source File: cityscapesLabelTool.py From fcn8s_tensorflow with GNU General Public License v3.0 | 4 votes |
def drawLabelAtMouse(self, qp): # Nothing to do without a highlighted object if not self.highlightObjs: return # Also we do not want to draw the label, if we have a drawn polygon if not self.drawPoly.isEmpty(): return # Nothing to without a mouse position if not self.mousePos: return # Save QPainter settings to stack qp.save() # That is the mouse positiong mouse = self.mousePos # Will show zoom showZoom = self.config.zoom and not self.image.isNull() and self.w and self.h # The text that is written next to the mouse mouseText = self.highlightObjs[-1].label # Where to write the text # Depends on the zoom (additional offset to mouse to make space for zoom?) # The location in the image (if we are at the top we want to write below of the mouse) off = 36 if showZoom: off += self.config.zoomSize/2 if mouse.y()-off > self.toolbar.height(): top = mouse.y()-off btm = mouse.y() vAlign = QtCore.Qt.AlignTop else: # The height of the cursor if not showZoom: off += 20 top = mouse.y() btm = mouse.y()+off vAlign = QtCore.Qt.AlignBottom # Here we can draw rect = QtCore.QRect() rect.setTopLeft(QtCore.QPoint(mouse.x()-100,top)) rect.setBottomRight(QtCore.QPoint(mouse.x()+100,btm)) # The color qp.setPen(QtGui.QColor('white')) # The font to use font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold) qp.setFont(font) # Non-transparent qp.setOpacity(1) # Draw the text, horizontally centered qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText) # Restore settings qp.restore() # Draw the zoom