Пример #1
0
    def paintEvent(self, ev):
        if self.isEnabled():
            color = self.color
            colorBorder = [0.4, 0.4, 0.4]
        else:
            color = [0.8, 0.8, 0.8]
            colorBorder = [0.7, 0.7, 0.7]

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setRenderHint(QPainter.HighQualityAntialiasing)

        if self.isChecked():
            pen = QPen(QColor.fromRgbF(0.2, 0.2, 0.2))
            pen.setWidth(2.0)
        else:
            pen = QPen(
                QColor.fromRgbF(colorBorder[0], colorBorder[1],
                                colorBorder[2]))
            pen.setWidth(1.0)

        size = self.size()
        sizeCircle = 12.0
        x = size.width() / 2.0 - (sizeCircle / 2.0)
        y = size.height() / 2.0 - (sizeCircle / 2.0)
        rect = QRectF(x, y, sizeCircle, sizeCircle)
        painter.setPen(pen)
        painter.setBrush(QColor.fromRgbF(color[0], color[1], color[2]))
        painter.drawEllipse(rect)
	def paintEvent(self, ev):
		if self.isEnabled():
			color = self.color
			colorBorder = [0.4, 0.4, 0.4]
		else:
			color = [0.8, 0.8, 0.8]
			colorBorder = [0.7, 0.7, 0.7]

		painter = QPainter(self)
		painter.setRenderHint(QPainter.Antialiasing)
		painter.setRenderHint(QPainter.HighQualityAntialiasing)

		if self.isChecked():
			pen = QPen(QColor.fromRgbF(0.2, 0.2, 0.2))
			pen.setWidth(2.0)
		else:
			pen = QPen(QColor.fromRgbF(colorBorder[0], colorBorder[1], colorBorder[2]))
			pen.setWidth(1.0)

		size = self.size()
		sizeCircle = 12.0
		x = size.width() / 2.0 - (sizeCircle / 2.0)
		y = size.height() / 2.0 - (sizeCircle / 2.0)
		rect = QRectF(x, y, sizeCircle, sizeCircle)
		painter.setPen(pen)
		painter.setBrush(QColor.fromRgbF(color[0], color[1], color[2]))
		painter.drawEllipse(rect)
Пример #3
0
 def loadContour(self, contourData):
     logging.debug("In CPRAction::loadContour()")
     scenes = self._ilsa.scenes()
     contour = CPRContour(scenes, self._ilsa, self.cprClosed)
     for scene in scenes:
         if contourData["sceneId"] == scene.id:
             contour.scene = scene
         elif contourData["panoramicSceneId"] == scene.id:
             contour.setPanoramicPlane(scene.parent)
         elif contourData["transversalSceneId"] == scene.id:
             contour.setTransversalPlane(scene.parent)
     self.propertiesAction.addContour(contour)
     
     contour.loadPoints(contourData["points"])
         
     lc = contourData["lineColor"]
     alc = contourData["actualLineColor"]
     ts = contourData["transversalSize"]
     lineColor = QColor.fromRgbF(lc[0], lc[1], lc[2])
     actualLineColor = QColor.fromRgbF(alc[0], alc[1], alc[2])
     self.propertiesAction.changeLineColor(lineColor)
     self.propertiesAction.changeActualLineColor(actualLineColor)
     contour.setTransversalSize(ts)
     self.propertiesAction.slotActionVisible(contourData["visible"])
     self.propertiesAction.slotActionLock(contourData["locked"])
     self.propertiesAction.lock.setChecked(contourData["locked"])
Пример #4
0
    def __init__(self, *args):
        super(ColorPickerWidget, self).__init__(*args)
        self.updating = False
        self.updatingAlpha = False
        self.ui = UI()
        self.ui.setupUi(self)

        self.setWindowFlags(Qt.Popup)

        self.preview = ColorPreviewWidget(self.ui.containerPreview)
        self.hueSlider = HueSliderWidget(self.ui.containerHueSlider)
        self.alphaSlider = AlphaSliderWidget(self.ui.containerAlphaSlider)

        self.colorPlane = ColorPlaneWidget(self.ui.containerColorPlane)

        self.hueSlider.valueChanged.connect(self.onHueChanged)
        self.alphaSlider.valueChanged.connect(self.onAlphaSliderChanged)
        self.colorPlane.valueChanged.connect(self.onColorBaseChanged)

        self.ui.buttonOK.clicked.connect(self.onButtonOK)
        self.ui.buttonCancel.clicked.connect(self.onButtonCancel)
        self.ui.buttonCopyHEX.clicked.connect(self.onButtonCopyHEX)
        self.ui.buttonCopyRGB.clicked.connect(self.onButtonCopyRGBA)
        self.ui.buttonCopyHSV.clicked.connect(self.onButtonCopyHSV)

        self.ui.buttonScreenPick.clicked.connect(self.onButtonScreenPick)

        self.ui.numR.valueChanged.connect(self.onTextRGBChanged)
        self.ui.numG.valueChanged.connect(self.onTextRGBChanged)
        self.ui.numB.valueChanged.connect(self.onTextRGBChanged)

        self.ui.numH.valueChanged.connect(self.onTextHSVChanged)
        self.ui.numS.valueChanged.connect(self.onTextHSVChanged)
        self.ui.numV.valueChanged.connect(self.onTextHSVChanged)

        self.ui.textHex.textChanged.connect(self.onTextHexChanged)

        self.ui.numA.valueChanged.connect(self.onAlphaSliderChanged)

        self.originalColor = QColor.fromRgbF(0.0, 0.0, 0.0)
        self.currentColor = QColor.fromRgbF(1.0, 1.0, 0.0)

        self.preview.setColor(self.currentColor)
        self.preview.setOriginalColor(self.originalColor)

        self.updateAlphaWidgets()
        self.updateTextWidgets()
        self.updateColorPlane()
Пример #5
0
    def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setPen(Qt.NoPen)
        w = self.width()
        h = self.height()
        painter.setBrush(self.originalColor)
        painter.drawRect(0, 0, w, h / 2)
        cSolid = QColor(self.previewColor)
        cSolid.setAlphaF(1)
        #left 1/2 for solid color
        painter.setBrush(cSolid)
        painter.drawRect(0, h / 2, w / 2, h / 2 + 1)
        #draw chekerGrid
        x0 = w / 2
        y0 = h / 2
        w2 = w / 2
        h2 = h / 2
        painter.setBrush(Qt.white)
        painter.drawRect(x0, y0, w2, h2)
        painter.setBrush(QColor.fromRgbF(0.5, 0.5, 0.5))
        for y in range(4):
            for x in range(w2 / 10):
                if (x % 2) == (y % 2):
                    painter.drawRect(x0 + x * 10, y0 + y * 10, 10, 10)

        #right 2/3 for color with alpha
        painter.setBrush(self.previewColor)
        painter.drawRect(x0, y0, w2 + 1, h2 + 1)
 def __init__(self, size, dynamic, controller):
     layer.__init__(self,size,dynamic)
     self.controller = controller
     self.ready = False
     
     dotColor = QColor()
     dotColor.setNamedColor(self.controller.svgLayer.svg.dotPrototype.getAttribute('fill'))
     dotColor.setAlphaF(float(self.controller.svgLayer.svg.dotPrototype.getAttribute('fill-opacity')))
     self.dotColors = []
     i = 0
     while i <= 1.0:
         self.dotColors.append(QColor.fromRgbF(dotColor.redF(),dotColor.greenF(),dotColor.blueF(),i))
         i += dotColor.alphaF()
     
     self.dotWidth = self.controller.svgLayer.svg.dotPrototype.width()
     self.dotHeight = self.controller.svgLayer.svg.dotPrototype.height()
     
     self.halfDotWidth = self.dotWidth/2
     self.halfDotHeight = self.dotHeight/2
     
     self.xoffset = self.controller.scatterBounds[0]-self.halfDotWidth
     self.yoffset = self.controller.scatterBounds[3]-self.halfDotHeight
     
     self.xNonNumeric = (self.controller.svgLayer.svg.xNonNumericIcon.left() + self.controller.svgLayer.svg.xNonNumericIcon.right())/2 - self.halfDotWidth
     self.yNonNumeric = (self.controller.svgLayer.svg.yNonNumericIcon.top() + self.controller.svgLayer.svg.yNonNumericIcon.bottom())/2 - self.halfDotHeight
Пример #7
0
    def loadContour(self, contourData):
        logging.debug("In MarkAction::loadContour()")
        scenes = self._ilsa.scenes()
        replyList = []

        for scene in scenes:
            if isinstance(scene, VtkMultiSliceImagePlane):
                contour = MultiSliceContour(scene)
            else:
                contour = Contour(scene)
            replyList.append(contour)

        self.propertiesAction.addContour(replyList[0])

        for i, scene in enumerate(scenes):
            a = replyList[:]
            b = a.pop(i)
            b.replyList = a

        contour.loadPoints(contourData["points"])

        lc = contourData["lineColor"]
        lineColor = QColor.fromRgbF(lc[0], lc[1], lc[2])
        self.propertiesAction.changeLineColor(lineColor)
        self.propertiesAction.slotActionVisible(contourData["visible"])
        self.propertiesAction.slotActionLock(contourData["locked"])
        self.propertiesAction.lock.setChecked(contourData["locked"])
        self.propertiesAction.slotThicknessChanged(contourData["radius"])
Пример #8
0
 def paintEvent(self, event):
     painter = QtGui.QPainter(self)
     color = QColor.fromRgbF(0, 0, 0)
     # color.setAlphaF( 0.5 )
     painter.setPen(Qt.NoPen)
     painter.setBrush(color)
     painter.drawRect(event.rect())
Пример #9
0
 def test_filter_list_item_has_icon(self):
     file_names = [os.path.abspath('hi.txt')]
     color = QColor.fromRgbF(.5, .6, .4, .34)
     item = FilterListItem(file_names, color=color)
     icon = item.icon()
     self.assertIsNotNone(icon)
     self.assertFalse(icon.isNull())
Пример #10
0
 def test_filter_list_item_has_icon(self):
     file_names = [os.path.abspath('hi.txt')]
     color = QColor.fromRgbF(.5, .6, .4, .34)
     item = FilterListItem(file_names, color=color)
     icon = item.icon()
     self.assertIsNotNone(icon)
     self.assertFalse(icon.isNull())
Пример #11
0
 def onTextRGBChanged(self, value):
     if self.updating: return
     r = self.ui.numR.value()
     g = self.ui.numG.value()
     b = self.ui.numB.value()
     color = QColor.fromRgbF(r, g, b)
     color.setAlphaF(self.currentColor.alphaF())
     self.setColor(color)
     self.updateColorPlane()
Пример #12
0
 def _add_field(self, param, value):
     """Add a field to the task panel."""
     name = param.name
     if param.type == "float":
         widget = QLineEdit()
         widget.setAlignment(Qt.AlignRight)
         widget.setValidator(QDoubleValidator())
         try:
             value = QLocale().toString(float(value))
         except (ValueError, TypeError):
             value = None
         widget.setText(value)
         self.fields.append(
             (name, lambda: QLocale().toDouble(widget.text())[0]))
     elif param.type == "RGB":
         if value:
             parsedvalue = parse_csv_str(value)
             if "Object" not in parsedvalue:
                 color = str2rgb(parsedvalue[0])
                 use_object_color = False
             else:
                 use_object_color = True
                 if len(parsedvalue) > 1:
                     color = str2rgb(parsedvalue[1])
                 else:
                     color = (0.8, 0.8, 0.8)
             qcolor = QColor.fromRgbF(*color)
             widget = ColorPickerExt(qcolor, use_object_color)
         else:
             widget = ColorPickerExt()
         self.fields.append((name, widget.get_value))
     else:
         widget = QLineEdit()
         self.fields.append((name, widget.text))
     widget.setToolTip(param.desc)
     layout = self.form.findChild(QLayout, "FieldsLayout")
     layout.addRow(f"{param.name}:", widget)
Пример #13
0
 def testReduceRGB(self):
     self.reduceColor(QColor.fromRgbF(0.1, 0.2, 0.3, 0.4))
Пример #14
0
 def test_filter_list_item_color(self):
     file_names = [os.path.abspath('hi.txt')]
     color = QColor.fromRgbF(1., 1., 1., 1.)
     item = FilterListItem(file_names, color=color)
     color_check = item.get_params()['color']
     self.assertEqual(color, color_check)
Пример #15
0
 def setUp(self):
     self.original = QColor.fromRgbF(0.2, 0.3, 0.4, 0.5)
Пример #16
0
 def testReduceRGB(self):
     self.reduceColor(QColor.fromRgbF(0.1, 0.2, 0.3, 0.4))
 def updateColor(self, color):
     self._brushNormal.setColor(
         QColor.fromRgbF(color[0], color[1], color[2]))
     self._brushHighlighted.setColor(
         QColor.fromRgbF(color[0], color[1], color[2]))
     self.update(self.rect())
Пример #18
0
    def paintEvent(self, event):
        # print self.height()

        s = (self.target_angle - self.angle) * 0.09

        self.angle += s
        if math.fabs(self.angle - self.target_angle) < 0.001:
            self.angle = self.target_angle
            self.timer.stop()

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        qp = QPainterPath()

        width = min(self.height(), (self.width() / 2))
        height = self.height()

        # center
        x = self.width() / 2

        big_radius = 1000
        y = big_radius + 10
        small_radius = big_radius - 15

        ac = math.atan(float(self.width()) / 2.0 /
                       float(big_radius)) / math.pi * 180.0 * 0.95

        qp.arcMoveTo(x - big_radius, y - big_radius, 2 * big_radius,
                     2 * big_radius, 90 - ac)
        qp.arcTo(x - big_radius, y - big_radius, 2 * big_radius,
                 2 * big_radius, 90 - ac, 2 * ac)
        qp.arcTo(x - small_radius, y - small_radius, 2 * small_radius,
                 2 * small_radius, 90 + ac, -2 * ac)
        qp.arcTo(x - big_radius, y - big_radius, 2 * big_radius,
                 2 * big_radius, 90 - ac, 0)
        # qp.lineTo(x+big_radius,y)

        grange = ac * 2.0 / 360.0

        # Centered on 0, starting at angle 90-ac, counterclockwise
        self.gradient = QConicalGradient(0, 0, 90 - ac - 1)

        if self.gradient_type == 1:
            self.gradient.setColorAt(0, Qt.GlobalColor.red)
            self.gradient.setColorAt(0.1, Qt.GlobalColor.yellow)
            self.gradient.setColorAt(0.2, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.5, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.5, Qt.GlobalColor.green)
        elif self.gradient_type == 2:
            self.gradient.setColorAt(0, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.6 * grange, Qt.GlobalColor.yellow)
            self.gradient.setColorAt(1 * grange, Qt.GlobalColor.red)
        elif self.gradient_type == 3:
            self.gradient.setColorAt(0 * grange, Qt.GlobalColor.red)
            self.gradient.setColorAt(0.05 * grange, Qt.GlobalColor.yellow)
            self.gradient.setColorAt(0.1 * grange, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.4 * grange, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.45 * grange, Qt.GlobalColor.yellow)
            self.gradient.setColorAt(0.5 * grange, Qt.GlobalColor.red)

        self.gradient.setCenter(x, y)
        painter.fillPath(qp, QBrush(self.gradient))

        pen = QPen()
        pen.setColor(Qt.GlobalColor.black)
        pen.setWidth(max(1, int(1 * self.width() / 300)))
        painter.setPen(pen)
        painter.drawPath(qp)

        qp = QPainterPath()
        #qp.moveTo(0,0)
        #qp.lineTo(x,y)
        #qp.lineTo(self.width(),0)

        angle = 0
        ac = math.atan(float(self.width()) / 2.0 / float(big_radius)) * 0.95

        if self.direction == self.UNIDIRECTIONAL:
            angle = math.pi / 2 + ac * (1 - 2 * self.angle)

        elif self.direction == self.BIDIRECTIONAL:
            angle = math.pi / 2 - self.angle * ac

        length = big_radius + 10
        short_length = small_radius - 10

        qp.moveTo(x + math.cos(angle) * short_length,
                  y - math.sin(angle) * short_length)
        qp.lineTo(x + math.cos(angle) * length, y - math.sin(angle) * length)
        pen = QPen()
        pen.setCapStyle(Qt.RoundCap)
        pen.setColor(Qt.GlobalColor.black)
        pen.setWidth(max(3, int(3 * width / 300)))
        painter.setPen(pen)
        painter.drawPath(qp)

        qp = QPainterPath()
        delta = self.width() * 0.025

        # print "{}-{} {} c:{}".format(x,y,delta,math.cos(angle))
        qp.moveTo(x + delta + math.cos(angle) * short_length,
                  y + delta - math.sin(angle) * short_length)
        qp.lineTo(x + delta + math.cos(angle) * length,
                  y + delta - math.sin(angle) * length)
        pen = QPen()
        pen.setCapStyle(Qt.RoundCap)
        pen.setColor(QColor.fromRgbF(0, 0, 0, 0.3))
        pen.setWidth(max(3, int(3 * width / 300)))
        painter.setPen(pen)
        painter.drawPath(qp)

        qp = QPainterPath()
        qp.addRect(0, 0, self.width(), self.height())
        painter.drawPath(qp)
	def updateColor(self, color):
		self._brushNormal.setColor(QColor.fromRgbF(color[0], color[1], color[2]))
		self._brushHighlighted.setColor(QColor.fromRgbF(color[0], color[1], color[2]))
		self.update(self.rect())
Пример #20
0
 def test_filter_list_item_color(self):
     file_names = [os.path.abspath('hi.txt')]
     color = QColor.fromRgbF(1., 1., 1., 1.)
     item = FilterListItem(file_names, color=color)
     color_check = item.get_params()['color']
     self.assertEqual(color, color_check)
Пример #21
0
 def setUp(self):
     self.original = QColor.fromRgbF(0.2, 0.3, 0.4, 0.5)