コード例 #1
0
    def paintEvent(self, event):
        img = self.image
        self.zoom = self.bZoom.isChecked()
        if img.width() > 256:
            self.zoom = False
            self.bZoom.setChecked(False)
        if self.zoom:
            img = self.image.scaledToWidth(self.image.width() * 2)
        painter = QPainter()
        painter.begin(self)

        painter.drawImage(self.image_frame.x(), self.image_frame.y(), img)

        i = 0
        for poly in self.polylist:
            if i + 1 == self.polylistindex:
                pen = QPen(Qt.red, 2)
            else:
                pen = QPen(Qt.black, 2)
            i = i + 1
            painter.setPen(pen)
            lastdp = None
            for qp in poly.vertices():
                qpz = copy.copy(qp)
                if self.zoom:
                    qpz.setX(qpz.x() * 2)
                    qpz.setY(qpz.y() * 2)

                adp = self.image_frame.mapToParent(qpz)
                if not lastdp is None:
                    painter.drawLine(lastdp, adp)
                lastdp = adp
        painter.end()
コード例 #2
0
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        pen = painter.pen()

        fontscale = float(self._scale)
        painter.setFont(scaledFont(self.valueFont, 0.9))
        h = self.props['height'] * fontscale
        w = self.props['width'] * fontscale
        elwidth = w / 20.
        elheight = h / 3

        pol_bits = self.props['polarizer']
        is_in = int(self._curval[0] << pol_bits | self._curval[7])
        is_out = int(self._curval[1] << pol_bits | self._curval[8])
        x = elwidth
        y = 2.5 * fontscale
        for i in range(18):
            painter.setPen(QPen(_black.color()))
            painter.setBrush(_grey)
            painter.drawRect(x, y, elwidth - 2, elheight)
            painter.setBrush(_blue)
            if is_in & (1 << (17 - i)):
                ely = 3
            elif is_out & (1 << (17 - i)):
                ely = 2 + elheight / 2
            else:
                ely = 2 + elheight / 4
            painter.drawRect(x + 3, y + ely, elwidth - 8, elheight / 3)
            if i >= 18 - pol_bits:
                painter.setPen(QPen(_white.color()))
                painter.drawText(x + 3, y + ely - 2, elwidth - 8,
                                 elheight / 3 + 2, Qt.AlignHCenter, 'POL')
                painter.setPen(QPen(_black.color()))
            painter.drawText(x, 3, elwidth, 2 * fontscale,
                             Qt.AlignRight | Qt.AlignTop, str(19 - i))
            x += elwidth
        painter.fillRect(0, y + elheight / 3 - 5, w, 3, _yellow)
        painter.setPen(pen)

        x = elwidth + 1
        y += elheight + 4

        slhw = 1.6 * elwidth
        for i, slitpos in enumerate([20, 14, 8, 4, 2]):
            slitw, slith = self._curval[2 + i]
            xmiddle = x + ((20 - slitpos) * elwidth)
            painter.drawLine(xmiddle, y, xmiddle, y + 15)
            painter.setBrush(_white)
            painter.drawRect(xmiddle - 0.5 * slhw, y + 15, slhw, slhw)
            painter.setBrush(collstatusbrush[self._curstatus[2 + i]])
            w = (50 - slitw) * slhw / 100
            h = (50 - slith) * slhw / 100
            painter.drawRect(xmiddle - 0.5 * slhw + w, y + 15 + h,
                             slhw - 2 * w, slhw - 2 * h)
            painter.drawText(xmiddle - 0.8 * elwidth, y + 15, slhw, slhw,
                             Qt.AlignCenter, '%.1f\n%.1f' % (slitw, slith))
コード例 #3
0
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        h = self._scale * 2.5 * self.props['height']
        w = self._scale * self.props['width']

        # cache pen
        pen = painter.pen()

        if self.props['name']:
            painter.setFont(self.font())
            if self._curstatus != OK:
                painter.fillRect(0, 0, w, self._scale * 2.5,
                                 statusbrush[self._curstatus])
            if self._fixed:
                painter.setPen(QPen(_blue.color()))
            else:
                painter.setPen(QPen(_black.color()))
            painter.drawText(0, 0, w, self._scale * 2.5, Qt.AlignCenter,
                             self.props['name'])
            painter.setPen(pen)
            yoff = self._scale * 2.5
        else:
            yoff = 0

        painter.setPen(QPen(_blue.color()))

        y = h * 0.5 + yoff
        painter.drawLine(0, y, w, y)
        painter.drawLine(0, y + 1, w, y + 1)
        painter.drawLine(0, y + 2, w, y + 2)

        # reset pen
        painter.setPen(pen)

        painter.setBrush(statusbrush[self._curstatus])
        if self._curstr in self.props['options']:
            self.shift = self.props['options'].index(self._curstr)
        if self._curstr in self.props['disabled_options']:
            self.shift = len(self.props['options'])

        painter.setFont(self.valueFont)

        h0 = max(2 * self._scale, 2 * self._scale + 4)
        painter.setClipRect(0, yoff, w, h)
        for i, t in enumerate(self.props['options']):
            y = h * 0.5 + yoff + h0 * (self.shift - i - 0.45)
            b = statusbrush[self._curstatus]
            if t == self._curstr:
                painter.setBrush(b)
            else:
                painter.setBrush(_grey if b == statusbrush[OK] else b)
            painter.drawRect(5, y + 2, w - 10, h0 - 4)
            painter.drawText(5, y + 2, w - 10, h0 - 4, Qt.AlignCenter, t)
コード例 #4
0
ファイル: beam.py プロジェクト: umithardal/nicos
 def __init__(self, fromObj, toObj, parent=None, scene=None):
     self._start = fromObj
     self._end = toObj
     QGraphicsLineItem.__init__(self, parent)
     self.setPen(QPen(QColor('white'), 4))
     self._beam = QGraphicsLineItem(parent)
     self._beam.setPen(QPen(QColor('blue'), 1))
     if not parent and scene:
         scene.addItem(self)
         scene.addItem(self._beam)
     self.update()
     self.setZValue(50)
     self._beam.setZValue(51)
コード例 #5
0
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        painter.setPen(QPen(_black.color()))
        painter.setBrush(_grey)

        fontscale = float(self._scale)
        h = self.props['height'] * fontscale
        w = self.props['width'] * fontscale
        painter.drawRect(2, 10, w - 4, h / 2)

        is_in = int(self._curval[0])
        is_out = int(self._curval[1])
        lensheight = h / 2 - 25
        lensw = w / 32
        for (i, n, x) in [(0, 4, 0), (1, 6, 6), (2, 16, 14)]:
            if is_in & (1 << i):
                lensy = 22
            elif is_out & (1 << i):
                lensy = h / 2 + 20
            else:
                lensy = h / 4 + 22
            for j in range(n):
                painter.drawRect((1 + x + j) * lensw, lensy, lensw + 1,
                                 lensheight)
コード例 #6
0
    def _select_item(self, item):
        """Select the given item by drawing a colored circle beneath the
        selected item (so it looks like a ring around it.
        Also emits the timepointSelected signal."""

        # The selection_item used to signal the selection of a timepoint
        # is always the same and is only moved.
        if self._selection_item is None:
            self._selection_item = QGraphicsEllipseItem(
                0, 0, self.SELECTION_DIAMETER, self.SELECTION_DIAMETER)

            # The used color is a cubical to the time point color
            self._selection_item.setBrush(QBrush(QColor(0x70, 0xbb, 0x00)))
            self._selection_item.setPen(QPen(0))
            self.scene().addItem(self._selection_item)

        # center position of the timepoint circle
        center_x = item.pos().x() + self.TIMEPOINT_DIAMETER / 2
        center_y = item.pos().y() + self.TIMEPOINT_DIAMETER / 2

        # move selection item
        self._selection_item.setPos(center_x - self.SELECTION_DIAMETER / 2,
                                    center_y - self.SELECTION_DIAMETER / 2)

        # store the selection_item like a timepoint item (using the timepoint
        # of the selected item)
        self._time_point_items[self._selection_item] = \
            self._time_point_items[item]

        # emit signal at the end to ensure a valid internal state before
        # anything can react to it
        self.timepointSelected.emit(self._time_point_items[item])
コード例 #7
0
    def _add_timeline(self):
        """Draw the timeline."""

        # height is either the necessary space to display all items or the
        # maximal available display size, so it's looks nicely in larger
        # windows and enables scrolling in smaller ones.
        height = self.TIMEPOINT_DIAMETER * len(self._time_points)
        height += self.TIMEPOINT_SPACING * len(self._time_points)
        height = max(height, self.viewport().height())

        # draw the timeline left aligned with enough space to draw the items
        # and the selection ring.
        x = self.MARGIN_HORIZONTAL + (self.SELECTION_DIAMETER / 2)

        # position the line on the left side of the item
        item = QGraphicsLineItem(0, 0, 0, height)

        # The used color for the timeline is the lightest one of the FRM II
        # colors
        item.setPen(QPen(QBrush(QColor(0xa3, 0xc1, 0xe7)),
                         self.TIMELINE_WIDTH))

        self.scene().addItem(item)

        # move the whole item to the desired timeline position
        item.setPos(x, 0)
        return item
コード例 #8
0
    def _add_time_point(self, center_x, center_y, time_point):
        """Add a single time point item."""
        x = center_x - (self.TIMEPOINT_DIAMETER / 2)
        y = center_y - (self.TIMEPOINT_DIAMETER / 2)

        # Create the acutal time point item
        time_point_item = QGraphicsEllipseItem(0, 0, self.TIMEPOINT_DIAMETER,
                                               self.TIMEPOINT_DIAMETER)

        # The used color is the strongest one of the FRM II colors.
        time_point_item.setBrush(QBrush(QColor(0x00, 0x71, 0xbb)))
        time_point_item.setPen(QPen(0))

        self.scene().addItem(time_point_item)
        time_point_item.setPos(x, y)

        # place the time point item above the timeline and the selection item
        time_point_item.setZValue(2)

        # Create the label of the time point showing the time in the
        # defined strftime format on the right side of the time point item.
        label = QGraphicsTextItem(time_point.strftime(self.STRFTIME_FMT))
        label.setFont(QFont('Monospace'))
        label_height = label.boundingRect().height()

        # minor height adjustment
        label_y = y - label_height / 6

        self.scene().addItem(label)
        label.setPos(x + self.SELECTION_DIAMETER + self.LABEL_SPACING, label_y)

        # store references to the item and the timepoint in the same dict
        # to be able to use it for forward and reverse lookup
        self._time_point_items[time_point] = time_point_item
        self._time_point_items[time_point_item] = time_point
コード例 #9
0
 def __init__(self, x, y, size=10, parent=None, scene=None):
     TableBase.__init__(self, x, y, size, parent, scene)
     sz = size / 2
     self._crystal = QGraphicsLineItem(-sz, 0, sz, 0, self)
     if not self._pencolor:
         self._pencolor = QColor('black')
     self._crystal.setPen(QPen(self._pencolor, 3))
     self._crystal.setZValue(100)
コード例 #10
0
ファイル: tube.py プロジェクト: umithardal/nicos
 def __init__(self, width=10, parent=None, scene=None):
     QGraphicsPathItem.__init__(self, parent)
     self._width = width
     self.setPath(self.shape())
     if not parent and scene:
         scene.addItem(self)
     self.setBrush(QBrush(statuscolor[status.OK]))
     self.setPen(QPen(statuscolor[status.OK], width))
コード例 #11
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        NicosWidget.__init__(self)

        self.p_black = QPen(QColor('black'))
        self.p_red = QPen(QColor('red'))

        self.br_back = QBrush(QColor(190, 190, 190))
        self.br_empty = QBrush(QColor(255, 255, 255))

        self.col_led = [QColor(0, 0, 255), QColor(255, 255, 0)]
        self.br_led = [QBrush(self.col_led[0]), QBrush(self.col_led[1])]
        self.br_seg = QBrush(QColor(211, 211, 211))

        self.devs = ['diagnostics/value', 'diag_switches/value',
                     'mb_arm_raw/value', 'mtt_raw/value', 'n_blocks_cw/value']
        self.values = [0, 0, 0, 0, 0]
コード例 #12
0
ファイル: dettable.py プロジェクト: ess-dmsc/nicos
 def __init__(self, x, y, size=20, parent=None, scene=None):
     TableBase.__init__(self, x, y, size, parent, scene)
     self._halowidth = max(size / 4, 10)
     self._halo = Halo(x, y, size, self._halowidth, self, scene)
     self._tuberadius = size / 5
     p = QPointF(self._tuberadius, self._tuberadius)
     s = QSizeF(2 * self._tuberadius, 2 * self._tuberadius)
     self._tube = QGraphicsEllipseItem(QRectF(-p, s), self)
     self._tube.setPen(QPen(QColor('black'), 3))
     self._tube.setBrush(QBrush(QColor('white')))
     self._tube.setZValue(20)
コード例 #13
0
    def __init__(self, parent):
        QMainWindow.__init__(self, parent)
        DlgUtils.__init__(self, 'Live data')
        self.panel = parent
        layout1 = QVBoxLayout()
        self.plot = QwtPlot(self)
        layout1.addWidget(self.plot)
        self.curve = QwtPlotCurve()
        self.curve.setRenderHint(QwtPlotCurve.RenderAntialiased)
        self.curve.attach(self.plot)
        self.marker = QwtPlotMarker()
        self.marker.attach(self.plot)
        self.markerpen = QPen(Qt.red)
        self.marker.setSymbol(
            QwtSymbol(QwtSymbol.Ellipse, QBrush(), self.markerpen, QSize(7,
                                                                         7)))
        self.zoomer = QwtPlotZoomer(self.plot.canvas())
        self.zoomer.setMousePattern(QwtPlotZoomer.MouseSelect3, Qt.NoButton)
        self.picker = QwtPlotPicker(self.plot.canvas())
        self.picker.setSelectionFlags(QwtPlotPicker.PointSelection
                                      | QwtPlotPicker.ClickSelection)
        self.picker.setMousePattern(QwtPlotPicker.MouseSelect1, Qt.MidButton)
        self.picker.selected.connect(self.pickerSelected)
        layout2 = QHBoxLayout()
        layout2.addWidget(QLabel('Scale:', self))
        self.scale = QComboBox(self)
        self.scale.addItems([
            'Single detectors, sorted by angle',
            'Scattering angle 2theta (deg)', 'Q value (A-1)'
        ])
        self.scale.currentIndexChanged[int].connect(self.scaleChanged)
        layout2.addWidget(self.scale)
        layout2.addStretch()
        self.scaleframe = QFrame(self)
        self.scaleframe.setLayout(layout2)
        self.scaleframe.setVisible(False)
        layout1.addWidget(self.scaleframe)
        mainframe = QFrame(self)
        mainframe.setLayout(layout1)
        self.setCentralWidget(mainframe)
        self.setContentsMargins(6, 6, 6, 6)
        plotfont = scaledFont(self.font(), 0.7)
        self.plot.setAxisFont(QwtPlot.xBottom, plotfont)
        self.plot.setAxisFont(QwtPlot.yLeft, plotfont)
        self.plot.setCanvasBackground(Qt.white)
        self.resize(800, 200)

        self._detinfo = None
        self._anglemap = None
        self._infowindow = None
        self._infolabel = None
        self._xs = self._ys = None
        self._type = None
コード例 #14
0
ファイル: detector.py プロジェクト: umithardal/nicos
 def __init__(self, width, parent=None, scene=None):
     w = width + 2
     if parent and isinstance(parent, QGraphicsRectItem):
         rect = parent.rect()
         size = rect.size()
         size += QSizeF(w, w)
         rect.setSize(size)
     else:
         rect = QRectF()
     QGraphicsRectItem.__init__(self, rect, parent)
     transform = QTransform()
     transform.translate(-w / 2, -w / 2)
     self.setTransform(transform)
     self.setBrush(QBrush(statuscolor[status.OK]))
     self.setPen(QPen(statuscolor[status.OK], width))
コード例 #15
0
ファイル: sample.py プロジェクト: ess-dmsc/nicos
 def __init__(self, x, y, size=20, parent=None, scene=None):
     if parent:
         self._color = parent._color
     TableBase.__init__(self, x, y, size, parent, scene)
     if not self._pencolor:
         self._pencolor = QColor('#666666')
     self._pen = QPen(self._pencolor, 1)
     self._pen.setBrush(QBrush(self._pencolor))
     sz = size / 3
     self._polygon = QGraphicsRectItem(
         QRectF(-QPointF(sz, sz), QPointF(sz, sz)), self)
     self._polygon.setBrush(QBrush(self._pencolor))
     self._l1 = QGraphicsLineItem(-size, 0, size, 0, self)
     self._l1.setPen(self._pen)
     self._l2 = QGraphicsLineItem(0, -size, 0, size, self)
     self._l2.setPen(self._pen)
コード例 #16
0
ファイル: editor.py プロジェクト: ess-dmsc/nicos
        def formatPage(self, painter, drawing, area, pagenr):
            QsciPrinter.formatPage(self, painter, drawing, area, pagenr)

            fn = self.docName()
            header = 'File: %s    page %s    %s' % \
                     (fn, pagenr, time.strftime('%Y-%m-%d %H:%M'))
            painter.save()
            pen = QPen(QColor(30, 30, 30))
            pen.setWidth(1)
            painter.setPen(pen)
            newTop = area.top() + painter.fontMetrics().height() + 15
            area.setLeft(area.left() + 30)
            if drawing:
                painter.drawText(area.left(),
                                 area.top() + painter.fontMetrics().ascent(),
                                 header)
                painter.drawLine(area.left() - 2, newTop - 12,
                                 area.right() + 2, newTop - 12)
            area.setTop(newTop)
            painter.restore()
コード例 #17
0
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        fontscale = float(self._scale)
        ww = self.props['width'] * fontscale - 4
        wh = self.props['height'] * fontscale - 4
        sx, sy = self.props['maxw'], self.props['maxh']

        if self._opmode == 'offcentered':
            dx, dy, w, h = self._curval
            x0, x1, y0, y1 = dx - w / 2., dx + w / 2., dy - h / 2., dy + h / 2.
            l1, l2, l3, l4 = '(%.1f, %.1f)' % (dx, dy), '%.1f x %.1f' % (
                w, h), '', ''
        elif self._opmode == 'centered':
            w, h = self._curval
            x0, x1, y0, y1 = -w / 2., w / 2., -h / 2., h / 2.
            l1, l2, l3, l4 = '', '%.1f x %.1f' % (w, h), '', ''
        elif self._opmode.startswith('4blades'):
            x0, x1, y0, y1 = self._curval
            l1, l2, l3, l4 = '%.1f' % y1, '%.1f' % y0, '%.1f' % x0, '%.1f' % x1
            if self._opmode.endswith('opposite'):
                x0 *= -1
                y0 *= -1

        x0 = (x0 + sx / 2) / sx * ww
        x1 = (x1 + sx / 2) / sx * ww
        y0 = wh - (y0 + sy / 2) / sy * wh
        y1 = wh - (y1 + sy / 2) / sy * wh

        painter.setPen(QPen(_black.color()))
        painter.setBrush(_white)
        painter.drawRect(2, 2, ww, wh)
        painter.setBrush(collstatusbrush[self._curstatus])
        painter.drawRect(2 + x0, 2 + y1, x1 - x0, y0 - y1)

        painter.setFont(scaledFont(self.valueFont, 0.8))
        painter.drawText(2, 2, ww, wh, Qt.AlignTop | Qt.AlignHCenter, l1)
        painter.drawText(2, 2, ww, wh, Qt.AlignBottom | Qt.AlignHCenter, l2)
        painter.drawText(2, 2, ww, wh, Qt.AlignVCenter | Qt.AlignLeft, l3)
        painter.drawText(2, 2, ww, wh, Qt.AlignVCenter | Qt.AlignRight, l4)
コード例 #18
0
 def __init__(self, offset, view):
     QStyledItemDelegate.__init__(self, view)
     self._icon_offset = offset
     self._margin_offset = 0
     self._pen = QPen(QBrush(QColor('grey')), 1)
コード例 #19
0
ファイル: halo.py プロジェクト: umithardal/nicos
 def setState(self, state):
     self.setPen(QPen(statuscolor[state], self._width))
     self.update()
コード例 #20
0
ファイル: monitorwidgets.py プロジェクト: umithardal/nicos
from nicos.core.status import OK
from nicos.guisupport.qt import QBrush, QColor, QPainter, QPen, QPointF, \
    QPolygonF, QSize, Qt, QWidget
from nicos.guisupport.widget import NicosWidget, PropDef
from nicos.utils import readonlylist

from nicos_mlz.refsans.gui.refsansview import RefsansView
from nicos_mlz.refsans.gui.timedistancewidget import TimeDistanceWidget
from nicos_mlz.sans1.gui.monitorwidgets import CollimatorTable

_yellow = QBrush(QColor('yellow'))
_white = QBrush(QColor('white'))
_red = QBrush(QColor('#FF3333'))
_nobrush = QBrush()

nopen = QPen(QColor('white'))
defaultpen = QPen(QColor('black'))
beampen = QPen(QColor('blue'))
monopen = QPen(QColor('black'))
monopen.setWidth(3)
beambackgroundpen = QPen(QColor('white'))
beambackgroundpen.setWidth(4)
samplepen = QPen(QColor('#006600'))
samplepen.setWidth(2)
samplebrush = QBrush(QColor('#006600'))
samplecoordpen = QPen(QColor('#666666'))
targetpen = QPen(QColor('black'))
targetpen.setStyle(Qt.DashLine)

monotablebrush = QBrush(QColor('#6666ff'))
sampletablebrush = QBrush(QColor('#66ff66'))
コード例 #21
0
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setBrush(QBrush(self.color))
        painter.setRenderHint(QPainter.Antialiasing)

        fontscale = float(self._scale)
        h = self.props['height'] * fontscale
        w = self.props['width'] * fontscale
        posscale = (w - 100) / self.props['posscale']

        # Draw name above tube
        if self.props['name']:
            painter.setFont(self.font())
            painter.drawText(5, 0, w, fontscale * 2.5, Qt.AlignCenter,
                             self.props['name'])
            yoff = fontscale * 2.5
        elif self.props['smalldet']:
            yoff = 50
        else:
            yoff = 0

        # Draw tube
        painter.setPen(self.color)
        painter.drawEllipse(5, 5 + yoff, 50, h)
        painter.drawRect(30, 5 + yoff, w - 50, h)
        painter.setPen(QColor('black'))
        painter.drawArc(5, 5 + yoff, 50, h, 1440, 2880)
        painter.drawLine(30, 5 + yoff, w - 25, 5 + yoff)
        painter.drawLine(30, 5 + yoff + h, w - 25, 5 + yoff + h)
        painter.drawEllipse(w - 45, 5 + yoff, 50, h)

        if self.props['smalldet']:
            sw = 20
            sx = 30 + self.props['smalldet'] * posscale
            painter.setPen(self.color)
            painter.drawRect(sx - sw, 2, 2 * sw, yoff + 10)
            painter.setPen(QColor('black'))
            painter.drawLine(sx - sw, 5 + yoff, sx - sw, 2)
            painter.drawLine(sx - sw, 2, sx + sw, 2)
            painter.drawLine(sx + sw, 2, sx + sw, 5 + yoff)

        # draw detector
        pos_val = self._curval[0]
        if pos_val is not None:
            pos_status = self._curstatus[0]
            pos_str = self._curstr[0]
            x_val = self._curval[1]
            x_status = self._curstatus[1]
            x_str = '%.1f x' % x_val
            y_val = self._curval[2]
            y_status = self._curstatus[2]
            y_str = '%.1f y' % y_val

            stat = max(pos_status, x_status, y_status)
            painter.setBrush(statusbrush[stat])
            painter.setFont(self.valueFont)
            painter.resetTransform()
            # Translate to detector position
            xp = 30 + pos_val * posscale
            painter.translate(xp + fontscale / 2., 15 + yoff + (h - 20) / 2.)
            painter.drawRect(-fontscale / 2., -(h - 20) / 2., fontscale,
                             h - 20)
            painter.resetTransform()
            # Put X/Y values left or right of detector depending on position
            if pos_val < 14:
                xoff = 2 * fontscale
            else:
                xoff = -8.5 * fontscale
            # X translation
            painter.drawText(xp + xoff, yoff + 2 * fontscale, 7 * fontscale,
                             2 * fontscale, Qt.AlignRight, x_str)
            # Y translation
            painter.drawText(xp + xoff, yoff + 3.5 * fontscale, 7 * fontscale,
                             2 * fontscale, Qt.AlignRight, y_str)
            # Z position
            minx = max(0, xp + 5 - 4 * fontscale)
            painter.drawText(minx, h + 10 + yoff, 8 * fontscale, 30,
                             Qt.AlignCenter, pos_str)

            # draw beamstop
            if self.props['beamstop']:
                painter.setPen(QPen(_blue.color()))
                painter.drawRect(xp - 8,
                                 yoff + 15 + posscale / 350 * (1100 - y_val),
                                 2, 10)

        # draw small detector
        if self.props['smalldet'] and self._curval[4] is not None:
            x_status = self._curstatus[3]
            x_str = '%4.1f x' % self._curval[3]
            y_status = self._curstatus[4]
            y_val = self._curval[4]
            y_str = '%4.0f y' % y_val
            stat = max(x_status, y_status)

            painter.setBrush(statusbrush[stat])
            painter.setPen(QPen(_black.color()))
            painter.setFont(self.valueFont)
            sy = 10 + y_val * posscale / 250
            painter.drawRect(sx - fontscale / 2., sy, fontscale, 30)

            painter.drawText(sx - 10.5 * fontscale, sy, 8 * fontscale,
                             2 * fontscale, Qt.AlignRight, x_str)
            painter.drawText(sx - 10.5 * fontscale, sy + 1.5 * fontscale,
                             8 * fontscale, 2 * fontscale, Qt.AlignRight,
                             y_str)
コード例 #22
0
 def __init__(self, parent=None, scene=None):
     QGraphicsPathItem.__init__(self, parent)
     self.setPath(self.shape())
     if not parent and scene:
         scene.addItem(self)
     self.setPen(QPen(QColor('darkblue')))
コード例 #23
0
 def __init__(self, x, y, size=50, parent=None, scene=None):
     TableBase.__init__(self, x, y, size, parent, scene)
     self.setBrush(QBrush())
     pen = QPen(QColor('black'))
     pen.setStyle(Qt.DashLine)
     self.setPen(pen)