def _get_brush(self, color): """Get brush associated to a color.""" if isinstance(color, list) or isinstance(color, tuple): q_color = QtGui.QColor(*color) else: q_color = QtGui.QColor(color) return QtGui.QBrush(q_color)
def __init__(self, *args, **kwargs): super(QtViewer3d, self).__init__(*args, **kwargs) self._lock_rotation = False self._lock_zoom = False self._drawbox = None self._zoom_area = False self._select_area = False self._inited = False self._leftisdown = False self._middleisdown = False self._rightisdown = False self._selection = None self._drawtext = True self._select_pen = QtGui.QPen(QtGui.QColor(0, 0, 0), 2) self._callbacks = { 'key_pressed': [], 'mouse_dragged': [], 'mouse_scrolled': [], 'mouse_moved': [], 'mouse_pressed': [], 'mouse_released': [], } self.proxy = None self._last_code = None # enable Mouse Tracking self.setMouseTracking(True) # Strong focus self.setFocusPolicy(Qt.WheelFocus) # required for overpainting the widget self.setAttribute(Qt.WA_PaintOnScreen) self.setAttribute(Qt.WA_NoSystemBackground) self.setAutoFillBackground(False)
def _get_color(self, color): """ Returns a QColor built from a Pygments color string. """ qcolor = QtGui.QColor() qcolor.setRgb(int(color[:2], base=16), int(color[2:4], base=16), int(color[4:6], base=16)) return qcolor
def paintEvent(self, event): if self._inited: self._display.Context.UpdateCurrentViewer() # important to allow overpainting of the OCC OpenGL context in Qt self.swapBuffers() if self._drawbox: self.makeCurrent() painter = QtGui.QPainter(self) painter.setPen(QtGui.QPen(QtGui.QColor(0, 0, 0), 1)) rect = QtCore.QRect(*self._drawbox) painter.drawRect(rect) painter.end() self.doneCurrent()
def _get_brush(self, color): if isinstance(color, list) or isinstance(color, tuple): q_color = QtGui.QColor(*color) else: q_color = QtGui.QColor(color) return QtGui.QBrush(q_color)