| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/object/ref_counted.h" |
| 34 |
#include "core/templates/hash_map.h" |
| 35 |
#include "core/templates/hash_set.h" |
| 36 |
|
| 37 |
class GraphEdit; |
| 38 |
|
| 39 |
class GraphEditArranger : public RefCounted { |
| 40 |
GDSOFTCLASS(GraphEditArranger, RefCounted); |
| 41 |
|
| 42 |
enum SET_OPERATIONS { |
| 43 |
IS_EQUAL, |
| 44 |
IS_SUBSET, |
| 45 |
DIFFERENCE, |
| 46 |
UNION, |
| 47 |
}; |
| 48 |
|
| 49 |
GraphEdit *graph_edit = nullptr; |
| 50 |
bool arranging_graph = false; |
| 51 |
|
| 52 |
int _set_operations(SET_OPERATIONS p_operation, HashSet<StringName> &r_u, const HashSet<StringName> &r_v); |
| 53 |
HashMap<int, Vector<StringName>> _layering(const HashSet<StringName> &r_selected_nodes, const HashMap<StringName, HashSet<StringName>> &r_upper_neighbours); |
| 54 |
Vector<StringName> _split(const Vector<StringName> &r_layer, const HashMap<StringName, Dictionary> &r_crossings); |
| 55 |
void _horizontal_alignment(Dictionary &r_root, Dictionary &r_align, const HashMap<int, Vector<StringName>> &r_layers, const HashMap<StringName, HashSet<StringName>> &r_upper_neighbours, const HashSet<StringName> &r_selected_nodes); |
| 56 |
void _crossing_minimisation(HashMap<int, Vector<StringName>> &r_layers, const HashMap<StringName, HashSet<StringName>> &r_upper_neighbours); |
| 57 |
void _calculate_inner_shifts(Dictionary &r_inner_shifts, const Dictionary &r_root, const Dictionary &r_node_names, const Dictionary &r_align, const HashSet<StringName> &r_block_heads, const HashMap<StringName, Pair<int, int>> &r_port_info); |
| 58 |
float _calculate_threshold(const StringName &p_v, const StringName &p_w, const Dictionary &r_node_names, const HashMap<int, Vector<StringName>> &r_layers, const Dictionary &r_root, const Dictionary &r_align, const Dictionary &r_inner_shift, real_t p_current_threshold, const HashMap<StringName, Vector2> &r_node_positions); |
| 59 |
void _place_block(const StringName &p_v, float p_delta, const HashMap<int, Vector<StringName>> &r_layers, const Dictionary &r_root, const Dictionary &r_align, const Dictionary &r_node_name, const Dictionary &r_inner_shift, Dictionary &r_sink, Dictionary &r_shift, HashMap<StringName, Vector2> &r_node_positions); |
| 60 |
|
| 61 |
public: |
| 62 |
void arrange_nodes(); |
| 63 |
|
| 64 |
GraphEditArranger(GraphEdit *p_graph_edit) : |
| 65 |
graph_edit(p_graph_edit) {} |
| 66 |
}; |