Subversion Repositories wimsdev

Rev

Rev 15715 | Rev 15717 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15715 Rev 15716
Line 2543... Line 2543...
2543
                    break;
2543
                    break;
2544
                    default:break;
2544
                    default:break;
2545
                }
2545
                }
2546
            }
2546
            }
2547
            reset();
2547
            reset();
-
 
2548
            break;
-
 
2549
        case KILL:
-
 
2550
        /*
-
 
2551
        @ kill arguments
-
 
2552
        @ arguments may be: affine linear translation rotation slider offset  reset
-
 
2553
        @ for documentation see: killaffine,killlinear,killtranslation...
-
 
2554
        @ multiple arguments are allowed (although not checked for validity...)
-
 
2555
        */
-
 
2556
            temp = get_string(infile,1);
-
 
2557
            if(strstr(temp,"affine") != 0 ){use_affine = FALSE;affine_matrix[0] = 1.0;affine_matrix[1] = 0.0;affine_matrix[2] = 0.0;affine_matrix[3] = 1.0;affine_matrix[4] = 0.0;affine_matrix[5] = 0.0;}
-
 
2558
            if(strstr(temp,"linear") != 0 ){affine_matrix[0] = 1.0;affine_matrix[1] = 0.0;affine_matrix[2] = 0.0;affine_matrix[3] = 1.0;}
-
 
2559
            if(strstr(temp,"translation") != 0 || strstr(temp,"translate") != 0 ){affine_matrix[4] = 0.0;affine_matrix[5] = 0.0;}
-
 
2560
            if(strstr(temp,"rotation") != 0 || strstr(temp,"rotate") != 0 ){use_rotate = FALSE;angle = 0.0;rotation_center="null";}
-
 
2561
            if(strstr(temp,"slider") != 0 ){slider_type = "0";my_sliders = "[-1]";last_slider = use_slider+1;}
-
 
2562
            if(strstr(temp,"reset") != 0 ){if(no_reset == FALSE){no_reset = TRUE;}else{no_reset = FALSE;reset();}}
-
 
2563
            if(strstr(temp,"offset") != 0 ){use_offset = 0;}
2548
            break;
2564
            break;
2549
        case KILLAFFINE:
2565
        case KILLAFFINE:
2550
        /*
2566
        /*
2551
        @ killaffine
2567
        @ killaffine
2552
        @ keyword: resets the transformation matrix to 1,0,0,1,0,0
2568
        @ keyword: resets the transformation matrix to 1,0,0,1,0,0
Line 3752... Line 3768...
3752
        @ the command interconnects the points in the given order with a line (canvasdraw will not close the drawing: use command <a href="#poly">polygon</a> for this)
3768
        @ the command interconnects the points in the given order with a line (canvasdraw will not close the drawing: use command <a href="#poly">polygon</a> for this)
3753
        @ use command <a href='#segments'>segments</a> for a series of segments. These may be clicked/dragged individually
3769
        @ use command <a href='#segments'>segments</a> for a series of segments. These may be clicked/dragged individually
3754
        @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a>
3770
        @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a>
3755
        @%polyline_1%size 400,400%xrange -10,10%yrange -10,10%linewidth 2%drag xy%snaptogrid%polyline blue,0,0,1,3,3,1,2,4,-1,3
3771
        @%polyline_1%size 400,400%xrange -10,10%yrange -10,10%linewidth 2%drag xy%snaptogrid%polyline blue,0,0,1,3,3,1,2,4,-1,3
3756
        @%polyline_2%size 400,400%xrange -10,10%yrange -10,10%linewidth 1%onclick%polyline green,0,0,1,3,3,1,2,4,-1,3
3772
        @%polyline_2%size 400,400%xrange -10,10%yrange -10,10%linewidth 1%onclick%polyline green,0,0,1,3,3,1,2,4,-1,3
3757
        */
3773
        */
3758
 
3774
 
3759
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
3775
            stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/
3760
            i=0;
3776
            i=0;
3761
            c=0;
3777
            c=0;
3762
            while( ! done ){     /* get next item until EOL*/
3778
            while( ! done ){     /* get next item until EOL*/
3763
                if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
3779
                if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
3764
                for( c = 0 ; c < 2; c++){
3780
                for( c = 0 ; c < 2; c++){
3765
                    if(c == 0 ){
3781
                    if(c == 0 ){
3766
                        double_data[i] = get_real(infile,0);
3782
                        double_data[i] = get_real(infile,0);
3767
                        i++;
3783
                        i++;
Line 3833... Line 3849...
3833
                    case 4: int_data[1] = (int)(get_real(infile,0));break; /* passive mode == 0; active mode == -1 */
3849
                    case 4: int_data[1] = (int)(get_real(infile,0));break; /* passive mode == 0; active mode == -1 */
3834
                    case 5: int_data[2] = (int)(get_real(infile,1)); /* use scale */
3850
                    case 5: int_data[2] = (int)(get_real(infile,1)); /* use scale */
3835
                    decimals = find_number_of_digits(precision);
3851
                    decimals = find_number_of_digits(precision);
3836
                    if( int_data[1] < 0 ){ js_function[JS_FIND_ANGLE] = 1;}
3852
                    if( int_data[1] < 0 ){ js_function[JS_FIND_ANGLE] = 1;}
3837
                    add_js_protractor(int_data[0],double_data[0],double_data[1],double_data[2],font_family,stroke_color,stroke_opacity,fill_color,fill_opacity,line_width,int_data[2],int_data[1],use_snap);
3853
                    add_js_protractor(int_data[0],double_data[0],double_data[1],double_data[2],font_family,stroke_color,stroke_opacity,fill_color,fill_opacity,line_width,int_data[2],int_data[1],use_snap);
3838
 
3854
 
3839
                    string_length = 1 + snprintf(NULL,0,";protractor%d(); ",canvas_root_id);
3855
                    string_length = 1 + snprintf(NULL,0,";protractor%d(); ",canvas_root_id);
3840
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length);
3856
                    check_string_length(string_length);tmp_buffer = my_newmem(string_length);
3841
                    snprintf(tmp_buffer,string_length,";protractor%d(); ",canvas_root_id);
3857
                    snprintf(tmp_buffer,string_length,";protractor%d(); ",canvas_root_id);
3842
                    add_to_buffer(tmp_buffer);
3858
                    add_to_buffer(tmp_buffer);
3843
                    reply_precision = precision;
3859
                    reply_precision = precision;
Line 3909... Line 3925...
3909
        @ use command <a href='centered'>centered</a> to place <a href='#legend'>legend</a> text inside the piechart. The text is using the same color as the pie segment: use (fill) opacity to enhance visibility.
3925
        @ use command <a href='centered'>centered</a> to place <a href='#legend'>legend</a> text inside the piechart. The text is using the same color as the pie segment: use (fill) opacity to enhance visibility.
3910
        @%piechart_1%size 300,200%xrange -10,10%yrange -10,10%legend cars:motorcycles:bicycles:trikes%opacity 255,120%piechart -5,0,75,22:red:8:blue:63:green:7:purple%
3926
        @%piechart_1%size 300,200%xrange -10,10%yrange -10,10%legend cars:motorcycles:bicycles:trikes%opacity 255,120%piechart -5,0,75,22:red:8:blue:63:green:7:purple%
3911
        @%piechart_2%size 200,200%xrange -10,10%yrange -10,10%fontfamily 16px Arial%centered%legend cars:motorcycles:bicycles:trikes%opacity 255,60%piechart 0,0,100,22:red:8:blue:63:green:7:purple
3927
        @%piechart_2%size 200,200%xrange -10,10%yrange -10,10%fontfamily 16px Arial%centered%legend cars:motorcycles:bicycles:trikes%opacity 255,60%piechart 0,0,100,22:red:8:blue:63:green:7:purple
3912
        */
3928
        */
3913
            js_function[DRAW_PIECHART] = 1;
3929
            js_function[DRAW_PIECHART] = 1;
3914
            for(i=0;i<5;i++){
3930
            for(i=0;i<5;i++){
3915
                switch(i){
3931
                switch(i){
3916
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
3932
                    case 0: int_data[0] = x2px(get_real(infile,0)); break; /* x */
3917
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
3933
                    case 1: int_data[1] = y2px(get_real(infile,0)); break; /* y  */
3918
                    case 2: int_data[2] = (int)(get_real(infile,1));break;/* radius*/
3934
                    case 2: int_data[2] = (int)(get_real(infile,1));break;/* radius*/
3919
                    case 3: temp = get_string(infile,1);
3935
                    case 3: temp = get_string(infile,1);
Line 4060... Line 4076...
4060
            }
4076
            }
4061
            dragstuff[5] = 1;
4077
            dragstuff[5] = 1;
4062
            if(use_dragstuff == 0 ){ use_dragstuff = 1; }
4078
            if(use_dragstuff == 0 ){ use_dragstuff = 1; }
4063
            if(use_rotate == TRUE ){
4079
            if(use_rotate == TRUE ){
4064
             rotate(i-1,angle,rotationcenter,2);
4080
             rotate(i-1,angle,rotationcenter,2);
4065
            }
4081
            }
4066
            reset();
4082
            reset();
4067
            break;
4083
            break;
4068
 
4084
 
4069
        case REPLYFORMAT:
4085
        case REPLYFORMAT:
4070
        /*
4086
        /*
4071
        @ replyformat number
4087
        @ replyformat number
Line 4109... Line 4125...
4109
                        add_to_buffer(tmp_buffer);
4125
                        add_to_buffer(tmp_buffer);
4110
                        if(onclick != 0){object_cnt++;}
4126
                        if(onclick != 0){object_cnt++;}
4111
                        /* object_cnt++;*/
4127
                        /* object_cnt++;*/
4112
                        reset();
4128
                        reset();
4113
                    break;
4129
                    break;
4114
                }
4130
                }
4115
            }
4131
            }
4116
            dragstuff[6] = 1;
4132
            dragstuff[6] = 1;
4117
            if(use_dragstuff == 0 ){ use_dragstuff = 1; }
4133
            if(use_dragstuff == 0 ){ use_dragstuff = 1; }
4118
            break;
4134
            break;
4119
 
4135
 
Line 4137... Line 4153...
4137
                else
4153
                else
4138
                {
4154
                {
4139
                    double_data[i] = get_real(infile,1); /* y */
4155
                    double_data[i] = get_real(infile,1); /* y */
4140
                }
4156
                }
4141
                i++;
4157
                i++;
4142
            }
4158
            }
4143
            if(use_rotate == TRUE ){rotate(i-1,angle,rotationcenter,2);}
4159
            if(use_rotate == TRUE ){rotate(i-1,angle,rotationcenter,2);}
4144
            if(use_affine == TRUE ){ transform(i-1,2);}
4160
            if(use_affine == TRUE ){ transform(i-1,2);}
4145
            if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */
4161
            if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */
4146
            decimals = find_number_of_digits(precision);
4162
            decimals = find_number_of_digits(precision);
4147
            for(c = 0 ; c < i-1 ; c = c+4){
4163
            for(c = 0 ; c < i-1 ; c = c+4){
Line 4364... Line 4380...
4364
                    case 2: double_data[2]= get_real(infile,0);break; /* x2-values */
4380
                    case 2: double_data[2]= get_real(infile,0);break; /* x2-values */
4365
                    case 3: double_data[3]= get_real(infile,0);break; /* y2-values */
4381
                    case 3: double_data[3]= get_real(infile,0);break; /* y2-values */
4366
                    case 4: stroke_color=get_color(infile,1);/* name or hex color */
4382
                    case 4: stroke_color=get_color(infile,1);/* name or hex color */
4367
                        if(use_rotate == TRUE ){rotate(4,angle,rotationcenter,2);}
4383
                        if(use_rotate == TRUE ){rotate(4,angle,rotationcenter,2);}
4368
                        if(use_affine == TRUE ){ transform(4,2);}
4384
                        if(use_affine == TRUE ){ transform(4,2);}
4369
                        if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */
4385
                        if( use_slider != -1 && onclick == 0){ onclick = 3; }/* no drag&onclick but slideable */
4370
                        decimals = find_number_of_digits(precision);
4386
                        decimals = find_number_of_digits(precision);
4371
                        string_length = 1 + snprintf(NULL,0,"dragstuff.addShape(new Shape(%d,%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset);
4387
                        string_length = 1 + snprintf(NULL,0,"dragstuff.addShape(new Shape(%d,%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset);
4372
                        check_string_length(string_length);tmp_buffer = my_newmem(string_length);
4388
                        check_string_length(string_length);tmp_buffer = my_newmem(string_length);
4373
                        snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset);
4389
                        snprintf(tmp_buffer,string_length,"dragstuff.addShape(new Shape(%d,%d,%d,%d,4,[%.*f,%.*f],[%.*f,%.*f],[30,30],[30,30],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%s,%s,%d));\n",drag_type,object_cnt,onclick,use_snap,decimals,double_data[0],decimals,double_data[2],decimals,double_data[1],decimals,double_data[3],line_width,stroke_color,stroke_opacity,stroke_color,stroke_opacity,0,use_dashed,dashtype[0],dashtype[1],use_rotate,angle,flytext,font_size,font_family,my_sliders,rotation_center,use_offset);
4374
                        add_to_buffer(tmp_buffer);
4390
                        add_to_buffer(tmp_buffer);
Line 6762... Line 6778...
6762
        *ellipses="ellipses",
6778
        *ellipses="ellipses",
6763
        *fellipse="fellipse",
6779
        *fellipse="fellipse",
6764
        *rotate="rotate",
6780
        *rotate="rotate",
6765
        *affine="affine",
6781
        *affine="affine",
6766
        *rotationcenter="rotationcenter",
6782
        *rotationcenter="rotationcenter",
-
 
6783
        *kill="kill",
6767
        *killrotate="killrotate",
6784
        *killrotate="killrotate",
6768
        *killaffine="killaffine",
6785
        *killaffine="killaffine",
6769
        *killlinear="killlinear",
6786
        *killlinear="killlinear",
6770
        *killinear="killinear",
6787
        *killinear="killinear",
6771
        *fontfamily="fontfamily",
6788
        *fontfamily="fontfamily",
Line 7400... Line 7417...
7400
        return CLEARBUTTON;
7417
        return CLEARBUTTON;
7401
        }
7418
        }
7402
        if( strcmp(input_type, translation) == 0 ||  strcmp(input_type, translate) == 0  ){
7419
        if( strcmp(input_type, translation) == 0 ||  strcmp(input_type, translate) == 0  ){
7403
        free(input_type);
7420
        free(input_type);
7404
        return TRANSLATION;
7421
        return TRANSLATION;
-
 
7422
        }
-
 
7423
        if( strcmp(input_type, kill) == 0 ){
-
 
7424
        free(input_type);
-
 
7425
        return KILL;
7405
        }
7426
        }
7406
        if( strcmp(input_type, killtranslation) == 0 ||  strcmp(input_type, killtranslate) == 0){
7427
        if( strcmp(input_type, killtranslation) == 0 ||  strcmp(input_type, killtranslate) == 0){
7407
        free(input_type);
7428
        free(input_type);
7408
        return KILLTRANSLATION;
7429
        return KILLTRANSLATION;
7409
        }
7430
        }