当前位置: 首页>>代码示例>>Python>>正文


Python QtWidgets.QGraphicsLineItem类代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsLineItem的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsLineItem类的具体用法?Python QGraphicsLineItem怎么用?Python QGraphicsLineItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QGraphicsLineItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_clearance_graph

 def add_clearance_graph(self):
     print("-----------------------------------------")
     horizontal_clearance = self.clearance_analysis.horizontal_clearance
     x_init = self.graph_zero[0] + self.line_extend
     y_init = self.graph_zero[1]
     for i in range(len(horizontal_clearance)):
         clearance_points = horizontal_clearance[i]
         x = x_init + i * self.dimension_analysis.section_distance * self.length_multiplier
         left = -self.dimension_analysis.domain_length
         right = self.dimension_analysis.domain_length
         if clearance_points[0]:
             left = clearance_points[0]
         if clearance_points[1]:
             right = clearance_points[1]
         clearance = right - left
         y_top = y_init + left * self.height_multiplier
         y_bottom = y_init + right * self.height_multiplier
         pen_red = QPen()
         red = Color.create_qcolor_from_rgb_tuple(Color.red)
         pen_red.setColor(red)
         pen_green = QPen()
         green = Color.create_qcolor_from_rgb_tuple(Color.green)
         pen_green.setColor(green)
         line = QGraphicsLineItem(x, y_top, x, y_bottom)
         if clearance < self.min_horizontal_clearance:
             line.setPen(pen_red)
         else:
             line.setPen(pen_green)
         self.addToGroup(line)
     pass
开发者ID:johanesmikhael,项目名称:ContinuityAnalysis,代码行数:30,代码来源:analysis_component.py

示例2: __init__

    def __init__(self, source, dest, id, graphicsGraphView):
        # Parent constructor(s)
        GraphicsEdge.__init__(self, source, dest, id, graphicsGraphView)
        QGraphicsLineItem.__init__(self)

        self.setFlag(QGraphicsItem.ItemIsSelectable)
        self.update()
开发者ID:pydoted,项目名称:dotEd,代码行数:7,代码来源:GraphicsLineEdge.py

示例3: __init__

    def __init__(self, shape):
        QGraphicsLineItem.__init__(self)
        StMove.__init__(self, shape)

        self.allwaysshow = False
        self.path = QPainterPath()

        self.setFlag(QGraphicsItem.ItemIsSelectable, False)

        self.pen = QPen(QColor(50, 100, 255), 1, QtCore.Qt.SolidLine,
                        QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)
        self.pen.setCosmetic(True)
        self.make_papath()
开发者ID:opme,项目名称:dxf2gcode,代码行数:13,代码来源:canvas2d.py

示例4: generateData

 def generateData(self, canvas, lines, params):
     scene = QGraphicsScene()
     scene.setSceneRect(canvas)
     group = scene.createItemGroup([])
     for line in lines:
         clone = QGraphicsLineItem(line)
         clone.setLine(line.line())
         clone.setPen(line.pen())
         scene.addItem(clone)
         group.addToGroup(clone)
     pixmaps = []
     for i in xrange(params.count):
         pixmaps.append(self.generateRandom(scene, group, canvas, params))
     return pixmaps
开发者ID:xsyann,项目名称:mediocre,代码行数:14,代码来源:dataset.py

示例5: __init__

    def __init__(self, startNode, endNode):
        QGraphicsLineItem.__init__(self)
        self.setPen(QPen())

        self.startNode = startNode
        self.endNode = endNode

        self.startNode.addObserver(self)

        startShape = self.startNode.mapToScene(self.startNode.shape())

        p1 = closestPointTo(self.endNode, startShape)
                
        self.setLine(QLineF(p1, self.endNode))
开发者ID:MatthieuDien,项目名称:DotEd,代码行数:14,代码来源:edge.py

示例6: __init__

    def __init__(self, manager):
        """Summary

        Args:
            manager (TYPE): Description
        """
        super(AbstractSliceTool, self).__init__(parent=manager.viewroot)
        """ Pareting to viewroot to prevent orphan _line_item from occuring
        """
        self.sgv = None
        self.manager = manager
        self._active = False
        self._last_location = None
        self._line_item = QGraphicsLineItem(self)
        self._line_item.hide()
        self._vhi = None

        self.hide()
        self.is_started = False
        self.angles = [math.radians(x) for x in range(0, 360, 30)]
        self.vectors = self.setVectors()
        self.part_item = None

        self.vhi_hint_item = QGraphicsEllipseItem(_DEFAULT_RECT, self)
        self.vhi_hint_item.setPen(_MOD_PEN)
        self.vhi_hint_item.setZValue(styles.ZPARTITEM)
开发者ID:hadim,项目名称:cadnano2.5,代码行数:26,代码来源:abstractslicetool.py

示例7: mousePressEvent

    def mousePressEvent(self, mouseEvent):
        if (mouseEvent.button() != Qt.LeftButton):
            return

        if self.myMode == self.InsertItem:
            item = DiagramItem(self.myItemType, self.myItemMenu)
            item.setBrush(self.myItemColor)
            self.addItem(item)
            item.setPos(mouseEvent.scenePos())
            self.itemInserted.emit(item)
        elif self.myMode == self.InsertLine:
            self.line = QGraphicsLineItem(QLineF(mouseEvent.scenePos(),
                    mouseEvent.scenePos()))
            self.line.setPen(QPen(self.myLineColor, 2))
            self.addItem(self.line)
        elif self.myMode == self.InsertText:
            textItem = DiagramTextItem()
            textItem.setFont(self.myFont)
            textItem.setTextInteractionFlags(Qt.TextEditorInteraction)
            textItem.setZValue(1000.0)
            textItem.lostFocus.connect(self.editorLostFocus)
            textItem.selectedChange.connect(self.itemSelected)
            self.addItem(textItem)
            textItem.setDefaultTextColor(self.myTextColor)
            textItem.setPos(mouseEvent.scenePos())
            self.textInserted.emit(textItem)

        super(DiagramScene, self).mousePressEvent(mouseEvent)
开发者ID:Axel-Erfurt,项目名称:pyqt5,代码行数:28,代码来源:diagramscene.py

示例8: mousePressEvent

    def mousePressEvent(self, mouse_event):

        if mouse_event.button() != Qt.LeftButton:
            return
        if self.my_mode == self.InsertItem:
            x = mouse_event.scenePos().x()  # // 50 * 50
            y = mouse_event.scenePos().y()  # // 50 * 50
            item = self.insert_item(self.my_item_type, x, y)
            self.itemInserted.emit(item.flume_component)
        elif self.my_mode == self.InsertLine:
            self.line = QGraphicsLineItem(QLineF(mouse_event.scenePos(),
                                                 mouse_event.scenePos()))
            self.line.setPen(QPen(self.my_line_color, 2))
            self.addItem(self.line)
        elif self.my_mode == self.InsertText:
            text_item = DiagramTextItem()
            text_item.setFont(self.my_font)
            text_item.setTextInteractionFlags(Qt.TextEditorInteraction)
            text_item.setZValue(1000.0)
            text_item.lostFocus.connect(self.editor_lost_focus)
            # text_item.selectedChange.connect(self.itemSelected)
            self.addItem(text_item)
            text_item.setDefaultTextColor(self.my_text_color)
            text_item.setPos(mouse_event.scenePos())
            self.textInserted.emit(text_item)
        else:
            self.m_dragged = QGraphicsScene.itemAt(self, mouse_event.scenePos(), QTransform())
            if self.m_dragged:
                self.my_mode = self.MoveItem
                self.m_drag_offset = mouse_event.scenePos() - self.m_dragged.pos()

        super(DiagramScene, self).mousePressEvent(mouse_event)
开发者ID:ADobrodey,项目名称:Apache-Flume-Editor,代码行数:32,代码来源:_diagram_scene.py

示例9: ParticipantItem

class ParticipantItem(QGraphicsItem):
    def __init__(self, model_item: Participant, parent=None):
        super().__init__(parent)

        self.model_item = model_item

        self.text = QGraphicsTextItem(self)

        self.line = QGraphicsLineItem(self)
        self.line.setPen(QPen(Qt.darkGray, 1, Qt.DashLine, Qt.RoundCap, Qt.RoundJoin))

        self.refresh()

    def update_position(self, x_pos=-1, y_pos=-1):
        if x_pos == -1:
            x_pos = self.x_pos()

        if y_pos == -1:
            y_pos = self.line.line().y2()

        self.text.setPos(x_pos - (self.text.boundingRect().width() / 2), 0)
        self.line.setLine(x_pos, 30, x_pos, y_pos)

    def x_pos(self):
        return self.line.line().x1()

    def width(self):
        return self.boundingRect().width()

    def refresh(self):
        self.text.setPlainText("?" if not self.model_item else self.model_item.shortname)
        if hasattr(self.model_item, "simulate") and self.model_item.simulate:
            font = QFont()
            font.setBold(True)
            self.text.setFont(font)
            self.text.setDefaultTextColor(Qt.darkGreen)
            self.line.setPen(QPen(Qt.darkGreen, 2, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        else:
            self.text.setFont(QFont())
            self.text.setDefaultTextColor(constants.LINECOLOR)
            self.line.setPen(QPen(Qt.darkGray, 1, Qt.DashLine, Qt.RoundCap, Qt.RoundJoin))

    def boundingRect(self):
        return self.childrenBoundingRect()

    def paint(self, painter, option, widget):
        pass
开发者ID:jopohl,项目名称:urh,代码行数:47,代码来源:ParticipantItem.py

示例10: drawNewFence

    def drawNewFence(self, fps):
        self.clearFencePoints()

        prev_fp = None
        for i in range(1, len(fps)):
            if prev_fp is not None:
                prev_x = prev_fp.lon
                prev_y = -prev_fp.lat
                mapped_x = fps[i].lon
                mapped_y = -fps[i].lat

                next_line = QGraphicsLineItem(prev_x, prev_y, 
                    mapped_x, mapped_y, self.__fence_layer)
                l_pen = QPen(QColor(0, 255, 0))
                l_pen.setWidth(0.1)
                next_line.setPen(l_pen)
                self.__fence_layer.addToGroup(next_line)

            prev_fp = fps[i]
开发者ID:dtdavi1,项目名称:acs_dashboards,代码行数:19,代码来源:mapWidgetWrapper.py

示例11: createOriginLine

 def createOriginLine(self):
     if self.originLine == None:
         self.originLine = QGraphicsLineItem(self.midPointX, self.midPointY, self.graphicsOrigin.scenePos().x(),
                                             self.graphicsOrigin.scenePos().y(), self)
     else:
         self.originLine.setLine(QLineF(self.midPointX, self.midPointY, self.graphicsOrigin.scenePos().x(),
                                        self.graphicsOrigin.scenePos().y()))
     myLine = self.originLine.line()
     myLine.setLength(myLine.length() - StateGraphicsItem.NODE_WIDTH / 2)
     self.originLine.setLine(myLine)
开发者ID:Diegojnb,项目名称:JdeRobot,代码行数:10,代码来源:guitransition.py

示例12: __init__

    def __init__(self, model_item: Participant, parent=None):
        super().__init__(parent)

        self.model_item = model_item

        self.text = QGraphicsTextItem(self)

        self.line = QGraphicsLineItem(self)
        self.line.setPen(QPen(Qt.darkGray, 1, Qt.DashLine, Qt.RoundCap, Qt.RoundJoin))

        self.refresh()
开发者ID:jopohl,项目名称:urh,代码行数:11,代码来源:ParticipantItem.py

示例13: __init__

    def __init__(self):
        super().__init__()

        self.center_x = 0
        self.center_y = 0
        self.radius = 1

        self.now = datetime.utcfromtimestamp(0)

        # build the clock face
        self.circle = QGraphicsEllipseItem(self.root)

        self.lines = []
        for _ in range(0, 60):
            self.lines.append(QGraphicsLineItem(self.root))

        self.hours_hand = QGraphicsLineItem(self.root)
        self.minutes_hand = QGraphicsLineItem(self.root)
        self.seconds_hand = QGraphicsLineItem(self.root)

        self.hand_circle = QGraphicsEllipseItem(self.root)
开发者ID:Grumbel,项目名称:clockgr,代码行数:21,代码来源:analog_clock.py

示例14: moveTo

    def moveTo(self, pos):
        # data coordinates
        oldX, oldY = self.pos.x(), self.pos.y()
        x, y = pos.x(), pos.y()

        line = QGraphicsLineItem(oldX, oldY, x, y)
        line.setPen(QPen(QBrush(Qt.white), self.brushSize, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        self.scene.addItem(line)
        self._hasMoved = True

        # update bounding Box
        if not self.bb.isValid():
            self.bb = QRect(QPoint(oldX, oldY), QSize(1, 1))
        # grow bounding box
        self.bb.setLeft(min(self.bb.left(), max(0, x - self.brushSize // 2 - 1)))
        self.bb.setRight(max(self.bb.right(), min(self.sliceRect[0] - 1, x + self.brushSize // 2 + 1)))
        self.bb.setTop(min(self.bb.top(), max(0, y - self.brushSize // 2 - 1)))
        self.bb.setBottom(max(self.bb.bottom(), min(self.sliceRect[1] - 1, y + self.brushSize // 2 + 1)))

        # update/move position
        self.pos = pos
开发者ID:ilastik,项目名称:volumina,代码行数:21,代码来源:brushingmodel.py

示例15: drawWPLine

    def drawWPLine(self, wp1, wp2):
        if wp1 is None or wp2 is None:
            print("Error: Can't draw line for Null endpoint")
            return
    
        rad = self.__wp_diameter * 0.5
        mapped_wp1_x = wp1.y - rad
        mapped_wp1_y = -wp1.x
        #tangential approach?
        if (wp1.command == mavutil.mavlink.MAV_CMD_NAV_LOITER_TO_ALT
                and wp1.param1 == 1.0):
            l_rad = abs(self.__wp_loiter_radius)
            if l_rad is not None:
                dis = acs_math.gps_distance(wp1.x, wp1.y, wp2.x, wp2.y)
                theta = math.degrees(math.atan(l_rad / dis))

                #sign of self.__wp_loiter_radius indicates the direction of the
                #loiter (negative is counter-clockwise, postive is clockwise)
                #Also, the waypoint itself can override the default setting
                #via param2
                if ((wp1.param2 == 0 and self.__wp_loiter_radius > 0.0) or
                     wp1.param2 > 0.0):
                    theta = -theta

                tan_dis = math.sqrt( dis * dis - l_rad * l_rad)
                bearing = acs_math.gps_bearing(wp2.x, wp2.y, wp1.x, wp1.y)

                (tan_wp_x, tan_wp_y) = acs_math.gps_newpos(wp2.x, wp2.y,
                    bearing - theta, tan_dis)

                mapped_wp1_x = tan_wp_y - rad
                mapped_wp1_y = -tan_wp_x

        next_line = QGraphicsLineItem(mapped_wp1_x, mapped_wp1_y,
                            wp2.y - rad, -wp2.x, self.__mission_layer)
        l_pen = QPen(QColor(255, 255, 255))
        l_pen.setWidth(0.00002)
        next_line.setPen(l_pen)
        self.__mission_layer.addToGroup(next_line)
开发者ID:dtdavi1,项目名称:acs_dashboards,代码行数:39,代码来源:mapWidgetWrapper.py


注:本文中的PyQt5.QtWidgets.QGraphicsLineItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。