class-description NEWS COMMUNITY STORE TUTORIALS SIGN UP LOGIN LOGOUT ROKOJORI NEWSLETTER SIGN UP LOGIN LOGOUT NEWS COMMUNITY STORE TUTORIALS TOGGLE FULLSCREEN VOLLBILD AN/AUS ObjectNodeCanvasItemControl GraphEdit
An editor for graph-like structures, using GraphNodes.

GraphEdit provides tools for creation, manipulation, and display of various graphs. Its main purpose in the engine is to power the visual programming systems, such as visual shaders, but it is also available for use in user projects.

GraphEdit by itself is only an empty container, representing an infinite grid where GraphNodes can be placed. Each GraphNode represents a node in the graph, a single unit of data in the connected scheme. GraphEdit, in turn, helps to control various interactions with nodes and between nodes. When the user attempts to connect, disconnect, or delete a GraphNode, a signal is emitted in the GraphEdit, but no action is taken by default. It is the responsibility of the programmer utilizing this control to implement the necessary logic to determine how each request should be handled.

Performance: It is greatly advised to enable low-processor usage mode (see OS.low_processor_usage_mode) when using GraphEdits.

Signal begin_node_move<>():Signal

Emitted at the beginning of a GraphElement's movement.

Signal connection_drag_ended<>():Signal

Emitted at the end of a connection drag.

Signal connection_drag_started<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, bool is_output=, is_output:bool=, ):Signal

Emitted at the beginning of a connection drag.

Signal connection_from_empty<>( StringName to_node=, to_node:StringName=, int to_port=, to_port:int=, Vector2 release_position=, release_position:Vector2=, ):Signal

Emitted when user drags a connection from an input port into the empty space of the graph.

Signal connection_request<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, StringName to_node=, to_node:StringName=, int to_port=, to_port:int=, ):Signal

Emitted to the GraphEdit when the connection between the from_port of the from_node GraphNode and the to_port of the to_node GraphNode is attempted to be created.

Signal connection_to_empty<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, Vector2 release_position=, release_position:Vector2=, ):Signal

Emitted when user drags a connection from an output port into the empty space of the graph.

Signal copy_nodes_request<>():Signal

Emitted when this GraphEdit captures a ui_copy action (Ctrl + C by default). In general, this signal indicates that the selected GraphElements should be copied.

Signal cut_nodes_request<>():Signal

Emitted when this GraphEdit captures a ui_cut action (Ctrl + X by default). In general, this signal indicates that the selected GraphElements should be cut.

Signal delete_nodes_request<>( =, :=, ):Signal

Emitted when this GraphEdit captures a ui_graph_delete action (Delete by default).

nodes is an array of node names that should be removed. These usually include all selected nodes.

Signal disconnection_request<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, StringName to_node=, to_node:StringName=, int to_port=, to_port:int=, ):Signal

Emitted to the GraphEdit when the connection between from_port of from_node GraphNode and to_port of to_node GraphNode is attempted to be removed.

Signal duplicate_nodes_request<>():Signal

Emitted when this GraphEdit captures a ui_graph_duplicate action (Ctrl + D by default). In general, this signal indicates that the selected GraphElements should be duplicated.

Signal end_node_move<>():Signal

Emitted at the end of a GraphElement's movement.

Signal frame_rect_changed<>( GraphFrame frame=, frame:GraphFrame=, Rect2 new_rect=, new_rect:Rect2=, ):Signal

Emitted when the GraphFrame frame is resized to new_rect.

Signal graph_elements_linked_to_frame_request<>( Array elements=, elements:Array=, StringName frame=, frame:StringName=, ):Signal

Emitted when one or more GraphElements are dropped onto the GraphFrame named frame, when they were not previously attached to any other one.

elements is an array of GraphElements to be attached.

Signal node_deselected<>( Node node=, node:Node=, ):Signal

Emitted when the given GraphElement node is deselected.

Signal node_selected<>( Node node=, node:Node=, ):Signal

Emitted when the given GraphElement node is selected.

Signal paste_nodes_request<>():Signal

Emitted when this GraphEdit captures a ui_paste action (Ctrl + V by default). In general, this signal indicates that previously copied GraphElements should be pasted.

Signal popup_request<>( Vector2 at_position=, at_position:Vector2=, ):Signal

Emitted when a popup is requested. Happens on right-clicking in the GraphEdit. at_position is the position of the mouse pointer when the signal is sent.

Signal scroll_offset_changed<>( Vector2 offset=, offset:Vector2=, ):Signal

Emitted when the scroll offset is changed by the user. It will not be emitted when changed in code.

Enum PanningScheme<>():Enum

SCROLL_ZOOMS = 0

Mouse Wheel will zoom, Ctrl + Mouse Wheel will move the view.


SCROLL_PANS = 1

Mouse Wheel will move the view, Ctrl + Mouse Wheel will zoom.

Enum GridPattern<>():Enum

GRID_PATTERN_LINES = 0

Draw the grid using solid lines.


GRID_PATTERN_DOTS = 1

Draw the grid using dots.

bool connection_lines_antialiased<>():bool

If true, the lines between nodes will use antialiasing.

float connection_lines_curvature<>():float

The curvature of the lines between the nodes. 0 results in straight lines.

float connection_lines_thickness<>():float

The thickness of the lines between the nodes.

Array connections<>():Array

The connections between GraphNodes.

A connection is represented as a Dictionary in the form of:

{ from_node: StringName, from_port: int, to_node: StringName, to_port: int, keep_alive: bool }

Connections with keep_alive set to false may be deleted automatically if invalid during a redraw.

GridPattern grid_pattern<>():GridPattern

The pattern used for drawing the grid.

bool minimap_enabled<>():bool

If true, the minimap is visible.

float minimap_opacity<>():float

The opacity of the minimap rectangle.

Vector2 minimap_size<>():Vector2

The size of the minimap rectangle. The map itself is based on the size of the grid area and is scaled to fit this rectangle.

PanningScheme panning_scheme<>():PanningScheme

Defines the control scheme for panning with mouse wheel.

bool right_disconnects<>():bool

If true, enables disconnection of existing connections in the GraphEdit by dragging the right end.

Vector2 scroll_offset<>():Vector2

The scroll offset.

bool show_arrange_button<>():bool

If true, the button to automatically arrange graph nodes is visible.

bool show_grid<>():bool

If true, the grid is visible.

bool show_grid_buttons<>():bool

If true, buttons that allow to configure grid and snapping options are visible.

bool show_menu<>():bool

If true, the menu toolbar is visible.

bool show_minimap_button<>():bool

If true, the button to toggle the minimap is visible.

bool show_zoom_buttons<>():bool

If true, buttons that allow to change and reset the zoom level are visible.

bool show_zoom_label<>():bool

If true, the label with the current zoom level is visible. The zoom level is displayed in percents.

int snapping_distance<>():int

The snapping distance in pixels, also determines the grid line distance.

bool snapping_enabled<>():bool

If true, enables snapping.

float zoom<>():float

The current zoom value.

float zoom_max<>():float

The upper zoom limit.

float zoom_min<>():float

The lower zoom limit.

float zoom_step<>():float

The step of each zoom level.

PackedVector2Array _get_connection_line<>( Vector2 from_position=, from_position:Vector2=, Vector2 to_position=, to_position:Vector2=, ):PackedVector2Array

Virtual method which can be overridden to customize how connections are drawn.

bool _is_in_input_hotzone<>( Object in_node=, in_node:Object=, int in_port=, in_port:int=, Vector2 mouse_position=, mouse_position:Vector2=, ):bool

Returns whether the mouse_position is in the input hot zone.

By default, a hot zone is a Rect2 positioned such that its center is at in_node.GraphNode.get_input_port_position()(in_port) (For output's case, call GraphNode.get_output_port_position() instead). The hot zone's width is twice the Theme Property port_grab_distance_horizontal, and its height is twice the port_grab_distance_vertical.

Below is a sample code to help get started:

func _is_in_input_hotzone(in_node, in_port, mouse_position): var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical")) var port_pos = in_node.get_position() + in_node.get_input_port_position(in_port) - port_size / 2 var rect = Rect2(port_pos, port_size) return rect.has_point(mouse_position)
bool _is_in_output_hotzone<>( Object in_node=, in_node:Object=, int in_port=, in_port:int=, Vector2 mouse_position=, mouse_position:Vector2=, ):bool

Returns whether the mouse_position is in the output hot zone. For more information on hot zones, see _is_in_input_hotzone().

Below is a sample code to help get started:

func _is_in_output_hotzone(in_node, in_port, mouse_position): var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical")) var port_pos = in_node.get_position() + in_node.get_output_port_position(in_port) - port_size / 2 var rect = Rect2(port_pos, port_size) return rect.has_point(mouse_position)
bool _is_node_hover_valid<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, StringName to_node=, to_node:StringName=, int to_port=, to_port:int=, ):bool

This virtual method can be used to insert additional error detection while the user is dragging a connection over a valid port.

Return true if the connection is indeed valid or return false if the connection is impossible. If the connection is impossible, no snapping to the port and thus no connection request to that port will happen.

In this example a connection to same node is suppressed:

func _is_node_hover_valid(from, from_port, to, to_port): return from != to
void add_valid_connection_type<>( int from_type=, from_type:int=, int to_type=, to_type:int=, ):void

Allows the connection between two different port types. The port type is defined individually for the left and the right port of each slot with the GraphNode.set_slot() method.

See also is_valid_connection_type() and remove_valid_connection_type().

void add_valid_left_disconnect_type<>( int type=, type:int=, ):void

Allows to disconnect nodes when dragging from the left port of the GraphNode's slot if it has the specified type. See also remove_valid_left_disconnect_type().

void add_valid_right_disconnect_type<>( int type=, type:int=, ):void

Allows to disconnect nodes when dragging from the right port of the GraphNode's slot if it has the specified type. See also remove_valid_right_disconnect_type().

void arrange_nodes<>():void

Rearranges selected nodes in a layout with minimum crossings between connections and uniform horizontal and vertical gap between nodes.

void attach_graph_element_to_frame<>( StringName element=, element:StringName=, StringName frame=, frame:StringName=, ):void

Attaches the element GraphElement to the frame GraphFrame.

void clear_connections<>():void

Removes all connections between nodes.

Error connect_node<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, StringName to_node=, to_node:StringName=, int to_port=, to_port:int=, bool keep_alive=false, keep_alive:bool=false, ):Error

Create a connection between the from_port of the from_node GraphNode and the to_port of the to_node GraphNode. If the connection already exists, no connection is created.

Connections with keep_alive set to false may be deleted automatically if invalid during a redraw.

void detach_graph_element_from_frame<>( StringName element=, element:StringName=, ):void

Detaches the element GraphElement from the GraphFrame it is currently attached to.

void disconnect_node<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, StringName to_node=, to_node:StringName=, int to_port=, to_port:int=, ):void

Removes the connection between the from_port of the from_node GraphNode and the to_port of the to_node GraphNode. If the connection does not exist, no connection is removed.

void force_connection_drag_end<>():void

Ends the creation of the current connection. In other words, if you are dragging a connection you can use this method to abort the process and remove the line that followed your cursor.

This is best used together with connection_drag_started and connection_drag_ended to add custom behavior like node addition through shortcuts.

Note: This method suppresses any other connection request signals apart from connection_drag_ended.

Array get_attached_nodes_of_frame<>( StringName frame=, frame:StringName=, ):Array

Returns an array of node names that are attached to the GraphFrame with the given name.

Dictionary get_closest_connection_at_point<>( Vector2 point=, point:Vector2=, float max_distance=4.0, max_distance:float=4.0, ):Dictionary

Returns the closest connection to the given point in screen space. If no connection is found within max_distance pixels, an empty Dictionary is returned.

A connection is represented as a Dictionary in the form of:

{ from_node: StringName, from_port: int, to_node: StringName, to_port: int, keep_alive: bool }

For example, getting a connection at a given mouse position can be achieved like this:

var connection = get_closest_connection_at_point(mouse_event.get_position())
int get_connection_count<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, ):int

Returns the number of connections from from_port of from_node.

PackedVector2Array get_connection_line<>( Vector2 from_node=, from_node:Vector2=, Vector2 to_node=, to_node:Vector2=, ):PackedVector2Array

Returns the points which would make up a connection between from_node and to_node.

Array get_connections_intersecting_with_rect<>( Rect2 rect=, rect:Rect2=, ):Array

Returns an Array containing the list of connections that intersect with the given Rect2.

A connection is represented as a Dictionary in the form of:

{ from_node: StringName, from_port: int, to_node: StringName, to_port: int, keep_alive: bool }
GraphFrame get_element_frame<>( StringName element=, element:StringName=, ):GraphFrame

Returns the GraphFrame that contains the GraphElement with the given name.

HBoxContainer get_menu_hbox<>():HBoxContainer

Gets the HBoxContainer that contains the zooming and grid snap controls in the top left of the graph. You can use this method to reposition the toolbar or to add your own custom controls to it.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their CanvasItem.visible property.

bool is_node_connected<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, StringName to_node=, to_node:StringName=, int to_port=, to_port:int=, ):bool

Returns true if the from_port of the from_node GraphNode is connected to the to_port of the to_node GraphNode.

bool is_valid_connection_type<>( int from_type=, from_type:int=, int to_type=, to_type:int=, ):bool

Returns whether it's possible to make a connection between two different port types. The port type is defined individually for the left and the right port of each slot with the GraphNode.set_slot() method.

See also add_valid_connection_type() and remove_valid_connection_type().

void remove_valid_connection_type<>( int from_type=, from_type:int=, int to_type=, to_type:int=, ):void

Disallows the connection between two different port types previously allowed by add_valid_connection_type(). The port type is defined individually for the left and the right port of each slot with the GraphNode.set_slot() method.

See also is_valid_connection_type().

void remove_valid_left_disconnect_type<>( int type=, type:int=, ):void

Disallows to disconnect nodes when dragging from the left port of the GraphNode's slot if it has the specified type. Use this to disable disconnection previously allowed with add_valid_left_disconnect_type().

void remove_valid_right_disconnect_type<>( int type=, type:int=, ):void

Disallows to disconnect nodes when dragging from the right port of the GraphNode's slot if it has the specified type. Use this to disable disconnection previously allowed with add_valid_right_disconnect_type().

void set_connection_activity<>( StringName from_node=, from_node:StringName=, int from_port=, from_port:int=, StringName to_node=, to_node:StringName=, int to_port=, to_port:int=, float amount=, amount:float=, ):void

Sets the coloration of the connection between from_node's from_port and to_node's to_port with the color provided in the activity theme property. The color is linearly interpolated between the connection color and the activity color using amount as weight.

void set_selected<>( Node node=, node:Node=, ):void

Sets the specified node as the one selected.




All social media brands are registrated trademarks and belong to their respective owners.





CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
We are using cookies on this site. Read more... Wir benutzen Cookies auf dieser Seite. Mehr lesen...