Exemple #1
0
    def __init__(self, modelStrand, virtualHelixItem, viewroot):
        """The parent should be a VirtualHelixItem."""
        super(StrandItem, self).__init__(virtualHelixItem)
        self._modelStrand = modelStrand
        self._virtualHelixItem = virtualHelixItem
        self._viewroot = viewroot
        self._activeTool = virtualHelixItem.activeTool()

        self._controller = StrandItemController(self, modelStrand)
        isDrawn5to3 = modelStrand.strandSet().isDrawn5to3()

        self._strandFilter = modelStrand.strandFilter()

        self._insertionItems = {}
        # caps
        self._lowCap = EndpointItem(self, 'low', isDrawn5to3)
        self._highCap = EndpointItem(self, 'high', isDrawn5to3)
        self._dualCap = EndpointItem(self, 'dual', isDrawn5to3)

        # orientation
        self._isDrawn5to3 = isDrawn5to3
        # self._isOnTop = virtualHelixItem.isStrandOnTop(modelStrand)
        # label
        self._seqLabel = QGraphicsSimpleTextItem(self)

        self.refreshInsertionItems(modelStrand)
        self._updateSequenceText()

        # create a larger click area rect to capture mouse events
        self._clickArea = cA = QGraphicsRectItem(_defaultRect, self)
        cA.mousePressEvent = self.mousePressEvent
        cA.setPen(_noPen)
        self.setAcceptHoverEvents(True)
        cA.setAcceptHoverEvents(True)
        cA.hoverMoveEvent = self.hoverMoveEvent

        self.setZValue(styles.ZSTRANDITEM)

        # xover comming from the 3p end
        self._xover3pEnd = XoverItem(self, virtualHelixItem)
        # initial refresh
        self._updateColor(modelStrand)
        self._updateAppearance(modelStrand)

        self.setZValue(styles.ZSTRANDITEM)
        self.setFlag(QGraphicsItem.ItemIsSelectable)