int main ( int argc, char * argv[]) { /* parse command line */ if ( argc < 6 ) { fprintf (stderr, "Usage: %s <bin bdries file> <selection size 1> <selection size 2> <overlap size> <number of simluation rounds>\n" "where <bin bdries file is of the format (for example) \n" " 113 \n" " 256 \n" " 500 \n" "etc \n", argv[0]); exit (1); } char infilename[150] = {'\0'}; int nsel1, nsel2, noverlap, nrounds; sprintf ( infilename, "%s", argv[1]); nsel1 = atoi(argv[2]); nsel2 = atoi(argv[3]); noverlap = atoi(argv[4]); nrounds = atoi(argv[5]); /* read in boundary array */ int * boundaries; int bds_length; if (read_boundaries (infilename, &boundaries, &bds_length)) exit (1); if (nsel1>bds_length || nsel2>bds_length) { fprintf (stderr, "Both selection sizes must be no bigger than the number of bins.\n"); exit(1); } /* build the search tree */ int nodes_needed = number_of_nodes_needed(bds_length); Node * root = NULL; Node * node_list = NULL; node_list = (Node*)ecalloc(nodes_needed, sizeof(Node)); tree_build_bottom_up(boundaries, bds_length, node_list, &root); /* simulation */ srand48(time(NULL)); int n, i; char * selection_array = calloc(bds_length, sizeof(char)); int max_val = boundaries[bds_length-1]; int count_smaller=0, count_bigger=0; for(n=0; n<nrounds; n++) { memset(selection_array, 0, bds_length*sizeof(char)); mark_selection(root, nsel1, selection_array, max_val, 1); mark_selection(root, nsel2, selection_array, max_val, 2); int overlap_size = 0; for (i=0; i<bds_length; i++) { if (selection_array[i]==3) overlap_size+=1; } if (overlap_size>=noverlap) count_bigger++; if (overlap_size<=noverlap) count_smaller++; } count_smaller +=1; // to remind ourselves that e cannot go below 1/nrounds in precision printf (" count smaller = %5d, p smaller = %.2e\n", count_smaller, (float)count_smaller/nrounds); printf (" count bigger = %5d, p bigger = %.2e\n", count_bigger, (float)count_bigger/nrounds); return 0; }
void move(mouseStateStruct *mouseState, double x, double y){ //simulate it's been cut cairo_set_source_rgb(mouseState->cr,1,1,1); cairo_rectangle(mouseState->cr,selection_x1,selection_y1,selection_x2-selection_x1,selection_y2-selection_y1); cairo_fill(mouseState->cr); //draw selection double diff_x = move_x1 - selection_x1; double diff_y = move_y1 - selection_y1; mark_selection(mouseState->cr,x-diff_x,y-diff_y,x+selection_x2-move_x1,y+selection_y2-move_y1); gdk_cairo_set_source_pixbuf(mouseState->cr,selection_pixbuf,x-diff_x,y-diff_y); cairo_paint(mouseState->cr); }
void paste(GtkWidget *widget, gpointer data){ cairo_t *cr = gdk_cairo_create(canvas->window); //save_current_surface(cairo_get_target(cr)); // GError *error = NULL; //gdk_pixbuf_save (current_surface_pixbuf, "current.png", "png", &error,NULL); double clipboard_width = (double) gdk_pixbuf_get_width(clipboard_pixbuf); double clipboard_height = (double) gdk_pixbuf_get_height(clipboard_pixbuf); selection_x1 = paste_x1; selection_y1 = paste_y1; selection_x2 = paste_x1+clipboard_width; selection_y2 = paste_y1+clipboard_height; gdk_cairo_set_source_pixbuf(cr,clipboard_pixbuf,paste_x1,paste_y1); cairo_paint(cr); current_tool = XPainter_MOVE_TOOL; mark_selection(cr,selection_x1,selection_y1,selection_x2,selection_y2); save_selection(selection_x1,selection_y1,selection_x2,selection_y2); }
int main_widget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWorkspace::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: resize_s(); break; case 1: push_right(); break; case 2: push_left(); break; case 3: mark_selection(); break; case 4: open_new_file(); break; case 5: set_font(); break; case 6: set_page((*reinterpret_cast< int(*)>(_a[1]))); break; case 7: set_background(); break; case 8: save_label(); break; default: ; } _id -= 9; } return _id; }