예제 #1
0
    def updateAppearance(self):
        """Check item's current visibility, color and active state, and sets
        pen, brush, text according to style defaults.
        """
        is_visible, color = self._model_part.getVirtualHelixProperties(self._id_num, ['is_visible', 'color'])
        if is_visible:
            self.show()
        else:
            self.hide()
            return

        pwidth = styles.GRID_HELIX_STROKE_WIDTH if self.old_pen is None else SNAP_WIDTH

        if self.is_active:
            self._USE_PEN = getPenObj(styles.ACTIVE_STROKE, pwidth)
        else:
            self._USE_PEN = getPenObj(color, pwidth)

        self._TEXT_BRUSH = getBrushObj(styles.GRID_TEXT_COLOR)

        self._BRUSH = _BRUSH_DEFAULT
        self._USE_BRUSH = getBrushObj(color, alpha=150)

        self._label.setBrush(self._TEXT_BRUSH)
        self.setBrush(self._BRUSH)
        self.setPen(self._USE_PEN)
        self.setRect(_RECT)
예제 #2
0
    def __init__(self, model_part, part_item):
        super(QGraphicsRectItem, self).__init__(BASE_RECT, part_item)
        # self.setAcceptHoverEvents(True)
        # self.setBrush(getNoBrush())
        self.setBrush(getBrushObj(styles.BLUE_FILL, alpha=12))
        self.setPen(getNoPen())
        self.setZValue(styles.ZWORKPLANE)

        self._model_part = model_part
        self._part_item = part_item
        self._idx_low, self._idx_high = model_part.getProperty('workplane_idxs')
        self._low_drag_bound = 0  # idx, not pos
        self._high_drag_bound = model_part.getProperty('max_vhelix_length')  # idx, not pos

        self.outline = PathWorkplaneOutline(self)
        self.resize_handle_group = ResizeHandleGroup(self.rect(),
                                                     self._HANDLE_SIZE,
                                                     styles.BLUE_STROKE,
                                                     True,
                                                     HandleType.LEFT | HandleType.RIGHT,
                                                     self,
                                                     translates_in=Axis.X)

        # Minimum size hint (darker internal rect, visible during resizing)
        self.model_bounds_hint = m_b_h = QGraphicsRectItem(self)
        m_b_h.setBrush(getBrushObj(styles.BLUE_FILL, alpha=64))
        m_b_h.setPen(getNoPen())
        m_b_h.hide()

        # Low and high idx labels
        self.resize_handle_group.updateText(HandleType.LEFT, self._idx_low)
        self.resize_handle_group.updateText(HandleType.RIGHT, self._idx_high)
예제 #3
0
    def partPropertyChangedSlot(self, model_part, property_key, new_value):
        """Summary

        Args:
            model_part (Part): The model part
            property_key (TYPE): Description
            new_value (TYPE): Description

        Args:
            TYPE: Description
        """
        if self._model_part == model_part:
            self._model_props[property_key] = new_value
            if property_key == 'color':
                self.outline.setPen(getPenObj(new_value, _DEFAULT_WIDTH))
                for vhi in self._virtual_helix_item_hash.values():
                    vhi.updateAppearance()
                self.grab_cornerTL.setBrush(getBrushObj(new_value))
                self.grab_cornerBR.setBrush(getBrushObj(new_value))
            elif property_key == 'is_visible':
                if new_value:
                    self.show()
                else:
                    self.hide()
            elif property_key == 'grid_type':
                self.griditem.setGridType(new_value)
예제 #4
0
    def resetItem(self, from_virtual_helix_item, is_fwd, from_index,
                  to_vh_id_num, prexoveritemgroup, color):
        """Summary

        Args:
            from_virtual_helix_item (cadnano.gui.views.pathview.virtualhelixitem.VirtualHelixItem): Description
            is_fwd (TYPE): Description
            from_index (TYPE): Description
            to_vh_id_num (TYPE): Description
            prexoveritemgroup (TYPE): Description
            color (TYPE): Description

        Returns:
            TYPE: Description
        """
        self.setParentItem(from_virtual_helix_item)
        self.resetTransform()
        self._id_num = from_virtual_helix_item.idNum()
        self.idx = from_index
        self.is_fwd = is_fwd
        self.to_vh_id_num = to_vh_id_num
        self._color = color
        self.prexoveritemgroup = prexoveritemgroup
        self._bond_item.hide()
        self._label_txt = lbt = None if to_vh_id_num is None else str(
            to_vh_id_num)
        self.setLabel(text=lbt)
        self._label.resetItem(is_fwd, color)

        phos = self._phos_item
        bonditem = self._bond_item

        if is_fwd:
            phos.setPath(FWDPHOS_PP)
            phos.setTransformOriginPoint(0, phos.boundingRect().center().y())
            phos.setPos(0.5 * BASE_WIDTH, BASE_WIDTH)
            phos.setPen(getNoPen())
            phos.setBrush(getBrushObj(color))
            bonditem.setPen(getPenObj(color, styles.PREXOVER_STROKE_WIDTH))
            self.setPos(from_index * BASE_WIDTH, -BASE_WIDTH)
        else:
            phos.setPath(REVPHOS_PP)
            phos.setTransformOriginPoint(0, phos.boundingRect().center().y())
            phos.setPos(0.5 * BASE_WIDTH, 0)
            phos.setPen(getPenObj(color, 0.25))
            phos.setBrush(getNoBrush())
            bonditem.setPen(
                getPenObj(color,
                          styles.PREXOVER_STROKE_WIDTH,
                          penstyle=Qt.DotLine,
                          capstyle=Qt.RoundCap))
            self.setPos(from_index * BASE_WIDTH, 2 * BASE_WIDTH)

        if to_vh_id_num is not None:
            inactive_alpha = PROX_ALPHA
            self.setBrush(getBrushObj(color, alpha=inactive_alpha))
        else:
            self.setBrush(getBrushObj(color, alpha=0))
        self.show()
예제 #5
0
    def resetItem(self, from_virtual_helix_item, is_fwd, from_index,
                  to_vh_id_num, prexoveritemgroup, color):
        """Summary

        Args:
            from_virtual_helix_item (cadnano.gui.views.pathview.virtualhelixitem.VirtualHelixItem): Description
            is_fwd (TYPE): Description
            from_index (TYPE): Description
            to_vh_id_num (TYPE): Description
            prexoveritemgroup (TYPE): Description
            color (TYPE): Description

        Returns:
            TYPE: Description
        """
        self.setParentItem(from_virtual_helix_item)
        self.resetTransform()
        self._id_num = from_virtual_helix_item.idNum()
        self.idx = from_index
        self.is_fwd = is_fwd
        self.to_vh_id_num = to_vh_id_num
        self._color = color
        self.prexoveritemgroup = prexoveritemgroup
        self._bond_item.hide()
        self._label_txt = lbt = None if to_vh_id_num is None else str(to_vh_id_num)
        self.setLabel(text=lbt)
        self._label.resetItem(is_fwd, color)

        phos = self._phos_item
        bonditem = self._bond_item

        if is_fwd:
            phos.setPath(FWDPHOS_PP)
            phos.setTransformOriginPoint(0, phos.boundingRect().center().y())
            phos.setPos(0.5*BASE_WIDTH, BASE_WIDTH)
            phos.setPen(getNoPen())
            phos.setBrush(getBrushObj(color))
            bonditem.setPen(getPenObj(color, styles.PREXOVER_STROKE_WIDTH))
            self.setPos(from_index*BASE_WIDTH, -BASE_WIDTH)
        else:
            phos.setPath(REVPHOS_PP)
            phos.setTransformOriginPoint(0, phos.boundingRect().center().y())
            phos.setPos(0.5*BASE_WIDTH, 0)
            phos.setPen(getPenObj(color, 0.25))
            phos.setBrush(getNoBrush())
            bonditem.setPen(getPenObj(color, styles.PREXOVER_STROKE_WIDTH,
                                      penstyle=Qt.DotLine, capstyle=Qt.RoundCap))
            self.setPos(from_index*BASE_WIDTH, 2*BASE_WIDTH)

        if to_vh_id_num is not None:
            inactive_alpha = PROX_ALPHA
            self.setBrush(getBrushObj(color, alpha=inactive_alpha))
        else:
            self.setBrush(getBrushObj(color, alpha=0))
        self.show()
예제 #6
0
    def __init__(self, parent):
        """Summary

        Args:
            parent (TYPE): Description
        """
        QSyntaxHighlighter.__init__(self, parent)
        self.parent = parent
        self.format = QTextCharFormat()
        self.format.setForeground(getBrushObj(Qt.white))
        self.format.setBackground(getBrushObj(styles.INVALID_DNA_COLOR))
        if styles.UNDERLINE_INVALID_DNA:
            self.format.setFontUnderline(True)
            self.format.setUnderlineColor(getColorObj(styles.INVALID_DNA_COLOR))
예제 #7
0
    def __init__(self, parent):
        """Summary

        Args:
            parent (TYPE): Description
        """
        QSyntaxHighlighter.__init__(self, parent)
        self.parent = parent
        self.format = QTextCharFormat()
        self.format.setForeground(getBrushObj(Qt.white))
        self.format.setBackground(getBrushObj(styles.INVALID_DNA_COLOR))
        if styles.UNDERLINE_INVALID_DNA:
            self.format.setFontUnderline(True)
            self.format.setUnderlineColor(getColorObj(styles.INVALID_DNA_COLOR))
예제 #8
0
 def __init__(self, is_fwd, pre_xover_item):
     """
     Args:
         is_fwd (bool): True if forward strand base, False if reverse.
         pre_xover_item (TYPE): Description
     """
     super(Triangle, self).__init__(pre_xover_item)
     color = pre_xover_item.color
     self.adapter = PropertyWrapperObject(self)
     self.setAcceptHoverEvents(True)
     self.setFiltersChildEvents(True)
     self._click_area = click_area = QGraphicsRectItem(PXI_RECT, self)
     click_area.setAcceptHoverEvents(True)
     click_area.setPen(getNoPen())
     click_area.hoverMoveEvent = self.hoverMoveEvent
     if is_fwd:
         # grad = QLinearGradient(0., 0., 0., 1.)
         # grad.setColorAt(0, getColorObj(color))
         # grad.setColorAt(1, Qt.black)
         # self.setBrush(grad)
         self.setBrush(getBrushObj(color, alpha=128))
         self.setPath(FWDPXI_PP)
         self.setPen(getNoPen())
         self._click_area.setPos(-0.5*IW, -0.75*IW)
     else:
         self.setPath(REVPXI_PP)
         self.setPen(getPenObj(color, 0.25, alpha=128))
         # grad = QLinearGradient(0., 0., 0., -1.)
         # grad.setColorAt(1, getColorObj(color))
         # grad.setColorAt(0, Qt.black)
         # self.setPen(getNoPen())
         # self.setBrush(grad)
         self._click_area.setPos(-0.5*IW, -0.25*IW)
예제 #9
0
    def __init__(self, handle_type, width, color, handle_group, parent):
        ''' parent is a :class:`QGraphicsItem` such as a :class:`NucleicAcidPartItem`
        '''
        super(HandleItem, self).__init__(parent)
        self.setAcceptHoverEvents(True)
        self._handle_type = handle_type
        self._group = handle_group
        self.width = w = width
        self.half_width = w / 2
        self.align_offset = parent._BOUNDING_RECT_PADDING
        self.model_bounds = ()
        self.can_move_x = handle_group.translates_in & AxisEnum.X
        self.can_move_y = handle_group.translates_in & AxisEnum.Y

        self.setBrush(getBrushObj(styles.RESIZEHANDLE_FILL_COLOR))
        self.setPen(getPenObj(color, 0))
        self.setRect(QRectF(0, 0, w, w))

        self.label = HandleItemLabel(self)

        self.event_start_position = QPointF(0, 0)
        self.event_scene_start_position = QPointF(0, 0)

        if handle_type & (HandleEnum.LEFT | HandleEnum.RIGHT):
            self._resize_cursor = Qt.SizeHorCursor
        elif handle_type & (HandleEnum.TOP | HandleEnum.BOTTOM):
            self._resize_cursor = Qt.SizeVerCursor
        elif handle_type & (HandleEnum.TOP_LEFT | HandleEnum.BOTTOM_RIGHT):
            self._resize_cursor = Qt.SizeFDiagCursor
        elif handle_type & (HandleEnum.TOP_RIGHT | HandleEnum.BOTTOM_LEFT):
            self._resize_cursor = Qt.SizeBDiagCursor
        else:
            self._resize_cursor = Qt.ClosedHandCursor
예제 #10
0
 def __init__(self, is_fwd, pre_xover_item):
     """
     Args:
         is_fwd (bool): True if forward strand base, False if reverse.
         pre_xover_item (TYPE): Description
     """
     super(Triangle, self).__init__(pre_xover_item)
     color = pre_xover_item.color
     self.adapter = PropertyWrapperObject(self)
     self.setAcceptHoverEvents(True)
     self.setFiltersChildEvents(True)
     self._click_area = click_area = QGraphicsRectItem(PXI_RECT, self)
     click_area.setAcceptHoverEvents(True)
     click_area.setPen(getNoPen())
     click_area.hoverMoveEvent = self.hoverMoveEvent
     if is_fwd:
         # grad = QLinearGradient(0., 0., 0., 1.)
         # grad.setColorAt(0, getColorObj(color))
         # grad.setColorAt(1, Qt.black)
         # self.setBrush(grad)
         self.setBrush(getBrushObj(color, alpha=128))
         self.setPath(FWDPXI_PP)
         self.setPen(getNoPen())
         self._click_area.setPos(-0.5 * IW, -0.75 * IW)
     else:
         self.setPath(REVPXI_PP)
         self.setPen(getPenObj(color, 0.25, alpha=128))
         # grad = QLinearGradient(0., 0., 0., -1.)
         # grad.setColorAt(1, getColorObj(color))
         # grad.setColorAt(0, Qt.black)
         # self.setPen(getNoPen())
         # self.setBrush(grad)
         self._click_area.setPos(-0.5 * IW, -0.25 * IW)
예제 #11
0
 def hoverLeaveEvent(self, event: QGraphicsSceneHoverEvent):
     """
     Args:
         event: Description
     """
     self.setBrush(getBrushObj(styles.DEFAULT_GRID_DOT_COLOR))
     self.setPen(getPenObj(styles.DEFAULT_GRID_DOT_COLOR, 1.0))
예제 #12
0
 def hoverLeaveEvent(self, event: QGraphicsSceneHoverEvent):
     """
     Args:
         event: Description
     """
     self.setBrush(getBrushObj(styles.DEFAULT_GRID_DOT_COLOR))
     self.setPen(getPenObj(styles.DEFAULT_GRID_DOT_COLOR, 1.0))
예제 #13
0
    def partPropertyChangedSlot(self, model_part, property_key, new_value):
        """Summary

        Args:
            model_part (Part): The model part
            property_key (TYPE): Description
            new_value (TYPE): Description

        Returns:
            TYPE: Description
        """
        if self._model_part == model_part:
            self._model_props[property_key] = new_value
            if property_key == 'color':
                self._updateBoundingRect()
                for vhi in self._virtual_helix_item_list:
                    vhi.handle().refreshColor()
                self.grab_corner.setBrush(getBrushObj(new_value))
            elif property_key == 'is_visible':
                if new_value:
                    self.show()
                else:
                    self.hide()
            elif property_key == 'virtual_helix_order':
                vhi_dict = self._virtual_helix_item_hash
                new_list = [vhi_dict[id_num] for id_num in new_value]
                ztf = False
                self._setVirtualHelixItemList(new_list, zoom_to_fit=ztf)
예제 #14
0
    def __init__(self,  x: float, y: float, diameter: float,
                        parent_grid: GridItem,
                        coord: Tuple[int, int] = None):
        """
        Args:
            x:
            y:
            diameter:
            parent_grid:
            coord: This is the row, column tuple
        """
        super(GridPoint, self).__init__(0., 0., diameter, diameter, parent=parent_grid)
        self.offset = diameter / 2
        self.grid = parent_grid
        self._coord = coord
        self._label = label = QGraphicsSimpleTextItem("", self)
        label.setFont(styles.SLICE_NUM_FONT)
        label.setZValue(styles.ZSLICEHELIX)
        label.setBrush(getBrushObj(styles.SLICE_TEXT_COLOR, alpha=64))
        b_rect = label.boundingRect()
        posx = b_rect.width()/2
        posy = b_rect.height()/2
        label.setPos(_RADIUS-posx, _RADIUS-posy)

        self.click_area = ClickArea(diameter, parent=self)

        self.setPos(x, y)
        self.setZValue(_ZVALUE)
        self.setAcceptHoverEvents(True)
예제 #15
0
파일: bar.py 프로젝트: sdouglas/lr-notebook
    def __init__(self, rect, parent=None):
        super(QGraphicsEllipseItem, self).__init__(rect, parent)
        self._parent = parent
        self.setPen(getNoPen())

        iw = _ITEM_WIDTH = 3
        x = _RECT.width() - 2*rect_gain - 2*styles.SLICE_HELIX_STROKE_WIDTH - 1
        y = _RECT.center().y()
        prexo_items = {}
        fwd_angles = [0, 240, 120]
        fwd_colors = ['#cc0000', '#00cc00', '#0000cc']
        for i in range(len(fwd_angles)):
            item = QGraphicsEllipseItem(x, y, iw, iw, self)
            item.setPen(getNoPen())
            item.setBrush(getBrushObj(fwd_colors[i]))
            item.setTransformOriginPoint(_RECT.center())
            item.setRotation(fwd_angles[i])
            prexo_items[i] = item

        rev_angles = [150, 30, 270]
        rev_colors = ['#800000cc', '#80cc0000', '#8000cc00']
        # rev_colors = ['#ff00ff', '#3399ff', '#ff6600']
        for i in range(len(fwd_angles)):
            item = QGraphicsEllipseItem(x, y, iw, iw, self)
            item.setPen(getPenObj(rev_colors[i],0.5))
            item.setBrush(getNoBrush())
            item.setTransformOriginPoint(_RECT.center())
            item.setRotation(rev_angles[i])
            prexo_items[i] = item
예제 #16
0
    def __init__(self, handle_type, width, color, handle_group, parent):
        ''' parent is a :class:`QGraphicsItem` such as a :class:`NucleicAcidPartItem`
        '''
        super(HandleItem, self).__init__(parent)
        self.setAcceptHoverEvents(True)
        self._handle_type = handle_type
        self._group = handle_group
        self.width = w = width
        self.half_width = w/2
        self.align_offset = parent._BOUNDING_RECT_PADDING
        self.model_bounds = ()
        self.can_move_x = handle_group.translates_in & AxisEnum.X
        self.can_move_y = handle_group.translates_in & AxisEnum.Y

        self.setBrush(getBrushObj(styles.RESIZEHANDLE_FILL_COLOR))
        self.setPen(getPenObj(color, 0))
        self.setRect(QRectF(0, 0, w, w))

        self.label = HandleItemLabel(self)

        self.event_start_position = QPointF(0, 0)
        self.event_scene_start_position = QPointF(0, 0)

        if handle_type & (HandleEnum.LEFT | HandleEnum.RIGHT):
            self._resize_cursor = Qt.SizeHorCursor
        elif handle_type & (HandleEnum.TOP | HandleEnum.BOTTOM):
            self._resize_cursor = Qt.SizeVerCursor
        elif handle_type & (HandleEnum.TOP_LEFT | HandleEnum.BOTTOM_RIGHT):
            self._resize_cursor = Qt.SizeFDiagCursor
        elif handle_type & (HandleEnum.TOP_RIGHT | HandleEnum.BOTTOM_LEFT):
            self._resize_cursor = Qt.SizeBDiagCursor
        else:
            self._resize_cursor = Qt.ClosedHandCursor
예제 #17
0
    def setActiveHovered(self, is_active):
        """Rotate phosphate Triangle if `self.to_vh_id_num` is not `None`

        Args:
            is_active (bool): whether or not the PreXoverItem is parented to the
                active VirtualHelixItem
        """
        if is_active:
            self.setBrush(getBrushObj(self._color, alpha=128))
            self.animate(self, 'brush_alpha', 1, 0, 128)  # overwrite running anim
            # if self.to_vh_id_num is not None:
            self.animate(self._phos_item, 'rotation', 500, 0, -90)
        else:
            inactive_alpha = 0 if self.to_vh_id_num is None else PROX_ALPHA
            self.setBrush(getBrushObj(self._color, alpha=inactive_alpha))
            self.animate(self, 'brush_alpha', 1000, 128, inactive_alpha)
            self.animate(self._phos_item, 'rotation', 500, -90, 0)
 def resetBrush(self, color: str, alpha: int):
     """
     Args:
         color: color string
         alpha: transparency
     """
     brush = getBrushObj(color, alpha=alpha)
     self.setBrush(brush)
    def paint(self, painter: QPainter, option: QStyleOptionViewItem,
              model_index: QModelIndex):
        column = model_index.column()
        new_rect = QRect(option.rect)
        if column == NAME_COL:  # Part Name
            option.displayAlignment = Qt.AlignVCenter
            QStyledItemDelegate.paint(self, painter, option, model_index)
        if column == LOCKED_COL:  # Visibility
            element = _QCOMMONSTYLE.PE_IndicatorCheckBox
            styleoption = QStyleOptionButton()
            styleoption.rect = new_rect
            checked = model_index.model().data(model_index, Qt.EditRole)
            styleoption.state |= QStyle.State_On if checked else QStyle.State_Off
            # make the check box look a little more active by changing the pallete
            styleoption.palette.setBrush(QPalette.Button, Qt.white)
            styleoption.palette.setBrush(QPalette.HighlightedText, Qt.black)
            _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
            if checked:
                # element = _QCOMMONSTYLE.PE_IndicatorMenuCheckMark
                # _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
                # _QCOMMONSTYLE.drawItemText(painter, new_rect, Qt.AlignCenter, styleoption.palette, True, 'L')
                icon = QPixmap(":/outlinericons/lock")
                _QCOMMONSTYLE.drawItemPixmap(painter, new_rect, Qt.AlignCenter,
                                             icon)
        if column == VISIBLE_COL:  # Visibility
            element = _QCOMMONSTYLE.PE_IndicatorCheckBox
            styleoption = QStyleOptionButton()
            styleoption.rect = new_rect
            checked = model_index.model().data(model_index, Qt.EditRole)
            styleoption.state |= QStyle.State_On if checked else QStyle.State_Off
            # make the check box look a little more active by changing the pallete
            styleoption.palette.setBrush(QPalette.Button, Qt.white)
            styleoption.palette.setBrush(QPalette.HighlightedText, Qt.black)
            _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
            if checked:
                # element = _QCOMMONSTYLE.PE_IndicatorMenuCheckMark
                # _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
                icon = QPixmap(":/outlinericons/eye")
                _QCOMMONSTYLE.drawItemPixmap(painter, new_rect, Qt.AlignCenter,
                                             icon)
        elif column == COLOR_COL:  # Color

            # Alternate way to get color
            # outline_tw = self.parent()
            # item = outline_tw.itemFromIndex(model_index)
            # color = item.getColor()
            # print("COLOR_COL", item)

            color = model_index.model().data(model_index, Qt.EditRole)
            element = _QCOMMONSTYLE.PE_IndicatorCheckBox
            styleoption = QStyleOptionViewItem()
            brush = getBrushObj(color)
            styleoption.palette.setBrush(QPalette.Button, brush)
            styleoption.rect = new_rect
            _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
        else:
            QStyledItemDelegate.paint(self, painter, option, model_index)
예제 #20
0
 def refreshColor(self):
     """
     """
     part_color = self._model_part.getProperty('color')
     self._USE_PEN = getPenObj(part_color, styles.VIRTUALHELIXHANDLEITEM_STROKE_WIDTH)
     self._USE_BRUSH = getBrushObj(styles.DEFAULT_BRUSH_COLOR)
     self.setPen(self._USE_PEN)
     self.setBrush(self._USE_BRUSH)
     self.update(self.boundingRect())
예제 #21
0
    def setActiveHovered(self, is_active):
        """Rotate phosphate Triangle if `self.to_vh_id_num` is not `None`

        Args:
            is_active (bool): whether or not the PreXoverItem is parented to the
                active VirtualHelixItem
        """
        if is_active:
            self.setBrush(getBrushObj(self._color, alpha=128))
            self.animate(self, 'brush_alpha', 1, 0,
                         128)  # overwrite running anim
            # if self.to_vh_id_num is not None:
            self.animate(self._phos_item, 'rotation', 500, 0, -90)
        else:
            inactive_alpha = 0 if self.to_vh_id_num is None else PROX_ALPHA
            self.setBrush(getBrushObj(self._color, alpha=inactive_alpha))
            self.animate(self, 'brush_alpha', 1000, 128, inactive_alpha)
            self.animate(self._phos_item, 'rotation', 500, -90, 0)
예제 #22
0
    def _updateSequenceText(self):
        """
        docstring for _updateSequenceText
        """
        # print("updating sequence")
        bw = _BASE_WIDTH
        seq_lbl = self._seq_label
        strand = self.strand()

        seq_txt = strand.sequence()
        isDrawn3to5 = not self.is_forward
        text_X_centering_offset = styles.SEQUENCETEXTXCENTERINGOFFSET

        if seq_txt == '':
            seq_lbl.hide()
            for i_item in self.insertionItems().values():
                i_item.hideSequence()
            return
        # end if

        strand_seq_list = strand.getSequenceList()
        seq_list = [x[1][0] for x in strand_seq_list]
        insert_seq_list = [(x[0], x[1][1]) for x in strand_seq_list]

        i_items = self.insertionItems()
        for idx, seq_txt in insert_seq_list:
            if seq_txt != '':
                i_items[idx].setSequence(seq_txt)

        if isDrawn3to5:
            seq_list = seq_list[::-1]

        seq_txt = ''.join(seq_list)

        # seq_lbl.setPen(QPen( Qt.NoPen))    # leave the Pen as None for unless required
        seq_lbl.setBrush(getBrushObj(styles.SEQUENCEFONTCOLOR))
        seq_lbl.setFont(styles.SEQUENCEFONT)

        # this will always draw from the 5 Prime end!
        seqX = 2 * text_X_centering_offset + bw * strand.idx5Prime()
        seqY = styles.SEQUENCETEXTYCENTERINGOFFSET

        if isDrawn3to5:
            # offset it towards the bottom
            seqY += bw * .8
            # offset X by the reverse centering offset and the string length
            seqX += text_X_centering_offset * .75
            # rotate the characters upside down this does not affect positioning
            # coordinate system, +Y is still Down, and +X is still Right
            seq_lbl.setRotation(180)
            # draw the text and reverse the string to draw 5 prime to 3 prime
            # seq_txt = seq_txt[::-1]
        # end if
        seq_lbl.setPos(seqX, seqY)
        seq_lbl.setText(seq_txt)
        seq_lbl.show()
예제 #23
0
    def paint(self, painter: QPainter,
                    option: QStyleOptionViewItem,
                    model_index: QModelIndex):
        column = model_index.column()
        new_rect = QRect(option.rect)
        if column == NAME_COL:  # Part Name
            option.displayAlignment = Qt.AlignVCenter
            QStyledItemDelegate.paint(self, painter, option, model_index)
        if column == LOCKED_COL:  # Visibility
            element = _QCOMMONSTYLE.PE_IndicatorCheckBox
            styleoption = QStyleOptionButton()
            styleoption.rect = new_rect
            checked = model_index.model().data(model_index, Qt.EditRole)
            styleoption.state |= QStyle.State_On if checked else QStyle.State_Off
            # make the check box look a little more active by changing the pallete
            styleoption.palette.setBrush(QPalette.Button, Qt.white)
            styleoption.palette.setBrush(QPalette.HighlightedText, Qt.black)
            _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
            if checked:
                # element = _QCOMMONSTYLE.PE_IndicatorMenuCheckMark
                # _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
                # _QCOMMONSTYLE.drawItemText(painter, new_rect, Qt.AlignCenter, styleoption.palette, True, 'L')
                icon = QPixmap(":/outlinericons/lock")
                _QCOMMONSTYLE.drawItemPixmap(painter, new_rect, Qt.AlignCenter, icon)
        if column == VISIBLE_COL:  # Visibility
            element = _QCOMMONSTYLE.PE_IndicatorCheckBox
            styleoption = QStyleOptionButton()
            styleoption.rect = new_rect
            checked = model_index.model().data(model_index, Qt.EditRole)
            styleoption.state |= QStyle.State_On if checked else QStyle.State_Off
            # make the check box look a little more active by changing the pallete
            styleoption.palette.setBrush(QPalette.Button, Qt.white)
            styleoption.palette.setBrush(QPalette.HighlightedText, Qt.black)
            _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
            if checked:
                # element = _QCOMMONSTYLE.PE_IndicatorMenuCheckMark
                # _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
                icon = QPixmap(":/outlinericons/eye")
                _QCOMMONSTYLE.drawItemPixmap(painter, new_rect, Qt.AlignCenter, icon)
        elif column == COLOR_COL:  # Color

            # Alternate way to get color
            # outline_tw = self.parent()
            # item = outline_tw.itemFromIndex(model_index)
            # color = item.getColor()
            # print("COLOR_COL", item)

            color = model_index.model().data(model_index, Qt.EditRole)
            element = _QCOMMONSTYLE.PE_IndicatorCheckBox
            styleoption = QStyleOptionViewItem()
            brush = getBrushObj(color)
            styleoption.palette.setBrush(QPalette.Button, brush)
            styleoption.rect = new_rect
            _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
        else:
            QStyledItemDelegate.paint(self, painter, option, model_index)
예제 #24
0
    def _updateSequenceText(self):
        """
        docstring for _updateSequenceText
        """
        # print("updating sequence")
        bw = _BASE_WIDTH
        seq_lbl = self._seq_label
        strand = self.strand()

        seq_txt = strand.sequence()
        isDrawn3to5 = not self.is_forward
        text_X_centering_offset = styles.SEQUENCETEXTXCENTERINGOFFSET

        if seq_txt == '':
            seq_lbl.hide()
            for i_item in self.insertionItems().values():
                i_item.hideSequence()
            return
        # end if

        strand_seq_list = strand.getSequenceList()
        seq_list = [x[1][0] for x in strand_seq_list]
        insert_seq_list = [(x[0], x[1][1]) for x in strand_seq_list]

        i_items = self.insertionItems()
        for idx, seq_txt in insert_seq_list:
            if seq_txt != '':
                i_items[idx].setSequence(seq_txt)

        if isDrawn3to5:
            seq_list = seq_list[::-1]

        seq_txt = ''.join(seq_list)

        # seq_lbl.setPen(QPen( Qt.NoPen))    # leave the Pen as None for unless required
        seq_lbl.setBrush(getBrushObj(styles.SEQUENCEFONTCOLOR))
        seq_lbl.setFont(styles.SEQUENCEFONT)

        # this will always draw from the 5 Prime end!
        seqX = 2*text_X_centering_offset + bw*strand.idx5Prime()
        seqY = styles.SEQUENCETEXTYCENTERINGOFFSET

        if isDrawn3to5:
            # offset it towards the bottom
            seqY += bw * .8
            # offset X by the reverse centering offset and the string length
            seqX += text_X_centering_offset*.75
            # rotate the characters upside down this does not affect positioning
            # coordinate system, +Y is still Down, and +X is still Right
            seq_lbl.setRotation(180)
            # draw the text and reverse the string to draw 5 prime to 3 prime
            # seq_txt = seq_txt[::-1]
        # end if
        seq_lbl.setPos(seqX, seqY)
        seq_lbl.setText(seq_txt)
        seq_lbl.show()
예제 #25
0
    def _highlightSpaVH(self, vh_id):
        # TODO[NF]:  Docstring
        if self.spa_start_vhi:
            self.spa_start_vhi.setBrush(getNoBrush())

        if vh_id is None:
            self.spa_start_vhi = None
        else:
            self.spa_start_vhi = self._virtual_helix_item_hash[vh_id]
            self.spa_start_vhi.setBrush(getBrushObj(styles.SPA_START_HINT_COLOR, alpha=32))
예제 #26
0
    def hoverEnterEvent(self, event):
        """Summary

        Args:
            event (QGraphicsSceneHoverEvent): Description
        """
        self.setBrush(getBrushObj(styles.ACTIVE_GRID_DOT_COLOR))
        self.setPen(getPenObj(styles.ACTIVE_GRID_DOT_COLOR, 1.0))
        self.grid.part_item.vhi_hint_item.setPos(
            self.scenePos() - QPointF(_RADIUS - DELTA, _RADIUS - DELTA))
예제 #27
0
    def hoverEnterEvent(self, event):
        """Summary

        Args:
            event (QGraphicsSceneHoverEvent): Description
        """
        self.setBrush(getBrushObj(styles.ACTIVE_GRID_DOT_COLOR))
        self.setPen(getPenObj(styles.ACTIVE_GRID_DOT_COLOR, 1.0))
        part_item = self.grid.part_item
        part_item._getActiveTool()
예제 #28
0
    def hoverEnterEvent(self, event: QGraphicsSceneHoverEvent):
        """Summary

        Args:
            event: Description
        """
        self.setBrush(getBrushObj(styles.ACTIVE_GRID_DOT_COLOR))
        self.setPen(getPenObj(styles.ACTIVE_GRID_DOT_COLOR, 1.0))
        part_item = self.grid.part_item
        part_item._getActiveTool()
예제 #29
0
    def __init__(self, model_part_instance, viewroot, parent):
        """parent should always be pathrootitem

        Args:
            model_part_instance (TYPE): Description
            viewroot (TYPE): Description
            parent (TYPE): Description
        """
        super(PathNucleicAcidPartItem, self).__init__(model_part_instance,
                                                      viewroot, parent)
        self.setAcceptHoverEvents(True)

        self._getActiveTool = viewroot.manager.activeToolGetter
        self.active_virtual_helix_item = None
        m_p = self._model_part
        self._controller = NucleicAcidPartItemController(self, m_p)
        self.prexover_manager = PreXoverManager(self)
        self._virtual_helix_item_list = []
        self._initModifierRect()
        self._proxy_parent = ProxyParentItem(self)
        self._proxy_parent.setFlag(QGraphicsItem.ItemHasNoContents)
        self._scale_2_model = m_p.baseWidth() / _BASE_WIDTH
        self._scale_2_Qt = _BASE_WIDTH / m_p.baseWidth()

        # self._rect = QRectF()
        self._vh_rect = QRectF()
        # self.setPen(getPenObj(styles.ORANGE_STROKE, 0))
        self.setPen(getNoPen())
        # self.setRect(self._rect)

        self.outline = outline = PathRectItem(self)
        outline.setFlag(QGraphicsItem.ItemStacksBehindParent)
        self.setZValue(styles.ZPART)
        self._proxy_parent.setZValue(styles.ZPART)
        outline.setZValue(styles.ZDESELECTOR)
        self.outline.setPen(getPenObj(m_p.getColor(), _DEFAULT_WIDTH))
        o_rect = self._configureOutline(outline)
        model_color = m_p.getColor()

        self.resize_handle_group = ResizeHandleGroup(
            o_rect,
            _HANDLE_SIZE,
            model_color,
            True,
            # HandleType.LEFT |
            HandleType.RIGHT,
            self)

        self.model_bounds_hint = m_b_h = QGraphicsRectItem(self)
        m_b_h.setBrush(getBrushObj(styles.BLUE_FILL, alpha=32))
        m_b_h.setPen(getNoPen())
        m_b_h.hide()

        self.workplane = PathWorkplaneItem(m_p, self)
        self.hide()  # show on adding first vh
예제 #30
0
    def setTextAndStyle(self, text, outline=False):
        """Summary

        Args:
            text (TYPE): Description
            outline (bool, optional): Description

        Returns:
            TYPE: Description
        """
        str_txt = str(text)
        self._tbr = tBR = self._FM.tightBoundingRect(str_txt)
        half_label_H = tBR.height() / 2.0
        half_label_W = tBR.width() / 2.0

        labelX = BASE_WIDTH / 2.0 - half_label_W
        if str_txt == '1':  # adjust for the number one
            labelX -= tBR.width()

        labelY = half_label_H if self.is_fwd else (BASE_WIDTH -
                                                   tBR.height()) / 2

        self.setPos(labelX, labelY)
        self.setText(str_txt)

        if outline:
            self.setFont(self._XO_BOLD)
            self.setBrush(getBrushObj('#ff0000'))
        else:
            self.setFont(self._XO_FONT)
            self.setBrush(getBrushObj('#666666'))

        if outline:
            r = QRectF(self._tbr).adjusted(-half_label_W, 0, half_label_W,
                                           half_label_H)
            self._outline.setRect(r)
            self._outline.setPen(getPenObj('#ff0000', 0.25))
            self._outline.setY(2 * half_label_H)
            self._outline.show()
        else:
            self._outline.hide()
예제 #31
0
 def __init__(self, is_fwd: bool, pre_xover_item: 'PreXoverItem'):
     """
     Args:
         is_fwd: Description
         pre_xover_item: Description
     """
     super(QGraphicsSimpleTextItem, self).__init__(pre_xover_item)
     self.is_fwd = is_fwd
     self._tbr = None
     self._outline = QGraphicsRectItem(self)
     self.setFont(self._XO_FONT)
     self.setBrush(getBrushObj('#666666'))
예제 #32
0
    def resetBrush(self, color, alpha):
        """Summary

        Args:
            color (TYPE): Description
            alpha (TYPE): Description

        Returns:
            TYPE: Description
        """
        brush = getBrushObj(color, alpha=alpha)
        self.setBrush(brush)
예제 #33
0
 def __init__(self, is_fwd: bool, pre_xover_item: 'PreXoverItem'):
     """
     Args:
         is_fwd: Description
         pre_xover_item: Description
     """
     super(QGraphicsSimpleTextItem, self).__init__(pre_xover_item)
     self.is_fwd = is_fwd
     self._tbr = None
     self._outline = QGraphicsRectItem(self)
     self.setFont(self._XO_FONT)
     self.setBrush(getBrushObj('#666666'))
예제 #34
0
 def showCreateHint(self, id_num=0, show_hint=True, color=None):
     label = self._label
     if show_hint:
         label.setText("%d" % id_num)
         b_rect = label.boundingRect()
         posx = b_rect.width()/2
         posy = b_rect.height()/2
         label.setPos(_RADIUS-posx, _RADIUS-posy)
         self.setBrush(getBrushObj(color if color else styles.MULTI_VHI_HINT_COLOR, alpha=64))
     else:
         label.setText("")
         self.setBrush(getNoBrush())
예제 #35
0
    def setTextAndStyle(self, text, outline=False):
        """Summary

        Args:
            text (TYPE): Description
            outline (bool, optional): Description

        Returns:
            TYPE: Description
        """
        str_txt = str(text)
        self._tbr = tBR = self._FM.tightBoundingRect(str_txt)
        half_label_H = tBR.height() / 2.0
        half_label_W = tBR.width() / 2.0

        labelX = BASE_WIDTH/2.0 - half_label_W
        if str_txt == '1':  # adjust for the number one
            labelX -= tBR.width()

        labelY = half_label_H if self.is_fwd else (BASE_WIDTH - tBR.height())/2

        self.setPos(labelX, labelY)
        self.setText(str_txt)

        if outline:
            self.setFont(self._XO_BOLD)
            self.setBrush(getBrushObj('#ff0000'))
        else:
            self.setFont(self._XO_FONT)
            self.setBrush(getBrushObj('#666666'))

        if outline:
            r = QRectF(self._tbr).adjusted(-half_label_W, 0,
                                           half_label_W, half_label_H)
            self._outline.setRect(r)
            self._outline.setPen(getPenObj('#ff0000', 0.25))
            self._outline.setY(2*half_label_H)
            self._outline.show()
        else:
            self._outline.hide()
예제 #36
0
    def paint(self, painter, option, model_index):
        """Summary

        Args:
            painter (TYPE): Description
            option (TYPE): Description
            model_index (TYPE): Description

        Returns:
            TYPE: Description
        """
        # row = model_index.row()
        column = model_index.column()
        if column == 0:  # Part Name
            option.displayAlignment = Qt.AlignVCenter
            QStyledItemDelegate.paint(self, painter, option, model_index)
        if column == 1:  # Visibility
            value = model_index.model().data(model_index, Qt.EditRole)
            data_type = type(value)
            if data_type is str:
                # print("val", value)
                if COLOR_PATTERN.search(value):
                    # print("found color")
                    element = _QCOMMONSTYLE.PE_IndicatorCheckBox
                    styleoption = QStyleOptionViewItem()
                    styleoption.palette.setBrush(QPalette.Button,
                                                 getBrushObj(value))
                    styleoption.rect = QRect(option.rect)
                    _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
                option.displayAlignment = Qt.AlignVCenter
                QStyledItemDelegate.paint(self, painter, option, model_index)
            elif data_type is int:
                option.displayAlignment = Qt.AlignVCenter
                QStyledItemDelegate.paint(self, painter, option, model_index)
            elif data_type is float:
                option.displayAlignment = Qt.AlignVCenter
                QStyledItemDelegate.paint(self, painter, option, model_index)
            elif data_type is bool:
                element = _QCOMMONSTYLE.PE_IndicatorCheckBox
                styleoption = QStyleOptionButton()
                styleoption.rect = QRect(option.rect)
                checked = value
                styleoption.state |= QStyle.State_On if checked else QStyle.State_Off
                styleoption.palette.setBrush(QPalette.Button, Qt.white)
                styleoption.palette.setBrush(QPalette.HighlightedText,
                                             Qt.black)
                _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
                if checked:
                    element = _QCOMMONSTYLE.PE_IndicatorMenuCheckMark
                    _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
        else:
            QStyledItemDelegate.paint(self, painter, option, model_index)
예제 #37
0
    def deactivateNeighbor(self):
        """Summary

        Returns:
            TYPE: Description
        """
        if self.isVisible():
            inactive_alpha = PROX_ALPHA if self.to_vh_id_num is not None else 0
            self.setBrush(getBrushObj(self._color, alpha=inactive_alpha))
            self.animate(self, 'brush_alpha', 1000, 128, inactive_alpha)
            self.animate(self._phos_item, 'rotation', 500, -90, 0)
            self._bond_item.hide()
            self.setLabel(text=self._label_txt)
예제 #38
0
    def updateProperty(self):
        part_color = self.part().getProperty('color')

        self._USE_PEN = getPenObj(part_color, styles.SLICE_HELIX_STROKE_WIDTH)
        self._OUT_OF_SLICE_PEN = getPenObj(part_color, styles.SLICE_HELIX_STROKE_WIDTH)
        self._USE_BRUSH = getBrushObj(part_color, alpha=128)
        self._OUT_OF_SLICE_BRUSH = getBrushObj(part_color, alpha=64)

        if self.part().crossSectionType() == LatticeType.HONEYCOMB:
            self._USE_PEN = getPenObj(styles.BLUE_STROKE, styles.SLICE_HELIX_STROKE_WIDTH)
            self._OUT_OF_SLICE_PEN = getPenObj(styles.BLUE_STROKE,\
                                          styles.SLICE_HELIX_STROKE_WIDTH)

        if self.part().partType() == PartType.NUCLEICACIDPART:
            self._OUT_OF_SLICE_BRUSH = self._OUT_OF_SLICE_BRUSH_DEFAULT
            # self._USE_BRUSH = getBrushObj(part_color, lighter=180)
            self._USE_BRUSH = getBrushObj(part_color, alpha=150)

        self._label.setBrush(self._OUT_OF_SLICE_TEXT_BRUSH)
        self.setBrush(self._OUT_OF_SLICE_BRUSH)
        self.setPen(self._OUT_OF_SLICE_PEN)
        self.setRect(self._RECT)
예제 #39
0
    def deactivateNeighbor(self):
        """Summary

        Returns:
            TYPE: Description
        """
        if self.isVisible():
            inactive_alpha = PROX_ALPHA if self.to_vh_id_num is not None else 0
            self.setBrush(getBrushObj(self._color, alpha=inactive_alpha))
            self.animate(self, 'brush_alpha', 1000, 128, inactive_alpha)
            self.animate(self._phos_item, 'rotation', 500, -90, 0)
            self._bond_item.hide()
            self.setLabel(text=self._label_txt)
예제 #40
0
    def __init__(self,  model_part: NucleicAcidPartT,
                        part_item: PathNucleicAcidPartItemT):
        """
        Args:
            model_part:
            part_item:
        """
        super(QGraphicsRectItem, self).__init__(BASE_RECT, part_item.proxy())
        self.setAcceptHoverEvents(True)
        self.setBrush(getBrushObj(styles.BLUE_FILL, alpha=12))
        self.setPen(getNoPen())
        self.setZValue(styles.ZWORKPLANE)

        self._model_part = model_part
        self._part_item = part_item

        self._low_drag_bound = 0  # idx, not pos
        self._high_drag_bound = model_part.getProperty('max_vhelix_length')  # idx, not pos
        self._moving_via_handle = False

        self.outline = PathWorkplaneOutline(self)
        self.resize_handle_group = ResizeHandleGroup(self.rect(),
                                                     self._HANDLE_SIZE,
                                                     styles.BLUE_STROKE,
                                                     True,
                                                     HandleEnum.LEFT | HandleEnum.RIGHT,
                                                     self,
                                                     translates_in=AxisEnum.X)

        # Minimum size hint (darker internal rect, visible during resizing)
        self.model_bounds_hint = m_b_h = QGraphicsRectItem(self)
        m_b_h.setBrush(getBrushObj(styles.BLUE_FILL, alpha=64))
        m_b_h.setPen(getNoPen())
        m_b_h.hide()

        # Low and high idx labels
        self.resize_handle_group.updateText(HandleEnum.LEFT, self._idx_low)
        self.resize_handle_group.updateText(HandleEnum.RIGHT, self._idx_high)
예제 #41
0
    def __init__(self, is_fwd, pre_xover_item):
        """Summary

        Args:
            is_fwd (TYPE): Description
            color (TYPE): Description
            pre_xover_item (TYPE): Description
        """
        super(QGraphicsSimpleTextItem, self).__init__(pre_xover_item)
        self.is_fwd = is_fwd
        self._tbr = None
        self._outline = QGraphicsRectItem(self)
        self.setFont(self._XO_FONT)
        self.setBrush(getBrushObj('#666666'))
예제 #42
0
    def configurePath(self):
        """
        """
        self._path_thing.setBrush(getBrushObj(_PENCIL_COLOR))
        path = PPR3 if self.is_forward else PPL3
        offset = -_BASE_WIDTH if self.is_forward else _BASE_WIDTH
        self._path_thing.setPath(path)
        self._path_thing.setPos(offset, 0)

        offset = -_BASE_WIDTH if self.is_forward else 0
        self._blank_thing.setPos(offset, 0)

        self._blank_thing.show()
        self._path_thing.show()
예제 #43
0
    def configurePath(self):
        """
        """
        self._path_thing.setBrush(getBrushObj(_PENCIL_COLOR))
        path = PPR3 if self.is_forward else PPL3
        offset = -_BASE_WIDTH if self.is_forward else _BASE_WIDTH
        self._path_thing.setPath(path)
        self._path_thing.setPos(offset, 0)

        offset = -_BASE_WIDTH if self.is_forward else 0
        self._blank_thing.setPos(offset, 0)

        self._blank_thing.show()
        self._path_thing.show()
예제 #44
0
    def __init__(self, width, color, is_resizable, parent):
        super(GrabCornerItem, self).__init__(parent)
        self.setRect(QRectF(0, 0, width, width))
        self.width = width
        self.half_width = width/2
        self.offset = QPointF(width, width)
        self.offset_x = QPointF(width, 0)
        self.offset_y = QPointF(0, width)

        self.is_grabbing = False
        self.setBrush(getBrushObj(color))
        self.is_resizable = is_resizable
        self.model_bounds = ()
        self.corner_type = TOP_LEFT
예제 #45
0
 def showCreateHint(self, id_num: int = 0,
                         show_hint: bool = True,
                         color: str = None):
     label = self._label
     if show_hint:
         label.setText("%d" % id_num)
         b_rect = label.boundingRect()
         posx = b_rect.width()/2
         posy = b_rect.height()/2
         label.setPos(_RADIUS-posx, _RADIUS-posy)
         self.setBrush(getBrushObj(color if color else styles.MULTI_VHI_HINT_COLOR, alpha=64))
     else:
         label.setText("")
         self.setBrush(getNoBrush())
예제 #46
0
    def __init__(self, width, color, is_resizable, parent):
        super(GrabCornerItem, self).__init__(parent)
        self.setRect(QRectF(0, 0, width, width))
        self.width = width
        self.half_width = width / 2
        self.offset = QPointF(width, width)
        self.offset_x = QPointF(width, 0)
        self.offset_y = QPointF(0, width)

        self.is_grabbing = False
        self.setBrush(getBrushObj(color))
        self.is_resizable = is_resizable
        self.model_bounds = ()
        self.corner_type = TOP_LEFT
    def __init__(self, part_instance: ObjectInstance, viewroot: PathRootItemT):
        """parent should always be ``PathRootItem``

        Args:
            part_instance:  ``ObjectInstance`` of the ``Part``
            viewroot: ``PathRootItem`` and parent object
        """
        super(PathNucleicAcidPartItem, self).__init__(part_instance, viewroot)
        self.setAcceptHoverEvents(True)

        self._getActiveTool = viewroot.manager.activeToolGetter
        self.active_virtual_helix_item: PathVirtualHelixItem = None
        m_p = self._model_part
        self._controller = NucleicAcidPartItemController(self, m_p)
        self.prexover_manager: PreXoverManager = PreXoverManager(self)
        self._virtual_helix_item_list = []
        self._initModifierRect()
        self._proxy_parent = ProxyParentItem(self)
        self._proxy_parent.setFlag(QGraphicsItem.ItemHasNoContents)
        self._scale_2_model: float = m_p.baseWidth() / _BASE_WIDTH
        self._scale_2_Qt: float = _BASE_WIDTH / m_p.baseWidth()

        self._vh_rect: QRectF = QRectF()
        self.setPen(getNoPen())

        self.outline: PathRectItem = PathRectItem(self)
        outline = self.outline
        outline.setFlag(QGraphicsItem.ItemStacksBehindParent)
        self.setZValue(styles.ZPART)
        self._proxy_parent.setZValue(styles.ZPART)
        outline.setZValue(styles.ZDESELECTOR)
        self.outline.setPen(getPenObj(m_p.getColor(), _DEFAULT_WIDTH))
        o_rect = self._configureOutline(outline)
        model_color = m_p.getColor()

        self.resize_handle_group: ResizeHandleGroup = ResizeHandleGroup(
            o_rect,
            _HANDLE_SIZE,
            model_color,
            True,
            # HandleEnum.LEFT |
            HandleEnum.RIGHT,
            self)

        self.model_bounds_hint = m_b_h = QGraphicsRectItem(self)
        m_b_h.setBrush(getBrushObj(styles.BLUE_FILL, alpha=32))
        m_b_h.setPen(getNoPen())
        m_b_h.hide()

        self.hide()  # show on adding first vh
예제 #48
0
    def __init__(self,  part_instance: ObjectInstance,
                        viewroot: PathRootItemT):
        """parent should always be ``PathRootItem``

        Args:
            part_instance:  ``ObjectInstance`` of the ``Part``
            viewroot: ``PathRootItem`` and parent object
        """
        super(PathNucleicAcidPartItem, self).__init__(part_instance, viewroot)
        self.setAcceptHoverEvents(True)

        self._getActiveTool = viewroot.manager.activeToolGetter
        self.active_virtual_helix_item: PathVirtualHelixItem = None
        m_p = self._model_part
        self._controller = NucleicAcidPartItemController(self, m_p)
        self.prexover_manager: PreXoverManager = PreXoverManager(self)
        self._virtual_helix_item_list = []
        self._initModifierRect()
        self._proxy_parent = ProxyParentItem(self)
        self._proxy_parent.setFlag(QGraphicsItem.ItemHasNoContents)
        self._scale_2_model: float = m_p.baseWidth()/_BASE_WIDTH
        self._scale_2_Qt: float = _BASE_WIDTH / m_p.baseWidth()

        self._vh_rect: QRectF = QRectF()
        self.setPen(getNoPen())

        self.outline: PathRectItem = PathRectItem(self)
        outline = self.outline
        outline.setFlag(QGraphicsItem.ItemStacksBehindParent)
        self.setZValue(styles.ZPART)
        self._proxy_parent.setZValue(styles.ZPART)
        outline.setZValue(styles.ZDESELECTOR)
        self.outline.setPen(getPenObj(m_p.getColor(), _DEFAULT_WIDTH))
        o_rect = self._configureOutline(outline)
        model_color = m_p.getColor()

        self.resize_handle_group: ResizeHandleGroup = ResizeHandleGroup(
                                                        o_rect, _HANDLE_SIZE,
                                                        model_color, True,
                                                        # HandleEnum.LEFT |
                                                        HandleEnum.RIGHT,
                                                        self)

        self.model_bounds_hint = m_b_h = QGraphicsRectItem(self)
        m_b_h.setBrush(getBrushObj(styles.BLUE_FILL, alpha=32))
        m_b_h.setPen(getNoPen())
        m_b_h.hide()

        self.hide()  # show on adding first vh
예제 #49
0
    def enableActive(self, is_active, to_vh_id_num=None):
        """Call on PreXoverItems created on the active VirtualHelixItem

        Args:
            is_active (TYPE): Description
            to_vh_id_num (None, optional): Description
        """
        if is_active:
            self.to_vh_id_num = to_vh_id_num
            self.setAcceptHoverEvents(True)
            if to_vh_id_num is None:
                self.setLabel(text=None)
                self.setBrush(getBrushObj(self._color, alpha=0))
            else:
                self.setLabel(text=str(to_vh_id_num))
                inactive_alpha = PROX_ALPHA
                self.setBrush(getBrushObj(self._color, alpha=inactive_alpha))
                self.animate(self, 'brush_alpha', 1000, 128, inactive_alpha)
                self.setFlag(KEYINPUT_ACTIVE_FLAG, True)
        else:
            self.setBrush(getNoBrush())
            # self.setLabel(text=None)
            self.setAcceptHoverEvents(False)
            self.setFlag(KEYINPUT_ACTIVE_FLAG, False)
예제 #50
0
    def __init__(self, is_fwd, color, pre_xover_item):
        """Summary

        Args:
            is_fwd (TYPE): Description
            color (TYPE): Description
            pre_xover_item (TYPE): Description
        """
        super(QGraphicsSimpleTextItem, self).__init__(pre_xover_item)
        self.is_fwd = is_fwd
        self._color = color
        self._tbr = None
        self._outline = QGraphicsRectItem(self)
        self.setFont(self._XO_FONT)
        self.setBrush(getBrushObj('#666666'))
예제 #51
0
    def enableActive(self, is_active, to_vh_id_num=None):
        """Call on PreXoverItems created on the active VirtualHelixItem

        Args:
            is_active (TYPE): Description
            to_vh_id_num (None, optional): Description
        """
        if is_active:
            self.to_vh_id_num = to_vh_id_num
            self.setAcceptHoverEvents(True)
            if to_vh_id_num is None:
                self.setLabel(text=None)
                self.setBrush(getBrushObj(self._color, alpha=0))
            else:
                self.setLabel(text=str(to_vh_id_num))
                inactive_alpha = PROX_ALPHA
                self.setBrush(getBrushObj(self._color, alpha=inactive_alpha))
                self.animate(self, 'brush_alpha', 1000, 128, inactive_alpha)
                self.setFlag(KEYINPUT_ACTIVE_FLAG, True)
        else:
            self.setBrush(getNoBrush())
            # self.setLabel(text=None)
            self.setAcceptHoverEvents(False)
            self.setFlag(KEYINPUT_ACTIVE_FLAG, False)
예제 #52
0
 def paint(self, painter: QPainter,
                 option: QStyleOptionViewItem,
                 model_index: QModelIndex):
     """
     Args:
         painter: Description
         option: Description
         model_index: Description
     """
     # row = model_index.row()
     column = model_index.column()
     if column == 0:  # Part Name
         option.displayAlignment = Qt.AlignVCenter
         QStyledItemDelegate.paint(self, painter, option, model_index)
     if column == 1:  # Visibility
         value = model_index.model().data(model_index, Qt.EditRole)
         data_type = type(value)
         if data_type is str:
             # print("val", value)
             if COLOR_PATTERN.search(value):
                 # print("found color")
                 element = _QCOMMONSTYLE.PE_IndicatorCheckBox
                 styleoption = QStyleOptionViewItem()
                 styleoption.palette.setBrush(QPalette.Button, getBrushObj(value))
                 styleoption.rect = QRect(option.rect)
                 _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
             option.displayAlignment = Qt.AlignVCenter
             QStyledItemDelegate.paint(self, painter, option, model_index)
         elif data_type is int:
             option.displayAlignment = Qt.AlignVCenter
             QStyledItemDelegate.paint(self, painter, option, model_index)
         elif data_type is float:
             option.displayAlignment = Qt.AlignVCenter
             QStyledItemDelegate.paint(self, painter, option, model_index)
         elif data_type is bool:
             element = _QCOMMONSTYLE.PE_IndicatorCheckBox
             styleoption = QStyleOptionButton()
             styleoption.rect = QRect(option.rect)
             checked = value
             styleoption.state |= QStyle.State_On if checked else QStyle.State_Off
             styleoption.palette.setBrush(QPalette.Button, Qt.white)
             styleoption.palette.setBrush(QPalette.HighlightedText, Qt.black)
             _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
             if checked:
                 element = _QCOMMONSTYLE.PE_IndicatorMenuCheckMark
                 _QCOMMONSTYLE.drawPrimitive(element, styleoption, painter)
     else:
         QStyledItemDelegate.paint(self, painter, option, model_index)
예제 #53
0
 def _updateColor(self, strand):
     oligo = strand.oligo()
     color = SELECT_COLOR if self.isSelected() else oligo.getColor()
     if oligo.shouldHighlight():
         alpha = 128
         pen_width = styles.PATH_STRAND_HIGHLIGHT_STROKE_WIDTH
     else:
         pen_width = styles.PATH_STRAND_STROKE_WIDTH
         alpha = None
     self.xover_3p_end._updateColor(strand)
     pen = getPenObj(color, pen_width, alpha=alpha, capstyle=Qt.FlatCap)
     brush = getBrushObj(color, alpha=alpha)
     self.setPen(pen)
     self._low_cap.updateHighlight(brush)
     self._high_cap.updateHighlight(brush)
     self._dual_cap.updateHighlight(brush)
예제 #54
0
    def __init__(self, width, color, is_resizable, parent):
        super(GrabCornerItem, self).__init__(parent)
        self.setRect(QRectF(0, 0, width, width))
        self.width = width
        self.half_width = width/2
        self.offset = QPointF(width, width)
        self.offset_x = QPointF(width, 0)
        self.offset_y = QPointF(0, width)
        self.align_offset = self.parentItem()._BOUNDING_RECT_PADDING

        self.is_grabbing = False
        self.setBrush(getBrushObj(FILL_COLOR))
        self.setPen(getPenObj(color, 0))
        self.is_resizable = is_resizable
        self.model_bounds = ()
        self.corner_type = TOP_LEFT
예제 #55
0
    def shutdown(self):
        """Summary

        Returns:
            TYPE: Description
        """
        self.setBrush(getBrushObj(self._color, alpha=0))
        self.to_vh_id_num = None
        self.adapter.resetAnimations()
        phos = self._phos_item
        phos.adapter.resetAnimations()
        phos.resetTransform()
        phos.setPos(0, 0)
        self.setAcceptHoverEvents(False)
        self.setFlag(KEYINPUT_ACTIVE_FLAG, False)
        self.hide()
예제 #56
0
 def _updateColor(self, strand):
     oligo = strand.oligo()
     color = SELECT_COLOR if self.isSelected() else oligo.getColor()
     if oligo.shouldHighlight():
         alpha = 128
         pen_width = styles.PATH_STRAND_HIGHLIGHT_STROKE_WIDTH
     else:
         pen_width = styles.PATH_STRAND_STROKE_WIDTH
         alpha = None
     self.xover_3p_end._updateColor(strand)
     pen = getPenObj(color, pen_width, alpha=alpha, capstyle=Qt.FlatCap)
     brush = getBrushObj(color, alpha=alpha)
     self.setPen(pen)
     self._low_cap.updateHighlight(brush)
     self._high_cap.updateHighlight(brush)
     self._dual_cap.updateHighlight(brush)
예제 #57
0
    def configurePath(self):
        """Summary

        Returns:
            TYPE: Description
        """
        self._path_thing.setBrush(getBrushObj(_PENCIL_COLOR))
        path = PPL5 if self.is_forward else PPR5
        offset = _BASE_WIDTH if self.is_forward else -_BASE_WIDTH
        self._path_thing.setPath(path)
        self._path_thing.setPos(offset, 0)

        offset = 0 if self.is_forward else -_BASE_WIDTH
        self._blank_thing.setPos(offset, 0)

        self._blank_thing.show()
        self._path_thing.show()