本文整理汇总了C++中GraphNode::connect方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphNode::connect方法的具体用法?C++ GraphNode::connect怎么用?C++ GraphNode::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphNode
的用法示例。
在下文中一共展示了GraphNode::connect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inset
void Graph::inset(long key) {
srand(time(NULL));
GraphNode *n = new GraphNode(key);
nodes[numOfNodes] = n;
int connectCount = 0;
int connectSpot;
int connectedSpot[5];
bool alreadyConnected = false;
for(int i = 0; i < 5; i++) connectedSpot[i] = -1;
if(numOfNodes <= 5) {
for(int i = 0; i < numOfNodes; i++) {
nodes[i]->connect(n);
n->connect(nodes[i]);
}
}
else {
while(connectCount <= 4) {
connectSpot = rand() % numOfNodes;
for(int i = 0; i < connectCount; i++)
if(connectedSpot[i] == connectSpot) alreadyConnected = true;
if(!alreadyConnected) {
nodes[connectSpot]->connect(n);
n->connect(nodes[connectSpot]);
connectedSpot[connectCount] = connectSpot;
connectCount++;
}
alreadyConnected = false;
}
}
numOfNodes++;
if(numOfNodes == capacity) doubleNodes();
//connect();
}
示例2: add_child_notify
void GraphEdit::add_child_notify(Node *p_child) {
Control::add_child_notify(p_child);
top_layer->call_deferred("raise"); //top layer always on top!
GraphNode *gn = Object::cast_to<GraphNode>(p_child);
if (gn) {
gn->set_scale(Vector2(zoom, zoom));
gn->connect("offset_changed", this, "_graph_node_moved", varray(gn));
gn->connect("raise_request", this, "_graph_node_raised", varray(gn));
gn->connect("item_rect_changed", connections_layer, "update");
_graph_node_moved(gn);
gn->set_mouse_filter(MOUSE_FILTER_PASS);
}
}
示例3: add_child_notify
void GraphEdit::add_child_notify(Node *p_child) {
top_layer->call_deferred("raise"); //top layer always on top!
GraphNode *gn = p_child->cast_to<GraphNode>();
if (gn) {
gn->connect("offset_changed",this,"_graph_node_moved",varray(gn));
gn->connect("raise_request",this,"_graph_node_raised",varray(gn));
_graph_node_moved(gn);
gn->set_stop_mouse(false);
}
}
示例4: _update_graph
void VisualShaderEditor::_update_graph() {
if (updating)
return;
if (visual_shader.is_null())
return;
graph->set_scroll_ofs(visual_shader->get_graph_offset() * EDSCALE);
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
graph->clear_connections();
//erase all nodes
for (int i = 0; i < graph->get_child_count(); i++) {
if (Object::cast_to<GraphNode>(graph->get_child(i))) {
memdelete(graph->get_child(i));
i--;
}
}
static const Color type_color[3] = {
Color::html("#61daf4"),
Color::html("#d67dee"),
Color::html("#f6a86e")
};
List<VisualShader::Connection> connections;
visual_shader->get_node_connections(type, &connections);
Ref<StyleBoxEmpty> label_style = make_empty_stylebox(2, 1, 2, 1);
Vector<int> nodes = visual_shader->get_node_list(type);
for (int n_i = 0; n_i < nodes.size(); n_i++) {
Vector2 position = visual_shader->get_node_position(type, nodes[n_i]);
Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, nodes[n_i]);
GraphNode *node = memnew(GraphNode);
graph->add_child(node);
/*if (!vsnode->is_connected("changed", this, "_node_changed")) {
vsnode->connect("changed", this, "_node_changed", varray(vsnode->get_instance_id()), CONNECT_DEFERRED);
}*/
node->set_offset(position);
node->set_title(vsnode->get_caption());
node->set_name(itos(nodes[n_i]));
if (nodes[n_i] >= 2) {
node->set_show_close_button(true);
node->connect("close_request", this, "_delete_request", varray(nodes[n_i]), CONNECT_DEFERRED);
}
node->connect("dragged", this, "_node_dragged", varray(nodes[n_i]));
Control *custom_editor = NULL;
int port_offset = 0;
Ref<VisualShaderNodeUniform> uniform = vsnode;
if (uniform.is_valid()) {
LineEdit *uniform_name = memnew(LineEdit);
uniform_name->set_text(uniform->get_uniform_name());
node->add_child(uniform_name);
uniform_name->connect("text_entered", this, "_line_edit_changed", varray(uniform_name, nodes[n_i]));
uniform_name->connect("focus_exited", this, "_line_edit_focus_out", varray(uniform_name, nodes[n_i]));
if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") {
//shortcut
VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0);
node->set_slot(0, false, VisualShaderNode::PORT_TYPE_SCALAR, Color(), true, port_right, type_color[port_right]);
continue;
}
port_offset++;
}
for (int i = 0; i < plugins.size(); i++) {
custom_editor = plugins.write[i]->create_editor(vsnode);
if (custom_editor) {
break;
}
}
if (custom_editor && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
//will be embedded in first port
} else if (custom_editor) {
port_offset++;
node->add_child(custom_editor);
custom_editor = NULL;
}
for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) {
if (vsnode->is_port_separator(i)) {
node->add_child(memnew(HSeparator));
port_offset++;
}
//.........这里部分代码省略.........
示例5: _update_graph
void AnimationNodeBlendTreeEditor::_update_graph() {
if (updating)
return;
graph->set_scroll_ofs(blend_tree->get_graph_offset() * EDSCALE);
if (blend_tree->get_parent().is_valid()) {
goto_parent->show();
} else {
goto_parent->hide();
}
graph->clear_connections();
//erase all nodes
for (int i = 0; i < graph->get_child_count(); i++) {
if (Object::cast_to<GraphNode>(graph->get_child(i))) {
memdelete(graph->get_child(i));
i--;
}
}
animations.clear();
List<StringName> nodes;
blend_tree->get_node_list(&nodes);
for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) {
GraphNode *node = memnew(GraphNode);
graph->add_child(node);
Ref<AnimationNode> agnode = blend_tree->get_node(E->get());
if (!agnode->is_connected("changed", this, "_node_changed")) {
agnode->connect("changed", this, "_node_changed", varray(agnode->get_instance_id()), CONNECT_DEFERRED);
}
node->set_offset(agnode->get_position() * EDSCALE);
node->set_title(agnode->get_caption());
node->set_name(E->get());
int base = 0;
if (String(E->get()) != "output") {
LineEdit *name = memnew(LineEdit);
name->set_text(E->get());
name->set_expand_to_text_length(true);
node->add_child(name);
node->set_slot(0, false, 0, Color(), true, 0, get_color("font_color", "Label"));
name->connect("text_entered", this, "_node_renamed", varray(agnode));
name->connect("focus_exited", this, "_node_renamed_focus_out", varray(name, agnode));
base = 1;
node->set_show_close_button(true);
node->connect("close_request", this, "_delete_request", varray(E->get()), CONNECT_DEFERRED);
}
for (int i = 0; i < agnode->get_input_count(); i++) {
Label *in_name = memnew(Label);
node->add_child(in_name);
in_name->set_text(agnode->get_input_name(i));
node->set_slot(base + i, true, 0, get_color("font_color", "Label"), false, 0, Color());
}
node->connect("dragged", this, "_node_dragged", varray(agnode));
if (EditorNode::get_singleton()->item_has_editor(agnode.ptr())) {
node->add_child(memnew(HSeparator));
Button *open_in_editor = memnew(Button);
open_in_editor->set_text(TTR("Open Editor"));
open_in_editor->set_icon(get_icon("Edit", "EditorIcons"));
node->add_child(open_in_editor);
open_in_editor->connect("pressed", this, "_open_in_editor", varray(E->get()), CONNECT_DEFERRED);
open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER);
}
if (agnode->has_filter()) {
node->add_child(memnew(HSeparator));
Button *edit_filters = memnew(Button);
edit_filters->set_text(TTR("Edit Filters"));
edit_filters->set_icon(get_icon("AnimationFilter", "EditorIcons"));
node->add_child(edit_filters);
edit_filters->connect("pressed", this, "_edit_filters", varray(E->get()), CONNECT_DEFERRED);
edit_filters->set_h_size_flags(SIZE_SHRINK_CENTER);
}
Ref<AnimationNodeAnimation> anim = agnode;
if (anim.is_valid()) {
MenuButton *mb = memnew(MenuButton);
mb->set_text(anim->get_animation());
mb->set_icon(get_icon("Animation", "EditorIcons"));
Array options;
node->add_child(memnew(HSeparator));
node->add_child(mb);
ProgressBar *pb = memnew(ProgressBar);
//.........这里部分代码省略.........