示例#1
0
    def __init__(self, port_mode, port_type, parent):
        QGraphicsPathItem.__init__(self)
        self.setParentItem(parent)

        self.m_port_mode = port_mode
        self.m_port_type = port_type

        # Port position doesn't change while moving around line
        self.p_itemX = self.scenePos().x()
        self.p_itemY = self.scenePos().y()
        self.p_width = parent.getPortWidth()

        if port_type == PORT_TYPE_AUDIO_JACK:
            pen = QPen(canvas.theme.line_audio_jack, 2)
        elif port_type == PORT_TYPE_MIDI_JACK:
            pen = QPen(canvas.theme.line_midi_jack, 2)
        elif port_type == PORT_TYPE_MIDI_ALSA:
            pen = QPen(canvas.theme.line_midi_alsa, 2)
        elif port_type == PORT_TYPE_PARAMETER:
            pen = QPen(canvas.theme.line_parameter, 2)
        else:
            qWarning(
                "PatchCanvas::CanvasBezierLineMov({}, {}, {}) - invalid port type"
                .format(port_mode2str(port_mode), port_type2str(port_type),
                        parent))
            pen = QPen(Qt.black)

        pen.setCapStyle(Qt.FlatCap)
        pen.setWidthF(pen.widthF() + 0.00001)
        self.setPen(pen)
示例#2
0
    def __init__(self, point=QPointF(0,0), parent=None, scene=None,\
                 brush=QBrush(Qt.white, Qt.SolidPattern),\
                 pen=QPen(Qt.black, 2, Qt.SolidLine),\
                 orient='v', rsize=7) :

        self._lst_circle = None

        path = self.pathForPointV(point, scene, rsize) if orient=='v' else\
               self.pathForPointH(point, scene, rsize) if orient=='h' else\
               self.pathForPointR(point, scene, rsize)

        QGraphicsPathItem.__init__(self, path, parent)
        if scene is not None: scene.addItem(self)

        DragBase.__init__(self, parent, brush, pen)

        self.setAcceptHoverEvents(True)
        self.setAcceptTouchEvents(True)
        #self.setAcceptedMouseButtons(Qt.LeftButton)

        self.setPen(self._pen_pos)
        self.setBrush(self._brush)
        self.setFlags(self.ItemIsSelectable | self.ItemIsMovable)

        #self.setBoundingRegionGranularity(0.95)
        self._mode = ADD
示例#3
0
 def __init__(self, annotation_item, path, parent=None):
     """
     Extends PyQt5's QGraphicsPathItem to create the general structure of the Grabbable points for resizing shapes.
     """
     QGraphicsPathItem.__init__(self, parent)
     self.m_annotation_item = annotation_item
     # set path of item
     self.setPath(path)
     self.setAcceptHoverEvents(True)
     self.setCursor(QCursor(Qt.PointingHandCursor))
示例#4
0
    def __init__(self, item1, item2, parent):
        QGraphicsPathItem.__init__(self)
        self.setParentItem(parent)

        self.item1 = item1
        self.item2 = item2

        self.m_locked = False
        self.m_lineSelected = False

        self.setBrush(QColor(0, 0, 0, 0))
        self.setGraphicsEffect(None)
        self.updateLinePos()
示例#5
0
    def __init__(self, pituus, kulma, scene, sijainti = None, suunta = None):
        '''
        Luo uuden ratapalan, joko sen pituuden ja kulman avulla, jolloin pala lisätään edellisen perään, tai käyttäen koordinaatteja sijainti ja suunta.
        Tämän konstruktorin toiminta on hieman omalaatuinen, se on selitetty seikkaperäisesti työn dokumentissa.
        '''
        self.scene = scene
        self.kulma = kulma
        self.pituus = pituus
        
        self.pen = QPen(Qt.black, 2, Qt.SolidLine)
        
        if sijainti == None:
            self.sijainti = self.scene.jatkoPiste 
            
        else:
            self.sijainti = sijainti
            
        if suunta == None and sijainti == None:
        
            lx = self.pituus * math.cos(kulma)
            ly = self.pituus * math.sin(kulma)
            self.suunta = QPointF(lx,ly)
                
        else:             
            self.kulma = math.atan2(sijainti.y()-suunta.y(), sijainti.x()-suunta.x())
            self.pituus = math.sqrt((sijainti.x()-suunta.x())**2 + (sijainti.y()-suunta.y())**2) 
            self.suunta = suunta
            
        self.scene.jatkoPiste  = self.scene.jatkoPiste + self.suunta

        self.path = QPainterPath()
        
        
        self.path.lineTo(self.suunta) 
        
        '''
        # Jostain syystä käyrät ei ole ystäviä :(
        
        nelio= 	QRectF()
        nelio.setCoords(self.sijainti.x(), self.sijainti.y(), self.suunta.x(), self.suunta.y()-self.sijainti.y())
        self.path.arcTo(nelio, self.kulma, -self.kulma+math.pi) 
        '''
        
        QGraphicsPathItem.__init__(self, self.path )
        self.setPos(self.sijainti)

        self.setFlag( QGraphicsItem.ItemIsMovable, True)
        self.setFlag( QGraphicsItem.ItemIsSelectable, True)
        self.setAcceptDrops(True)
示例#6
0
    def __init__(self, **kwargs):
        QGraphicsPathItem.__init__(self, **kwargs)

        # pen
        pen = QPen(Qt.black, 1.5, Qt.SolidLine)
        pen.setCosmetic(True)  # thickness independent os scale
        self.setPen(pen)
        self.setBrush(QColor("lightYellow"))
        #self.setBrush(QColor("Magenta").darker(120))

        # move handling
        self.setFlag(QGraphicsItem.ItemIsMovable, True)
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        # needed to handle move event
        self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
        self.setAcceptHoverEvents(True)
示例#7
0
    def __init__(self, point=QPointF(0,0), parent=None, scene=None,\
                 brush=QBrush(Qt.white, Qt.SolidPattern),\
                 pen=QPen(Qt.black, 2, Qt.SolidLine),\
                 pshape='v', rsize=7) :
        """pshape (char) point shape: h-horizontal rectangular, v-rombic, r-radial (ellyptical)
        """

        self._lst_circle = None

        self._dragtype = POINT

        self.rsize = rsize
        self.point_center = point

        path = self.pathForPointV(point, scene, rsize) if pshape=='v' else\
               self.pathForPointH(point, scene, rsize) if pshape=='h' else\
               self.pathForPointW(point, scene, rsize) if pshape=='w' else\
               self.pathForPointZ(point, scene, rsize) if pshape=='z' else\
               self.pathForPointX(point, scene, rsize) if pshape=='x' else\
               self.pathForPointC(point, scene, rsize) if pshape=='c' else\
               self.pathForPointR(point, scene, rsize)

        #print('selected path', str(path))

        QGraphicsPathItem.__init__(self, path, parent)
        if (parent is None) and (scene is not None): scene.addItem(self)
        DragBase.__init__(self, parent, brush, pen)

        self.setTransformOriginPoint(point)

        #================
        #self.grabMouse()
        #================

        self.setAcceptHoverEvents(True)
        self.setAcceptTouchEvents(True)
        #self.setAcceptedMouseButtons(Qt.LeftButton)

        self.setPen(self._pen_pos)
        self.setBrush(self._brush)
        self.setFlags(self.ItemIsSelectable | self.ItemIsMovable)

        #self.setBoundingRegionGranularity(0.95)
        self._drag_mode = ADD
示例#8
0
    def __init__(self, model_virtual_helix, part_item, viewroot):
        """Summary

        Args:
            id_num (int): VirtualHelix ID number. See `NucleicAcidPart` for description and related methods.
            part_item (TYPE): Description
            viewroot (TYPE): Description
        """
        AbstractVirtualHelixItem.__init__(self, model_virtual_helix, part_item)
        QGraphicsPathItem.__init__(self, parent=part_item.proxy())
        self._viewroot = viewroot
        self._getActiveTool = part_item._getActiveTool
        self._controller = VirtualHelixItemController(self, self._model_part,
                                                      False, True)

        self._handle = VirtualHelixHandleItem(self, part_item, viewroot)
        self._last_strand_set = None
        self._last_idx = None
        self.setFlag(QGraphicsItem.ItemUsesExtendedStyleOption)
        self.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
        # self.setBrush(getNoBrush())
        # self.setBrush(getBrushObj(styles.BLUE_FILL, alpha=32))

        view = self.view()
        view.levelOfDetailChangedSignal.connect(self.levelOfDetailChangedSlot)
        should_show_details = view.shouldShowDetails()

        pen = newPenObj(styles.MINOR_GRID_STROKE,
                        styles.MINOR_GRID_STROKE_WIDTH)
        pen.setCosmetic(should_show_details)
        self.setPen(pen)

        self.is_active = False

        self.refreshPath()
        self.setAcceptHoverEvents(True)  # for pathtools
        self.setZValue(styles.ZPATHHELIX)

        self._right_mouse_move = False
        self.drag_last_position = self.handle_start = self.pos()
示例#9
0
文件: opl-tilt.py 项目: ybnd/opl-tilt
    def __init__(self, **kwargs):
        QGraphicsPathItem.__init__(self, **kwargs)

        self.setAcceptHoverEvents(True)
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        # Rays stay just below the source,
        # without any need to set Z-value explicitly
        # This avoid selection problems (ray is always behind handles)
        self.setFlag(QGraphicsItem.ItemStacksBehindParent, True)

        # pen for normal state
        self.pen_normal = QPen(Qt.blue, 1.5, Qt.SolidLine)
        self.pen_normal.setCosmetic(True)  # thickness does not scale
        self.setPen(self.pen_normal)
        # pen for hover state
        self.pen_hover = QPen(Qt.gray, 1.5, Qt.SolidLine)
        self.pen_hover.setCosmetic(True)  # thickness does not scale

        # will be used in shape()
        self.stroker = QPainterPathStroker()

        self._selected = False
示例#10
0
文件: Plot.py 项目: dani-l/PaPI
    def __init__(self, x, y, counter, pen=pg.mkPen('r')):
        """

        :param x:
        :param y:
        :param pen:
        :return:
        """

        x = np.array(x[:])[np.newaxis, :]

        connect = np.ones(x.shape, dtype=bool)
        connect[:,-1] = 0 # don't draw the segment between each trace
        self.path = pg.arrayToQPath(x.flatten(), y.flatten(), connect.flatten())
        QGraphicsPathItem.__init__(self, self.path)
        self.setCacheMode(QGraphicsItem.NoCache)
        self.setPen(pen)
        self.not_drawn = True
        self.counter = counter
        self.y = y
        self.last_x = x[0][-1]
        self.last_y = y[-1]
示例#11
0
文件: Plot.py 项目: TUB-Control/PaPI
    def __init__(self, x, y, counter, pen=pg.mkPen('r')):
        """

        :param x:
        :param y:
        :param pen:
        :return:
        """

        x = np.array(x[:])[np.newaxis, :]

        connect = np.ones(x.shape, dtype=bool)
        connect[:,-1] = 0 # don't draw the segment between each trace
        self.path = pg.arrayToQPath(x.flatten(), y.flatten(), connect.flatten())
        QGraphicsPathItem.__init__(self, self.path)
        self.setCacheMode(QGraphicsItem.NoCache)
        self.setPen(pen)
        self.not_drawn = True
        self.counter = counter
        self.y = y
        self.last_x = x[0][-1]
        self.last_y = y[-1]
示例#12
0
    def __init__(self, parent):
        QGraphicsPathItem.__init__(self, parent)
        if not isinstance(parent, LinkItem):
            raise TypeError("'LinkItem' expected")

        self.setAcceptedMouseButtons(Qt.NoButton)
        self.__canvasLink = parent
        self.setAcceptHoverEvents(True)

        self.shadow = QGraphicsDropShadowEffect(blurRadius=5,
                                                color=QColor(SHADOW_COLOR),
                                                offset=QPointF(0, 0))

        self.normalPen = QPen(QBrush(QColor("#9CACB4")), 2.0)
        self.hoverPen = QPen(QBrush(QColor("#7D7D7D")), 2.1)
        self.setPen(self.normalPen)
        self.setGraphicsEffect(self.shadow)
        self.shadow.setEnabled(False)

        self.__hover = False
        self.__enabled = True
        self.__shape = None
示例#13
0
    def __init__(self, model_virtual_helix, part_item, viewroot):
        """Summary

        Args:
            id_num (int): VirtualHelix ID number. See `NucleicAcidPart` for description and related methods.
            part_item (TYPE): Description
            viewroot (TYPE): Description
        """
        AbstractVirtualHelixItem.__init__(self, model_virtual_helix, part_item)
        QGraphicsPathItem.__init__(self, parent=part_item.proxy())
        self._viewroot = viewroot
        self._getActiveTool = part_item._getActiveTool
        self._controller = VirtualHelixItemController(self, self._model_part, False, True)

        self._handle = VirtualHelixHandleItem(self, part_item, viewroot)
        self._last_strand_set = None
        self._last_idx = None
        self.setFlag(QGraphicsItem.ItemUsesExtendedStyleOption)
        self.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
        self.setBrush(getNoBrush())

        view = self.view()
        view.levelOfDetailChangedSignal.connect(self.levelOfDetailChangedSlot)
        should_show_details = view.shouldShowDetails()

        pen = newPenObj(styles.MINOR_GRID_STROKE, styles.MINOR_GRID_STROKE_WIDTH)
        pen.setCosmetic(should_show_details)
        self.setPen(pen)

        self.is_active = False

        self.refreshPath()
        self.setAcceptHoverEvents(True)  # for pathtools
        self.setZValue(styles.ZPATHHELIX)

        self._right_mouse_move = False
        self.drag_last_position = self.handle_start = self.pos()
示例#14
0
    def __init__(self, port_mode, port_type, port_posinportgrp, portgrp_lenght,
                 parent):
        QGraphicsPathItem.__init__(self)
        self.setParentItem(parent)

        self.m_port_mode = port_mode
        self.m_port_type = port_type
        self.m_port_posinportgrp = port_posinportgrp
        self.m_port_posinportgrp_to = port_posinportgrp
        self.m_portgrp_lenght = portgrp_lenght
        self.m_portgrp_lenght_to = portgrp_lenght
        self.m_ready_to_disc = False

        # Port position doesn't change while moving around line
        self.p_itemX = self.scenePos().x()
        self.p_itemY = self.scenePos().y()
        self.p_width = parent.getPortWidth()

        if self.m_port_type not in (PORT_TYPE_AUDIO_JACK, PORT_TYPE_MIDI_JACK,
                                    PORT_TYPE_MIDI_ALSA, PORT_TYPE_PARAMETER):
            qWarning(
                "PatchCanvas::CanvasBezierLineMov(%s, %s, %s) - invalid port type"
                % (port_mode2str(self.m_port_mode),
                   port_type2str(self.m_port_type), self.parentItem()))
示例#15
0
 def __init__(self, parent=None):
     QGraphicsPathItem.__init__(self, parent)