int editor_track_draw_new_direction_roads () { int k; int count = editor_override_get_count(); if (TrackConfirmedStreet.valid) editor_track_draw_current_new_direction_road(); for (k=0; k<count; k++) { int line_id, square, flags, direction; if (!editor_override_get(k, &line_id, &square, &direction, &flags)) continue; if (flags & ED_LINE_NEW_DIRECTION){ RoadMapPosition from; RoadMapPosition to; int first_shape; int last_shape; RoadMapPen layer_pens[LAYER_PROJ_AREAS]; int i; if (!roadmap_square_set_current(square)) continue; if (line_id >= roadmap_line_count() || line_id < 0) continue; roadmap_line_shapes (line_id, &first_shape, &last_shape); roadmap_line_from (line_id, &from); roadmap_line_to (line_id, &to); if (!roadmap_layer_is_visible (roadmap_line_cfcc(line_id), 0)) continue; if (!roadmap_math_line_is_visible (&from, &to)) continue; for (i = 0; i < LAYER_PROJ_AREAS; i++) { layer_pens[i] = roadmap_layer_get_pen (roadmap_line_cfcc(line_id),1, i); } roadmap_screen_draw_one_line (&from, &to, 0, &from, first_shape, last_shape, NULL, layer_pens, LAYER_PROJ_AREAS, -1, 0, 0, 0); } } return 0; }
int roadmap_layer_visible_lines (int *layers, int size, int pen_type, RoadMapPen *pens) { int i; int j; int count = -1; --size; /* To match our boundary check. */ for (i = 0; RoadMapLineClass[i].name != NULL; ++i) { RoadMapClass *this_class = RoadMapLineClass + i; for (j = 0; j<this_class->count; ++j) { int category = this_class->category[j]; if (!roadmap_layer_is_visible (category, 0)) continue; //if (pen_type >= RoadMapCategory[category].pen_count) continue; if ((pen_type > -1) && (! RoadMapCategory[category].in_use[0][pen_type])) continue; layers[++count] = category; if (pens) { if (pen_type == -1) { int p; for (p=RoadMapMaxUsedPen; p>=0; p--) { if (RoadMapCategory[category].in_use[0][p]) { pens[count] = RoadMapCategory[category].pen[0][p]; break; } } } else { pens[count] = RoadMapCategory[category].pen[0][pen_type]; } } if (count >= size) goto done; } } done: return count + 1; }
int roadmap_layer_visible_roads (int *layers, int size) { int i; int count = -1; --size; /* To match our boundary check. */ for (i = RoadMapRoadClass->count - 1; i >= 0; --i) { int category = RoadMapRoadClass->category[i]; if (roadmap_layer_is_visible (category, 0)) { if (count >= size) break; layers[++count] = category; } } return count + 1; }
void roadmap_layer_adjust (void) { int i; int j; int k; int future_thickness; int thickness; struct roadmap_canvas_category *category; if (last_zoom == roadmap_math_get_zoom()) return; if (!RoadMapCategoryCount) return; last_zoom = roadmap_math_get_zoom(); for (i = RoadMapCategoryCount; i > 0; --i) { category = RoadMapCategory + i; for (k=0; k<LAYER_PROJ_AREAS; k++) { if (roadmap_layer_is_visible(i, k)) { thickness = roadmap_math_thickness (category->thickness, category->declutter, k+1, category->pen_count > 1); if (thickness <= 0) thickness = 1; #ifdef VIEW_MODE_3D_OGL if (roadmap_screen_get_view_mode() == VIEW_MODE_3D) thickness *= 2; #endif if (thickness > 40) thickness = 40; #if !defined (OPENGL) && !defined (J2ME) if (roadmap_screen_fast_refresh()) { if (thickness && (thickness <= 4)) thickness = 1; #elif defined(J2ME) if (thickness && (thickness <= 4)) { thickness = 1; } else #endif { /* As a matter of taste, I do dislike roads with a filler * of 1 pixel. Lets force at least a filler of 2. */ future_thickness = thickness; for (j = 1; j < category->pen_count; ++j) { if (category->delta_thickness[j] > 0) break; future_thickness = category->thickness + category->delta_thickness[j]; if (future_thickness == 1) { thickness += 1; } } } #if !defined (OPENGL) && !defined (J2ME) } #endif if (k == 0) { roadmap_plugin_adjust_layer (i, thickness, category->pen_count); } if (thickness > 0) { roadmap_canvas_select_pen (category->pen[k][0]); roadmap_canvas_set_thickness (thickness); } category->in_use[k][0] = 1; for (j = 1; j < category->pen_count; ++j) { /* The previous thickness was already the minimum: * the pens that follow should not be used. */ if (thickness <= 1) { category->in_use[k][j] = 0; continue; } if (category->delta_thickness[j] < 0) { thickness += category->delta_thickness[j]; #ifdef VIEW_MODE_3D_OGL if (roadmap_screen_get_view_mode() == VIEW_MODE_3D/* && !roadmap_screen_fast_refresh()*/) thickness += category->delta_thickness[j]*2; //increase the delta #endif } else { /* Don't end with a road mostly drawn with the latter * pen. */ if ((category->delta_thickness[j] >= thickness / 2) && (j != 2)) { category->in_use[k][j] = 0; thickness = 1; continue; } thickness = category->delta_thickness[j]; } /* If this pen is not visible, there is no reason * to draw it. */ if (thickness < 1) { category->in_use[k][j] = 0; continue; } roadmap_canvas_select_pen (category->pen[k][j]); roadmap_canvas_set_thickness (thickness); category->in_use[k][j] = 1; } } } } }
static void RealtimeTrafficInfoScreenRepaint (int max_pen) { int i; int iNumLines; int width = TRAFFIC_PEN_WIDTH; int previous_with = -1; int previous_type = -1; if (!isDisplayingTrafficInfoOn()) return; if (RTTrafficInfo_IsEmpty()) return; iNumLines = RTTrafficInfo_GetNumLines(); for (i=0; i<iNumLines; i++) { RTTrafficInfoLines *pTrafficLine = RTTrafficInfo_GetLine(i); RoadMapGuiPoint seg_middle; RoadMapPen previous_pen; RoadMapPen layer_pen; roadmap_square_set_current(pTrafficLine->pluginLine.square); if (!roadmap_layer_is_visible (pTrafficLine->pluginLine.cfcc, 0)) continue; if (!roadmap_math_line_is_visible (&pTrafficLine->positionFrom, &pTrafficLine->positionTo)) continue; layer_pen = roadmap_layer_get_pen (pTrafficLine->pluginLine.cfcc, 0, 0); if (layer_pen) width = roadmap_canvas_get_thickness (layer_pen)+1; else width = TRAFFIC_PEN_WIDTH; if (width < TRAFFIC_PEN_WIDTH) { width = TRAFFIC_PEN_WIDTH; } previous_pen = roadmap_canvas_select_pen (pens[pTrafficLine->iType]); roadmap_canvas_set_thickness (width); if (previous_pen) { roadmap_canvas_select_pen (previous_pen); } if ((width != previous_with) || (previous_type != pTrafficLine->iType)) roadmap_screen_draw_flush(); previous_with = width; previous_type = pTrafficLine->iType; roadmap_screen_draw_one_line (&pTrafficLine->positionFrom, &pTrafficLine->positionTo, 0, &pTrafficLine->positionFrom, pTrafficLine->iFirstShape, pTrafficLine->iLastShape, roadmap_shape_get_position, &pens[pTrafficLine->iType], 1, -1, NULL, &seg_middle, NULL); if (width >= 4){ static const char *direction_colors[3] = {"#fd9f0b", "#FFF380", "#FFFFFF"}; roadmap_screen_draw_line_direction (&pTrafficLine->positionFrom, &pTrafficLine->positionTo, &pTrafficLine->positionFrom, pTrafficLine->iFirstShape, pTrafficLine->iLastShape, roadmap_shape_get_position, width, pTrafficLine->iDirection, direction_colors[pTrafficLine->iType]); } } }