Example #1
0
class SkipTool(AbstractPathTool):
    def __init__(self, controller, parent=None):
        """
        This class inherits from the PathTool class for the majority of
        methods/behaviours.  Essentially it adds merely decorator graphics
        custimazation of behaviour and data structure access particular to
        skip insertion on a mouseclick.

        Its parent should be *always* be a PathHelix.
        """
        super(SkipTool, self).__init__(controller, parent)
        self._skipItem = SkipItem()
        _pen = QPen(styles.redstroke, 2)
        self.baseWidth = styles.PATH_BASE_WIDTH
        self.hide()
        self.setZValue(styles.ZPATHTOOL)
    # end def

    def paint(self, painter, option, widget=None):
        painter.setPen(self._pen)
        painter.setBrush(self._brush)
        painter.drawRect(self._toolRect)
        painter.setPen(self._skipItem.getPen())
        painter.drawPath(self._skipItem.getSkip())
    # end def

    def mousePressPathHelix(self, pathHelix, event):
        vh = pathHelix.vhelix()
        posScene = pathHelix.mapToScene(QPointF(event.pos()))
        posItem = pathHelix.mapFromScene(posScene)
        indexp = self.helixIndex(posItem)
        mouseDownBase = pathHelix.baseAtLocation(posItem.x(), posItem.y())
        if mouseDownBase:
            loopsize = vh.hasLoopOrSkipAt(*mouseDownBase)
            if loopsize > 0:    # toggle from loop
                vh.installLoop(mouseDownBase[0],mouseDownBase[1],-1)
            elif loopsize < 0:    # skip already there
                vh.installLoop(mouseDownBase[0],mouseDownBase[1],0)
            elif vh.hasStrandAt(*mouseDownBase):
                vh.installLoop(mouseDownBase[0],mouseDownBase[1],-1)
            pathHelix.makeSelfActiveHelix()
Example #2
0
    def __init__(self, controller, parent=None):
        """
        This class inherits from the PathTool class for the majority of
        methods/behaviours.  Essentially it adds merely decorator graphics
        custimazation of behaviour and data structure access particular to
        skip insertion on a mouseclick.

        Its parent should be *always* be a PathHelix.
        """
        super(SkipTool, self).__init__(controller, parent)
        self._skipItem = SkipItem()
        _pen = QPen(styles.redstroke, 2)
        self.baseWidth = styles.PATH_BASE_WIDTH
        self.hide()
        self.setZValue(styles.ZPATHTOOL)