///////////////////////////////////////////////////// TMapDC ------ draw a vector (line with an ending arrow) on the screen from map coords
| 654 | // draw a vector (line with an ending arrow) on the screen |
| 655 | // from map coords |
| 656 | void |
| 657 | TMapDC::DrawMapVector(SHORT mapXstart, SHORT mapYstart, SHORT mapXend, SHORT mapYend) |
| 658 | { |
| 659 | #ifndef WINDOWS_CLIPPING |
| 660 | if ( ! IS_VISIBLE_MAP_RECT(mapXstart, mapYstart, mapXend, mapYend) ) |
| 661 | return; |
| 662 | #endif |
| 663 | |
| 664 | #ifdef WINDOWS_SCALING |
| 665 | SHORT x0 = mapXstart; |
| 666 | SHORT y0 = mapYstart; |
| 667 | SHORT x1 = mapXend; |
| 668 | SHORT y1 = mapYend; |
| 669 | #else |
| 670 | SHORT x0 = SCREENX(mapXstart); |
| 671 | SHORT y0 = SCREENY(mapYstart); |
| 672 | SHORT x1 = SCREENX(mapXend); |
| 673 | SHORT y1 = SCREENY(mapYend); |
| 674 | #endif |
| 675 | SHORT dx = x0 - x1; |
| 676 | SHORT dy = y0 - y1; |
| 677 | |
| 678 | // Draw the line part of the vector |
| 679 | MoveTo (x0, y0); |
| 680 | LineTo (x1, y1); |
| 681 | |
| 682 | // Don't draw arrow if Scale <= 1/6 |
| 683 | if ( (ScaleNum == 1) && (ScaleDen >= 6) ) |
| 684 | return; |
| 685 | |
| 686 | // Calc the length of the line |
| 687 | SHORT r = (SHORT)hypot(dx, dy); |
| 688 | // Don't calc if length == 0 (no orientation !) |
| 689 | if ( r == 0 ) |
| 690 | return; |
| 691 | |
| 692 | // Draw the arrow part of the vector |
| 693 | SHORT scrXoff = (SHORT) (dx * 8 * MUL_SCALE / r); |
| 694 | SHORT scrYoff = (SHORT) (dy * 8 * MUL_SCALE / r); |
| 695 | x0 = x1 + 2 * scrXoff; |
| 696 | y0 = y1 + 2 * scrYoff; |
| 697 | MoveTo (x0 - scrYoff, y0 + scrXoff); |
| 698 | LineTo (x1 , y1); |
| 699 | LineTo (x0 + scrYoff, y0 - scrXoff); |
| 700 | } |
| 701 | |
| 702 | |
| 703 |