… | |
… | |
80 | //# Authors: Martin Schaller (04/2008) |
80 | //# Authors: Martin Schaller (04/2008) |
81 | //############################################################################################################## |
81 | //############################################################################################################## |
82 | |
82 | |
83 | // above what "order" level to show only prerendered map |
83 | // above what "order" level to show only prerendered map |
84 | #define ORDER_USE_PRERENDERED_MAP 0 |
84 | #define ORDER_USE_PRERENDERED_MAP 0 |
|
|
85 | // minimun (line legth * 32) squared (in pixel) to show text label |
|
|
86 | #define MIN_LINE_LENGTH_FOR_TEXT_2 409600 |
|
|
87 | // minimun (line legth * 32) squared (in pixel) to show text label -> for middle segments of streets |
|
|
88 | #define MIN_LINE_LENGTH_FOR_TEXT_MIDDLE_2 1638400 |
|
|
89 | |
|
|
90 | #define ORDER_LEVEL_FOR_STREET_SIMPLIFY 9 |
|
|
91 | #define STREET_SIMPLIFY 24 |
85 | |
92 | |
86 | struct graphics |
93 | struct graphics |
87 | { |
94 | { |
88 | struct graphics_priv *priv; |
95 | struct graphics_priv *priv; |
89 | struct graphics_methods meth; |
96 | struct graphics_methods meth; |
… | |
… | |
175 | |
182 | |
176 | static void clear_hash(struct displaylist *dl) |
183 | static void clear_hash(struct displaylist *dl) |
177 | { |
184 | { |
178 | int i; |
185 | int i; |
179 | for (i = 0; i < HASH_SIZE_GRAPHICS_; i++) |
186 | for (i = 0; i < HASH_SIZE_GRAPHICS_; i++) |
|
|
187 | { |
180 | dl->hash_entries[i].type = type_none; |
188 | dl->hash_entries[i].type = type_none; |
|
|
189 | } |
181 | } |
190 | } |
182 | |
191 | |
183 | static struct hash_entry * |
192 | static struct hash_entry * |
184 | get_hash_entry(struct displaylist *dl, enum item_type type) |
193 | get_hash_entry(struct displaylist *dl, enum item_type type) |
185 | { |
194 | { |
… | |
… | |
195 | { |
204 | { |
196 | return &dl->hash_entries[hashidx]; |
205 | return &dl->hash_entries[hashidx]; |
197 | } |
206 | } |
198 | hashidx = (hashidx + 1) & (HASH_SIZE_GRAPHICS_ - 1); |
207 | hashidx = (hashidx + 1) & (HASH_SIZE_GRAPHICS_ - 1); |
199 | } |
208 | } |
200 | |
|
|
201 | while (offset-- > 0); |
209 | while (offset-- > 0); |
202 | |
210 | |
203 | return NULL; |
211 | return NULL; |
204 | } |
212 | } |
205 | |
213 | |
… | |
… | |
970 | if (label && label_count) |
978 | if (label && label_count) |
971 | { |
979 | { |
972 | for (i = 0; i < label_count; i++) |
980 | for (i = 0; i < label_count; i++) |
973 | { |
981 | { |
974 | if (label[i]) |
982 | if (label[i]) |
|
|
983 | { |
975 | len += strlen(label[i]) + 1; |
984 | len += strlen(label[i]) + 1; |
|
|
985 | } |
976 | else |
986 | else |
|
|
987 | { |
977 | len++; |
988 | len++; |
|
|
989 | } |
978 | } |
990 | } |
979 | } |
991 | } |
980 | p = g_malloc(len); |
992 | p = g_malloc(len); |
|
|
993 | // dbg(0,"malloc len:%d\n", len); |
981 | |
994 | |
982 | di = (struct displayitem *) p; |
995 | di = (struct displayitem *) p; |
983 | p += sizeof(*di) + count * sizeof(*c); |
996 | p += sizeof(*di) + count * sizeof(*c); |
984 | di->item = *item; |
997 | di->item = *item; |
985 | if (label && label_count) |
998 | if (label && label_count) |
… | |
… | |
991 | { |
1004 | { |
992 | strcpy(p, label[i]); |
1005 | strcpy(p, label[i]); |
993 | p += strlen(label[i]) + 1; |
1006 | p += strlen(label[i]) + 1; |
994 | } |
1007 | } |
995 | else |
1008 | else |
|
|
1009 | { |
996 | *p++ = '\0'; |
1010 | *p++ = '\0'; |
|
|
1011 | } |
997 | } |
1012 | } |
998 | } |
1013 | } |
999 | else |
1014 | else |
1000 | { |
1015 | { |
1001 | di->label = NULL; |
1016 | di->label = NULL; |
… | |
… | |
1014 | */ |
1029 | */ |
1015 | static void label_line(struct graphics *gra, struct graphics_gc *fg, struct graphics_gc *bg, struct graphics_font *font, struct point *p, int count, char *label) |
1030 | static void label_line(struct graphics *gra, struct graphics_gc *fg, struct graphics_gc *bg, struct graphics_font *font, struct point *p, int count, char *label) |
1016 | { |
1031 | { |
1017 | int i, x, y, tl, tlm, th, thm, tlsq, l; |
1032 | int i, x, y, tl, tlm, th, thm, tlsq, l; |
1018 | float lsq; |
1033 | float lsq; |
1019 | double dx, dy; |
1034 | // double dx, dy; |
|
|
1035 | float dx, dy; |
1020 | struct point p_t; |
1036 | struct point p_t; |
1021 | struct point pb[5]; |
1037 | struct point pb[5]; |
1022 | |
1038 | |
1023 | if (gra->meth.get_text_bbox) |
1039 | if (gra->meth.get_text_bbox) |
1024 | { |
1040 | { |
1025 | gra->meth.get_text_bbox(gra->priv, font->priv, label, 0x10000, 0x0, pb, 1); |
1041 | gra->meth.get_text_bbox(gra->priv, font->priv, label, 0x10000, 0x0, pb, 1); |
|
|
1042 | // tl -> text length |
1026 | tl = (pb[2].x - pb[0].x); |
1043 | tl = (pb[2].x - pb[0].x); |
|
|
1044 | // th -> text height |
1027 | th = (pb[0].y - pb[1].y); |
1045 | th = (pb[0].y - pb[1].y); |
1028 | } |
1046 | } |
1029 | else |
1047 | else |
1030 | { |
1048 | { |
|
|
1049 | // tl -> text length |
1031 | tl = strlen(label) * 4; |
1050 | tl = strlen(label) * 4; |
|
|
1051 | // th -> text height |
1032 | th = 8; |
1052 | th = 8; |
1033 | } |
1053 | } |
1034 | tlm = tl * 32; |
1054 | tlm = tl * 32; |
1035 | thm = th * 36; |
1055 | thm = th * 36; |
|
|
1056 | // tlsq -> (text length * 32) squared |
1036 | tlsq = tlm * tlm; |
1057 | tlsq = tlm * tlm; |
1037 | for (i = 0; i < count - 1; i++) |
1058 | for (i = 0; i < count - 1; i++) |
1038 | { |
1059 | { |
1039 | dx = p[i + 1].x - p[i].x; |
1060 | dx = p[i + 1].x - p[i].x; |
1040 | dx *= 32; |
1061 | dx *= 32; |
1041 | dy = p[i + 1].y - p[i].y; |
1062 | dy = p[i + 1].y - p[i].y; |
1042 | dy *= 32; |
1063 | dy *= 32; |
|
|
1064 | // lsq -> (line length * 32) squared |
1043 | lsq = dx * dx + dy * dy; |
1065 | lsq = dx * dx + dy * dy; |
1044 | if (lsq > tlsq) |
1066 | if (lsq > tlsq) |
1045 | { |
1067 | { |
|
|
1068 | if (((int)lsq > MIN_LINE_LENGTH_FOR_TEXT_MIDDLE_2) || ( ( (i==0)||(i==(count-2)) && ((int)lsq > (int)MIN_LINE_LENGTH_FOR_TEXT_2) ) )) |
|
|
1069 | { |
|
|
1070 | // segments in the middle of the "way" need to be longer for streetname to be drawn |
|
|
1071 | // l -> line length |
1046 | l = (int) sqrtf(lsq); |
1072 | l = (int) sqrtf_fast2(lsq); |
1047 | x = p[i].x; |
1073 | x = p[i].x; |
1048 | y = p[i].y; |
1074 | y = p[i].y; |
1049 | if (dx < 0) |
1075 | if (dx < 0) |
1050 | { |
1076 | { |
1051 | dx = -dx; |
1077 | dx = -dx; |
1052 | dy = -dy; |
1078 | dy = -dy; |
1053 | x = p[i + 1].x; |
1079 | x = p[i + 1].x; |
1054 | y = p[i + 1].y; |
1080 | y = p[i + 1].y; |
1055 | } |
1081 | } |
1056 | x += (l - tlm) * dx / l / 64; |
1082 | x += (l - tlm) * dx / l / 64; |
1057 | y += (l - tlm) * dy / l / 64; |
1083 | y += (l - tlm) * dy / l / 64; |
1058 | x -= dy * thm / l / 64; |
1084 | x -= dy * thm / l / 64; |
1059 | y += dx * thm / l / 64; |
1085 | y += dx * thm / l / 64; |
1060 | p_t.x = x; |
1086 | p_t.x = x; |
1061 | p_t.y = y; |
1087 | p_t.y = y; |
1062 | #if 0 |
1088 | #if 0 |
1063 | //DBG dbg(0,"display_text: '%s', %d, %d, %d, %d %d\n", label, x, y, dx*0x10000/l, dy*0x10000/l, l); |
1089 | //DBG dbg(0,"display_text: '%s', %d, %d, %d, %d %d\n", label, x, y, dx*0x10000/l, dy*0x10000/l, l); |
1064 | #endif |
1090 | #endif |
1065 | if (x < gra->r.rl.x && x + tl > gra->r.lu.x && y + tl > gra->r.lu.y && y - tl < gra->r.rl.y) |
1091 | if (x < gra->r.rl.x && x + tl > gra->r.lu.x && y + tl > gra->r.lu.y && y - tl < gra->r.rl.y) |
|
|
1092 | { |
1066 | gra->meth.draw_text(gra->priv, fg->priv, bg ? bg->priv : NULL, font->priv, label, &p_t, dx * 0x10000 / l, dy * 0x10000 / l); |
1093 | gra->meth.draw_text(gra->priv, fg->priv, bg ? bg->priv : NULL, font->priv, label, &p_t, dx * 0x10000 / l, dy * 0x10000 / l); |
|
|
1094 | } |
|
|
1095 | } |
1067 | } |
1096 | } |
1068 | } |
1097 | } |
1069 | } |
1098 | } |
1070 | |
1099 | |
1071 | static void display_draw_arrow(struct point *p, int dx, int dy, int l, struct graphics_gc *gc, struct graphics *gra) |
1100 | static void display_draw_arrow(struct point *p, int dx, int dy, int l, struct graphics_gc *gc, struct graphics *gra) |
… | |
… | |
1375 | res->ny = -(y + 1) / 2; |
1404 | res->ny = -(y + 1) / 2; |
1376 | res->py = y / 2; |
1405 | res->py = y / 2; |
1377 | } |
1406 | } |
1378 | } |
1407 | } |
1379 | |
1408 | |
|
|
1409 | |
|
|
1410 | // this func. is not obsolete!! and unused!!!! |
|
|
1411 | // this func. is not obsolete!! and unused!!!! |
|
|
1412 | // this func. is not obsolete!! and unused!!!! |
1380 | static void graphics_draw_polyline_as_polygon(struct graphics *gra, struct graphics_gc *gc, struct point *pnt, int count, int *width, int step, int fill, int order, int oneway) |
1413 | static void graphics_draw_polyline_as_polygon(struct graphics *gra, struct graphics_gc *gc, struct point *pnt, int count, int *width, int step, int fill, int order, int oneway) |
1381 | { |
1414 | { |
1382 | int maxpoints = 200; |
1415 | int maxpoints = 200; |
1383 | struct point *res = g_alloca(sizeof(struct point) * maxpoints); |
1416 | struct point *res = g_alloca(sizeof(struct point) * maxpoints); |
1384 | struct point pos, poso, neg, nego; |
1417 | struct point pos, poso, neg, nego; |
… | |
… | |
1539 | dxo = -dx; |
1572 | dxo = -dx; |
1540 | dyo = -dy; |
1573 | dyo = -dy; |
1541 | fowo = fow; |
1574 | fowo = fow; |
1542 | } |
1575 | } |
1543 | } |
1576 | } |
|
|
1577 | // this func. is not obsolete!! and unused!!!! |
|
|
1578 | // this func. is not obsolete!! and unused!!!! |
|
|
1579 | // this func. is not obsolete!! and unused!!!! |
|
|
1580 | |
|
|
1581 | |
1544 | |
1582 | |
1545 | struct wpoint |
1583 | struct wpoint |
1546 | { |
1584 | { |
1547 | int x, y, w; |
1585 | int x, y, w; |
1548 | }; |
1586 | }; |
… | |
… | |
1557 | if (p->y < r->lu.y) |
1595 | if (p->y < r->lu.y) |
1558 | code |= 4; |
1596 | code |= 4; |
1559 | if (p->y > r->rl.y) |
1597 | if (p->y > r->rl.y) |
1560 | code |= 8; |
1598 | code |= 8; |
1561 | return code; |
1599 | return code; |
|
|
1600 | } |
|
|
1601 | |
|
|
1602 | #define DONT_INTERSECT 0 |
|
|
1603 | #define DO_INTERSECT 1 |
|
|
1604 | #define COLLINEAR 2 |
|
|
1605 | #define SAME_SIGNS( a, b ) \ |
|
|
1606 | (((long) ((unsigned long) a ^ (unsigned long) b)) >= 0 ) |
|
|
1607 | |
|
|
1608 | static int lines_intersect(int x1, int y1, /* First line segment */ |
|
|
1609 | int x2, int y2, |
|
|
1610 | |
|
|
1611 | int x3, int y3, /* Second line segment */ |
|
|
1612 | int x4, int y4, |
|
|
1613 | |
|
|
1614 | int *x, |
|
|
1615 | int *y /* Output value: |
|
|
1616 | * point of intersection */ |
|
|
1617 | ) |
|
|
1618 | { |
|
|
1619 | int a1, a2, b1, b2, c1, c2; /* Coefficients of line eqns. */ |
|
|
1620 | int r1, r2, r3, r4; /* 'Sign' values */ |
|
|
1621 | int denom, offset, num; /* Intermediate values */ |
|
|
1622 | |
|
|
1623 | /* Compute a1, b1, c1, where line joining points 1 and 2 |
|
|
1624 | * is "a1 x + b1 y + c1 = 0". |
|
|
1625 | */ |
|
|
1626 | |
|
|
1627 | a1 = y2 - y1; |
|
|
1628 | b1 = x1 - x2; |
|
|
1629 | c1 = x2 * y1 - x1 * y2; |
|
|
1630 | |
|
|
1631 | /* Compute r3 and r4. |
|
|
1632 | */ |
|
|
1633 | r3 = a1 * x3 + b1 * y3 + c1; |
|
|
1634 | r4 = a1 * x4 + b1 * y4 + c1; |
|
|
1635 | |
|
|
1636 | /* Check signs of r3 and r4. If both point 3 and point 4 lie on |
|
|
1637 | * same side of line 1, the line segments do not intersect. |
|
|
1638 | */ |
|
|
1639 | if ( r3 != 0 && |
|
|
1640 | r4 != 0 && |
|
|
1641 | SAME_SIGNS( r3, r4 )) |
|
|
1642 | { |
|
|
1643 | return ( DONT_INTERSECT ); |
|
|
1644 | } |
|
|
1645 | |
|
|
1646 | /* Compute a2, b2, c2 */ |
|
|
1647 | a2 = y4 - y3; |
|
|
1648 | b2 = x3 - x4; |
|
|
1649 | c2 = x4 * y3 - x3 * y4; |
|
|
1650 | |
|
|
1651 | /* Compute r1 and r2 */ |
|
|
1652 | r1 = a2 * x1 + b2 * y1 + c2; |
|
|
1653 | r2 = a2 * x2 + b2 * y2 + c2; |
|
|
1654 | |
|
|
1655 | /* Check signs of r1 and r2. If both point 1 and point 2 lie |
|
|
1656 | * on same side of second line segment, the line segments do |
|
|
1657 | * not intersect. |
|
|
1658 | */ |
|
|
1659 | if ( r1 != 0 && |
|
|
1660 | r2 != 0 && |
|
|
1661 | SAME_SIGNS( r1, r2 )) |
|
|
1662 | { |
|
|
1663 | return ( DONT_INTERSECT ); |
|
|
1664 | } |
|
|
1665 | |
|
|
1666 | /* Line segments intersect: compute intersection point. |
|
|
1667 | */ |
|
|
1668 | |
|
|
1669 | denom = a1 * b2 - a2 * b1; |
|
|
1670 | if ( denom == 0 ) |
|
|
1671 | { |
|
|
1672 | return ( COLLINEAR ); |
|
|
1673 | } |
|
|
1674 | offset = denom < 0 ? - denom / 2 : denom / 2; |
|
|
1675 | |
|
|
1676 | /* The denom/2 is to get rounding instead of truncating. It |
|
|
1677 | * is added or subtracted to the numerator, depending upon the |
|
|
1678 | * sign of the numerator. |
|
|
1679 | */ |
|
|
1680 | /* |
|
|
1681 | num = b1 * c2 - b2 * c1; |
|
|
1682 | *x = ( num < 0 ? num - offset : num + offset ) / denom; |
|
|
1683 | num = a2 * c1 - a1 * c2; |
|
|
1684 | *y = ( num < 0 ? num - offset : num + offset ) / denom; |
|
|
1685 | */ |
|
|
1686 | |
|
|
1687 | return ( DO_INTERSECT ); |
|
|
1688 | } /* lines_intersect */ |
|
|
1689 | |
|
|
1690 | |
|
|
1691 | static int clip_line_aprox(struct wpoint *p1, struct wpoint *p2, struct point_rect *r) |
|
|
1692 | { |
|
|
1693 | int code1, code2; |
|
|
1694 | code1 = clipcode(p1, r); |
|
|
1695 | code2 = clipcode(p2, r); |
|
|
1696 | if (code1 & code2) |
|
|
1697 | { |
|
|
1698 | // line completely invisible! |
|
|
1699 | return 0; |
|
|
1700 | } |
|
|
1701 | else if ((code1 == 0)&&(code2 == 0)) |
|
|
1702 | { |
|
|
1703 | // line completely visible! |
|
|
1704 | return 1; |
|
|
1705 | } |
|
|
1706 | else if ((code1 == 0)||(code2 == 0)) |
|
|
1707 | { |
|
|
1708 | // at least 1 point of line is visible |
|
|
1709 | return 2; |
|
|
1710 | } |
|
|
1711 | else |
|
|
1712 | { |
|
|
1713 | int xx; |
|
|
1714 | int yy; |
|
|
1715 | // top |
|
|
1716 | int ret_ = lines_intersect(p1->x,p1->y,p2->x,p2->y,r->lu.x,r->lu.y,r->rl.x,r->lu.y,&xx,&yy); |
|
|
1717 | if (ret_ == DO_INTERSECT) |
|
|
1718 | { |
|
|
1719 | return 3; |
|
|
1720 | } |
|
|
1721 | // bottom |
|
|
1722 | ret_ = lines_intersect(p1->x,p1->y,p2->x,p2->y,r->lu.x,r->rl.y,r->rl.x,r->rl.y,&xx,&yy); |
|
|
1723 | if (ret_ == DO_INTERSECT) |
|
|
1724 | { |
|
|
1725 | return 3; |
|
|
1726 | } |
|
|
1727 | // left |
|
|
1728 | ret_ = lines_intersect(p1->x,p1->y,p2->x,p2->y,r->lu.x,r->lu.y,r->lu.x,r->rl.y,&xx,&yy); |
|
|
1729 | if (ret_ == DO_INTERSECT) |
|
|
1730 | { |
|
|
1731 | return 3; |
|
|
1732 | } |
|
|
1733 | // right |
|
|
1734 | ret_ = lines_intersect(p1->x,p1->y,p2->x,p2->y,r->rl.x,r->lu.y,r->rl.x,r->rl.y,&xx,&yy); |
|
|
1735 | if (ret_ == DO_INTERSECT) |
|
|
1736 | { |
|
|
1737 | return 3; |
|
|
1738 | } |
|
|
1739 | } |
|
|
1740 | // not visible |
|
|
1741 | return 0; |
1562 | } |
1742 | } |
1563 | |
1743 | |
1564 | static int clip_line(struct wpoint *p1, struct wpoint *p2, struct point_rect *r) |
1744 | static int clip_line(struct wpoint *p1, struct wpoint *p2, struct point_rect *r) |
1565 | { |
1745 | { |
1566 | int code1, code2, ret = 1; |
1746 | int code1, code2, ret = 1; |
… | |
… | |
1575 | dy = p2->y - p1->y; |
1755 | dy = p2->y - p1->y; |
1576 | dw = p2->w - p1->w; |
1756 | dw = p2->w - p1->w; |
1577 | while (code1 || code2) |
1757 | while (code1 || code2) |
1578 | { |
1758 | { |
1579 | if (code1 & code2) |
1759 | if (code1 & code2) |
|
|
1760 | { |
1580 | return 0; |
1761 | return 0; |
|
|
1762 | } |
1581 | if (code1 & 1) |
1763 | if (code1 & 1) |
1582 | { |
1764 | { |
1583 | p1->y += (r->lu.x - p1->x) * dy / dx; |
1765 | p1->y += (r->lu.x - p1->x) * dy / dx; |
1584 | p1->w += (r->lu.x - p1->x) * dw / dx; |
1766 | p1->w += (r->lu.x - p1->x) * dw / dx; |
1585 | p1->x = r->lu.x; |
1767 | p1->x = r->lu.x; |
… | |
… | |
1632 | code2 = clipcode(p2, r); |
1814 | code2 = clipcode(p2, r); |
1633 | } |
1815 | } |
1634 | return ret; |
1816 | return ret; |
1635 | } |
1817 | } |
1636 | |
1818 | |
|
|
1819 | |
1637 | static void graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int step, int poly, int order, int oneway) |
1820 | static void graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int step, int poly, int order, int oneway) |
1638 | { |
1821 | { |
1639 | struct point *p = g_alloca(sizeof(struct point) * (count + 1)); |
1822 | struct point *p = g_alloca(sizeof(struct point) * (count + 1)); |
1640 | int *w = g_alloca(sizeof(int) * (count * step + 1)); |
|
|
1641 | struct wpoint p1, p2; |
1823 | struct wpoint p1, p2; |
1642 | int i, code, out = 0; |
1824 | int i; |
|
|
1825 | int code; |
1643 | int wmax; |
1826 | int wmax; |
|
|
1827 | int out = 0; |
|
|
1828 | const int max_segs = 20; |
1644 | struct point_rect r = gra->r; |
1829 | struct point_rect r = gra->r; |
1645 | |
1830 | |
1646 | wmax = width[0]; |
1831 | // check if whole line is within a 2x2 pixel square |
1647 | if (step) |
1832 | if (order < 11) |
1648 | { |
1833 | { |
|
|
1834 | const int max_dist = 2*2; |
|
|
1835 | int need_draw = 0; |
|
|
1836 | int diff; |
1649 | for (i = 1; i < count; i++) |
1837 | for (i = 0; i < count; i++) |
|
|
1838 | { |
|
|
1839 | if (i > 0) |
1650 | { |
1840 | { |
1651 | if (width[i * step] > wmax) |
1841 | p2.x = pa[i].x; |
1652 | wmax = width[i * step]; |
1842 | p2.y = pa[i].y; |
|
|
1843 | diff = (p2.x - p1.x) * (p2.y - p1.y); |
|
|
1844 | if (diff < 0) |
|
|
1845 | { |
|
|
1846 | diff = -diff; |
|
|
1847 | } |
|
|
1848 | |
|
|
1849 | if (diff > max_dist) |
|
|
1850 | { |
|
|
1851 | // line is bigger, so we need to draw it |
|
|
1852 | need_draw = 1; |
|
|
1853 | break; |
|
|
1854 | } |
1653 | } |
1855 | } |
|
|
1856 | else |
|
|
1857 | { |
|
|
1858 | p1.x = pa[i - 1].x; |
|
|
1859 | p1.y = pa[i - 1].y; |
|
|
1860 | } |
1654 | } |
1861 | } |
1655 | if (wmax <= 0) |
1862 | |
|
|
1863 | if (need_draw == 0) |
1656 | { |
1864 | { |
|
|
1865 | // dont draw this line |
1657 | return; |
1866 | return; |
1658 | } |
1867 | } |
|
|
1868 | } |
|
|
1869 | |
|
|
1870 | // calc visible area on screen |
|
|
1871 | wmax=width[0]; |
1659 | r.lu.x -= wmax; |
1872 | r.lu.x-=wmax; |
1660 | r.lu.y -= wmax; |
1873 | r.lu.y-=wmax; |
1661 | r.rl.x += wmax; |
1874 | r.rl.x+=wmax; |
1662 | r.rl.y += wmax; |
1875 | r.rl.y+=wmax; |
1663 | |
1876 | |
1664 | for (i = 0; i < count; i++) |
1877 | for (i = 0; i < count; i++) |
1665 | { |
1878 | { |
1666 | if (i) |
1879 | if (i > 0) |
1667 | { |
1880 | { |
1668 | p1.x = pa[i - 1].x; |
1881 | p1.x = pa[i - 1].x; |
1669 | p1.y = pa[i - 1].y; |
1882 | p1.y = pa[i - 1].y; |
1670 | p1.w = width[(i - 1) * step]; |
|
|
1671 | p2.x = pa[i].x; |
1883 | p2.x = pa[i].x; |
1672 | p2.y = pa[i].y; |
1884 | p2.y = pa[i].y; |
1673 | p2.w = width[i * step]; |
1885 | /* 0 = invisible, 1 = completely visible, 2,3 = at least part of line visible */ |
1674 | /* 0 = invisible, 1 = completely visible, 3 = start point clipped, 5 = end point clipped, 7 both points clipped */ |
|
|
1675 | code = clip_line(&p1, &p2, &r); |
1886 | code=clip_line_aprox(&p1, &p2, &r); |
1676 | |
1887 | |
1677 | if (((code == 1 || code == 5) && i == 1) || (code & 2)) |
1888 | if (code > 0) |
|
|
1889 | { |
|
|
1890 | if (out == 0) |
1678 | { |
1891 | { |
1679 | p[out].x = p1.x; |
1892 | p[out].x=p1.x; |
1680 | p[out].y = p1.y; |
1893 | p[out].y=p1.y; |
1681 | w[out * step] = p1.w; |
1894 | out++; |
|
|
1895 | } |
|
|
1896 | p[out].x=p2.x; |
|
|
1897 | p[out].y=p2.y; |
1682 | out++; |
1898 | out++; |
1683 | } |
|
|
1684 | |
1899 | |
1685 | if (code) |
1900 | if ((out <= max_segs) && (i < (count - 1))) |
1686 | { |
1901 | { |
1687 | p[out].x = p2.x; |
1902 | // ok gather more line segs |
1688 | p[out].y = p2.y; |
1903 | continue; |
1689 | w[out * step] = p2.w; |
|
|
1690 | out++; |
|
|
1691 | } |
1904 | } |
1692 | |
|
|
1693 | if (i == count - 1 || (code & 4)) |
|
|
1694 | { |
1905 | } |
1695 | if (out > 1) |
1906 | else // (code == 0) |
1696 | { |
1907 | { |
|
|
1908 | if (out == 0) |
|
|
1909 | { |
|
|
1910 | // first visible line seg not yet found, search on ... |
|
|
1911 | continue; |
|
|
1912 | } |
|
|
1913 | } |
|
|
1914 | |
|
|
1915 | // PAINT --- LINE SEGMENTS ------------ |
|
|
1916 | // PAINT --- LINE SEGMENTS ------------ |
|
|
1917 | |
1697 | if ((poly == 1) || (poly == 0)) |
1918 | if ((poly == 1) || (poly == 0)) |
1698 | { |
1919 | { |
1699 | // normal street |
1920 | // normal street |
1700 | //if (1 == 0) |
1921 | //if (1 == 0) |
1701 | //{ |
1922 | //{ |
… | |
… | |
1703 | // graphics_draw_polyline_as_polygon(gra, gc, p, out, w, step, 1, order, 0); |
1924 | // graphics_draw_polyline_as_polygon(gra, gc, p, out, w, step, 1, order, 0); |
1704 | //} |
1925 | //} |
1705 | //else |
1926 | //else |
1706 | //{ |
1927 | //{ |
1707 | // draw as line |
1928 | // draw as line |
1708 | // dbg(0,"w=%d", width[i]); |
|
|
1709 | gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i]); |
1929 | gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i]); |
|
|
1930 | //draw_lines_count_3++; |
1710 | //} |
1931 | //} |
1711 | |
1932 | |
1712 | // one way arrow |
1933 | // one way arrow |
1713 | if (oneway > 0) |
1934 | if ((oneway > 0) && (order > 13)) |
1714 | { |
1935 | { |
1715 | gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, oneway); |
1936 | gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, oneway); |
|
|
1937 | //draw_lines_count_2++; |
1716 | } |
1938 | } |
1717 | } |
1939 | } |
1718 | else if (poly == 2) |
1940 | else if (poly == 2) |
1719 | { |
1941 | { |
1720 | // ******* street is underground ******** |
1942 | // ******* street is underground ******** |
… | |
… | |
1726 | // // draw as polygon --> OLD method |
1948 | // // draw as polygon --> OLD method |
1727 | // graphics_draw_polyline_as_polygon(gra, gc, p, out, w, step, 0, order, 0); |
1949 | // graphics_draw_polyline_as_polygon(gra, gc, p, out, w, step, 0, order, 0); |
1728 | //} |
1950 | //} |
1729 | //else |
1951 | //else |
1730 | //{ |
1952 | //{ |
|
|
1953 | |
1731 | // draw as line |
1954 | // draw as line |
1732 | gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i], 1); |
1955 | gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i], 1); |
|
|
1956 | //draw_lines_count_4++; |
1733 | //} |
1957 | //} |
1734 | |
1958 | |
1735 | // one way arrow |
1959 | // one way arrow |
1736 | if (oneway > 0) |
1960 | if ((oneway > 0) && (order > 13)) |
1737 | { |
1961 | { |
1738 | gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, oneway); |
1962 | gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, oneway); |
|
|
1963 | //draw_lines_count_2++; |
1739 | } |
1964 | } |
1740 | } |
1965 | } |
1741 | else if (poly == 3) |
1966 | else if (poly == 3) |
1742 | { |
1967 | { |
1743 | // ******* street has bridge ******** |
1968 | // ******* street has bridge ******** |
1744 | // ******* street has bridge ******** |
1969 | // ******* street has bridge ******** |
1745 | // ******* street has bridge ******** |
1970 | // ******* street has bridge ******** |
1746 | gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i], 2); |
1971 | gra->meth.draw_lines4(gra->priv, gc->priv, p, out, order, width[i], 2); |
|
|
1972 | //draw_lines_count_4++; |
1747 | |
1973 | |
1748 | // one way arrow |
1974 | // one way arrow |
1749 | if (oneway > 0) |
1975 | if ((oneway > 0) && (order > 13)) |
1750 | { |
1976 | { |
1751 | gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, oneway); |
1977 | gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, oneway); |
|
|
1978 | //draw_lines_count_2++; |
1752 | } |
1979 | } |
1753 | } |
1980 | } |
1754 | // --> now NOT used anymore!! |
1981 | // --> now NOT used anymore!! |
1755 | else // poly==0 -> street that is only a line (width=1) |
1982 | else // poly==0 -> street that is only a line (width=1) |
1756 | { |
1983 | { |
1757 | // OLD // gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, 0); |
1984 | // OLD // gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, 0); |
1758 | |
1985 | |
1759 | gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i]); |
1986 | gra->meth.draw_lines3(gra->priv, gc->priv, p, out, order, width[i]); |
|
|
1987 | //draw_lines_count_3++; |
1760 | |
1988 | |
1761 | // one way arrow |
1989 | // one way arrow |
1762 | if (oneway > 0) |
1990 | if ((oneway > 0) && (order > 13)) |
1763 | { |
1991 | { |
1764 | gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, oneway); |
1992 | gra->meth.draw_lines2(gra->priv, gc->priv, p, out, order, oneway); |
|
|
1993 | //draw_lines_count_2++; |
1765 | } |
1994 | } |
1766 | } |
1995 | } |
1767 | out = 0; |
1996 | |
1768 | } |
1997 | out = 0; // reset point counter after painting |
|
|
1998 | // PAINT --- LINE SEGMENTS ------------ |
|
|
1999 | // PAINT --- LINE SEGMENTS ------------ |
|
|
2000 | // PAINT --- LINE SEGMENTS ------------ |
1769 | } |
2001 | } |
1770 | } |
2002 | } |
1771 | } |
|
|
1772 | } |
2003 | } |
|
|
2004 | |
1773 | |
2005 | |
1774 | static int is_inside(struct point *p, struct point_rect *r, int edge) |
2006 | static int is_inside(struct point *p, struct point_rect *r, int edge) |
1775 | { |
2007 | { |
1776 | switch (edge) |
2008 | switch (edge) |
1777 | { |
2009 | { |
… | |
… | |
1996 | return i + 1; |
2228 | return i + 1; |
1997 | } |
2229 | } |
1998 | return count; |
2230 | return count; |
1999 | } |
2231 | } |
2000 | |
2232 | |
2001 | static void displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc, int order, int allow_dashed) |
2233 | static void displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc, int order, int allow_dashed, int run_type) |
2002 | { |
2234 | { |
2003 | ////DBG dbg(0,"ooo enter ooo\n"); |
2235 | ////DBG dbg(0,"ooo enter ooo\n"); |
2004 | |
2236 | |
2005 | int *width = g_alloca(sizeof(int) * dc->maxlen); |
2237 | int *width = g_alloca(sizeof(int) * dc->maxlen); |
2006 | struct point *pa = g_alloca(sizeof(struct point) * dc->maxlen); |
2238 | struct point *pa = g_alloca(sizeof(struct point) * dc->maxlen); |
… | |
… | |
2009 | struct element *e = dc->e; |
2241 | struct element *e = dc->e; |
2010 | struct graphics_image *img = dc->img; |
2242 | struct graphics_image *img = dc->img; |
2011 | struct point p; |
2243 | struct point p; |
2012 | char *path; |
2244 | char *path; |
2013 | |
2245 | |
2014 | // //DBG dbg(0,"enter\n"); |
2246 | //if (run_type > 100) dbg(0,"enter\n"); |
2015 | |
2247 | |
2016 | while (di) |
2248 | while (di) |
2017 | { |
2249 | { |
|
|
2250 | if (run_type != 99) |
|
|
2251 | { |
|
|
2252 | if (run_type == 1) |
|
|
2253 | { |
|
|
2254 | if (di->item.flags & AF_UNDERGROUND) |
|
|
2255 | { |
|
|
2256 | // next item |
|
|
2257 | di = di->next; |
|
|
2258 | continue; |
|
|
2259 | } |
|
|
2260 | else if (di->item.flags & AF_BRIDGE) |
|
|
2261 | { |
|
|
2262 | // next item |
|
|
2263 | di = di->next; |
|
|
2264 | continue; |
|
|
2265 | } |
|
|
2266 | } |
|
|
2267 | else if (run_type == 2) |
|
|
2268 | { |
|
|
2269 | // tunnel |
|
|
2270 | if (di->item.flags & AF_UNDERGROUND) |
|
|
2271 | { |
|
|
2272 | } |
|
|
2273 | else |
|
|
2274 | { |
|
|
2275 | // next item |
|
|
2276 | di = di->next; |
|
|
2277 | continue; |
|
|
2278 | } |
|
|
2279 | } |
|
|
2280 | else if (run_type == 3) |
|
|
2281 | { |
|
|
2282 | // bridge |
|
|
2283 | if (di->item.flags & AF_BRIDGE) |
|
|
2284 | { |
|
|
2285 | } |
|
|
2286 | else |
|
|
2287 | { |
|
|
2288 | // next item |
|
|
2289 | di = di->next; |
|
|
2290 | continue; |
|
|
2291 | } |
|
|
2292 | } |
|
|
2293 | } |
|
|
2294 | |
2018 | int i, count = di->count, mindist = dc->mindist; |
2295 | int i, count = di->count, mindist = dc->mindist; |
2019 | |
2296 | |
2020 | if (!gc) |
2297 | if (!gc) |
2021 | { |
2298 | { |
2022 | gc = graphics_gc_new(gra); |
2299 | gc = graphics_gc_new(gra); |
… | |
… | |
2030 | } |
2307 | } |
2031 | if (dc->type == type_poly_water_tiled) |
2308 | if (dc->type == type_poly_water_tiled) |
2032 | { |
2309 | { |
2033 | mindist = 0; |
2310 | mindist = 0; |
2034 | } |
2311 | } |
|
|
2312 | if (dc->type == type_border_country) |
|
|
2313 | { |
|
|
2314 | if (order < 10) |
|
|
2315 | { |
|
|
2316 | mindist = 3; |
|
|
2317 | } |
|
|
2318 | } |
2035 | if (dc->e->type == element_polyline) |
2319 | if (dc->e->type == element_polyline) |
2036 | { |
2320 | { |
2037 | count = transform(dc->trans, dc->pro, di->c, pa, count, mindist, e->u.polyline.width, width); |
2321 | count = transform(dc->trans, dc->pro, di->c, pa, count, mindist, e->u.polyline.width, width); |
2038 | } |
2322 | } |
2039 | else |
2323 | else |
2040 | { |
2324 | { |
2041 | count = transform(dc->trans, dc->pro, di->c, pa, count, mindist, 0, NULL); |
2325 | count = transform(dc->trans, dc->pro, di->c, pa, count, mindist, 0, NULL); |
2042 | //struct coord *c9191; |
|
|
2043 | //c9191 = di->c; |
|
|
2044 | //dbg(0,"di->c %i %i pa %d %d \n",c9191->x, c9191->y, pa->x, pa->y); |
|
|
2045 | } |
2326 | } |
2046 | |
2327 | |
2047 | switch (e->type) |
2328 | switch (e->type) |
2048 | { |
2329 | { |
2049 | case element_polygon: |
2330 | case element_polygon: |
… | |
… | |
2076 | { |
2357 | { |
2077 | oneway = 1; |
2358 | oneway = 1; |
2078 | } |
2359 | } |
2079 | |
2360 | |
2080 | // -------- apply dashes ------- |
2361 | // -------- apply dashes ------- |
2081 | //if (e->u.polyline.width > 0 && e->u.polyline.dash_num > 0) |
|
|
2082 | if (e->u.polyline.dash_num > 0) |
2362 | if (e->u.polyline.dash_num > 0) |
2083 | { |
2363 | { |
2084 | graphics_gc_set_dashes(gra, gc, e->u.polyline.width, e->u.polyline.offset, e->u.polyline.dash_table, e->u.polyline.dash_num, order); |
2364 | graphics_gc_set_dashes(gra, gc, e->u.polyline.width, e->u.polyline.offset, e->u.polyline.dash_table, e->u.polyline.dash_num, order); |
2085 | } |
2365 | } |
2086 | // -------- apply dashes ------- |
2366 | // -------- apply dashes ------- |
2087 | |
2367 | |
2088 | for (i = 0; i < count; i++) |
2368 | for (i = 0; i < count; i++) |
2089 | { |
2369 | { |
2090 | if (width[i] < 2) |
2370 | if (width[i] < 1) |
2091 | { |
2371 | { |
2092 | width[i] = 2; |
2372 | width[i] = 1; |
2093 | } |
2373 | } |
2094 | } |
2374 | } |
|
|
2375 | |
|
|
2376 | if (dc->type == type_border_country) |
|
|
2377 | { |
|
|
2378 | graphics_draw_polyline_clipped(gra, gc, pa, count, width, 99, poly, order, oneway); |
|
|
2379 | } |
|
|
2380 | else |
|
|
2381 | { |
2095 | graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway); |
2382 | graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, poly, order, oneway); |
|
|
2383 | // graphics_draw_polyline_clipped(gra, gc, pa, count, width, 99, poly, order, oneway); |
|
|
2384 | } |
2096 | |
2385 | |
2097 | // -------- cancel dashes ------- |
2386 | // -------- cancel dashes ------- |
2098 | if (e->u.polyline.dash_num > 0) |
2387 | if (e->u.polyline.dash_num > 0) |
2099 | { |
2388 | { |
2100 | int dummy_1[1]; |
2389 | int dummy_1[1]; |
2101 | dummy_1[0]=0; |
2390 | dummy_1[0]=0; |
2102 | graphics_gc_set_dashes(gra, gc, e->u.polyline.width, e->u.polyline.offset, dummy_1, e->u.polyline.dash_num, order); |
2391 | graphics_gc_set_dashes(gra, gc, e->u.polyline.width, e->u.polyline.offset, dummy_1, e->u.polyline.dash_num, order); |
2103 | } |
2392 | } |
|
|
2393 | //if (run_type > 100) dbg(0,"gg005\n"); |
2104 | // -------- cancel dashes ------- |
2394 | // -------- cancel dashes ------- |
2105 | } |
2395 | } |
2106 | break; |
2396 | break; |
2107 | case element_circle: |
2397 | case element_circle: |
2108 | if (count) |
2398 | if (count) |
… | |
… | |
2139 | } |
2429 | } |
2140 | break; |
2430 | break; |
2141 | case element_text: |
2431 | case element_text: |
2142 | if (count && di->label) |
2432 | if (count && di->label) |
2143 | { |
2433 | { |
|
|
2434 | //if (run_type > 100) dbg(0,"gg006\n"); |
|
|
2435 | |
2144 | struct graphics_font *font = get_font(gra, e->text_size); |
2436 | struct graphics_font *font = get_font(gra, e->text_size); |
2145 | struct graphics_gc *gc_background = dc->gc_background; |
2437 | struct graphics_gc *gc_background = dc->gc_background; |
2146 | |
2438 | |
2147 | if (!gc_background && e->u.text.background_color.a) |
2439 | if (!gc_background && e->u.text.background_color.a) |
2148 | { |
2440 | { |
… | |
… | |
2192 | { |
2484 | { |
2193 | dc->img = img; |
2485 | dc->img = img; |
2194 | } |
2486 | } |
2195 | else |
2487 | else |
2196 | { |
2488 | { |
2197 | dbg(0, "-- ICON MISSING -- failed to load icon '%s'\n", path); |
2489 | // missing icon // dbg(0, "-- ICON MISSING -- failed to load icon '%s'\n", path); |
2198 | } |
2490 | } |
2199 | g_free(path); |
2491 | g_free(path); |
2200 | } |
2492 | } |
2201 | |
2493 | |
2202 | if (img) |
2494 | if (img) |
… | |
… | |
2225 | printf("Unhandled element type %d\n", e->type); |
2517 | printf("Unhandled element type %d\n", e->type); |
2226 | |
2518 | |
2227 | } |
2519 | } |
2228 | di = di->next; |
2520 | di = di->next; |
2229 | } |
2521 | } |
|
|
2522 | |
|
|
2523 | //if (run_type > 100) dbg(0,"gg099\n"); |
|
|
2524 | |
2230 | } |
2525 | } |
2231 | /** |
2526 | /** |
2232 | * FIXME |
2527 | * FIXME |
2233 | * @param <> |
2528 | * @param <> |
2234 | * @returns <> |
2529 | * @returns <> |
2235 | * @author Martin Schaller (04/2008) |
2530 | * @author Martin Schaller (04/2008) |
2236 | */ |
2531 | */ |
2237 | static void xdisplay_draw_elements(struct graphics *gra, struct displaylist *display_list, struct itemgra *itm) |
2532 | static void xdisplay_draw_elements(struct graphics *gra, struct displaylist *display_list, struct itemgra *itm, int run_type) |
2238 | { |
2533 | { |
2239 | //dbg(0,"Enter\n"); |
2534 | // dbg(0,"Enter\n"); |
2240 | |
2535 | |
2241 | struct element *e; |
2536 | struct element *e; |
2242 | GList *es, *types; |
2537 | GList *es, *types; |
2243 | struct display_context *dc = &display_list->dc; |
2538 | struct display_context *dc = &display_list->dc; |
2244 | struct hash_entry *entry; |
2539 | struct hash_entry *entry; |
|
|
2540 | int draw_it = 1; |
|
|
2541 | |
|
|
2542 | #ifdef NAVIT_MEASURE_TIME_DEBUG |
|
|
2543 | clock_t s_ = debug_measure_start(); |
|
|
2544 | #endif |
2245 | |
2545 | |
2246 | es = itm->elements; |
2546 | es = itm->elements; |
2247 | while (es) |
2547 | while (es) |
2248 | { |
2548 | { |
2249 | //dbg(0,"*es\n"); |
2549 | //dbg(0,"*es\n"); |
2250 | e = es->data; |
2550 | e = es->data; |
2251 | dc->e = e; |
2551 | dc->e = e; |
2252 | types = itm->type; |
2552 | types = itm->type; |
2253 | while (types) |
2553 | while (types) |
2254 | { |
2554 | { |
|
|
2555 | draw_it = 1; |
|
|
2556 | |
2255 | dc->type = GPOINTER_TO_INT(types->data); |
2557 | dc->type = GPOINTER_TO_INT(types->data); |
2256 | // dbg(0,"**type=%d\n", dc->type); |
2558 | //dbg(0,"**type=%d\n", dc->type); |
|
|
2559 | |
|
|
2560 | if (dc->type == type_poly_water_from_relations) |
|
|
2561 | { |
|
|
2562 | // ok "poly_water_from_relations" is found, now what? |
|
|
2563 | if (enable_water_from_relations == 0) |
|
|
2564 | { |
|
|
2565 | draw_it = 0; |
|
|
2566 | } |
|
|
2567 | } |
|
|
2568 | |
|
|
2569 | if (draw_it == 1) |
|
|
2570 | { |
2257 | entry = get_hash_entry(display_list, dc->type); |
2571 | entry = get_hash_entry(display_list, dc->type); |
2258 | if (entry && entry->di) |
2572 | if (entry && entry->di) |
2259 | { |
2573 | { |
2260 | //dbg(0,"++type=%s\n", item_to_name(dc->type)); |
2574 | //dbg(0,"++type=%s\n", item_to_name(dc->type)); |
|
|
2575 | //if (!strcmp(item_to_name(dc->type), "border_country")) |
|
|
2576 | //{ |
2261 | displayitem_draw(entry->di, NULL, dc, display_list->order, 1); |
2577 | // displayitem_draw(entry->di, NULL, dc, display_list->order, 1, 101); |
|
|
2578 | //} |
|
|
2579 | //else |
|
|
2580 | //{ |
|
|
2581 | displayitem_draw(entry->di, NULL, dc, display_list->order, 1, run_type); |
|
|
2582 | //} |
2262 | //dbg(0,"**+gc free\n"); |
2583 | //dbg(0,"**+gc free\n"); |
2263 | display_context_free(dc); |
2584 | display_context_free(dc); |
|
|
2585 | } |
2264 | } |
2586 | } |
2265 | types = g_list_next(types); |
2587 | types = g_list_next(types); |
|
|
2588 | draw_it = 1; |
2266 | } |
2589 | } |
2267 | es = g_list_next(es); |
2590 | es = g_list_next(es); |
2268 | } |
2591 | } |
|
|
2592 | |
|
|
2593 | #ifdef NAVIT_MEASURE_TIME_DEBUG |
|
|
2594 | debug_mrp("xdisplay_draw_elements:", debug_measure_end(s_)); |
|
|
2595 | #endif |
2269 | } |
2596 | } |
2270 | |
2597 | |
2271 | void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label) |
2598 | void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label) |
2272 | { |
2599 | { |
2273 | ////DBG dbg(0,"ooo enter ooo\n"); |
2600 | ////DBG dbg(0,"ooo enter ooo\n"); |
… | |
… | |
2303 | { |
2630 | { |
2304 | //DBG dbg(0, "maximum number of coords reached: %d > %d\n", e->coord_count, max_coord); |
2631 | //DBG dbg(0, "maximum number of coords reached: %d > %d\n", e->coord_count, max_coord); |
2305 | di->count = max_coord; |
2632 | di->count = max_coord; |
2306 | } |
2633 | } |
2307 | else |
2634 | else |
|
|
2635 | { |
2308 | di->count = e->coord_count; |
2636 | di->count = e->coord_count; |
|
|
2637 | } |
2309 | memcpy(di->c, e->coord, di->count * sizeof(struct coord)); |
2638 | memcpy(di->c, e->coord, di->count * sizeof(struct coord)); |
2310 | } |
2639 | } |
2311 | else |
2640 | else |
2312 | { |
2641 | { |
2313 | di->c[0].x = 0; |
2642 | di->c[0].x = 0; |
2314 | di->c[0].y = 0; |
2643 | di->c[0].y = 0; |
2315 | di->count = 1; |
2644 | di->count = 1; |
2316 | } |
2645 | } |
2317 | dc.e = e; |
2646 | dc.e = e; |
2318 | di->next = NULL; |
2647 | di->next = NULL; |
2319 | displayitem_draw(di, NULL, &dc, transform_get_scale(t), 0); |
2648 | displayitem_draw(di, NULL, &dc, transform_get_scale(t), 0, 99); |
2320 | display_context_free(&dc); |
2649 | display_context_free(&dc); |
2321 | es = g_list_next(es); |
2650 | es = g_list_next(es); |
2322 | } |
2651 | } |
2323 | } |
2652 | } |
2324 | |
2653 | |
… | |
… | |
2332 | { |
2661 | { |
2333 | //DBG dbg(0,"ooo enter ooo\n"); |
2662 | //DBG dbg(0,"ooo enter ooo\n"); |
2334 | |
2663 | |
2335 | GList *itms; |
2664 | GList *itms; |
2336 | struct itemgra *itm; |
2665 | struct itemgra *itm; |
|
|
2666 | |
|
|
2667 | int run_type = 0; // 99 -> normal |
|
|
2668 | // 1 -> normal streets (except tunnels and bridges) |
|
|
2669 | // 2 -> tunnel |
|
|
2670 | // 3 -> bridge |
|
|
2671 | |
2337 | int order_corrected = order; |
2672 | int order_corrected = order + shift_order; |
2338 | if (order_corrected < limit_order_corrected) |
2673 | if (order_corrected < limit_order_corrected) |
2339 | { |
2674 | { |
2340 | order_corrected = limit_order_corrected; |
2675 | order_corrected = limit_order_corrected; |
2341 | } |
2676 | } |
|
|
2677 | |
2342 | int order_corrected_2 = order; |
2678 | int order_corrected_2 = order + shift_order; |
2343 | if (order < 0) |
2679 | if (order < 0) |
2344 | { |
2680 | { |
2345 | order_corrected_2 = 0; |
2681 | order_corrected_2 = 0; |
2346 | } |
2682 | } |
2347 | |
2683 | |
2348 | //dbg(0,"layer name=%s\n", lay->name); |
2684 | //dbg(0,"layer name=%s\n", lay->name); |
2349 | |
2685 | |
|
|
2686 | if ((strncmp("streets_1", lay->name, 9) == 0)) |
|
|
2687 | { |
|
|
2688 | //dbg(0,"MT:7.3.1 - tunnel start\n"); |
|
|
2689 | //draw_lines_count_2 = 0; |
|
|
2690 | //draw_lines_count_3 = 0; |
|
|
2691 | //draw_lines_count_4 = 0; |
|
|
2692 | |
|
|
2693 | run_type = 2; |
2350 | itms = lay->itemgras; |
2694 | itms = lay->itemgras; |
2351 | while (itms) |
2695 | while (itms) |
2352 | { |
2696 | { |
2353 | // stop drawing is requested |
2697 | // stop drawing is requested |
2354 | if (cancel_drawing_global == 1) |
2698 | if (cancel_drawing_global == 1) |
2355 | { |
2699 | { |
2356 | //DBG dbg(0, "** STOP MD 002 **\n"); |
2700 | //DBG dbg(0, "** STOP MD 002 **\n"); |
2357 | break; |
2701 | break; |
2358 | } |
2702 | } |
2359 | |
2703 | |
2360 | itm = itms->data; |
2704 | itm = itms->data; |
2361 | //if (order_corrected >= itm->order.min && order_corrected <= itm->order.max) |
2705 | //if (order_corrected >= itm->order.min && order_corrected <= itm->order.max) |
2362 | if (order_corrected_2 >= itm->order.min && order_corrected_2 <= itm->order.max) |
2706 | if (order_corrected_2 >= itm->order.min && order_corrected_2 <= itm->order.max) |
2363 | { |
2707 | { |
2364 | xdisplay_draw_elements(gra, display_list, itm); |
2708 | xdisplay_draw_elements(gra, display_list, itm, run_type); |
2365 | } |
2709 | } |
2366 | itms = g_list_next(itms); |
2710 | itms = g_list_next(itms); |
2367 | } |
2711 | } |
2368 | |
2712 | |
|
|
2713 | //dbg(0,"lines count2=%lld\n", draw_lines_count_2); |
|
|
2714 | //dbg(0,"lines count3=%lld\n", draw_lines_count_3); |
|
|
2715 | //dbg(0,"lines count4=%lld\n", draw_lines_count_4); |
|
|
2716 | //draw_lines_count_2 = 0; |
|
|
2717 | //draw_lines_count_3 = 0; |
|
|
2718 | //draw_lines_count_4 = 0; |
|
|
2719 | //dbg(0,"MT:7.3.2 - streets start\n"); |
|
|
2720 | |
|
|
2721 | run_type = 1; |
|
|
2722 | itms = lay->itemgras; |
|
|
2723 | while (itms) |
|
|
2724 | { |
|
|
2725 | // stop drawing is requested |
|
|
2726 | if (cancel_drawing_global == 1) |
|
|
2727 | { |
|
|
2728 | //DBG dbg(0, "** STOP MD 002 **\n"); |
|
|
2729 | break; |
|
|
2730 | } |
|
|
2731 | |
|
|
2732 | itm = itms->data; |
|
|
2733 | //if (order_corrected >= itm->order.min && order_corrected <= itm->order.max) |
|
|
2734 | if (order_corrected_2 >= itm->order.min && order_corrected_2 <= itm->order.max) |
|
|
2735 | { |
|
|
2736 | xdisplay_draw_elements(gra, display_list, itm, run_type); |
|
|
2737 | } |
|
|
2738 | itms = g_list_next(itms); |
|
|
2739 | } |
|
|
2740 | |
|
|
2741 | /* |
|
|
2742 | dbg(0,"lines count2=%lld\n", draw_lines_count_2); |
|
|
2743 | dbg(0,"lines count3=%lld\n", draw_lines_count_3); |
|
|
2744 | dbg(0,"lines count4=%lld\n", draw_lines_count_4); |
|
|
2745 | draw_lines_count_2 = 0; |
|
|
2746 | draw_lines_count_3 = 0; |
|
|
2747 | draw_lines_count_4 = 0; |
|
|
2748 | dbg(0,"MT:7.3.3 - bridges start\n"); |
|
|
2749 | */ |
|
|
2750 | |
|
|
2751 | run_type = 3; |
|
|
2752 | itms = lay->itemgras; |
|
|
2753 | while (itms) |
|
|
2754 | { |
|
|
2755 | // stop drawing is requested |
|
|
2756 | if (cancel_drawing_global == 1) |
|
|
2757 | { |
|
|
2758 | //DBG dbg(0, "** STOP MD 002 **\n"); |
|
|
2759 | break; |
|
|
2760 | } |
|
|
2761 | |
|
|
2762 | itm = itms->data; |
|
|
2763 | //if (order_corrected >= itm->order.min && order_corrected <= itm->order.max) |
|
|
2764 | if (order_corrected_2 >= itm->order.min && order_corrected_2 <= itm->order.max) |
|
|
2765 | { |
|
|
2766 | xdisplay_draw_elements(gra, display_list, itm, run_type); |
|
|
2767 | } |
|
|
2768 | itms = g_list_next(itms); |
|
|
2769 | } |
|
|
2770 | |
|
|
2771 | /* |
|
|
2772 | dbg(0,"lines count2=%lld\n", draw_lines_count_2); |
|
|
2773 | dbg(0,"lines count3=%lld\n", draw_lines_count_3); |
|
|
2774 | dbg(0,"lines count4=%lld\n", draw_lines_count_4); |
|
|
2775 | draw_lines_count_2 = 0; |
|
|
2776 | draw_lines_count_3 = 0; |
|
|
2777 | draw_lines_count_4 = 0; |
|
|
2778 | dbg(0,"MT:7.3.4 - ready\n"); |
|
|
2779 | */ |
|
|
2780 | |
|
|
2781 | } |
|
|
2782 | else |
|
|
2783 | { |
|
|
2784 | run_type = 99; |
|
|
2785 | itms = lay->itemgras; |
|
|
2786 | while (itms) |
|
|
2787 | { |
|
|
2788 | // stop drawing is requested |
|
|
2789 | if (cancel_drawing_global == 1) |
|
|
2790 | { |
|
|
2791 | //DBG dbg(0, "** STOP MD 002 **\n"); |
|
|
2792 | break; |
|
|
2793 | } |
|
|
2794 | |
|
|
2795 | itm = itms->data; |
|
|
2796 | //if (order_corrected >= itm->order.min && order_corrected <= itm->order.max) |
|
|
2797 | if (order_corrected_2 >= itm->order.min && order_corrected_2 <= itm->order.max) |
|
|
2798 | { |
|
|
2799 | xdisplay_draw_elements(gra, display_list, itm, run_type); |
|
|
2800 | } |
|
|
2801 | itms = g_list_next(itms); |
|
|
2802 | } |
|
|
2803 | } |
|
|
2804 | |
2369 | if (strncmp("streets__tunnel", lay->name, 15) == 0) |
2805 | //if (strncmp("streets__tunnel", lay->name, 15) == 0) |
2370 | { |
2806 | //{ |
2371 | } |
2807 | //} |
2372 | else if (strncmp("streets__bridge", lay->name, 15) == 0) |
2808 | //else if (strncmp("streets__bridge", lay->name, 15) == 0) |
2373 | { |
2809 | //{ |
2374 | } |
2810 | //} |
|
|
2811 | |
2375 | // dirty hack to draw "waypoint(s)" --------------------------- |
2812 | // dirty hack to draw "waypoint(s)" --------------------------- |
2376 | else if (strncmp("Internal", lay->name, 8) == 0) |
2813 | if (strncmp("Internal", lay->name, 8) == 0) |
2377 | { |
2814 | { |
2378 | if (global_navit->route) |
2815 | if (global_navit->route) |
2379 | { |
2816 | { |
2380 | if (global_navit->destination_valid == 1) |
2817 | if (global_navit->destination_valid == 1) |
2381 | { |
2818 | { |
… | |
… | |
2432 | ////DBG dbg(0,"ooo enter ooo\n"); |
2869 | ////DBG dbg(0,"ooo enter ooo\n"); |
2433 | |
2870 | |
2434 | GList *lays; |
2871 | GList *lays; |
2435 | struct layer *lay; |
2872 | struct layer *lay; |
2436 | |
2873 | |
2437 | ////DBG dbg(0,"draw prerender map for drag!!\n"); |
|
|
2438 | |
|
|
2439 | |
|
|
2440 | int draw_vector_map = 1; |
2874 | int draw_vector_map = 1; |
2441 | |
2875 | |
2442 | // if zoomed out too much then use prerendered map tiles |
2876 | // if zoomed out too much then use prerendered map tiles |
2443 | if (display_list->order < ORDER_USE_PRERENDERED_MAP) |
2877 | if (display_list->order < ORDER_USE_PRERENDERED_MAP) |
2444 | { |
2878 | { |
2445 | draw_vector_map = 0; |
2879 | draw_vector_map = 0; |
2446 | } |
2880 | } |
2447 | |
2881 | |
2448 | ////DBG dbg(0,"ooo %d %d %d\n",display_list->order_hashed,ORDER_USE_PRERENDERED_MAP,draw_vector_map); |
|
|
2449 | ////DBG dbg(0,"ooo xxx ooo2\n"); |
|
|
2450 | |
|
|
2451 | if (!draw_vector_map) |
2882 | if (!draw_vector_map) |
2452 | { |
2883 | { |
2453 | // draw prerendered big mapimage --- HERE --- |
2884 | // draw prerendered big mapimage --- HERE --- |
2454 | |
|
|
2455 | ////DBG dbg(0,"###### order=%d\n",display_list->order); |
|
|
2456 | struct transformation *t; |
2885 | struct transformation *t; |
2457 | t = display_list->dc.trans; |
2886 | t = display_list->dc.trans; |
2458 | ////DBG dbg(0,"###### screen center x=%d\n",t->screen_center.x); |
|
|
2459 | ////DBG dbg(0,"###### screen center y=%d\n",t->screen_center.y); |
|
|
2460 | |
|
|
2461 | struct coord *cp; |
2887 | struct coord *cp; |
2462 | cp = transform_get_center(t); |
2888 | cp = transform_get_center(t); |
2463 | ////DBG dbg(0,"###### t center x=%d\n",cp->x); |
|
|
2464 | ////DBG dbg(0,"###### t center y=%d\n",cp->y); |
|
|
2465 | |
|
|
2466 | struct attr attr; |
2889 | struct attr attr; |
2467 | struct config |
2890 | struct config |
2468 | { |
2891 | { |
2469 | struct attr **attrs; |
2892 | struct attr **attrs; |
2470 | struct callback_list *cbl; |
2893 | struct callback_list *cbl; |
2471 | }*config; |
2894 | }*config; |
2472 | struct point p; |
2895 | struct point p; |
2473 | int valid = 0; |
2896 | int valid = 0; |
2474 | // config_get_attr(config, attr_navit, &attr, NULL); |
|
|
2475 | if (global_navit) |
2897 | if (global_navit) |
2476 | { |
2898 | { |
2477 | if ((global_navit->vehicle) && (global_navit->vehicle->vehicle)) |
2899 | if ((global_navit->vehicle) && (global_navit->vehicle->vehicle)) |
2478 | { |
2900 | { |
2479 | ////DBG dbg(0,"###### v x=%d\n",p.x); |
|
|
2480 | ////DBG dbg(0,"###### v y=%d\n",p.y); |
|
|
2481 | |
|
|
2482 | ////DBG dbg(0,"###### v2 x=%d\n",global_vehicle_pos_onscreen.x); |
|
|
2483 | ////DBG dbg(0,"###### v2 y=%d\n",global_vehicle_pos_onscreen.y); |
|
|
2484 | |
|
|
2485 | ////DBG dbg(0,"### vf x=%d\n",global_navit->vehicle->last.x); |
|
|
2486 | ////DBG dbg(0,"### vf y=%d\n",global_navit->vehicle->last.y); |
|
|
2487 | |
|
|
2488 | ////DBG dbg(0,"### vff x=%d\n",global_navit->vehicle->coord.x); |
|
|
2489 | ////DBG dbg(0,"### vff y=%d\n",global_navit->vehicle->coord.y); |
|
|
2490 | |
|
|
2491 | int a, s; |
2901 | //int a, s; |
2492 | struct point pnt2; |
2902 | //struct point pnt2; |
2493 | vehicle_get_cursor_data(global_navit->vehicle->vehicle, &pnt2, &a, &s); |
2903 | //vehicle_get_cursor_data(global_navit->vehicle->vehicle, &pnt2, &a, &s); |
2494 | ////DBG dbg(0,"### vf 2 x=%d\n",pnt2.x); |
|
|
2495 | ////DBG dbg(0,"### vf 2 y=%d\n",pnt2.y); |
|
|
2496 | //global_vehicle_pos_onscreen.x=pnt2.x; |
|
|
2497 | //global_vehicle_pos_onscreen.y=pnt2.y; |
|
|
2498 | |
2904 | |
2499 | |
|
|
2500 | struct attr pos_attr; |
2905 | //struct attr pos_attr; |
2501 | if (vehicle_get_attr(global_navit->vehicle->vehicle, attr_position_coord_geo, &pos_attr, NULL)) |
2906 | //if (vehicle_get_attr(global_navit->vehicle->vehicle, attr_position_coord_geo, &pos_attr, NULL)) |
2502 | { |
2907 | //{ |
2503 | ////DBG dbg(0,"1 lat=%f, lng=%f\n",pos_attr.u.coord_geo->lat,pos_attr.u.coord_geo->lng); |
2908 | // ////DBG dbg(0,"1 lat=%f, lng=%f\n",pos_attr.u.coord_geo->lat,pos_attr.u.coord_geo->lng); |
2504 | } |
2909 | //} |
2505 | |
2910 | |
2506 | valid = 1; |
2911 | valid = 1; |
2507 | } |
2912 | } |
2508 | } |
2913 | } |
2509 | |
2914 | |
2510 | ////DBG dbg(0,"###### yaw=%d\n",-t->yaw); |
|
|
2511 | struct coord *c; |
2915 | struct coord *c; |
2512 | c = &(t->map_center); |
2916 | c = &(t->map_center); |
2513 | ////DBG dbg(0,"###### map center x=%d\n",c->x); |
|
|
2514 | ////DBG dbg(0,"###### map center y=%d\n",c->y); |
|
|
2515 | |
2917 | |
2516 | enum projection pro = transform_get_projection(global_navit->trans_cursor); |
2918 | enum projection pro = transform_get_projection(global_navit->trans_cursor); |
2517 | struct coord_geo g22; |
2919 | struct coord_geo g22; |
2518 | struct coord *c22; |
2920 | struct coord *c22; |
2519 | struct point mcenter_pnt; |
2921 | struct point mcenter_pnt; |
2520 | c22 = &(t->map_center); |
2922 | c22 = &(t->map_center); |
2521 | transform_to_geo(projection_mg, c22, &g22); |
2923 | transform_to_geo(projection_mg, c22, &g22); |
2522 | ////DBG dbg(0,"2 lat=%f, lng=%f\n",g22.lat,g22.lng); |
|
|
2523 | transform(global_navit->trans, pro, c22, &mcenter_pnt, 1, 0, 0, NULL); |
2924 | transform(global_navit->trans, pro, c22, &mcenter_pnt, 1, 0, 0, NULL); |
2524 | ////DBG dbg(0,"xxx 5 44444xxxx=%d\n",mcenter_pnt.x); |
|
|
2525 | ////DBG dbg(0,"yyy 5 44444yyyy=%d\n",mcenter_pnt.y); |
|
|
2526 | |
|
|
2527 | |
2925 | |
2528 | struct coord c99; |
2926 | struct coord c99; |
2529 | struct coord_geo g99; |
2927 | struct coord_geo g99; |
2530 | struct point cursor_pnt; |
2928 | struct point cursor_pnt; |
2531 | struct point p99; |
2929 | struct point p99; |
|
|
2930 | long my_scale; |
2532 | |
2931 | |
2533 | /* |
2932 | my_scale = transform_get_scale(global_navit->trans); |
2534 | g99.lat=79.0; |
|
|
2535 | g99.lng=-170.0; |
|
|
2536 | transform_from_geo(pro, &g99, &c99); |
|
|
2537 | //DBG dbg(0,"left top lat=%f, lng=%f, x=%d y=%d\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2538 | ////DBG dbg(0,"left top lat=%f, lng=%f, x=%f y=%f\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2539 | ////DBG dbg(0,"0x%x,0x%x\n",c99.x,c99.y); |
|
|
2540 | transform(global_navit->trans, pro, &c99, &cursor_pnt, 1, 0, 0, NULL); |
|
|
2541 | //DBG dbg(0,"xxxxxxx=%d\n",cursor_pnt.x); |
|
|
2542 | //DBG dbg(0,"yyyyyyy=%d\n",cursor_pnt.y); |
|
|
2543 | |
|
|
2544 | g99.lat=-79.0; |
|
|
2545 | g99.lng=170.0; |
|
|
2546 | transform_from_geo(pro, &g99, &c99); |
|
|
2547 | //DBG dbg(0,"right bottom lat=%f, lng=%f, x=%d y=%d\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2548 | ////DBG dbg(0,"right bottom lat=%f, lng=%f, x=%f y=%f\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2549 | transform(global_navit->trans, pro, &c99, &cursor_pnt, 1, 0, 0, NULL); |
|
|
2550 | //DBG dbg(0,"xxxxxxx=%d\n",cursor_pnt.x); |
|
|
2551 | //DBG dbg(0,"yyyyyyy=%d\n",cursor_pnt.y); |
|
|
2552 | */ |
|
|
2553 | |
2933 | |
2554 | g99.lat = 0.0; |
2934 | g99.lat = 0.0; |
2555 | g99.lng = 0.0; |
2935 | g99.lng = 0.0; |
|
|
2936 | // g99.lat = 80.0; |
|
|
2937 | // g99.lng = -174.0; |
2556 | transform_from_geo(pro, &g99, &c99); |
2938 | transform_from_geo(pro, &g99, &c99); |
2557 | ////DBG dbg(0,"center center lat=%f, lng=%f, x=%d y=%d\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2558 | ////DBG dbg(0,"center center lat=%f, lng=%f, x=%f y=%f\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2559 | transform(global_navit->trans, pro, &c99, &cursor_pnt, 1, 0, 0, NULL); |
2939 | transform(global_navit->trans, pro, &c99, &cursor_pnt, 1, 0, 0, NULL); |
2560 | ////DBG dbg(0,"xxx44444xxxx=%d\n",cursor_pnt.x); |
|
|
2561 | ////DBG dbg(0,"yyy44444yyyy=%d\n",cursor_pnt.y); |
|
|
2562 | |
|
|
2563 | //struct coord *c77; |
|
|
2564 | //c77=&(t->map_center); |
|
|
2565 | //transform(global_navit->trans, pro, &c77, &cursor_pnt, 1, 0, 0, NULL); |
|
|
2566 | ////DBG dbg(0,"---> cx=%d\n",cursor_pnt.x); |
|
|
2567 | ////DBG dbg(0,"---> cy=%d\n",cursor_pnt.y); |
|
|
2568 | |
|
|
2569 | |
2940 | |
2570 | // now really draw it |
2941 | // now really draw it |
2571 | struct graphics *gra22 = display_list->dc.gra; |
2942 | struct graphics *gra22 = display_list->dc.gra; |
2572 | struct graphics_gc *gc22 = display_list->dc.gc; |
2943 | struct graphics_gc *gc22 = display_list->dc.gc; |
2573 | if (!gc22) |
2944 | if (!gc22) |
2574 | { |
2945 | { |
2575 | gc22 = graphics_gc_new(gra22); |
2946 | gc22 = graphics_gc_new(gra22); |
2576 | } |
2947 | } |
2577 | // graphics_draw_bigmap(gra22, gc22, -t->yaw, display_list->order, g22.lat, g22.lng, c->x, c->y, t->screen_center.x, t->screen_center.y, global_vehicle_pos_onscreen.x, global_vehicle_pos_onscreen.y, valid); |
|
|
2578 | graphics_draw_bigmap(gra22, gc22, -t->yaw, display_list->order, g22.lat, g22.lng, cursor_pnt.x, cursor_pnt.y, mcenter_pnt.x, mcenter_pnt.y, global_vehicle_pos_onscreen.x, global_vehicle_pos_onscreen.y, valid); |
2948 | // graphics_draw_bigmap(gra22, gc22, -t->yaw, display_list->order, g22.lat, g22.lng, cursor_pnt.x, cursor_pnt.y, mcenter_pnt.x, mcenter_pnt.y, global_vehicle_pos_onscreen.x, global_vehicle_pos_onscreen.y, valid); |
|
|
2949 | graphics_draw_bigmap(gra22, gc22, -t->yaw, (int)(my_scale / 100), g22.lat, g22.lng, cursor_pnt.x, cursor_pnt.y, mcenter_pnt.x, mcenter_pnt.y, global_vehicle_pos_onscreen.x, global_vehicle_pos_onscreen.y, valid); |
|
|
2950 | } |
|
|
2951 | |
|
|
2952 | // reset value; --> not sure here, maybe it should NOT be reset here!!!??? |
|
|
2953 | cancel_drawing_global = 0; |
|
|
2954 | |
|
|
2955 | lays = l->layers; |
|
|
2956 | while (lays) |
|
|
2957 | { |
|
|
2958 | lay = lays->data; |
|
|
2959 | if (lay->active) |
|
|
2960 | { |
|
|
2961 | xdisplay_draw_layer(display_list, gra, lay, order); |
2579 | } |
2962 | } |
|
|
2963 | lays = g_list_next(lays); |
2580 | |
2964 | |
2581 | ////DBG dbg(0, "XXXXXYYYYYYY Draw: 001\n"); |
2965 | // stop drawing is requested |
|
|
2966 | if (cancel_drawing_global == 1) |
|
|
2967 | { |
|
|
2968 | break; |
|
|
2969 | } |
|
|
2970 | } |
2582 | |
2971 | |
2583 | // reset value; |
2972 | // reset value; |
2584 | cancel_drawing_global = 0; |
2973 | cancel_drawing_global = 0; |
2585 | |
|
|
2586 | lays = l->layers; |
|
|
2587 | while (lays) |
|
|
2588 | { |
|
|
2589 | lay = lays->data; |
|
|
2590 | if (lay->active) |
|
|
2591 | { |
|
|
2592 | xdisplay_draw_layer(display_list, gra, lay, order); |
|
|
2593 | } |
|
|
2594 | lays = g_list_next(lays); |
|
|
2595 | |
|
|
2596 | // stop drawing is requested |
|
|
2597 | if (cancel_drawing_global == 1) |
|
|
2598 | { |
|
|
2599 | //DBG dbg(0, "** STOP MD 003 **\n"); |
|
|
2600 | break; |
|
|
2601 | } |
|
|
2602 | } |
|
|
2603 | |
|
|
2604 | // reset value; |
|
|
2605 | cancel_drawing_global = 0; |
|
|
2606 | |
|
|
2607 | ////DBG dbg(0, "XXXXXYYYYYYY Draw: 002\n"); |
|
|
2608 | |
2974 | |
2609 | #ifdef HAVE_API_ANDROID |
2975 | #ifdef HAVE_API_ANDROID |
2610 | android_return_generic_int(2, 1); |
2976 | android_return_generic_int(2, 1); |
2611 | #endif |
2977 | #endif |
2612 | |
2978 | |
… | |
… | |
2622 | |
2988 | |
2623 | static void displaylist_update_layers(struct displaylist *displaylist, GList *layers, int order) |
2989 | static void displaylist_update_layers(struct displaylist *displaylist, GList *layers, int order) |
2624 | { |
2990 | { |
2625 | ////DBG dbg(0,"ooo enter ooo\n"); |
2991 | ////DBG dbg(0,"ooo enter ooo\n"); |
2626 | |
2992 | |
2627 | int order_corrected = order; |
2993 | int order_corrected = order + shift_order; |
2628 | //int saved=displaylist->order; |
2994 | //int saved=displaylist->order; |
2629 | if (order < limit_order_corrected) |
2995 | if (order < limit_order_corrected) |
2630 | { |
2996 | { |
2631 | order_corrected = limit_order_corrected; |
2997 | order_corrected = limit_order_corrected; |
2632 | // displaylist->order=0; |
2998 | // displaylist->order=0; |
… | |
… | |
2666 | // dbg(1, "max offset %d\n", displaylist->max_offset); |
3032 | // dbg(1, "max offset %d\n", displaylist->max_offset); |
2667 | } |
3033 | } |
2668 | |
3034 | |
2669 | static void do_draw(struct displaylist *displaylist, int cancel, int flags) |
3035 | static void do_draw(struct displaylist *displaylist, int cancel, int flags) |
2670 | { |
3036 | { |
|
|
3037 | |
|
|
3038 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
|
|
3039 | dbg(0,"+#+:enter\n"); |
|
|
3040 | #endif |
|
|
3041 | |
|
|
3042 | //dbg(0,"enter\n"); |
|
|
3043 | |
|
|
3044 | #ifdef HAVE_API_ANDROID |
|
|
3045 | // ---- disable map view ----- |
|
|
3046 | // ---- disable map view ----- |
|
|
3047 | // ---- disable map view ----- |
|
|
3048 | if (disable_map_drawing == 1) |
|
|
3049 | { |
|
|
3050 | android_return_generic_int(2, 0); |
|
|
3051 | |
|
|
3052 | //dbg(0,"set:0:displaylist->busy=%d\n",displaylist->busy); |
|
|
3053 | displaylist->busy = 0; |
|
|
3054 | |
|
|
3055 | //dbg(0,"return 001\n"); |
|
|
3056 | return; |
|
|
3057 | } |
|
|
3058 | // ---- disable map view ----- |
|
|
3059 | // ---- disable map view ----- |
|
|
3060 | // ---- disable map view ----- |
|
|
3061 | #endif |
|
|
3062 | |
|
|
3063 | |
|
|
3064 | |
|
|
3065 | clock_t s_; |
|
|
3066 | #ifdef NAVIT_MEASURE_TIME_DEBUG |
|
|
3067 | s_ = debug_measure_start(); |
|
|
3068 | #endif |
|
|
3069 | |
|
|
3070 | |
2671 | struct item *item; |
3071 | struct item *item; |
2672 | int count, max = displaylist->dc.maxlen, workload = 0; |
3072 | int count, max = displaylist->dc.maxlen, workload = 0; |
2673 | struct coord *ca = g_alloca(sizeof(struct coord) * max); |
3073 | struct coord *ca = g_alloca(sizeof(struct coord) * max); |
2674 | struct attr attr, attr2; |
3074 | struct attr attr, attr2; |
2675 | enum projection pro; |
3075 | enum projection pro; |
2676 | int draw_vector_map = 1; // do we draw the vecotor map, or not? 0=false, 1=true |
3076 | int draw_vector_map = 1; // do we draw the vecotor map, or not? 0=false, 1=true |
2677 | int mapset_counter = 0; |
3077 | int mapset_counter = 0; |
2678 | int mapset_need_draw = 0; |
3078 | int mapset_need_draw = 0; |
2679 | |
3079 | |
2680 | //DBG dbg(0,"ooo enter ooo %d\n",displaylist->order); |
3080 | // dbg(0,"ooo enter ooo %d\n",displaylist->order); |
2681 | |
3081 | |
2682 | int order_corrected = displaylist->order; |
3082 | int order_corrected = displaylist->order + shift_order; |
2683 | int saved = displaylist->order; |
3083 | int saved = displaylist->order; |
2684 | if (order_corrected < limit_order_corrected) |
3084 | if (order_corrected < limit_order_corrected) |
2685 | { |
3085 | { |
2686 | order_corrected = limit_order_corrected; |
3086 | order_corrected = limit_order_corrected; |
2687 | } |
3087 | } |
… | |
… | |
2689 | if (displaylist->order != displaylist->order_hashed || displaylist->layout != displaylist->layout_hashed) |
3089 | if (displaylist->order != displaylist->order_hashed || displaylist->layout != displaylist->layout_hashed) |
2690 | { |
3090 | { |
2691 | displaylist_update_hash(displaylist); |
3091 | displaylist_update_hash(displaylist); |
2692 | displaylist->order_hashed = displaylist->order; |
3092 | displaylist->order_hashed = displaylist->order; |
2693 | displaylist->layout_hashed = displaylist->layout; |
3093 | displaylist->layout_hashed = displaylist->layout; |
2694 | |
|
|
2695 | // //DBG dbg(0,"-----====> order (zoom) = %d",displaylist->order); |
|
|
2696 | // //DBG dbg(0,"-----====> order (zoom) = %d",displaylist->order_hashed); |
|
|
2697 | // TODO // give new order (zoom) back to Java // TODO |
|
|
2698 | } |
3094 | } |
2699 | |
3095 | |
2700 | //profile(0, NULL); |
|
|
2701 | pro = transform_get_projection(displaylist->dc.trans); |
3096 | pro = transform_get_projection(displaylist->dc.trans); |
2702 | |
|
|
2703 | // //DBG dbg(0,"ooo xxx ooo1\n"); |
|
|
2704 | // //DBG dbg(0,"ooo %d %d %d\n",displaylist->order_hashed,ORDER_USE_PRERENDERED_MAP,draw_vector_map); |
|
|
2705 | |
3097 | |
2706 | // if zoomed out too much then use prerendered map tiles |
3098 | // if zoomed out too much then use prerendered map tiles |
2707 | if (displaylist->order_hashed < ORDER_USE_PRERENDERED_MAP) |
3099 | if (displaylist->order_hashed < ORDER_USE_PRERENDERED_MAP) |
2708 | { |
3100 | { |
2709 | draw_vector_map = 0; |
3101 | draw_vector_map = 0; |
2710 | } |
3102 | } |
2711 | |
|
|
2712 | // //DBG dbg(0,"ooo %d %d %d\n",displaylist->order_hashed,ORDER_USE_PRERENDERED_MAP,draw_vector_map); |
|
|
2713 | // //DBG dbg(0,"ooo xxx ooo2\n"); |
|
|
2714 | |
|
|
2715 | if (!draw_vector_map) |
|
|
2716 | { |
|
|
2717 | // draw prerendered big mapimage --- HERE --- |
|
|
2718 | |
|
|
2719 | ////DBG dbg(0,"###### order=%d\n",displaylist->order_hashed); |
|
|
2720 | struct transformation *t; |
|
|
2721 | t = displaylist->dc.trans; |
|
|
2722 | ////DBG dbg(0,"###### screen center x=%d\n",t->screen_center.x); |
|
|
2723 | ////DBG dbg(0,"###### screen center y=%d\n",t->screen_center.y); |
|
|
2724 | |
|
|
2725 | struct coord *cp; |
|
|
2726 | cp = transform_get_center(t); |
|
|
2727 | ////DBG dbg(0,"###### t center x=%d\n",cp->x); |
|
|
2728 | ////DBG dbg(0,"###### t center y=%d\n",cp->y); |
|
|
2729 | |
|
|
2730 | struct attr attr; |
|
|
2731 | struct config |
|
|
2732 | { |
|
|
2733 | struct attr **attrs; |
|
|
2734 | struct callback_list *cbl; |
|
|
2735 | }*config; |
|
|
2736 | struct point p; |
|
|
2737 | int valid = 0; |
|
|
2738 | // config_get_attr(config, attr_navit, &attr, NULL); |
|
|
2739 | if (global_navit) |
|
|
2740 | { |
|
|
2741 | if ((global_navit->vehicle) && (global_navit->vehicle->vehicle)) |
|
|
2742 | { |
|
|
2743 | ////DBG dbg(0,"###### v x=%d\n",p.x); |
|
|
2744 | ////DBG dbg(0,"###### v y=%d\n",p.y); |
|
|
2745 | |
|
|
2746 | ////DBG dbg(0,"###### v2 x=%d\n",global_vehicle_pos_onscreen.x); |
|
|
2747 | ////DBG dbg(0,"###### v2 y=%d\n",global_vehicle_pos_onscreen.y); |
|
|
2748 | |
|
|
2749 | ////DBG dbg(0,"### vf x=%d\n",global_navit->vehicle->last.x); |
|
|
2750 | ////DBG dbg(0,"### vf y=%d\n",global_navit->vehicle->last.y); |
|
|
2751 | |
|
|
2752 | ////DBG dbg(0,"### vff x=%d\n",global_navit->vehicle->coord.x); |
|
|
2753 | ////DBG dbg(0,"### vff y=%d\n",global_navit->vehicle->coord.y); |
|
|
2754 | |
|
|
2755 | int a, s; |
|
|
2756 | struct point pnt2; |
|
|
2757 | vehicle_get_cursor_data(global_navit->vehicle->vehicle, &pnt2, &a, &s); |
|
|
2758 | ////DBG dbg(0,"### vf 2 x=%d\n",pnt2.x); |
|
|
2759 | ////DBG dbg(0,"### vf 2 y=%d\n",pnt2.y); |
|
|
2760 | //global_vehicle_pos_onscreen.x=pnt2.x; |
|
|
2761 | //global_vehicle_pos_onscreen.y=pnt2.y; |
|
|
2762 | |
|
|
2763 | struct attr pos_attr; |
|
|
2764 | if (vehicle_get_attr(global_navit->vehicle->vehicle, attr_position_coord_geo, &pos_attr, NULL)) |
|
|
2765 | { |
|
|
2766 | ////DBG dbg(0,"1 lat=%f, lng=%f\n",pos_attr.u.coord_geo->lat,pos_attr.u.coord_geo->lng); |
|
|
2767 | } |
|
|
2768 | |
|
|
2769 | valid = 1; |
|
|
2770 | } |
|
|
2771 | } |
|
|
2772 | |
|
|
2773 | //DBG dbg(0,"###### yaw=%d\n",-t->yaw); |
|
|
2774 | struct coord *c; |
|
|
2775 | c = &(t->map_center); |
|
|
2776 | //DBG dbg(0,"###### map center x=%d\n",c->x); |
|
|
2777 | //DBG dbg(0,"###### map center y=%d\n",c->y); |
|
|
2778 | |
|
|
2779 | enum projection pro = transform_get_projection(global_navit->trans_cursor); |
|
|
2780 | struct coord_geo g22; |
|
|
2781 | struct coord *c22; |
|
|
2782 | struct point mcenter_pnt; |
|
|
2783 | c22 = &(t->map_center); |
|
|
2784 | transform_to_geo(projection_mg, c22, &g22); |
|
|
2785 | ////DBG dbg(0,"2 lat=%f, lng=%f\n",g22.lat,g22.lng); |
|
|
2786 | transform(global_navit->trans, pro, c22, &mcenter_pnt, 1, 0, 0, NULL); |
|
|
2787 | ////DBG dbg(0,"xxx 5 33333xxxx=%d\n",mcenter_pnt.x); |
|
|
2788 | ////DBG dbg(0,"yyy 5 33333yyyy=%d\n",mcenter_pnt.y); |
|
|
2789 | |
|
|
2790 | |
|
|
2791 | struct coord c99; |
|
|
2792 | struct coord_geo g99; |
|
|
2793 | struct point cursor_pnt; |
|
|
2794 | struct point p99; |
|
|
2795 | |
|
|
2796 | /* |
|
|
2797 | g99.lat=79.0; |
|
|
2798 | g99.lng=-170.0; |
|
|
2799 | transform_from_geo(pro, &g99, &c99); |
|
|
2800 | //DBG dbg(0,"left top lat=%f, lng=%f, x=%d y=%d\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2801 | ////DBG dbg(0,"left top lat=%f, lng=%f, x=%f y=%f\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2802 | ////DBG dbg(0,"0x%x,0x%x\n",c99.x,c99.y); |
|
|
2803 | transform(global_navit->trans, pro, &c99, &cursor_pnt, 1, 0, 0, NULL); |
|
|
2804 | //DBG dbg(0,"xxxxxxx=%d\n",cursor_pnt.x); |
|
|
2805 | //DBG dbg(0,"yyyyyyy=%d\n",cursor_pnt.y); |
|
|
2806 | |
|
|
2807 | g99.lat=-79.0; |
|
|
2808 | g99.lng=170.0; |
|
|
2809 | transform_from_geo(pro, &g99, &c99); |
|
|
2810 | //DBG dbg(0,"right bottom lat=%f, lng=%f, x=%d y=%d\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2811 | ////DBG dbg(0,"right bottom lat=%f, lng=%f, x=%f y=%f\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2812 | transform(global_navit->trans, pro, &c99, &cursor_pnt, 1, 0, 0, NULL); |
|
|
2813 | //DBG dbg(0,"xxxxxxx=%d\n",cursor_pnt.x); |
|
|
2814 | //DBG dbg(0,"yyyyyyy=%d\n",cursor_pnt.y); |
|
|
2815 | */ |
|
|
2816 | |
|
|
2817 | g99.lat = 0.0; |
|
|
2818 | g99.lng = 0.0; |
|
|
2819 | transform_from_geo(pro, &g99, &c99); |
|
|
2820 | ////DBG dbg(0,"center center lat=%f, lng=%f, x=%d y=%d\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2821 | ////DBG dbg(0,"center center lat=%f, lng=%f, x=%f y=%f\n",g99.lat,g99.lng,c99.x,c99.y); |
|
|
2822 | transform(global_navit->trans, pro, &c99, &cursor_pnt, 1, 0, 0, NULL); |
|
|
2823 | ////DBG dbg(0,"xxxx333xxx=%d\n",cursor_pnt.x); |
|
|
2824 | ////DBG dbg(0,"yyyy333yyy=%d\n",cursor_pnt.y); |
|
|
2825 | |
|
|
2826 | //struct coord *c77; |
|
|
2827 | //c77=&(t->map_center); |
|
|
2828 | //transform(global_navit->trans, pro, &c77, &cursor_pnt, 1, 0, 0, NULL); |
|
|
2829 | ////DBG dbg(0,"---> cx=%d\n",cursor_pnt.x); |
|
|
2830 | ////DBG dbg(0,"---> cy=%d\n",cursor_pnt.y); |
|
|
2831 | |
|
|
2832 | |
|
|
2833 | // now really draw it |
|
|
2834 | struct graphics *gra22 = displaylist->dc.gra; |
|
|
2835 | struct graphics_gc *gc22 = displaylist->dc.gc; |
|
|
2836 | if (!gc22) |
|
|
2837 | { |
|
|
2838 | gc22 = graphics_gc_new(gra22); |
|
|
2839 | } |
|
|
2840 | //DBG dbg(0,"graphics_draw_bigmap s\n"); |
|
|
2841 | graphics_draw_bigmap(gra22, gc22, -t->yaw, displaylist->order, g22.lat, g22.lng, cursor_pnt.x, cursor_pnt.y, mcenter_pnt.x, mcenter_pnt.y, global_vehicle_pos_onscreen.x, global_vehicle_pos_onscreen.y, valid); |
|
|
2842 | //DBG dbg(0,"graphics_draw_bigmap e\n"); |
|
|
2843 | } |
|
|
2844 | |
|
|
2845 | //DBG dbg(0,"xxx uuu xxx\n"); |
|
|
2846 | |
3103 | |
2847 | displaylist->order = order_corrected; |
3104 | displaylist->order = order_corrected; |
2848 | |
3105 | |
2849 | //DBG dbg(0, "XXXXXYYYYYYY Draw: 003\n"); |
3106 | //DBG dbg(0, "XXXXXYYYYYYY Draw: 003\n"); |
2850 | |
3107 | |
… | |
… | |
2872 | mapset_need_draw = 1; |
3129 | mapset_need_draw = 1; |
2873 | struct attr map_name_attr; |
3130 | struct attr map_name_attr; |
2874 | |
3131 | |
2875 | if (map_get_attr(displaylist->m, attr_name, &map_name_attr, NULL)) |
3132 | if (map_get_attr(displaylist->m, attr_name, &map_name_attr, NULL)) |
2876 | { |
3133 | { |
2877 | // //DBG dbg(0,"map name=%s",map_name_attr.u.str); |
3134 | //dbg(0,"#+* start reading map file #+*=%s\n",map_name_attr.u.str); |
2878 | if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0) |
3135 | if (strncmp("_ms_sdcard_map:", map_name_attr.u.str, 15) == 0) |
2879 | { |
3136 | { |
2880 | if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/borders.bin", map_name_attr.u.str, 41) == 0) |
3137 | if (strncmp("_ms_sdcard_map:/sdcard/zanavi/maps/borders.bin", map_name_attr.u.str, 41) == 0) |
2881 | { |
3138 | { |
2882 | // if its the countryborder map, always draw it |
3139 | // if its the countryborder map, always draw it |
2883 | mapset_need_draw = 0; // --> now dont even draw borders on low zoom level, we have prerendered image |
3140 | mapset_need_draw = 0; // now dont even draw border map!! |
2884 | } |
3141 | } |
2885 | else |
3142 | else |
2886 | { |
3143 | { |
2887 | // if its an sdcard street map, don't draw it |
3144 | // if its an sdcard street map, don't draw it |
2888 | mapset_need_draw = 0; |
3145 | mapset_need_draw = 0; |
… | |
… | |
2912 | if ((draw_vector_map) || (mapset_need_draw == 1)) |
3169 | if ((draw_vector_map) || (mapset_need_draw == 1)) |
2913 | { |
3170 | { |
2914 | |
3171 | |
2915 | //dbg(0, "XXXXXYYYYYYY Draw: A.01\n"); |
3172 | //dbg(0, "XXXXXYYYYYYY Draw: A.01\n"); |
2916 | |
3173 | |
|
|
3174 | |
|
|
3175 | // ------ READ all items in this map rectangle --------- |
|
|
3176 | // ------ READ all items in this map rectangle --------- |
|
|
3177 | // ------ READ all items in this map rectangle --------- |
|
|
3178 | // ------ READ all items in this map rectangle --------- |
|
|
3179 | // ------ READ all items in this map rectangle --------- |
|
|
3180 | //dbg(0,"#+* start reading map file #+*\n"); |
|
|
3181 | int _item_counter_ = 0; |
2917 | while ((item = map_rect_get_item(displaylist->mr))) |
3182 | while ((item = map_rect_get_item(displaylist->mr))) |
2918 | { |
3183 | { |
|
|
3184 | _item_counter_++; |
|
|
3185 | |
2919 | int label_count = 0; |
3186 | int label_count = 0; |
2920 | char *labels[2]; |
3187 | char *labels[2]; |
2921 | struct hash_entry *entry; |
3188 | struct hash_entry *entry; |
2922 | |
3189 | |
2923 | if (cancel_drawing_global == 1) |
3190 | if (cancel_drawing_global == 1) |
… | |
… | |
2931 | { |
3198 | { |
2932 | if (displaylist->workload) |
3199 | if (displaylist->workload) |
2933 | { |
3200 | { |
2934 | // restore order :-) |
3201 | // restore order :-) |
2935 | displaylist->order = saved; |
3202 | displaylist->order = saved; |
|
|
3203 | |
|
|
3204 | //dbg(0,"set:0:displaylist->busy=%d\n",displaylist->busy); |
|
|
3205 | displaylist->busy = 0; |
|
|
3206 | |
|
|
3207 | //dbg(0,"return 002\n"); |
2936 | return; |
3208 | return; |
2937 | } |
3209 | } |
2938 | else |
3210 | else |
2939 | { |
3211 | { |
2940 | continue; |
3212 | continue; |
… | |
… | |
2966 | } |
3238 | } |
2967 | |
3239 | |
2968 | //dbg(0, "XXXXXYYYYYYY Draw: A.item2\n"); |
3240 | //dbg(0, "XXXXXYYYYYYY Draw: A.item2\n"); |
2969 | |
3241 | |
2970 | if (displaylist->dc.pro != pro) |
3242 | if (displaylist->dc.pro != pro) |
|
|
3243 | { |
2971 | transform_from_to_count(ca, displaylist->dc.pro, ca, pro, count); |
3244 | transform_from_to_count(ca, displaylist->dc.pro, ca, pro, count); |
|
|
3245 | } |
2972 | |
3246 | |
2973 | if (count == max) |
3247 | if (count == max) |
2974 | { |
3248 | { |
2975 | //DBG dbg(0,"point count overflow %d for %s "ITEM_ID_FMT"\n", count,item_to_name(item->type),ITEM_ID_ARGS(*item)); |
3249 | //DBG dbg(0,"point count overflow %d for %s "ITEM_ID_FMT"\n", count,item_to_name(item->type),ITEM_ID_ARGS(*item)); |
2976 | displaylist->dc.maxlen = max * 2; |
3250 | displaylist->dc.maxlen = max * 2; |
… | |
… | |
3055 | if (labels[1]) |
3329 | if (labels[1]) |
3056 | { |
3330 | { |
3057 | map_convert_free(labels[1]); |
3331 | map_convert_free(labels[1]); |
3058 | } |
3332 | } |
3059 | |
3333 | |
3060 | workload++; |
3334 | //workload++; |
3061 | |
3335 | /* |
3062 | if (workload == displaylist->workload) |
3336 | if (workload == displaylist->workload) |
3063 | { |
3337 | { |
3064 | // restore order :-) |
3338 | // restore order :-) |
3065 | displaylist->order = saved; |
3339 | displaylist->order = saved; |
3066 | // reset value; |
3340 | // reset value; |
3067 | cancel_drawing_global = 0; |
3341 | cancel_drawing_global = 0; |
|
|
3342 | |
|
|
3343 | dbg(0,"set:0:displaylist->busy=%d\n",displaylist->busy); |
|
|
3344 | displaylist->busy = 0; |
|
|
3345 | |
|
|
3346 | dbg(0,"return 003\n"); |
3068 | return; |
3347 | return; |
3069 | } |
3348 | } |
|
|
3349 | */ |
3070 | } // while item=map_rect_get_item |
3350 | } // while item=map_rect_get_item |
|
|
3351 | // ------ READ all items in this map rectangle --------- |
|
|
3352 | // ------ READ all items in this map rectangle --------- |
|
|
3353 | // ------ READ all items in this map rectangle --------- |
|
|
3354 | // ------ READ all items in this map rectangle --------- |
|
|
3355 | // ------ READ all items in this map rectangle --------- |
|
|
3356 | |
3071 | |
3357 | |
3072 | ////DBG dbg(0, "XXXXXYYYYYYY Draw: A.02\n"); |
3358 | ////DBG dbg(0, "XXXXXYYYYYYY Draw: A.02\n"); |
3073 | |
3359 | |
3074 | map_rect_destroy(displaylist->mr); |
3360 | map_rect_destroy(displaylist->mr); |
3075 | } |
3361 | } |
… | |
… | |
3083 | displaylist->mr = NULL; |
3369 | displaylist->mr = NULL; |
3084 | displaylist->sel = NULL; |
3370 | displaylist->sel = NULL; |
3085 | displaylist->m = NULL; |
3371 | displaylist->m = NULL; |
3086 | } // while ---- |
3372 | } // while ---- |
3087 | |
3373 | |
|
|
3374 | |
|
|
3375 | |
|
|
3376 | #ifdef NAVIT_MEASURE_TIME_DEBUG |
|
|
3377 | debug_mrp("do_draw:load", debug_measure_end(s_)); |
|
|
3378 | #endif |
|
|
3379 | s_ = debug_measure_start(); |
|
|
3380 | |
|
|
3381 | |
3088 | //DBG dbg(0, "XXXXXYYYYYYY Draw: 004\n"); |
3382 | //DBG dbg(0, "XXXXXYYYYYYY Draw: 004\n"); |
3089 | |
3383 | |
3090 | // reset value; |
3384 | // reset value; |
3091 | cancel_drawing_global = 0; |
3385 | cancel_drawing_global = 0; |
3092 | |
3386 | |
… | |
… | |
3102 | } |
3396 | } |
3103 | //DBG dbg(0,"ee e\n"); |
3397 | //DBG dbg(0,"ee e\n"); |
3104 | displaylist->idle_ev = NULL; |
3398 | displaylist->idle_ev = NULL; |
3105 | callback_destroy(displaylist->idle_cb); |
3399 | callback_destroy(displaylist->idle_cb); |
3106 | displaylist->idle_cb = NULL; |
3400 | displaylist->idle_cb = NULL; |
|
|
3401 | //dbg(0,"set:0:displaylist->busy=%d\n",displaylist->busy); |
3107 | displaylist->busy = 0; |
3402 | //displaylist->busy = 0; |
3108 | |
3403 | |
3109 | // graphics_process_selection(displaylist->dc.gra, displaylist); |
3404 | // graphics_process_selection(displaylist->dc.gra, displaylist); |
3110 | |
3405 | |
3111 | //profile(1, "draw\n"); |
3406 | //profile(1, "draw\n"); |
3112 | |
3407 | |
… | |
… | |
3122 | // dont clean bg of screen when drawing prerendered tiles |
3417 | // dont clean bg of screen when drawing prerendered tiles |
3123 | flags2 = flags2 + 2; |
3418 | flags2 = flags2 + 2; |
3124 | } |
3419 | } |
3125 | } |
3420 | } |
3126 | //DBG dbg(0,"call graphics_displaylist_draw 3") |
3421 | //DBG dbg(0,"call graphics_displaylist_draw 3") |
|
|
3422 | //dbg(0,"# MT:002 #\n"); |
3127 | graphics_displaylist_draw(displaylist->dc.gra, displaylist, displaylist->dc.trans, displaylist->layout, flags2); |
3423 | graphics_displaylist_draw(displaylist->dc.gra, displaylist, displaylist->dc.trans, displaylist->layout, flags2); |
|
|
3424 | //dbg(0,"# MT:003 #\n"); |
|
|
3425 | } |
|
|
3426 | |
|
|
3427 | #ifdef NAVIT_MEASURE_TIME_DEBUG |
|
|
3428 | debug_mrp("do_draw:draw", debug_measure_end(s_)); |
|
|
3429 | #endif |
|
|
3430 | |
|
|
3431 | #ifdef HAVE_API_ANDROID |
|
|
3432 | if (cur_mapdraw_time_index < 11) |
|
|
3433 | { |
|
|
3434 | mapdraw_time[cur_mapdraw_time_index] = debug_measure_end_tsecs(s_); |
|
|
3435 | // dbg(0,"maptime: %d\n", mapdraw_time[cur_mapdraw_time_index]); |
|
|
3436 | cur_mapdraw_time_index++; |
|
|
3437 | } |
|
|
3438 | |
|
|
3439 | if (cur_mapdraw_time_index > 10) |
|
|
3440 | { |
|
|
3441 | cur_mapdraw_time_index = 0; |
|
|
3442 | int jk; |
|
|
3443 | int mean_time = 0; |
|
|
3444 | for (jk=0;jk<11;jk++) |
|
|
3445 | { |
|
|
3446 | mean_time = mean_time + mapdraw_time[jk]; |
3128 | } |
3447 | } |
|
|
3448 | android_return_generic_int(6, (int)((float)mean_time / (float)10)); |
|
|
3449 | } |
|
|
3450 | #endif |
|
|
3451 | |
|
|
3452 | |
|
|
3453 | //dbg(0,"set:0:displaylist->busy=%d\n",displaylist->busy); |
|
|
3454 | displaylist->busy = 0; |
3129 | |
3455 | |
3130 | //DBG dbg(0, "XXXXXYYYYYYY Draw: 006\n"); |
3456 | //DBG dbg(0, "XXXXXYYYYYYY Draw: 006\n"); |
3131 | |
3457 | |
3132 | #ifdef HAVE_API_ANDROID |
3458 | #ifdef HAVE_API_ANDROID |
3133 | android_return_generic_int(2, 0); |
3459 | android_return_generic_int(2, 0); |
3134 | #endif |
3460 | #endif |
3135 | |
3461 | |
3136 | map_rect_destroy(displaylist->mr); |
3462 | map_rect_destroy(displaylist->mr); |
3137 | if (!route_selection) |
3463 | if (!route_selection) |
|
|
3464 | { |
3138 | map_selection_destroy(displaylist->sel); |
3465 | map_selection_destroy(displaylist->sel); |
|
|
3466 | } |
3139 | mapset_close(displaylist->msh); |
3467 | mapset_close(displaylist->msh); |
3140 | displaylist->mr = NULL; |
3468 | displaylist->mr = NULL; |
3141 | displaylist->sel = NULL; |
3469 | displaylist->sel = NULL; |
3142 | displaylist->m = NULL; |
3470 | displaylist->m = NULL; |
3143 | displaylist->msh = NULL; |
3471 | displaylist->msh = NULL; |
3144 | //profile(1, "callback\n"); |
3472 | //profile(1, "callback\n"); |
3145 | callback_call_1(displaylist->cb, cancel); |
3473 | callback_call_1(displaylist->cb, cancel); |
3146 | //profile(0, "end\n"); |
3474 | //profile(0, "end\n"); |
|
|
3475 | |
3147 | //DBG dbg(0,"leave\n"); |
3476 | //dbg(0,"leave\n"); |
|
|
3477 | |
|
|
3478 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
|
|
3479 | dbg(0,"+#+:leave\n"); |
|
|
3480 | #endif |
|
|
3481 | |
3148 | } |
3482 | } |
3149 | |
3483 | |
3150 | /** |
3484 | /** |
3151 | * FIXME |
3485 | * FIXME |
3152 | * @param <> |
3486 | * @param <> |
3153 | * @returns <> |
3487 | * @returns <> |
3154 | * @author Martin Schaller (04/2008) |
3488 | * @author Martin Schaller (04/2008) |
3155 | */ |
3489 | */ |
3156 | void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags) |
3490 | void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags) |
3157 | { |
3491 | { |
|
|
3492 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
|
|
3493 | dbg(0,"+#+:enter\n"); |
|
|
3494 | #endif |
|
|
3495 | |
3158 | //DBG dbg(0,"ooo enter ooo\n"); |
3496 | // dbg(0,"ooo enter ooo flags=%d\n", flags); |
3159 | |
3497 | |
3160 | int order = transform_get_order(trans); |
3498 | int order = transform_get_order(trans); |
3161 | displaylist->dc.trans = trans; |
3499 | displaylist->dc.trans = trans; |
3162 | displaylist->dc.gra = gra; |
3500 | displaylist->dc.gra = gra; |
|
|
3501 | |
|
|
3502 | |
|
|
3503 | // *********DISABLED******* |
|
|
3504 | // *********DISABLED******* |
|
|
3505 | // *********DISABLED******* |
|
|
3506 | // set min. distanct of 2 points on line at which a point will be left out when zoomed out too much!! |
|
|
3507 | // *********DISABLED******* displaylist->dc.mindist = transform_get_scale(trans) / 2; |
|
|
3508 | //dbg(0,"mindist would be:%d\n", (int)(transform_get_scale(trans) / 2)); |
|
|
3509 | displaylist->dc.mindist = 0; |
|
|
3510 | if (order < 13) |
|
|
3511 | { |
3163 | displaylist->dc.mindist = transform_get_scale(trans) / 2; |
3512 | displaylist->dc.mindist = transform_get_scale(trans); |
3164 | //DBG dbg(0,"1\n"); |
3513 | } |
|
|
3514 | // *********DISABLED******* |
|
|
3515 | // *********DISABLED******* |
|
|
3516 | // *********DISABLED******* |
|
|
3517 | |
|
|
3518 | |
|
|
3519 | |
3165 | // FIXME find a better place to set the background color |
3520 | // FIXME find a better place to set the background color |
3166 | if (l) |
3521 | if (l) |
3167 | { |
3522 | { |
3168 | graphics_gc_set_background(gra->gc[0], &l->color); |
3523 | graphics_gc_set_background(gra->gc[0], &l->color); |
3169 | graphics_gc_set_foreground(gra->gc[0], &l->color); |
3524 | graphics_gc_set_foreground(gra->gc[0], &l->color); |
3170 | gra->default_font = g_strdup(l->font); |
3525 | gra->default_font = g_strdup(l->font); |
3171 | } |
3526 | } |
3172 | //DBG dbg(0,"2\n"); |
|
|
3173 | graphics_background_gc(gra, gra->gc[0]); |
3527 | graphics_background_gc(gra, gra->gc[0]); |
3174 | if (flags & 1) |
3528 | if (flags & 1) |
3175 | { |
3529 | { |
3176 | //DBG dbg(0,"3\n"); |
3530 | // calls -> navit.c navit_predraw --> draw all vehicles |
3177 | callback_list_call_attr_0(gra->cbl, attr_predraw); |
3531 | callback_list_call_attr_0(gra->cbl, attr_predraw); |
3178 | //DBG dbg(0,"4\n"); |
|
|
3179 | } |
3532 | } |
3180 | gra->meth.draw_mode(gra->priv, (flags & 8) ? draw_mode_begin_clear : draw_mode_begin); |
3533 | gra->meth.draw_mode(gra->priv, (flags & 8) ? draw_mode_begin_clear : draw_mode_begin); |
3181 | //DBG dbg(0,"5\n"); |
|
|
3182 | if (!(flags & 2)) |
3534 | if (!(flags & 2)) |
3183 | { |
3535 | { |
3184 | //DBG dbg(0,"6\n"); |
|
|
3185 | // clear the display/screen/whatever here |
3536 | // clear the display/screen/whatever here |
3186 | gra->meth.draw_rectangle(gra->priv, gra->gc[0]->priv, &gra->r.lu, gra->r.rl.x - gra->r.lu.x, gra->r.rl.y - gra->r.lu.y); |
3537 | gra->meth.draw_rectangle(gra->priv, gra->gc[0]->priv, &gra->r.lu, gra->r.rl.x - gra->r.lu.x, gra->r.rl.y - gra->r.lu.y); |
3187 | //DBG dbg(0,"7\n"); |
|
|
3188 | } |
3538 | } |
3189 | if (l) |
3539 | if (l) |
3190 | { |
3540 | { |
3191 | //DBG dbg(0,"8\n"); |
3541 | // draw the mapitems |
3192 | // //DBG dbg(0,"o , l->d = %d , %d\n",order,l->order_delta); |
3542 | // dbg(0,"o , l->d = %d , %d\n",order,l->order_delta); |
3193 | xdisplay_draw(displaylist, gra, l, order + l->order_delta); |
3543 | xdisplay_draw(displaylist, gra, l, order + l->order_delta); |
3194 | //DBG dbg(0,"9\n"); |
|
|
3195 | } |
3544 | } |
3196 | if (flags & 1) |
3545 | if (flags & 1) |
3197 | { |
3546 | { |
3198 | //DBG dbg(0,"10\n"); |
|
|
3199 | callback_list_call_attr_0(gra->cbl, attr_postdraw); |
3547 | callback_list_call_attr_0(gra->cbl, attr_postdraw); |
3200 | //DBG dbg(0,"11\n"); |
|
|
3201 | } |
3548 | } |
3202 | if (!(flags & 4)) |
3549 | if (!(flags & 4)) |
3203 | { |
3550 | { |
3204 | //DBG dbg(0,"12\n"); |
|
|
3205 | gra->meth.draw_mode(gra->priv, draw_mode_end); |
3551 | gra->meth.draw_mode(gra->priv, draw_mode_end); |
3206 | //DBG dbg(0,"13\n"); |
|
|
3207 | } |
3552 | } |
3208 | |
3553 | |
|
|
3554 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
3209 | //DBG dbg(0,"leave\n"); |
3555 | dbg(0,"+#+:leave\n"); |
|
|
3556 | #endif |
|
|
3557 | |
3210 | } |
3558 | } |
3211 | |
3559 | |
3212 | static void graphics_load_mapset(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags) |
3560 | static void graphics_load_mapset(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags) |
3213 | { |
3561 | { |
3214 | int order = transform_get_order(trans); |
3562 | int order = transform_get_order(trans); |
3215 | |
3563 | |
3216 | //DBG dbg(0,"enter displaylist->busy=%d\n",displaylist->busy); |
3564 | //dbg(0,"enter displaylist->busy=%d\n",displaylist->busy); |
3217 | ////DBG dbg(0,"async=%d\n",async); |
3565 | //dbg(0,"async=%d\n",async); |
3218 | if (displaylist->busy) |
3566 | if (displaylist->busy) |
3219 | { |
3567 | { |
3220 | if (async == 1) |
3568 | if (async == 1) |
3221 | { |
3569 | { |
|
|
3570 | //dbg(0,"**draw 1.a\n"); |
3222 | return; |
3571 | return; |
3223 | } |
3572 | } |
3224 | //DBG dbg(0,"**draw 1"); |
3573 | ///dbg(0,"**draw 1\n"); |
|
|
3574 | return; |
3225 | do_draw(displaylist, 1, flags); |
3575 | //do_draw(displaylist, 1, flags); |
3226 | } |
3576 | } |
3227 | xdisplay_free(displaylist); |
3577 | xdisplay_free(displaylist); |
3228 | |
3578 | |
3229 | displaylist->dc.gra = gra; |
3579 | displaylist->dc.gra = gra; |
3230 | displaylist->ms = mapset; |
3580 | displaylist->ms = mapset; |
… | |
… | |
3236 | if (l) |
3586 | if (l) |
3237 | { |
3587 | { |
3238 | order += l->order_delta; |
3588 | order += l->order_delta; |
3239 | } |
3589 | } |
3240 | displaylist->order = order; |
3590 | displaylist->order = order; |
|
|
3591 | //dbg(0,"set:1:displaylist->busy=%d\n",displaylist->busy); |
3241 | displaylist->busy = 1; |
3592 | displaylist->busy = 1; |
3242 | displaylist->layout = l; |
3593 | displaylist->layout = l; |
3243 | |
3594 | |
|
|
3595 | |
|
|
3596 | // ---------- DISABLED ------ no more async!! |
|
|
3597 | /* |
3244 | if (async) |
3598 | if (async) |
3245 | { |
3599 | { |
3246 | //DBG dbg(0,"§§async"); |
3600 | //DBG dbg(0,"§§async"); |
3247 | if (!displaylist->idle_cb) |
3601 | if (!displaylist->idle_cb) |
3248 | { |
3602 | { |
… | |
… | |
3255 | else |
3609 | else |
3256 | { |
3610 | { |
3257 | //DBG dbg(0,"@@sync"); |
3611 | //DBG dbg(0,"@@sync"); |
3258 | do_draw(displaylist, 0, flags); |
3612 | do_draw(displaylist, 0, flags); |
3259 | } |
3613 | } |
|
|
3614 | */ |
|
|
3615 | |
|
|
3616 | |
|
|
3617 | if (async) |
|
|
3618 | { |
|
|
3619 | if (! displaylist->idle_cb) |
|
|
3620 | { |
|
|
3621 | //dbg(0,"**draw 2.b1\n"); |
|
|
3622 | displaylist->idle_cb=callback_new_3(callback_cast(do_draw), displaylist, 0, flags); |
|
|
3623 | //dbg(0,"**draw 2.b2\n"); |
|
|
3624 | } |
|
|
3625 | //dbg(0,"**draw 2.b3\n"); |
|
|
3626 | // displaylist->idle_ev= |
|
|
3627 | event_add_idle(1000, displaylist->idle_cb); |
|
|
3628 | //dbg(0,"**draw 2.b4\n"); |
|
|
3629 | } |
|
|
3630 | else |
|
|
3631 | { |
|
|
3632 | //dbg(0,"**draw 2.b5\n"); |
|
|
3633 | do_draw(displaylist, 0, flags); |
|
|
3634 | } |
3260 | } |
3635 | } |
3261 | |
3636 | |
3262 | /** |
3637 | /** |
3263 | * FIXME |
3638 | * FIXME |
3264 | * @param <> |
3639 | * @param <> |
3265 | * @returns <> |
3640 | * @returns <> |
3266 | * @author Martin Schaller (04/2008) |
3641 | * @author Martin Schaller (04/2008) |
3267 | */ |
3642 | */ |
3268 | void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags) |
3643 | void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags) |
3269 | { |
3644 | { |
3270 | //DBG dbg(0,"ooo enter ooo\n"); |
3645 | //dbg(0,"ooo enter ooo\n"); |
3271 | |
3646 | |
3272 | graphics_load_mapset(gra, displaylist, mapset, trans, l, async, cb, flags); |
3647 | graphics_load_mapset(gra, displaylist, mapset, trans, l, async, cb, flags); |
3273 | } |
3648 | } |
3274 | |
3649 | |
3275 | int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist) |
3650 | int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist) |
… | |
… | |
3362 | struct displaylist * graphics_displaylist_new(void) |
3737 | struct displaylist * graphics_displaylist_new(void) |
3363 | { |
3738 | { |
3364 | struct displaylist *ret=g_new0(struct displaylist, 1); |
3739 | struct displaylist *ret=g_new0(struct displaylist, 1); |
3365 | |
3740 | |
3366 | ret->dc.maxlen = 16384; |
3741 | ret->dc.maxlen = 16384; |
|
|
3742 | ret->busy = 0; |
3367 | |
3743 | |
3368 | return ret; |
3744 | return ret; |
3369 | } |
3745 | } |
3370 | |
3746 | |
3371 | /** |
3747 | /** |