Overview
Comment: | 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 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2090a12c76d960e1aaeb6ca48ec74ece |
User & Date: | drh 2021-07-17 19:25:18 |
References
2021-07-17
| ||
19:27 | • Reply: Bug when connecting circles with chopped arrow (artifact: cd5916b576 user: drh) | |
Context
2021-07-17
| ||
19:36 | Comment improvements. No changes to executable code. (check-in: 6f3e2f6141 user: drh tags: trunk) | |
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) | |
Changes
Changes to Makefile.
︙ | ︙ | |||
34 35 36 37 38 39 40 | echo >> piktcl/pkgIndex.tcl \ "package ifneeded $(TCL_PACKAGE_NAME) $(TCL_PACKAGE_VERSION) [list load [file join" '$$dir' "libpikchr.so]]" lemon: lemon.c $(CC) $(CFLAGS) lemon.c -o lemon test: pikchr | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | echo >> piktcl/pkgIndex.tcl \ "package ifneeded $(TCL_PACKAGE_NAME) $(TCL_PACKAGE_VERSION) [list load [file join" '$$dir' "libpikchr.so]]" lemon: lemon.c $(CC) $(CFLAGS) lemon.c -o lemon test: pikchr ./pikchr tests/*.pikchr >out.html || true open out.html || true ./pikchr --dark-mode */*.pikchr >darkmode.html || true open darkmode.html clean: rm -f pikchr pikchr.c pikchr.h pikchr.out lemon out.html |
Changes to pikchr.c.
︙ | ︙ | |||
315 316 317 318 319 320 321 322 323 324 325 326 327 328 | unsigned mProp; /* Masks of properties set so far */ unsigned mCalc; /* Values computed from other constraints */ PToken aTxt[5]; /* Text with .eCode holding TP flags */ int iLayer; /* Rendering order */ int inDir, outDir; /* Entry and exit directions */ int nPath; /* Number of path points */ PPoint *aPath; /* Array of path points */ PBox bbox; /* Bounding box */ }; /* A list of graphics objects */ struct PList { int n; /* Number of statements in the list */ int nAlloc; /* Allocated slots in a[] */ | > | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | unsigned mProp; /* Masks of properties set so far */ unsigned mCalc; /* Values computed from other constraints */ PToken aTxt[5]; /* Text with .eCode holding TP flags */ int iLayer; /* Rendering order */ int inDir, outDir; /* Entry and exit directions */ int nPath; /* Number of path points */ PPoint *aPath; /* Array of path points */ PObj *pFrom, *pTo; /* End-point objects of a path */ PBox bbox; /* Bounding box */ }; /* A list of graphics objects */ struct PList { int n; /* Number of statements in the list */ int nAlloc; /* Allocated slots in a[] */ |
︙ | ︙ | |||
345 346 347 348 349 350 351 352 353 354 355 356 357 358 | PToken sIn; /* Input Pikchr-language text */ char *zOut; /* Result accumulates here */ unsigned int nOut; /* Bytes written to zOut[] so far */ unsigned int nOutAlloc; /* Space allocated to zOut[] */ unsigned char eDir; /* Current direction */ unsigned int mFlags; /* Flags passed to pikchr() */ PObj *cur; /* Object under construction */ PList *list; /* Object list under construction */ PMacro *pMacros; /* List of all defined macros */ PVar *pVar; /* Application-defined variables */ PBox bbox; /* Bounding box around all statements */ /* Cache of layout values. <=0.0 for unknown... */ PNum rScale; /* Multiply to convert inches to pixels */ PNum fontScale; /* Scale fonts by this percent */ | > | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | PToken sIn; /* Input Pikchr-language text */ char *zOut; /* Result accumulates here */ unsigned int nOut; /* Bytes written to zOut[] so far */ unsigned int nOutAlloc; /* Space allocated to zOut[] */ unsigned char eDir; /* Current direction */ unsigned int mFlags; /* Flags passed to pikchr() */ PObj *cur; /* Object under construction */ PObj *lastRef; /* Last object references by "place" */ PList *list; /* Object list under construction */ PMacro *pMacros; /* List of all defined macros */ PVar *pVar; /* Application-defined variables */ PBox bbox; /* Bounding box around all statements */ /* Cache of layout values. <=0.0 for unknown... */ PNum rScale; /* Multiply to convert inches to pixels */ PNum fontScale; /* Scale fonts by this percent */ |
︙ | ︙ | |||
475 476 477 478 479 480 481 | 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); | | | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | 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 510 "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 |
︙ | ︙ | |||
1704 1705 1706 1707 1708 1709 1710 | ** 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 */ { | | | | | | 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 | ** 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 499 "pikchr.y" pik_elist_free(p,(yypminor->yy227)); #line 1740 "pikchr.c" } break; case 100: /* statement */ case 101: /* unnamed_statement */ case 102: /* basetype */ { #line 501 "pikchr.y" pik_elem_free(p,(yypminor->yy36)); #line 1749 "pikchr.c" } break; /********* End destructor definitions *****************************************/ default: break; /* If no destructor action specified: do nothing */ } } |
︙ | ︙ | |||
1933 1934 1935 1936 1937 1938 1939 | 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 ******************************************/ | | | | 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 | 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 533 "pikchr.y" pik_error(p, 0, "parser stack overflow"); #line 1970 "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 |
︙ | ︙ | |||
2416 2417 2418 2419 2420 2421 2422 | ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* document ::= statement_list */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 3039 3040 | ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* document ::= statement_list */ #line 537 "pikchr.y" {pik_render(p,yymsp[0].minor.yy227);} #line 2452 "pikchr.c" break; case 1: /* statement_list ::= statement */ #line 540 "pikchr.y" { yylhsminor.yy227 = pik_elist_append(p,0,yymsp[0].minor.yy36); } #line 2457 "pikchr.c" yymsp[0].minor.yy227 = yylhsminor.yy227; break; case 2: /* statement_list ::= statement_list EOL statement */ #line 542 "pikchr.y" { yylhsminor.yy227 = pik_elist_append(p,yymsp[-2].minor.yy227,yymsp[0].minor.yy36); } #line 2463 "pikchr.c" yymsp[-2].minor.yy227 = yylhsminor.yy227; break; case 3: /* statement ::= */ #line 545 "pikchr.y" { yymsp[1].minor.yy36 = 0; } #line 2469 "pikchr.c" break; case 4: /* statement ::= direction */ #line 546 "pikchr.y" { pik_set_direction(p,yymsp[0].minor.yy0.eCode); yylhsminor.yy36=0; } #line 2474 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 5: /* statement ::= lvalue ASSIGN rvalue */ #line 547 "pikchr.y" {pik_set_var(p,&yymsp[-2].minor.yy0,yymsp[0].minor.yy153,&yymsp[-1].minor.yy0); yylhsminor.yy36=0;} #line 2480 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 6: /* statement ::= PLACENAME COLON unnamed_statement */ #line 549 "pikchr.y" { yylhsminor.yy36 = yymsp[0].minor.yy36; pik_elem_setname(p,yymsp[0].minor.yy36,&yymsp[-2].minor.yy0); } #line 2486 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 7: /* statement ::= PLACENAME COLON position */ #line 551 "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 2493 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 8: /* statement ::= unnamed_statement */ #line 553 "pikchr.y" {yylhsminor.yy36 = yymsp[0].minor.yy36;} #line 2499 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 9: /* statement ::= print prlist */ #line 554 "pikchr.y" {pik_append(p,"<br>\n",5); yymsp[-1].minor.yy36=0;} #line 2505 "pikchr.c" break; case 10: /* statement ::= ASSERT LP expr EQ expr RP */ #line 559 "pikchr.y" {yymsp[-5].minor.yy36=pik_assert(p,yymsp[-3].minor.yy153,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy153);} #line 2510 "pikchr.c" break; case 11: /* statement ::= ASSERT LP position EQ position RP */ #line 561 "pikchr.y" {yymsp[-5].minor.yy36=pik_position_assert(p,&yymsp[-3].minor.yy79,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy79);} #line 2515 "pikchr.c" break; case 12: /* statement ::= DEFINE ID CODEBLOCK */ #line 562 "pikchr.y" {yymsp[-2].minor.yy36=0; pik_add_macro(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} #line 2520 "pikchr.c" break; case 13: /* rvalue ::= PLACENAME */ #line 573 "pikchr.y" {yylhsminor.yy153 = pik_lookup_color(p,&yymsp[0].minor.yy0);} #line 2525 "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 578 "pikchr.y" {pik_append_num(p,"",pik_value(p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.n,0));} #line 2533 "pikchr.c" break; case 17: /* pritem ::= rvalue */ #line 581 "pikchr.y" {pik_append_num(p,"",yymsp[0].minor.yy153);} #line 2538 "pikchr.c" break; case 18: /* pritem ::= STRING */ #line 582 "pikchr.y" {pik_append_text(p,yymsp[0].minor.yy0.z+1,yymsp[0].minor.yy0.n-2,0);} #line 2543 "pikchr.c" break; case 19: /* prsep ::= COMMA */ #line 583 "pikchr.y" {pik_append(p, " ", 1);} #line 2548 "pikchr.c" break; case 20: /* unnamed_statement ::= basetype attribute_list */ #line 586 "pikchr.y" {yylhsminor.yy36 = yymsp[-1].minor.yy36; pik_after_adding_attributes(p,yylhsminor.yy36);} #line 2553 "pikchr.c" yymsp[-1].minor.yy36 = yylhsminor.yy36; break; case 21: /* basetype ::= CLASSNAME */ #line 588 "pikchr.y" {yylhsminor.yy36 = pik_elem_new(p,&yymsp[0].minor.yy0,0,0); } #line 2559 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 22: /* basetype ::= STRING textposition */ #line 590 "pikchr.y" {yymsp[-1].minor.yy0.eCode = yymsp[0].minor.yy164; yylhsminor.yy36 = pik_elem_new(p,0,&yymsp[-1].minor.yy0,0); } #line 2565 "pikchr.c" yymsp[-1].minor.yy36 = yylhsminor.yy36; break; case 23: /* basetype ::= LB savelist statement_list RB */ #line 592 "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 2571 "pikchr.c" break; case 24: /* savelist ::= */ #line 597 "pikchr.y" {yymsp[1].minor.yy227 = p->list; p->list = 0;} #line 2576 "pikchr.c" break; case 25: /* relexpr ::= expr */ #line 604 "pikchr.y" {yylhsminor.yy10.rAbs = yymsp[0].minor.yy153; yylhsminor.yy10.rRel = 0;} #line 2581 "pikchr.c" yymsp[0].minor.yy10 = yylhsminor.yy10; break; case 26: /* relexpr ::= expr PERCENT */ #line 605 "pikchr.y" {yylhsminor.yy10.rAbs = 0; yylhsminor.yy10.rRel = yymsp[-1].minor.yy153/100;} #line 2587 "pikchr.c" yymsp[-1].minor.yy10 = yylhsminor.yy10; break; case 27: /* optrelexpr ::= */ #line 607 "pikchr.y" {yymsp[1].minor.yy10.rAbs = 0; yymsp[1].minor.yy10.rRel = 1.0;} #line 2593 "pikchr.c" break; case 28: /* attribute_list ::= relexpr alist */ #line 609 "pikchr.y" {pik_add_direction(p,0,&yymsp[-1].minor.yy10);} #line 2598 "pikchr.c" break; case 29: /* attribute ::= numproperty relexpr */ #line 613 "pikchr.y" { pik_set_numprop(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy10); } #line 2603 "pikchr.c" break; case 30: /* attribute ::= dashproperty expr */ #line 614 "pikchr.y" { pik_set_dashed(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy153); } #line 2608 "pikchr.c" break; case 31: /* attribute ::= dashproperty */ #line 615 "pikchr.y" { pik_set_dashed(p,&yymsp[0].minor.yy0,0); } #line 2613 "pikchr.c" break; case 32: /* attribute ::= colorproperty rvalue */ #line 616 "pikchr.y" { pik_set_clrprop(p,&yymsp[-1].minor.yy0,yymsp[0].minor.yy153); } #line 2618 "pikchr.c" break; case 33: /* attribute ::= go direction optrelexpr */ #line 617 "pikchr.y" { pik_add_direction(p,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy10);} #line 2623 "pikchr.c" break; case 34: /* attribute ::= go direction even position */ #line 618 "pikchr.y" {pik_evenwith(p,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy79);} #line 2628 "pikchr.c" break; case 35: /* attribute ::= CLOSE */ #line 619 "pikchr.y" { pik_close_path(p,&yymsp[0].minor.yy0); } #line 2633 "pikchr.c" break; case 36: /* attribute ::= CHOP */ #line 620 "pikchr.y" { p->cur->bChop = 1; } #line 2638 "pikchr.c" break; case 37: /* attribute ::= FROM position */ #line 621 "pikchr.y" { pik_set_from(p,p->cur,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy79); } #line 2643 "pikchr.c" break; case 38: /* attribute ::= TO position */ #line 622 "pikchr.y" { pik_add_to(p,p->cur,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy79); } #line 2648 "pikchr.c" break; case 39: /* attribute ::= THEN */ #line 623 "pikchr.y" { pik_then(p, &yymsp[0].minor.yy0, p->cur); } #line 2653 "pikchr.c" break; case 40: /* attribute ::= THEN optrelexpr HEADING expr */ case 42: /* attribute ::= GO optrelexpr HEADING expr */ yytestcase(yyruleno==42); #line 625 "pikchr.y" {pik_move_hdg(p,&yymsp[-2].minor.yy10,&yymsp[-1].minor.yy0,yymsp[0].minor.yy153,0,&yymsp[-3].minor.yy0);} #line 2659 "pikchr.c" break; case 41: /* attribute ::= THEN optrelexpr EDGEPT */ case 43: /* attribute ::= GO optrelexpr EDGEPT */ yytestcase(yyruleno==43); #line 626 "pikchr.y" {pik_move_hdg(p,&yymsp[-1].minor.yy10,0,0,&yymsp[0].minor.yy0,&yymsp[-2].minor.yy0);} #line 2665 "pikchr.c" break; case 44: /* attribute ::= AT position */ #line 631 "pikchr.y" { pik_set_at(p,0,&yymsp[0].minor.yy79,&yymsp[-1].minor.yy0); } #line 2670 "pikchr.c" break; case 45: /* attribute ::= SAME */ #line 633 "pikchr.y" {pik_same(p,0,&yymsp[0].minor.yy0);} #line 2675 "pikchr.c" break; case 46: /* attribute ::= SAME AS object */ #line 634 "pikchr.y" {pik_same(p,yymsp[0].minor.yy36,&yymsp[-2].minor.yy0);} #line 2680 "pikchr.c" break; case 47: /* attribute ::= STRING textposition */ #line 635 "pikchr.y" {pik_add_txt(p,&yymsp[-1].minor.yy0,yymsp[0].minor.yy164);} #line 2685 "pikchr.c" break; case 48: /* attribute ::= FIT */ #line 636 "pikchr.y" {pik_size_to_fit(p,&yymsp[0].minor.yy0,3); } #line 2690 "pikchr.c" break; case 49: /* attribute ::= BEHIND object */ #line 637 "pikchr.y" {pik_behind(p,yymsp[0].minor.yy36);} #line 2695 "pikchr.c" break; case 50: /* withclause ::= DOT_E edge AT position */ case 51: /* withclause ::= edge AT position */ yytestcase(yyruleno==51); #line 645 "pikchr.y" { pik_set_at(p,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy79,&yymsp[-1].minor.yy0); } #line 2701 "pikchr.c" break; case 52: /* numproperty ::= HEIGHT|WIDTH|RADIUS|DIAMETER|THICKNESS */ #line 649 "pikchr.y" {yylhsminor.yy0 = yymsp[0].minor.yy0;} #line 2706 "pikchr.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 53: /* boolproperty ::= CW */ #line 660 "pikchr.y" {p->cur->cw = 1;} #line 2712 "pikchr.c" break; case 54: /* boolproperty ::= CCW */ #line 661 "pikchr.y" {p->cur->cw = 0;} #line 2717 "pikchr.c" break; case 55: /* boolproperty ::= LARROW */ #line 662 "pikchr.y" {p->cur->larrow=1; p->cur->rarrow=0; } #line 2722 "pikchr.c" break; case 56: /* boolproperty ::= RARROW */ #line 663 "pikchr.y" {p->cur->larrow=0; p->cur->rarrow=1; } #line 2727 "pikchr.c" break; case 57: /* boolproperty ::= LRARROW */ #line 664 "pikchr.y" {p->cur->larrow=1; p->cur->rarrow=1; } #line 2732 "pikchr.c" break; case 58: /* boolproperty ::= INVIS */ #line 665 "pikchr.y" {p->cur->sw = 0.0;} #line 2737 "pikchr.c" break; case 59: /* boolproperty ::= THICK */ #line 666 "pikchr.y" {p->cur->sw *= 1.5;} #line 2742 "pikchr.c" break; case 60: /* boolproperty ::= THIN */ #line 667 "pikchr.y" {p->cur->sw *= 0.67;} #line 2747 "pikchr.c" break; case 61: /* boolproperty ::= SOLID */ #line 668 "pikchr.y" {p->cur->sw = pik_value(p,"thickness",9,0); p->cur->dotted = p->cur->dashed = 0.0;} #line 2753 "pikchr.c" break; case 62: /* textposition ::= */ #line 671 "pikchr.y" {yymsp[1].minor.yy164 = 0;} #line 2758 "pikchr.c" break; case 63: /* textposition ::= textposition CENTER|LJUST|RJUST|ABOVE|BELOW|ITALIC|BOLD|ALIGNED|BIG|SMALL */ #line 674 "pikchr.y" {yylhsminor.yy164 = (short int)pik_text_position(yymsp[-1].minor.yy164,&yymsp[0].minor.yy0);} #line 2763 "pikchr.c" yymsp[-1].minor.yy164 = yylhsminor.yy164; break; case 64: /* position ::= expr COMMA expr */ #line 677 "pikchr.y" {yylhsminor.yy79.x=yymsp[-2].minor.yy153; yylhsminor.yy79.y=yymsp[0].minor.yy153;} #line 2769 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 65: /* position ::= place PLUS expr COMMA expr */ #line 679 "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 2775 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 66: /* position ::= place MINUS expr COMMA expr */ #line 680 "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 2781 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 67: /* position ::= place PLUS 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 2787 "pikchr.c" yymsp[-6].minor.yy79 = yylhsminor.yy79; break; case 68: /* position ::= place MINUS LP expr COMMA expr RP */ #line 684 "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 2793 "pikchr.c" yymsp[-6].minor.yy79 = yylhsminor.yy79; break; case 69: /* position ::= LP position COMMA position RP */ #line 685 "pikchr.y" {yymsp[-4].minor.yy79.x=yymsp[-3].minor.yy79.x; yymsp[-4].minor.yy79.y=yymsp[-1].minor.yy79.y;} #line 2799 "pikchr.c" break; case 70: /* position ::= LP position RP */ #line 686 "pikchr.y" {yymsp[-2].minor.yy79=yymsp[-1].minor.yy79;} #line 2804 "pikchr.c" break; case 71: /* position ::= expr between position AND position */ #line 688 "pikchr.y" {yylhsminor.yy79 = pik_position_between(yymsp[-4].minor.yy153,yymsp[-2].minor.yy79,yymsp[0].minor.yy79);} #line 2809 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 72: /* position ::= expr LT position COMMA position GT */ #line 690 "pikchr.y" {yylhsminor.yy79 = pik_position_between(yymsp[-5].minor.yy153,yymsp[-3].minor.yy79,yymsp[-1].minor.yy79);} #line 2815 "pikchr.c" yymsp[-5].minor.yy79 = yylhsminor.yy79; break; case 73: /* position ::= expr ABOVE position */ #line 691 "pikchr.y" {yylhsminor.yy79=yymsp[0].minor.yy79; yylhsminor.yy79.y += yymsp[-2].minor.yy153;} #line 2821 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 74: /* position ::= expr BELOW position */ #line 692 "pikchr.y" {yylhsminor.yy79=yymsp[0].minor.yy79; yylhsminor.yy79.y -= yymsp[-2].minor.yy153;} #line 2827 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 75: /* position ::= expr LEFT OF position */ #line 693 "pikchr.y" {yylhsminor.yy79=yymsp[0].minor.yy79; yylhsminor.yy79.x -= yymsp[-3].minor.yy153;} #line 2833 "pikchr.c" yymsp[-3].minor.yy79 = yylhsminor.yy79; break; case 76: /* position ::= expr RIGHT OF position */ #line 694 "pikchr.y" {yylhsminor.yy79=yymsp[0].minor.yy79; yylhsminor.yy79.x += yymsp[-3].minor.yy153;} #line 2839 "pikchr.c" yymsp[-3].minor.yy79 = yylhsminor.yy79; break; case 77: /* position ::= expr ON HEADING EDGEPT OF position */ #line 696 "pikchr.y" {yylhsminor.yy79 = pik_position_at_hdg(yymsp[-5].minor.yy153,&yymsp[-2].minor.yy0,yymsp[0].minor.yy79);} #line 2845 "pikchr.c" yymsp[-5].minor.yy79 = yylhsminor.yy79; break; case 78: /* position ::= expr HEADING EDGEPT OF position */ #line 698 "pikchr.y" {yylhsminor.yy79 = pik_position_at_hdg(yymsp[-4].minor.yy153,&yymsp[-2].minor.yy0,yymsp[0].minor.yy79);} #line 2851 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 79: /* position ::= expr EDGEPT OF position */ #line 700 "pikchr.y" {yylhsminor.yy79 = pik_position_at_hdg(yymsp[-3].minor.yy153,&yymsp[-2].minor.yy0,yymsp[0].minor.yy79);} #line 2857 "pikchr.c" yymsp[-3].minor.yy79 = yylhsminor.yy79; break; case 80: /* position ::= expr ON HEADING expr FROM position */ #line 702 "pikchr.y" {yylhsminor.yy79 = pik_position_at_angle(yymsp[-5].minor.yy153,yymsp[-2].minor.yy153,yymsp[0].minor.yy79);} #line 2863 "pikchr.c" yymsp[-5].minor.yy79 = yylhsminor.yy79; break; case 81: /* position ::= expr HEADING expr FROM position */ #line 704 "pikchr.y" {yylhsminor.yy79 = pik_position_at_angle(yymsp[-4].minor.yy153,yymsp[-2].minor.yy153,yymsp[0].minor.yy79);} #line 2869 "pikchr.c" yymsp[-4].minor.yy79 = yylhsminor.yy79; break; case 82: /* place ::= edge OF object */ #line 716 "pikchr.y" {yylhsminor.yy79 = pik_place_of_elem(p,yymsp[0].minor.yy36,&yymsp[-2].minor.yy0);} #line 2875 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 83: /* place2 ::= object */ #line 717 "pikchr.y" {yylhsminor.yy79 = pik_place_of_elem(p,yymsp[0].minor.yy36,0);} #line 2881 "pikchr.c" yymsp[0].minor.yy79 = yylhsminor.yy79; break; case 84: /* place2 ::= object DOT_E edge */ #line 718 "pikchr.y" {yylhsminor.yy79 = pik_place_of_elem(p,yymsp[-2].minor.yy36,&yymsp[0].minor.yy0);} #line 2887 "pikchr.c" yymsp[-2].minor.yy79 = yylhsminor.yy79; break; case 85: /* place2 ::= NTH VERTEX OF object */ #line 719 "pikchr.y" {yylhsminor.yy79 = pik_nth_vertex(p,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,yymsp[0].minor.yy36);} #line 2893 "pikchr.c" yymsp[-3].minor.yy79 = yylhsminor.yy79; break; case 86: /* object ::= nth */ #line 731 "pikchr.y" {yylhsminor.yy36 = pik_find_nth(p,0,&yymsp[0].minor.yy0);} #line 2899 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 87: /* object ::= nth OF|IN object */ #line 732 "pikchr.y" {yylhsminor.yy36 = pik_find_nth(p,yymsp[0].minor.yy36,&yymsp[-2].minor.yy0);} #line 2905 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 88: /* objectname ::= THIS */ #line 734 "pikchr.y" {yymsp[0].minor.yy36 = p->cur;} #line 2911 "pikchr.c" break; case 89: /* objectname ::= PLACENAME */ #line 735 "pikchr.y" {yylhsminor.yy36 = pik_find_byname(p,0,&yymsp[0].minor.yy0);} #line 2916 "pikchr.c" yymsp[0].minor.yy36 = yylhsminor.yy36; break; case 90: /* objectname ::= objectname DOT_U PLACENAME */ #line 737 "pikchr.y" {yylhsminor.yy36 = pik_find_byname(p,yymsp[-2].minor.yy36,&yymsp[0].minor.yy0);} #line 2922 "pikchr.c" yymsp[-2].minor.yy36 = yylhsminor.yy36; break; case 91: /* nth ::= NTH CLASSNAME */ #line 739 "pikchr.y" {yylhsminor.yy0=yymsp[0].minor.yy0; yylhsminor.yy0.eCode = pik_nth_value(p,&yymsp[-1].minor.yy0); } #line 2928 "pikchr.c" yymsp[-1].minor.yy0 = yylhsminor.yy0; break; case 92: /* nth ::= NTH LAST CLASSNAME */ #line 740 "pikchr.y" {yylhsminor.yy0=yymsp[0].minor.yy0; yylhsminor.yy0.eCode = -pik_nth_value(p,&yymsp[-2].minor.yy0); } #line 2934 "pikchr.c" yymsp[-2].minor.yy0 = yylhsminor.yy0; break; case 93: /* nth ::= LAST CLASSNAME */ #line 741 "pikchr.y" {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.eCode = -1;} #line 2940 "pikchr.c" break; case 94: /* nth ::= LAST */ #line 742 "pikchr.y" {yylhsminor.yy0=yymsp[0].minor.yy0; yylhsminor.yy0.eCode = -1;} #line 2945 "pikchr.c" yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 95: /* nth ::= NTH LB RB */ #line 743 "pikchr.y" {yylhsminor.yy0=yymsp[-1].minor.yy0; yylhsminor.yy0.eCode = pik_nth_value(p,&yymsp[-2].minor.yy0);} #line 2951 "pikchr.c" yymsp[-2].minor.yy0 = yylhsminor.yy0; break; case 96: /* nth ::= NTH LAST LB RB */ #line 744 "pikchr.y" {yylhsminor.yy0=yymsp[-1].minor.yy0; yylhsminor.yy0.eCode = -pik_nth_value(p,&yymsp[-3].minor.yy0);} #line 2957 "pikchr.c" yymsp[-3].minor.yy0 = yylhsminor.yy0; break; case 97: /* nth ::= LAST LB RB */ #line 745 "pikchr.y" {yymsp[-2].minor.yy0=yymsp[-1].minor.yy0; yymsp[-2].minor.yy0.eCode = -1; } #line 2963 "pikchr.c" break; case 98: /* expr ::= expr PLUS expr */ #line 747 "pikchr.y" {yylhsminor.yy153=yymsp[-2].minor.yy153+yymsp[0].minor.yy153;} #line 2968 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 99: /* expr ::= expr MINUS expr */ #line 748 "pikchr.y" {yylhsminor.yy153=yymsp[-2].minor.yy153-yymsp[0].minor.yy153;} #line 2974 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 100: /* expr ::= expr STAR expr */ #line 749 "pikchr.y" {yylhsminor.yy153=yymsp[-2].minor.yy153*yymsp[0].minor.yy153;} #line 2980 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 101: /* expr ::= expr SLASH expr */ #line 750 "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 2989 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 102: /* expr ::= MINUS expr */ #line 754 "pikchr.y" {yymsp[-1].minor.yy153=-yymsp[0].minor.yy153;} #line 2995 "pikchr.c" break; case 103: /* expr ::= PLUS expr */ #line 755 "pikchr.y" {yymsp[-1].minor.yy153=yymsp[0].minor.yy153;} #line 3000 "pikchr.c" break; case 104: /* expr ::= LP expr RP */ #line 756 "pikchr.y" {yymsp[-2].minor.yy153=yymsp[-1].minor.yy153;} #line 3005 "pikchr.c" break; case 105: /* expr ::= LP FILL|COLOR|THICKNESS RP */ #line 757 "pikchr.y" {yymsp[-2].minor.yy153=pik_get_var(p,&yymsp[-1].minor.yy0);} #line 3010 "pikchr.c" break; case 106: /* expr ::= NUMBER */ #line 758 "pikchr.y" {yylhsminor.yy153=pik_atof(&yymsp[0].minor.yy0);} #line 3015 "pikchr.c" yymsp[0].minor.yy153 = yylhsminor.yy153; break; case 107: /* expr ::= ID */ #line 759 "pikchr.y" {yylhsminor.yy153=pik_get_var(p,&yymsp[0].minor.yy0);} #line 3021 "pikchr.c" yymsp[0].minor.yy153 = yylhsminor.yy153; break; case 108: /* expr ::= FUNC1 LP expr RP */ #line 760 "pikchr.y" {yylhsminor.yy153 = pik_func(p,&yymsp[-3].minor.yy0,yymsp[-1].minor.yy153,0.0);} #line 3027 "pikchr.c" yymsp[-3].minor.yy153 = yylhsminor.yy153; break; case 109: /* expr ::= FUNC2 LP expr COMMA expr RP */ #line 761 "pikchr.y" {yylhsminor.yy153 = pik_func(p,&yymsp[-5].minor.yy0,yymsp[-3].minor.yy153,yymsp[-1].minor.yy153);} #line 3033 "pikchr.c" yymsp[-5].minor.yy153 = yylhsminor.yy153; break; case 110: /* expr ::= DIST LP position COMMA position RP */ #line 762 "pikchr.y" {yymsp[-5].minor.yy153 = pik_dist(&yymsp[-3].minor.yy79,&yymsp[-1].minor.yy79);} #line 3039 "pikchr.c" break; case 111: /* expr ::= place2 DOT_XY X */ #line 763 "pikchr.y" {yylhsminor.yy153 = yymsp[-2].minor.yy79.x;} #line 3044 "pikchr.c" yymsp[-2].minor.yy153 = yylhsminor.yy153; break; case 112: /* expr ::= place2 DOT_XY Y */ #line 764 "pikchr.y" {yylhsminor.yy153 = yymsp[-2].minor.yy79.y;} #line 3050 "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 765 "pikchr.y" {yylhsminor.yy153=pik_property_of(yymsp[-2].minor.yy36,&yymsp[0].minor.yy0);} #line 3058 "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); |
︙ | ︙ | |||
3127 3128 3129 3130 3131 3132 3133 | 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 ****************************************/ | | | | 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 | 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 525 "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 3169 "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 |
︙ | ︙ | |||
3368 3369 3370 3371 3372 3373 3374 | assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif } | | | 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 | assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); return yyFallback[iToken]; #else (void)iToken; return 0; #endif } #line 770 "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 ** |
︙ | ︙ | |||
5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 | if( p->mTPath & 1 ) n = pik_next_rpath(p, pDir); p->aTPath[n].x = pPlace->x; p->mTPath |= 1; break; } pObj->outDir = pDir->eCode; } /* Set the "from" of an object */ static void pik_set_from(Pik *p, PObj *pObj, PToken *pTk, PPoint *pPt){ if( !pObj->type->isLine ){ pik_error(p, pTk, "use \"at\" to position this object"); return; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 | if( p->mTPath & 1 ) n = pik_next_rpath(p, pDir); p->aTPath[n].x = pPlace->x; p->mTPath |= 1; break; } pObj->outDir = pDir->eCode; } /* If the last referenced object is centered at point pPt then return ** a pointer to that object. If there is no prior object reference, ** or if the points are not the same, return NULL. ** ** This is a side-channel hack used to find the objects at which a ** line begins and ends. For example, in ** ** arrow from OBJ1 to OBJ2 chop ** ** The arrow object is normally just handed the coordinates of the ** centers for OBJ1 and OBJ2. But we also want to know the specific ** object named in case there are multiple objects centered at the ** same point. ** ** See forum post 1d46e3a0bc */ static PObj *pik_last_ref_object(Pik *p, PPoint *pPt){ PObj *pRes = 0; if( p->lastRef==0 ) return 0; if( p->lastRef->ptAt.x==pPt->x && p->lastRef->ptAt.y==pPt->y ){ pRes = p->lastRef; } p->lastRef = 0; return pRes; } /* Set the "from" of an object */ static void pik_set_from(Pik *p, PObj *pObj, PToken *pTk, PPoint *pPt){ if( !pObj->type->isLine ){ pik_error(p, pTk, "use \"at\" to position this object"); return; |
︙ | ︙ | |||
5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 | p->aTPath[i].x += dx; p->aTPath[i].y += dy; } } p->aTPath[0] = *pPt; p->mTPath = 3; pObj->mProp |= A_FROM; } /* Set the "to" of an object */ static void pik_add_to(Pik *p, PObj *pObj, PToken *pTk, PPoint *pPt){ int n = p->nTPath-1; if( !pObj->type->isLine ){ pik_error(p, pTk, "use \"at\" to position this object"); return; } if( pObj->bClose ){ pik_error(p, pTk, "polygon is closed"); return; } pik_reset_samepath(p); if( n==0 || p->mTPath==3 || p->thenFlag ){ n = pik_next_rpath(p, pTk); } p->aTPath[n] = *pPt; p->mTPath = 3; } static void pik_close_path(Pik *p, PToken *pErr){ PObj *pObj = p->cur; if( p->nTPath<3 ){ pik_error(p, pErr, "need at least 3 vertexes in order to close the polygon"); | > > | 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 | p->aTPath[i].x += dx; p->aTPath[i].y += dy; } } p->aTPath[0] = *pPt; p->mTPath = 3; pObj->mProp |= A_FROM; pObj->pFrom = pik_last_ref_object(p, pPt); } /* Set the "to" of an object */ static void pik_add_to(Pik *p, PObj *pObj, PToken *pTk, PPoint *pPt){ int n = p->nTPath-1; if( !pObj->type->isLine ){ pik_error(p, pTk, "use \"at\" to position this object"); return; } if( pObj->bClose ){ pik_error(p, pTk, "polygon is closed"); return; } pik_reset_samepath(p); if( n==0 || p->mTPath==3 || p->thenFlag ){ n = pik_next_rpath(p, pTk); } p->aTPath[n] = *pPt; p->mTPath = 3; pObj->pTo = pik_last_ref_object(p, pPt); } static void pik_close_path(Pik *p, PToken *pErr){ PObj *pObj = p->cur; if( p->nTPath<3 ){ pik_error(p, pErr, "need at least 3 vertexes in order to close the polygon"); |
︙ | ︙ | |||
6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 | pik_error(p, pName, "no such object"); return 0; } /* First look explicitly tagged objects */ for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; if( pObj->zName && pik_token_eq(pName,pObj->zName)==0 ){ return pObj; } } /* If not found, do a second pass looking for any object containing ** text which exactly matches pName */ for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; for(j=0; j<pObj->nTxt; j++){ if( pObj->aTxt[j].n==pName->n+2 && memcmp(pObj->aTxt[j].z+1,pName->z,pName->n)==0 ){ return pObj; } } } pik_error(p, pName, "no such object"); return 0; } | > > | 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 | pik_error(p, pName, "no such object"); return 0; } /* First look explicitly tagged objects */ for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; if( pObj->zName && pik_token_eq(pName,pObj->zName)==0 ){ p->lastRef = pObj; return pObj; } } /* If not found, do a second pass looking for any object containing ** text which exactly matches pName */ for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; for(j=0; j<pObj->nTxt; j++){ if( pObj->aTxt[j].n==pName->n+2 && memcmp(pObj->aTxt[j].z+1,pName->z,pName->n)==0 ){ p->lastRef = pObj; return pObj; } } } pik_error(p, pName, "no such object"); return 0; } |
︙ | ︙ | |||
6676 6677 6678 6679 6680 6681 6682 | /* ** 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. */ | | > | > | 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 | /* ** 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){ if( pObj==0 || pObj->type->xChop==0 ){ 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. |
︙ | ︙ | |||
6776 6777 6778 6779 6780 6781 6782 | /* "chop" processing: ** If the line goes to the center of an object with an ** xChop method, then use the xChop method to trim the line. */ if( pObj->bChop && pObj->nPath>=2 ){ int n = pObj->nPath; | | | | 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 | /* "chop" processing: ** If the line goes to the center of an object with an ** xChop method, then use the xChop method to trim the line. */ if( pObj->bChop && pObj->nPath>=2 ){ int n = pObj->nPath; pik_autochop(p, &pObj->aPath[n-2], &pObj->aPath[n-1], pObj->pTo); pik_autochop(p, &pObj->aPath[1], &pObj->aPath[0], pObj->pFrom); } pObj->ptEnter = pObj->aPath[0]; pObj->ptExit = pObj->aPath[pObj->nPath-1]; /* Compute the center of the line based on the bounding box over ** the vertexes. This is a difference from PIC. In Pikchr, the |
︙ | ︙ | |||
8039 8040 8041 8042 8043 8044 8045 | return TCL_OK; } #endif /* PIKCHR_TCL */ | | | 8075 8076 8077 8078 8079 8080 8081 8082 | return TCL_OK; } #endif /* PIKCHR_TCL */ #line 8107 "pikchr.c" |
Changes to pikchr.y.
︙ | ︙ | |||
314 315 316 317 318 319 320 321 322 323 324 325 326 327 | unsigned mProp; /* Masks of properties set so far */ unsigned mCalc; /* Values computed from other constraints */ PToken aTxt[5]; /* Text with .eCode holding TP flags */ int iLayer; /* Rendering order */ int inDir, outDir; /* Entry and exit directions */ int nPath; /* Number of path points */ PPoint *aPath; /* Array of path points */ PBox bbox; /* Bounding box */ }; /* A list of graphics objects */ struct PList { int n; /* Number of statements in the list */ int nAlloc; /* Allocated slots in a[] */ | > | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | unsigned mProp; /* Masks of properties set so far */ unsigned mCalc; /* Values computed from other constraints */ PToken aTxt[5]; /* Text with .eCode holding TP flags */ int iLayer; /* Rendering order */ int inDir, outDir; /* Entry and exit directions */ int nPath; /* Number of path points */ PPoint *aPath; /* Array of path points */ PObj *pFrom, *pTo; /* End-point objects of a path */ PBox bbox; /* Bounding box */ }; /* A list of graphics objects */ struct PList { int n; /* Number of statements in the list */ int nAlloc; /* Allocated slots in a[] */ |
︙ | ︙ | |||
344 345 346 347 348 349 350 351 352 353 354 355 356 357 | PToken sIn; /* Input Pikchr-language text */ char *zOut; /* Result accumulates here */ unsigned int nOut; /* Bytes written to zOut[] so far */ unsigned int nOutAlloc; /* Space allocated to zOut[] */ unsigned char eDir; /* Current direction */ unsigned int mFlags; /* Flags passed to pikchr() */ PObj *cur; /* Object under construction */ PList *list; /* Object list under construction */ PMacro *pMacros; /* List of all defined macros */ PVar *pVar; /* Application-defined variables */ PBox bbox; /* Bounding box around all statements */ /* Cache of layout values. <=0.0 for unknown... */ PNum rScale; /* Multiply to convert inches to pixels */ PNum fontScale; /* Scale fonts by this percent */ | > | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | PToken sIn; /* Input Pikchr-language text */ char *zOut; /* Result accumulates here */ unsigned int nOut; /* Bytes written to zOut[] so far */ unsigned int nOutAlloc; /* Space allocated to zOut[] */ unsigned char eDir; /* Current direction */ unsigned int mFlags; /* Flags passed to pikchr() */ PObj *cur; /* Object under construction */ PObj *lastRef; /* Last object references by "place" */ PList *list; /* Object list under construction */ PMacro *pMacros; /* List of all defined macros */ PVar *pVar; /* Application-defined variables */ PBox bbox; /* Bounding box around all statements */ /* Cache of layout values. <=0.0 for unknown... */ PNum rScale; /* Multiply to convert inches to pixels */ PNum fontScale; /* Scale fonts by this percent */ |
︙ | ︙ | |||
3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 | if( p->mTPath & 1 ) n = pik_next_rpath(p, pDir); p->aTPath[n].x = pPlace->x; p->mTPath |= 1; break; } pObj->outDir = pDir->eCode; } /* Set the "from" of an object */ static void pik_set_from(Pik *p, PObj *pObj, PToken *pTk, PPoint *pPt){ if( !pObj->type->isLine ){ pik_error(p, pTk, "use \"at\" to position this object"); return; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 | if( p->mTPath & 1 ) n = pik_next_rpath(p, pDir); p->aTPath[n].x = pPlace->x; p->mTPath |= 1; break; } pObj->outDir = pDir->eCode; } /* If the last referenced object is centered at point pPt then return ** a pointer to that object. If there is no prior object reference, ** or if the points are not the same, return NULL. ** ** This is a side-channel hack used to find the objects at which a ** line begins and ends. For example, in ** ** arrow from OBJ1 to OBJ2 chop ** ** The arrow object is normally just handed the coordinates of the ** centers for OBJ1 and OBJ2. But we also want to know the specific ** object named in case there are multiple objects centered at the ** same point. ** ** See forum post 1d46e3a0bc */ static PObj *pik_last_ref_object(Pik *p, PPoint *pPt){ PObj *pRes = 0; if( p->lastRef==0 ) return 0; if( p->lastRef->ptAt.x==pPt->x && p->lastRef->ptAt.y==pPt->y ){ pRes = p->lastRef; } p->lastRef = 0; return pRes; } /* Set the "from" of an object */ static void pik_set_from(Pik *p, PObj *pObj, PToken *pTk, PPoint *pPt){ if( !pObj->type->isLine ){ pik_error(p, pTk, "use \"at\" to position this object"); return; |
︙ | ︙ | |||
3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 | p->aTPath[i].x += dx; p->aTPath[i].y += dy; } } p->aTPath[0] = *pPt; p->mTPath = 3; pObj->mProp |= A_FROM; } /* Set the "to" of an object */ static void pik_add_to(Pik *p, PObj *pObj, PToken *pTk, PPoint *pPt){ int n = p->nTPath-1; if( !pObj->type->isLine ){ pik_error(p, pTk, "use \"at\" to position this object"); return; } if( pObj->bClose ){ pik_error(p, pTk, "polygon is closed"); return; } pik_reset_samepath(p); if( n==0 || p->mTPath==3 || p->thenFlag ){ n = pik_next_rpath(p, pTk); } p->aTPath[n] = *pPt; p->mTPath = 3; } static void pik_close_path(Pik *p, PToken *pErr){ PObj *pObj = p->cur; if( p->nTPath<3 ){ pik_error(p, pErr, "need at least 3 vertexes in order to close the polygon"); | > > | 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 | p->aTPath[i].x += dx; p->aTPath[i].y += dy; } } p->aTPath[0] = *pPt; p->mTPath = 3; pObj->mProp |= A_FROM; pObj->pFrom = pik_last_ref_object(p, pPt); } /* Set the "to" of an object */ static void pik_add_to(Pik *p, PObj *pObj, PToken *pTk, PPoint *pPt){ int n = p->nTPath-1; if( !pObj->type->isLine ){ pik_error(p, pTk, "use \"at\" to position this object"); return; } if( pObj->bClose ){ pik_error(p, pTk, "polygon is closed"); return; } pik_reset_samepath(p); if( n==0 || p->mTPath==3 || p->thenFlag ){ n = pik_next_rpath(p, pTk); } p->aTPath[n] = *pPt; p->mTPath = 3; pObj->pTo = pik_last_ref_object(p, pPt); } static void pik_close_path(Pik *p, PToken *pErr){ PObj *pObj = p->cur; if( p->nTPath<3 ){ pik_error(p, pErr, "need at least 3 vertexes in order to close the polygon"); |
︙ | ︙ | |||
3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 | pik_error(p, pName, "no such object"); return 0; } /* First look explicitly tagged objects */ for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; if( pObj->zName && pik_token_eq(pName,pObj->zName)==0 ){ return pObj; } } /* If not found, do a second pass looking for any object containing ** text which exactly matches pName */ for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; for(j=0; j<pObj->nTxt; j++){ if( pObj->aTxt[j].n==pName->n+2 && memcmp(pObj->aTxt[j].z+1,pName->z,pName->n)==0 ){ return pObj; } } } pik_error(p, pName, "no such object"); return 0; } | > > | 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 | pik_error(p, pName, "no such object"); return 0; } /* First look explicitly tagged objects */ for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; if( pObj->zName && pik_token_eq(pName,pObj->zName)==0 ){ p->lastRef = pObj; return pObj; } } /* If not found, do a second pass looking for any object containing ** text which exactly matches pName */ for(i=pList->n-1; i>=0; i--){ PObj *pObj = pList->a[i]; for(j=0; j<pObj->nTxt; j++){ if( pObj->aTxt[j].n==pName->n+2 && memcmp(pObj->aTxt[j].z+1,pName->z,pName->n)==0 ){ p->lastRef = pObj; return pObj; } } } pik_error(p, pName, "no such object"); return 0; } |
︙ | ︙ | |||
4068 4069 4070 4071 4072 4073 4074 | /* ** 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. */ | | > | > | 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 | /* ** 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){ if( pObj==0 || pObj->type->xChop==0 ){ 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. |
︙ | ︙ | |||
4168 4169 4170 4171 4172 4173 4174 | /* "chop" processing: ** If the line goes to the center of an object with an ** xChop method, then use the xChop method to trim the line. */ if( pObj->bChop && pObj->nPath>=2 ){ int n = pObj->nPath; | | | | 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 | /* "chop" processing: ** If the line goes to the center of an object with an ** xChop method, then use the xChop method to trim the line. */ if( pObj->bChop && pObj->nPath>=2 ){ int n = pObj->nPath; pik_autochop(p, &pObj->aPath[n-2], &pObj->aPath[n-1], pObj->pTo); pik_autochop(p, &pObj->aPath[1], &pObj->aPath[0], pObj->pFrom); } pObj->ptEnter = pObj->aPath[0]; pObj->ptExit = pObj->aPath[pObj->nPath-1]; /* Compute the center of the line based on the bounding box over ** the vertexes. This is a difference from PIC. In Pikchr, the |
︙ | ︙ |
Added tests/autochop09.pikchr.
> > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | circle "C0" fit color blue C1: circle at C0 radius 2.5*C0.radius color red text "C1" with .n at C1.n color red circle "X1" at 8*C0.radius heading 60 from C0 fit color blue circle "X2" at 8*C0.radius heading 80 from C0 fit color red circle "X3" at 8*C0.radius heading 100 from C0 fit color blue circle "X4" at 8*C0.radius heading 120 from C0 fit color red arrow color blue from C0 to X1 chop arrow color red from C1 to X2 chop arrow color blue from X3 to C0 chop arrow color red from X4 to C1 chop text "chop bug 2021-07-17" \ "forum 1d46e3a0bc5c5631" \ "red lines to red circles" \ "blue lines to blue circle" \ at 2cm below C0 |