示例#1
0
 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)
示例#2
0
    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
示例#4
0
    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()
示例#5
0
 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)