Python PyQt5.QtGui.QPolygonF() Examples

The following are 30 code examples of PyQt5.QtGui.QPolygonF(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .
Example #1
Source File: quickplotter.py    From phidl with MIT License 6 votes vote down vote up
def add_polygons(self, polygons, color = '#A8F22A', alpha = 1):
        qcolor = QColor()
        qcolor.setNamedColor(color)
        qcolor.setAlphaF(alpha)
        for points in polygons:
            qpoly = QPolygonF( [QPointF(p[0], p[1]) for p in points] )
            scene_poly = self.scene.addPolygon(qpoly)
            scene_poly.setBrush(qcolor)
            scene_poly.setPen(self.pen)
            self.scene_polys.append(scene_poly)
            # Update custom bounding box
            sr = scene_poly.sceneBoundingRect()
            if len(self.scene_polys) == 1:
                self.scene_xmin = sr.left()
                self.scene_xmax = sr.right()
                self.scene_ymin = sr.top()
                self.scene_ymax = sr.bottom()
            else:
                self.scene_xmin = min(self.scene_xmin, sr.left())
                self.scene_xmax = max(self.scene_xmax, sr.right())
                self.scene_ymin = min(self.scene_ymin, sr.top())
                self.scene_ymax = max(self.scene_ymax, sr.bottom()) 
Example #2
Source File: geographical_view.py    From pyNMS with GNU General Public License v3.0 6 votes vote down vote up
def draw_polygons(self):
        sf = shapefile.Reader(self.shapefile)       
        polygons = sf.shapes() 
        for polygon in polygons:
            # convert shapefile geometries into shapely geometries
            # to extract the polygons of a multipolygon
            polygon = shapely.geometry.shape(polygon)
            # if it is a polygon, we use a list to make it iterable
            if polygon.geom_type == 'Polygon':
                polygon = [polygon]
            for land in polygon:
                qt_polygon = QtGui.QPolygonF() 
                longitudes, latitudes = land.exterior.coords.xy
                for lon, lat in zip(longitudes, latitudes):
                    px, py = self.to_canvas_coordinates(lon, lat)
                    if px > 1e+10:
                        continue
                    qt_polygon.append(QtCore.QPointF(px, py))
                polygon_item = QtWidgets.QGraphicsPolygonItem(qt_polygon)
                polygon_item.setBrush(self.land_brush)
                polygon_item.setPen(self.land_pen)
                polygon_item.setZValue(1)
                yield polygon_item 
Example #3
Source File: common.py    From eddy with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, geometry=QtGui.QPolygonF(),
         brush=QtGui.QBrush(QtCore.Qt.NoBrush),
         pen=QtGui.QPen(QtCore.Qt.NoPen)):
        """
        Initialize the polygon.
        :type geometry: T <= QRectF|QtGui.QPolygonF|QPainterPath
        :type brush: QBrush
        :type pen: QPen
        """
        self._geometry = geometry
        self._brush = brush
        self._pen = pen

    #############################################
    #   INTERFACE
    ################################# 
Example #4
Source File: design.py    From picasso with MIT License 6 votes vote down vote up
def __init__(self, y, x):
        hex_center_x, hex_center_y = indextoHex(y, x)
        center = QtCore.QPointF(hex_center_x, hex_center_y)
        points = [
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(-1, 0) + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(-0.5, sqrt(3) / 2)
            + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(0.5, sqrt(3) / 2)
            + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(1, 0) + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(0.5, -sqrt(3) / 2)
            + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(-0.5, -sqrt(3) / 2)
            + center,
        ]

        hexagonPointsF = QtGui.QPolygonF(points)
        super().__init__(hexagonPointsF)
        self.setPen(HEX_PEN)
        self.setBrush(defaultcolor)  # initialize all as grey 
Example #5
Source File: MWTrackerViewer.py    From tierpsy-tracker with MIT License 6 votes vote down vote up
def draw_food_contour(self, image):
        if self.food_coordinates is None or not self.ui.checkBox_showFood.isChecked():
            return

        painter = QPainter()
        painter.begin(image)

        penwidth = max(1, max(image.height(), image.width()) // 800)
        col = Qt.darkMagenta
        p = QPolygonF()
        for x,y in self.food_coordinates:
            p.append(QPointF(x,y))
            
        pen = QPen()
        pen.setWidth(penwidth)
        pen.setColor(col)
        painter.setPen(pen)

        painter.drawPolyline(p)
        painter.end() 
Example #6
Source File: RewriteHandle.py    From PyQt with GNU General Public License v3.0 6 votes vote down vote up
def paintEvent(self, event):
        # 绘制默认的样式
        super(SplitterHandle, self).paintEvent(event)
        # 绘制顶部扩展按钮
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setPen(Qt.red)
        # 画矩形
        painter.drawRect(0, 0, self.width(), 24)
        # 画三角形
        painter.setBrush(Qt.red)
        painter.drawPolygon(QPolygonF([
            QPointF(0, (24 - 8) / 2),
            QPointF(self.width() - 2, 24 / 2),
            QPointF(0, (24 + 8) / 2)
        ])) 
Example #7
Source File: WorldMap.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def initMap(self):
        features = json.load(
            open("Data/world.json", encoding="utf8")).get("features")
        for feature in features:
            geometry = feature.get("geometry")
            if not geometry:
                continue
            _type = geometry.get("type")
            coordinates = geometry.get("coordinates")
            for coordinate in coordinates:
                if _type == "Polygon":
                    polygon = QPolygonF(
                        [QPointF(latitude, -longitude) for latitude, longitude in coordinate])
                    item = QGraphicsPolygonItem(polygon)
                    item.setPen(QPen(self.borderColor, 0))
                    item.setBrush(QBrush(self.backgroundColor))
                    item.setPos(0, 0)
                    self._scene.addItem(item)
                elif _type == "MultiPolygon":
                    for _coordinate in coordinate:
                        polygon = QPolygonF(
                            [QPointF(latitude, -longitude) for latitude, longitude in _coordinate])
                        item = QGraphicsPolygonItem(polygon)
                        item.setPen(QPen(self.borderColor, 0))
                        item.setBrush(QBrush(self.backgroundColor))
                        item.setPos(0, 0)
                        self._scene.addItem(item) 
Example #8
Source File: MWTrackerViewer.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def draw_trajectories(self, painter, row_data, is_current_index):
        if self.traj_worm_index_grouped is None:
            return
        worm_index = int(row_data[self.worm_index_type])
        current_frame = row_data['frame_number']
        traj_data = self._h_get_trajectory(worm_index, current_frame)
        traj_data = traj_data.dropna(subset=['coord_x', 'coord_y'])

        x_v = traj_data['coord_x'].round()
        y_v = traj_data['coord_y'].round()
        points = [QPointF(*map(int, c)) for c in zip(x_v, y_v)]

        if self.ui.is_color_features.isChecked():

            vec_color = [self._h_assign_feat_color(x) for x in traj_data.index]
            
            pen = QPen()
            pen.setWidth(self.penwidth)
            for p1, p2, c in zip(points[1:], points[:-1], vec_color):
                pen.setColor(c)
                painter.setPen(pen)
                painter.drawLine(p1, p2)
        else:
            pol = QPolygonF()
            for p in points:
                pol.append(p)

            if not worm_index in self.traj_colors:
                self.traj_colors[worm_index] = QColor(*np.random.randint(50, 230, 3))
            col = self.traj_colors[worm_index]
            
            pen = QPen()
            pen.setWidth(self.penwidth)
            pen.setColor(col)
            painter.setPen(pen)
            painter.drawPolyline(pol) 
Example #9
Source File: TrackerViewerAux.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def _drawSkel(self, worm_qimg, skel_dat, skel_colors = GOOD_SKEL_COLOURS):

        qPlg = {}
        for tt, dat in skel_dat.items():
            qPlg[tt] = QPolygonF()
            for p in dat:
                #do not add point if it is nan
                if p[0] == p[0]: 
                    qPlg[tt].append(QPointF(*p))


        if not qPlg or len(qPlg['skeleton']) == 0:
            return

        pen = QPen()
        pen.setWidth(1)

        painter = QPainter()
        painter.begin(worm_qimg)

        for k, pol_v in qPlg.items():
            color = skel_colors[k]
            pen.setColor(QColor(*color))
            painter.setPen(pen)
            painter.drawPolyline(pol_v)

        pen.setColor(Qt.black)
        painter.setBrush(Qt.white)
        painter.setPen(pen)

        radius = 3
        painter.drawEllipse(qPlg['skeleton'][0], radius, radius)
        painter.drawEllipse(QPointF(0,0), radius, radius)

        painter.end() 
Example #10
Source File: charts.py    From Quantdom with Apache License 2.0 5 votes vote down vote up
def paint(self, p, *args):
        p.setRenderHint(p.Antialiasing)
        if isinstance(self.item, tuple):
            positive = self.item[0].opts
            negative = self.item[1].opts
            p.setPen(pg.mkPen(positive['pen']))
            p.setBrush(pg.mkBrush(positive['brush']))
            p.drawPolygon(
                QtGui.QPolygonF(
                    [
                        QtCore.QPointF(0, 0),
                        QtCore.QPointF(18, 0),
                        QtCore.QPointF(18, 18),
                    ]
                )
            )
            p.setPen(pg.mkPen(negative['pen']))
            p.setBrush(pg.mkBrush(negative['brush']))
            p.drawPolygon(
                QtGui.QPolygonF(
                    [
                        QtCore.QPointF(0, 0),
                        QtCore.QPointF(0, 18),
                        QtCore.QPointF(18, 18),
                    ]
                )
            )
        else:
            opts = self.item.opts
            p.setPen(pg.mkPen(opts['pen']))
            p.drawRect(0, 10, 18, 0.5) 
Example #11
Source File: pyqt_backend.py    From ezdxf with MIT License 5 votes vote down vote up
def draw_filled_polygon(self, points: List[Vector], properties: Properties) -> None:
        brush = qg.QBrush(self._get_color(properties.color), qc.Qt.SolidPattern)
        polygon = qg.QPolygonF()
        for p in points:
            polygon.append(qc.QPointF(p.x, p.y))
        item = self.scene.addPolygon(polygon, self._no_line, brush)
        self._set_item_data(item) 
Example #12
Source File: cityscapesViewer.py    From Detectron-PYTORCH with Apache License 2.0 5 votes vote down vote up
def getPolygon(self, obj):
        poly = QtGui.QPolygonF()
        for pt in obj.polygon:
            point = QtCore.QPointF(pt.x, pt.y)
            poly.append(point)
        return poly

    # Draw the labels in the given QPainter qp
    # optionally provide a list of labels to ignore 
Example #13
Source File: MessageItem.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def paint(self, painter, option, widget):
        if self.line().length() == 0:
            return

        pen = self.pen()
        pen.setColor(settings.LINECOLOR)
        painter.setPen(pen)
        painter.setBrush(settings.LINECOLOR)

        arrow_size = 10.0

        angle = math.acos(self.line().dx() / self.line().length())

        if self.line().dy() >= 0:
            angle = (math.pi * 2) - angle

        arrow_p1 = self.line().p2() - QPointF(math.sin(angle + math.pi / 2.5) * arrow_size,
                                              math.cos(angle + math.pi / 2.5) * arrow_size)

        arrow_p2 = self.line().p2() - QPointF(math.sin(angle + math.pi - math.pi / 2.5) * arrow_size,
                                              math.cos(angle + math.pi - math.pi / 2.5) * arrow_size)

        arrow_head = QPolygonF()
        arrow_head.append(self.line().p2())
        arrow_head.append(arrow_p1)
        arrow_head.append(arrow_p2)

        painter.drawLine(self.line())
        painter.drawPolygon(arrow_head) 
Example #14
Source File: polygon.py    From CvStudio with MIT License 5 votes vote down vote up
def movePoint(self, i, p):
        if 0 <= i < len(self.m_points):
            self.m_points[i] = self.mapFromScene(p)
            self.setPolygon(QtGui.QPolygonF(self.m_points)) 
Example #15
Source File: polygon.py    From CvStudio with MIT License 5 votes vote down vote up
def addPoint(self, p):
        self.m_points.append(p)
        self.setPolygon(QtGui.QPolygonF(self.m_points))
        item = GripItem(self, len(self.m_points) - 1)
        self.scene().addItem(item)
        self.m_items.append(item)
        item.setPos(p) 
Example #16
Source File: items.py    From CvStudio with MIT License 5 votes vote down vote up
def point_deleted_slot(self, index: int):
        del self.points[index]
        del self.controls[index]
        self.setPolygon(QtGui.QPolygonF(self.points))
        self.update_indexes() 
Example #17
Source File: items.py    From CvStudio with MIT License 5 votes vote down vote up
def point_moved_slot(self, item: EditablePolygonPoint, pos: QPointF):
        self.points[item.index] = self.mapFromScene(pos)
        self.setPolygon(QtGui.QPolygonF(self.points)) 
Example #18
Source File: items.py    From CvStudio with MIT License 5 votes vote down vote up
def insertPoint(self, index, p):
        self.points.insert(index, p)
        item = EditablePolygonPoint(index)
        item.brush_color = self._brush_color
        item.pen_color = self._pen_color
        item.signals.moved.connect(self.point_moved_slot)
        item.signals.deleted.connect(self.point_deleted_slot)
        item.signals.doubleClicked.connect(self.point_double_clicked)
        self.scene().addItem(item)
        item.setPos(p)
        self.controls.insert(index, item)
        self.setPolygon(QtGui.QPolygonF(self.points)) 
Example #19
Source File: items.py    From CvStudio with MIT License 5 votes vote down vote up
def addPoint(self, p):
        self._points.append(p)
        item = EditablePolygonPoint(len(self._points) - 1)
        item.brush_color = self._brush_color
        item.pen_color = self._pen_color
        item.pen_width = self._pen_width
        item.signals.moved.connect(self.point_moved_slot)
        item.signals.deleted.connect(self.point_deleted_slot)
        item.signals.doubleClicked.connect(self.point_double_clicked)
        self.scene().addItem(item)
        item.setPos(p)
        self._controls.append(item)
        self.setPolygon(QtGui.QPolygonF(self.points)) 
Example #20
Source File: widgets.py    From qomui with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        super(favouriteButton, self).__init__(parent)
        self.star = QtGui.QPolygonF([QtCore.QPointF(1.0, 0.5)])
        for i in range(5):
            self.star << QtCore.QPointF(0.5 + 0.5 * math.cos(0.8 * i * math.pi),
                                        0.5 + 0.5 * math.sin(0.8 * i * math.pi)
                                        ) 
Example #21
Source File: audio_visualiser.py    From code-jam-5 with MIT License 5 votes vote down vote up
def amp_polygon(self):
        """
        Uses polar co-ordinate formulae in order to plot a
        circular polygon based off of amplitudes.
        """
        # There are three polygons for each colour of the flame
        large_poly = QtGui.QPolygonF()
        medium_poly = QtGui.QPolygonF()
        small_poly = QtGui.QPolygonF()

        for theta, amp in zip(np.linspace(-np.pi / 2, np.pi * 1.5, self.amps.size), self.amps):
            r = self.min_radius + (self.max_radius - self.min_radius) * amp

            # When wanting to obtain a cartesian point (x, y) at r distance from the origin
            # and theta distance rotated away from the positive x axis, you can use these formulae
            # x = rcos(theta)
            # y = rsin(theta)

            x = r * np.cos(theta)
            y = r * np.sin(theta)
            variance = np.random.random()*0.05
            large_poly.append(QtCore.QPointF(x, y))
            medium_poly.append(QtCore.QPointF(x*(0.9+variance), y*(0.9+variance)))
            small_poly.append(QtCore.QPointF(x*(0.8+variance), y*(0.8+variance)))

        # Centering the polygons
        large_poly.translate(self.width()//2, self.height()//2)
        medium_poly.translate(self.width()//2, self.height()//2)
        small_poly.translate(self.width()//2, self.height()//2)

        return large_poly, medium_poly, small_poly 
Example #22
Source File: base.py    From eddy with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, source, target=None, breakpoints=None, **kwargs):
        """
        Initialize the edge.
        :type source: AbstractNode
        :type target: AbstractNode
        :type breakpoints: list
        """
        super().__init__(**kwargs)

        self.source = source
        self.target = target

        self.anchors = {} # {AbstractNode: Polygon}
        self.breakpoints = breakpoints or [] # [QtCore.QPointF]
        self.handles = [] # [Polygon]
        self.head = Polygon(QtGui.QPolygonF())
        self.path = Polygon(QtGui.QPainterPath())
        self.selection = Polygon(QtGui.QPainterPath())

        self.mp_AnchorNode = None
        self.mp_AnchorNodePos = None
        self.mp_BreakPoint = None
        self.mp_BreakPointPos = None
        self.mp_Pos = None

        self.setAcceptHoverEvents(True)
        self.setCacheMode(AbstractItem.DeviceCoordinateCache)
        self.setFlag(AbstractItem.ItemIsSelectable, True)

    #############################################
    #   INTERFACE
    ################################# 
Example #23
Source File: quickplotter.py    From phidl with MIT License 5 votes vote down vote up
def add_port(self, port, is_subport = False):
        if (port.width is None) or (port.width == 0):
            x,y = port.midpoint
            cs = 1 # cross size
            pn = QPointF(x, y+cs)
            ps = QPointF(x, y-cs)
            pe = QPointF(x+cs, y)
            pw = QPointF(x-cs, y)
            qline1 = self.scene.addLine(QLineF(pn, ps))
            qline2 = self.scene.addLine(QLineF(pw, pe))
            port_shapes = [qline1,qline2]
        else:
            point1, point2 = port.endpoints
            point1 = QPointF(point1[0], point1[1])
            point2 = QPointF(point2[0], point2[1])
            qline = self.scene.addLine(QLineF(point1, point2))
            arrow_points = np.array([[0,0],[10,0],[6,4],[6,2],[0,2]])/(40)*port.width
            arrow_qpoly = QPolygonF( [QPointF(p[0], p[1]) for p in arrow_points] )
            port_scene_poly = self.scene.addPolygon(arrow_qpoly)
            port_scene_poly.setRotation(port.orientation)
            port_scene_poly.moveBy(port.midpoint[0], port.midpoint[1])
            port_shapes = [qline,port_scene_poly]
        qtext = self.scene.addText(str(port.name), self.portfont)
        port_items = port_shapes + [qtext]
        rad = port.orientation*np.pi/180
        x,y = port.endpoints[0]*1/4 +  port.endpoints[1]*3/4 + np.array([np.cos(rad), np.sin(rad)])*port.width/8
#        x,y = port.midpoint[0], port.midpoint[1]
#        x,y  = x - qtext.boundingRect().width()/2, y - qtext.boundingRect().height()/2
        qtext.setPos(QPointF(x,y))
        qtext.setFlag(QGraphicsItem.ItemIgnoresTransformations)

        if not is_subport:
            [shape.setPen(self.portpen) for shape in port_shapes]
            qtext.setDefaultTextColor(self.portfontcolor)
            self.portitems += port_items
        else:
            [shape.setPen(self.subportpen) for shape in port_shapes]
            qtext.setDefaultTextColor(self.subportfontcolor)
            self.subportitems += port_items
#        self.portlabels.append(qtext) 
Example #24
Source File: lab2.py    From Computer-graphics with MIT License 5 votes vote down vote up
def turn():
    global epi_x, epi_y, p1, p2, p3, p4, rect
    write_log()
    teta = math.radians(window.spin_deg.value())
    t_x = window.spin_turn_x.value()
    t_y = window.spin_turn_y.value()
    scene.clear()

    rect_t = QPolygonF(4)
    p1 = [t_x + (p1[0] - t_x) * math.cos(teta) + (p1[1] - t_y) * math.sin(teta),
          t_y - (p1[0] - t_x) * math.sin(teta) + (p1[1] - t_y) * math.cos(teta)]
    p2 = [t_x + (p2[0] - t_x) * math.cos(teta) + (p2[1] - t_y) * math.sin(teta),
          t_y - (p2[0] - t_x) * math.sin(teta) + (p2[1] - t_y) * math.cos(teta)]
    p3 = [t_x + (p3[0] - t_x) * math.cos(teta) + (p3[1] - t_y) * math.sin(teta),
          t_y - (p3[0] - t_x) * math.sin(teta) + (p3[1] - t_y) * math.cos(teta)]
    p4 = [t_x + (p4[0] - t_x) * math.cos(teta) + (p4[1] - t_y) * math.sin(teta),
          t_y - (p4[0] - t_x) * math.sin(teta) + (p4[1] - t_y) * math.cos(teta)]
    rect[0] = QPointF(p1[0], p1[1])
    rect[1] = QPointF(p2[0], p2[1])
    rect[2] = QPointF(p3[0], p3[1])
    rect[3] = QPointF(p4[0], p4[1])
    scene.addPolygon(rect, pen=p, brush=b)
    l = len(epi_x)
    for i in range(l):
        x1 = t_x + (epi_x[i] - t_x) * math.cos(teta) + (epi_y[i] - t_y) * math.sin(teta)
        y1 = t_y - (epi_x[i] - t_x) * math.sin(teta) + (epi_y[i] - t_y) * math.cos(teta)
        epi_x[i] = x1
        epi_y[i] = y1
        scene.addLine(epi_x[i], epi_y[i], epi_x[i] + 0.01, epi_y[i] + 0.01, pen=p) 
Example #25
Source File: lab9.py    From Computer-graphics with MIT License 5 votes vote down vote up
def sutherland_hodgman(clip, pol, norm):
    # дублируем начальную вершину отсекателя в конец
    clip.append(clip[0])

    s = None
    f = None
    # цикл по вершинам отсекателя
    for i in range(len(clip) - 1):
        new = []  # новый массив вершин
        for j in range(len(pol)):    # цикл по вершинам многоугольника
            if j == 0:
                f = pol[j]
            else:
                t = is_intersection([s, pol[j]], [clip[i], clip[i + 1]], norm)
                if t:
                    new.append(t)

            s = pol[j]
            if is_visiable(s,  clip[i], clip[i + 1], norm):
                    new.append(s)

        if len(new) != 0:
            t = is_intersection([s, f], [clip[i], clip[i + 1]], norm)
            if t:
                new.append(t)

        pol = copy.deepcopy(new)

    if len(pol) == 0:
        return False
    else:
        return QPolygonF(pol) 
Example #26
Source File: geometry.py    From eddy with GNU General Public License v3.0 5 votes vote down vote up
def createArea(p1, p2, degrees, size):
    """
    Creates an area between the given QPointF and according to the given angle and size.
    :type p1: QPointF
    :type p2: QPointF
    :type degrees: float
    :type size: int
    :rtype: QPolygonF
    """
    rad = math.radians(degrees)
    x = size / 2 * math.sin(rad)
    y = size / 2 * math.cos(rad)
    a = QtCore.QPointF(+x, +y)
    b = QtCore.QPointF(-x, -y)
    return QtGui.QPolygonF([p1 + a, p1 + b, p2 + b, p2 + a]) 
Example #27
Source File: equivalence.py    From eddy with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, **kwargs):
        """
        Initialize the edge.
        """
        super().__init__(**kwargs)
        self.tail = Polygon(QtGui.QPolygonF())

    #############################################
    #   INTERFACE
    ################################# 
Example #28
Source File: equivalence.py    From eddy with GNU General Public License v3.0 5 votes vote down vote up
def createHead(p1, angle, size):
        """
        Create the head polygon.
        :type p1: QPointF
        :type angle: float
        :type size: int
        :rtype: QPolygonF
        """
        rad = radians(angle)
        p2 = p1 - QtCore.QPointF(sin(rad + M_PI / 3.0) * size, cos(rad + M_PI / 3.0) * size)
        p3 = p1 - QtCore.QPointF(sin(rad + M_PI - M_PI / 3.0) * size, cos(rad + M_PI - M_PI / 3.0) * size)
        return QtGui.QPolygonF([p1, p2, p3]) 
Example #29
Source File: equivalence.py    From eddy with GNU General Public License v3.0 5 votes vote down vote up
def createTail(p1, angle, size):
        """
        Create the tail polygon.
        :type p1: QPointF
        :type angle: float
        :type size: int
        :rtype: QPolygonF
        """
        rad = radians(angle)
        p2 = p1 + QtCore.QPointF(sin(rad + M_PI / 3.0) * size, cos(rad + M_PI / 3.0) * size)
        p3 = p1 + QtCore.QPointF(sin(rad + M_PI - M_PI / 3.0) * size, cos(rad + M_PI - M_PI / 3.0) * size)
        return QtGui.QPolygonF([p1, p2, p3]) 
Example #30
Source File: input.py    From eddy with GNU General Public License v3.0 5 votes vote down vote up
def createHead(p1, angle, size):
        """
        Create the head polygon.
        :type p1: QPointF
        :type angle: float
        :type size: int
        :rtype: QPolygonF
        """
        rad = radians(angle)
        p2 = p1 - QtCore.QPointF(sin(rad + M_PI / 4.0) * size, cos(rad + M_PI / 4.0) * size)
        p3 = p2 - QtCore.QPointF(sin(rad + 3.0 / 4.0 * M_PI) * size, cos(rad + 3.0 / 4.0 * M_PI) * size)
        p4 = p3 - QtCore.QPointF(sin(rad - 3.0 / 4.0 * M_PI) * size, cos(rad - 3.0 / 4.0 * M_PI) * size)
        return QtGui.QPolygonF([p1, p2, p3, p4])