Ejemplo n.º 1
0
    def center(self):

        return QtCore.QPointF(0, 0)
Ejemplo n.º 2
0
def test_laser_graphics_selection(qtbot: QtBot):
    graphics = LaserGraphicsView(GraphicsOptions())
    qtbot.addWidget(graphics)

    x = np.random.random((10, 10))
    graphics.drawImage(x, QtCore.QRectF(0, 0, 100, 100), "x")

    qtbot.waitExposed(graphics)

    # Test rectangle selector and center pixel selecting
    graphics.startRectangleSelection()

    event = QtGui.QMouseEvent(
        QtCore.QEvent.MouseButtonPress,
        graphics.mapFromScene(QtCore.QPointF(1, 1)),
        QtCore.Qt.LeftButton,
        QtCore.Qt.LeftButton,
        QtCore.Qt.NoModifier,
    )

    graphics.mousePressEvent(event)
    event.setLocalPos(graphics.mapFromScene(QtCore.QPointF(9, 9)))
    graphics.mouseMoveEvent(event)
    graphics.mouseReleaseEvent(event)

    assert graphics.mask[0][0]
    assert np.all(graphics.mask[1:, :] == 0)
    assert np.all(graphics.mask[:, 1:] == 0)

    graphics.endSelection()
    assert graphics.selection_item is None
    assert np.all(graphics.mask == 0)
    assert not graphics.posInSelection(graphics.mapFromScene(QtCore.QPoint(1, 1)))

    # Test lasso works
    graphics.startLassoSelection()

    event = QtGui.QMouseEvent(
        QtCore.QEvent.MouseButtonPress,
        graphics.mapFromScene(QtCore.QPointF(1, 1)),
        QtCore.Qt.LeftButton,
        QtCore.Qt.LeftButton,
        QtCore.Qt.NoModifier,
    )

    graphics.mousePressEvent(event)
    event.setLocalPos(graphics.mapFromScene(QtCore.QPointF(99, 1)))
    graphics.mouseMoveEvent(event)
    event.setLocalPos(graphics.mapFromScene(QtCore.QPointF(99, 99)))
    graphics.mouseMoveEvent(event)
    event.setLocalPos(graphics.mapFromScene(QtCore.QPointF(91, 99)))
    graphics.mouseMoveEvent(event)
    event.setLocalPos(graphics.mapFromScene(QtCore.QPointF(91, 11)))
    graphics.mouseMoveEvent(event)
    event.setLocalPos(graphics.mapFromScene(QtCore.QPointF(1, 11)))
    graphics.mouseMoveEvent(event)
    graphics.mouseReleaseEvent(event)

    assert np.all(graphics.mask[0, :])
    assert np.all(graphics.mask[:, -1])
    assert np.all(graphics.mask[1:, :-1] == 0)

    assert graphics.posInSelection(graphics.mapFromScene(QtCore.QPoint(1, 1)))
    assert not graphics.posInSelection(graphics.mapFromScene(QtCore.QPoint(11, 11)))
Ejemplo n.º 3
0
def addTestItems(scene):

    # add items to the scene
    circle1 = gic.GraphicsCollection()
    circle1.Circle(0., 0., 0.1)
    circle1.pen.setWidthF(0.2)
    circle1.pen.setColor(QtGui.QColor(0, 0, 0, 255))
    circle1.brush.setColor(QtGui.QColor(255, 255, 0, 255))

    circle2 = gic.GraphicsCollection()
    circle2.Circle(-0.3, -0.3, 0.3)
    circle2.pen.setWidthF(0.02)
    circle2.pen.setColor(QtGui.QColor(0, 0, 0, 255))
    circle2.brush.setColor(QtGui.QColor(255, 0, 0, 255))

    circle3 = gic.GraphicsCollection()
    circle3.Circle(0.5, 0.5, 0.2)
    circle3.pen.setWidthF(0.02)
    circle3.pen.setColor(QtGui.QColor(0, 255, 0, 255))
    circle3.brush.setColor(QtGui.QColor(30, 30, 255, 100))

    circle4 = gic.GraphicsCollection()
    circle4.Circle(-0.1, 0.4, 0.2)
    circle4.pen.setWidthF(0.02)
    circle4.pen.setColor(QtGui.QColor(0, 0, 255, 255))
    circle4.brush.setColor(QtGui.QColor(30, 30, 30, 255))

    rectangle1 = gic.GraphicsCollection()
    rectangle1.Rectangle(-0.20, 0.10, 0.70, 0.35)
    rectangle1.pen.setWidthF(0.02)
    rectangle1.pen.setColor(QtGui.QColor(0, 0, 255, 255))
    rectangle1.brush.setColor(QtGui.QColor(0, 255, 0, 180))

    text1 = gic.GraphicsCollection()
    font = QtGui.QFont('Arial', 20)
    font.setBold(True)
    text1.Text(0, 0.90, 'This is a text', font)
    text1.pen.setColor(QtGui.QColor(50, 30, 200, 255))

    point1 = gic.GraphicsCollection()
    point1.Point(0, 0)
    point1.pen.setColor(QtGui.QColor(255, 0, 0, 255))
    point1.pen.setWidthF(0.02)

    polygon1 = gic.GraphicsCollection()
    polygon = QtGui.QPolygonF()
    polygon.append(QtCore.QPointF(0.20, 0.10))
    polygon.append(QtCore.QPointF(0.45, 0.10))
    polygon.append(QtCore.QPointF(0.45, -0.40))
    polygon.append(QtCore.QPointF(0.15, -0.40))
    polygon.append(QtCore.QPointF(0.0, 0.0))
    polygon1.pen.setWidthF(0.02)
    polygon1.pen.setColor(QtGui.QColor(0, 0, 0, 255))
    polygon1.brush.setColor(QtGui.QColor(0, 0, 255, 150))
    polygon1.Polygon(polygon)

    # create on the fly scene attributes which can be accessed deleteTestItems
    scene.itemc1 = GraphicsItem.GraphicsItem(circle1)
    scene.itemc2 = GraphicsItem.GraphicsItem(circle2)
    scene.itemc3 = GraphicsItem.GraphicsItem(circle3)
    scene.itemc4 = GraphicsItem.GraphicsItem(circle4)
    scene.itemr1 = GraphicsItem.GraphicsItem(rectangle1)

    # add test items to the scene
    scene.addItem(scene.itemc1)
    scene.addItem(scene.itemc2)
    scene.addItem(scene.itemc3)
    scene.addItem(scene.itemc4)
    scene.addItem(scene.itemr1)
Ejemplo n.º 4
0
 def boundingRect(self):
     return QtCore.QRectF(QtCore.QPointF(0, 0), QtCore.QSizeF(self.p.size()))
Ejemplo n.º 5
0
	def points(pts):
		pts = np.array(pts)
		if transform is not None:
			pts = transform(pts)
		return [QtCore.QPointF(*pt) for pt in (pts * scale)]
Ejemplo n.º 6
0
    def createMenu(self, category, type):
        sw = self.window.scene.sceneRect().width()
        xOffset = 15
        yOffset = 10
        maxExamples = Colors.menuCount
        menuIndex = 1
        name = str(category.attribute('name'))
        currentNode = category.firstChild()
        currentMenu = '%s -menu%d' % (name, menuIndex)

        while not currentNode.isNull():
            movieIn = self.score.insertMovie(currentMenu)
            movieOut = self.score.insertMovie(currentMenu + ' -out')
            movieNextTopOut = self.score.insertMovie(currentMenu + ' -top_out')
            movieNextBottomOut = self.score.insertMovie(currentMenu + ' -bottom_out')
            movieNextTopIn = self.score.insertMovie(currentMenu + ' -top_in')
            movieNextBottomIn = self.score.insertMovie(currentMenu + ' -bottom_in')
            movieShake = self.score.insertMovie(currentMenu + ' -shake')

            i = 0
            while not currentNode.isNull() and i < maxExamples:
                # Create a normal menu button.
                label = str(currentNode.toElement().attribute('name'))
                item = TextButton(label, TextButton.LEFT, type,
                        self.window.scene)
                currentNode = currentNode.nextSibling()

                # Skip the OpenGL examples if they can't run.
                if str(currentNode.toElement().attribute('dirname')) == 'opengl':
                    if not Colors.openGlAvailable:
                        currentNode = currentNode.nextSibling()

                item.setRecursiveVisible(False)
                item.setZValue(10)
                ih = item.sceneBoundingRect().height()
                iw = item.sceneBoundingRect().width()
                ihp = ih + 3

                # Create in-animation.
                anim = DemoItemAnimation(item, DemoItemAnimation.ANIM_IN)
                anim.setDuration(float(1000 + (i * 20)) * Colors.animSpeedButtons)
                anim.setStartPos(QtCore.QPointF(xOffset, -ih))
                anim.setPosAt(0.20, QtCore.QPointF(xOffset, -ih))
                anim.setPosAt(0.50, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY + (10 * float(i / 4.0))))
                anim.setPosAt(0.60, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                anim.setPosAt(0.70, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY + (5 * float(i / 4.0))))
                anim.setPosAt(0.80, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                anim.setPosAt(0.90, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY + (2 * float(i / 4.0))))
                anim.setPosAt(1.00, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                movieIn.append(anim)

                # Create out-animation.
                anim = DemoItemAnimation(item, DemoItemAnimation.ANIM_OUT)
                anim.hideOnFinished = True
                anim.setDuration((700 + (30 * i)) * Colors.animSpeedButtons)
                anim.setStartPos(QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                anim.setPosAt(0.60, QtCore.QPointF(xOffset, 600 - ih - ih))
                anim.setPosAt(0.65, QtCore.QPointF(xOffset + 20, 600 - ih))
                anim.setPosAt(1.00, QtCore.QPointF(sw + iw, 600 - ih))
                movieOut.append(anim)

                # Create shake-animation.
                anim = DemoItemAnimation(item)
                anim.setDuration(700 * Colors.animSpeedButtons)
                anim.setStartPos(QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                anim.setPosAt(0.55, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY - i*2.0))
                anim.setPosAt(0.70, QtCore.QPointF(xOffset - 10, (i * ihp) + yOffset + Colors.contentStartY - i*1.5))
                anim.setPosAt(0.80, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY - i*1.0))
                anim.setPosAt(0.90, QtCore.QPointF(xOffset - 2, (i * ihp) + yOffset + Colors.contentStartY - i*0.5))
                anim.setPosAt(1.00, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                movieShake.append(anim)

                # Create next-menu top-out-animation.
                anim = DemoItemAnimation(item, DemoItemAnimation.ANIM_OUT)
                anim.hideOnFinished = True
                anim.setDuration((200 + (30 * i)) * Colors.animSpeedButtons)
                anim.setStartPos(QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                anim.setPosAt(0.70, QtCore.QPointF(xOffset, yOffset + Colors.contentStartY))
                anim.setPosAt(1.00, QtCore.QPointF(-iw, yOffset + Colors.contentStartY))
                movieNextTopOut.append(anim)

                # Create next-menu bottom-out-animation.
                anim = DemoItemAnimation(item, DemoItemAnimation.ANIM_OUT)
                anim.hideOnFinished = True
                anim.setDuration((200 + (30 * i)) * Colors.animSpeedButtons)
                anim.setStartPos(QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                anim.setPosAt(0.70, QtCore.QPointF(xOffset, (maxExamples * ihp) + yOffset + Colors.contentStartY))
                anim.setPosAt(1.00, QtCore.QPointF(-iw, (maxExamples * ihp) + yOffset + Colors.contentStartY))
                movieNextBottomOut.append(anim)

                # Create next-menu top-in-animation.
                anim = DemoItemAnimation(item, DemoItemAnimation.ANIM_IN)
                anim.setDuration((700 - (30 * i)) * Colors.animSpeedButtons)
                anim.setStartPos(QtCore.QPointF(-iw, yOffset + Colors.contentStartY))
                anim.setPosAt(0.30, QtCore.QPointF(xOffset, yOffset + Colors.contentStartY))
                anim.setPosAt(1.00, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                movieNextTopIn.append(anim)

                # Create next-menu bottom-in-animation.
                reverse = maxExamples - i
                anim = DemoItemAnimation(item, DemoItemAnimation.ANIM_IN)
                anim.setDuration((1000 - (30 * reverse)) * Colors.animSpeedButtons)
                anim.setStartPos(QtCore.QPointF(-iw, (maxExamples * ihp) + yOffset + Colors.contentStartY))
                anim.setPosAt(0.30, QtCore.QPointF(xOffset, (maxExamples * ihp) + yOffset + Colors.contentStartY))
                anim.setPosAt(1.00, QtCore.QPointF(xOffset, (i * ihp) + yOffset + Colors.contentStartY))
                movieNextBottomIn.append(anim)

                i += 1

            if not currentNode.isNull() and i == maxExamples:
                # We need another menu, so register for 'more' and 'back'
                # buttons.
                menuIndex += 1
                self.info.setdefault(currentMenu, {})['more'] = '%s -menu%d' % (name, menuIndex)
                currentMenu = '%s -menu%d' % (name, menuIndex)
                self.info.setdefault(currentMenu, {})['back'] = '%s -menu%d' % (name, menuIndex - 1)
Ejemplo n.º 7
0
    scene.addItem(p3)
    scene.addItem(p4)
    scene.addItem(p5)
    scene.addItem(p6)

    machine = QtCore.QStateMachine()
    state1 = QtCore.QState(machine)
    state2 = QtCore.QState(machine)
    state3 = QtCore.QState(machine)
    machine.setInitialState(state1)

    # State 1.
    state1.assignProperty(button, 'text', "Switch to state 2")
    state1.assignProperty(widget, 'geometry', QtCore.QRectF(0, 0, 400, 150))
    state1.assignProperty(box, 'geometry', QtCore.QRect(-200, 150, 200, 150))
    state1.assignProperty(p1, 'pos', QtCore.QPointF(68, 185))
    state1.assignProperty(p2, 'pos', QtCore.QPointF(168, 185))
    state1.assignProperty(p3, 'pos', QtCore.QPointF(268, 185))
    state1.assignProperty(p4, 'pos', QtCore.QPointF(68 - 150, 48 - 150))
    state1.assignProperty(p5, 'pos', QtCore.QPointF(168, 48 - 150))
    state1.assignProperty(p6, 'pos', QtCore.QPointF(268 + 150, 48 - 150))
    state1.assignProperty(p1, 'rotation', 0.0)
    state1.assignProperty(p2, 'rotation', 0.0)
    state1.assignProperty(p3, 'rotation', 0.0)
    state1.assignProperty(p4, 'rotation', -270.0)
    state1.assignProperty(p5, 'rotation', -90.0)
    state1.assignProperty(p6, 'rotation', 270.0)
    state1.assignProperty(boxProxy, 'opacity', 0.0)
    state1.assignProperty(p1, 'opacity', 1.0)
    state1.assignProperty(p2, 'opacity', 1.0)
    state1.assignProperty(p3, 'opacity', 1.0)
Ejemplo n.º 8
0
 def __init__(self, step):
     Item.__init__(self)
     self._step = step
     self._pos = QtCore.QPointF(0, 0)
     self._uid = str(uuid.uuid1())
     self._id = step.getIdentifier()
Ejemplo n.º 9
0
    def snipe_select(self, objtype=None, graph=Inject('gearbox/graph')):
        self.main.key_cancel.connect(self.snipe_cancel)

        nodes = graph.selected_nodes()

        nodes = [node.parent if node.collapsed else node for node in nodes]

        if not nodes:
            pipes = graph.selected_pipes()
            if not pipes:
                nodes = [graph.top]
            else:
                nodes = [pipe.parent for pipe in pipes]

        keys = [2]

        for n in nodes:
            if n.collapsed:
                continue

            for i, obj in enumerate(self.get_visible_objs(n, objtype=objtype)):
                key_codes = [key + ord('A') for key in reversed(keys)]
                snipe_text = ''.join([chr(key).upper() for key in key_codes])
                text = SnipeCodeItem(snipe_text)

                text.setZValue(100)
                graph.scene().addItem(text)

                if isinstance(obj, NodeItem):
                    text.setPos(
                        obj.mapToScene((obj.boundingRect().bottomLeft() +
                                        obj.boundingRect().bottomRight()) /
                                       2) -
                        QtCore.QPointF(text.boundingRect().width() / 2,
                                       text.boundingRect().height()))
                else:
                    text.setPos(
                        obj.mapToScene(obj.path().pointAtPercent(0.5)) -
                        QtCore.QPointF(text.boundingRect().width(),
                                       text.boundingRect().height()) / 2)

                self.main.change_domain('_snipe')
                shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(*key_codes),
                                               self.main)

                shortcut.activated.connect(partial(self.snipe_shot, obj))

                # if len(keys) > 0:
                #     shortcut.activatedAmbiguously.connect(
                #         self.snipe_shot_prefix_test)
                # shortcut.activatedAmbiguously.connect(
                #     partial(
                #         self.snipe_shot_prefix, prefix=snipe_text[:-1]))

                snipe_shortcuts.append((text, shortcut))

                for pos in range(len(keys) + 1):
                    if pos == len(keys):
                        keys.insert(0, 0)
                        break

                    keys[pos] += 1

                    if keys[pos] < 25:
                        break
                    else:
                        keys[pos] = 0
Ejemplo n.º 10
0
 def endPos(self):
     return QtCore.QPointF(0, 0)
Ejemplo n.º 11
0
    def timerEvent(self):
        # Don't move too far away.
        lineToCenter = QtCore.QLineF(QtCore.QPointF(0, 0),
                                     self.mapFromScene(0, 0))
        if lineToCenter.length() > 150:
            angleToCenter = math.acos(lineToCenter.dx() /
                                      lineToCenter.length())
            if lineToCenter.dy() < 0:
                angleToCenter = Mouse.TwoPi - angleToCenter
            angleToCenter = Mouse.normalizeAngle((Mouse.Pi - angleToCenter) +
                                                 Mouse.Pi / 2)

            if angleToCenter < Mouse.Pi and angleToCenter > Mouse.Pi / 4:
                # Rotate left.
                self.angle += [-0.25, 0.25][self.angle < -Mouse.Pi / 2]
            elif angleToCenter >= Mouse.Pi and angleToCenter < (
                    Mouse.Pi + Mouse.Pi / 2 + Mouse.Pi / 4):
                # Rotate right.
                self.angle += [-0.25, 0.25][self.angle < Mouse.Pi / 2]
        elif math.sin(self.angle) < 0:
            self.angle += 0.25
        elif math.sin(self.angle) > 0:
            self.angle -= 0.25

        # Try not to crash with any other mice.
        dangerMice = self.scene().items(
            QtGui.QPolygonF([
                self.mapToScene(0, 0),
                self.mapToScene(-30, -50),
                self.mapToScene(30, -50)
            ]))

        for item in dangerMice:
            if item is self:
                continue

            lineToMouse = QtCore.QLineF(QtCore.QPointF(0, 0),
                                        self.mapFromItem(item, 0, 0))
            angleToMouse = math.acos(lineToMouse.dx() / lineToMouse.length())
            if lineToMouse.dy() < 0:
                angleToMouse = Mouse.TwoPi - angleToMouse
            angleToMouse = Mouse.normalizeAngle((Mouse.Pi - angleToMouse) +
                                                Mouse.Pi / 2)

            if angleToMouse >= 0 and angleToMouse < Mouse.Pi / 2:
                # Rotate right.
                self.angle += 0.5
            elif angleToMouse <= Mouse.TwoPi and angleToMouse > (Mouse.TwoPi -
                                                                 Mouse.Pi / 2):
                # Rotate left.
                self.angle -= 0.5

        # Add some random movement.
        if len(dangerMice) > 1 and (QtCore.qrand() % 10) == 0:
            if QtCore.qrand() % 1:
                self.angle += (QtCore.qrand() % 100) / 500.0
            else:
                self.angle -= (QtCore.qrand() % 100) / 500.0

        self.speed += (-50 + QtCore.qrand() % 100) / 100.0

        dx = math.sin(self.angle) * 10
        self.mouseEyeDirection = [dx / 5, 0.0][QtCore.qAbs(dx / 5) < 1]

        self.setTransform(QtGui.QTransform().rotate(dx))
        self.setPos(self.mapToParent(0, -(3 + math.sin(self.speed) * 3)))
Ejemplo n.º 12
0
 def startPos(self):
     return QtCore.QPointF(0, 0)
Ejemplo n.º 13
0
 def _update_extents(self):
     self.minValue = QtCore.QPointF(self.xy_data['x'].min(),
                                    self.xy_data['y'].min())
     self.maxValue = QtCore.QPointF(self.xy_data['x'].max(),
                                    self.xy_data['y'].max())
Ejemplo n.º 14
0
def hier_layout(self):
    if self.collapsed:
        node_layout(self)
        return

    for node in self._nodes:
        if hasattr(node, 'layout'):
            node.layout()

    for node in self._nodes:
        gvn = self.get_layout_node(node)
        try:
            del gvn.attr['width']
            del gvn.attr['height']
        except KeyError:
            pass

        if node._layout != minimized_layout:
            # gvn.attr['label'] = gv_utils.get_node_record(node).replace(
            #     '\n', '')
            node_layout_rec = gv_utils.get_node_record(node)
            # print('-' * 60)
            # print(f'Node layout for {node.model.name}')
            # print('-' * 60)
            # print(node_layout_rec)
            gvn.attr['label'] = node_layout_rec.replace('\n', '')
        else:
            gvn.attr['label'] = ""
            gvn.attr['width'] = 1 / 72
            gvn.attr['height'] = 1 / 72

    if not self.layout_graph.subgraphs():
        self.layout_graph.add_subgraph([
            self.layout_graph.get_node(f'i{i}')
            for i in range(len(self.inputs))
        ],
                                       'sources',
                                       rank='same')
        self.layout_graph.add_subgraph([
            self.layout_graph.get_node(f'o{i}')
            for i in range(len(self.outputs))
        ],
                                       'sink',
                                       rank='same')

    # for i in range(len(self.inputs)):
    #     gvn = self.layout_graph.get_node(f'i{i}')

    # for i in range(len(self.outputs)):
    #     gvn = self.layout_graph.get_node(f'o{i}')

    # for pipe in self.pipes:
    #     gve = self.get_layout_edge(pipe)

    self.layout_graph.layout(prog='dot')

    # if self.model.name == '/riscv':
    #     # if self.model.name == '':
    #     self.layout_graph.draw('proba.png')
    #     self.layout_graph.draw('proba.dot')

    # self.layout_graph.draw(f'{self.model.name.replace("/", "_")}.png')
    # self.layout_graph.draw(f'{self.model.name.replace("/", "_")}.dot')

    def gv_point_load(point):
        return tuple(float(num) for num in point.split(',')[-2:])

    # if self.name:
    #     import pdb; pdb.set_trace()

    padding_y = 40
    padding_x = -5

    bounding_box = None
    # print(f"Layout for: {node.name}")
    for node in self._nodes:
        gvn = self.get_layout_node(node)
        pos = gv_point_load(gvn.attr['pos'])
        node_bounding_box = QtCore.QRectF(pos[0] - node.width / 2,
                                          pos[1] - node.height / 2, node.width,
                                          node.height)
        # print(
        #     f'  bb: {node.name}: {pos[0], pos[1], float(gvn.attr["width"])*72, float(gvn.attr["height"])*72} -> {node_bounding_box}'
        # )
        node.setPos(node_bounding_box.x(), node_bounding_box.y())
        if bounding_box is None:
            bounding_box = node_bounding_box
        else:
            bounding_box = bounding_box.united(node_bounding_box)

    if self.inputs:
        port_height = self.inputs[0].boundingRect().height()

        for i, p in enumerate(self.inputs):
            gvn = self.layout_graph.get_node(f'i{i}')
            pos = gv_point_load(gvn.attr['pos'])
            node_bounding_box = QtCore.QRectF(pos[0] - port_height / 2,
                                              pos[1] - port_height / 2 + 0.5,
                                              port_height, port_height)
            # print(
            #     f'  bb: {p.name}: {pos[0], pos[1], float(gvn.attr["width"])*72, float(gvn.attr["height"])*72} -> {node_bounding_box}'
            # )
            p.setPos(node_bounding_box.x(), node_bounding_box.y())
            bounding_box = bounding_box.united(node_bounding_box)

    if self.outputs:
        port_height = self.outputs[0].boundingRect().height()

        for i, p in enumerate(self.outputs):
            gvn = self.layout_graph.get_node(f'o{i}')
            pos = gv_point_load(gvn.attr['pos'])
            node_bounding_box = QtCore.QRectF(pos[0] - port_height / 2,
                                              pos[1] - port_height / 2 + 0.5,
                                              port_height, port_height)
            # print(
            #     f'  bb: {p.name}: {pos[0], pos[1], float(gvn.attr["width"])*72, float(gvn.attr["height"])*72} -> {node_bounding_box}'
            # )
            p.setPos(node_bounding_box.x(), node_bounding_box.y())
            bounding_box = bounding_box.united(node_bounding_box)

    for pipe in self.pipes:
        gve = self.get_layout_edge(pipe)
        path = [gv_point_load(point) for point in gve.attr['pos'].split()]
        pipe.layout_path = [QtCore.QPointF(p[0], p[1]) for p in path]

        # max_y = max(max_y, *(p.y() for p in pipe.layout_path))

    self.layers = []

    class Layer(list):
        def __init__(self, node):
            super().__init__([node])
            self.rect = node.boundingRect()
            self.rect.translate(node.pos())

        def __str__(self):
            return str(self.rect)

        def __repr__(self):
            return repr(self.rect)

        def add(self, node):
            rect = node.boundingRect()
            rect.translate(node.pos())

            if ((self.rect.left() < rect.right())
                    and (self.rect.right() > rect.left())):
                self.append(node)
                self.sort(key=lambda n: n.y())
                return True
            else:
                return False

    def find_layer(node):
        for layer in self.layers:
            if layer.add(node):
                return
        else:
            self.layers.append(Layer(node))

    # print(f"  Bounding box: {bounding_box}")

    self.layers = sorted(self.layers, key=lambda l: l.rect.left())
    for node in self._nodes:
        find_layer(node)

    for item in (self._nodes + self.inputs + self.outputs):
        # node.setY(max_y - node.y() + padding)
        item.setPos(
            item.x() - bounding_box.x() + padding_x,
            bounding_box.height() -
            (item.y() - bounding_box.y() + item._height) + padding_y)
        # print(f'  {item.name}: {item.pos()}')

    for p in self.inputs:
        p.setX(padding_x)

    for p in self.outputs:
        p.setX(bounding_box.width() + padding_x)

    for pipe in self.pipes:
        for p in pipe.layout_path:
            p.setX(p.x() - bounding_box.x() + padding_x)
            p.setY(bounding_box.height() - (p.y() - bounding_box.y()) +
                   padding_y)

    if self.parent is not None:
        self.size_expander(self)
    else:
        for p in self.pipes:
            p.draw_path()
Ejemplo n.º 15
0
    def applyData(self, items=list(), maya=False):
        '''
        This is temporary to read in json files.
        '''
        # read in the file with the read function which will return the
        # data into a dictionary we can unpack
        # if there is data, then we will iterate through the dictionary and make the data
        # set the center point as zero and check if the scene is passed. If scene is passed
        if not items:
            items = self._data.keys()
        center_point = QtCore.QPointF()
        if self.scene:
            center_point = self.scene.sceneRect().center()
        for item in items:
            if self._data.has_key(item):
                # store the point array for the button so we can create a polygon.
                if maya:
                    import rigrepo.ui.viewport as viewport
                    import maya.api.OpenMayaUI as omui2
                    activeView = omui2.M3dView().active3dView()
                    point_array = list()
                    for point in self._data[item]["points"]:
                        pointXY = viewport.viewToWorld(
                            point[0],
                            activeView.portHeight() - point[1])
                        print point, pointXY
                        pointZ = self._data[item]["zValue"]

                        point_array.append(
                            (pointXY[0].x, pointXY[0].y, pointZ))
                    color = QtGui.QColor(*self._data[item]["color"])
                    color = color.getRgbF()
                    # create the polygon using the points
                    mc.polyCreateFacet(name=item,
                                       ch=False,
                                       tx=1,
                                       s=1,
                                       p=point_array)
                    # select the polygon so we can assign the vertex colors to it.
                    mc.select(item)
                    mc.polyColorPerVertex(rgb=color[0:3], a=color[3], cdo=True)
                    mc.addAttr(item, ln="selectableItems", dt="string")
                    mc.setAttr("{}.selectableItems".format(item),
                               self._data[item]["selectableItems"],
                               type="string")
                    if self._data[item].has_key("buttonType"):
                        button_type = self._data[item]["buttonType"]
                        mc.addAttr(item, ln="buttonType", dt="string")
                        mc.setAttr("{}.buttonType".format(item),
                                   self._data[item]["buttonType"],
                                   type="string")
                else:
                    point_array = [
                        center_point + QtCore.QPoint(*point)
                        for point in self._data[item]["points"]
                    ]
                    # default button type is going to be null.
                    button_type = "null"
                    if self._data[item].has_key("buttonType"):
                        button_type = self._data[item]["buttonType"]
                    # check the different button types and make sure we create the correct one.
                    # if the button is null, we will just create a PolygonItem
                    if button_type == "null":
                        button_item = graphicsWidgets.PolygonItem(
                            item,
                            color=QtGui.QColor(*self._data[item]["color"]),
                            polygon=QtGui.QPolygonF(point_array))
                    elif button_type == "select":
                        button_item = mayaGraphicsWidgets.SelectButtonItem(
                            item,
                            color=QtGui.QColor(*self._data[item]["color"]),
                            polygon=QtGui.QPolygonF(point_array),
                            selectableItems=self._data[item]
                            ["selectableItems"])
                    elif button_type == "command":
                        button_item = mayaGraphicsWidgets.SelectButtonItem(
                            item,
                            color=QtGui.QColor(*self._data[item]["color"]),
                            polygon=QtGui.QPolygonF(point_array),
                            command=self._data[item]["command"])
                    # set the Z depth for the button.
                    if self._data[item].has_key("zValue"):
                        button_item.setZValue(self._data[item]["zValue"])
                    if self.scene:
                        self.scene.addItem(button_item)
Ejemplo n.º 16
0
 def startPos(self):
     return QtCore.QPointF(self.line.p1().x() * self.scaleX,
             self.line.p1().y() * self.scaleY)
Ejemplo n.º 17
0
 def updateLocation(self, pos):
     self.location_changed.emit(
         QtCore.QPointF(
             (pos.x() - self.width() / 2) * self.scale + self.center_x,
             (pos.y() - self.height() / 2) * self.scale + self.center_y))
Ejemplo n.º 18
0
 def endPos(self):
     return QtCore.QPointF(self.line.p2().x() * self.scaleX,
             self.line.p2().y() * self.scaleY)
Ejemplo n.º 19
0
    def createTicker(self):
        if Colors.noTicker:
            return

        movie_in = self.score.insertMovie('ticker')
        movie_out = self.score.insertMovie('ticker -out')
        movie_activate = self.score.insertMovie('ticker -activate')
        movie_deactivate = self.score.insertMovie('ticker -deactivate')

        self.ticker = ItemCircleAnimation(self.window.scene)
        self.ticker.setZValue(50)
        self.ticker.hide()

        # Move ticker in.
        qtendpos = 485
        qtPosY = 120
        self.tickerInAnim = DemoItemAnimation(self.ticker,
                DemoItemAnimation.ANIM_IN)
        self.tickerInAnim.setDuration(500)
        self.tickerInAnim.setStartPos(QtCore.QPointF(self.window.scene.sceneRect().width(), Colors.contentStartY + qtPosY))
        self.tickerInAnim.setPosAt(0.60, QtCore.QPointF(qtendpos, Colors.contentStartY + qtPosY))
        self.tickerInAnim.setPosAt(0.70, QtCore.QPointF(qtendpos + 30, Colors.contentStartY + qtPosY))
        self.tickerInAnim.setPosAt(0.80, QtCore.QPointF(qtendpos, Colors.contentStartY + qtPosY))
        self.tickerInAnim.setPosAt(0.90, QtCore.QPointF(qtendpos + 5, Colors.contentStartY + qtPosY))
        self.tickerInAnim.setPosAt(1.00, QtCore.QPointF(qtendpos, Colors.contentStartY + qtPosY))
        movie_in.append(self.tickerInAnim)

        # Move ticker out.
        qtOut = DemoItemAnimation(self.ticker, DemoItemAnimation.ANIM_OUT)
        qtOut.hideOnFinished = True
        qtOut.setDuration(500)
        qtOut.setStartPos(QtCore.QPointF(qtendpos, Colors.contentStartY + qtPosY))
        qtOut.setPosAt(1.00, QtCore.QPointF(self.window.scene.sceneRect().width() + 700, Colors.contentStartY + qtPosY))
        movie_out.append(qtOut)

        # Move ticker in on activate.
        qtActivate = DemoItemAnimation(self.ticker)
        qtActivate.setDuration(400)
        qtActivate.setStartPos(QtCore.QPointF(self.window.scene.sceneRect().width(), Colors.contentStartY + qtPosY))
        qtActivate.setPosAt(0.60, QtCore.QPointF(qtendpos, Colors.contentStartY + qtPosY))
        qtActivate.setPosAt(0.70, QtCore.QPointF(qtendpos + 30, Colors.contentStartY + qtPosY))
        qtActivate.setPosAt(0.80, QtCore.QPointF(qtendpos, Colors.contentStartY + qtPosY))
        qtActivate.setPosAt(0.90, QtCore.QPointF(qtendpos + 5, Colors.contentStartY + qtPosY))
        qtActivate.setPosAt(1.00, QtCore.QPointF(qtendpos, Colors.contentStartY + qtPosY))
        movie_activate.append(qtActivate)

        # Move ticker out on deactivate.
        qtDeactivate = DemoItemAnimation(self.ticker)
        qtDeactivate.hideOnFinished = True
        qtDeactivate.setDuration(400)
        qtDeactivate.setStartPos(QtCore.QPointF(qtendpos, Colors.contentStartY + qtPosY))
        qtDeactivate.setPosAt(1.00, QtCore.QPointF(qtendpos, 800))
        movie_deactivate.append(qtDeactivate)
Ejemplo n.º 20
0
 def guide(self, item, moveSpeed):
     frame = item.guideFrame - self.startLength
     endX = (self.line.p1().x() + (frame * self.line.dx() / self.length())) * self.scaleX
     endY = (self.line.p1().y() + (frame * self.line.dy() / self.length())) * self.scaleY
     pos = QtCore.QPointF(endX, endY)
     self.move(item, pos, moveSpeed)
Ejemplo n.º 21
0
 def paint(self, painter, option, widget):
     painter.drawPixmap(QtCore.QPointF(), self.p)
Ejemplo n.º 22
0
    def createCurveIcons(self):
        pix = QtGui.QPixmap(self.m_iconSize)
        painter = QtGui.QPainter()

        gradient = QtGui.QLinearGradient(0, 0, 0, self.m_iconSize.height())
        gradient.setColorAt(0.0, QtGui.QColor(240, 240, 240))
        gradient.setColorAt(1.0, QtGui.QColor(224, 224, 224))

        brush = QtGui.QBrush(gradient)

        # The original C++ code uses undocumented calls to get the names of the
        # different curve types.  We do the Python equivalant (but without
        # cheating)
        curve_types = [(n, c) for n, c in QtCore.QEasingCurve.__dict__.items()
                        if isinstance(c, QtCore.QEasingCurve.Type) \
                            and c != QtCore.QEasingCurve.Custom    \
                            and c != QtCore.QEasingCurve.NCurveTypes \
                            and c != QtCore.QEasingCurve.TCBSpline]
        curve_types.sort(key=lambda ct: ct[1])

        painter.begin(pix)

        for curve_name, curve_type in curve_types:
            painter.fillRect(
                QtCore.QRect(QtCore.QPoint(0, 0), self.m_iconSize), brush)
            curve = QtCore.QEasingCurve(curve_type)

            painter.setPen(QtGui.QColor(0, 0, 255, 64))
            xAxis = self.m_iconSize.height() / 1.5
            yAxis = self.m_iconSize.width() / 3.0
            painter.drawLine(0, xAxis, self.m_iconSize.width(), xAxis)
            painter.drawLine(yAxis, 0, yAxis, self.m_iconSize.height())

            curveScale = self.m_iconSize.height() / 2.0

            painter.setPen(QtCore.Qt.NoPen)

            # Start point.
            painter.setBrush(QtCore.Qt.red)
            start = QtCore.QPoint(
                yAxis, xAxis - curveScale * curve.valueForProgress(0))
            painter.drawRect(start.x() - 1, start.y() - 1, 3, 3)

            # End point.
            painter.setBrush(QtCore.Qt.blue)
            end = QtCore.QPoint(yAxis + curveScale,
                                xAxis - curveScale * curve.valueForProgress(1))
            painter.drawRect(end.x() - 1, end.y() - 1, 3, 3)

            curvePath = QtGui.QPainterPath()
            curvePath.moveTo(QtCore.QPointF(start))
            t = 0.0
            while t <= 1.0:
                to = QtCore.QPointF(
                    yAxis + curveScale * t,
                    xAxis - curveScale * curve.valueForProgress(t))
                curvePath.lineTo(to)
                t += 1.0 / curveScale

            painter.setRenderHint(QtGui.QPainter.Antialiasing, True)
            painter.strokePath(curvePath, QtGui.QColor(32, 32, 32))
            painter.setRenderHint(QtGui.QPainter.Antialiasing, False)

            item = QtWidgets.QListWidgetItem()
            item.setIcon(QtGui.QIcon(pix))
            item.setText(curve_name)
            self.m_ui.easingCurvePicker.addItem(item)

        painter.end()
Ejemplo n.º 23
0
    def __init__(self, diagramType, contextMenu, parent=None, scene=None):
        super(DiagramItem, self).__init__(parent, scene)

        self.arrows = []

        self.diagramType = diagramType
        self.myContextMenu = contextMenu

        path = QtGui.QPainterPath()
        if self.diagramType == self.StartEnd:
            path.moveTo(200, 50)
            path.arcTo(150, 0, 50, 50, 0, 90)
            path.arcTo(50, 0, 50, 50, 90, 90)
            path.arcTo(50, 50, 50, 50, 180, 90)
            path.arcTo(150, 50, 50, 50, 270, 90)
            path.lineTo(200, 25)
            self.myPolygon = path.toFillPolygon()
        elif self.diagramType == self.Conditional:
            self.myPolygon = QtGui.QPolygonF([
                    QtCore.QPointF(-100, 0), QtCore.QPointF(0, 100),
                    QtCore.QPointF(100, 0), QtCore.QPointF(0, -100),
                    QtCore.QPointF(-100, 0)])
        elif self.diagramType == self.Step:
            self.myPolygon = QtGui.QPolygonF([
                    QtCore.QPointF(-100, -100), QtCore.QPointF(100, -100),
                    QtCore.QPointF(100, 100), QtCore.QPointF(-100, 100),
                    QtCore.QPointF(-100, -100)])
        else:
            self.myPolygon = QtGui.QPolygonF([
                    QtCore.QPointF(-120, -80), QtCore.QPointF(-70, 80),
                    QtCore.QPointF(120, 80), QtCore.QPointF(70, -80),
                    QtCore.QPointF(-120, -80)])

        self.setPolygon(self.myPolygon)
        self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True)
        self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True)
Ejemplo n.º 24
0
 def startAnimation(self):
     self.m_anim.setStartValue(QtCore.QPointF(0, 0))
     self.m_anim.setEndValue(QtCore.QPointF(100, 100))
     self.m_anim.setDuration(2000)
     self.m_anim.setLoopCount(-1)
     self.m_anim.start()
Ejemplo n.º 25
0
def render_lines(
	pixmap, lines, predictors, scale=1, font_scale=1,
	get_label=None, show_vectors=False):

	if not lines:
		return pixmap

	brushes = LabelBrushes(predictors)

	qp = QtGui.QPainter()
	qp.begin(pixmap)

	try:
		black_pen = default_pen(width=5 * scale)
		red_pen = default_pen("#FFA500", width=7 * scale)

		for i, (line_path, line) in enumerate(lines.items()):
			geom_type = line.image_space_polygon.geom_type
			if geom_type != "Polygon":
				logging.error("encountered %s as line geometry" % geom_type)
				continue

			qp.setBrush(brushes.get_brush(line_path[:3], value=(i % 2) * 50))
			qp.setPen(black_pen)

			qp.setOpacity(0.5)
			poly = QtGui.QPolygonF()
			coords = np.array(line.image_space_polygon.exterior.coords) * scale
			for x, y in coords:
				poly.append(QtCore.QPointF(x, y))
			qp.drawPolygon(poly)

			if show_vectors:
				p1, p2 = line.baseline
				p1 = np.array(p1) * scale
				p2 = np.array(p2) * scale

				line_info = line.info
				tess_data = line_info["tesseract_data"]

				up = np.array(line_info["up"])
				lh = abs(tess_data["height"]) - abs(tess_data["ascent"])
				up = up * (scale * lh / np.linalg.norm(up))

				qp.setOpacity(0.9)
				qp.setPen(red_pen)
				qp.drawPolyline([QtCore.QPointF(*p1), QtCore.QPointF(*p2)])

				m = (np.array(p1) + np.array(p2)) / 2
				qp.drawPolyline([QtCore.QPointF(*m), QtCore.QPointF(*(m + up))])
				render_arrows(qp, [m, m + up], "end", scale=scale)

		if get_label:
			font = QtGui.QFont("Arial Narrow", 24 * scale * font_scale, QtGui.QFont.Bold)
			qp.setFont(font)
			fm = QtGui.QFontMetrics(font)

			qp.setPen(default_pen(width=5 * scale * font_scale))
			node_r = 25 * scale * font_scale

			for i, (line_path, line) in enumerate(lines.items()):
				x, y = line.image_space_polygon.centroid.coords[0]
				p = QtCore.QPointF(x * scale, y * scale)

				path, label = get_label(line_path)
				qp.setBrush(brushes.get_brush(line_path[:3], value=50))

				qp.setOpacity(0.8)
				qp.drawEllipse(p, node_r, node_r)

				qp.setOpacity(1)
				# flags=QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter does
				# not work. fix it manually.
				label_str = label if isinstance(label, str) else str(label)
				w = fm.horizontalAdvance(label_str)
				qp.drawText(p.x() - w / 2, p.y() + fm.descent(), label_str)

	finally:
		qp.end()

	return pixmap
    # States.
    rootState = QtCore.QState()
    ellipseState = QtCore.QState(rootState)
    figure8State = QtCore.QState(rootState)
    randomState = QtCore.QState(rootState)
    tiledState = QtCore.QState(rootState)
    centeredState = QtCore.QState(rootState)

    # Values.
    for i, item in enumerate(items):
        # Ellipse.
        ellipseState.assignProperty(
            item, 'pos',
            QtCore.QPointF(
                math.cos((i / 63.0) * 6.28) * 250,
                math.sin((i / 63.0) * 6.28) * 250))

        # Figure 8.
        figure8State.assignProperty(
            item, 'pos',
            QtCore.QPointF(
                math.sin((i / 63.0) * 6.28) * 250,
                math.sin(((i * 2) / 63.0) * 6.28) * 250))

        # Random.
        randomState.assignProperty(
            item, 'pos',
            QtCore.QPointF(-250 + QtCore.qrand() % 500,
                           -250 + QtCore.qrand() % 500))
Ejemplo n.º 27
0
 def __init__(self, parent=None):
     QtWidgets.QGraphicsEllipseItem.__init__(self, parent)
     self.initialPos = QtCore.QPointF()
     self.rotation = 0
     self.setFlags(self.flags() | QtWidgets.QGraphicsItem.ItemIsSelectable)
Ejemplo n.º 28
0
def get_status_rect(rect):
    size = ceil(sqrt((rect.width()**2) + (rect.width()**2)) / 15)
    topleft = QtCore.QPointF(rect.bottomRight().x() - size,
                             rect.bottomRight().y() - size)
    return QtCore.QRectF(topleft, rect.bottomRight())
Ejemplo n.º 29
0
    def __init__(self, width, height):
        super(Panel, self).__init__()

        self.selectedX = 0
        self.selectedY = 0
        self.width = width
        self.height = height
        self.flipped = False
        self.flipLeft = True

        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setCacheMode(QtGui.QGraphicsView.CacheBackground)
        self.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate)
        self.setRenderHints(QtGui.QPainter.Antialiasing
                            | QtGui.QPainter.SmoothPixmapTransform
                            | QtGui.QPainter.TextAntialiasing)

        self.setBackgroundBrush(
            QtGui.QBrush(QtGui.QPixmap('./images/blue_angle_swirl.jpg')))

        if QtOpenGL.QGLFormat.hasOpenGL():
            self.setViewport(
                QtOpenGL.QGLWidget(
                    QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers)))

        self.setMinimumSize(50, 50)

        self.selectionTimeLine = QtCore.QTimeLine(150, self)
        self.flipTimeLine = QtCore.QTimeLine(500, self)
        bounds = QtCore.QRectF((-width / 2.0) * 150, (-height / 2.0) * 150,
                               width * 150, height * 150)

        self.scene = QtGui.QGraphicsScene(bounds, self)
        self.setScene(self.scene)

        self.baseItem = RoundRectItem(bounds, QtGui.QColor(226, 255, 92, 64))
        self.scene.addItem(self.baseItem)

        embed = QtGui.QWidget()

        self.ui = Ui_BackSide()
        self.ui.setupUi(embed)
        self.ui.hostName.setFocus()

        self.backItem = RoundRectItem(bounds, embed.palette().window(), embed)
        self.backItem.setTransform(QtGui.QTransform().rotate(
            180, QtCore.Qt.YAxis))
        self.backItem.setParentItem(self.baseItem)

        self.selectionItem = RoundRectItem(QtCore.QRectF(-60, -60, 120, 120),
                                           QtCore.Qt.gray)
        self.selectionItem.setParentItem(self.baseItem)
        self.selectionItem.setZValue(-1)
        self.selectionItem.setPos(self.posForLocation(0, 0))
        self.startPos = self.selectionItem.pos()
        self.endPos = QtCore.QPointF()

        self.grid = []

        for y in range(height):
            self.grid.append([])
            for x in range(width):
                item = RoundRectItem(QtCore.QRectF(-54, -54, 108, 108),
                                     QtGui.QColor(214, 240, 110, 128))
                item.setPos(self.posForLocation(x, y))

                item.setParentItem(self.baseItem)
                item.setFlag(QtGui.QGraphicsItem.ItemIsFocusable)
                self.grid[y].append(item)

                rand = QtCore.qrand() % 9
                if rand == 0:
                    item.setPixmap(
                        QtGui.QPixmap(':/images/kontact_contacts.png'))
                elif rand == 1:
                    item.setPixmap(
                        QtGui.QPixmap(':/images/kontact_journal.png'))
                elif rand == 2:
                    item.setPixmap(QtGui.QPixmap(':/images/kontact_notes.png'))
                elif rand == 3:
                    item.setPixmap(
                        QtGui.QPixmap(':/images/kopeteavailable.png'))
                elif rand == 4:
                    item.setPixmap(
                        QtGui.QPixmap(':/images/metacontact_online.png'))
                elif rand == 5:
                    item.setPixmap(QtGui.QPixmap(':/images/minitools.png'))
                elif rand == 6:
                    item.setPixmap(
                        QtGui.QPixmap(':/images/kontact_journal.png'))
                elif rand == 7:
                    item.setPixmap(
                        QtGui.QPixmap(':/images/kontact_contacts.png'))
                elif rand == 8:
                    item.setPixmap(
                        QtGui.QPixmap(':/images/kopeteavailable.png'))
                else:
                    pass

                item.qobject.activated.connect(self.flip)

        self.grid[0][0].setFocus()

        self.backItem.qobject.activated.connect(self.flip)
        self.selectionTimeLine.valueChanged.connect(self.updateSelectionStep)
        self.flipTimeLine.valueChanged.connect(self.updateFlipStep)

        self.splash = SplashItem()
        self.splash.setZValue(5)
        self.splash.setPos(-self.splash.rect().width() / 2,
                           self.scene.sceneRect().top())
        self.scene.addItem(self.splash)

        self.splash.grabKeyboard()

        self.updateSelectionStep(0)

        self.setWindowTitle("Pad Navigator Example")
Ejemplo n.º 30
0
 def updateCursor(self, pos):
     self.cursor = QtCore.QPointF(pos)