void MoveWindow(t_point destination, double delta) { t_point bottom_left, top_right; bottom_left.x = destination.x - delta; bottom_left.y = destination.y - delta; top_right.x = destination.x + delta; top_right.y = destination.y + delta; t_bound_box move_coords = t_bound_box(bottom_left, top_right); set_visible_world(move_coords); }
void begin_graphics (void) { t_bound_box initial_coords = t_bound_box(0,0,100,100); init_graphics("Analytical Placer - Final View", WHITE); set_visible_world(initial_coords); std::ostringstream str_buf; str_buf << cells.size() << " cells placed with " << nets.size() << " nets"; std::string disp_str = str_buf.str(); update_message(disp_str); if(!created_button) { create_button ("Window", "Toggle Lines", act_on_toggle_nets_button); // name is UTF-8 created_button = true; } event_loop(NULL, NULL, NULL, drawscreen); //t_bound_box old_coords = get_visible_world(); //save the current view for later }
void step_graphis (double overlap_ratio, int vpin_cnt) { t_bound_box initial_coords = t_bound_box(0,0,100,100); init_graphics("Analytical Placer - verbose mode", WHITE); set_visible_world(initial_coords); std::ostringstream str_buf; str_buf << "Added " << vpin_cnt << " virtual pins; overlap ratio = " << overlap_ratio; std::string disp_str = str_buf.str(); update_message(disp_str); if(!created_button) { create_button ("Window", "Toggle Lines", act_on_toggle_nets_button); // name is UTF-8 created_button = true; } drawscreen(); event_loop(NULL, NULL, NULL, drawscreen); }
void drawscreen (void) { set_draw_mode(DRAW_NORMAL); clearscreen(); for(auto it = cells.begin(); it != cells.end(); ++it) { t_point bt_marker = t_point(it->x_pos - 0.3, it->y_pos - 0.3); t_bound_box cell_rect = t_bound_box(bt_marker, 0.6, 0.6); if (it->fixed) setcolor(RED); else setcolor(BLUE); fillrect(cell_rect); } #ifdef _DEBUG_ setcolor(BLACK); for(auto it = virtual_pins.begin(); it != virtual_pins.end(); ++it) { t_point bt_marker = t_point(it->x_pos - 0.3, it->y_pos - 0.3); t_bound_box cell_rect = t_bound_box(bt_marker, 0.6, 0.6); fillrect(cell_rect); } #endif setcolor(MEDIUMPURPLE); setlinestyle(SOLID); setlinewidth(1); std::vector<int> q_to_c_map; q_to_c_map.resize(Q.size()); unsigned int q_idx=0; for(unsigned int i=0; i<cells.size(); i++) { if (Vertex::v_map_table[i] == -1) continue; assert(q_idx < Q.size()); q_to_c_map[q_idx++] = i; } if (show_nets) { int drawn_lines =0; //draw lines between movable cells for(unsigned int c=0; c<Q.size(); c++) { for(unsigned int r=c+1; r<Q.size(); r++) { if (Q[c][r] != 0) { int src_idx = q_to_c_map.at(c); int tgt_idx = q_to_c_map.at(r); drawline(cells[src_idx].x_pos, cells[src_idx].y_pos, cells[tgt_idx].x_pos, cells[tgt_idx].y_pos); drawn_lines++; } } } setcolor(RED); setlinestyle(DASHED); setlinewidth(1); //used edge set to filter std::unordered_set<std::pair<int, int>> u_edges; for(auto f_iter = fixed_cells.begin(); f_iter != fixed_cells.end(); ++f_iter) { std::list<Edge>& adj_cells = f_iter->adj_list; //iterating over the edge list to draw for(auto t_iter = adj_cells.begin(); t_iter != adj_cells.end(); ++t_iter) { std::pair<int, int> edge (f_iter->v_id, t_iter->tgt->v_id); auto set_idx = u_edges.find(edge); //skip if edge is found in the set if (set_idx != u_edges.end()) { continue; } u_edges.insert(edge); drawline(f_iter->x_pos, f_iter->y_pos, t_iter->tgt->x_pos, t_iter->tgt->y_pos); drawn_lines++; } } } #ifdef _DEBUG_ std::cout << "Number of lines drawn: " << drawn_lines << "\n"; #endif }