Beispiel #1
0
            self.create_property('color_picker', (0, 0, 255),
                                 widget_type=NODE_PROP_COLORPICKER)
            self.create_property('integer', 10,
                                 widget_type=NODE_PROP_QSPINBOX)
            self.create_property('list', 'foo',
                                 items=['foo', 'bar'],
                                 widget_type=NODE_PROP_QCOMBO)
            self.create_property('range', 50,
                                 range=(45, 55),
                                 widget_type=NODE_PROP_SLIDER)

    def prop_changed(node_id, prop_name, prop_value):
        print('-'*100)
        print(node_id, prop_name, prop_value)


    app = QtWidgets.QApplication(sys.argv)

    graph = NodeGraph()
    graph.register_node(TestNode)

    prop_bin = PropertiesBinWidget()
    prop_bin.property_changed.connect(prop_changed)

    node = graph.create_node('nodeGraphQt.nodes.TestNode')

    prop_bin.add_node(node)
    prop_bin.show()

    app.exec_()
Beispiel #2
0
            node_tree.show()

    graph.node_double_clicked.connect(show_nodes_list)

    # registered nodes.
    reg_nodes = [
        BackdropNode, MyNode, basic_nodes.FooNode, basic_nodes.BarNode,
        widget_nodes.DropdownMenuNode, widget_nodes.TextInputNode,
        widget_nodes.CheckboxNode
    ]
    for n in reg_nodes:
        graph.register_node(n)

    my_node = graph.create_node('com.chantasticvfx.MyNode',
                                name='chantastic!',
                                color='#0a1e20',
                                text_color='#feab20',
                                pos=[310, 10])

    foo_node = graph.create_node('com.chantasticvfx.FooNode',
                                 name='node',
                                 pos=[-480, 140])
    foo_node.set_disabled(True)

    # create example "TextInputNode".
    text_node = graph.create_node('com.chantasticvfx.TextInputNode',
                                  name='text node',
                                  pos=[-480, -160])

    # create example "TextInputNode".
    checkbox_node = graph.create_node('com.chantasticvfx.CheckboxNode',
Beispiel #3
0
    # viewer widget used for the node graph.
    viewer = graph.viewer()
    viewer.resize(1100, 800)
    viewer.show()

    # registered nodes.
    reg_nodes = [
        Backdrop, MyNode, basic_nodes.FooNode, basic_nodes.BarNode,
        widget_nodes.DropdownMenuNode, widget_nodes.TextInputNode
    ]
    for n in reg_nodes:
        graph.register_node(n)

    my_node = graph.create_node('com.chantasticvfx.MyNode',
                                name='portal',
                                color='#193a33',
                                pos=[310, 10])

    foo_node = graph.create_node('com.chantasticvfx.FooNode',
                                 name='chantastic!',
                                 pos=[-480, 140])
    foo_node.set_disabled(True)

    # create example "TextInputNode".
    text_node = graph.create_node('com.chantasticvfx.TextInputNode',
                                  name='rick',
                                  pos=[-480, -160])

    # create node with a combo box menu.
    menu_node = graph.create_node('com.chantasticvfx.DropdownMenuNode',
                                  name='morty',
Beispiel #4
0
    def setup_exp(self):
        """Prepares the patch expander once a patch has been selected.
        Currently triggered via a button press.
        """

        class MyNode(BaseNode):
            """
            example test node.
            """

            # set a unique node identifier.
            __identifier__ = 'com.chantasticvfx'

            # set the initial default node name.
            NODE_NAME = 'my node'

            def __init__(self):
                super(MyNode, self).__init__()
                self.set_color(25, 58, 51)

        # QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
        # win = QtWidgets.QApplication([])

        win = QWidget()
        win.setWindowTitle(
            "Interactive Patch Routing: {}".format(self.curr_viz["name"])
        )
        win.setWindowIcon(QIcon(
            os.path.join(os.getcwd(), "zoia_lib", "UI", "resources",
                         "logo.ico")))
        win.setFixedSize(540, 540)

        # create node graph.
        graph = NodeGraph()

        # set up default menu and commands.
        setup_context_menu(graph)

        # widget used for the node graph.
        graph_widget = graph.widget
        graph_widget.resize(1100, 800)
        graph_widget.show()

        # show the properties bin when a node is "double clicked" in the graph.
        properties_bin = PropertiesBinWidget(node_graph=graph)
        properties_bin.setWindowFlags(QtCore.Qt.Tool)

        def show_prop_bin(node):
            if not properties_bin.isVisible():
                properties_bin.show()

        graph.node_double_clicked.connect(show_prop_bin)

        # show the nodes list when a node is "double clicked" in the graph.
        node_tree = NodeTreeWidget(node_graph=graph)

        def show_nodes_list(node):
            if not node_tree.isVisible():
                node_tree.update()
                node_tree.show()

        graph.node_double_clicked.connect(show_nodes_list)

        # registered nodes.
        nodes_to_reg = [
            # BackdropNode,
            MyNode,
            # basic_nodes.FooNode,
            # basic_nodes.BarNode,
            # widget_nodes.DropdownMenuNode,
            # widget_nodes.TextInputNode,
            # widget_nodes.CheckboxNode
        ]
        graph.register_nodes(nodes_to_reg)

        pch = self.curr_viz

        nodes = {}
        for module in pch['modules']:
            my_node = graph.create_node(
                'com.chantasticvfx.MyNode',
                name=(module['type'] if module['name'] == '' else module['name']) + str(module["number"]),
                color='#0a1e20',
                text_color='#feab20'
            )
            inp, outp, in_pos, out_pos = [], [], [], []
            for key, param in module['blocks'].items():
                if 'in' in key:
                    my_node.add_input(key)
                    inp.append(key)
                    in_pos.append(int(param["position"]))
                elif param["isParam"]:
                    my_node.add_input(key)
                    inp.append(key)
                    in_pos.append(int(param["position"]))
                elif 'out' in key:
                    my_node.add_output(key)
                    outp.append(key)
                    out_pos.append(int(param["position"]))
            nodes[module["number"]] = my_node, inp, outp, in_pos, out_pos

        # print(nodes)

        # map pos from nodes to connections
        def node_pos_map(node):
            inpts = node[1]
            outps = node[2]
            in_pos = node[3]
            out_pos = node[4]
            node_pos_start = [x for x in range(0, len(inpts))]
            node_pos_end = [x for x in range(0, len(outps))]
            data_input = dict(zip(in_pos, node_pos_start))
            data_output = dict(zip(out_pos, node_pos_end))

            return {**data_input, **data_output}

        data = []
        for key, node in nodes.items():
            data.append(node_pos_map(node))

        for conn in pch['connections']:
            mod, block = conn['source'].split('.')
            nmod, nblock = conn['destination'].split('.')
            src = data[int(mod)]
            dest = data[int(nmod)]
            try:
                nodes[int(mod)][0].set_output(
                    src[int(block)],
                    nodes[int(nmod)][0].input(dest[int(nblock)])
                )
            except KeyError as e:
                print(conn, e)
            except IndexError as e:
                print(conn, e)
        print('done making connections')

        # auto layout nodes.
        graph.auto_layout_nodes()

        # wrap a backdrop node.
        # backdrop_node = graph.create_node('nodeGraphQt.nodes.BackdropNode')
        # backdrop_node.wrap_nodes([text_node, checkbox_node])

        graph.fit_to_selection()

        win.exec_()
Beispiel #5
0
    graph = NodeGraph()

    viewer = graph.viewer()
    viewer.setWindowTitle('My Node Graph')
    viewer.resize(1100, 800)
    viewer.show()

    # registered nodes.
    reg_nodes = [
        Backdrop, MyNode, menu_node.DropdownMenuNode, simple_nodes.FooNode,
        simple_nodes.BarNode, text_input_node.TextInputNode
    ]
    [graph.register_node(n) for n in reg_nodes]

    my_node = graph.create_node('com.chantasticvfx.MyNode',
                                name='test',
                                pos=(310.0, 10.0))

    foo_node = graph.create_node('com.chantasticvfx.FooNode',
                                 name='Foo Node',
                                 pos=(-487.0, 141.0))

    # create example "TextInputNode".
    text_node = graph.create_node('com.chantasticvfx.TextInputNode',
                                  name='Text Node',
                                  color='#6b273f',
                                  pos=(-488.0, -158.0))
    text_node.set_disabled(True)

    # create node with a combo box menu.
    menu_node = graph.create_node('com.chantasticvfx.DropdownMenuNode',
Beispiel #6
0
        if not node_tree.isVisible():
            node_tree.update()
            node_tree.show()

    graph.node_double_clicked.connect(show_nodes_list)

    # registered nodes.
    nodes_to_reg = [
        BackdropNode, MyNode, basic_nodes.FooNode, basic_nodes.BarNode,
        widget_nodes.DropdownMenuNode, widget_nodes.TextInputNode,
        widget_nodes.CheckboxNode
    ]
    graph.register_nodes(nodes_to_reg)

    my_node = graph.create_node('com.chantasticvfx.MyNode',
                                name='chantastic!',
                                color='#0a1e20',
                                text_color='#feab20')

    foo_node = graph.create_node('com.chantasticvfx.FooNode', name='node')
    foo_node.set_disabled(True)

    # create example "TextInputNode".
    text_node = graph.create_node('com.chantasticvfx.TextInputNode',
                                  name='text node')

    # create example "TextInputNode".
    checkbox_node = graph.create_node('com.chantasticvfx.CheckboxNode',
                                      name='checkbox node')

    # create node with a combo box menu.
    menu_node = graph.create_node('com.chantasticvfx.DropdownMenuNode',
Beispiel #7
0
    # show the properties bin when a node is "double clicked" in the graph.
    properties_bin = PropertiesBinWidget(node_graph=graph)
    properties_bin.setWindowFlags(QtCore.Qt.Tool)

    def show_prop_bin(node):
        if not properties_bin.isVisible():
            properties_bin.show()

    graph.node_double_clicked.connect(show_prop_bin)

    # registered nodes.
    reg_nodes = [InfoNode, SpeakNode, CameraNode, MoveNode]
    for n in reg_nodes:
        graph.register_node(n)

    info_node = graph.create_node('personax.InfoNode',
                                  name='Default=info, changed to desc',
                                  pos=[0, 0])
    speak_node = graph.create_node('personax.SpeakNode',
                                   name='Default=speak, changed to desc',
                                   pos=[0, 0])
    camera_node = graph.create_node('personax.CameraNode',
                                    name='Default=camera, changed to desc',
                                    pos=[0, 0])
    move_node = graph.create_node('personax.MoveNode',
                                  name='Default=move, changed to desc',
                                  pos=[0, 0])

    app.exec_()
Beispiel #8
0
    def show_nodes_list(node):
        if not node_tree.isVisible():
            node_tree.update()
            node_tree.show()

    graph.node_double_clicked.connect(show_nodes_list)

    # registered nodes.
    reg_nodes = [And, Not, Or2]
    for n in reg_nodes:
        graph.register_node(n)

    and_node = graph.create_node('hal.comp.And',
                                 name='AND',
                                 color='#0a1e20',
                                 text_color='#feab20',
                                 pos=[310, 10])

    not_node = graph.create_node('hal.comp.Not',
                                 name='NOT',
                                 color='#0a1e20',
                                 text_color='#feab20',
                                 pos=[500, 10])

    or_node = graph.create_node('hal.comp.Or2',
                                name='OR',
                                color='#0a1e20',
                                text_color='#feab20',
                                pos=[450, 50])
    #
Beispiel #9
0
    graph.node_double_clicked.connect(show_nodes_list)
    """

    # registered nodes.
    reg_nodes = [
        basic_nodes.FooNode, basic_nodes.BarNode,
        widget_nodes.DropdownMenuNode, widget_nodes.TextInputNode,
        widget_nodes.CheckboxNode, InputListNode
    ]

    for n in reg_nodes:
        graph.register_node(n)

    input_node = graph.create_node('com.volvo.InputListNode',
                                   name='Input Test',
                                   color='#0a1e20',
                                   text_color='#feab20',
                                   pos=[110, 10])
    input_node2 = graph.create_node('com.volvo.InputListNode',
                                    name='Input Test',
                                    color='#0a1e20',
                                    text_color='#feab20',
                                    pos=[110, 310])

    input_node.set_content(["A", "B", "C"])

    # connect the nodes
    #foo_node.set_output(0, bar_node.input(2))
    #menu_node.set_input(0, bar_node.output(1))
    #bar_node.set_input(0, text_node.output(0))
Beispiel #10
0
    for n in reg_nodes:
        graph.register_node(n)

    node_menu = graph.context_nodes_menu()
    node_menu.add_command('Print Functions',
                          print_functions,
                          node_class=ModuleNode)
    node_menu.add_command('Cook Node', cook_node, node_class=AutoNode)
    node_menu.add_command('Toggle Auto Cook',
                          toggle_auto_cook,
                          node_class=AutoNode)

    mathNodeA = graph.create_node('Module.MathModuleNode',
                                  name='Math Functions A',
                                  color='#0a1e20',
                                  text_color='#feab20',
                                  pos=[-250, 70])

    mathNodeB = graph.create_node('Module.MathModuleNode',
                                  name='Math Functions B',
                                  color='#0a1e20',
                                  text_color='#feab20',
                                  pos=[-250, -70])

    mathNodeC = graph.create_node('Module.MathModuleNode',
                                  name='Math Functions C',
                                  color='#0a1e20',
                                  text_color='#feab20',
                                  pos=[0, 0])
Beispiel #11
0
    # registered example nodes.
    graph.register_nodes([
        basic_nodes.BasicNodeA, basic_nodes.BasicNodeB,
        custom_ports_node.CustomPortsNode, group_node.MyGroupNode,
        widget_nodes.DropdownMenuNode, widget_nodes.TextInputNode,
        widget_nodes.CheckboxNode
    ])

    # show the node graph widget.
    graph_widget = graph.widget
    graph_widget.resize(1100, 800)
    graph_widget.show()

    # create node with custom text color and disable it.
    n_basic_a = graph.create_node('nodes.basic.BasicNodeA',
                                  text_color='#feab20')
    n_basic_a.set_disabled(True)

    # create node and set a custom icon.
    n_basic_b = graph.create_node('nodes.basic.BasicNodeB', name='custom icon')
    this_path = os.path.dirname(os.path.abspath(__file__))
    icon = os.path.join(this_path, 'examples', 'star.png')
    n_basic_b.set_icon(icon)

    # create node with the custom port shapes.
    n_custom_ports = graph.create_node('nodes.custom.ports.CustomPortsNode',
                                       name='custom ports')

    # create node with the embedded QLineEdit widget.
    n_text_input = graph.create_node('nodes.widget.TextInputNode',
                                     name='text node',