Beispiel #1
0
    def __init__(self, v_from: Vertex, v_to: Vertex, node: Vertex, oriented: bool, weight: int = 1,
                 weighted: bool = True):
        super().__init__()

        self.v_from = v_from
        self.v_to = v_to
        self.node = node
        self.weighted = weighted
        self.weight = weight

        # self.pen = QPen(QBrush(QColor(0, 0, 0)), 3)



        if weighted:
            self.ellipse = QGraphicsEllipseItem(self.node.x - 8, self.node.y - 8, 16, 16)
            self.ellipse.setBrush(QBrush(QColor(0, 0, 0)))
            self.addToGroup(self.ellipse)

            text = QGraphicsSimpleTextItem(str(self.weight))
            font = QFont()
            font.setPixelSize(8)
            text.setPen(QColor(255, 255, 255))
            text.setFont(font)
            # настраиваем расположение текста
            if self.weight < 10:
                text.setPos(self.node.x - 16 / 6, self.node.y - 16 / 3)
            else:
                text.setPos(self.node.x - 4, self.node.y - 16 / 3)

            self.addToGroup(text)
        else:
            self.ellipse = QGraphicsEllipseItem(self.node.x - 4, self.node.y - 4, 8, 8)
            self.ellipse.setBrush(QBrush(QColor(0, 0, 0)))
            self.addToGroup(self.ellipse)
Beispiel #2
0
    def __iniGraphicsSystem(self):  ##初始化 graphics View系统
        rect = QRectF(-200, -100, 400, 200)
        self.scene = QGraphicsScene(rect)  #scene逻辑坐标系定义
        self.view.setScene(self.scene)

        ## 画一个矩形框,大小等于scene
        item = QGraphicsRectItem(rect)  #矩形框正好等于scene的大小
        item.setFlag(QGraphicsItem.ItemIsSelectable)  #可选,
        item.setFlag(QGraphicsItem.ItemIsFocusable)  #可以有焦点
        pen = QPen()
        pen.setWidth(2)
        item.setPen(pen)
        self.scene.addItem(item)

        ##一个位于scene中心的椭圆,测试局部坐标
        #矩形框内创建椭圆,绘图项的局部坐标,左上角(-100,-50),宽200,高100
        item2 = QGraphicsEllipseItem(-100, -50, 200, 100)
        item2.setPos(0, 0)
        item2.setBrush(QBrush(Qt.blue))
        item2.setFlag(QGraphicsItem.ItemIsSelectable)  #可选,
        item2.setFlag(QGraphicsItem.ItemIsFocusable)  #可以有焦点
        item2.setFlag(QGraphicsItem.ItemIsMovable)  #可移动

        self.scene.addItem(item2)

        ##一个圆,中心位于scene的边缘
        item3 = QGraphicsEllipseItem(-50, -50, 100, 100)  #矩形框内创建椭圆,绘图项的局部坐标
        item3.setPos(rect.right(), rect.bottom())
        item3.setBrush(QBrush(Qt.red))
        item3.setFlag(QGraphicsItem.ItemIsSelectable)  #可选,
        item3.setFlag(QGraphicsItem.ItemIsFocusable)  #可以有焦点
        item3.setFlag(QGraphicsItem.ItemIsMovable)  #可移动
        self.scene.addItem(item3)

        self.scene.clearSelection()
Beispiel #3
0
    def __init__(self, f):
        super().__init__(None)
        # Création du point de l'avion
        self.item_avion = QGraphicsEllipseItem()
        self.item_avion.setRect(
            -PLANE_CIRCLE_SIZE / 2, -PLANE_CIRCLE_SIZE / 2, PLANE_CIRCLE_SIZE,
            PLANE_CIRCLE_SIZE)  # Les coordonnées x,y centrent le cercle
        self.item_avion.setBrush(FLIGHT_BRUSH)
        self.addToGroup(self.item_avion)
        self.flight = f
        self.trajectoire = f.completeTrajectory(N_POINT_TRAJECTORY)

        # Création du cercle de conflit pour l'avion
        self.item_conflit = QGraphicsEllipseItem()
        self.item_conflit.setRect(
            -CONFLICT_CIRCLE_SIZE / 2, -CONFLICT_CIRCLE_SIZE / 2,
            CONFLICT_CIRCLE_SIZE,
            CONFLICT_CIRCLE_SIZE)  # Les coords x,y centrent le cercle
        dicoConflits = self.flight.listeConflits()
        duree = 0
        self.item_conflit.setBrush(CONFLICT_CIRCLE_BRUSH)
        if len(dicoConflits) != 0:
            for i in dicoConflits:
                for j in i:
                    duree += j[1] - j[0]
        if duree != 0:
            self.item_conflit.setBrush(CONFLICT_CIRCLE_BRUSH_CONFLICT)
        self.addToGroup(self.item_conflit)
        self.setPos(self.trajectoire[0] + QPoint(0, 0))
Beispiel #4
0
 def setLeftPoints(self, e):
     if self.state == "first_state":
         ## if it contains points already
         self.leftPoint = self.gfxLeft.mapToScene(e.pos())
         greenPen = QPen(QtCore.Qt.green)
         greenBrush = QBrush(QtCore.Qt.green)
         self.leftPointItem = QGraphicsEllipseItem(self.leftPoint.x(),
                                                   self.leftPoint.y(), 20,
                                                   20)
         self.leftPointItem.setPen(greenPen)
         self.leftPointItem.setBrush(greenBrush)
         self.startSetImg.addItem(self.leftPointItem)
         self.state = "left_set"
     elif self.state == "right_set":
         self.comfirmPoints()
         ## if it contains points already
         self.leftPoint = self.gfxLeft.mapToScene(e.pos())
         greenPen = QPen(QtCore.Qt.green)
         greenBrush = QBrush(QtCore.Qt.green)
         self.leftPointItem = QGraphicsEllipseItem(self.leftPoint.x(),
                                                   self.leftPoint.y(), 20,
                                                   20)
         self.leftPointItem.setPen(greenPen)
         self.leftPointItem.setBrush(greenBrush)
         self.startSetImg.addItem(self.leftPointItem)
         self.state = "left_set"
Beispiel #5
0
 def __init__(self, ID=0, x=0, y=0):
     super(self.__class__, self).__init__(ID, x, y)
     self._kind_name = 'shelf'
     self._carried = None
     self._products = []
     self._graphics_item = QGraphicsEllipseItem(self)
     self._graphics_carried = QGraphicsEllipseItem()
     self._text = QGraphicsTextItem(self)
     self.setZValue(2.0)
     self.update_tooltip()
Beispiel #6
0
    def __init__(self, equipo, tamaño="pequeño"):
        self.equipo = equipo
        self.tamaño = tamaño
        super().__init__()
        if tamaño == "pequeño":
            self.setPixmap(QPixmap("Minions/minion0.png").scaled(30, 30))
            self.setTransformOriginPoint(15, 15)
        else:
            self.setPixmap(QPixmap("Minions/minion0.png").scaled(40, 40))
            self.setTransformOriginPoint(20, 20)
        paths = ["minion{}".format(i) for i in range(0, 9)]
        paths = sorted([p for i in range(3) for p in paths])
        self.img = self.gen_path(paths)

        # Area de ataque
        if tamaño == "pequeño":
            self.area = QGraphicsEllipseItem(-5, -5, 40, 40)
            self.area.setTransformOriginPoint(20, 20)
        else:
            self.area = QGraphicsEllipseItem(-20, -20, 80, 80)
            self.area.setTransformOriginPoint(40, 40)
        self.area.setParentItem(self)
        self.area.hide()

        # La barra de vida
        if tamaño == "pequeño":
            self.barra_vida = BarraVida(30, 45)
        else:
            self.barra_vida = BarraVida(40, 60)
        self.barra_vida.setParentItem(self)

        # Para cuando ataquen
        self.target = None

        # Stats
        if self.tamaño == "pequeño":
            self.vida = 45
            self.daño = 2
            self.pix = 30
        else:
            self.vida = 60
            self.daño = 4
            self.pix = 40

        self.mover = QtCore.QTimer()
        self.mover.timeout.connect(self.move)
        # Se mueve una vez cada 50 milisegundos
        self.mover.start(50)

        # Timer de ataque
        self.ataque = QtCore.QTimer()
        self.ataque.timeout.connect(self.atacar)

        self.hover = False
Beispiel #7
0
 def parse_shape(self, shape, bounding_box):
     if shape in ('box', 'rect', 'rectangle'):
         self._graphics_item = QGraphicsRectItem(bounding_box)
     elif shape in ('ellipse', 'oval', 'circle'):
         self._graphics_item = QGraphicsEllipseItem(bounding_box)
     elif shape in ('box3d', ):
         self._graphics_item = QGraphicsBox3dItem(bounding_box)
     else:
         print("Invalid shape '%s', defaulting to ellipse" % shape,
               file=sys.stderr)
         self._graphics_item = QGraphicsEllipseItem(bounding_box)
Beispiel #8
0
    def __init__(self, _icon_top_file, _icon_bottom_file, _win):
        super().__init__()

        self.index = 0
        self.active = False
        self.win = _win

        width = 80
        self.width = width
        height = 250
        self.height = height
        height_ratio = 8
        width_ratio = 4

        points = [QPointF(width / 2, 0), QPointF(width, height / height_ratio),
                  QPointF((width_ratio - 1) * width / width_ratio, height / height_ratio),
                  QPointF((width_ratio - 1) * width / width_ratio, (height_ratio - 1) * height / height_ratio),
                  QPointF(width, (height_ratio - 1) * height / height_ratio), QPointF(width / 2, height),
                  QPointF(0, (height_ratio - 1) * height / height_ratio),
                  QPointF(width / width_ratio, (height_ratio - 1) * height / height_ratio),
                  QPointF(width / width_ratio, height / height_ratio),
                  QPointF(0, height / height_ratio), QPointF(width / 2, 0)
                  ]
        needle = QPolygonF(points)
        self.setPolygon(needle)
        self.setBrush(IDLE_BRUSH)
        self.setPen(ON_PEN)

        self.value_point = QGraphicsEllipseItem(width / 2 - 5, height / 2 - 5, 10, 10)
        self.value_point.setPen(BG_PEN)
        self.value_point.setBrush(FG_COL)
        self.value_point.setParentItem(self)
        self.value_point.setZValue(10)

        self.value_point_raw = QGraphicsEllipseItem(width / 2 - 3, height / 2 - 3, 6, 6)
        self.value_point_raw.setPen(BG_PEN)
        self.value_point_raw.setBrush(FG_COL_2)
        self.value_point_raw.setParentItem(self)
        self.value_point_raw.setZValue(9)

        script_dir = os.path.dirname(os.path.realpath(__file__))
        icon_top_path = script_dir + os.path.sep + "img" + os.path.sep + _icon_top_file
        icon_bottom_path = script_dir + os.path.sep + "img" + os.path.sep + _icon_bottom_file
        self.top = QGraphicsPixmapItem(self)
        self.top.setPixmap(QPixmap(icon_top_path))
        self.top.setPos(width / 2 - 8, -18)
        self.top.setScale(0.5)
        self.top.setOpacity(0.5)
        self.bottom = QGraphicsPixmapItem(self)
        self.bottom.setPixmap(QPixmap(icon_bottom_path))
        self.bottom.setPos(width / 2 - 8, height + 2)
        self.bottom.setScale(0.5)
        self.bottom.setOpacity(0.5)
Beispiel #9
0
    def __init__(self, model):
        super().__init__(model)
        if isinstance(self.model, models.PushInletSocket):
            self.graphics_item = GraphicsPushSocketItem(model, 0, 0, 15, 15)
            self.graphics_item.setBrush(Qt.black)

            inner_rect_item = QGraphicsRectItem(1, 1, 13, 13,
                                                self.graphics_item)
            inner_rect_item.setBrush(Qt.white)

            self.socket_marker_item = QGraphicsRectItem(
                4, 4, 7, 7, inner_rect_item)
            self.socket_marker_item.setBrush(Qt.red)
            self.socket_marker_item.setOpacity(0.3)
        elif isinstance(self.model, models.PushOutletSocket):
            self.graphics_item = GraphicsPushSocketItem(model, 0, 0, 15, 15)
            self.graphics_item.setBrush(Qt.black)

            inner_rect_item = QGraphicsRectItem(2, 2, 11, 11,
                                                self.graphics_item)
            inner_rect_item.setBrush(Qt.white)

            self.socket_marker_item = QGraphicsRectItem(
                4, 4, 7, 7, inner_rect_item)
            self.socket_marker_item.setBrush(Qt.red)
            self.socket_marker_item.setOpacity(0.3)
        elif isinstance(self.model, models.PullInletSocket):
            self.graphics_item = GraphicsPullSocketItem(model, 0, 0, 15, 15)
            self.graphics_item.setBrush(Qt.black)

            inner_circle_item = QGraphicsEllipseItem(1, 1, 13, 13,
                                                     self.graphics_item)
            inner_circle_item.setBrush(Qt.white)

            self.socket_marker_item = QGraphicsEllipseItem(
                4, 4, 7, 7, inner_circle_item)
            self.socket_marker_item.setBrush(Qt.red)
            self.socket_marker_item.setOpacity(0.3)
        elif isinstance(self.model, models.PullOutletSocket):
            self.graphics_item = GraphicsPullSocketItem(model, 0, 0, 15, 15)
            self.graphics_item.setBrush(Qt.black)

            inner_circle_item = QGraphicsEllipseItem(2, 2, 11, 11,
                                                     self.graphics_item)
            inner_circle_item.setBrush(Qt.white)

            self.socket_marker_item = QGraphicsEllipseItem(
                4, 4, 7, 7, inner_circle_item)
            self.socket_marker_item.setBrush(Qt.red)
            self.socket_marker_item.setOpacity(0.3)
Beispiel #10
0
 def send_setWarnLightRed(self):
     scene = QGraphicsScene()
     item = QGraphicsEllipseItem(0, 30, 15, 15)
     item.setPen(QColor(144, 25, 19))
     item.setBrush(QColor(196, 109, 104))
     scene.addItem(item)
     self.ui.send_graphicWarn.setScene(scene)
Beispiel #11
0
    def __init__(self, img_arr, binary_array, parent=None, title='ImageWindow'):
        super(OverlayImageWindow, self).__init__(parent)
        self.setWindowTitle(title)
        self.img_arr = img_arr
        self.binary_array = binary_array

        win = pg.GraphicsLayoutWidget()
        self.vb = pg.ViewBox(enableMouse=False, enableMenu=False)

        self.img_item = DragImageItem(img_arr[0])

        pos = np.array([0., 1.])
        color = np.array([[0., 0., 0., 0.], [1., 0., 0., self.alpha]])
        cm = pg.ColorMap(pos, color)
        lut = cm.getLookupTable(0., 1.)

        self.olay_updated.connect(self.update_overlay)

        self.overlay_item = pg.ImageItem(binary_array[0])
        self.overlay_item.setLookupTable(lut)
        self.vb.addItem(self.img_item)
        self.vb.addItem(self.overlay_item)
        self.vb.setAspectLocked()
        win.addItem(self.vb)

        self.circle = QGraphicsEllipseItem(30., 30., 0., 0.)
        self.vb.addItem(self.circle)

        hist = pg.HistogramLUTItem()
        hist.setImageItem(self.img_item)
        win.addItem(hist)

        win.setStyleSheet("background-color:black;")
        self.setCentralWidget(win)
Beispiel #12
0
    def obstacle_cb(self, msg):
        for item in self.obstacles:
            self._scene.removeItem(item)

        for obstacle_msg in msg.obstacles:
            obstacle = QGraphicsEllipseItem(0, 0, self.obsacle_size,
                                            self.obsacle_size, self.radar)
            obstacle.setPen(self.obstacle_pen)
            obstacle.setOpacity(self.opacity)

            obstacle_point = PointStamped()
            obstacle_point.header.frame_id = msg.header.frame_id
            obstacle_point.header.stamp = msg.header.stamp
            obstacle_point.point = obstacle_msg.pose.pose.pose.position

            try:
                obstacle_point = self.tf_buffer.transform(
                    obstacle_point, "base_footprint")
            except tf2_ros.LookupException:
                rospy.logwarn("Could not transform from " +
                              msg.header.frame_id + " to 'base_footprint'")
                return None

            self.set_scaled_position(obstacle, -1 * obstacle_point.point.x,
                                     -1 * obstacle_point.point.y,
                                     self.obsacle_size, self.obsacle_size)
            color_tuple = self.confidence2color(obstacle_msg.pose.confidence)
            obstacle.setBrush(QBrush(QColor(*color_tuple)))
            obstacle.setVisible(True)
            self.obstacles.append(obstacle)
Beispiel #13
0
 def importSVG(self, filepath, view):
     
     try:
         doc = minidom.parse(filepath)
     except (ExpatError, IsADirectoryError):
         # xml file is broken: we can't import it
         pass
     else:
     
         lines = doc.getElementsByTagName("line")
         for line in lines:
             x1 = line.getAttribute("x1")
             y1 = line.getAttribute("y1")
             x2 = line.getAttribute("x2")
             y2 = line.getAttribute("y2")
             width = line.getAttribute("width")
             
             lineItem = QGraphicsLineItem(float(x1), float(y1), float(x2), float(y2))
             lineItem.setPen(QPen(view.colour, view.penRadius, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
             view.scene().addItem(lineItem)
             
         ellipses = doc.getElementsByTagName("ellipse")
         for ellipse in ellipses:
             cx = ellipse.getAttribute("cx")
             cy = ellipse.getAttribute("cy")
             rx = ellipse.getAttribute("rx")
             ry = ellipse.getAttribute("ry")
             width = ellipse.getAttribute("width")
             
             ellipseItem = QGraphicsEllipseItem(float(cx)-float(rx), float(cy)-float(ry), float(rx)*2, float(ry)*2)
             ellipseItem.setPen(QPen(view.colour, QtCore.Qt.SolidPattern))
             ellipseItem.setBrush(view.colour)
             
             view.scene().addItem(ellipseItem)
Beispiel #14
0
    def __init__(self, data):
        super(QGraphicsObject, self).__init__()
        self.stateData = data
        self.setAcceptHoverEvents(True)
        self.setFlag(QGraphicsItem.ItemIsMovable)
        self.setAcceptDrops(True)

        # position of the graphics item on the scene
        self.setPos(self.stateData.x, self.stateData.y)

        self.dragging = False

        # create an ellipse
        self.ellipse = QGraphicsEllipseItem(-StateGraphicsItem.NODE_WIDTH / 2,
                                            -StateGraphicsItem.NODE_WIDTH / 2,
                                            StateGraphicsItem.NODE_WIDTH,
                                            StateGraphicsItem.NODE_WIDTH, self)
        brush = QBrush(Qt.SolidPattern)
        brush.setColor(Qt.blue)
        self.ellipse.setBrush(brush)

        self.textGraphics = IdTextBoxGraphicsItem(self.stateData.name, self)
        textWidth = self.textGraphics.boundingRect().width()
        self.textGraphics.setPos(
            -textWidth / 2, StateGraphicsItem.NODE_WIDTH -
            (StateGraphicsItem.NODE_WIDTH / 2) + 5)
        self.textGraphics.textChanged.connect(self.nameChanged)
        self.textGraphics.textEditStarted.connect(self.textEditStarted)
        self.textGraphics.textEditFinished.connect(self.textEditFinished)

        self.initGraphics = None
        self.setInitial(self.stateData.initial)
    def attach_attribute(self, l, txt, id, type, parent, w, h, txt_geo, child):
        self.con_list.append(QGraphicsLineItem(parent))
        self.atr_shape_list.append(QGraphicsEllipseItem(parent))

        self.con_list[-1].setLine(l)
        self.con_list[-1].setPen(self.at_connection_pen)
        self.atr_shape_list[-1].setRect(
            QRectF(l.x1() - w / 2,
                   l.y2() - h, w, h))
        self.atr_shape_list[-1].setPen(self.attribute_pen)
        self.atr_shape_list[-1].setBrush(self.attribute_brush)

        self.atr_txt_list.append(self.scene.addWidget(QLineEdit()))
        self.atr_txt_list[-1].setParentItem(self.atr_shape_list[-1])
        self.atr_txt_list[-1].setGeometry(txt_geo)
        self.atr_txt_list[-1].widget().setFixedWidth(txt_geo.width())
        self.atr_txt_list[-1].widget().setFixedHeight(txt_geo.height())
        self.atr_txt_list[-1].widget().setStyleSheet(self.txt_style)

        if (type == 'Prime' or type == 'prime'):
            self.atr_txt_list[-1].widget().setStyleSheet(
                '''QWidget{text-decoration:underline;font-weight:bold;}''')
        self.atr_txt_list[-1].setPos(
            l.x2() - self.txt_atr_geometry.width() / 2,
            l.y2() - 0.75 * h)
        self.atr_txt_list[-1].widget().setText(txt)
        widget = self.atr_txt_list[-1].widget()
        self.atr_txt_list[-1].widget().editingFinished.connect(
            lambda: ContainerItem.trial(self, id, widget, child))
Beispiel #16
0
    def draw_vp(self, point, index):
        key = self.vp_eng.get_key_from_id(index)
        print("drawing at {} {}".format(point, key))
        x, y = point
        r = 10

        graphic_view = self.get_graphic_view()

        graphic_view.vp_drawn_callback(point, index)
        self.vp_eng.add_vpoint(index, point)

        circle_item = QGraphicsEllipseItem(x - r, y - r, 2 * r, 2 * r)
        circle_item.setPen(
            QPen(self.get_pen_color(), 2, Qt.SolidLine, Qt.RoundCap,
                 Qt.RoundJoin))
        circle_item.setBrush(QBrush(Qt.black, Qt.SolidPattern))

        text_item = QGraphicsTextItem()
        text_item.setPos(x, y)
        text_item.setPlainText("V{}".format(key))

        if self.vp_dict[key]["vp"] is not None:
            self.removeItem(self.vp_dict[key]["vp"])
            self.removeItem(self.vp_dict[key]["label"])

        self.vp_dict[key]["vp"] = circle_item
        self.vp_dict[key]["label"] = text_item
        self.addItem(circle_item)
        self.addItem(text_item)
Beispiel #17
0
    def __init__(self, qPointList, bot, rType):  #

        QGraphicsItemGroup.__init__(self)
        self.rType = rType

        #射线类型雷达
        if rType == "poly":
            self.item = QGraphicsPolygonItem()  #提供一个多边形item
            self.polygon = QPolygonF(qPointList)
            self.item.setPolygon(self.polygon)
            self.robot = bot

        #范围类型雷达
        elif rType == "round":
            self.item = QGraphicsEllipseItem()  #提供一个椭圆item
            self.item.setRect(qPointList[0], qPointList[1], qPointList[2],
                              qPointList[3])
            self.robot = bot

        color = QColor(255, 100, 6, 10)  #设置雷达的颜色,
        brush = QBrush(color)
        pen = QPen(color)
        self.item.setBrush(brush)
        self.item.setPen(pen)
        self.addToGroup(self.item)
 def drawObstacleWarnings(self, result):
     for item in self.obstacleMarkerShapes:
         self.augmentedRealityScene.removeItem(item)
     self.obstacleMarkerShapes.clear()
     shape0 = QGraphicsEllipseItem(-self.AugmentedRealityPanel.height() / 2,
                                   -self.AugmentedRealityPanel.height() / 2, self.AugmentedRealityPanel.height(),
                                   self.AugmentedRealityPanel.height())
     shape0.setPen(QPen(self.black))
     shape0.setOpacity(0.01)
     self.augmentedRealityScene.addItem(shape0)
     self.obstacleMarkerShapes.append(shape0)
     if (self.ObstacleWarningCB.isChecked()):
         markersToShow = np.zeros(self.numberOfObstacleGroupings)
         startAngle = result.angle_min
         angleIncrement = result.angle_increment
         AngleCutOff = 2 * np.pi / self.numberOfObstacleGroupings
         offset = np.pi/2
         for point in range(0, len(result.ranges)):
             if result.ranges[point]<=self.obstacleWarningDistance:
                 angle = startAngle + angleIncrement*point
                 directionSector = int(angle/AngleCutOff)
                 markersToShow[directionSector]=1
         for marker in range(0, self.numberOfObstacleGroupings):
             if(markersToShow[marker]):
                 shape = QGraphicsLineItem(-self.AugmentedRealityPanel.height()*0.98/2*math.cos(marker*AngleCutOff+offset),-self.AugmentedRealityPanel.height()*0.98/2*math.sin(marker*AngleCutOff+offset), -self.AugmentedRealityPanel.height()*0.98/2*math.cos((marker+1)*AngleCutOff+offset),-self.AugmentedRealityPanel.height()*0.98/2*math.sin((marker+1)*AngleCutOff+offset))
                 shape.setPen(QPen(self.red, 5))
                 self.augmentedRealityScene.addItem(shape)
                 self.obstacleMarkerShapes.append(shape)
     self.AugmentedRealityPanel.centerOn(QPoint(0, 0))
Beispiel #19
0
    def balls_cb(self, msg):
        ball_msgs = msg.poses

        for ball_msg in ball_msgs:
            ball_point = PointStamped()
            ball_point.header.frame_id = msg.header.frame_id
            ball_point.header.stamp = msg.header.stamp
            ball_point.point = ball_msg.pose.pose.position
            try:
                ball_point = self.tf_buffer.transform(ball_point,
                                                      "base_footprint")
            except tf2_ros.LookupException:
                rospy.logwarn("Could not transform from " +
                              msg.header.frame_id + " to 'base_footprint'")
                return None

            ball = QGraphicsEllipseItem(0, 0, self.ball_size, self.ball_size,
                                        self.radar)
            ball.setPen(self.ball_pen)
            ball.setVisible(False)
            ball.setOpacity(self.opacity)
            self.set_scaled_position(ball, -1 * ball_point.point.x,
                                     -1 * ball_point.point.y, self.ball_size,
                                     self.ball_size)

            color_tuple = self.confidence2color(ball_msg.confidence)
            ball.setBrush(QBrush(QColor(*color_tuple)))
            ball.setVisible(self.ball_active)
 def remplirScene(self):
     scene = self.scene
     rectGris = scene.addRect(0, 0, 200, 150, brush=QBrush(Qt.lightGray))
     self.rectGris = rectGris
     self.texte = scene.addText("")
     dy = rectGris.rect().height() - self.texte.sceneBoundingRect().height()
     self.texte.setPos(rectGris.x(), rectGris.y() + dy)
     self.texte.setDefaultTextColor(Qt.cyan)
     scene.addItem(self.texte)
     d = 48.  # diametre smiley
     ox = 4.  # largeur oeil
     oy = 6.  # hauteur oeil
     smiley = scene.addEllipse(-d / 2,
                               -d / 2,
                               d,
                               d,
                               brush=QBrush(Qt.yellow))
     yeux = [QGraphicsEllipseItem(-ox/2.,-oy/2.,ox,oy,parent=smiley) \
             for i in range(2)]
     yeux[0].setPos(-d / 6, -d / 8)
     yeux[1].setPos(+d / 6, -d / 8)
     brush = QBrush(Qt.black)
     for oeil in yeux:
         oeil.setBrush(brush)
     smiley.setPos(rectGris.mapToScene(rectGris.rect().center()))
     smiley.setRotation(20)
     smiley.setScale(1.5)
     for item in scene.items():
         item.setFlag(QGraphicsItem.ItemIsMovable)
         item.setFlag(QGraphicsItem.ItemIsSelectable)
Beispiel #21
0
    def __showCircle(self):
        ratio = 3

        pen = QPen()
        pen.setBrush(Qt.red)
        pen.setWidth(0.01)

        font = QFont()
        font.setPointSize(200 * ratio)

        self.scene.clear()

        for i in range(len(self.pointsXYItem)):
            (x, y) = self.pointsXYItem[i]
            r = self.radius[i] * ratio

            circleItem = QGraphicsEllipseItem(x - r, y - r, 2 * r, 2 * r)
            circleItem.setPen(pen)

            self.scene.addItem(circleItem)

            strItem = QGraphicsTextItem()
            strItem.setDefaultTextColor(Qt.blue)
            strItem.setFont(font)

            strItem.setPlainText(self.pointsName[i])
            strItem.setPos(x, y)

            self.scene.addItem(strItem)
Beispiel #22
0
    def __init__(self, map, *args):
        super().__init__(*args)
        self.map = map
        self.position = map.center

        self.providers = deque([
            'osm',
            'stamen-terrain',
            'stamen-toner-lite',
            'stamen-toner',
            'stamen-watercolor',
            'ms-aerial',
            'ms-hybrid',
            'ms-road',
            'bluemarble',
        ])

        self.refresh_map = asyncio.Event()

        scene = QGraphicsScene()
        self.scene = scene
        self.setScene(scene)
        self.map_layer = QGraphicsPixmapItem()
        scene.addItem(self.map_layer)

        self.circle = QGraphicsEllipseItem(0, 0, 20, 20)
        pen = QPen(QColor(255, 0, 0, 128))
        pen.setWidth(2)
        self.circle.setPen(pen)
        scene.addItem(self.circle)

        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
Beispiel #23
0
 def send_setWarnLightGreen(self):
     scene = QGraphicsScene()
     item = QGraphicsEllipseItem(0, 30, 15, 15)
     item.setPen(QColor(65, 128, 17))
     item.setBrush(QColor(128,174,93))
     scene.addItem(item)
     self.ui.send_graphicWarn.setScene(scene)
Beispiel #24
0
    def step(self, x, y, direction, brightness):
        """
        step is called many times while iterating over the loaded bitmap
        in each step we calculate a circle based on position x,y with given brightness
        in the bitmap. direction is a direction vector indicating what direction we are
        moving in.

        calculate a new circle in the circle generation process
        :param x: x pos in bitmap that calculation should be based on
        :param y: y pos in bitmap that calculation should be based on
        :param direction: in what direction are we moving?
        :param brightness: gray value in the bitmap at x,y
        :return: potentially modified step size
        """
        r = Mapping.linexp(brightness, self.minBrightness, self.maxBrightness,
                           self.maxRadius, self.minRadius)
        if not r:
            r = self.minRadius
        stepsize = int(
            Mapping.linlin(brightness, self.minBrightness, self.maxBrightness,
                           self.minStepSize, self.maxStepSize))
        if not self.clipToBitmap or (self.clipToBitmap and not Circle(
                x, y, r).edges(self.width, self.height)):
            item = QGraphicsEllipseItem(x - r, y - r, r * 2, r * 2)
            pen = QPen()
            pen.setWidth(self.strokeWidth)
            item.setPen(pen)
            self.group.addToGroup(item)
        return max(int(stepsize), 1)
Beispiel #25
0
    def showFrame(self, image_widget, dimensions):
        if self.positions_df is None:
            return
        self.set_unit_scaling()

        scaleFactor = image_widget.scaleFactor
        self.clearAll(image_widget)
        frame_no = dimensions['t'].position

        selection = self.positions_df[self.positions_df['frame'] == frame_no]

        for i, row in selection.iterrows():
            x = float(row[self.x_name]) * self.unit_scaling
            y = float(row[self.y_name]) * self.unit_scaling

            r = float(row[self.r_name]) * self.unit_scaling
            if np.isnan(r):
                r = 10.0

            ellipse = QGraphicsEllipseItem(
                self.rect_from_xyr(x, y, r, scaleFactor))
            pen = ellipse.pen()
            pen.setWidth(2)
            pen.setColor(Qt.red)
            ellipse.setPen(pen)
            image_widget.addItemToScene(ellipse)
            self.items.append(ellipse)
Beispiel #26
0
    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)
Beispiel #27
0
 def add_arc(self, x, y,
             r):  # x,y - центр окружности, к которой строится дуга
     ell = QGraphicsEllipseItem(x - r // 4, y - r / 1.1, r - r // 2,
                                r + r // 2)
     ell.setStartAngle(0)
     ell.setSpanAngle(2900)
     self.scene.addItem(ell)
     self.add_triangle(x - r // 4.4, y - r // 2.28, r // 4)
Beispiel #28
0
 def __init__(self, *args, **kwargs):
     PoolItem.__init__(self, *args, **kwargs)
     self.setFlag(QGraphicsItem.ItemIsMovable, True)
     self.bgColor = QGraphicsEllipseItem(self)
     self.bgColor.setFlag(QGraphicsItem.ItemStacksBehindParent, True)
     self.bgColor.setRect(((self.gobj.boundingRect().width() +
                            PoolItem.fontMetrics.width('  ')) / 2) - 5,
                          self.gobj.boundingRect().height() / 2 - 5, 10, 10)
Beispiel #29
0
 def paint_circle(self, x, y, r, name):  # добавляет круг на сцену
     ell = QGraphicsEllipseItem(
         x - r // 2, y - r // 2, r,
         r)  # поправка смещения(в qt x,y - правый левый угол)
     ell.setBrush(QColor(192, 192, 192))
     self.scene.addItem(ell)
     self.conditions[name]["scene_items"].append(ell)
     if self.conditions[name]["is_final"] == 'yes':
         ell = QGraphicsEllipseItem(x - r // 2 + r // 10,
                                    y - r // 2 + r // 10, r - r // 5,
                                    r - r // 5)
         ell.setBrush(QColor(192, 192, 192))
         self.scene.addItem(ell)
         self.conditions[name]["scene_items"].append(ell)
     text_item = QGraphicsTextItem(name)
     text_item.moveBy(x - 11, y - 12)
     self.scene.addItem(text_item)
Beispiel #30
0
 def _add_ellipse(self, radius, scale_factor, pen, use_brush=False):
     r = scale_factor * radius
     item = QGraphicsEllipseItem(-r, -r, r * 2, r * 2, self)
     item.setPen(_map_physical_pen_to_scene(pen, scale_factor))
     if use_brush:
         item.setBrush(QBrush(pen.color()))
     item.setZValue(Z.NEW_MANUAL_ELEMENT_PIN)
     self._items_info.append(_PinItemInfo(item, radius, pen))