Example #1
0
 def __init__(self, mID, modelStrand, virtualHelixItem):
     """
     The parent should be a VirtualHelixItem.
     Initialize function creates the Maya Node for the strand, and setups
     the lookup tables inside of mayaObjectManager (Mom) so that the Maya
     Node can be globally found given a strand, and the other way around.
     Also, sets up StrandItemController that is used to setup all the
     slots and signals between strand model and this strandItem.
     """
     self._modelStrand = modelStrand
     self._virtualHelixItem = virtualHelixItem
     self._viewroot = app().activeDocument.win.solidroot
     mayaNodeInfo = ()
     # print "solidview.StrandItem.__init__ %s" % mID
     if(modelStrand.strandSet().isScaffold()):
         mayaNodeInfo = self.createMayaHelixNodes(virtualHelixItem.x(),
                                                  virtualHelixItem.y(),
                                   modelStrand.oligo().color(),
                                   StrandType.SCAFFOLD,
                                   mID)
     else:
         mayaNodeInfo = self.createMayaHelixNodes(virtualHelixItem.x(),
                                                  virtualHelixItem.y(),
                                   modelStrand.oligo().color(),
                                   StrandType.STAPLE,
                                   mID)
     #self.onStrandDidMove(strand)
     m = Mom()
     m.cnToMaya[modelStrand] = mayaNodeInfo
     m.mayaToCn[mayaNodeInfo[2]] = modelStrand
     m.mayaToCn[mayaNodeInfo[0]] = modelStrand
     self.updateSize()
     self._controller = StrandItemController(self, modelStrand)
Example #2
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)