Rev 18558 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8225 | bpr | 1 | #include <assert.h> |
2 | #include "../../Lib/libwims.h" |
||
17583 | schaersvoo | 3 | #define MAX_INT 128 |
18558 | bpr | 4 | #define MAX_BUFFER 65536 |
5 | #define MAX_DRAGSTUFF 27 |
||
6 | #define MAX_MULTI_PRIMITIVES 29 |
||
15111 | schaersvoo | 7 | /* wims : MAX_FWRITE_SIZE 64*1024=65536 == 2*MAX_BUFFER */ |
18558 | bpr | 8 | #define MAX_COLOR_STRING 32 |
9 | #define MAX_SLIDERS 16 |
||
15111 | schaersvoo | 10 | /* the commmand / keyword name collection */ |
18558 | bpr | 11 | typedef enum { |
12 | COMMENT=-2,END,SIZE=1,XRANGE,YRANGE,FONTFAMILY,MATHML,INPUT,TEXTAREA,LINEWIDTH,POLYLINE,POLY, |
||
13 | SEGMENT=15,LINE,DLINE,RECT,ARC,NEW,STRING,STRINGUP,COPY,COPYRESIZED,TRANSPARENT,POINT,CIRCLE, |
||
14 | GETPIXEL,SQUARE,ELLIPSE=31,ROTATE,TYPE,QUALITY,CSS,POINTS,TRIANGLE,HLINE,VLINE,GRID,ZOOM,ARROW, |
||
15 | DARROW,AXIS,FONTSIZE=46,CURVE=50,PLOTSTEPS,TRANGE=53,MOUSE_PRECISION,FLY_TEXT,FLY_TEXTUP,BGIMAGE, |
||
16 | DASHED,PARALLEL,LATTICE,OPACITY,AXIS_NUMBERING,RAYS,OUTPUT,CLOCK,STYLE,USERDRAW,MOUSE,AUDIO, |
||
17 | AUDIOOBJECT,STOP,RESTART,FILLCOLOR,CUBE,CLEARBUTTON,ONCLICK,CROSSHAIR,CROSSHAIRS,BLINK,DASHTYPE, |
||
18 | HTML,CROSSHAIRSIZE,ARROWHEAD,DRAG,HTTP,SLIDER,CLICKTILE=88,CLICKTILE_COLORS,TRANSLATION, |
||
19 | KILLTRANSLATION,ARROW2,DARROW2,SVGCODE=95,ROUNDRECT,HATCHFILL,PATTERNFILL,DIAMONDFILL,DOTFILL, |
||
20 | GRIDFILL,IMAGEFILL,FILL,FILLED,XYLOGSCALE,XLOGSCALE,YLOGSCALE,XLOGBASE,INTOOLTIP,REPLYFORMAT, |
||
21 | VIDEO,BGCOLOR,FLOODFILL,FILLTOBORDER,SETPIXEL,PIXELS,PIXELSIZE,X_AXIS_STRINGS=121,Y_AXIS_STRINGS, |
||
22 | FONTCOLOR,PIECHART,LEGEND,BARCHART,LINEGRAPH,STROKECOLOR,XLABEL,YLABEL,LEGENDCOLORS,ANIMATE,STATUS, |
||
23 | SNAPTOGRID,XSNAPTOGRID,YSNAPTOGRID,USERINPUT_XY,SGRAPH=139,YLOGBASE,AFFINE,KILLAFFINE,LEVELCURVE, |
||
24 | JSMATH,TRACE_JSCURVE,SETLIMITS,JSCURVE,CENTERSTRING,MOUSEX,MOUSEY,MOUSE_DEGREE,MOUSE_DISPLAY,XUNIT, |
||
25 | YUNIT,KILLSLIDER,ANGLE,USERINPUT_FUNCTION,USERINPUT,HALFLINE,FUNCTION_LABEL,SEGMENTS,ARROWS, |
||
26 | CIRCLES,ARROWS2,LINES,RECTS,HALFLINES,HLINES,VLINES,ROUNDRECTS,BEZIER,SNAPTOPOINTS,GROUP, |
||
27 | SNAPTOFUNCTION=175,MULTIDRAW,MULTILINEWIDTH,MULTISTROKECOLORS,MULTISTROKEOPACITY,MULTIFILLCOLORS, |
||
28 | MULTIFILLOPACITY,MULTIFILL,MULTILABEL,MULTIDASH,MULTISNAPTOGRID,MULTIUSERINPUT,PROTRACTOR,RULER, |
||
29 | TRIANGLES, POPUP,X_AXIS_STRINGS_UP,CURSOR,XERRORBARS,YERRORBARS, BOXPLOTDATA=196,USERBOXPLOT, |
||
30 | USERBOXPLOTDATA, ROTATION_CENTER,KILLROTATE,CANVASTYPE, NOXAXIS,NOYAXIS,BOXPLOT,COLORPALETTE, |
||
31 | FILLALL,XYOFFSET, XOFFSET,YOFFSET,CENTERED,RESETOFFSET,TEXTFILL,FILLPATTERN,NUMBERLINE,ELLIPSES, |
||
32 | IMAGEPALETTE, CURVEDARROW2,CURVEDARROW,CURVEDARROWS,CURVEDARROWS2,LATEX,ALLOW_DUPLICATES=223, |
||
33 | LINEAR,KILLLINEAR, OBABEL,CHEMTEX,NORESET,ARCARROW,KILL,RANGE,NEWRANGE,RESET, |
||
18608 | bpr | 34 | HYPCIRCLES,HYPSEGMENTS,HYPLINES,HYPPOLY,HYPRAYS,STROKEOPACITY,FILLOPACITY} keyword; |
18558 | bpr | 35 | |
15111 | schaersvoo | 36 | /* the js_function[] dcollection : js-code without configurable argumens see canvasutil.c */ |
18558 | bpr | 37 | enum {DRAW_GRID, DRAW_CROSSHAIRS,DRAW_GRIDFILL,DRAW_XML,DRAW_ARCS,DRAW_LATTICE,DRAW_INPUTS, |
38 | DRAW_TEXTAREAS,DRAW_HTTP,DRAW_AUDIO,DRAW_VIDEO,DRAW_DOTFILL,DRAW_HATCHFILL,DRAW_IMAGEFILL, |
||
39 | DRAW_FLOODFILL,DRAW_FILLTOBORDER,DRAW_PIXELS,DRAW_LINES,DRAW_PIECHART,DRAW_CLOCK,DRAW_EXTERNAL_IMAGE, |
||
40 | DRAW_DIAMONDFILL,DRAW_SGRAPH,DRAW_YLOGSCALE,DRAW_XLOGSCALE,DRAW_XYLOGSCALE,DRAW_CENTERSTRING, |
||
41 | DRAW_JSFUNCTION,DRAW_BEZIER,DRAW_BOXPLOT,DRAW_JSBOXPLOT,DRAW_NUMBERLINE,JS_FIND_ANGLE,DRAW_TEXTFILL, |
||
42 | INTERACTIVE,JS_ROTATE_MOUSE,JS_TRANSFORM_MOUSE,DRAW_FILL_PATTERN,JS_ZOOM,DRAG_AND_ZOOM, |
||
43 | USERDRAW_AND_ZOOM,JS_RAWMATH,JS_LOAD_IMAGE,JS_SAFE_EVAL,JS_PLOT,JS_MATH,DRAW_TEXTS, |
||
44 | DRAG_EXTERNAL_IMAGE,ADD_USER_INPUTS,JSPLOT_AND_ZOOM,JS_ARROWHEAD,DRAW_SUBSUP,MAX_JS_FUNCTIONS}; |
||
15111 | schaersvoo | 45 | /* end js_function[] */ |
46 | /* default canvasses, eg png images xsize x ysize */ |
||
18558 | bpr | 47 | enum{EXTERNAL_IMAGE_CANVAS, /* this is created first !!! in order to draw on it */ |
48 | BG_CANVAS,STATIC_CANVAS,MOUSE_CANVAS,GRID_CANVAS,DRAG_CANVAS,DRAW_CANVAS,TEXT_CANVAS,CLOCK_CANVAS,ANIMATE_CANVAS,TRACE_CANVAS, |
||
49 | JSPLOT_CANVAS=100, |
||
50 | /* JSPLOT_canvas will be increased with every added inputfield...should not conflict with other images*/ |
||
51 | FILL_CANVAS=200, |
||
52 | /* will be increase with every fill */ |
||
53 | USERDRAW_JSPLOT=300, |
||
54 | /* USERDRAW_JSPLOT will be increased with every added inputfield...should not conflict with other images*/ |
||
55 | CLICKFILL_CANVAS=400, /* will be increase with every click fill */ |
||
56 | BOXPLOT_CANVAS=500, /* will increase with every new boxplot */ |
||
57 | NUMBERLINE_CANVAS=600, |
||
58 | MULTIDRAW_CANVAS=1000, /* + >25 draw types... 1001=points*/ |
||
59 | ZOOM_CANVAS=1100, |
||
60 | STATIC_IMAGE_CANVAS=700}; |
||
61 | |||
7614 | schaersvoo | 62 | #ifndef STD_H |
63 | #define STD_H |
||
64 | |||
65 | #ifndef bool |
||
66 | #define bool char |
||
67 | #endif |
||
68 | #ifndef TRUE |
||
69 | #define TRUE 1 |
||
70 | #endif |
||
71 | #ifndef FALSE |
||
72 | #define FALSE 0 |
||
73 | #endif |
||
74 | |||
75 | #endif |
||
18558 | bpr | 76 | void add_to_buffer(char *tmp); /* add tmp_buffer to the buffer */ |
77 | void check_string_length(int length); |
||
15348 | bpr | 78 | extern void *tmp_buffer; |
7614 | schaersvoo | 79 | |
15111 | schaersvoo | 80 | void rotate(int num,double angle,double center[],int incr); |
81 | void transform(int num,int incr); |
||
82 | void add_read_canvas(int type_reply,int reply_precision); |
||
83 | void add_javascript_function(); |
||
84 | void add_drag_code(int canvas_cnt,int use_dragstuff, int stuff[],int reply_format); |
||
85 | void add_trace_js_mouse(int canvas_cnt,char *stroke_color,char *jsmath,int font_size,double stroke_opacity,int line_width,int crosshair_size,char *css_class); |
||
86 | void add_setlimits(int font_size,char *css_class); |
||
87 | void add_safe_eval(); |
||
88 | void add_calc_y(char *jsmath,int font_size,char *css_class); |
||
89 | void add_slider(int anim); |
||
90 | void add_slider_display(int precision,int font_size,char *font_color,double stroke_opacity); |
||
91 | void add_xyslider(double v1,double v2,int width,int height,char *use_slider,char *label,int slider_cnt,char *stroke_color,char *fill_color,int line_width,double opacity,char *font_family,char *font_color,int use_slider_display); |
||
8225 | bpr | 92 | void *my_newmem(size_t size); |
93 | void canvas_error(char *msg); |
||
15601 | schaersvoo | 94 | char *eval(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int xsteps,int precision,double rotationcenter[]); |
95 | char *eval_parametric(int xsize,int ysize,char *fun1,char* fun2,double xmin,double xmax,double ymin,double ymax, double tmin,double tmax,int plotsteps,int precision,double rotationcenter[]); |
||
8225 | bpr | 96 | char *eval_levelcurve(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int plotsteps,int precision,double level); |
14230 | schaersvoo | 97 | char *getMML(char *tex); |
15111 | schaersvoo | 98 | char *getSVGMOL(char *inputtype,char *keys); |
14208 | schaersvoo | 99 | char *data2js_array(int data[],int len); |
8225 | bpr | 100 | char *double_xy2js_array(double xy[],int len,int decimals); |
15111 | schaersvoo | 101 | char *doubledata2js_array(double data[],int len, int decimals); |
102 | char *list2js_array(char *list,char *s); |
||
8225 | bpr | 103 | int find_number_of_digits(int i); |
104 | int x2px(double x); |
||
105 | int y2px(double y); |
||
15111 | schaersvoo | 106 | char *str_replace(const char *str, const char *old, const char *new); |
107 | void add_clear_button(char *css_class,char *button_text); |
||
108 | void add_js_mouse(int canvas_cnt,int precision,char *stroke_color,int font_size,double stroke_opacity,int type); |
||
109 | void add_js_filltoborder(int canvas_type); |
||
110 | void add_js_multidraw(char *draw_types,char *button_style,int use_offset,int use_controls,int crosshair_size,int use_zoom); |
||
111 | extern void add_js_userdraw(char *draw_type,char *stroke_color,double stroke_opacity,int crosshair_size,int arrow_head,int use_offset, char *css_class,int use_snap,int canvas_type,int use_filled,char * fill_color,double fill_opacity,int line_width,char *font_family); |
||
8244 | schaersvoo | 112 | /* these should be harmonized via switch key !!*/ |
15111 | schaersvoo | 113 | void add_input_circle(int type,int num); |
114 | void add_input_segment(int num); |
||
115 | void add_input_demiline(int num); |
||
116 | void add_input_line(int num); |
||
117 | void add_input_polyline(); |
||
118 | void add_input_crosshair(int num); |
||
119 | void add_input_arrow(int num); |
||
120 | void add_input_xy(int font_size,char *css_class); |
||
121 | void add_input_xyr(int font_size,char *css_class); |
||
122 | void add_input_x1y1x2y2(int font_size,char *css_class); |
||
123 | void add_textarea_xy(char *css_class); |
||
124 | void add_js_zoom_buttons(char *stroke_color,double stroke_opacity); |
||
125 | void add_js_tooltip(char *tooltip_text,char *bgcolor); |
||
126 | void add_js_popup(char *getfile_cmd); |
||
127 | void add_input_jsfunction(char *css_class,char *input_label,int input_cnt,char *stroke_color,float stroke_opacity,int line_width,int use_dashed,int dashtype0,int dashtype1,int font_size); |
||
128 | void add_js_protractor(int type,double xcenter,double ycenter,int size,char *font,char *stroke_color,double stroke_opacity,char *fill_color,double fill_opacity,int line_width,int use_scale,int dynamic,int use_snap); |
||
129 | void add_js_ruler(double x,double y,double sizex,double sizey,char *font,char *stroke_color,double stroke_opacity,char *fill_color,double fill_opacity,int line_width,int dynamic,int use_snap); |
||
130 | void add_color_palette(char *css_class); |
||
131 | void add_js_images(int use_offset,int snap); |
||
16828 | schaersvoo | 132 | int count_substring(char* string, char* substring); |
8225 | bpr | 133 | extern int NUMBER_OF_COLORNAMES; |
134 | extern struct colors { char *hex; char *name; char *rgb; } colors[]; |
||
15111 | schaersvoo | 135 | extern int js_function[MAX_JS_FUNCTIONS]; |
136 | extern int reply_format; |
||
137 | extern int xsize; |
||
138 | extern int ysize; |
||
139 | extern unsigned int canvas_root_id; |
||
140 | extern int user_input_xy; |
||
141 | extern char *css_class; |
||
142 | extern int font_size; |
||
143 | extern char *draw_type; |
||
144 | extern char *function_label; |
||
145 | extern int input_cnt; |
||
146 | extern int use_dashed; |
||
147 | extern int dashtype[]; |
||
148 | extern int jsplot_cnt; |
||
149 | extern int linegraph_cnt; |
||
150 | extern int barchart_cnt; |
||
151 | extern int legend_cnt; |
||
152 | extern int use_axis; |
||
153 | extern int use_axis_numbering; |
||
154 | |||
18558 | bpr | 155 | extern FILE *js_include_file; |
15348 | bpr | 156 | /* used multidraw primitives : identifier in canvasmultidraw.c is index of this array |
15111 | schaersvoo | 157 | static char multidraw_primitives[MAX_MULTI_PRIMITIVES][32] = {"point","points","circle","circles", |
158 | "line","lines","segment","segments", |
||
159 | "arrow","arrows","triangle","triangles", |
||
160 | "closedpoly","text","rect","rects", |
||
161 | "poly","polys","parallelogram","parallelograms", |
||
162 | "images","curvedarrow","curvedarrows","curvedarrow2","curvedarrows2", |
||
163 | "crosshair","crosshairs"}; |
||
164 | size of words "point","points",... == 6,7,.. |
||
165 | static int multidraw_primitives_length[MAX_MULTI_PRIMITIVES] = {7,6,8,7,6,5,9,8,7,6,10,9,11,5,6,5,6,5,15,14,7,14, |
||
166 | 13,13,12,10,11}; |
||
15348 | bpr | 167 | */ |