Exemple #1
0
    def __init__(self, axis, crop_extents_model, editable=True):

        self._cropColor = Qt.white

        QGraphicsItem.__init__(self)
        self.setFlag(QGraphicsItem.ItemHasNoContents)
        self.setAcceptHoverEvents(True)
        self.axis = axis
        self.crop_extents_model = crop_extents_model

        self._width = 0
        self._height = 0

        # Add shading item first so crop lines are drawn on top.
        self._shading_item = ExcludedRegionShading(self, self.crop_extents_model)

        self._horizontal0 = CropLine(self, "horizontal", 0)
        self._horizontal1 = CropLine(self, "horizontal", 1)
        self._vertical0 = CropLine(self, "vertical", 0)
        self._vertical1 = CropLine(self, "vertical", 1)

        self.crop_extents_model.changed.connect(self.onExtentsChanged)
        self.crop_extents_model.colorChanged.connect(self.onColorChanged)

        # keeping track which line started mouse move
        self._mouseMoveStartH = -1
        self._mouseMoveStartV = -1
        self._fractionOfDistance = 1
Exemple #2
0
    def __init__(self,
                 x=0,
                 y=10,
                 x1=0,
                 y1=0,
                 colour='green',
                 icon='images/pacman.ico'):
        QGraphicsItem.__init__(self)

        self.key = 0
        self.oldkey = 0
        self.pom = 0

        self.pocetak = 0
        self.game_over = False
        self.brojacZaSilu = 0
        self.colour = colour
        self.i = QImage(icon)
        self.i2 = QImage(icon)
        self.i3 = QImage('images/pacman2.png')
        self.img = QImage('images/pacman5.png')
        self.img2 = QImage('images/pacman6.png')

        self.pojeosilu = False
        self.way1 = 0
        self.poeni = 0
        self.zivot = 3
        self.x = x
        self.y = y
        self.x1 = x1
        self.y1 = y1
        self.konacno = x, y
Exemple #3
0
    def __init__(self, group_id, port_id, port_name, port_mode, port_type,
                 is_alternate, parent):
        QGraphicsItem.__init__(self)
        self.setParentItem(parent)

        # Save Variables, useful for later
        self.m_group_id = group_id
        self.m_port_id = port_id
        self.m_port_mode = port_mode
        self.m_port_type = port_type
        self.m_port_name = port_name
        self.m_is_alternate = is_alternate

        # Base Variables
        self.m_port_width = 15
        self.m_port_height = canvas.theme.port_height
        self.m_port_font = QFont()
        self.m_port_font.setFamily(canvas.theme.port_font_name)
        self.m_port_font.setPixelSize(canvas.theme.port_font_size)
        self.m_port_font.setWeight(canvas.theme.port_font_state)

        self.m_line_mov = None
        self.m_hover_item = None

        self.m_mouse_down = False
        self.m_cursor_moving = False

        self.setFlags(QGraphicsItem.ItemIsSelectable)

        if options.auto_select_items:
            self.setAcceptHoverEvents(True)
	def __init__(self, parentItem, segments, colour):
		QGraphicsItem.__init__(self, parent=parentItem)
		self.colour_name = colour
		self.shape = QPainterPath()
		self.labels = QGraphicsItemGroup(self)
		self.bbox = QRectF(0, 0, 0, 0)
		for (p1, p2), label in segments:
			lvect = QVector2D(p2 - p1)
			lpath = QPainterPath()
			m = TWY_line_margin
			l = lvect.length()
			plst = [QPointF(-m, 0), QPointF(-m/3, -m), QPointF(l + m/3, -m), QPointF(l + m, 0), QPointF(l + m/3, m), QPointF(-m/3, m)]
			lpath.addPolygon(QPolygonF(plst))
			lrot = QTransform()
			lrot.rotateRadians(atan2(lvect.y(), lvect.x()))
			lpath = lrot.map(lpath)
			lpath.translate(p1)
			self.shape.addPath(lpath)
			rect = QRectF(p1, p2).normalized()
			if label != None:
				self.labels.addToGroup(TaxiwayLabelItem(label, rect.center(), self))
			self.bbox |= rect
		self.shape.setFillRule(Qt.WindingFill)
		self.mouse_highlight = False
		self.labels.setVisible(False)
Exemple #5
0
 def __init__(self, src, title, draw_sections):
     QGraphicsItem.__init__(self, None)
     self.source_file = src
     self.title = title
     self.bounding_rect = QRectF()
     self.line_paths = []
     self.single_points = []
     self.text_labels = []
     for colour, points in draw_sections:
         for coords, txt in points:
             if txt != None:
                 label_item = BgHandDrawingLabelItem(colour, txt, self)
                 self.text_labels.append(label_item)
                 label_item.setPos(self.qpoint_rebound(coords))
         if len(points) == 1:
             point_item = BgHandDrawingPointItem(colour, self)
             self.single_points.append(point_item)
             point_item.setPos(self.qpoint_rebound(points[0][0]))
         else:
             path = QPainterPath()
             path.moveTo(self.qpoint_rebound(points[0][0]))
             for p, txt in points[1:]:
                 path.lineTo(self.qpoint_rebound(p))
             self.line_paths.append((colour, path))
     self.setVisible(False)
	def __init__(self, ad_data, physical_index):
		QGraphicsItem.__init__(self, parent=None)
		self.physical_location = ad_data.navpoint.code
		self.physical_runway_index = physical_index
		self.base_rwy, self.opposite_runway = ad_data.physicalRunway(physical_index)
		width_metres, surface = ad_data.physicalRunwayData(physical_index)
		self.width = m2NM * width_metres
		self.paved = is_paved_surface(surface)
		self.occupation_indication = 0
		thr = self.base_rwy.threshold().toRadarCoords()
		self.length = thr.distanceTo(self.opposite_runway.threshold().toRadarCoords())
		item_rot = self.base_rwy.orientation().trueAngle()
		self.label1 = RunwayNameItem(self.base_rwy.name, item_rot, self)
		self.label2 = RunwayNameItem(self.opposite_runway.name, item_rot + 180, self)
		self.label1.setPos(0, 0)
		self.label2.setPos(0, -self.length)
		self.LOC_item1 = LocaliserItem(self.base_rwy, self) # CAUTION: accessed from outside of class
		self.LOC_item2 = LocaliserItem(self.opposite_runway, self) # CAUTION: accessed from outside of class
		self.LOC_item2.setPos(0, -self.length)
		if self.base_rwy.LOC_bearing != None:
			self.LOC_item1.setRotation(self.base_rwy.LOC_bearing.trueAngle() - item_rot)
		if self.opposite_runway.LOC_bearing == None:
			self.LOC_item2.setRotation(180)
		else:
			self.LOC_item2.setRotation(self.opposite_runway.LOC_bearing.trueAngle() - item_rot)
		self.rect = QRectF(-self.width / 2, -self.length, self.width, self.length)
		self.setPos(thr.toQPointF())
		self.setRotation(item_rot)
		self.setAcceptHoverEvents(True)
 def __init__(self):
     QGraphicsItem.__init__(self, None)
     self.setFlag(QGraphicsItem.ItemIgnoresTransformations, True)
     self.setVisible(False)
     self.timer = QTimer(self.scene())
     self.timer.setSingleShot(True)
     self.timer.timeout.connect(lambda: self.setVisible(False))
Exemple #8
0
    def __init__(
            self,
            text='S',
            startp=Point(x=0.0, y=0.0),
    ):
        """
        Initialisation of the class.
        """
        QGraphicsItem.__init__(self)

        self.setFlag(QGraphicsItem.ItemIsSelectable, False)

        self.text = text
        self.sc = 1.0
        self.startp = QtCore.QPointF(startp.x, -startp.y)

        pencolor = QColor(0, 200, 255)
        self.brush = QColor(0, 100, 255)

        self.pen = QPen(pencolor, 1, QtCore.Qt.SolidLine)
        self.pen.setCosmetic(True)

        self.path = QPainterPath()
        self.path.addText(QtCore.QPointF(0, 0), QFont("Arial", 10 / self.sc),
                          self.text)
Exemple #9
0
 def __init__(self, xy=(75, 75), colour='black', radius=28):
     QGraphicsItem.__init__(self)
     self.colour = colour
     self.xy = xy
     self.dx = xy[0]
     self.dy = xy[1]
     self._radius = radius
Exemple #10
0
 def __init__(self, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.setFlag(QGraphicsItem.ItemIgnoresTransformations, True)
     self.setAcceptedMouseButtons(
         Qt.NoButton
     )  # is selectable but only by explicit flag setting; no mouseclick here
     self.setFlag(QGraphicsItem.ItemIsSelectable, True)
Exemple #11
0
 def __init__(self, xy=(75, 75), dimensionality=9, radius=30):
     self.dimensionality = dimensionality
     QGraphicsItem.__init__(self)
     self.colour = QColor(155, 88, 19)
     self.dx = xy[0]
     self.dy = xy[1]
     self._radius = radius
Exemple #12
0
 def __init__(self, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.display_distance = True
     self.setVisible(False)
     self.info_box = ToolTextItem(self)
     self.setCursor(Qt.CrossCursor)
     self.mousePos = self.pos()  # dummy
    def __init__(self, axis, posModel):
        QGraphicsItem.__init__(self)
        self.setFlag(QGraphicsItem.ItemHasNoContents)

        self.axis = axis
        self.posModel = posModel

        self._width = 0
        self._height = 0

        self.thick_penX = QPen(Qt.red, self.thick_width)
        self.thick_penX.setCosmetic(True)

        self.thick_penY = QPen(Qt.green, self.thick_width)
        self.thick_penY.setCosmetic(True)

        self.thin_penX = QPen(Qt.red, self.thin_width)
        self.thin_penX.setCosmetic(True)

        self.thin_penY = QPen(Qt.green, self.thin_width)
        self.thin_penY.setCosmetic(True)

        self.x = 0
        self.y = 0

        # These child items do most of the work.
        self._horizontal_marker = SliceMarkerLine(self, "horizontal")
        self._vertical_marker = SliceMarkerLine(self, "vertical")
Exemple #14
0
    def __init__(self, parent=None):
        QGraphicsItem.__init__(self, parent)
        self.setFlag(QGraphicsItem.ItemIsMovable, True)
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setFlag(QGraphicsItem.ItemIsFocusable, True)

        self.setAcceptHoverEvents(True)
    def __init__(self, parent, direction):
        assert isinstance(parent, SliceIntersectionMarker)
        assert direction in ("horizontal", "vertical")

        self._parent = parent
        self._direction = direction
        QGraphicsItem.__init__(self, parent)
        self.setAcceptHoverEvents(True)
	def __init__(self, runway, parentItem):
		QGraphicsItem.__init__(self, parentItem)
		self.runway = runway
		self.updateFromSettings() # CAUTION: creates a few attributes
		self.draw_OM = None if runway.OM_pos == None else runway.threshold().distanceTo(runway.OM_pos)
		self.draw_MM = None if runway.MM_pos == None else runway.threshold().distanceTo(runway.MM_pos)
		self.draw_IM = None if runway.IM_pos == None else runway.threshold().distanceTo(runway.IM_pos)
		self.setVisible(False)
Exemple #17
0
    def __init__(self, parent=None):
        QGraphicsItem.__init__(self, parent)
        self.df = pd.read_pickle('../../bitmex_1m_2018.pkl')

        self.path = QPainterPath()
        for i in range(data_range):
            self.path.addRect(i / width, self.df['open'][i] / height, 10,
                              self.df['open'][i] - self.df['close'][i])
Exemple #18
0
 def __init__(self, x=0, y=0, colour='green', icon='images/rotten.png'):
     QGraphicsItem.__init__(self)
     self.colour = colour
     self.i = QImage(icon)
     self.i2 = QImage("images/heart.png")
     self.x = 0
     self.y = 0
     self.option = -1
     self.avaible = []
Exemple #19
0
 def __init__(self, xy=(-1, -1), dir=180, obrazki = None,type='stojacy',delay=500,scene=None,hp=1):
     QGraphicsItem.__init__(self)
     self.scene = scene
     self.delay=delay
     self.xy = xy
     self.dir = dir
     self.obrazek = obrazki['czolg']
     self.type=type
     self.hp = hp
Exemple #20
0
 def __init__(self, p1, p2, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.setAcceptedMouseButtons(
         Qt.NoButton
     )  # is selectable but only by explicit flag setting; no mouseclick here
     self.setFlag(QGraphicsItem.ItemIsSelectable, True)
     self.segments = breakUpLine(p1.coordinates,
                                 p2.coordinates,
                                 segmentLength=route_leg_breakUp_length)
Exemple #21
0
 def __init__(self, data, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.num = 1
     self.data = data
     self.path = QPainterPath()
     self.trans = QTransform()
     self.cached = False
     self.printed = False
     self.setZValue(0)
Exemple #22
0
 def __init__(self, radar_contact, parent_item):
     QGraphicsItem.__init__(self, parent_item)
     self.setVisible(False)
     self.info_box = ToolTextItem(self)
     self.info_box.setPos(ToolTextItem.rectangle.topLeft() / 2)
     self.radar_contact = radar_contact
     self.mouseXY = QPointF(0, 0)
     self.diff_alt_measured = None
     self.diff_speed_measured = None
 def __init__(self, acft_item):
     QGraphicsItem.__init__(self, acft_item)
     self.setVisible(False)
     self.radar_contact = acft_item.radar_contact
     self.setFlag(QGraphicsItem.ItemIgnoresTransformations, True)
     self.text_box_item = TextBoxItem(self)
     self.callout_line_start = QPointF(0, 0)
     self.callout_line_end = self.text_box_item.pos(
     ) + self.text_box_item.calloutConnectingPoint()
Exemple #24
0
    def __init__(self, tiling, delay=datetime.timedelta(milliseconds=1000)):
        QGraphicsItem.__init__(self, parent=None)
        self.delay = delay
        self.setFlags(QGraphicsItem.ItemUsesExtendedStyleOption)

        self._tiling = tiling
        self._indicate = numpy.zeros(len(tiling))
        self._zeroProgressTimestamp = [datetime.datetime.now()] * len(tiling)
        self._last_zero = False
Exemple #25
0
    def __init__(self,
                 start_socket,
                 end_socket=None,
                 id_=None,
                 style="solid",
                 curve=True):
        QGraphicsItem.__init__(self, None)

        if id_ is None:
            id_ = id(self)

        self.id = id_

        self._rect = QRectF(0, 0, 0, 0)

        self._isTempConnection = False

        self._path = QPainterPath()

        self._activeStyle = style
        self._curve = curve
        self._isActive = False

        self._color = start_socket.colorRef()
        self._pen = QPen(self._color)

        self._penWidthInactive = 2
        self._penWidthActive = 4
        self._penWidthBlink = 8

        self._penWidth = self._penWidthInactive

        self.setStartSocket(start_socket)

        self._keyPoints = []

        self._centerWidget = None

        if end_socket is None:
            # creating a dummy endHook for temporary connection dragging,
            #  the "input" and shape/style parameters have no effect
            end_mode = "output" if start_socket.isInput() else "input"
            end_socket = QtSocket(start_socket.parentSocketRow(),
                                  end_mode,
                                  start_socket._shape,
                                  parent_item=self)
            end_socket.boundingRect().setSize(QSizeF(2.0, 2.0))
            self._isTempConnection = True

        self.setEndConnection(end_socket)

        self.updateStartPos()

        self.setZValue(-1.0)
        self.setActiveState(False)

        self._blink_depth = 0
Exemple #26
0
 def __init__(self, xy=(-1, -1), dir=180, obrazki = None,scene=None):
     QGraphicsItem.__init__(self)
     self.licznik = 0
     self.xy = xy
     self.dir = dir
     self.obrazek = obrazki['player']
     self.hp=3
     self.scene = scene
     self.result=''
Exemple #27
0
	def __init__(self, sourceNode, destNode):
		'''Constructor giving the two nodes'''
		QGraphicsItem.__init__(self)

		self.sourcePoint = QtCore.QPointF()
		self.destPoint = QtCore.QPointF()
		self.setAcceptedMouseButtons(QtCore.Qt.RightButton)
		self.source = sourceNode
		self.dest = destNode
		self.adjust()
Exemple #28
0
 def __init__(self, parent_item):
     QGraphicsItem.__init__(self, parent_item)
     self.acft = None  # to be given on .start
     self.setVisible(False)
     self.bbox = QRectF(0, 0, 0, 0)
     self.node_route = None  # None if start/end point too far from ground net; list of nodes otherwise
     self.parking_position = None
     self.target_point = None  # invalid init value; last mouse release target (EarthCoords)
     self.snapped_OK = False
     self.lines = []
Exemple #29
0
    def __init__(self, nr, closed, parentEntity):
        QGraphicsItem.__init__(self)
        Shape.__init__(self, nr, closed, parentEntity)

        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setAcceptedMouseButtons(QtCore.Qt.NoButton)

        self.selectionChangedCallback = None
        self.enableDisableCallback = None

        self.starrow = None
        self.enarrow = None
Exemple #30
0
    def __init__(self, zvalue=100, **kwargs):
        QGraphicsItem.__init__(self, **kwargs)

        # no need to implement paint()
        # but still need to implement boundingRect()
        self.setFlag(QGraphicsItem.ItemHasNoContents)

        self.rays = None

        self._selected = False

        self.setZValue(zvalue)
Exemple #31
0
    def __init__(self, nr, closed, parentEntity):
        QGraphicsItem.__init__(self)
        Shape.__init__(self, nr, closed, parentEntity)

        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setAcceptedMouseButtons(QtCore.Qt.NoButton)

        self.selectionChangedCallback = None
        self.enableDisableCallback = None

        self.starrow = None
        self.enarrow = None
Exemple #32
0
    def __init__(self, parent, direction, index):
        assert isinstance(parent, CroppingMarkers)
        assert direction in ("horizontal", "vertical")

        self._parent = parent
        self._direction = direction
        self._index = index
        QGraphicsItem.__init__(self, parent)
        self.setAcceptHoverEvents(True)
        self._position = 0
        self._line_thickness = 1

        # keeping track which line started mouse move
        self._mouseMoveStartH = -1
        self._mouseMoveStartV = -1
Exemple #33
0
    def __init__(self):
        QGraphicsItem.__init__(self)

        self._width = 0
        self._height = 0

        self.penDotted = QPen(Qt.red, 2, Qt.DotLine, Qt.RoundCap, Qt.RoundJoin)
        self.penDotted.setCosmetic(True)

        self.penSolid = QPen(Qt.red, 2)
        self.penSolid.setCosmetic(True)

        self.x = 0
        self.y = 0
        self.brushSize = 0

        self.mode = self.modeXYPosition
        self._enabled = True
Exemple #34
0
    def __init__(self, text='S', startp=Point(x=0.0, y=0.0),):
        """
        Initialisation of the class.
        """
        QGraphicsItem.__init__(self)

        self.setFlag(QGraphicsItem.ItemIsSelectable, False)

        self.text = text
        self.sc = 1.0
        self.startp = QtCore.QPointF(startp.x, -startp.y)

        pencolor = QColor(0, 200, 255)
        self.brush = QColor(0, 100, 255)

        self.pen = QPen(pencolor, 1, QtCore.Qt.SolidLine)
        self.pen.setCosmetic(True)

        self.path = QPainterPath()
        self.path.addText(QtCore.QPointF(0, 0),
                          QFont("Arial", 10/self.sc),
                          self.text)
Exemple #35
0
 def __init__(self, index):
     Node.__init__(self, index)
     QGraphicsItem.__init__(self)
     # 绘制时的位置
     self.index_draw = 0