Rev 18158 | Rev 18164 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 18158 | Rev 18160 | ||
---|---|---|---|
Line 4126... | Line 4126... | ||
4126 | @ choose<ul><li>replyformat 1: <code>x1,x2,x3,x4....x_n<br>y1,y2,y3,y4....y_n</code> x/y in pixels</li><li>replyformat 2: <code> x1,x2,x3,x4....x_n<br> y1,y2,y3,y4....y_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 3: <code> x1,x2,x3,x4....x_n<br> y1,y2,y3,y4....y_n<br> r1,r2,r3,r4....r_n</code> x/y in pixels, r in pixels</li><li>replyformat 4: <code> x1,x2,x3,x4....x_n<br> y1,y2,y3,y4....y_n<br> r1,r2,r3,r4....r_n</code> x/y in xrange / yrange coordinate system, r in pixels</li><li>replyformat 5: <code> Ax1,Ax2,Ax3,Ax4....Ax_n<br> Ay1,Ay2,Ay3,Ay4....Ay_n<br> Bx1,Bx2,Bx3,Bx4....Bx_n<br> By1,By2,By3,By4....By_n<br> Cx1,Cx2,Cx3,Cx4....Cx_n<br> Cy1,Cy2,Cy3,Cy4....Cy_n<br> ....<br> Zx1,Zx2,Zx3,Zx4....Zx_n<br> Zy1,Zy2,Zy3,Zy4....Zy_n</code> x/y in pixels</li><li>replyformat 6: <code> Ax1,Ax2,Ax3,Ax4....Ax_n<br> Ay1,Ay2,Ay3,Ay4....Ay_n<br> Bx1,Bx2,Bx3,Bx4....Bx_n<br> By1,By2,By3,By4....By_n<br> Cx1,Cx2,Cx3,Cx4....Cx_n<br> Cy1,Cy2,Cy3,Cy4....Cy_n<br> ....<br> Zx1,Zx2,Zx3,Zx4....Zx_n<br> Zy1,Zy2,Zy3,Zy4....Zy_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 7: <code> x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n</code> x/y in pixels</li><li>replyformat 8: <code> x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 9: <code> x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n</code> x/y in pixels</li><li>replyformat 10: <code> x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 11: <code> Ax1,Ay1,Ax2,Ay2<br>Bx1,By1,Bx2,By2<br> Cx1,Cy1,Cx2,Cy2<br> Dx1,Dy1,Dx2,Dy2<br> ......<br> Zx1,Zy1,Zx2,Zy2</code> x/y in xrange / yrange coordinate system</li><li>replyformat 12: <code> Ax1,Ay1,Ax2,Ay2<br> Bx1,By1,Bx2,By2<br>Cx1,Cy1,Cx2,Cy2<br> Dx1,Dy1,Dx2,Dy2<br> ......<br> Zx1,Zy1,Zx2,Zy2</code> x/y in pixels</li><li>replyformat 13: <code> Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2,Cx1:Cy1:Cx2:Cy2,Dx1:Dy1:Dx2:Dy2, ... ,Zx1:Zy1:Zx2:Zy2</code> x/y in xrange / yrange coordinate system</li><li>replyformat 14: <code> Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2....Zx1:Zy1:Zx2:Zy2</code> x/y in pixels</li><li>replyformat 15: reply from inputfields,textareas <code>reply1,reply2,reply3,...,reply_n</code></li><li>replyformat 16: mathml input fields</li><li>replyformat 17: read ''userdraw text,color`` only <code>x1,y1,text1 \\n x2,y2,text2...\\n...x_n,y_n,text_n </code> x/y-values are in xrange/yrange</li><li>replyformat 18: read_canvas() will read all interactive clocks in <code>H1:M1:S1,H2:M2:S2...Hn:Mn:Sn</code></li><li>replyformat 19: read_canvas() will return the object number of marked / clicked object (clock), analogue to (shape library) onclick command</li><li>replyformat 20: read_canvas() will reply "object_number:x:y" of external images: object_number of the first draggable external image in the fly-script starts with 0, e.g. expect something like 0:-5:4,1:6:2,2:-2:-5, the first image position is (-5:4), the second image position is (6:2) and the third image position is (-2:-5) <li>replyformat 21: <code> (x1:y1) (x2:y2) ... (x_n:y_n)</code> verbatim coordinate return</li><li>replyformat 22: returns an array .... <code>reply[0]=x1 reply[1]=y1 reply[2]=x2 reply[3]=y2 ... reply[n-1]=x_n reply[n]=y_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 23: can only be used for drawtype ''polyline``. A typical click sequence in drawtype polyline is x1,y1,x2,y2,x2,y2,x3,y3,x3,y3.....,x(n-1),y(n-1),x(n-1),y(n-1),xn,yn --replyformat 23 gives <code>x1,y1,x2,y2,x3,y3,.....x(n-1),y(n-1),xn,yn</code>; multiple occurences will be filtered out. The reply will be in x-y-range (xreply \\n yreply)</li><li>replyformat 24: read all inputfield values: even those set ''readonly``</li><li>replyformat 25: <code> angle1,angle2;...;angle_n</code> will return the radius (one or many) of the user drawn circle segment in degrees</li><li>replyformat 26: <code> rad1,rad2,...rad_n</code> will return the radius (one or many) of the user drawn circle segment in radians</li><li>replyformat 27: return (only) userdraw inputfields <code>x1,y1,text1<br> x2,y2,text2...<br>...x_n,y_n,textn</code></li><li>replyformat 28: <code> x1,y1,r1,x2,y2,r2...x_n,y_n,r_n</code> x / y / r in xrange / yrange coordinate system: may be used to reinput into command <code>circles color,x1,y1,r1,x2,y2,r2...x_n,y_n,r_n</code> will not return anything else (e.g. no inputfields, text etc)</li><li>replyformat 34: a special for OEF and dragging external images -included via commands <a href='#copy'>copy</a> or <a href='#copyresized'>copyresized</a> there will be an extra function <code>read_canvas_images()</code> for reading the coordinates of the images.<br>for now this is a unique function, e.g. there is no ''canvas id`` linked to it. (TO DO !!! 18/5/2019)</li></ul> |
4126 | @ choose<ul><li>replyformat 1: <code>x1,x2,x3,x4....x_n<br>y1,y2,y3,y4....y_n</code> x/y in pixels</li><li>replyformat 2: <code> x1,x2,x3,x4....x_n<br> y1,y2,y3,y4....y_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 3: <code> x1,x2,x3,x4....x_n<br> y1,y2,y3,y4....y_n<br> r1,r2,r3,r4....r_n</code> x/y in pixels, r in pixels</li><li>replyformat 4: <code> x1,x2,x3,x4....x_n<br> y1,y2,y3,y4....y_n<br> r1,r2,r3,r4....r_n</code> x/y in xrange / yrange coordinate system, r in pixels</li><li>replyformat 5: <code> Ax1,Ax2,Ax3,Ax4....Ax_n<br> Ay1,Ay2,Ay3,Ay4....Ay_n<br> Bx1,Bx2,Bx3,Bx4....Bx_n<br> By1,By2,By3,By4....By_n<br> Cx1,Cx2,Cx3,Cx4....Cx_n<br> Cy1,Cy2,Cy3,Cy4....Cy_n<br> ....<br> Zx1,Zx2,Zx3,Zx4....Zx_n<br> Zy1,Zy2,Zy3,Zy4....Zy_n</code> x/y in pixels</li><li>replyformat 6: <code> Ax1,Ax2,Ax3,Ax4....Ax_n<br> Ay1,Ay2,Ay3,Ay4....Ay_n<br> Bx1,Bx2,Bx3,Bx4....Bx_n<br> By1,By2,By3,By4....By_n<br> Cx1,Cx2,Cx3,Cx4....Cx_n<br> Cy1,Cy2,Cy3,Cy4....Cy_n<br> ....<br> Zx1,Zx2,Zx3,Zx4....Zx_n<br> Zy1,Zy2,Zy3,Zy4....Zy_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 7: <code> x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n</code> x/y in pixels</li><li>replyformat 8: <code> x1:y1,x2:y2,x3:y3,x4:y4...x_n:y_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 9: <code> x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n</code> x/y in pixels</li><li>replyformat 10: <code> x1:y1:r1,x2:y2:r2,x3:y3:r3,x4:y4:r3...x_n:y_n:r_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 11: <code> Ax1,Ay1,Ax2,Ay2<br>Bx1,By1,Bx2,By2<br> Cx1,Cy1,Cx2,Cy2<br> Dx1,Dy1,Dx2,Dy2<br> ......<br> Zx1,Zy1,Zx2,Zy2</code> x/y in xrange / yrange coordinate system</li><li>replyformat 12: <code> Ax1,Ay1,Ax2,Ay2<br> Bx1,By1,Bx2,By2<br>Cx1,Cy1,Cx2,Cy2<br> Dx1,Dy1,Dx2,Dy2<br> ......<br> Zx1,Zy1,Zx2,Zy2</code> x/y in pixels</li><li>replyformat 13: <code> Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2,Cx1:Cy1:Cx2:Cy2,Dx1:Dy1:Dx2:Dy2, ... ,Zx1:Zy1:Zx2:Zy2</code> x/y in xrange / yrange coordinate system</li><li>replyformat 14: <code> Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2....Zx1:Zy1:Zx2:Zy2</code> x/y in pixels</li><li>replyformat 15: reply from inputfields,textareas <code>reply1,reply2,reply3,...,reply_n</code></li><li>replyformat 16: mathml input fields</li><li>replyformat 17: read ''userdraw text,color`` only <code>x1,y1,text1 \\n x2,y2,text2...\\n...x_n,y_n,text_n </code> x/y-values are in xrange/yrange</li><li>replyformat 18: read_canvas() will read all interactive clocks in <code>H1:M1:S1,H2:M2:S2...Hn:Mn:Sn</code></li><li>replyformat 19: read_canvas() will return the object number of marked / clicked object (clock), analogue to (shape library) onclick command</li><li>replyformat 20: read_canvas() will reply "object_number:x:y" of external images: object_number of the first draggable external image in the fly-script starts with 0, e.g. expect something like 0:-5:4,1:6:2,2:-2:-5, the first image position is (-5:4), the second image position is (6:2) and the third image position is (-2:-5) <li>replyformat 21: <code> (x1:y1) (x2:y2) ... (x_n:y_n)</code> verbatim coordinate return</li><li>replyformat 22: returns an array .... <code>reply[0]=x1 reply[1]=y1 reply[2]=x2 reply[3]=y2 ... reply[n-1]=x_n reply[n]=y_n</code> x/y in xrange / yrange coordinate system</li><li>replyformat 23: can only be used for drawtype ''polyline``. A typical click sequence in drawtype polyline is x1,y1,x2,y2,x2,y2,x3,y3,x3,y3.....,x(n-1),y(n-1),x(n-1),y(n-1),xn,yn --replyformat 23 gives <code>x1,y1,x2,y2,x3,y3,.....x(n-1),y(n-1),xn,yn</code>; multiple occurences will be filtered out. The reply will be in x-y-range (xreply \\n yreply)</li><li>replyformat 24: read all inputfield values: even those set ''readonly``</li><li>replyformat 25: <code> angle1,angle2;...;angle_n</code> will return the radius (one or many) of the user drawn circle segment in degrees</li><li>replyformat 26: <code> rad1,rad2,...rad_n</code> will return the radius (one or many) of the user drawn circle segment in radians</li><li>replyformat 27: return (only) userdraw inputfields <code>x1,y1,text1<br> x2,y2,text2...<br>...x_n,y_n,textn</code></li><li>replyformat 28: <code> x1,y1,r1,x2,y2,r2...x_n,y_n,r_n</code> x / y / r in xrange / yrange coordinate system: may be used to reinput into command <code>circles color,x1,y1,r1,x2,y2,r2...x_n,y_n,r_n</code> will not return anything else (e.g. no inputfields, text etc)</li><li>replyformat 34: a special for OEF and dragging external images -included via commands <a href='#copy'>copy</a> or <a href='#copyresized'>copyresized</a> there will be an extra function <code>read_canvas_images()</code> for reading the coordinates of the images.<br>for now this is a unique function, e.g. there is no ''canvas id`` linked to it. (TO DO !!! 18/5/2019)</li></ul> |
4127 | @ special replyformat = 100 ; will access to the raw javascript object data...use: read_dragdrop([property,property,...])<br>for example properies like 'clicked','text', 'angle' , 'x' |
4127 | @ special replyformat = 100 ; will access to the raw javascript object data...use: read_dragdrop([property,property,...])<br>for example properies like 'clicked','text', 'angle' , 'x' |
4128 | */ |
4128 | */ |
4129 | reply_format = (int) get_real(infile,1); |
4129 | reply_format = (int) get_real(infile,1); |
4130 | reply_precision = precision; |
4130 | reply_precision = precision; |
- | 4131 | break; |
|
- | 4132 | ||
- | 4133 | case RESET: |
|
- | 4134 | no_reset=FALSE; |
|
- | 4135 | reset(); |
|
4131 | break; |
4136 | break; |
4132 | 4137 | ||
4133 | case ROUNDRECT: |
4138 | case ROUNDRECT: |
4134 | /* |
4139 | /* |
4135 | @ roundrect x1,y1,x2,y2,radius in px,color |
4140 | @ roundrect x1,y1,x2,y2,radius in px,color |
Line 5083... | Line 5088... | ||
5083 | case 0: affine_matrix[4] = get_real(infile,0);break; |
5088 | case 0: affine_matrix[4] = get_real(infile,0);break; |
5084 | case 1: affine_matrix[5] = get_real(infile,1); |
5089 | case 1: affine_matrix[5] = get_real(infile,1); |
5085 | use_affine = TRUE; |
5090 | use_affine = TRUE; |
5086 | /* the other values affine_matrix[0..3] remain untouched*/ |
5091 | /* the other values affine_matrix[0..3] remain untouched*/ |
5087 | break; |
5092 | break; |
5088 | default: break; |
5093 | default: break; |
5089 | } |
5094 | } |
5090 | } |
5095 | } |
5091 | break; |
5096 | break; |
5092 | 5097 | ||
5093 | case TRIANGLE: |
5098 | case TRIANGLE: |
5094 | /* |
5099 | /* |
5095 | @ triangle x1,y1,x2,y2,x3,y3,color |
5100 | @ triangle x1,y1,x2,y2,x3,y3,color |
5096 | @ use ftriangle or keyword <a href='#filled'>filled</a> for a solid triangle |
5101 | @ use ftriangle or keyword <a href='#filled'>filled</a> for a solid triangle |
5097 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> |
5102 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> |
Line 5445... | Line 5450... | ||
5445 | add_to_buffer(tmp_buffer); |
5450 | add_to_buffer(tmp_buffer); |
5446 | if(onclick != 0){object_cnt++;} |
5451 | if(onclick != 0){object_cnt++;} |
5447 | /* object_cnt++; */ |
5452 | /* object_cnt++; */ |
5448 | reset(); |
5453 | reset(); |
5449 | break; |
5454 | break; |
5450 | } |
5455 | } |
5451 | } |
5456 | } |
5452 | dragstuff[4] = 1; |
5457 | dragstuff[4] = 1; |
5453 | if(use_dragstuff == 0 ){ use_dragstuff = 1; } |
5458 | if(use_dragstuff == 0 ){ use_dragstuff = 1; } |
5454 | break; |
5459 | break; |
5455 | 5460 | ||
5456 | case VLINES: |
5461 | case VLINES: |
5457 | /* |
5462 | /* |
Line 5566... | Line 5571... | ||
5566 | @ draw multiple points with x-errorbars E1 (error value left from point) and E2 (error value right from point) at given coordinates in color 'color' |
5571 | @ draw multiple points with x-errorbars E1 (error value left from point) and E2 (error value right from point) at given coordinates in color 'color' |
5567 | @ the errors E1 and E2 values are in xrange. |
5572 | @ the errors E1 and E2 values are in xrange. |
5568 | @ use command ''linewidth int`` to adust size |
5573 | @ use command ''linewidth int`` to adust size |
5569 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> individually (!) |
5574 | @ may be set <a href="#drag">draggable</a> / <a href="#onclick">onclick</a> individually (!) |
5570 | @%xerrorbars%size 400,400%xrange -10,10%yrange -10,10%linewidth 2%drag xy%xerrorbars red,0.8,1.3,0,0,1,1,2,3,3,2,4,5,5,2,6,1,-1,-2,-2,0,-3,2,-4,4,-5,-1 |
5575 | @%xerrorbars%size 400,400%xrange -10,10%yrange -10,10%linewidth 2%drag xy%xerrorbars red,0.8,1.3,0,0,1,1,2,3,3,2,4,5,5,2,6,1,-1,-2,-2,0,-3,2,-4,4,-5,-1 |
5571 | 5576 | ||
5572 | */ |
5577 | */ |
5573 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
5578 | stroke_color=get_color(infile,0); /* how nice: now the color comes first...*/ |
5574 | fill_color = stroke_color; |
5579 | fill_color = stroke_color; |
5575 | i=0; |
5580 | i=0; |
5576 | while( ! done ){ /* get next item until EOL*/ |
5581 | while( ! done ){ /* get next item until EOL*/ |
5577 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
5582 | if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");} |
Line 5686... | Line 5691... | ||
5686 | @ use together with command <a href="#display">display or mouse</a> |
5691 | @ use together with command <a href="#display">display or mouse</a> |
5687 | @ will display the cursor x-coordinate in ''unit`` |
5692 | @ will display the cursor x-coordinate in ''unit`` |
5688 | @%xunit%size 400,400%xrange -10,10%yrange -10,10%xunit cm \\u00B2%grid 2,2,grey%linewidth 2%userdraw segments,blue%display x,blue,18 |
5693 | @%xunit%size 400,400%xrange -10,10%yrange -10,10%xunit cm \\u00B2%grid 2,2,grey%linewidth 2%userdraw segments,blue%display x,blue,18 |
5689 | */ |
5694 | */ |
5690 | fprintf(js_include_file,"unit_x = \"%s\";",get_string(infile,1)); |
5695 | fprintf(js_include_file,"unit_x = \"%s\";",get_string(infile,1)); |
5691 | break; |
5696 | break; |
5692 | 5697 | ||
5693 | case XLABEL: |
5698 | case XLABEL: |
5694 | /* |
5699 | /* |
5695 | @ xlabel some_string |
5700 | @ xlabel some_string |
5696 | @ will be used to create a label for the x-axis (label is in quadrant I) |
5701 | @ will be used to create a label for the x-axis (label is in quadrant I) |
5697 | @ can only be used together with command ''grid``<br>not depending on keywords ''axis`` and ''axisnumbering`` |
5702 | @ can only be used together with command ''grid``<br>not depending on keywords ''axis`` and ''axisnumbering`` |
Line 5699... | Line 5704... | ||
5699 | @ use <a href="#ylabel">ylabel</a> |
5704 | @ use <a href="#ylabel">ylabel</a> |
5700 | @%xlabel%size 400,400%xrange -10,10%yrange -10,10%axis%axisnumbering%xlabel cm\\u00B2 %ylabel v\\u00B2 %precision 1%grid 2,2,grey,2,2,5,grey |
5705 | @%xlabel%size 400,400%xrange -10,10%yrange -10,10%axis%axisnumbering%xlabel cm\\u00B2 %ylabel v\\u00B2 %precision 1%grid 2,2,grey,2,2,5,grey |
5701 | */ |
5706 | */ |
5702 | temp = get_string(infile,1); |
5707 | temp = get_string(infile,1); |
5703 | fprintf(js_include_file,"var xaxislabel = \"%s\";",temp); |
5708 | fprintf(js_include_file,"var xaxislabel = \"%s\";",temp); |
5704 | break; |
5709 | break; |
5705 | 5710 | ||
5706 | case XLOGBASE: |
5711 | case XLOGBASE: |
5707 | /* |
5712 | /* |
5708 | @ xlogbase number |
5713 | @ xlogbase number |
5709 | @ sets the logbase number for the x-axis |
5714 | @ sets the logbase number for the x-axis |
Line 5742... | Line 5747... | ||
5742 | case 3: fill_color = get_color(infile,1); |
5747 | case 3: fill_color = get_color(infile,1); |
5743 | string_length = 1 + snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision); |
5748 | string_length = 1 + snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision); |
5744 | tmp_buffer = my_newmem(string_length); |
5749 | tmp_buffer = my_newmem(string_length); |
5745 | snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision); |
5750 | snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%f,%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,double_data[0],int_data[0],precision); |
5746 | fprintf(js_include_file,"use_xlogscale=1;snap_y = %f;snap_x = xlogbase;",double_data[0]/int_data[0]); |
5751 | fprintf(js_include_file,"use_xlogscale=1;snap_y = %f;snap_x = xlogbase;",double_data[0]/int_data[0]); |
5747 | add_to_buffer(tmp_buffer); |
5752 | add_to_buffer(tmp_buffer); |
5748 | break; |
5753 | break; |
5749 | default:break; |
5754 | default:break; |
5750 | } |
5755 | } |
5751 | } |
5756 | } |
5752 | break; |
5757 | break; |
5753 | 5758 | ||
5754 | case XYLOGSCALE: |
5759 | case XYLOGSCALE: |
5755 | /* |
5760 | /* |
5756 | @ xylogscale majorcolor,minorcolor |
5761 | @ xylogscale majorcolor,minorcolor |
5757 | @ the x/y-range are set using commands ''xrange xmin,xmax`` and ''yrange ymin,ymax`` |
5762 | @ the x/y-range are set using commands ''xrange xmin,xmax`` and ''yrange ymin,ymax`` |
Line 6047... | Line 6052... | ||
6047 | ** |
6052 | ** |
6048 | ******************************************************************************/ |
6053 | ******************************************************************************/ |
6049 | void sync_input(FILE *infile) |
6054 | void sync_input(FILE *infile) |
6050 | { |
6055 | { |
6051 | int c = 0; |
6056 | int c = 0; |
6052 | 6057 | ||
6053 | if( c == '\n' || c == ';' ) return; |
6058 | if( c == '\n' || c == ';' ) return; |
6054 | while( ( (c=getc(infile)) != EOF ) && (c != '\n') && (c != '\r') && (c != ';')) ; |
6059 | while( ( (c=getc(infile)) != EOF ) && (c != '\n') && (c != '\r') && (c != ';')) ; |
6055 | if( c == EOF ) finished = 1; |
6060 | if( c == EOF ) finished = 1; |
6056 | if( c == '\n' || c == '\r' || c == ';') line_number++; |
6061 | if( c == '\n' || c == '\r' || c == ';') line_number++; |
6057 | return; |
6062 | return; |
6058 | } |
6063 | } |
6059 | 6064 | ||
6060 | /******************************************************************************/ |
6065 | /******************************************************************************/ |
6061 | 6066 | ||
6062 | 6067 | ||
6063 | void transform(int num,int incr){ |
6068 | void transform(int num,int incr){ |
6064 | /*. |
6069 | /*. |
6065 | only "double_data[]" is used for transformations !! |
6070 | only "double_data[]" is used for transformations !! |
6066 | */ |
6071 | */ |
6067 | int i;int ii;double x,y; |
6072 | int i;int ii;double x,y; |
Line 6081... | Line 6086... | ||
6081 | int i;int ii;double rad = angle * 0.0174532925199; |
6086 | int i;int ii;double rad = angle * 0.0174532925199; |
6082 | double c = cos(rad); |
6087 | double c = cos(rad); |
6083 | double s = sin(rad); |
6088 | double s = sin(rad); |
6084 | double x,y; |
6089 | double x,y; |
6085 | for(i=0;i<num;i = i+incr){ |
6090 | for(i=0;i<num;i = i+incr){ |
6086 | ii = i+1; |
6091 | ii = i+1; |
6087 | x = c*(double_data[i]-center[0]) + s*(double_data[ii] - center[1] ) + center[0]; |
6092 | x = c*(double_data[i]-center[0]) + s*(double_data[ii] - center[1] ) + center[0]; |
6088 | y = c*(double_data[ii]-center[1]) - s*(double_data[i] - center[0] ) + center[1]; |
6093 | y = c*(double_data[ii]-center[1]) - s*(double_data[i] - center[0] ) + center[1]; |
6089 | double_data[i] = x; |
6094 | double_data[i] = x; |
6090 | double_data[ii] = y; |
6095 | double_data[ii] = y; |
6091 | // printf("(x:y) - (%f:%f)<br>",x,y); |
6096 | // printf("(x:y) - (%f:%f)<br>",x,y); |
Line 6114... | Line 6119... | ||
6114 | size_t newlen = strlen(new); |
6119 | size_t newlen = strlen(new); |
6115 | if (oldlen != newlen){ |
6120 | if (oldlen != newlen){ |
6116 | for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){ |
6121 | for (count = 0, p = str; (q = strstr(p, old)) != NULL; p = q + oldlen){ |
6117 | count++; |
6122 | count++; |
6118 | retlen = p - str + strlen(p) + count * (newlen - oldlen); |
6123 | retlen = p - str + strlen(p) + count * (newlen - oldlen); |
6119 | } |
6124 | } |
6120 | } |
6125 | } |
6121 | else |
6126 | else |
6122 | { |
6127 | { |
6123 | retlen = strlen(str); |
6128 | retlen = strlen(str); |
6124 | } |
6129 | } |
Line 6214... | Line 6219... | ||
6214 | char temp[MAX_BUFFER], *string; |
6219 | char temp[MAX_BUFFER], *string; |
6215 | while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != '\t') && ( c != ',')){ |
6220 | while(( (c=getc(infile)) != EOF ) && ( c != '\n') && ( c != '\t') && ( c != ',')){ |
6216 | temp[i]=c; |
6221 | temp[i]=c; |
6217 | i++; |
6222 | i++; |
6218 | if(i > MAX_BUFFER){ canvas_error("string size too big...will cut it off");break;} |
6223 | if(i > MAX_BUFFER){ canvas_error("string size too big...will cut it off");break;} |
6219 | } |
6224 | } |
6220 | if( ( c == '\n' || c == EOF) && last == 0){canvas_error("expecting more arguments in command");} |
6225 | if( ( c == '\n' || c == EOF) && last == 0){canvas_error("expecting more arguments in command");} |
6221 | if( c == '\n' || c == '\t' ) { line_number++; } |
6226 | if( c == '\n' || c == '\t' ) { line_number++; } |
6222 | if( c == EOF ) {finished = 1;} |
6227 | if( c == EOF ) {finished = 1;} |
6223 | if( finished == 1 && last == 0 ){ canvas_error("expected more arguments");} |
6228 | if( finished == 1 && last == 0 ){ canvas_error("expected more arguments");} |
6224 | temp[i]='\0'; |
6229 | temp[i]='\0'; |
Line 6281... | Line 6286... | ||
6281 | 6286 | ||
6282 | void canvas_error(char *msg){ |
6287 | void canvas_error(char *msg){ |
6283 | fprintf(stdout,"\n</script><hr><span style=\"color:red\">FATAL syntax error: line %d: %s</span><hr>",line_number,msg); |
6288 | fprintf(stdout,"\n</script><hr><span style=\"color:red\">FATAL syntax error: line %d: %s</span><hr>",line_number,msg); |
6284 | finished = 1; |
6289 | finished = 1; |
6285 | exit(EXIT_SUCCESS); |
6290 | exit(EXIT_SUCCESS); |
6286 | } |
6291 | } |
6287 | 6292 | ||
6288 | 6293 | ||
6289 | /* convert x/y coordinates to pixel */ |
6294 | /* convert x/y coordinates to pixel */ |
6290 | int x2px(double x){ |
6295 | int x2px(double x){ |
6291 | return x*xsize/(xmax - xmin) - xsize*xmin/(xmax - xmin); |
6296 | return x*xsize/(xmax - xmin) - xsize*xmin/(xmax - xmin); |
Line 6298... | Line 6303... | ||
6298 | double px2x(int x){ |
6303 | double px2x(int x){ |
6299 | return (x*(xmax - xmin)/xsize + xmin); |
6304 | return (x*(xmax - xmin)/xsize + xmin); |
6300 | } |
6305 | } |
6301 | double px2y(int y){ |
6306 | double px2y(int y){ |
6302 | return (y*(ymax - ymin)/ysize + ymin); |
6307 | return (y*(ymax - ymin)/ysize + ymin); |
6303 | } |
6308 | } |
6304 | 6309 | ||
6305 | void add_to_buffer(char *tmp){ |
6310 | void add_to_buffer(char *tmp){ |
6306 | //fprintf(stdout,"tmp = %s<br>buffer = %s<br>",tmp,buffer); |
6311 | //fprintf(stdout,"tmp = %s<br>buffer = %s<br>",tmp,buffer); |
6307 | if( tmp == NULL || tmp == 0 ){ canvas_error("nothing to add_to_buffer()...");} |
6312 | if( tmp == NULL || tmp == 0 ){ canvas_error("nothing to add_to_buffer()...");} |
6308 | /* do we have enough space left in buffer[MAX_BUFFER] ? */ |
6313 | /* do we have enough space left in buffer[MAX_BUFFER] ? */ |
Line 6315... | Line 6320... | ||
6315 | canvas_error("your memory buffer is too big<br>simplify your script...it produces too many lines "); |
6320 | canvas_error("your memory buffer is too big<br>simplify your script...it produces too many lines "); |
6316 | } |
6321 | } |
6317 | tmp = NULL;free(tmp); |
6322 | tmp = NULL;free(tmp); |
6318 | return; |
6323 | return; |
6319 | } |
6324 | } |
- | 6325 | ||
6320 | 6326 | ||
6321 | void reset(){ |
6327 | void reset(){ |
6322 | if(no_reset == FALSE){ /* 8/5/2020 */ |
6328 | if(no_reset == FALSE){ /* 8/5/2020 */ |
6323 | use_filled = FALSE; |
6329 | use_filled = FALSE; |
6324 | use_dashed = FALSE; |
6330 | use_dashed = FALSE; |
Line 6389... | Line 6395... | ||
6389 | read(link[0],buffer, sizeof(buffer)); |
6395 | read(link[0],buffer, sizeof(buffer)); |
6390 | close(link[0]); |
6396 | close(link[0]); |
6391 | /* need to remover newline from svg-string on freebsd */ |
6397 | /* need to remover newline from svg-string on freebsd */ |
6392 | char *pch = strstr(buffer, "\n"); |
6398 | char *pch = strstr(buffer, "\n"); |
6393 | while(pch != NULL){ |
6399 | while(pch != NULL){ |
6394 |
|
6400 | strcpy(pch, " "); |
6395 | pch = strstr(buffer, "\n"); |
6401 | pch = strstr(buffer, "\n"); |
6396 | } |
6402 | } |
6397 | string_length = 1 + snprintf(NULL,0,"%s",buffer); |
6403 | string_length = 1 + snprintf(NULL,0,"%s",buffer); |
6398 | svgmol= my_newmem(string_length); |
6404 | svgmol= my_newmem(string_length); |
6399 | snprintf(svgmol,string_length,"%s",buffer); |
6405 | snprintf(svgmol,string_length,"%s",buffer); |
Line 6679... | Line 6685... | ||
6679 | } |
6685 | } |
6680 | return digits; |
6686 | return digits; |
6681 | } |
6687 | } |
6682 | 6688 | ||
6683 | int count_substring(char* string, char* substring) { |
6689 | int count_substring(char* string, char* substring) { |
6684 | int i |
6690 | int i, l1, l2; |
6685 | int count = 0; |
6691 | int count = 0; |
6686 | l1 = strlen(string); |
6692 | l1 = strlen(string); |
6687 | l2 = strlen(substring); |
6693 | l2 = strlen(substring); |
6688 | for(i = 0; i < l1 - l2 + 1; i++) { |
6694 | for(i = 0; i < l1 - l2 + 1; i++) { |
6689 | if(strstr(string + i, substring) == string + i) { |
6695 | if(strstr(string + i, substring) == string + i) { |
Line 6986... | Line 6992... | ||
6986 | *allowdups="allowdups", |
6992 | *allowdups="allowdups", |
6987 | *linear="linear", |
6993 | *linear="linear", |
6988 | *obabel="obabel", |
6994 | *obabel="obabel", |
6989 | *chemtex="chemtex", |
6995 | *chemtex="chemtex", |
6990 | *noreset="noreset", |
6996 | *noreset="noreset", |
- | 6997 | *reset="reset", |
|
6991 | *killreset="killreset", |
6998 | *killreset="killreset", |
6992 | *arrowarc="arrowarc", |
6999 | *arrowarc="arrowarc", |
6993 | *arcarrow="arcarrow", |
7000 | *arcarrow="arcarrow", |
6994 | *newrange="newrange", |
7001 | *newrange="newrange", |
6995 | *canvastype="canvastype"; |
7002 | *canvastype="canvastype"; |
Line 7014... | Line 7021... | ||
7014 | if(strstr(temp,"dash") !=0 && strlen(temp) > 4 ){ |
7021 | if(strstr(temp,"dash") !=0 && strlen(temp) > 4 ){ |
7015 | int p; |
7022 | int p; |
7016 | /* 4/2024 adapt to Flydraw's dashing syntax for all objects with prefix "dash" */ |
7023 | /* 4/2024 adapt to Flydraw's dashing syntax for all objects with prefix "dash" */ |
7017 | use_dashed = TRUE;int idx=0; |
7024 | use_dashed = TRUE;int idx=0; |
7018 | for(p = 4; p < strlen(temp); p++){temp[idx] = temp[p];idx++;} |
7025 | for(p = 4; p < strlen(temp); p++){temp[idx] = temp[p];idx++;} |
7019 | input_type = (char*)my_newmem(idx); snprintf(input_type,idx+1,"%s",temp); |
- | |
7020 | }else{ |
- | |
7021 | input_type=(char*)my_newmem(strlen(temp)); |
- | |
7022 | snprintf(input_type,sizeof(temp),"%s",temp); |
- | |
7023 | } |
7026 | } |
- | 7027 | input_type=(char*)my_newmem(strlen(temp)); |
|
- | 7028 | snprintf(input_type,sizeof(temp),"%s",temp); |
|
- | 7029 | ||
7024 | /* fprintf(stdout,"input_type = %s<br/>",input_type);*/ |
7030 | /* fprintf(stdout,"input_type = %s<br/>",input_type);*/ |
7025 | if( strcmp(input_type, size) == 0 ){ |
7031 | if( strcmp(input_type, size) == 0 ){ |
7026 | free(input_type); |
7032 | free(input_type); |
7027 | return SIZE; |
7033 | return SIZE; |
7028 | } |
7034 | } |
Line 7973... | Line 7979... | ||
7973 | if( strcmp(input_type, chemtex) == 0 ){ |
7979 | if( strcmp(input_type, chemtex) == 0 ){ |
7974 | free(input_type); |
7980 | free(input_type); |
7975 | return CHEMTEX; |
7981 | return CHEMTEX; |
7976 | } |
7982 | } |
7977 | if( strcmp(input_type, noreset) == 0 || strcmp(input_type, killreset) == 0 ){ |
7983 | if( strcmp(input_type, noreset) == 0 || strcmp(input_type, killreset) == 0 ){ |
- | 7984 | free(input_type); |
|
7978 | return NORESET; |
7985 | return NORESET; |
- | 7986 | } |
|
- | 7987 | if( strcmp(input_type, reset) == 0 ){ |
|
- | 7988 | free(input_type); |
|
- | 7989 | return RESET; |
|
7979 | } |
7990 | } |
7980 | if( strcmp(input_type, duplicates) == 0 || strcmp(input_type, allowdups) == 0 ){ |
7991 | if( strcmp(input_type, duplicates) == 0 || strcmp(input_type, allowdups) == 0 ){ |
7981 | free(input_type); |
7992 | free(input_type); |
7982 | return ALLOW_DUPLICATES; |
7993 | return ALLOW_DUPLICATES; |
7983 | } |
7994 | } |