Rev 8322 | Rev 8348 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8322 | Rev 8347 | ||
---|---|---|---|
Line 318... | Line 318... | ||
318 | arrow_head = (int) (get_real(infile,1)); |
318 | arrow_head = (int) (get_real(infile,1)); |
319 | break; |
319 | break; |
320 | case CROSSHAIRSIZE: |
320 | case CROSSHAIRSIZE: |
321 | /* |
321 | /* |
322 | @ crosshairsize int |
322 | @ crosshairsize int |
323 | @ default |
323 | @ default 8 (px) |
324 | */ |
324 | */ |
325 | crosshair_size = (int) (get_real(infile,1)); |
325 | crosshair_size = (int) (get_real(infile,1)); |
326 | break; |
326 | break; |
327 | case CROSSHAIR: |
327 | case CROSSHAIR: |
328 | /* |
328 | /* |
Line 925... | Line 925... | ||
925 | @ arrows color,head (px),x1,y1,x2,y2...x_n,y_n |
925 | @ arrows color,head (px),x1,y1,x2,y2...x_n,y_n |
926 | @ draw single headed arrows / vectors from (x1:y1) to (x2:y2) ... (x3:y3) to (x4:y4) etc ... in color 'color' |
926 | @ draw single headed arrows / vectors from (x1:y1) to (x2:y2) ... (x3:y3) to (x4:y4) etc ... in color 'color' |
927 | @ use command 'linewidth int' to adjust thickness of the arrow |
927 | @ use command 'linewidth int' to adjust thickness of the arrow |
928 | @ may be set draggable / onclick individually |
928 | @ may be set draggable / onclick individually |
929 | */ |
929 | */ |
930 | fprintf(js_include_file,"\n<!-- FOUND ARROWS --> \n"); |
- | |
931 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
930 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
932 | fill_color = stroke_color; |
931 | fill_color = stroke_color; |
933 | arrow_head = (int) get_real(infile,0);/* h */ |
932 | arrow_head = (int) get_real(infile,0);/* h */ |
934 | i=0; |
933 | i=0; |
935 | while( ! done ){ /* get next item until EOL*/ |
934 | while( ! done ){ /* get next item until EOL*/ |
Line 994... | Line 993... | ||
994 | click_cnt++;reset(); |
993 | click_cnt++;reset(); |
995 | break; |
994 | break; |
996 | } |
995 | } |
997 | } |
996 | } |
998 | break; |
997 | break; |
- | 998 | case ARROWS2: |
|
- | 999 | /* |
|
- | 1000 | @ arrows2 color,head (px),x1,y1,x2,y2...x_n,y_n |
|
- | 1001 | @ draw double headed arrows / vectors from (x1:y1) to (x2:y2) ... (x3:y3) to (x4:y4) etc ... in color 'color' |
|
- | 1002 | @ use command 'linewidth int' to adjust thickness of the arrows |
|
- | 1003 | @ may be set draggable / onclick individually |
|
- | 1004 | */ |
|
- | 1005 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
|
- | 1006 | fill_color = stroke_color; |
|
- | 1007 | arrow_head = (int) get_real(infile,0);/* h */ |
|
- | 1008 | i=0; |
|
- | 1009 | while( ! done ){ /* get next item until EOL*/ |
|
- | 1010 | if(i > MAX_INT - 1){canvas_error("to many points in argument: repeat command multiple times to fit");} |
|
- | 1011 | if(i%2 == 0 ){ |
|
- | 1012 | double_data[i] = get_real(infile,0); /* x */ |
|
- | 1013 | } |
|
- | 1014 | else |
|
- | 1015 | { |
|
- | 1016 | double_data[i] = get_real(infile,1); /* y */ |
|
- | 1017 | } |
|
- | 1018 | i++; |
|
- | 1019 | } |
|
- | 1020 | decimals = find_number_of_digits(precision); |
|
- | 1021 | for(c = 0 ; c < i-1 ; c = c+4){ |
|
- | 1022 | fprintf(js_include_file,"dragstuff.addShape(new Shape(%d,%d,%d,10,[%.*f,%.*f],[%.*f,%.*f],[%d,%d],[%d,%d],%d,\"%s\",%.2f,\"%s\",%.2f,%d,%d,%d,%d,%d,%.1f,\"%s\",%d,\"%s\",%d,%s,%d,%d));\n",click_cnt,onclick,drag_type,decimals,double_data[c],decimals,double_data[c+2],decimals,double_data[c+1],decimals,double_data[c+3],arrow_head,arrow_head,arrow_head,arrow_head,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,use_affine,affine_matrix,slider,slider_cnt); |
|
- | 1023 | click_cnt++; |
|
- | 1024 | } |
|
- | 1025 | reset(); |
|
- | 1026 | break; |
|
999 | case PARALLEL: |
1027 | case PARALLEL: |
1000 | /* |
1028 | /* |
1001 | @ parallel x1,y1,x2,y2,dx,dy,n,[colorname or #hexcolor] |
1029 | @ parallel x1,y1,x2,y2,dx,dy,n,[colorname or #hexcolor] |
1002 | @ can not be set "onclick" or "drag xy" |
1030 | @ can not be set "onclick" or "drag xy" |
1003 | */ |
1031 | */ |
Line 3342... | Line 3370... | ||
3342 | @ use together with commands xlogscale / xylogscale |
3370 | @ use together with commands xlogscale / xylogscale |
3343 | */ |
3371 | */ |
3344 | fprintf(js_include_file,"xlogbase=%d;",(int)(get_real(infile,1))); |
3372 | fprintf(js_include_file,"xlogbase=%d;",(int)(get_real(infile,1))); |
3345 | break; |
3373 | break; |
3346 | case YLOGBASE: |
3374 | case YLOGBASE: |
3347 | /* |
3375 | /* |
3348 | @ ylogbase number |
3376 | @ ylogbase number |
3349 | @ sets the logbase number for the y-axis |
3377 | @ sets the logbase number for the y-axis |
3350 | @ default value 10 |
3378 | @ default value 10 |
3351 | @ use together with commands ylogscale / xylogscale |
3379 | @ use together with commands ylogscale / xylogscale |
3352 | */ |
3380 | */ |
Line 3528... | Line 3556... | ||
3528 | /* end main() */ |
3556 | /* end main() */ |
3529 | 3557 | ||
3530 | /****************************************************************************** |
3558 | /****************************************************************************** |
3531 | ** |
3559 | ** |
3532 | ** sync_input |
3560 | ** sync_input |
3533 | ** |
3561 | ** |
3534 | ** synchronises input line - reads to end of line, leaving file pointer |
3562 | ** synchronises input line - reads to end of line, leaving file pointer |
3535 | ** at first character of next line. |
3563 | ** at first character of next line. |
3536 | ** |
3564 | ** |
3537 | ** Used by: |
3565 | ** Used by: |
3538 | ** main program - error handling. |
3566 | ** main program - error handling. |
3539 | ** |
3567 | ** |
3540 | ******************************************************************************/ |
3568 | ******************************************************************************/ |
3541 | void sync_input(FILE *infile) |
3569 | void sync_input(FILE *infile) |
3542 | { |
3570 | { |
3543 | int c = 0; |
3571 | int c = 0; |
3544 | 3572 | ||
3545 | if( c == '\n' || c == ';' ) return; |
3573 | if( c == '\n' || c == ';' ) return; |
3546 | while( ( (c=getc(infile)) != EOF ) && (c != '\n') && (c != '\r') && (c != ';')) ; |
3574 | while( ( (c=getc(infile)) != EOF ) && (c != '\n') && (c != '\r') && (c != ';')) ; |
3547 | if( c == EOF ) finished = 1; |
3575 | if( c == EOF ) finished = 1; |
3548 | if( c == '\n' || c == '\r' || c == ';') line_number++; |
3576 | if( c == '\n' || c == '\r' || c == ';') line_number++; |
3549 | return; |
3577 | return; |
Line 3562... | Line 3590... | ||
3562 | size_t newlen = strlen(new); |
3590 | size_t newlen = strlen(new); |
3563 | if (oldlen != newlen){ |
3591 | if (oldlen != newlen){ |
3564 | for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){ |
3592 | for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){ |
3565 | count++; |
3593 | count++; |
3566 | retlen = p - str + strlen(p) + count * (newlen - oldlen); |
3594 | retlen = p - str + strlen(p) + count * (newlen - oldlen); |
3567 | } |
3595 | } |
3568 | } |
3596 | } |
3569 | else |
3597 | else |
3570 | { |
3598 | { |
3571 | retlen = strlen(str); |
3599 | retlen = strlen(str); |
3572 | } |
3600 | } |
Line 3586... | Line 3614... | ||
3586 | } |
3614 | } |
3587 | strcpy(r, p); |
3615 | strcpy(r, p); |
3588 | } |
3616 | } |
3589 | return ret; |
3617 | return ret; |
3590 | } |
3618 | } |
3591 | 3619 | ||
3592 | /******************************************************************************/ |
3620 | /******************************************************************************/ |
3593 | 3621 | ||
3594 | char *get_color(FILE *infile , int last){ |
3622 | char *get_color(FILE *infile , int last){ |
3595 | int c,i = 0,is_hex = 0; |
3623 | int c,i = 0,is_hex = 0; |
3596 | char temp[MAX_COLOR_STRING], *string; |
3624 | char temp[MAX_COLOR_STRING], *string; |
3597 | const char *not_allowed = "0123456789"; |
3625 | const char *not_allowed = "0123456789"; |
3598 | while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',' ) && ( c != ';' ) ){ |
3626 | while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != ',' ) && ( c != ';' ) ){ |
3599 | if( i > MAX_COLOR_STRING ){ canvas_error("colour string is too big ... ? ");} |
3627 | if( i > MAX_COLOR_STRING ){ canvas_error("colour string is too big ... ? ");} |
3600 | if( c == '#' ){ |
3628 | if( c == '#' ){ |
3601 | is_hex = 1; |
3629 | is_hex = 1; |
3602 | } |
3630 | } |
3603 | if( c != ' '){ |
3631 | if( c != ' '){ |
3604 | if( is_hex == 0 ){if(strchr(not_allowed,c) != 0){canvas_error("found something like a number...but is should have been a colour or #hex color number...<br />Do not use R,G,B !!! ");}} |
3632 | if( is_hex == 0 ){if(strchr(not_allowed,c) != 0){canvas_error("found something like a number...but is should have been a colour or #hex color number...<br />Do not use R,G,B !!! ");}} |
3605 | temp[i]=tolower(c); |
3633 | temp[i]=tolower(c); |
3606 | i++; |
3634 | i++; |
3607 | } |
3635 | } |
Line 3621... | Line 3649... | ||
3621 | int g = (int) strtol(green, NULL, 16); |
3649 | int g = (int) strtol(green, NULL, 16); |
3622 | int b = (int) strtol(blue, NULL, 16); |
3650 | int b = (int) strtol(blue, NULL, 16); |
3623 | string = (char *)my_newmem(12); |
3651 | string = (char *)my_newmem(12); |
3624 | snprintf(string,11,"%d,%d,%d",r,g,b); |
3652 | snprintf(string,11,"%d,%d,%d",r,g,b); |
3625 | return string; |
3653 | return string; |
3626 | } |
3654 | } |
3627 | else |
3655 | else |
3628 | { |
3656 | { |
3629 | string = (char *)my_newmem(sizeof(temp)); |
3657 | string = (char *)my_newmem(sizeof(temp)); |
3630 | snprintf(string,sizeof(temp),"%s",temp); |
3658 | snprintf(string,sizeof(temp),"%s",temp); |
3631 | for( i = 0; i < NUMBER_OF_COLORNAMES ; i++ ){ |
3659 | for( i = 0; i < NUMBER_OF_COLORNAMES ; i++ ){ |
3632 | if( strcmp( colors[i].name , string ) == 0 ){ |
3660 | if( strcmp( colors[i].name , string ) == 0 ){ |
Line 3634... | Line 3662... | ||
3634 | } |
3662 | } |
3635 | } |
3663 | } |
3636 | canvas_error("I was expecting a color name or hexnumber...but found nothing."); |
3664 | canvas_error("I was expecting a color name or hexnumber...but found nothing."); |
3637 | } |
3665 | } |
3638 | return "0,0,255"; |
3666 | return "0,0,255"; |
3639 | } |
3667 | } |
3640 | 3668 | ||
3641 | char *get_string(FILE *infile,int last){ /* last = 0 : more arguments ; last=1 final argument */ |
3669 | char *get_string(FILE *infile,int last){ /* last = 0 : more arguments ; last=1 final argument */ |
3642 | int c,i=0; |
3670 | int c,i=0; |
3643 | char temp[MAX_BUFFER], *string; |
3671 | char temp[MAX_BUFFER], *string; |
3644 | while(( (c=getc(infile)) != EOF ) && ( c != '\n') ){ |
3672 | while(( (c=getc(infile)) != EOF ) && ( c != '\n') ){ |
Line 3692... | Line 3720... | ||
3692 | const char *not_allowed = "#bdfghjkmquvwxyz";/* avoid segmentation faults in a "atof()" and "wims eval" */ |
3720 | const char *not_allowed = "#bdfghjkmquvwxyz";/* avoid segmentation faults in a "atof()" and "wims eval" */ |
3693 | while(( (c=getc(infile)) != EOF ) && ( c != ',') && (c != '\n') && ( c != ';')){ |
3721 | while(( (c=getc(infile)) != EOF ) && ( c != ',') && (c != '\n') && ( c != ';')){ |
3694 | if( c != ' ' ){ |
3722 | if( c != ' ' ){ |
3695 | if( i == 0 && c == '+' ){ |
3723 | if( i == 0 && c == '+' ){ |
3696 | continue; |
3724 | continue; |
3697 | } |
3725 | } |
3698 | else |
3726 | else |
3699 | { |
3727 | { |
3700 | c = tolower(c); |
3728 | c = tolower(c); |
3701 | if( strchr(not_allowed,c) != 0 ){canvas_error("found a character not associated with a number...");} |
3729 | if( strchr(not_allowed,c) != 0 ){canvas_error("found a character not associated with a number...");} |
3702 | if( strchr(allowed,c) != 0 ){found_calc = 1;}/* hand the string over to wims eval() */ |
3730 | if( strchr(allowed,c) != 0 ){found_calc = 1;}/* hand the string over to wims eval() */ |
Line 3715... | Line 3743... | ||
3715 | void *f = eval_create(tmp); |
3743 | void *f = eval_create(tmp); |
3716 | assert(f);if( f == NULL ){canvas_error("I'm having trouble parsing your \"expression\" ") ;} |
3744 | assert(f);if( f == NULL ){canvas_error("I'm having trouble parsing your \"expression\" ") ;} |
3717 | y = eval_x(f, 1); |
3745 | y = eval_x(f, 1); |
3718 | /* if function is bogus; y = 1 : so no core dumps */ |
3746 | /* if function is bogus; y = 1 : so no core dumps */ |
3719 | eval_destroy(f); |
3747 | eval_destroy(f); |
3720 | } |
3748 | } |
3721 | else |
3749 | else |
3722 | { |
3750 | { |
3723 | y = atof(tmp); |
3751 | y = atof(tmp); |
3724 | } |
3752 | } |
3725 | return y; |
3753 | return y; |
Line 3902... | Line 3930... | ||
3902 | };\ |
3930 | };\ |
3903 | len = userdraw_radius.length;\ |
3931 | len = userdraw_radius.length;\ |
3904 | if( len > 0 ){\ |
3932 | if( len > 0 ){\ |
3905 | for(var p = 0 ; p < len ; p++ ){\ |
3933 | for(var p = 0 ; p < len ; p++ ){\ |
3906 | userdraw_radius[p] = (Math.round(prec*userdraw_radius[p]))/prec;\ |
3934 | userdraw_radius[p] = (Math.round(prec*userdraw_radius[p]))/prec;\ |
3907 | };\ |
3935 | };\ |
3908 | };\ |
3936 | };\ |
3909 | };",reply_precision); |
3937 | };",reply_precision); |
3910 | 3938 | ||
3911 | switch(type_reply){ |
3939 | switch(type_reply){ |
3912 | /* |
3940 | /* |
Line 4090... | Line 4118... | ||
4090 | var p = 0;\ |
4118 | var p = 0;\ |
4091 | var reply = \"\";\ |
4119 | var reply = \"\";\ |
4092 | for(p = 0; p < userdraw_x.length;p++){\ |
4120 | for(p = 0; p < userdraw_x.length;p++){\ |
4093 | if(userdraw_x[p] != null ){\ |
4121 | if(userdraw_x[p] != null ){\ |
4094 | reply = reply + userdraw_x[p]+\"\\n\"+userdraw_y[p]+\"\\n\";\ |
4122 | reply = reply + userdraw_x[p]+\"\\n\"+userdraw_y[p]+\"\\n\";\ |
4095 | };\ |
4123 | };\ |
4096 | };\ |
4124 | };\ |
4097 | if(p == 0){alert(\"nothing drawn...\");return;};\ |
4125 | if(p == 0){alert(\"nothing drawn...\");return;};\ |
4098 | userdraw_x = [];userdraw_y = [];\ |
4126 | userdraw_x = [];userdraw_y = [];\ |
4099 | if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\ |
4127 | if( document.getElementById(\"canvas_input0\") || document.getElementById(\"mathml0\") ){\ |
4100 | var p = 0;var input_reply = new Array();\ |
4128 | var p = 0;var input_reply = new Array();\ |
4101 | if( document.getElementById(\"canvas_input0\")){\ |
4129 | if( document.getElementById(\"canvas_input0\")){\ |
4102 | var t = 0;\ |
4130 | var t = 0;\ |
4103 | while(document.getElementById(\"canvas_input\"+t)){\ |
4131 | while(document.getElementById(\"canvas_input\"+t)){\ |
4104 | if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\ |
4132 | if( ! document.getElementById(\"canvas_input\"+t).getAttribute(\"readonly\")){\ |
4105 | input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\ |
4133 | input_reply[p] = document.getElementById(\"canvas_input\"+t).value;\ |
4106 | p++;\ |
4134 | p++;\ |
4107 | };\ |
4135 | };\ |
4108 | t++;\ |
4136 | t++;\ |
4109 | };\ |
4137 | };\ |
4110 | };\ |
4138 | };\ |
4111 | if( typeof userdraw_text != 'undefined' ){\ |
4139 | if( typeof userdraw_text != 'undefined' ){\ |
4112 | return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\ |
4140 | return reply +\"\\n\"+input_reply+\"\\n\"+userdraw_text;\ |
4113 | }\ |
4141 | }\ |
4114 | else\ |
4142 | else\ |
4115 | {\ |
4143 | {\ |
4116 | return reply +\"\\n\"+input_reply;\ |
4144 | return reply +\"\\n\"+input_reply;\ |
4117 | }\ |
4145 | }\ |
4118 | }\ |
4146 | }\ |
4119 | else\ |
4147 | else\ |
4120 | {\ |
4148 | {\ |
4121 | if( typeof userdraw_text != 'undefined' ){\ |
4149 | if( typeof userdraw_text != 'undefined' ){\ |
4122 | return reply+\"\\n\"+userdraw_text;\ |
4150 | return reply+\"\\n\"+userdraw_text;\ |
4123 | }\ |
4151 | }\ |
4124 | else\ |
4152 | else\ |
4125 | {\ |
4153 | {\ |
4126 | return reply;\ |
4154 | return reply;\ |
4127 | }\ |
4155 | }\ |
4128 | };\ |
4156 | };\ |
4129 | };\n\ |
4157 | };\n\ |
4130 | <!-- end function 5 read_canvas%d() -->",canvas_root_id,canvas_root_id,canvas_root_id); |
4158 | <!-- end function 5 read_canvas%d() -->",canvas_root_id,canvas_root_id,canvas_root_id); |
4131 | break; |
4159 | break; |
4132 | /* |
4160 | /* |
4133 | attention: we reset userdraw_x / userdraw_y : because userdraw_x = [][] userdraw_y = [][] |
4161 | attention: we reset userdraw_x / userdraw_y : because userdraw_x = [][] userdraw_y = [][] |
4134 | used for userdraw multiple paths |
4162 | used for userdraw multiple paths |
Line 5450... | Line 5478... | ||
5450 | ctx.save();\ |
5478 | ctx.save();\ |
5451 | ctx.translate(x1,y1);\ |
5479 | ctx.translate(x1,y1);\ |
5452 | ctx.rotate(Math.atan2(-dy,-dx));\ |
5480 | ctx.rotate(Math.atan2(-dy,-dx));\ |
5453 | ctx.beginPath();\ |
5481 | ctx.beginPath();\ |
5454 | ctx.moveTo(0,0);\ |
5482 | ctx.moveTo(0,0);\ |
5455 | ctx.lineTo(-1*arrow_head,-0. |
5483 | ctx.lineTo(-1*arrow_head,-0.4*arrow_head);\ |
5456 | ctx.lineTo(-1*arrow_head, 0. |
5484 | ctx.lineTo(-1*arrow_head, 0.4*arrow_head);\ |
5457 | ctx.closePath();\ |
5485 | ctx.closePath();\ |
5458 | ctx.stroke();\ |
5486 | ctx.stroke();\ |
5459 | ctx.fill();\ |
5487 | ctx.fill();\ |
5460 | ctx.restore();\ |
5488 | ctx.restore();\ |
5461 | }\ |
5489 | }\ |
Line 6848... | Line 6876... | ||
6848 | *arrow="arrow", |
6876 | *arrow="arrow", |
6849 | *darrow="darrow", |
6877 | *darrow="darrow", |
6850 | *arrow2="arrow2", |
6878 | *arrow2="arrow2", |
6851 | *darrow2="darrow2", |
6879 | *darrow2="darrow2", |
6852 | *arrows="arrows", |
6880 | *arrows="arrows", |
- | 6881 | *arrows2="arrows2", |
|
6853 | *zoom="zoom", |
6882 | *zoom="zoom", |
6854 | *grid="grid", |
6883 | *grid="grid", |
6855 | *hline="hline", |
6884 | *hline="hline", |
6856 | *dhline="dhline", |
6885 | *dhline="dhline", |
6857 | *drag="drag", |
6886 | *drag="drag", |
Line 7258... | Line 7287... | ||
7258 | } |
7287 | } |
7259 | if( strcmp(input_type, darrow2) == 0 ){ |
7288 | if( strcmp(input_type, darrow2) == 0 ){ |
7260 | free(input_type); |
7289 | free(input_type); |
7261 | use_dashed = TRUE; |
7290 | use_dashed = TRUE; |
7262 | return ARROW2; |
7291 | return ARROW2; |
- | 7292 | } |
|
- | 7293 | if( strcmp(input_type, arrows2) == 0 ){ |
|
- | 7294 | free(input_type); |
|
- | 7295 | return ARROWS2; |
|
7263 | } |
7296 | } |
7264 | if( strcmp(input_type, arrows) == 0 ){ |
7297 | if( strcmp(input_type, arrows) == 0 ){ |
7265 | free(input_type); |
7298 | free(input_type); |
7266 | return ARROWS; |
7299 | return ARROWS; |
7267 | } |
7300 | } |