void nautilus_floating_bar_set_details_label (NautilusFloatingBar *self, const gchar *label) { if (g_strcmp0 (self->priv->details_label, label) != 0) { g_free (self->priv->details_label); self->priv->details_label = g_strdup (label); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAILS_LABEL]); update_labels (self); } }
void DateFilter::on_select_date(bool rangestart) { if(rangestart) { select_date(gettext("Select date"), m_startdate); if(m_enddate.empty()) { m_enddate = m_startdate; } } else { select_date(gettext("Select Enddate"), m_enddate); if(m_startdate.empty()) { m_startdate = m_enddate; } } update_labels(); }
void DateFilter::on_filtertype_changed() { Glib::ustring text = m_filter_type->get_active_text(); if(text == gettext("None")) { m_filter_date->hide(); m_filter_range->hide(); m_startdate.clear(); m_enddate.clear(); } if(text == gettext("Today")) { m_filter_date->hide(); m_filter_range->hide(); set_today(); } if(text == gettext("Yesterday")) { m_filter_date->hide(); m_filter_range->hide(); set_yesterday(); } if(text == gettext("Date")) { m_filter_date->show(); m_filter_range->hide(); if(m_startdate.empty()) { set_today(); } m_enddate.clear(); } if(text == gettext("Range")) { m_filter_date->show(); m_filter_range->show(); if(m_startdate.empty()) { set_today(); } if(m_enddate.empty()) { m_enddate = m_startdate; } } update_labels(); }
void sc_gui_update_menu(void) { GtkWidget *menu_item; guint i; static gboolean need_init = TRUE; GSList *group = NULL; gchar *label; if (need_init) { gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), sc_info->menu_item); need_init = FALSE; } if (sc_info->main_menu != NULL) gtk_widget_destroy(sc_info->main_menu); sc_info->main_menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(sc_info->menu_item), sc_info->main_menu); sc_info->submenu_item_default = gtk_menu_item_new_with_label(NULL); gtk_container_add(GTK_CONTAINER(sc_info->main_menu), sc_info->submenu_item_default); g_signal_connect(sc_info->submenu_item_default, "activate", G_CALLBACK(menu_item_toggled_cb), NULL); update_labels(); menu_item = gtk_separator_menu_item_new(); gtk_container_add(GTK_CONTAINER(sc_info->main_menu), menu_item); sc_ignore_callback = TRUE; for (i = 0; i < sc_info->dicts->len; i++) { label = g_ptr_array_index(sc_info->dicts, i); menu_item = gtk_radio_menu_item_new_with_label(group, label); group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menu_item)); if (utils_str_equal(sc_info->default_language, label)) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), TRUE); gtk_container_add(GTK_CONTAINER(sc_info->main_menu), menu_item); g_signal_connect(menu_item, "toggled", G_CALLBACK(menu_item_toggled_cb), label); } sc_ignore_callback = FALSE; gtk_widget_show_all(sc_info->main_menu); }
ColorWheel::ColorWheel() { add_child(overlay); style()->set("position: absolute; left: 0; top: 0; width:400px; height:400px;"); overlay->saturation_outer->slider->func_value_changed() = bind_member(this, &ColorWheel::option_changed); overlay->saturation_inner->slider->func_value_changed() = bind_member(this, &ColorWheel::option_changed); overlay->value_outer->slider->func_value_changed() = bind_member(this, &ColorWheel::option_changed); overlay->value_inner->slider->func_value_changed() = bind_member(this, &ColorWheel::option_changed); overlay->radio_row->radiobutton_HSV->func_selected() = bind_member(this, &ColorWheel::option_changed); overlay->radio_row->radiobutton_HSL->func_selected() = bind_member(this, &ColorWheel::option_changed); overlay->saturation_outer->slider->set_position(overlay->saturation_outer->slider->max_position()); overlay->saturation_inner->slider->set_position(0); overlay->value_outer->slider->set_position(overlay->value_outer->slider->max_position()); overlay->value_inner->slider->set_position(0); overlay->radio_row->radiobutton_HSV->set_selected(true); overlay->radio_row->radiobutton_HSV->set_selected(true); update_labels(); }
static void create_gui(struct application_info *app) { PangoFontDescription *font_desc = NULL; /* Main window. */ app->gui.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(app->gui.window), "delete_event", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(G_OBJECT(app->gui.window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_window_set_has_resize_grip(GTK_WINDOW(app->gui.window), FALSE); gtk_window_set_title(GTK_WINDOW(app->gui.window), "stopclock"); /* The layout box. */ app->gui.box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10); /* Create two labels and adjust their font. */ app->gui.clock = gtk_label_new("00:00"); app->gui.timer = gtk_label_new("00:00:00"); update_labels(app); font_desc = pango_font_description_from_string(LABEL_FONT); gtk_widget_modify_font(app->gui.clock, font_desc); gtk_widget_modify_font(app->gui.timer, font_desc); pango_font_description_free(font_desc); /* Timeout callback. */ g_timeout_add(500, (GSourceFunc)update_labels, app); /* Connect all the containers and show the window. */ gtk_box_pack_start(GTK_BOX(app->gui.box), app->gui.clock, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(app->gui.box), app->gui.timer, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(app->gui.window), app->gui.box); gtk_widget_show_all(app->gui.window); }
static XtGeometryResult query_geometry(Widget w, XtWidgetGeometry *intended, XtWidgetGeometry *preferred) { Dimension width,height; CtrlWidget cw = (CtrlWidget)w; CtrlPart *c = & cw->ctrl; if( c->isflip ) { c->msg.cmd=MSG_UPDATE; XtCallCallbacks( w, XtNcallback, (XtPointer) &c->msg ); update_labels(w); } calc_widget_size(w, &width, &height); preferred->request_mode = CWWidth | CWHeight; // preferred->width = Max( width, cw->core.width ); // preferred->height = Max( height, cw->core.height ); preferred->width = width; preferred->height = height; TRACE(2, "%s %u %u", cw->core.name, preferred->width, preferred->height ); if ( ((intended->request_mode & (CWWidth | CWHeight)) == (CWWidth | CWHeight)) && intended->width == preferred->width && intended->height == preferred->height) return XtGeometryYes; else if (preferred->width == w->core.width && preferred->height == w->core.height) return XtGeometryNo; else return XtGeometryAlmost; }
//TODO: // A train is regarded as a point!!! TODO: refactor to a train with length void get_shortest_route(track_node* track, int* train_direction, track_node* train_node, int train_shift, track_node* target_node, int target_shift, int* switches, int* route_found, track_node** route, int* route_length, track_edge** edges){ //printf("ENTERED\n"); // Initialization ///////////////////////////////////////////////////////// // Utility variables int i, min_label, switch_num; track_node* min_node; track_node* temp_node; track_node* temp_route[TRACK_MAX]; //Initialization init_dijkstra( track ); train_node->label = 0; *route_found = 0; *route_length = 0; //printf("INITIALIZED\n"); // Main loop ////////////////////////////////////////////////////////////// while( exist_unvisited( track ) ){ // Iteration initialization get_min_label( track, &min_node, &min_label ); min_node->visited = 1; ////printf("MIN LABEL: %s\n", min_node->name ); //At least one way to the target is found if( min_node == target_node ){ //printf("ROUTE IS FOUND!!! :)\n"); *route_found = 1; break; } // All other nodes cannot be reached (direction-caused dead-end) if(min_label == INFINITY){ //printf("ROUTE IS NOT FOUND!!! :(\n"); *route_found = 0; break; } // Update neighbours // init_node_neighbours( min_node ); update_labels( min_node ); } if( *route_found ){ // CONSTRUCTING THE ROUTE ///////////////////////////////////////////// //printf("CONSTRUCTING THE ROUTE\n"); temp_route[*route_length] = min_node; *route_length += 1; while( train_node->index != min_node->index ){ temp_node = min_node->previous; min_node = temp_node; temp_route[*route_length] = min_node; *route_length += 1; } // REVERSING THE ROUTE //////////////////////////////////////////////// //printf("REVERSING THE ROUTE\n"); for( i = 0; i < *route_length; i++ ){ route[*route_length - i - 1] = temp_route[i]; } // ADJUSTING SWITCHES ///////////////////////////////////////////////// //printf("ADJUSTING SWITCHES\n"); for( i = 0; i < *route_length - 1; i++ ){ if( route[i]->type == NODE_BRANCH ){ switch_num = route[i]->num; if( route[i]->edge[DIR_STRAIGHT].dest == route[i + 1] ){ //Adjust switch to straight switches[get_switch_index( switch_num )] = SWITCH_STRAIGHT_POS; ////printf("STRAIGHT SWITCH is found: %d\n", switch_num); } else if( route[i]->edge[DIR_CURVED].dest == route[i + 1] ){ //Adjust switch to curved switches[get_switch_index( switch_num )] = SWITCH_CURVE_POS; ////printf("CURVED SWITCH is found: %d\n", switch_num); } } } // Constructing edges pointers array ////////////////////////////////// //printf("CONSTRUCTING EDGES ARRAY\n"); for( i = 0; i < *route_length - 1; i++ ){ get_edge_by_nodes( route[i], route[i + 1], &edges[i]); } // Printing the route ///////////////////////////////////////////////// //printf("PRINTING THE ROUTE\n"); //printf("Route length is: %d\n", *route_length); for(i = 0; i < *route_length; i++){ //printf("%s; ", route[i]->name); } } //printf("\nEXITED\n"); }
void augment() //main function of the algorithm { if (verbose) { printf("\n\nAugment(.) call\n"); printf("Current matching is as follows:\n"); print_matching(); } if (max_match == n) return; //check wether matching is already perfect int x, y, root; //just counters and root vertex int q[N], wr = 0, rd = 0; //q - queue for bfs, wr,rd - write and read root = 0; // stop warning, it will be assigned below before xy has // a bunch of -1's in it to start. //pos in queue memset(S, false, sizeof(S)); //init set S memset(T, false, sizeof(T)); //init set T memset(prev, -1, sizeof(prev)); //init set prev - for the alternating tree for (x = 0; x < n; x++) //finding root of the tree if (xy[x] == -1) { q[wr++] = root = x; prev[x] = -2; S[x] = true; break; } for (y = 0; y < n; y++) //initializing slack array { slack[y] = lx[root] + ly[y] - cost[root][y]; slackx[y] = root; } //second part of augment() function while (true) //main cycle { while (rd < wr) //building tree with bfs cycle { x = q[rd++]; //current vertex from X part for (y = 0; y < n; y++) //iterate through all edges in equality graph if (cost[x][y] == lx[x] + ly[y] && !T[y]) { if (yx[y] == -1) break; //an exposed vertex in Y found, so //augmenting path exists! T[y] = true; //else just add y to T, q[wr++] = yx[y]; //add vertex yx[y], which is matched //with y, to the queue add_to_tree(yx[y], x); //add edges (x,y) and (y,yx[y]) to the tree } if (y < n) break; //augmenting path found! } if (y < n) break; //augmenting path found! if (verbose) { printf("Augmenting path not found\n"); print_S_T_sets(); } update_labels(); //augmenting path not found, so improve labeling draw_all_bfs_trees(root); wr = rd = 0; for (y = 0; y < n; y++) //in this cycle we add edges that were added to the equality graph as a //result of improving the labeling, we add edge (slackx[y], y) to the tree if //and only if !T[y] && slack[y] == 0, also with this edge we add another one //(y, yx[y]) or augment the matching, if y was exposed if (!T[y] && slack[y] == 0) { if (yx[y] == -1) //exposed vertex in Y found - augmenting path exists! { x = slackx[y]; break; } else { T[y] = true; //else just add y to T, if (!S[yx[y]]) { q[wr++] = yx[y]; //add vertex yx[y], which is matched with //y, to the queue add_to_tree(yx[y], slackx[y]); //and add edges (x,y) and (y, //yx[y]) to the tree } } } if (y < n) break; //augmenting path found! } if (y < n) //we found augmenting path! { if (verbose) { draw_graph(y); printf("Augmenting path found\n"); printf("Exposed vertex y%d (via x%d)\n", y, x); printf("Matching before is as follows:\n"); print_matching(); draw_all_bfs_trees(root); pause_for_user(); printf("Augmenting path:\n"); //printf("(y) y%d --> x%d (x) ", y, x); printf("y%d --> x%d ", y, x); fflush(stdout); int tx = x; while (prev[tx] != -2) { printf("<===> y%d ", xy[tx]); fflush(stdout); tx = prev[tx]; printf("--> x%d ", tx); fflush(stdout); if (tx == -1) { printf("error :-(\n"); break; } } printf("\n"); } max_match++; //increment matching //in this cycle we inverse edges along augmenting path for (int cx = x, cy = y, ty; cx != -2; cx = prev[cx], cy = ty) { ty = xy[cx]; yx[cy] = cx; xy[cx] = cy; } if (verbose) { draw_graph(y); pause_for_user(); printf("Matching after is as follows:\n"); print_matching(); printf("\n"); } augment(); //recall function, go to step 1 of the algorithm } }//end of augment() function
/* * Integrate peaks */ void psnd_integrate1d(MBLOCK *mblk, float x1, float x2) { int i; int i1 = round(x1); int i2 = round(x2); int lim1 = min(i1, i2); int lim2 = max(i1, i2); int xmin, xmax; float sum0, sum1, sum, ymin, ymax, yrange,xx; char *label; POPUP_INFO *popinf = mblk->popinf + POP_INT1D; lim1 = max(1, lim1); lim2 = max(1, lim2); lim1 = min(DAT->isize, lim1); lim2 = min(DAT->isize, lim2); mblk->int1dinf->left = min(lim1,lim2); mblk->int1dinf->right = max(lim1,lim2); update_labels(mblk); lim1 = mblk->int1dinf->left; lim2 = mblk->int1dinf->right; /* * ... determine integral over visible area (and min and max) */ for (i=0,sum0=0;i<DAT->isize;i++) sum0 += DAT->xreal[i]; if (sum0 == 0) sum0 = 1; /* * * ... determine integral over selected area (and min and max) * ... and draw the intensity lines * */ g_append_object(mblk->spar[S_REAL].obj_id); g_set_foreground(mblk->spar[S_REAL].color); for (i=lim1,sum=0,xmin=lim1,xmax=lim1;i<=lim2;i++) { sum += DAT->xreal[i-1]; g_moveto((float) i, DAT->xreal[i-1]); g_lineto((float) i, 0.0); } /* * * ... calc integral * */ g_set_foreground(mblk->spar[S_REAL].color3); minmax(DAT->xreal,DAT->isize,&(DAT->ylimit[0]),&(DAT->ylimit[1])); sum1=0; yrange = (DAT->ylimit[1] - DAT->ylimit[0])/ sum0; for (i=lim1;i<lim2;i++) { sum1 += yrange * DAT->xreal[i-1]; DAT->work1[i-1] = sum1; } /* * Try to move integral on top of peak */ xx=DAT->ylimit[0]; for (i=lim1;i<lim2;i++) { if (xx < (DAT->xreal[i-1]-DAT->work1[i-1])) xx = DAT->xreal[i-1]-DAT->work1[i-1]; } /* * But not outside window */ if (DAT->work1[lim2-2]+xx>DAT->ylimit[1]) xx -= -DAT->ylimit[1] + (DAT->work1[lim2-2] + xx); xx += (DAT->ylimit[1] - DAT->ylimit[0])/100; for (i=lim1;i<lim2;i++) { DAT->work1[i-1] += xx; } /* * Draw integral */ g_moveto((float) lim1, DAT->work1[lim1-1]); for (i=lim1;i<lim2;i++) { g_lineto((float)i, DAT->work1[i-1]); } /* * Print label */ g_moveto((float) lim1, DAT->work1[lim1-1]+(DAT->work1[lim2-2]-DAT->work1[lim1-1])/2); label = psnd_sprintf_temp("%.2e", sum); /* g_set_motif_realtextrotation(1); g_set_textdirection(90);*/ g_label(label); /* g_set_textdirection(0);*/ g_set_foreground(mblk->spar[S_REAL].color); g_close_object(mblk->spar[S_REAL].obj_id); g_plotall(); /* g_set_motif_realtext rotation(0);*/ mblk->int1dinf->sum = sum; if (popinf->visible) add_integral(mblk); psnd_printf(mblk," Range: %6d%6d Area: %g\n", lim1, lim2, sum); }
void solve_bipartite_matching() { for(size_t max_match=0; max_match<nel; ++max_match) { size_t x, y, root=MINUS_ONE; //just counters and root vertex std::vector<size_t> q(nel); size_t wr = 0, rd = 0; //q - queue for bfs, wr,rd - write and read //pos in queue S.assign(nel, false); //init set S T.assign(nel, false); //init set T prev.assign(nel, MINUS_ONE); //init set prev - for the alternating tree for (x = 0; x < nel; x++) //finding root of the tree if (xy[x] == MINUS_ONE) { q[wr++] = root = x; prev[x] = MINUS_TWO; S[x] = true; break; } for (y = 0; y < nel; y++) //initializing slack array { //std::cerr << "root " << root << " y " << y << std::endl; slack[y] = lx[root] + ly[y] - get_cost(root,y); slackx[y] = root; } //second part of augment() function bool found= false; while (!found) //main cycle { while (rd < wr && !found) //building tree with bfs cycle { x = q[rd++]; //current vertex from X part for (y = 0; y < nel && !found;) //iterate through all edges in equality graph { if (get_cost(x,y) == lx[x] + ly[y] && !T[y]) { if (yx[y] == MINUS_ONE) { found= true; //an exposed vertex in Y found, so } //augmenting path exists! else { T[y] = true; //else just add y to T, q[wr++] = yx[y]; //add vertex yx[y], which is matched //with y, to the queue add_to_tree(yx[y], x); //add edges (x,y) and (y,yx[y]) to the tree ++y; } } else ++y; } } if (!found) { update_labels(); //augmenting path not found, so improve labeling wr = rd = 0; for (y = 0; y < nel && !found;) { //in this cycle we add edges that were added to the equality graph as a //result of improving the labeling, we add edge (slackx[y], y) to the tree if //and only if !T[y] && slack[y] == 0, also with this edge we add another one //(y, yx[y]) or augment the matching, if y was exposed if (!T[y] && slack[y] == 0) { if (yx[y] == MINUS_ONE) //exposed vertex in Y found - augmenting path exists! { x = slackx[y]; found = true; } else { T[y] = true; //else just add y to T, if (!S[yx[y]]) { q[wr++] = yx[y]; //add vertex yx[y], which is matched with //y, to the queue add_to_tree(yx[y], slackx[y]); //and add edges (x,y) and (y, //yx[y]) to the tree } ++y; } } else ++y; } } } assert(found); //in this cycle we inverse edges along augmenting path for (size_t cx = x, cy = y, ty; cx != MINUS_TWO; cx = prev[cx], cy = ty) { ty = xy[cx]; yx[cy] = cx; xy[cx] = cy; } } }
void button_undecided_clicked(GtkWidget *widget, gpointer data) { //g_print("clicked undecided\n"); ++votes_amt; update_labels(); }
void ColorWheel::option_changed() { set_needs_render(); update_labels(); }
void augment(const double cost[N][N]) //main function of the algorithm { if (max_match == n) return; //check wether matching is already perfect int x, y, root = 0; //just counters and root vertex int q[N], wr = 0, rd = 0; //q - queue for bfs, wr,rd - write and read //pos in queue memset(S, false, sizeof(S)); //init set S memset(T, false, sizeof(T)); //init set T memset(prev, -1, sizeof(prev)); //init set prev - for the alternating tree for (x = 0; x < n; x++) //finding root of the tree if (xy[x] == -1) { q[wr++] = root = x; prev[x] = -2; S[x] = true; break; } for (y = 0; y < n; y++) //initializing slack array { slack[y] = lx[root] + ly[y] - cost[root][y]; slackx[y] = root; } while (true) //main cycle { while (rd < wr) //building tree with bfs cycle { x = q[rd++]; //current vertex from X part for (y = 0; y < n; y++) //iterate through all edges in equality graph if (cost[x][y] == lx[x] + ly[y] && !T[y]) { if (yx[y] == -1) break; //an exposed vertex in Y found, so //augmenting path exists! T[y] = true; //else just add y to T, q[wr++] = yx[y]; //add vertex yx[y], which is matched //with y, to the queue add_to_tree(yx[y], x, cost); //add edges (x,y) and (y,yx[y]) to the tree } if (y < n) break; //augmenting path found! } if (y < n) break; //augmenting path found! update_labels(); //augmenting path not found, so improve labeling wr = rd = 0; for (y = 0; y < n; y++) //in this cycle we add edges that were added to the equality graph as a //result of improving the labeling, we add edge (slackx[y], y) to the tree if //and only if !T[y] && slack[y] == 0, also with this edge we add another one //(y, yx[y]) or augment the matching, if y was exposed if (!T[y] && slack[y] == 0) { if (yx[y] == -1) //exposed vertex in Y found - augmenting path exists! { x = slackx[y]; break; } else { T[y] = true; //else just add y to T, if (!S[yx[y]]) { q[wr++] = yx[y]; //add vertex yx[y], which is matched with //y, to the queue add_to_tree(yx[y], slackx[y],cost); //and add edges (x,y) and (y, //yx[y]) to the tree } } } if (y < n) break; //augmenting path found! } if (y < n) //we found augmenting path! { max_match++; //increment matching //in this cycle we inverse edges along augmenting path for (int cx = x, cy = y, ty; cx != -2; cx = prev[cx], cy = ty) { ty = xy[cx]; yx[cy] = cx; xy[cx] = cy; } augment(cost); //recall function, go to step 1 of the algorithm } }//end of augment() function
int vect_to_rast(const char *vector_map, const char *raster_map, const char *field_name, const char *column, int cache_mb, int use, double value, int value_type, const char *rgbcolumn, const char *labelcolumn, int ftype, char *where, char *cats, int dense) { struct Map_info Map; struct line_pnts *Points; int i, field; struct cat_list *cat_list = NULL; int fd; /* for raster map */ int nareas, nlines; /* number of converted features */ int nareas_all, nplines_all; /* number of all areas, points/lines */ int stat; int format; int pass, npasses; /* Attributes */ int nrec; int ctype = 0; struct field_info *Fi; dbDriver *Driver; dbCatValArray cvarr; int is_fp = 0; nareas = 0; G_verbose_message(_("Loading data...")); Vect_set_open_level(2); if (Vect_open_old2(&Map, vector_map, "", field_name) < 0) G_fatal_error(_("Unable to open vector map <%s>"), vector_map); field = Vect_get_field_number(&Map, field_name); if (field > 0) cat_list = Vect_cats_set_constraint(&Map, field, where, cats); if ((use == USE_Z) && !(Vect_is_3d(&Map))) G_fatal_error(_("Vector map <%s> is not 3D"), Vect_get_full_name(&Map)); switch (use) { case USE_ATTR: db_CatValArray_init(&cvarr); if (!(Fi = Vect_get_field(&Map, field))) G_fatal_error(_("Database connection not defined for layer <%s>"), field_name); if ((Driver = db_start_driver_open_database(Fi->driver, Fi->database)) == NULL) G_fatal_error(_("Unable to open database <%s> by driver <%s>"), Fi->database, Fi->driver); db_set_error_handler_driver(Driver); /* Note do not check if the column exists in the table because it may be expression */ if ((nrec = db_select_CatValArray(Driver, Fi->table, Fi->key, column, NULL, &cvarr)) == -1) G_fatal_error(_("Column <%s> not found"), column); G_debug(3, "nrec = %d", nrec); ctype = cvarr.ctype; if (ctype != DB_C_TYPE_INT && ctype != DB_C_TYPE_DOUBLE) G_fatal_error(_("Column type (%s) not supported (did you mean 'labelcolumn'?)"), db_sqltype_name(ctype)); if (nrec < 0) G_fatal_error(_("No records selected from table <%s>"), Fi->table); G_debug(1, "%d records selected from table", nrec); db_close_database_shutdown_driver(Driver); for (i = 0; i < cvarr.n_values; i++) { if (ctype == DB_C_TYPE_INT) { G_debug(3, "cat = %d val = %d", cvarr.value[i].cat, cvarr.value[i].val.i); } else if (ctype == DB_C_TYPE_DOUBLE) { G_debug(3, "cat = %d val = %f", cvarr.value[i].cat, cvarr.value[i].val.d); } } switch (ctype) { case DB_C_TYPE_INT: format = CELL_TYPE; break; case DB_C_TYPE_DOUBLE: format = DCELL_TYPE; break; default: G_fatal_error(_("Unable to use column <%s>"), column); break; } break; case USE_CAT: format = CELL_TYPE; break; case USE_VAL: format = value_type; break; case USE_Z: format = DCELL_TYPE; is_fp = 1; break; case USE_D: format = DCELL_TYPE; break; default: G_fatal_error(_("Unknown use type: %d"), use); } fd = Rast_open_new(raster_map, format); Points = Vect_new_line_struct(); if (use != USE_Z && use != USE_D && (ftype & GV_AREA)) { if ((nareas = sort_areas(&Map, Points, field, cat_list)) == 0) G_warning(_("No areas selected from vector map <%s>"), vector_map); G_debug(1, "%d areas sorted", nareas); } if (nareas > 0 && dense) { G_warning(_("Area conversion and line densification are mutually exclusive, disabling line densification.")); dense = 0; } nlines = Vect_get_num_primitives(&Map, ftype); nplines_all = nlines; npasses = begin_rasterization(cache_mb, format, dense); pass = 0; nareas_all = Vect_get_num_areas(&Map); do { pass++; if (npasses > 1) G_message(_("Pass %d of %d:"), pass, npasses); stat = 0; if ((use != USE_Z && use != USE_D) && nareas) { if (do_areas (&Map, Points, &cvarr, ctype, use, value, value_type) < 0) { G_warning(_("Problem processing areas from vector map <%s>, continuing..."), vector_map); stat = -1; break; } } if (nlines) { if ((nlines = do_lines(&Map, Points, &cvarr, ctype, field, cat_list, use, value, value_type, ftype, &nplines_all, dense)) < 0) { G_warning(_("Problem processing lines from vector map <%s>, continuing..."), vector_map); stat = -1; break; } } G_important_message(_("Writing raster map...")); stat = output_raster(fd); } while (stat == 0); G_suppress_warnings(0); /* stat: 0 == repeat; 1 == done; -1 == error; */ Vect_destroy_line_struct(Points); if (stat < 0) { Rast_unopen(fd); return 1; } Vect_close(&Map); G_verbose_message(_("Creating support files for raster map...")); Rast_close(fd); update_hist(raster_map, vector_map, Map.head.orig_scale); /* colors */ if (rgbcolumn) { if (use != USE_ATTR && use != USE_CAT) { G_warning(_("Color can be updated from database only if use=attr")); update_colors(raster_map); } else { update_dbcolors(raster_map, vector_map, field, rgbcolumn, is_fp, column); } } else if (use == USE_D) update_fcolors(raster_map); else update_colors(raster_map); update_cats(raster_map); /* labels */ update_labels(raster_map, vector_map, field, labelcolumn, use, value, column); #if 0 /* maximum possible numer of areas: number of centroids * actual number of areas, currently unknown: * number of areas with centroid that are within cat constraint * and overlap with current region */ if (nareas_all > 0) G_message(_("Converted areas: %d of %d"), nareas, Vect_get_num_primitives(&Map, GV_CENTROID)); /* maximum possible numer of lines: number of GV_LINE + GV_POINT * actual number of lines, currently unknown: * number of lines are within cat constraint * and overlap with current region */ if (nlines > 0 && nplines_all > 0) G_message(_("Converted points/lines: %d of %d"), nlines, nplines_all); #endif return 0; }