本文整理汇总了C++中GraphNode::get_connection_output_position方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphNode::get_connection_output_position方法的具体用法?C++ GraphNode::get_connection_output_position怎么用?C++ GraphNode::get_connection_output_position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphNode
的用法示例。
在下文中一共展示了GraphNode::get_connection_output_position方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _filter_input
bool GraphEdit::_filter_input(const Point2 &p_point) {
Ref<Texture> port = get_icon("port", "GraphNode");
for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
for (int j = 0; j < gn->get_connection_output_count(); j++) {
Vector2 pos = gn->get_connection_output_position(j) + gn->get_position();
if (is_in_hot_zone(pos, p_point))
return true;
}
for (int j = 0; j < gn->get_connection_input_count(); j++) {
Vector2 pos = gn->get_connection_input_position(j) + gn->get_position();
if (is_in_hot_zone(pos, p_point)) {
return true;
}
}
}
return false;
}
示例2: _connections_layer_draw
void GraphEdit::_connections_layer_draw() {
Color activity_color = get_color("activity");
//draw connections
List<List<Connection>::Element *> to_erase;
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
NodePath fromnp(E->get().from);
Node *from = get_node(fromnp);
if (!from) {
to_erase.push_back(E);
continue;
}
GraphNode *gfrom = Object::cast_to<GraphNode>(from);
if (!gfrom) {
to_erase.push_back(E);
continue;
}
NodePath tonp(E->get().to);
Node *to = get_node(tonp);
if (!to) {
to_erase.push_back(E);
continue;
}
GraphNode *gto = Object::cast_to<GraphNode>(to);
if (!gto) {
to_erase.push_back(E);
continue;
}
Vector2 frompos = gfrom->get_connection_output_position(E->get().from_port) + gfrom->get_offset() * zoom;
Color color = gfrom->get_connection_output_color(E->get().from_port);
Vector2 topos = gto->get_connection_input_position(E->get().to_port) + gto->get_offset() * zoom;
Color tocolor = gto->get_connection_input_color(E->get().to_port);
if (E->get().activity > 0) {
color = color.linear_interpolate(activity_color, E->get().activity);
tocolor = tocolor.linear_interpolate(activity_color, E->get().activity);
}
_draw_cos_line(connections_layer, frompos, topos, color, tocolor);
}
while (to_erase.size()) {
connections.erase(to_erase.front()->get());
to_erase.pop_front();
}
}
示例3: _top_layer_draw
void GraphEdit::_top_layer_draw() {
_update_scroll();
if (connecting) {
Node *fromn = get_node(connecting_from);
ERR_FAIL_COND(!fromn);
GraphNode *from = Object::cast_to<GraphNode>(fromn);
ERR_FAIL_COND(!from);
Vector2 pos;
if (connecting_out)
pos = from->get_connection_output_position(connecting_index);
else
pos = from->get_connection_input_position(connecting_index);
pos += from->get_position();
Vector2 topos;
topos = connecting_to;
Color col = connecting_color;
if (connecting_target) {
col.r += 0.4;
col.g += 0.4;
col.b += 0.4;
}
if (!connecting_out) {
SWAP(pos, topos);
}
_draw_cos_line(top_layer, pos, topos, col, col);
}
if (box_selecting)
top_layer->draw_rect(box_selecting_rect, Color(0.7, 0.7, 1.0, 0.3));
}
示例4: _top_layer_input
void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
Ref<InputEventMouseButton> mb = p_ev;
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
Ref<Texture> port = get_icon("port", "GraphNode");
Vector2 mpos(mb->get_position().x, mb->get_position().y);
for (int i = get_child_count() - 1; i >= 0; i--) {
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
if (!gn)
continue;
for (int j = 0; j < gn->get_connection_output_count(); j++) {
Vector2 pos = gn->get_connection_output_position(j) + gn->get_position();
if (is_in_hot_zone(pos, mpos)) {
if (valid_left_disconnect_types.has(gn->get_connection_output_type(j))) {
//check disconnect
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
if (E->get().from == gn->get_name() && E->get().from_port == j) {
Node *to = get_node(String(E->get().to));
if (Object::cast_to<GraphNode>(to)) {
connecting_from = E->get().to;
connecting_index = E->get().to_port;
connecting_out = false;
connecting_type = Object::cast_to<GraphNode>(to)->get_connection_input_type(E->get().to_port);
connecting_color = Object::cast_to<GraphNode>(to)->get_connection_input_color(E->get().to_port);
connecting_target = false;
connecting_to = pos;
just_disconnected = true;
emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port);
to = get_node(String(connecting_from)); //maybe it was erased
if (Object::cast_to<GraphNode>(to)) {
connecting = true;
}
return;
}
}
}
}
connecting = true;
connecting_from = gn->get_name();
connecting_index = j;
connecting_out = true;
connecting_type = gn->get_connection_output_type(j);
connecting_color = gn->get_connection_output_color(j);
connecting_target = false;
connecting_to = pos;
just_disconnected = false;
return;
}
}
for (int j = 0; j < gn->get_connection_input_count(); j++) {
Vector2 pos = gn->get_connection_input_position(j) + gn->get_position();
if (is_in_hot_zone(pos, mpos)) {
if (right_disconnects || valid_right_disconnect_types.has(gn->get_connection_input_type(j))) {
//check disconnect
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
if (E->get().to == gn->get_name() && E->get().to_port == j) {
Node *fr = get_node(String(E->get().from));
if (Object::cast_to<GraphNode>(fr)) {
connecting_from = E->get().from;
connecting_index = E->get().from_port;
connecting_out = true;
connecting_type = Object::cast_to<GraphNode>(fr)->get_connection_output_type(E->get().from_port);
connecting_color = Object::cast_to<GraphNode>(fr)->get_connection_output_color(E->get().from_port);
connecting_target = false;
connecting_to = pos;
just_disconnected = true;
emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port);
fr = get_node(String(connecting_from)); //maybe it was erased
if (Object::cast_to<GraphNode>(fr)) {
connecting = true;
}
return;
}
}
}
}
connecting = true;
connecting_from = gn->get_name();
connecting_index = j;
connecting_out = false;
connecting_type = gn->get_connection_input_type(j);
connecting_color = gn->get_connection_input_color(j);
//.........这里部分代码省略.........