void link_announce (observer obs, modification mod) { //cout << "Link event " << mod << "\n"; for (list<string> ids= pointer_resolve [obs]; !is_nil (ids); ids= ids->next) for (list<tree> lns= get_links (compound ("id", ids->item)); !is_nil (lns); lns= lns->next) link_announce (lns->item, ids->item, mod); }
int find_interfaces(struct rarpd *rarpd) { if (nl_open(&rarpd->nl_ctx) != 0) { return -1; } if (get_links(rarpd) != 0) { return -1; } if (get_addresses(rarpd) != 0) { return -1; } nl_close(&rarpd->nl_ctx); return 0; }
void mininode_group::update_dirty() { miniv3d center; double radius; unsigned int s=get_links(); // clear bounding sphere bound_center=miniv3d(0,0,0); bound_radius=0.0; // get bounding sphere get_bsphere(center,radius); // merge bounding sphere with children for (unsigned int i=0; i<s; i++) { mininode *link=get_link(i); // get child group mininode_group *child_group=dynamic_cast<mininode_group *>(link); if (child_group) { miniv3d child_center; double child_radius; child_group->get_bsphere(child_center,child_radius); // merge with child bounding sphere if (child_radius>0.0) if (radius>0.0) merge_spheres(center,radius, child_center,child_radius); else { center=child_center; radius=child_radius; } } } bound_center=center; bound_radius=radius; }
void init_linedragging(F_line *l, int x, int y) { int xmin, ymin, xmax, ymax; new_l = l; cur_x = fix_x = x; cur_y = fix_y = y; canvas_locmove_proc = moving_line; canvas_ref_proc = elastic_movenewline; canvas_leftbut_proc = place_line; canvas_middlebut_proc = array_place_line; canvas_rightbut_proc = cancel_line; set_action_on(); if (l->type == T_BOX || l->type == T_ARCBOX || l->type == T_PICTURE) { line_bound(l, &xmin, &ymin, &xmax, &ymax); get_links(xmin, ymin, xmax, ymax); } elastic_moveline(new_l->points); }
void mininode_transform::update_dirty() { // merge two consecutive transform nodes if (get_links()==1) { mininode *link=get_link(); // get child transformation mininode_transform *child_transform=dynamic_cast<mininode_transform *>(link); if (child_transform) { // check child transform types BOOLINT child_translate=dynamic_cast<mininode_translate *>(link)!=NULL; BOOLINT child_rotate=dynamic_cast<mininode_rotate *>(link)!=NULL; BOOLINT child_affine=dynamic_cast<mininode_affine *>(link)!=NULL; BOOLINT child_scale=dynamic_cast<mininode_scale *>(link)!=NULL; BOOLINT child_coord=dynamic_cast<mininode_coord *>(link)!=NULL; // check node transform types BOOLINT node_translate=dynamic_cast<mininode_translate *>(this)!=NULL; BOOLINT node_rotate=dynamic_cast<mininode_rotate *>(this)!=NULL; BOOLINT node_affine=dynamic_cast<mininode_affine *>(this)!=NULL; BOOLINT node_scale=dynamic_cast<mininode_scale *>(this)!=NULL; BOOLINT node_coord=dynamic_cast<mininode_coord *>(this)!=NULL; // check child/node match if ((child_translate && node_translate) || (child_rotate && node_rotate) || (child_affine && node_affine) || (child_scale && node_scale) || (child_affine && node_translate) || (child_translate && node_affine) || (child_affine && node_rotate) || (child_rotate && node_affine)) { if (!child_coord || !node_coord) { // multiply with child's transformation matrix miniv4d mtx[3],mtx1[3],mtx2[3]; mtxget(oglmtx,mtx1); mtxget(child_transform->oglmtx,mtx2); mlt_mtx(mtx,mtx1,mtx2); mtxget(mtx,oglmtx); } // remove child remove_child(); // propagate node to affine transform if (child_affine) if (node_translate) *this=mininode_affine(*dynamic_cast<mininode_translate *>(this)); else if (node_rotate) *this=mininode_affine(*dynamic_cast<mininode_rotate *>(this)); } } } mininode_group::update_dirty(); }
void process_input(char *input, struct Graph *g){ int i = 0; char name_a[50]; char name_b[50]; char type[5]; sscanf(input, "%s %s %s", type, name_a, name_b); if(!strcmp(type,"new")){ add_new_node(name_a, g); } else if(!strcmp(type,"link")){ add_new_link(name_a, name_b, g); } else if(!strcmp(type,"out")){ print_outgoing_nodes(name_a, g); } else if(!strcmp(type,"in")){ print_incoming_nodes(name_a, g); } else if(!strcmp(type,"wn")){ write_data_prompt(name_a, g); } else if(!strcmp(type,"rn")){ read_data(name_a, g); } else if(!strcmp(type, "all")){ print_graph(g); } else if(!strcmp(type,"wl")){ write_link_data_prompt(name_a, name_b, g); } else if(!strcmp(type,"rl")){ read_link_data(name_a, name_b, g); } else if(!strcmp(type, "path")){ // printf("Hey"); test_for_path(name_a, name_b, g); } else if(!strcmp(type, "save")){ save_to_disk(g, name_a); } else if(!strcmp(type, "load")){ read_from_disk(name_a, g); } else if(!strcmp(type, "getl")){ get_links(g); // all links (node pairs) with X data } else if(!strcmp(type, "getn")){ get_nodes(g); // all nodes with X data } else if(!strcmp(type, "add")){ add_nodes(name_a, name_b, g); } else if(!strcmp(type, "div")){ divide_nodes(name_a, name_b, g); } else if(!strcmp(type, "sub")){ subtract_nodes(name_a, name_b, g); } else if(!strcmp(type, "mult")){ multiply_nodes(name_a, name_b, g); } else if(!strcmp(type, "cmd")){ run_command(name_a, g); } else if(!strcmp(type, "id")){ long long_val; long_val = strtol(name_a, NULL, 10); int id = (int) long_val; struct Node *node; node = get_node_by_id(id, g); if(!strcmp(node->name, "NULL")){ printf("{ \"error\": \"No node with id %d\" }\n", id); free(node->name); free(node); } else { printf("{ \"id: %d, \"name\": \"%s\", \"data\": \"%s\" }\n", id, node->name, node->data); } } }