Overview
Comment: | Improve the auto-chop algorithm so that the object that does the chopping must not contain the next point along the line. This is a partial fix to the bug reported by forum post 73eea815afda0715 but more work is needed. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6210a902d508c4b9479d63fb19ab3478 |
User & Date: | drh 2021-07-17 17:27:24 |
References
2021-07-17
| ||
17:48 | • Reply: Bug when connecting circles with chopped arrow (artifact: 568449d15b user: drh) | |
Context
2021-07-17
| ||
19:25 | The starting and ending objects of a line are remembered and used by the "chop" feature so that the line is chopped by the correct object in the case where two or more objects have the same center. Forum post 1d46e3a0bc (check-in: 2090a12c76 user: drh tags: trunk) | |
17:27 | Improve the auto-chop algorithm so that the object that does the chopping must not contain the next point along the line. This is a partial fix to the bug reported by forum post 73eea815afda0715 but more work is needed. (check-in: 6210a902d5 user: drh tags: trunk) | |
2021-07-12
| ||
18:31 | Fix the pik_round() function in pikchr.c. Needed to recompile pikchr.y. (check-in: 91a57c8b75 user: drh tags: trunk) | |
Changes
Changes to pikchr.c.
︙ | ︙ | |||
450 451 452 453 454 455 456 457 458 459 460 461 462 463 | static void pik_close_path(Pik*,PToken*); static void pik_set_at(Pik*,PToken*,PPoint*,PToken*); static short int pik_nth_value(Pik*,PToken*); static PObj *pik_find_nth(Pik*,PObj*,PToken*); static PObj *pik_find_byname(Pik*,PObj*,PToken*); static PPoint pik_place_of_elem(Pik*,PObj*,PToken*); static int pik_bbox_isempty(PBox*); static void pik_bbox_init(PBox*); static void pik_bbox_addbox(PBox*,PBox*); static void pik_bbox_add_xy(PBox*,PNum,PNum); static void pik_bbox_addellipse(PBox*,PNum x,PNum y,PNum rx,PNum ry); static void pik_add_txt(Pik*,PToken*,int); static int pik_text_length(const PToken *pToken); static void pik_size_to_fit(Pik*,PToken*,int); | > | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | static void pik_close_path(Pik*,PToken*); static void pik_set_at(Pik*,PToken*,PPoint*,PToken*); static short int pik_nth_value(Pik*,PToken*); static PObj *pik_find_nth(Pik*,PObj*,PToken*); static PObj *pik_find_byname(Pik*,PObj*,PToken*); static PPoint pik_place_of_elem(Pik*,PObj*,PToken*); static int pik_bbox_isempty(PBox*); static int pik_bbox_contains_point(PBox*,PPoint*); static void pik_bbox_init(PBox*); static void pik_bbox_addbox(PBox*,PBox*); static void pik_bbox_add_xy(PBox*,PNum,PNum); static void pik_bbox_addellipse(PBox*,PNum x,PNum y,PNum rx,PNum ry); static void pik_add_txt(Pik*,PToken*,int); static int pik_text_length(const PToken *pToken); static void pik_size_to_fit(Pik*,PToken*,int); |
︙ | ︙ | |||
474 475 476 477 478 479 480 | static void pik_behind(Pik*,PObj*); static PObj *pik_assert(Pik*,PNum,PToken*,PNum); static PObj *pik_position_assert(Pik*,PPoint*,PToken*,PPoint*); static PNum pik_dist(PPoint*,PPoint*); static void pik_add_macro(Pik*,PToken *pId,PToken *pCode); | | | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | static void pik_behind(Pik*,PObj*); static PObj *pik_assert(Pik*,PNum,PToken*,PNum); static PObj *pik_position_assert(Pik*,PPoint*,PToken*,PPoint*); static PNum pik_dist(PPoint*,PPoint*); static void pik_add_macro(Pik*,PToken *pId,PToken *pCode); #line 508 "pikchr.c" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols. ***************** Begin token definitions *************************************/ #ifndef T_ID #define T_ID 1 #define T_EDGEPT 2 #define T_OF 3 |
︙ | ︙ | |||
1703 1704 1705 1706 1707 1708 1709 | ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are *not* used ** inside the C code. */ /********* Begin destructor definitions ***************************************/ case 99: /* statement_list */ { | | | | | | 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 | ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are *not* used ** inside the C code. */ /********* Begin destructor definitions ***************************************/ case 99: /* statement_list */ { #line 497 "pikchr.y" pik_elist_free(p,(yypminor->yy227)); #line 1738 "pikchr.c" } break; case 100: /* statement */ case 101: /* unnamed_statement */ case 102: /* basetype */ { #line 499 "pikchr.y" pik_elem_free(p,(yypminor->yy36)); #line 1747 "pikchr.c" } break; /********* End destructor definitions *****************************************/ default: break; /* If no destructor action specified: do nothing */ } } |
︙ | ︙ | |||
1932 1933 1934 1935 1936 1937 1938 | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ | | | | 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ #line 531 "pikchr.y" pik_error(p, 0, "parser stack overflow"); #line 1968 "pikchr.c" /******** End %stack_overflow code ********************************************/ pik_parserARG_STORE /* Suppress warning about unused %extra_argument var */ pik_parserCTX_STORE } /* ** Print tracing information for a SHIFT action |
︙ | ︙ | |||
2415 2416 2417 2418 2419 2420 2421 | ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* document ::= statement_list */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 | ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* document ::= statement_list */ #line 535 "pikchr.y" {pik_render(p,yymsp[0].minor.yy227);} #line 2450 "pikchr.c" break; case 1: /* statement_list ::= statement */ #line 538 "pikchr.y" { yylhsminor.yy227 = pik_elist_append(p,0,yymsp[0].minor.yy36); } #line 2455 "pikchr.c" yymsp[0].minor.yy227 = yylhsminor.yy227; break; case 2: /* statement_list ::= statement_list EOL statement */ #line 540 "pikchr.y" { yylhsminor.yy227 = pik_elist_append(p,yymsp[-2].minor.yy227,yymsp[0].minor.yy36); } #line 2461 "pikchr.c" yymsp[-2].minor.yy227 = yylhsminor.yy227; break; case 3: /* statement ::= */ #line 543 "pikchr.y" { yymsp[1].minor.yy36 = 0; } #line 2467 "pikchr.c" break; case 4: /* statement ::= direction */ #line 544 "pikchr.y" { pik_set_direction(p,yymsp[0].minor.yy0.eCode); yylhsminor.yy36=0; } #line 2472 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 5: /* statement ::= lvalue ASSIGN rvalue */ #line 545 "pikchr.y" {pik_set_var(p,&yymsp[-2].minor.yy0,yymsp[0].minor.yy153,&yymsp[-1].minor.yy0); yylhsminor.yy36=0;} #line 2478 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 6: /* statement ::= PLACENAME COLON unnamed_statement */ #line 547 "pikchr.y" { yylhsminor.yy36 = yymsp[0].minor.yy36; pik_elem_setname(p,yymsp[0].minor.yy36,&yymsp[-2].minor.yy0); } #line 2484 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 7: /* statement ::= PLACENAME COLON position */ #line 549 "pikchr.y" { yylhsminor.yy36 = pik_elem_new(p,0,0,0); if(yylhsminor.yy36){ yylhsminor.yy36->ptAt = yymsp[0].minor.yy79; pik_elem_setname(p,yylhsminor.yy36,&yymsp[-2].minor.yy0); }} #line 2491 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 8: /* statement ::= unnamed_statement */ #line 551 "pikchr.y" {yylhsminor.yy36 = yymsp[0].minor.yy36;} #line 2497 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 9: /* statement ::= print prlist */ #line 552 "pikchr.y" {pik_append(p,"<br>\n",5); yymsp[-1].minor.yy36=0;} #line 2503 "pikchr.c" break; case 10: /* statement ::= ASSERT LP expr EQ expr RP */ #line 557 "pikchr.y" {yymsp[-5].minor.yy36=pik_assert(p,yymsp[-3].minor.yy153,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy153);} #line 2508 "pikchr.c" break; case 11: /* statement ::= ASSERT LP position EQ position RP */ #line 559 "pikchr.y" {yymsp[-5].minor.yy36=pik_position_assert(p,&yymsp[-3].minor.yy79,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy79);} #line 2513 "pikchr.c" break; case 12: /* statement ::= DEFINE ID CODEBLOCK */ #line 560 "pikchr.y" {yymsp[-2].minor.yy36=0; pik_add_macro(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} #line 2518 "pikchr.c" break; case 13: /* rvalue ::= PLACENAME */ #line 571 "pikchr.y" {yylhsminor.yy153 = pik_lookup_color(p,&yymsp[0].minor.yy0);} #line 2523 "pikchr.c" yymsp[0].minor.yy153 = yylhsminor.yy153; break; case 14: /* pritem ::= FILL */ case 15: /* pritem ::= COLOR */ yytestcase(yyruleno==15); case 16: /* pritem ::= THICKNESS */ yytestcase(yyruleno==16); #line 576 "pikchr.y" {pik_append_num(p,"",pik_value(p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.n,0));} #line 2531 "pikchr.c" break; case 17: /* pritem ::= rvalue */ #line 579 "pikchr.y" {pik_append_num(p,"",yymsp[0].minor.yy153);} #line 2536 "pikchr.c" break; case 18: /* pritem ::= STRING */ #line 580 "pikchr.y" {pik_append_text(p,yymsp[0].minor.yy0.z+1,yymsp[0].minor.yy0.n-2,0);} #line 2541 "pikchr.c" break; case 19: /* prsep ::= COMMA */ #line 581 "pikchr.y" {pik_append(p, " ", 1);} #line 2546 "pikchr.c" break; case 20: /* unnamed_statement ::= basetype attribute_list */ #line 584 "pikchr.y" {yylhsminor.yy36 = yymsp[-1].minor.yy36; pik_after_adding_attributes(p,yylhsminor.yy36);} #line 2551 "pikchr.c" yymsp[-1].minor.yy36 = yylhsminor.yy36; break; case 21: /* basetype ::= CLASSNAME */ #line 586 "pikchr.y" {yylhsminor.yy36 = pik_elem_new(p,&yymsp[0].minor.yy0,0,0); } #line 2557 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 22: /* basetype ::= STRING textposition */ #line 588 "pikchr.y" {yymsp[-1].minor.yy0.eCode = yymsp[0].minor.yy164; yylhsminor.yy36 = pik_elem_new(p,0,&yymsp[-1].minor.yy0,0); } #line 2563 "pikchr.c" yymsp[-1].minor.yy36 = yylhsminor.yy36; break; case 23: /* basetype ::= LB savelist statement_list RB */ #line 590 "pikchr.y" { p->list = yymsp[-2].minor.yy227; yymsp[-3].minor.yy36 = pik_elem_new(p,0,0,yymsp[-1].minor.yy227); if(yymsp[-3].minor.yy36) yymsp[-3].minor.yy36->errTok = yymsp[0].minor.yy0; } #line 2569 "pikchr.c" break; case 24: /* savelist ::= */ #line 595 "pikchr.y" {yymsp[1].minor.yy227 = p->list; p->list = 0;} #line 2574 "pikchr.c" break; case 25: /* relexpr ::= expr */ #line 602 "pikchr.y" {yylhsminor.yy10.rAbs = yymsp[0].minor.yy153; yylhsminor.yy10.rRel = 0;} #line 2579 "pikchr.c" yymsp[0].minor.yy10 = yylhsminor.yy10; break; case 26: /* relexpr ::= expr PERCENT */ #line 603 "pikchr.y" {yylhsminor.yy10.rAbs = 0; yylhsminor.yy10.rRel = yymsp[-1].minor.yy153/100;} #line 2585 "pikchr.c" yymsp[-1].minor.yy10 = yylhsminor.yy10; break; case 27: /* optrelexpr ::= */ #line 605 "pikchr.y" {yymsp[1].minor.yy10.rAbs = 0; yymsp[1].minor.yy10.rRel = 1.0;} #line 2591 "pikchr.c" break; case 28: /* attribute_list ::= relexpr alist */ #line 607 "pikchr.y" {pik_add_direction(p,0,&yymsp[-1].minor.yy10);} #line 2596 "pikchr.c" break; case 29: /* attribute ::= numproperty relexpr */ #line 611 "pikchr.y" { pik_set_numprop(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy10); } #line 2601 "pikchr.c" break; case 30: /* attribute ::= dashproperty expr */ #line 612 "pikchr.y" { pik_set_dashed(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy153); } #line 2606 "pikchr.c" break; case 31: /* attribute ::= dashproperty */ #line 613 "pikchr.y" { pik_set_dashed(p,&yymsp[0].minor.yy0,0); } #line 2611 "pikchr.c" break; case 32: /* attribute ::= colorproperty rvalue */ #line 614 "pikchr.y" { pik_set_clrprop(p,&yymsp[-1].minor.yy0,yymsp[0].minor.yy153); } #line 2616 "pikchr.c" break; case 33: /* attribute ::= go direction optrelexpr */ #line 615 "pikchr.y" { pik_add_direction(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy10);} #line 2621 "pikchr.c" break; case 34: /* attribute ::= go direction even position */ #line 616 "pikchr.y" {pik_evenwith(p,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy79);} #line 2626 "pikchr.c" break; case 35: /* attribute ::= CLOSE */ #line 617 "pikchr.y" { pik_close_path(p,&yymsp[0].minor.yy0); } #line 2631 "pikchr.c" break; case 36: /* attribute ::= CHOP */ #line 618 "pikchr.y" { p->cur->bChop = 1; } #line 2636 "pikchr.c" break; case 37: /* attribute ::= FROM position */ #line 619 "pikchr.y" { pik_set_from(p,p->cur,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy79); } #line 2641 "pikchr.c" break; case 38: /* attribute ::= TO position */ #line 620 "pikchr.y" { pik_add_to(p,p->cur,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy79); } #line 2646 "pikchr.c" break; case 39: /* attribute ::= THEN */ #line 621 "pikchr.y" { pik_then(p, &yymsp[0].minor.yy0, p->cur); } #line 2651 "pikchr.c" break; case 40: /* attribute ::= THEN optrelexpr HEADING expr */ case 42: /* attribute ::= GO optrelexpr HEADING expr */ yytestcase(yyruleno==42); #line 623 "pikchr.y" {pik_move_hdg(p,&yymsp[-2].minor.yy10,&yymsp[-1].minor.yy0,yymsp[0].minor.yy153,0,&yymsp[-3].minor.yy0);} #line 2657 "pikchr.c" break; case 41: /* attribute ::= THEN optrelexpr EDGEPT */ case 43: /* attribute ::= GO optrelexpr EDGEPT */ yytestcase(yyruleno==43); #line 624 "pikchr.y" {pik_move_hdg(p,&yymsp[-1].minor.yy10,0,0,&yymsp[0].minor.yy0,&yymsp[-2].minor.yy0);} #line 2663 "pikchr.c" break; case 44: /* attribute ::= AT position */ #line 629 "pikchr.y" { pik_set_at(p,0,&yymsp[0].minor.yy79,&yymsp[-1].minor.yy0); } #line 2668 "pikchr.c" break; case 45: /* attribute ::= SAME */ #line 631 "pikchr.y" {pik_same(p,0,&yymsp[0].minor.yy0);} #line 2673 "pikchr.c" break; case 46: /* attribute ::= SAME AS object */ #line 632 "pikchr.y" {pik_same(p,yymsp[0].minor.yy36,&yymsp[-2].minor.yy0);} #line 2678 "pikchr.c" break; case 47: /* attribute ::= STRING textposition */ #line 633 "pikchr.y" {pik_add_txt(p,&yymsp[-1].minor.yy0,yymsp[0].minor.yy164);} #line 2683 "pikchr.c" break; case 48: /* attribute ::= FIT */ #line 634 "pikchr.y" {pik_size_to_fit(p,&yymsp[0].minor.yy0,3); } #line 2688 "pikchr.c" break; case 49: /* attribute ::= BEHIND object */ #line 635 "pikchr.y" {pik_behind(p,yymsp[0].minor.yy36);} #line 2693 "pikchr.c" break; case 50: /* withclause ::= DOT_E edge AT position */ case 51: /* withclause ::= edge AT position */ yytestcase(yyruleno==51); #line 643 "pikchr.y" { pik_set_at(p,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy79,&yymsp[-1].minor.yy0); } #line 2699 "pikchr.c" break; case 52: /* numproperty ::= HEIGHT|WIDTH|RADIUS|DIAMETER|THICKNESS */ #line 647 "pikchr.y" {yylhsminor.yy0 = yymsp[0].minor.yy0;} #line 2704 "pikchr.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 53: /* boolproperty ::= CW */ #line 658 "pikchr.y" {p->cur->cw = 1;} #line 2710 "pikchr.c" break; case 54: /* boolproperty ::= CCW */ #line 659 "pikchr.y" {p->cur->cw = 0;} #line 2715 "pikchr.c" break; case 55: /* boolproperty ::= LARROW */ #line 660 "pikchr.y" {p->cur->larrow=1; p->cur->rarrow=0; } #line 2720 "pikchr.c" break; case 56: /* boolproperty ::= RARROW */ #line 661 "pikchr.y" {p->cur->larrow=0; p->cur->rarrow=1; } #line 2725 "pikchr.c" break; case 57: /* boolproperty ::= LRARROW */ #line 662 "pikchr.y" {p->cur->larrow=1; p->cur->rarrow=1; } #line 2730 "pikchr.c" break; case 58: /* boolproperty ::= INVIS */ #line 663 "pikchr.y" {p->cur->sw = 0.0;} #line 2735 "pikchr.c" break; case 59: /* boolproperty ::= THICK */ #line 664 "pikchr.y" {p->cur->sw *= 1.5;} #line 2740 "pikchr.c" break; case 60: /* boolproperty ::= THIN */ #line 665 "pikchr.y" {p->cur->sw *= 0.67;} #line 2745 "pikchr.c" break; case 61: /* boolproperty ::= SOLID */ #line 666 "pikchr.y" {p->cur->sw = pik_value(p,"thickness",9,0); p->cur->dotted = p->cur->dashed = 0.0;} #line 2751 "pikchr.c" break; case 62: /* textposition ::= */ #line 669 "pikchr.y" {yymsp[1].minor.yy164 = 0;} #line 2756 "pikchr.c" break; case 63: /* textposition ::= textposition CENTER|LJUST|RJUST|ABOVE|BELOW|ITALIC|BOLD|ALIGNED|BIG|SMALL */ #line 672 "pikchr.y" {yylhsminor.yy164 = (short int)pik_text_position(yymsp[-1].minor.yy164,&yymsp[0].minor.yy0);} #line 2761 "pikchr.c" yymsp[-1].minor.yy164 = yylhsminor.yy164; break; case 64: /* position ::= expr COMMA expr */ #line 675 "pikchr.y" {yylhsminor.yy79.x=yymsp[-2].minor.yy153; yylhsminor.yy79.y=yymsp[0].minor.yy153;} #line 2767 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 65: /* position ::= place PLUS expr COMMA expr */ #line 677 "pikchr.y" {yylhsminor.yy79.x=yymsp[-4].minor.yy79.x+yymsp[-2].minor.yy153; yylhsminor.yy79.y=yymsp[-4].minor.yy79.y+yymsp[0].minor.yy153;} #line 2773 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 66: /* position ::= place MINUS expr COMMA expr */ #line 678 "pikchr.y" {yylhsminor.yy79.x=yymsp[-4].minor.yy79.x-yymsp[-2].minor.yy153; yylhsminor.yy79.y=yymsp[-4].minor.yy79.y-yymsp[0].minor.yy153;} #line 2779 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 67: /* position ::= place PLUS LP expr COMMA expr RP */ #line 680 "pikchr.y" {yylhsminor.yy79.x=yymsp[-6].minor.yy79.x+yymsp[-3].minor.yy153; yylhsminor.yy79.y=yymsp[-6].minor.yy79.y+yymsp[-1].minor.yy153;} #line 2785 "pikchr.c" yymsp[-6].minor.yy79 = yylhsminor.yy79; break; case 68: /* position ::= place MINUS LP expr COMMA expr RP */ #line 682 "pikchr.y" {yylhsminor.yy79.x=yymsp[-6].minor.yy79.x-yymsp[-3].minor.yy153; yylhsminor.yy79.y=yymsp[-6].minor.yy79.y-yymsp[-1].minor.yy153;} #line 2791 "pikchr.c" yymsp[-6].minor.yy79 = yylhsminor.yy79; break; case 69: /* position ::= LP position COMMA position RP */ #line 683 "pikchr.y" {yymsp[-4].minor.yy79.x=yymsp[-3].minor.yy79.x; yymsp[-4].minor.yy79.y=yymsp[-1].minor.yy79.y;} #line 2797 "pikchr.c" break; case 70: /* position ::= LP position RP */ #line 684 "pikchr.y" {yymsp[-2].minor.yy79=yymsp[-1].minor.yy79;} #line 2802 "pikchr.c" break; case 71: /* position ::= expr between position AND position */ #line 686 "pikchr.y" {yylhsminor.yy79 = pik_position_between(yymsp[-4].minor.yy153,yymsp[-2].minor.yy79,yymsp[0].minor.yy79);} #line 2807 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 72: /* position ::= expr LT position COMMA position GT */ #line 688 "pikchr.y" {yylhsminor.yy79 = pik_position_between(yymsp[-5].minor.yy153,yymsp[-3].minor.yy79,yymsp[-1].minor.yy79);} #line 2813 "pikchr.c" yymsp[-5].minor.yy79 = yylhsminor.yy79; break; case 73: /* position ::= expr ABOVE position */ #line 689 "pikchr.y" {yylhsminor.yy79=yymsp[0].minor.yy79; yylhsminor.yy79.y += yymsp[-2].minor.yy153;} #line 2819 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 74: /* position ::= expr BELOW position */ #line 690 "pikchr.y" {yylhsminor.yy79=yymsp[0].minor.yy79; yylhsminor.yy79.y -= yymsp[-2].minor.yy153;} #line 2825 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 75: /* position ::= expr LEFT OF position */ #line 691 "pikchr.y" {yylhsminor.yy79=yymsp[0].minor.yy79; yylhsminor.yy79.x -= yymsp[-3].minor.yy153;} #line 2831 "pikchr.c" yymsp[-3].minor.yy79 = yylhsminor.yy79; break; case 76: /* position ::= expr RIGHT OF position */ #line 692 "pikchr.y" {yylhsminor.yy79=yymsp[0].minor.yy79; yylhsminor.yy79.x += yymsp[-3].minor.yy153;} #line 2837 "pikchr.c" yymsp[-3].minor.yy79 = yylhsminor.yy79; break; case 77: /* position ::= expr ON HEADING EDGEPT OF position */ #line 694 "pikchr.y" {yylhsminor.yy79 = pik_position_at_hdg(yymsp[-5].minor.yy153,&yymsp[-2].minor.yy0,yymsp[0].minor.yy79);} #line 2843 "pikchr.c" yymsp[-5].minor.yy79 = yylhsminor.yy79; break; case 78: /* position ::= expr HEADING EDGEPT OF position */ #line 696 "pikchr.y" {yylhsminor.yy79 = pik_position_at_hdg(yymsp[-4].minor.yy153,&yymsp[-2].minor.yy0,yymsp[0].minor.yy79);} #line 2849 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 79: /* position ::= expr EDGEPT OF position */ #line 698 "pikchr.y" {yylhsminor.yy79 = pik_position_at_hdg(yymsp[-3].minor.yy153,&yymsp[-2].minor.yy0,yymsp[0].minor.yy79);} #line 2855 "pikchr.c" yymsp[-3].minor.yy79 = yylhsminor.yy79; break; case 80: /* position ::= expr ON HEADING expr FROM position */ #line 700 "pikchr.y" {yylhsminor.yy79 = pik_position_at_angle(yymsp[-5].minor.yy153,yymsp[-2].minor.yy153,yymsp[0].minor.yy79);} #line 2861 "pikchr.c" yymsp[-5].minor.yy79 = yylhsminor.yy79; break; case 81: /* position ::= expr HEADING expr FROM position */ #line 702 "pikchr.y" {yylhsminor.yy79 = pik_position_at_angle(yymsp[-4].minor.yy153,yymsp[-2].minor.yy153,yymsp[0].minor.yy79);} #line 2867 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 82: /* place ::= edge OF object */ #line 714 "pikchr.y" {yylhsminor.yy79 = pik_place_of_elem(p,yymsp[0].minor.yy36,&yymsp[-2].minor.yy0);} #line 2873 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 83: /* place2 ::= object */ #line 715 "pikchr.y" {yylhsminor.yy79 = pik_place_of_elem(p,yymsp[0].minor.yy36,0);} #line 2879 "pikchr.c" yymsp[0].minor.yy79 = yylhsminor.yy79; break; case 84: /* place2 ::= object DOT_E edge */ #line 716 "pikchr.y" {yylhsminor.yy79 = pik_place_of_elem(p,yymsp[-2].minor.yy36,&yymsp[0].minor.yy0);} #line 2885 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 85: /* place2 ::= NTH VERTEX OF object */ #line 717 "pikchr.y" {yylhsminor.yy79 = pik_nth_vertex(p,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,yymsp[0].minor.yy36);} #line 2891 "pikchr.c" yymsp[-3].minor.yy79 = yylhsminor.yy79; break; case 86: /* object ::= nth */ #line 729 "pikchr.y" {yylhsminor.yy36 = pik_find_nth(p,0,&yymsp[0].minor.yy0);} #line 2897 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 87: /* object ::= nth OF|IN object */ #line 730 "pikchr.y" {yylhsminor.yy36 = pik_find_nth(p,yymsp[0].minor.yy36,&yymsp[-2].minor.yy0);} #line 2903 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 88: /* objectname ::= THIS */ #line 732 "pikchr.y" {yymsp[0].minor.yy36 = p->cur;} #line 2909 "pikchr.c" break; case 89: /* objectname ::= PLACENAME */ #line 733 "pikchr.y" {yylhsminor.yy36 = pik_find_byname(p,0,&yymsp[0].minor.yy0);} #line 2914 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 90: /* objectname ::= objectname DOT_U PLACENAME */ #line 735 "pikchr.y" {yylhsminor.yy36 = pik_find_byname(p,yymsp[-2].minor.yy36,&yymsp[0].minor.yy0);} #line 2920 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 91: /* nth ::= NTH CLASSNAME */ #line 737 "pikchr.y" {yylhsminor.yy0=yymsp[0].minor.yy0; yylhsminor.yy0.eCode = pik_nth_value(p,&yymsp[-1].minor.yy0); } #line 2926 "pikchr.c" yymsp[-1].minor.yy0 = yylhsminor.yy0; break; case 92: /* nth ::= NTH LAST CLASSNAME */ #line 738 "pikchr.y" {yylhsminor.yy0=yymsp[0].minor.yy0; yylhsminor.yy0.eCode = -pik_nth_value(p,&yymsp[-2].minor.yy0); } #line 2932 "pikchr.c" yymsp[-2].minor.yy0 = yylhsminor.yy0; break; case 93: /* nth ::= LAST CLASSNAME */ #line 739 "pikchr.y" {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.eCode = -1;} #line 2938 "pikchr.c" break; case 94: /* nth ::= LAST */ #line 740 "pikchr.y" {yylhsminor.yy0=yymsp[0].minor.yy0; yylhsminor.yy0.eCode = -1;} #line 2943 "pikchr.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 95: /* nth ::= NTH LB RB */ #line 741 "pikchr.y" {yylhsminor.yy0=yymsp[-1].minor.yy0; yylhsminor.yy0.eCode = pik_nth_value(p,&yymsp[-2].minor.yy0);} #line 2949 "pikchr.c" yymsp[-2].minor.yy0 = yylhsminor.yy0; break; case 96: /* nth ::= NTH LAST LB RB */ #line 742 "pikchr.y" {yylhsminor.yy0=yymsp[-1].minor.yy0; yylhsminor.yy0.eCode = -pik_nth_value(p,&yymsp[-3].minor.yy0);} #line 2955 "pikchr.c" yymsp[-3].minor.yy0 = yylhsminor.yy0; break; case 97: /* nth ::= LAST LB RB */ #line 743 "pikchr.y" {yymsp[-2].minor.yy0=yymsp[-1].minor.yy0; yymsp[-2].minor.yy0.eCode = -1; } #line 2961 "pikchr.c" break; case 98: /* expr ::= expr PLUS expr */ #line 745 "pikchr.y" {yylhsminor.yy153=yymsp[-2].minor.yy153+yymsp[0].minor.yy153;} #line 2966 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 99: /* expr ::= expr MINUS expr */ #line 746 "pikchr.y" {yylhsminor.yy153=yymsp[-2].minor.yy153-yymsp[0].minor.yy153;} #line 2972 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 100: /* expr ::= expr STAR expr */ #line 747 "pikchr.y" {yylhsminor.yy153=yymsp[-2].minor.yy153*yymsp[0].minor.yy153;} #line 2978 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 101: /* expr ::= expr SLASH expr */ #line 748 "pikchr.y" { if( yymsp[0].minor.yy153==0.0 ){ pik_error(p, &yymsp[-1].minor.yy0, "division by zero"); yylhsminor.yy153 = 0.0; } else{ yylhsminor.yy153 = yymsp[-2].minor.yy153/yymsp[0].minor.yy153; } } #line 2987 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 102: /* expr ::= MINUS expr */ #line 752 "pikchr.y" {yymsp[-1].minor.yy153=-yymsp[0].minor.yy153;} #line 2993 "pikchr.c" break; case 103: /* expr ::= PLUS expr */ #line 753 "pikchr.y" {yymsp[-1].minor.yy153=yymsp[0].minor.yy153;} #line 2998 "pikchr.c" break; case 104: /* expr ::= LP expr RP */ #line 754 "pikchr.y" {yymsp[-2].minor.yy153=yymsp[-1].minor.yy153;} #line 3003 "pikchr.c" break; case 105: /* expr ::= LP FILL|COLOR|THICKNESS RP */ #line 755 "pikchr.y" {yymsp[-2].minor.yy153=pik_get_var(p,&yymsp[-1].minor.yy0);} #line 3008 "pikchr.c" break; case 106: /* expr ::= NUMBER */ #line 756 "pikchr.y" {yylhsminor.yy153=pik_atof(&yymsp[0].minor.yy0);} #line 3013 "pikchr.c" yymsp[0].minor.yy153 = yylhsminor.yy153; break; case 107: /* expr ::= ID */ #line 757 "pikchr.y" {yylhsminor.yy153=pik_get_var(p,&yymsp[0].minor.yy0);} #line 3019 "pikchr.c" yymsp[0].minor.yy153 = yylhsminor.yy153; break; case 108: /* expr ::= FUNC1 LP expr RP */ #line 758 "pikchr.y" {yylhsminor.yy153 = pik_func(p,&yymsp[-3].minor.yy0,yymsp[-1].minor.yy153,0.0);} #line 3025 "pikchr.c" yymsp[-3].minor.yy153 = yylhsminor.yy153; break; case 109: /* expr ::= FUNC2 LP expr COMMA expr RP */ #line 759 "pikchr.y" {yylhsminor.yy153 = pik_func(p,&yymsp[-5].minor.yy0,yymsp[-3].minor.yy153,yymsp[-1].minor.yy153);} #line 3031 "pikchr.c" yymsp[-5].minor.yy153 = yylhsminor.yy153; break; case 110: /* expr ::= DIST LP position COMMA position RP */ #line 760 "pikchr.y" {yymsp[-5].minor.yy153 = pik_dist(&yymsp[-3].minor.yy79,&yymsp[-1].minor.yy79);} #line 3037 "pikchr.c" break; case 111: /* expr ::= place2 DOT_XY X */ #line 761 "pikchr.y" {yylhsminor.yy153 = yymsp[-2].minor.yy79.x;} #line 3042 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 112: /* expr ::= place2 DOT_XY Y */ #line 762 "pikchr.y" {yylhsminor.yy153 = yymsp[-2].minor.yy79.y;} #line 3048 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 113: /* expr ::= object DOT_L numproperty */ case 114: /* expr ::= object DOT_L dashproperty */ yytestcase(yyruleno==114); case 115: /* expr ::= object DOT_L colorproperty */ yytestcase(yyruleno==115); #line 763 "pikchr.y" {yylhsminor.yy153=pik_property_of(yymsp[-2].minor.yy36,&yymsp[0].minor.yy0);} #line 3056 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; default: /* (116) lvalue ::= ID */ yytestcase(yyruleno==116); /* (117) lvalue ::= FILL */ yytestcase(yyruleno==117); /* (118) lvalue ::= COLOR */ yytestcase(yyruleno==118); /* (119) lvalue ::= THICKNESS */ yytestcase(yyruleno==119); |
︙ | ︙ | |||
3126 3127 3128 3129 3130 3131 3132 | int yymajor, /* The major type of the error token */ pik_parserTOKENTYPE yyminor /* The minor type of the error token */ ){ pik_parserARG_FETCH pik_parserCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ | | | | 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 | int yymajor, /* The major type of the error token */ pik_parserTOKENTYPE yyminor /* The minor type of the error token */ ){ pik_parserARG_FETCH pik_parserCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ #line 523 "pikchr.y" if( TOKEN.z && TOKEN.z[0] ){ pik_error(p, &TOKEN, "syntax error"); }else{ pik_error(p, 0, "syntax error"); } UNUSED_PARAMETER(yymajor); #line 3167 "pikchr.c" /************ End %syntax_error code ******************************************/ pik_parserARG_STORE /* Suppress warning about unused %extra_argument variable */ pik_parserCTX_STORE } /* ** The following is executed when the parser accepts |
︙ | ︙ | |||
3367 3368 3369 3370 3371 3372 3373 | assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif } | | | 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 | assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif } #line 768 "pikchr.y" /* Chart of the 148 official CSS color names with their ** corresponding RGB values thru Color Module Level 4: ** https://developer.mozilla.org/en-US/docs/Web/CSS/color_value ** |
︙ | ︙ | |||
5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 | } /* Return true if a bounding box is empty. */ static int pik_bbox_isempty(PBox *p){ return p->sw.x>p->ne.x; } /* Initialize a bounding box to an empty container */ static void pik_bbox_init(PBox *p){ p->sw.x = 1.0; p->sw.y = 1.0; p->ne.x = 0.0; | > > > > > > > > > > > | 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 | } /* Return true if a bounding box is empty. */ static int pik_bbox_isempty(PBox *p){ return p->sw.x>p->ne.x; } /* Return true if point pPt is contained within the bounding box pBox */ static int pik_bbox_contains_point(PBox *pBox, PPoint *pPt){ if( pik_bbox_isempty(pBox) ) return 0; if( pPt->x < pBox->sw.x ) return 0; if( pPt->x > pBox->ne.x ) return 0; if( pPt->y < pBox->sw.y ) return 0; if( pPt->y > pBox->ne.y ) return 0; return 1; } /* Initialize a bounding box to an empty container */ static void pik_bbox_init(PBox *p){ p->sw.x = 1.0; p->sw.y = 1.0; p->ne.x = 0.0; |
︙ | ︙ | |||
6633 6634 6635 6636 6637 6638 6639 | memcpy(pObj->zName,pName->z,pName->n); pObj->zName[pName->n] = 0; } return; } /* | | > > | > | | | 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 | memcpy(pObj->zName,pName->z,pName->n); pObj->zName[pName->n] = 0; } return; } /* ** Search for object located at *pCenter that has an xChop method and ** that does not enclose point pOther. ** ** Return a pointer to the object, or NULL if not found. */ static PObj *pik_find_chopper(PList *pList, PPoint *pCenter, PPoint *pOther){ int i; if( pList==0 ) return 0; for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; if( pObj->type->xChop!=0 && pObj->ptAt.x==pCenter->x && pObj->ptAt.y==pCenter->y && !pik_bbox_contains_point(&pObj->bbox, pOther) ){ return pObj; }else if( pObj->pSublist ){ pObj = pik_find_chopper(pObj->pSublist,pCenter,pOther); if( pObj ) return pObj; } } return 0; } /* ** There is a line traveling from pFrom to pTo. ** ** If point pTo is the exact enter of a choppable object, ** then adjust pTo by the appropriate amount in the direction ** of pFrom. */ static void pik_autochop(Pik *p, PPoint *pFrom, PPoint *pTo){ PObj *pObj = pik_find_chopper(p->list, pTo, pFrom); if( pObj ){ *pTo = pObj->type->xChop(p, pObj, pFrom); } } /* This routine runs after all attributes have been received ** on an object. |
︙ | ︙ | |||
8024 8025 8026 8027 8028 8029 8030 | return TCL_OK; } #endif /* PIKCHR_TCL */ | | | 8039 8040 8041 8042 8043 8044 8045 8046 | return TCL_OK; } #endif /* PIKCHR_TCL */ #line 8071 "pikchr.c" |
Changes to pikchr.y.
︙ | ︙ | |||
449 450 451 452 453 454 455 456 457 458 459 460 461 462 | static void pik_close_path(Pik*,PToken*); static void pik_set_at(Pik*,PToken*,PPoint*,PToken*); static short int pik_nth_value(Pik*,PToken*); static PObj *pik_find_nth(Pik*,PObj*,PToken*); static PObj *pik_find_byname(Pik*,PObj*,PToken*); static PPoint pik_place_of_elem(Pik*,PObj*,PToken*); static int pik_bbox_isempty(PBox*); static void pik_bbox_init(PBox*); static void pik_bbox_addbox(PBox*,PBox*); static void pik_bbox_add_xy(PBox*,PNum,PNum); static void pik_bbox_addellipse(PBox*,PNum x,PNum y,PNum rx,PNum ry); static void pik_add_txt(Pik*,PToken*,int); static int pik_text_length(const PToken *pToken); static void pik_size_to_fit(Pik*,PToken*,int); | > | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | static void pik_close_path(Pik*,PToken*); static void pik_set_at(Pik*,PToken*,PPoint*,PToken*); static short int pik_nth_value(Pik*,PToken*); static PObj *pik_find_nth(Pik*,PObj*,PToken*); static PObj *pik_find_byname(Pik*,PObj*,PToken*); static PPoint pik_place_of_elem(Pik*,PObj*,PToken*); static int pik_bbox_isempty(PBox*); static int pik_bbox_contains_point(PBox*,PPoint*); static void pik_bbox_init(PBox*); static void pik_bbox_addbox(PBox*,PBox*); static void pik_bbox_add_xy(PBox*,PNum,PNum); static void pik_bbox_addellipse(PBox*,PNum x,PNum y,PNum rx,PNum ry); static void pik_add_txt(Pik*,PToken*,int); static int pik_text_length(const PToken *pToken); static void pik_size_to_fit(Pik*,PToken*,int); |
︙ | ︙ | |||
2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 | } /* Return true if a bounding box is empty. */ static int pik_bbox_isempty(PBox *p){ return p->sw.x>p->ne.x; } /* Initialize a bounding box to an empty container */ static void pik_bbox_init(PBox *p){ p->sw.x = 1.0; p->sw.y = 1.0; p->ne.x = 0.0; | > > > > > > > > > > > | 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 | } /* Return true if a bounding box is empty. */ static int pik_bbox_isempty(PBox *p){ return p->sw.x>p->ne.x; } /* Return true if point pPt is contained within the bounding box pBox */ static int pik_bbox_contains_point(PBox *pBox, PPoint *pPt){ if( pik_bbox_isempty(pBox) ) return 0; if( pPt->x < pBox->sw.x ) return 0; if( pPt->x > pBox->ne.x ) return 0; if( pPt->y < pBox->sw.y ) return 0; if( pPt->y > pBox->ne.y ) return 0; return 1; } /* Initialize a bounding box to an empty container */ static void pik_bbox_init(PBox *p){ p->sw.x = 1.0; p->sw.y = 1.0; p->ne.x = 0.0; |
︙ | ︙ | |||
4025 4026 4027 4028 4029 4030 4031 | memcpy(pObj->zName,pName->z,pName->n); pObj->zName[pName->n] = 0; } return; } /* | | > > | > | | | 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 | memcpy(pObj->zName,pName->z,pName->n); pObj->zName[pName->n] = 0; } return; } /* ** Search for object located at *pCenter that has an xChop method and ** that does not enclose point pOther. ** ** Return a pointer to the object, or NULL if not found. */ static PObj *pik_find_chopper(PList *pList, PPoint *pCenter, PPoint *pOther){ int i; if( pList==0 ) return 0; for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; if( pObj->type->xChop!=0 && pObj->ptAt.x==pCenter->x && pObj->ptAt.y==pCenter->y && !pik_bbox_contains_point(&pObj->bbox, pOther) ){ return pObj; }else if( pObj->pSublist ){ pObj = pik_find_chopper(pObj->pSublist,pCenter,pOther); if( pObj ) return pObj; } } return 0; } /* ** There is a line traveling from pFrom to pTo. ** ** If point pTo is the exact enter of a choppable object, ** then adjust pTo by the appropriate amount in the direction ** of pFrom. */ static void pik_autochop(Pik *p, PPoint *pFrom, PPoint *pTo){ PObj *pObj = pik_find_chopper(p->list, pTo, pFrom); if( pObj ){ *pTo = pObj->type->xChop(p, pObj, pFrom); } } /* This routine runs after all attributes have been received ** on an object. |
︙ | ︙ |
Added tests/autochop08.pikchr.
> > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 | circle "C0" move circle "C1" box at C0.c width 11cm height 2.5cm arrow from C0 to C1 chop color red move text "bug report 2021-07-17" \ "forum 73eea815afda0715" \ "arrow C0 to C1 chopped" \ "C0 and box have same center" \ at 0.5 between last box.w and C0.w |