Esempio n. 1
0
    def get(self, xtranslate=0, ytranslate=0):

        if not self.points:
            self.points = self._recalculate_points()

        polygon = QPolygonF(self.points)
        polygon.translate(xtranslate, ytranslate)
        return polygon
Esempio n. 2
0
from PyQt5.QtWidgets import QGraphicsSimpleTextItem

from cadnano.gui.palette import getNoPen, getPenObj
from cadnano.gui.palette import getBrushObj, getNoBrush
from . import pathstyles as styles

BASE_WIDTH = styles.PATH_BASE_WIDTH
BASE_RECT = QRectF(0, 0, BASE_WIDTH, BASE_WIDTH)

PHOS_ITEM_WIDTH = 0.25 * BASE_WIDTH
TRIANGLE = QPolygonF()
TRIANGLE.append(QPointF(0, 0))
TRIANGLE.append(QPointF(0.75 * PHOS_ITEM_WIDTH, 0.5 * PHOS_ITEM_WIDTH))
TRIANGLE.append(QPointF(0, PHOS_ITEM_WIDTH))
TRIANGLE.append(QPointF(0, 0))
TRIANGLE.translate(0, -0.5 * PHOS_ITEM_WIDTH)
T180 = QTransform()
T180.rotate(-180)
FWDPHOS_PP, REVPHOS_PP = QPainterPath(), QPainterPath()
FWDPHOS_PP.addPolygon(TRIANGLE)
REVPHOS_PP.addPolygon(T180.map(TRIANGLE))

KEYINPUT_ACTIVE_FLAG = QGraphicsItem.ItemIsFocusable


class PropertyWrapperObject(QObject):
    """Summary

    Attributes:
        animations (dict): Description
        brush_alpha (TYPE): Description
Esempio n. 3
0
from cadnano.fileio.lattice import (HoneycombDnaPart, SquareDnaPart)
from cadnano.gui.palette import (getBrushObj, getColorObj, getNoPen, getPenObj)

from cadnano.proxies.cnenum import GridEnum
from cadnano.part.nucleicacidpart import DEFAULT_RADIUS

from . import slicestyles as styles

PXI_PP_ITEM_WIDTH = IW = 2.0  # 1.5
TRIANGLE = QPolygonF()
TRIANGLE.append(QPointF(0, 0))
TRIANGLE.append(QPointF(0.75 * IW, 0.5 * IW))
TRIANGLE.append(QPointF(0, IW))
TRIANGLE.append(QPointF(0, 0))
# TRIANGLE.translate(-0.75*IW, -0.5*IW)
TRIANGLE.translate(-0.25 * IW, -0.5 * IW)

PXI_RECT = QRectF(0, 0, IW, IW)
T90, T270 = QTransform(), QTransform()
T90.rotate(90)
T270.rotate(270)
FWDPXI_PP, REVPXI_PP = QPainterPath(), QPainterPath()
FWDPXI_PP.addPolygon(T90.map(TRIANGLE))
REVPXI_PP.addPolygon(T270.map(TRIANGLE))

# FWDPXI_PP.moveTo(-0.5*IW, 0.7*IW)
# FWDPXI_PP.lineTo(0., -0.2*IW)
# FWDPXI_PP.lineTo(0.5*IW, 0.7*IW)
# extra1 = QPainterPath()
# extra1.addEllipse(-0.5*IW, 0.5*IW, IW, 0.4*IW)
# extra2 = QPainterPath()
Esempio n. 4
0
    getBrushObj,
    getColorObj,
    getNoPen,
    getPenObj
)
from . import gridstyles as styles


PXI_PP_ITEM_WIDTH = IW = 2.0  # 1.5
TRIANGLE = QPolygonF()
TRIANGLE.append(QPointF(0, 0))
TRIANGLE.append(QPointF(0.75*IW, 0.5*IW))
TRIANGLE.append(QPointF(0, IW))
TRIANGLE.append(QPointF(0, 0))
# TRIANGLE.translate(-0.75*IW, -0.5*IW)
TRIANGLE.translate(-0.25*IW, -0.5*IW)

PXI_RECT = QRectF(0, 0, IW, IW)
T90, T270 = QTransform(), QTransform()
T90.rotate(90)
T270.rotate(270)
FWDPXI_PP, REVPXI_PP = QPainterPath(), QPainterPath()
FWDPXI_PP.addPolygon(T90.map(TRIANGLE))
REVPXI_PP.addPolygon(T270.map(TRIANGLE))

# FWDPXI_PP.moveTo(-0.5*IW, 0.7*IW)
# FWDPXI_PP.lineTo(0., -0.2*IW)
# FWDPXI_PP.lineTo(0.5*IW, 0.7*IW)
# extra1 = QPainterPath()
# extra1.addEllipse(-0.5*IW, 0.5*IW, IW, 0.4*IW)
# extra2 = QPainterPath()
Esempio n. 5
0
    def drawToolButtonMenuIndicator(self, option, painter, widget=None):
        arrow_rect = self.proxy().subControlRect(QStyle.CC_ToolButton, option,
                                                 QStyle.SC_ToolButtonMenu,
                                                 widget)

        text_color = option.palette.color(
            QPalette.WindowText if option.state
            & QStyle.State_AutoRaise else QPalette.ButtonText)
        button_color = option.palette.color(QPalette.Button)
        background_color = self.background_color(button_color, 0.5)

        painter.save()

        # draw separating vertical line
        if option.state & (QStyle.State_On | QStyle.State_Sunken):
            top_offset, bottom_offset = 4, 3
        else:
            top_offset, bottom_offset = 2, 2

        if option.direction == Qt.LeftToRight:
            separator_line = QLineF(arrow_rect.x() - 3,
                                    arrow_rect.top() + top_offset,
                                    arrow_rect.x() - 3,
                                    arrow_rect.bottom() - bottom_offset)
        else:
            separator_line = QLineF(arrow_rect.right() + 3,
                                    arrow_rect.top() + top_offset,
                                    arrow_rect.right() + 3,
                                    arrow_rect.bottom() - bottom_offset)

        light_gradient = QLinearGradient(separator_line.p1(),
                                         separator_line.p2())
        light_gradient.setColorAt(
            0.0,
            ColorScheme.shade(self.background_top_color(button_color),
                              ColorScheme.LightShade, 0.0))
        light_gradient.setColorAt(
            1.0,
            ColorScheme.shade(self.background_bottom_color(button_color),
                              ColorScheme.MidlightShade, 0.5))
        separator_color = ColorScheme.shade(
            self.background_bottom_color(button_color), ColorScheme.MidShade,
            0.0)

        painter.setRenderHint(QPainter.Antialiasing, False)
        painter.setPen(QPen(light_gradient, 1))
        painter.drawLine(separator_line.translated(-1, 0))
        painter.drawLine(separator_line.translated(+1, 0))
        painter.setPen(QPen(separator_color, 1))
        painter.drawLine(separator_line)

        # draw arrow
        arrow = QPolygonF(
            [QPointF(-3, -1.5),
             QPointF(0.5, 2.5),
             QPointF(4, -1.5)])
        if option.direction == Qt.LeftToRight:
            arrow.translate(-2, 1)
        else:
            arrow.translate(+2, 1)
        pen_thickness = 1.6

        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.translate(arrow_rect.center())

        painter.translate(0, +1)
        painter.setPen(
            QPen(self.calc_light_color(background_color), pen_thickness,
                 Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        painter.drawPolyline(arrow)
        painter.translate(0, -1)
        painter.setPen(
            QPen(self.deco_color(background_color, text_color), pen_thickness,
                 Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        painter.drawPolyline(arrow)

        painter.restore()
Esempio n. 6
0
    RectT,
    Vec2T,
    SegmentT
)

BASE_WIDTH = styles.PATH_BASE_WIDTH
BASE_RECT = QRectF(0, 0, BASE_WIDTH, BASE_WIDTH)


PHOS_ITEM_WIDTH = 0.25*BASE_WIDTH
TRIANGLE = QPolygonF()
TRIANGLE.append(QPointF(0, 0))
TRIANGLE.append(QPointF(0.75 * PHOS_ITEM_WIDTH, 0.5 * PHOS_ITEM_WIDTH))
TRIANGLE.append(QPointF(0, PHOS_ITEM_WIDTH))
TRIANGLE.append(QPointF(0, 0))
TRIANGLE.translate(0, -0.5*PHOS_ITEM_WIDTH)
T180 = QTransform()
T180.rotate(-180)
FWDPHOS_PP, REVPHOS_PP = QPainterPath(), QPainterPath()
FWDPHOS_PP.addPolygon(TRIANGLE)
REVPHOS_PP.addPolygon(T180.map(TRIANGLE))

KEYINPUT_ACTIVE_FLAG = QGraphicsItem.ItemIsFocusable

PROX_ALPHA = 64

class PropertyWrapperObject(QObject):
    """
    Attributes:
        animations (dict): Description
        brush_alpha (TYPE): Description
Esempio n. 7
0
    def __call__(self, xtranslate=0, ytranslate=0):

        polygon = QPolygonF(self.points)
        polygon.translate(xtranslate, ytranslate)
        return polygon
Esempio n. 8
0
    def drawToolButtonMenuIndicator(self, option, painter, widget=None):
        arrow_rect = self.proxy().subControlRect(QStyle.CC_ToolButton, option, QStyle.SC_ToolButtonMenu, widget)

        text_color = option.palette.color(
            QPalette.WindowText if option.state & QStyle.State_AutoRaise else QPalette.ButtonText
        )
        button_color = option.palette.color(QPalette.Button)
        background_color = self.background_color(button_color, 0.5)

        painter.save()

        # draw separating vertical line
        if option.state & (QStyle.State_On | QStyle.State_Sunken):
            top_offset, bottom_offset = 4, 3
        else:
            top_offset, bottom_offset = 2, 2

        if option.direction == Qt.LeftToRight:
            separator_line = QLineF(
                arrow_rect.x() - 3,
                arrow_rect.top() + top_offset,
                arrow_rect.x() - 3,
                arrow_rect.bottom() - bottom_offset,
            )
        else:
            separator_line = QLineF(
                arrow_rect.right() + 3,
                arrow_rect.top() + top_offset,
                arrow_rect.right() + 3,
                arrow_rect.bottom() - bottom_offset,
            )

        light_gradient = QLinearGradient(separator_line.p1(), separator_line.p2())
        light_gradient.setColorAt(
            0.0, ColorScheme.shade(self.background_top_color(button_color), ColorScheme.LightShade, 0.0)
        )
        light_gradient.setColorAt(
            1.0, ColorScheme.shade(self.background_bottom_color(button_color), ColorScheme.MidlightShade, 0.5)
        )
        separator_color = ColorScheme.shade(self.background_bottom_color(button_color), ColorScheme.MidShade, 0.0)

        painter.setRenderHint(QPainter.Antialiasing, False)
        painter.setPen(QPen(light_gradient, 1))
        painter.drawLine(separator_line.translated(-1, 0))
        painter.drawLine(separator_line.translated(+1, 0))
        painter.setPen(QPen(separator_color, 1))
        painter.drawLine(separator_line)

        # draw arrow
        arrow = QPolygonF([QPointF(-3, -1.5), QPointF(0.5, 2.5), QPointF(4, -1.5)])
        if option.direction == Qt.LeftToRight:
            arrow.translate(-2, 1)
        else:
            arrow.translate(+2, 1)
        pen_thickness = 1.6

        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.translate(arrow_rect.center())

        painter.translate(0, +1)
        painter.setPen(
            QPen(self.calc_light_color(background_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
        )
        painter.drawPolyline(arrow)
        painter.translate(0, -1)
        painter.setPen(
            QPen(self.deco_color(background_color, text_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
        )
        painter.drawPolyline(arrow)

        painter.restore()