From 2e5fbad9be37b07255c272e294c5fc13d54ab010 Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Sat, 15 Feb 2025 23:53:57 -0700 Subject: [PATCH] Fixed Node Spawn Positioning Issues --- .../blueprint_node.cpython-312.pyc | Bin 0 -> 1925 bytes ...lyff_low_health_alert_node.cpython-312.pyc | Bin 8931 -> 8931 bytes Nodes/blueprint_node.py | 38 ++++++++++++++++++ borealis.py | 14 +++---- 4 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 Nodes/__pycache__/blueprint_node.cpython-312.pyc create mode 100644 Nodes/blueprint_node.py diff --git a/Nodes/__pycache__/blueprint_node.cpython-312.pyc b/Nodes/__pycache__/blueprint_node.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6a2ea35c9d0ddbd500903fb0efd002359036bf21 GIT binary patch literal 1925 zcmZ`)UuYaf7@xV_yX@uu7~3RJ63sM5?NWP6t76mmr%BqHg4Y%m;fM@-JCkJN-t9TN zXL3h{2muqQq%Yb&R(w#2NDBpDeH8Q|p(zPV1;M9#i=>qzh<-D7duN31!#BV0&&+)D z{o9{2nQjE%FRQm^|JD)uT{6)ZZ-Kqz0Ing17d0~bDRinxoU5YOa)}l@`**5;|EUJ z4v6i!o*-74k&;t(N?`f!R8DQJ_ZO?>a_yLF6?2Z4D@N|svu#g_bk)ZH34;u`4By^u zkbaJ@p`fh{q6neO=(7|;>n#lie!i=1)&>l(w@y|T$+n^mSd3{*kJ1GRjl)T*6xt>V z&_u+u#3L-)_p`1?SQyb6pg$Pl&KkW2w0#|Egd%Mn1e56fml66HgJplD@2vBOIygd? z@%%u9J8N_%Xa_se2(7oGjnS1?bQ$5HNYh!F!IG@|yHqEFHDspq^@9_xV}Brv?4qnb zmF315>}xDaau0~9H~xV|q$1MzNl7~bg&Mb;QW-oUGbm(w8eaejdn`MsS}v7UO@ms6 zhe$}Lp}$fK4x8nHlA1kX+^<%+5HgFQK`GQ}Kxt_BU{SV8JWNWY3OUqePlVk8UyLN_ zq9>qvTKXg{&bDC6DOaiit#~5v!?afoI$XR2KDl8E2oJb23H9bx(!A;IV>UFF)Cv#0 z3u>ko>OOa8LS5Q~NlI>-f{Mh5YGucd2mX zDm5W%tlr;lHEEWM-kt@W|2>e0OX!}Fxl+3R&Zcp6%Q*I%kzUKJW;XhPd2Tm>l9{#a zYWAwQe&U9xrV{qs2OA&q&EQgLq+yHQWhqil1HhV|z^gi=V@3uL* zX^!48$F_RMRwj4SJ!|Jz&u^!PH`Bv6Ui|vxmnXkEbyNQ#dnwE z#|1w{oPan!sZ<4bYcR+DKOUQ-OK#483zZ}e!@0g3BSee<4Kt7}n?qJq^6LZp?Su25SHS delta 19 ZcmaFt`q-80G%qg~0}#A#+Q@ZN2>?T825|rY diff --git a/Nodes/blueprint_node.py b/Nodes/blueprint_node.py new file mode 100644 index 0000000..cd6c742 --- /dev/null +++ b/Nodes/blueprint_node.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +from OdenGraphQt import BaseNode +from Qt import QtCore + +class BlueprintNode(BaseNode): + """ + A placeholder node used to preview placement before spawning + the real node. It has a distinct color and minimal UI. + """ + __identifier__ = 'bunny-lab.io.blueprint' + NODE_NAME = 'Blueprint Node' + + def __init__(self): + super(BlueprintNode, self).__init__() + # Display a name so the user sees "Click to Place Node" + self.set_name("Click to Place Node") + + # Give it a bluish color + white text, for visibility + self.set_color(60, 120, 220) # R, G, B + self.view.text_color = (255, 255, 255, 200) + self.view.border_color = (255, 255, 255, 180) + + # Make it slightly transparent if desired (alpha=150) + self.view._bg_color = (60, 120, 220, 150) + + # Remove any default inputs/outputs (make it minimal) + for port in self.input_ports() + self.output_ports(): + self.model.delete_port(port.name(), port.port_type) + + # Store the "actual node" we want to spawn + self.create_property("actual_node_type", "", widget_type=0) + + def process_input(self): + """ + We do nothing here; it is purely a placeholder node. + """ + pass diff --git a/borealis.py b/borealis.py index 8aff9c5..8bddcc8 100644 --- a/borealis.py +++ b/borealis.py @@ -21,13 +21,11 @@ def _patched_setSelectionArea(self, painterPath, second_arg, *args, **kwargs): # Monkey-patch the setSelectionArea method. QtWidgets.QGraphicsScene.setSelectionArea = _patched_setSelectionArea -# --- End of patch section --- - import sys import pkgutil import importlib import inspect -from Qt import QtWidgets, QtCore +from Qt import QtWidgets, QtCore, QtGui from OdenGraphQt import NodeGraph, BaseNode def import_nodes_from_folder(package_name): @@ -47,12 +45,14 @@ def import_nodes_from_folder(package_name): def make_node_command(graph, nt): """ Given a NodeGraph instance and a node type string nt, return a command - function that creates a node of that type. + function that creates a node of that type at the current mouse location. """ def command(): try: - node = graph.create_node(nt) - # (No need to force top-level if nodes are created as top-level by default.) + # Get the current cursor position in scene coordinates + pos = graph.cursor_pos() + # Create the node with the current cursor position. + node = graph.create_node(nt, pos=pos) except Exception as e: print(f"Error creating node of type {nt}: {e}") return command @@ -103,4 +103,4 @@ if __name__ == '__main__': timer.timeout.connect(global_update) timer.start(500) - sys.exit(app.exec()) \ No newline at end of file + sys.exit(app.exec())