void draw_tree(node_t *root){ if(root->body_num <= 1){ return; } int u_x = (int)round(window_size * (root->max_x-min_x) / axis_len); int d_x = (int)round(window_size * (root->min_x-min_x) / axis_len); int u_y = (int)round(window_size * (1 - (root->max_y-min_y) / axis_len)); int d_y = (int)round(window_size * (1 - (root->min_y-min_y) / axis_len)); int m_x = (int)round(window_size * (root->mid_x-min_x) / axis_len); int m_y = (int)round(window_size * (1 - (root->mid_y-min_y) / axis_len)); XDrawLine(X.display, X.window, X.gc, m_x, u_y, m_x, d_y); XDrawLine(X.display, X.window, X.gc, d_x, m_y, u_x, m_y); if(root->ne != NULL){ draw_tree(root->ne); } if(root->se != NULL){ draw_tree(root->se); } if(root->nw != NULL){ draw_tree(root->nw); } if(root->sw != NULL){ draw_tree(root->sw); } }
void draw_tree(BITMAP *bitmap, VECTOR p, VECTOR v, NODE *node, int x, int y, int r, int c) { int inv_c = inverse_color(c); if(node != NULL) { if(node->right != NULL) { //line(bitmap, x, y, x + 2 * r, y + 2 * r, inv_c); draw_tree(bitmap, p, v, node->right, x + 2 * r, y + 2 * r, r, c); } if(node->left != NULL) { //line(bitmap, x, y, x - 2 * r, y + 2 * r, inv_c); draw_tree(bitmap, p, v, node->left, x - 2 * r, y + 2 * r, r, c); } if(in_view(p, v, node->a, node->b)) vector_line(bitmap, node->a, node->b, makecol(255, 255, 255)); else vector_line(bitmap, node->a, node->b, 0); textprintf_centre_ex(bitmap, font, node->a.x - 10, node->a.y, makecol(0, 0, 255), -1, "%d", node->val); //circlefill(bitmap, x, y, r, c); //circle(bitmap, x, y, r, inv_c); //textprintf_centre_ex(bitmap, font, x, y - 4, inv_c, -1, "%d", node->val); } }
//draw floor void draw_floor(){ glPushMatrix(); stacks.push(nothing); nothing = nothing * Mtranslate(0,0,-4); nothing = nothing * Mscale(20,20,0.2); draw_cube(1,c7,nothing); //tree1 nothing = stacks.top(); nothing *=Mtranslate(5,5,-3); draw_tree(nothing); //tree2 nothing = stacks.top(); nothing *=Mtranslate(-5,5,-3); nothing *=Mscale(0.8,0.8,0.8); draw_tree(nothing); //tree3 nothing = stacks.top(); nothing *=Mtranslate(0,5,-3); nothing *=Mscale(0.4,0.4,0.4); draw_tree(nothing); nothing = stacks.top(); stacks.pop(); glPopMatrix(); }
//�������������������������������������������������������������������������Ŀ // ��� Protected ��� � // EschElement - draw_tree � // � // Draws recursively using Painter's algorithm (furtherest to closest) � //��������������������������������������������������������������������������� void EschElement::draw_tree(EschElement *elm) { assertMyth("EschElement::draw_tree() needs valid input", elm != 0); if (elm->right) draw_tree(elm->right); elm->draw(); if (elm->left) draw_tree(elm->left); }
void draw_tree(GContext* ctx, double offsetx, double offsety, double directionx, double directiony, double size, double rotation, int depth) { // determines how slowly the angle between branches shrinks // (higher value means slower shrinking) double rotation_scale = dbl(0.85); double SCALE = dbl(9.0); int x1 = offsetx; int y1 = offsety; int x2 = offsetx + directionx * size; int y2 = offsety + directiony * size; // Protect against drawing offscreen if ( 0 < x1 && x1 < 144 && 0 < y1 && y1 < 168 && 0 < x2 && x2 < 144 && 0 < y2 && y2 < 168) { graphics_draw_line(ctx, (GPoint){x1, y1}, (GPoint){x2, y2}); } if (depth > 0){ double dx1 = offsetx + directionx * size; double dy1 = offsety + directiony * size; double dx2 = directionx * cos(rotation) + directiony * sin(rotation); double dy2 = dbl(-1.0) * directionx * sin(rotation) + directiony * cos(rotation); double next_size = size * rand_fl() / SCALE + size * (SCALE - dbl(1.0)) / SCALE; double next_rotation = rotation * rotation_scale; // draw left branch draw_tree(ctx, dx1, dy1, dx2, dy2, next_size, next_rotation * lean_left, depth - 1); double neg_rotation = dbl(-1.0) * rotation; double dx3 = directionx * cos(neg_rotation) + directiony * sin(neg_rotation); double dy3 = dbl(-1.0) * directionx * sin(neg_rotation) + directiony * cos(neg_rotation); // draw right branch draw_tree(ctx, dx1, dy1, dx3, dy3, next_size, next_rotation * lean_right, depth - 1); } }
void draw_tree(int size_from, int size_to) { if (size_from >= size_to) { forward(size_from); turn(-45); draw_tree(size_from / 2, size_to); turn(RIGHT); draw_tree(size_from / 2, size_to); turn(-45); forward(-size_from); } }
static void update_display(Layer* layer, GContext *ctx) { double BRANCHES = dbl(8.0); double INITIAL_LENGTH = dbl(20.0); double pi_8 = dbl(0.39269908169); double width = dbl(72.0); double height = dbl(158.0); double negone = dbl(-1.0); double dzero = dbl(0.0); time_t start_time; uint16_t start_time_ms; time_ms(&start_time, &start_time_ms); lean_left = dbl(1.12); lean_right = dbl(1.12); draw_tree(ctx, width, //144 / 2, height,//168 - 10, dzero, negone, INITIAL_LENGTH, pi_8, BRANCHES); time_t end_time; uint16_t end_time_ms; time_ms(&end_time, &end_time_ms); printf("took %ld ms", (end_time * 1000 + end_time_ms) - (start_time * 1000 + start_time_ms)); }
void draw_tree(Area *a) { if (!a->on_screen) return; if (a->_redraw_needed) { a->_redraw_needed = 0; draw(a); } if (a->pix) XCopyArea(server.display, a->pix, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy); for (GList *l = a->children; l; l = l->next) draw_tree((Area *)l->data); }
void render_panel(Panel *panel) { relayout(&panel->area); if (debug_geometry) area_dump_geometry(&panel->area, 0); update_dependent_gradients(&panel->area); draw_tree(&panel->area); }
void draw_tree(Tree* t, Draw& d, double yunit) { for (Tree* s = t->son; s; s = s->sib) { d.move_to(t->x, int(round(yunit*(1+t->level)))); d.line_to(s->x, int(round(yunit*(1+s->level)))); } for (Tree* s = t->son; s; s = s->sib) draw_tree(s, d, yunit); d.out(t->x, int(round(yunit*(1+t->level))), t->no); }
void draw(t_env *e) { t_pt start; ft_bzero(e->data, e->size_line * 900); if (e->fract_type == 2) { start.x = 970 - 100 * e->decalx; start.y = 540 - 100 * e->decaly; draw_tree(e, start, -(M_PI / 2), e->depth); draw_tree(e, start, (M_PI / 2), e->depth); } else loop(e); control_bar(e); mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0); btext(e); mlx_do_sync(e->mlx); }
int main(int argc, char* argv[]) { srand(time(0)); create_turtle_world(); pen_up(); forward(-150); pen_down(); draw_tree(300, 5); return p1world_shutdown(); }
void draw_tree(GtkWidget *widget,cairo_t *cr, Familia *node){ cairo_set_source_rgb(cr, 0.1, 0.1, 0.1); cairo_select_font_face(cr, "Purisa", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 13); cairo_move_to(cr, node->x, node->y); cairo_show_text(cr, node->nomb_Familia); if (node->sig != NULL) draw_tree(widget,cr,node->sig); }
// draw the whole UI tree int draw_tree(gui_tree_node * tree_root) { node *current_node = NULL; gui_tree_node *current_child = NULL; current_node = tree_root->children.first; while ((current_node != NULL) && (tree_root->children.len != 0)){ current_child = current_node->data; if (!draw_tree(current_child)){ return FALSE; } current_node = current_node->next; } if (tree_root->parent != NULL) { //draw everything but tree's root if (!draw_gui_tree_node(tree_root)) return FALSE; } return TRUE; }
void Tree::print() { tree_calculate_level(this, 0); // calculate level_no 1st int level_no[64] = {0}; int level_max = 0; tree_calculate_level_no(this, level_no, level_max); // calculate the x by the level_no tree_calculate_x(this, level_no); // now it's ready to print out Draw d; double yunit = Draw::eY_MAX * 1.0 / (level_max+2); draw_tree(this, d, yunit); d.print(); }
bool MemoryDump::draw_tree(Node &node, std::ofstream &ofile, const cmd_opt &opt, std::set<uintptr_t> &declared_nodes, int level) { if (node.visited >= 0 && node.visited <= level) return true; if (opt.critical_only && !node.critical) return true; if (opt.depth > 0 && level >= opt.depth) return true; node.visited = level; std::vector<ChildNode*> edges; for (auto &&c : node.children) { if (c.node->subtree_size >= min_size && (!opt.critical_only || c.node->critical)) { edges.push_back(&c); } } std::sort(edges.begin(), edges.end(), [](const ChildNode *a, const ChildNode *b) { return a->node->subtree_size > b->node->subtree_size; } ); if (opt.max_subnodes > 0 && edges.size() > opt.max_subnodes) { //too many nodes, only write nodes with big sizes; edges.resize(opt.max_subnodes); } bool tail_written = false; for (const auto & c : edges) { if (!tail_written && declared_nodes.find(node.label) == declared_nodes.end()) { write_node(node, ofile, opt); declared_nodes.insert(node.label); tail_written = true; } if (declared_nodes.find(c->node->label) == declared_nodes.end()) { write_node(*c->node, ofile, opt); declared_nodes.insert(c->node->label); } exporter->write_edge(node, *c->node, ofile, c->edge.str()); draw_tree(*c->node, ofile, opt, declared_nodes, level + 1); } return true; }
void on_Abort_clicked (GtkButton *button, gpointer user_data) { char *cmd, *name, buf[3]; int i, size; name = xmlGetProp(table[cur_pid].page.curr, "name"); size = strlen(exec_path) + strlen(" -n ") + sizeof(cur_pid) + strlen(buf) + strlen(" ") + strlen(name) + strlen(" abort ") + 1; cmd = (char *) malloc (size); size = 0; strcpy (cmd, exec_path); strcat (cmd, " -n "); sprintf(buf, "%d", cur_pid); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, name); strcat (cmd, " abort "); runPeos(cmd); free(cmd); cmd = NULL; freeAll_extra(); draw_tree (cur_pid); /* check state of current action and highlight item in jtree */ for ( i = 0; i < counting_action; i++) { if ((strcmp (xmlGetProp (linklist[cur_pid][i].cur, "state"), "NONE") == 0) || (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "state"), "SUSPEND") == 0)) { table[cur_pid].page.curr = linklist[cur_pid][i].cur; if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1)))) gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][i].item); break; } } draw_text(table[cur_pid].page.curr); check_state(); }
string_t draw_tree(pair_t value, string_t indent, bool is_last, string_t result) { ptr_t label = fa_pair_first(value); list_t children = fa_pair_second(value); fa_append_to(result, indent); if (is_last) { fa_append_to(result, string("`- ")); fa_append_to(indent, string(" ")); } else { fa_append_to(result, string("+- ")); fa_append_to(indent, string("| ")); } fa_append_to(result, fa_string_to_string(label)); fa_append_to(result, string("\n")); fa_for_each_last(x, children, last) { result = draw_tree(x, indent, last, result); }
/* Perform the actual drawing of the entries */ static void do_drawing(GtkWidget *widget, cairo_t *cr) { /* How much space was the window actually allocated? */ GtkAllocation *allocation = g_new0 (GtkAllocation, 1); gtk_widget_get_allocation(GTK_WIDGET(widget), allocation); display_width = allocation->width; display_height = allocation->height; /* Allocation no longer needed */ g_free(allocation); /* Set cairo drawing variables */ cairo_set_source_rgb(cr, 0, 0, 0); cairo_select_font_face(cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(cr, 20); cairo_set_line_width(cr, 1); cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER); /* Begin drawing the nodes */ draw_tree(cr, root_entry); }
//�������������������������������������������������������������������������Ŀ // EschElement - flush � // � // Draws any pending element entries and clears the arena. � //��������������������������������������������������������������������������� void EschElement::flush() { assertMyth("EschElement::flush() needs sort area", EschSysInstance != 0 && EschSysInstance->sspace != 0); //��� Perform draw of any pending elements if (EschSysInstance->sroot) draw_tree(EschSysInstance->sroot); //��� Clear sort area ivory_arena_clear(EschSysInstance->sspace); EschSysInstance->sroot=0; //��� Update stats if (EschElementDepth > EschSysInstance->sspace_mdepth) EschSysInstance->sspace_mdepth = EschElementDepth; if (EschElementSize > EschSysInstance->sspace_mbytes) EschSysInstance->sspace_mbytes = EschElementSize; EschElementDepth=0; EschElementSize=0; }
void glut_display(void) { set_texture(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(300.0,1.0,0.1,10000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(Distance * cos(Angle2) * sin(Angle1), Distance * sin(Angle2), Distance * cos(Angle2)* cos(Angle1), 0.0,0.0,0.0,0.0,-1.0,0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); draw_tree(root,OpenKey); glFlush(); glDisable(GL_DEPTH_TEST); BuildList( cd->name ); DISPLAY_TEXT(); glutSwapBuffers(); }
void update_window(){ XSetForeground(X.display, X.gc, BlackPixel(X.display, X.screen)); XFillRectangle(X.display, X.window, X.gc, 0, 0, window_size, window_size); XSetForeground(X.display, X.gc, WhitePixel(X.display, X.screen)); // draw line if(LINE){ int u_x = (int)round(window_size * (root->max_x-min_x) / axis_len); int d_x = (int)round(window_size * (root->min_x-min_x) / axis_len); int u_y = (int)round(window_size * (1 - (root->max_y-min_y) / axis_len)); int d_y = (int)round(window_size * (1 - (root->min_y-min_y) / axis_len)); XDrawLine(X.display, X.window, X.gc, d_x, u_y, u_x, u_y); XDrawLine(X.display, X.window, X.gc, u_x, u_y, u_x, d_y); XDrawLine(X.display, X.window, X.gc, u_x, d_y, d_x, d_y); XDrawLine(X.display, X.window, X.gc, d_x, d_y, d_x, u_y); draw_tree(root); } for(int i=0; i<body_num; i++){ body_t *body = bodies + i; if(DEBUG && PIXEL){ int pixel_x = (int)round(window_size * (body->p_x-min_x) / axis_len); int pixel_y = (int)round(window_size * (1 - (body->p_y-min_y) / axis_len)); printf("(%.4lf, %.4lf)->(%d, %d)\n", body->p_x, body->p_y, pixel_x, pixel_y); } if(body->p_x > max_x || body->p_x < min_x || body->p_y > max_y || body->p_y < min_y){ continue; } int pixel_x = (int)round(window_size * (body->p_x-min_x) / axis_len); int pixel_y = (int)round(window_size * (1 - (body->p_y-min_y) / axis_len)); XDrawPoint (X.display, X.window, X.gc, pixel_x, pixel_y); } XFlush(X.display); }
static void ptree_redraw(struct wdgt *w) { DBG("--- redraw tree"); scr_werase(w); draw_tree(w); }
bool MemoryDump::write_output(const cmd_opt &opt) { try { std::ofstream ofile(opt.ofile, std::ofstream::trunc); min_size = total_size * opt.threshold; if (exporter == nullptr || export_type != opt.export_type) { delete exporter; export_type = opt.export_type; switch (export_type) { case EXPORT_DOT: exporter = new ExporterDot(total_size); break; case EXPORT_GML: exporter = new ExporterGML(total_size); break; case EXPORT_GRAPHML: exporter = new ExporterGraphML(); break; default: exporter = new ExporterDot(total_size); export_type = EXPORT_DOT; } } else { switch (export_type) { case EXPORT_DOT: case EXPORT_GML: exporter->set_total_size(total_size); break; default: break; } } exporter->write_preamble(ofile); std::vector<Node*> selected_nodes; if (opt.nodes.empty() && opt.labels.empty()) { for (const auto &c : top_nodes) { selected_nodes.push_back(c.node); } } else { /* find the node pointed by opt.node */ for (const auto &path : opt.nodes) { auto node = find_node(path.node); if (node == nullptr) { std::cout << "No node found for path " << path.literal << std::endl; continue; } selected_nodes.push_back(node); } for (const auto &label : opt.labels) { auto node = nodes.find(label); if (node != nodes.end()) { std::cout << "Found node by label " << std::hex << label << std::dec << std::endl; selected_nodes.push_back(&node->second); } else { std::cout << "Label " << std::hex << label << std::dec << " was not found\n"; } } } std::set<uintptr_t> declared_nodes; for (auto & node : selected_nodes) { write_node(*node, ofile, opt); declared_nodes.insert(node->label); draw_tree(*node, ofile, opt, declared_nodes); } for (auto & node : selected_nodes) { clear_visited(*node); } exporter->write_appendix(ofile); } catch (...) { std::cout << "Unexpected error hanppend while writing output" << std::endl; } return true; }
void draw_tree (tree * t) { if (!t) return; switch (t->type) { case t_program: fprintf (out, "l%d[label=\"program (%d)\"];\n", t->id, t->label); if (t->left) { fprintf (out, "def[label=\"definition (%d)\", fontcolor=%s];\n", t->left->label, COLOR_MAIN); draw_tree (t->left); } fprintf (out, "l%d->def[style=dotted];\n", t->id); fprintf (out, "def->l%d[style=dotted];\n", t->left->id); fprintf (out, "body[label=\"body (%d)\", fontcolor=%s];\n", t->right->label, COLOR_MAIN); draw_tree (t->right); fprintf (out, "l%d->body;\n", t->id); fprintf (out, "body->l%d;\n", t->right->id); break; case t_block: fprintf (out, "l%d[label=\"block (%d)\"];\n", t->id, t->label); draw_tree (t->left); fprintf (out, "l%d->l%d;\n", t->id, t->left->id); break; case t_join: if (t->op == LABEL_JOIN) { fprintf (out, "l%d[label=\"label (%d)\",fontcolor=%s];\n", t->id, t->label, COLOR_GOTO_LBL); fprintf (out, "l%d[label=\"%s (%d)\",fontcolor=%s];\n", t->left->id, t->left->value.idval, t->left->label, COLOR_LABEL); fprintf (out, "l%d->l%d;\n", t->id, t->left->id); } else { fprintf (out, "l%d[label=\"join (%d)\" ,fontcolor=%s];\n", t->id, t->label, COLOR_JOIN); draw_tree (t->left); if (isleaf(t->left) || (t->left->type == t_def)) fprintf (out, "l%d->l%d[style=dotted];\n", t->id, t->left->id); else fprintf (out, "l%d->l%d;\n", t->id, t->left->id); } if (t->right) { draw_tree (t->right); if (isleaf(t->right) || (t->right->type == t_def) || (t->right->left->type == t_def)) fprintf (out, "l%d->l%d[style=dotted];\n", t->id, t->right->id); else fprintf (out, "l%d->l%d;\n", t->id, t->right->id); } break; case t_if: fprintf (out, "l%d[label=\"if (%d)\",fontcolor=%s];\n", t->id, t->label, COLOR_IF_THEN_ELSE); draw_tree (t->left); fprintf (out, "l%d -> l%d;\n", t->id, t->left->id); fprintf (out, "l%d -> l%d;\n", t->id, t->right->id); t = t->right; fprintf (out, "l%d[label=\"then/else (%d)\",fontcolor=%s];\n", t->id, t->label, COLOR_IF_THEN_ELSE); draw_tree (t->left); fprintf (out, "l%d -> l%d;\n", t->id, t->left->id); if (t->right) { draw_tree (t->right); fprintf (out, "l%d -> l%d;\n", t->id, t->right->id); } else { fprintf (out, "l%d_null[label=\"null (%d)\",fontcolor=%s];\n", t->id, t->label, COLOR_NULL); fprintf (out, "l%d -> l%d_null;\n", t->id, t->id); } break; case t_goto: fprintf (out, "l%d[label=\"goto (%d)\",fontcolor=%s];\n", t->id, t->label, COLOR_GOTO_LBL); fprintf (out, "l%d[label=\"%s (%d)\",fontcolor=%s];\n", t->left->id, t->left->value.idval, t->label , COLOR_LABEL); fprintf (out, "l%d -> l%d;\n", t->id, t->left->id); break; case t_while: fprintf (out, "l%d[label=\"while (%d)\",fontcolor=%s];\n", t->id, t->label, COLOR_WHILE); draw_tree (t->left); fprintf (out, "l%d -> l%d;\n", t->id, t->left->id); draw_tree (t->right); fprintf (out, "l%d -> l%d;\n", t->id, t->right->id); break; case t_for: fprintf (out, "l%d[label=\"for (%d)\",fontcolor=%s];\n", t->id, t->label, COLOR_FOR); draw_tree (t->left); fprintf (out, "l%d -> l%d;\n", t->id, t->left->id); draw_tree (t->right); fprintf (out, "l%d -> l%d;\n", t->id, t->right->id); break; case t_sub: fprintf(out, "l%d[label=\"%s (%d)\", fontcolor=\"%s\"];\n", t->id, t->left->value.idval, t->left->label, COLOR_SUB); draw_tree(t->right); fprintf(out, "l%d->l%d;\n", t->id, t->right->id); break; case t_param: fprintf(out, "l%d[label=\", (%d)\", fontcolor=\"%s\"];\n", t->id, t->label, COLOR_PARAM); draw_tree(t->left); fprintf(out, "l%d->l%d;\n", t->id, t->left->id); if(t->right) { draw_tree(t->right); fprintf(out, "l%d->l%d;\n", t->id, t->right->id); } break; case t_def: fprintf (out, "l%d[label=\"as type (%d)\",fontcolor=%s];\n", t->id, t->label, COLOR_DEF); draw_tree (t->left); draw_tree (t->right); fprintf (out, "l%d->l%d[style=dotted];\n", t->id, t->left->id); fprintf (out, "l%d->l%d[style=dotted, color=%s];\n", t->id, t->right->id, COLOR_TYPE_LINK); break; case t_null: fprintf (out, "l%d[label=\"NULL (%d)\",fontcolor=%s];\n", t->id, t->label,COLOR_NULL); break; case t_assign: fprintf (out, "l%d[label=\":= (%d)\", fontcolor=%s];\n", t->id, t->label, COLOR_ASSIGN); draw_tree (t->left); draw_tree (t->right); fprintf (out, "l%d->l%d;\n", t->id, t->left->id); fprintf (out, "l%d->l%d;\n", t->id, t->right->id); break; case t_op: fprintf (out, "l%d[label=\"%c (%d)\",fontcolor=%s]\n", t->id, t->op, t->label, COLOR_OP); draw_tree (t->left); draw_tree (t->right); fprintf (out, "l%d->l%d;\n", t->id, t->left->id); fprintf (out, "l%d->l%d;\n", t->id, t->right->id); break; case t_num: fprintf (out, "l%d[label=\"%d (%d)\",fontcolor=%s];\n", t->id, t->value.numval, t->label, COLOR_NUM); break; case t_id: fprintf (out, "l%d[label=\"%s (%d)\",fontcolor=%s];\n", t->id, t->value.idval, t->label, COLOR_ID); break; default: break; } }
void on_Start_clicked(GtkButton *menuitem, gpointer user_data) { char *cmd = NULL, buf[3], *name = NULL, *res_qual = NULL, *res_val = NULL; int i, size = 0; static GtkWidget *input_dialog = NULL; xmlNode *cur = NULL; for ( cur = table[cur_pid].page.curr->children; cur;cur = cur->next) { if (cur->name && xmlStrcmp(cur->name, (const xmlChar*) "req_resource" ) == 0 ) { res_qual = xmlGetProp(cur, "qualifier"); res_val = xmlGetProp(cur, "value"); res_name = NULL; res_name = xmlGetProp(cur, "name"); if ( strcmp (res_val,"$$") == 0) { if ( strcmp ( res_qual, "abstract") != 0) { if (!input_dialog) { input_dialog = create_inputdialog((gchar *) res_name); gtk_widget_show (input_dialog); deactivate(); gtk_signal_connect (GTK_OBJECT(input_dialog), "destroy", (GtkSignalFunc) dialog_destroy, &input_dialog); } else { if (!GTK_WIDGET_MAPPED (input_dialog)) gtk_widget_show(input_dialog); else gdk_window_raise(input_dialog->window); } } } else if ( strcmp (res_qual, "new") == 0) { if (!input_dialog) { input_dialog = create_inputdialog((gchar *)res_name); gtk_widget_show (input_dialog); deactivate(); gtk_signal_connect (GTK_OBJECT(input_dialog), "destroy", (GtkSignalFunc) dialog_destroy, &input_dialog); } else { if (!GTK_WIDGET_MAPPED (input_dialog)) gtk_widget_show(input_dialog); else gdk_window_raise(input_dialog->window); } } else if (strcmp (res_val,"$$") != 0){ name = xmlGetProp (table[cur_pid].page.curr, "name"); sprintf(buf, "%d", cur_pid); size = strlen(exec_path) + strlen(" -n ") + strlen(buf) + strlen(" ") + strlen(name) + strlen(" start ") + 1; cmd = (char *) malloc(size*sizeof(char )); size = 0; strcpy (cmd, exec_path); strcat (cmd, " -n "); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, name); strcat (cmd, " start "); runPeos(cmd); free(cmd); cmd = NULL; freeAll_extra(); draw_tree (cur_pid); for ( i = 0; i < counting_action; i++) { if (strcmp (linklist[cur_pid][i].cur->name, "action") == 0) { if (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "name"), name) == 0) { table[cur_pid].page.curr = linklist[cur_pid][i].cur; break; } } } if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1)))) gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][i].item); draw_text(table[cur_pid].page.curr); check_state(); return; } } } }
void on_Finish_clicked(GtkButton *button, gpointer user_data) { if ( table[cur_pid].page.curr) { char *cmd, *name, buf[3]; int i, size; if (table[cur_pid].process != NULL ) { sprintf(buf, "%d", cur_pid); /* Put this up here: fix */ name = xmlGetProp(table[cur_pid].page.curr, "name"); size = strlen(exec_path) + strlen(" -n ") + sizeof(cur_pid) + strlen(buf) + strlen(" ") + strlen(name) + strlen(" finish ") + 1; cmd = (char *) malloc (size); strcpy (cmd, exec_path); strcat (cmd, " -n "); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, name); strcat (cmd, " finish "); runPeos(cmd); free(cmd); cmd = NULL; } freeAll_extra(); if (table[cur_pid].process != NULL ) { draw_tree (cur_pid); /* search through actions and find the current page */ for ( i = 0; i < counting_action; i++) { if (strcmp (linklist[cur_pid][i].cur->name, "action") == 0) { if (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "name"), name) == 0) { table[cur_pid].page.curr = linklist[cur_pid][i].cur; break; } } } draw_text(table[cur_pid].page.curr); if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1)))) gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][table[cur_pid].page.index].item); check_state(); } else { table[cur_pid].page.index = 0; gtk_widget_destroy (notebook); notebook = create_notebook(); gtk_widget_set_name (notebook, "notebook"); gtk_widget_ref (notebook); gtk_object_set_data_full (GTK_OBJECT (Peos), "notebook", notebook, (GtkDestroyNotify) gtk_widget_unref); set_selection(1); /* with current action selected */ gtk_widget_show (notebook); gtk_container_add (GTK_CONTAINER (vbox), notebook); for (i = 0; i < MAX_PID; i++) { if (table[i].process != NULL) cur_pid = i; } } redisplay_menu(); } }
int on_OK_clicked(GtkButton *button, gpointer user_data) { char *cmd, buf[3], *buf2, *input, *tmp, *name, *enter, *enter_tmp; int i, size; input = gtk_entry_get_text(GTK_ENTRY (entry1)); if(input == NULL) { perror("Inefficient memroy: input is NULL. Aborting."); RTN_ON_OK_CLICKED = EXIT_FAILURE; exit(1); } else { size = strlen("\'") + strlen(input) + strlen("\'") + 1; enter = (char *) malloc (size*sizeof(char)); strcpy (enter, "\'"); strcat (enter, input); strcat (enter, "\'"); size = 0; /* for reuse */ } if (table[cur_pid].process != NULL ) { if (input != NULL) { sprintf(buf, "%d", cur_pid); /* Moved here to satisfy below */ name = xmlGetProp(table[cur_pid].page.curr,"name"); size = strlen(exec_path) + strlen(" -n") + sizeof(cur_pid) + strlen(buf) + strlen(" ") + strlen(name) + strlen(" start ") + 1; cmd = (char *) malloc (size); size = 0; strcpy (cmd, exec_path); strcat (cmd, " -n "); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, name); strcat (cmd, " start "); runPeos(cmd); free(cmd); cmd = NULL; size = strlen(exec_path) + strlen(" -r ") + strlen(buf) + strlen(" ") + strlen(res_name) + strlen(" ") + strlen(enter) + strlen(" ") + 1; cmd = (char *) malloc (size); size = 0; /* ./peos -r pid resource_name resource_res_value */ strcpy (cmd, exec_path); strcat (cmd, " -r "); strcat (cmd, buf); strcat (cmd, " "); strcat (cmd, res_name); strcat (cmd, " "); strcat (cmd, enter); strcat (cmd, " "); tmp = get_current_dir_name(); if(tmp == NULL) { perror("No current directory found. Aborting. \n"); RTN_ON_OK_CLICKED = EXIT_FAILURE; exit(1); } else { //size = strlen(tmp) + strlen("/") + strlen(enter_tmp) + 1; size = strlen(tmp) + strlen("/") + 1; buf2 = (char *) malloc(size*sizeof(char)); size = 0; strcpy(buf2, tmp); strcat(buf2,"/"); } if(enter == NULL) { perror("Memory alloc error: enter = NULL \n"); RTN_ON_OK_CLICKED = EXIT_FAILURE; exit(1); } else enter[strlen(enter)] = '\0'; /* to eliminate the quotes and -2 in alloc to take into acount: '"', '"' */ size = strlen(enter) + 1; enter_tmp = (char *) malloc(size*sizeof(char)); strcpy(enter_tmp, enter); int j = 0; for(i = 1; i < size-3; i++) { /* integer value for the single quote character */ if(enter[i] != 39) { enter_tmp[j] = enter[i]; j++; } } enter_tmp[strlen(enter_tmp)-1] = '\0'; /* need more memory */ char *buf2_temp = NULL; size = 0; size = strlen(buf2) + strlen(enter_tmp) + 1; buf2_temp = (char *) malloc(size*sizeof(char)); strcpy(buf2_temp, buf2); free(buf2); buf2 = NULL; strcat(buf2_temp, enter_tmp); free(enter_tmp); enter_tmp = NULL; free(buf2_temp); buf2_temp = NULL; runPeos (cmd); free (cmd); cmd = NULL; freeAll_extra(); draw_tree (cur_pid); /* search through actions and find the current page */ for ( i = 0; i < counting_action; i++) { if (strcmp (linklist[cur_pid][i].cur->name, "action") == 0) { if (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "name"), name) == 0) { table[cur_pid].page.curr = linklist[cur_pid][i].cur; break; } } } draw_text(table[cur_pid].page.curr); /* highlight the current item in the jtree */ if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1)))) gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][table[cur_pid].page.index].item); } free (enter); enter = NULL; /* check to maintain the next and previous states */ check_state(); } /* return global EXIT_SUCCESS */ RTN_ON_OK_CLICKED = EXIT_SUCCESS; return EXIT_SUCCESS; }
void runalias() { create_tree(); draw_tree(); }
int main (int ac, char **av) { int rval = 0; tsp_bbnode *rootbbnode = (tsp_bbnode *) NULL; char *probname = (char *) NULL; double restart_upbound = 0.0; int restart_ncount = 0; int bbcount = 0; double branchzeit = 0.0; char format[1024]; double mod = -1.0; CCptrworld bbnode_world; CCptrworld_init (&bbnode_world); rval = parseargs (ac, av); if (rval) return 1; if (dig_before > 0) { int i; mod = 1.0; for (i=0; i<dig_before; i++) mod = mod * 10.0; sprintf (format, "%%0%d.%df", dig_before + dig_after + 1, dig_after); } else { mod = -1.0; sprintf (format, "%%.%df", dig_after); } rval = read_restart (resfname, &probname, &rootbbnode, &restart_upbound, &restart_ncount, &bbcount, &branchzeit, &bbnode_world); if (rval) { fprintf (stderr, "read_restart failed\n"); goto CLEANUP; } if (use_graphics) { rval = draw_tree (probname, restart_upbound, bbcount, branchzeit, arg_maxdepth, rootbbnode); if (rval) { fprintf (stderr, "draw_tree failed\n"); goto CLEANUP; } } else if (leafsummary || nodelist) { rval = report_leaves (probname, restart_upbound, bbcount, branchzeit, mod, format, rootbbnode, nodelist); if (rval) { fprintf (stderr, "report_leaves failed\n"); goto CLEANUP; } } else { rval = report_tree (probname, restart_upbound, bbcount, branchzeit, arg_maxdepth, mod, format, rootbbnode); if (rval) { fprintf (stderr, "report_tree failed\n"); goto CLEANUP; } } rval = 0; CLEANUP: CC_IFFREE (probname, char); free_tree (&rootbbnode, &bbnode_world); CCptrworld_delete (&bbnode_world); return rval; }