Subversion Repositories wimsdev

Rev

Rev 17583 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include <assert.h>
  2. #include "../../Lib/libwims.h"
  3. #define MAX_INT 128
  4. #define MAX_BUFFER              65536
  5. #define MAX_DRAGSTUFF           27
  6. #define MAX_MULTI_PRIMITIVES    29
  7. /* wims : MAX_FWRITE_SIZE 64*1024=65536 == 2*MAX_BUFFER */
  8. #define MAX_COLOR_STRING        32
  9. #define MAX_SLIDERS             16
  10. /* the commmand / keyword name collection */
  11. #define END             -1
  12. #define COMMENT         -2
  13. #define SIZE            1
  14. #define XRANGE          2
  15. #define YRANGE          3
  16. #define FONTFAMILY      4
  17. #define MATHML          5
  18. #define INPUT           6
  19. #define TEXTAREA        7
  20. #define LINEWIDTH       8
  21. #define POLYLINE        9
  22. #define POLY            10
  23. #define SEGMENT         15
  24. #define LINE            16
  25. #define DLINE           17
  26. #define RECT            18
  27. #define ARC             19
  28. #define NEW             20
  29. #define STRING          21
  30. #define STRINGUP        22
  31. #define COPY            23
  32. #define COPYRESIZED     24
  33. #define TRANSPARENT     25
  34. #define POINT           26
  35. #define CIRCLE          27
  36. #define GETPIXEL        28
  37. #define SQUARE          29
  38. #define ELLIPSE         31
  39. #define ROTATE          32
  40. #define TYPE            33
  41. #define QUALITY         34
  42. #define CSS     35
  43. #define POINTS          36
  44. #define TRIANGLE        37
  45. #define HLINE           38
  46. #define VLINE           39
  47. #define GRID            40
  48. #define ZOOM            41
  49. #define ARROW           42
  50. #define DARROW          43
  51. #define AXIS            44
  52. #define FONTSIZE        46
  53. #define CURVE           50
  54. #define PLOTSTEPS       51
  55. #define TRANGE          53
  56. #define MOUSE_PRECISION 54
  57. #define FLY_TEXT        55
  58. #define FLY_TEXTUP      56
  59. #define BGIMAGE         57
  60. #define DASHED          58
  61. #define PARALLEL        59
  62. #define LATTICE         60
  63. #define OPACITY         61
  64. #define AXIS_NUMBERING  62
  65. #define RAYS            63
  66. #define OUTPUT          64
  67. #define CLOCK           65
  68. #define STYLE           66
  69. #define USERDRAW        67
  70. #define MOUSE           68
  71. #define AUDIO           69
  72. #define AUDIOOBJECT     70
  73. #define STOP            71
  74. #define RESTART         72
  75. #define FILLCOLOR       73
  76. #define CUBE            74
  77. #define CLEARBUTTON     75
  78. #define ONCLICK         76
  79. #define CROSSHAIR       77
  80. #define CROSSHAIRS      78
  81. #define BLINK           79
  82. #define DASHTYPE        80
  83. #define HTML            81
  84. #define CROSSHAIRSIZE   82
  85. #define ARROWHEAD       83
  86. #define DRAG            84
  87. #define HTTP            85
  88. #define SLIDER          86
  89. #define CLICKTILE       88
  90. #define CLICKTILE_COLORS        89
  91. #define TRANSLATION     90
  92. #define KILLTRANSLATION 91
  93. #define ARROW2          92
  94. #define DARROW2         93
  95. #define SVGCODE         95
  96. #define ROUNDRECT       96
  97. #define HATCHFILL       97
  98. #define PATTERNFILL     98
  99. #define DIAMONDFILL     99
  100. #define DOTFILL         100
  101. #define GRIDFILL        101
  102. #define IMAGEFILL       102
  103. #define FILL            103
  104. #define FILLED          104
  105. #define XYLOGSCALE      105
  106. #define XLOGSCALE       106
  107. #define YLOGSCALE       107
  108. #define XLOGBASE        108
  109. #define INTOOLTIP       109
  110. #define REPLYFORMAT     110
  111. #define VIDEO           111
  112. #define BGCOLOR         112
  113. #define FLOODFILL       113
  114. #define FILLTOBORDER    114
  115. #define SETPIXEL        117
  116. #define PIXELS          118
  117. #define PIXELSIZE       119
  118. #define X_AXIS_STRINGS  121
  119. #define Y_AXIS_STRINGS  122
  120. #define FONTCOLOR       123
  121. #define PIECHART        124
  122. #define LEGEND          125
  123. #define BARCHART        126
  124. #define LINEGRAPH       127
  125. #define STROKECOLOR     128
  126. #define XLABEL          129
  127. #define YLABEL          130
  128. #define LEGENDCOLORS    131
  129. #define ANIMATE         132
  130. #define STATUS          133
  131. #define SNAPTOGRID      134
  132. #define XSNAPTOGRID     135
  133. #define YSNAPTOGRID     136
  134. #define USERINPUT_XY    137
  135. #define SGRAPH          139
  136. #define YLOGBASE        140
  137. #define AFFINE          141
  138. #define KILLAFFINE      142
  139. #define LEVELCURVE      143
  140. #define JSMATH          144
  141. #define TRACE_JSCURVE   145
  142. #define SETLIMITS       146
  143. #define JSCURVE         147
  144. #define CENTERSTRING    148
  145. #define MOUSEX          149
  146. #define MOUSEY          150
  147. #define MOUSE_DEGREE    151
  148. #define MOUSE_DISPLAY   152
  149. #define XUNIT           153
  150. #define YUNIT           154
  151. #define KILLSLIDER      155
  152. #define ANGLE           156
  153. #define USERINPUT_FUNCTION 157
  154. #define USERINPUT       158
  155. #define HALFLINE        159
  156. #define FUNCTION_LABEL  160
  157. #define SEGMENTS        161
  158. #define ARROWS          162
  159. #define CIRCLES         163
  160. #define ARROWS2         164
  161. #define LINES           165
  162. #define RECTS           166
  163. #define HALFLINES       167
  164. #define HLINES          168
  165. #define VLINES          169
  166. #define ROUNDRECTS      170
  167. #define BEZIER          171
  168. #define SNAPTOPOINTS    172
  169. #define GROUP           173
  170. #define SNAPTOFUNCTION  175
  171. #define MULTIDRAW       176
  172. #define MULTILINEWIDTH  177
  173. #define MULTISTROKECOLORS       178
  174. #define MULTISTROKEOPACITY      179
  175. #define MULTIFILLCOLORS 180
  176. #define MULTIFILLOPACITY        181
  177. #define MULTIFILL       182
  178. #define MULTILABEL      183
  179. #define MULTIDASH       184
  180. #define MULTISNAPTOGRID 185
  181. #define MULTIUSERINPUT  186
  182. #define PROTRACTOR      187
  183. #define RULER           188
  184. #define TRIANGLES       189
  185. #define POPUP           190
  186. #define X_AXIS_STRINGS_UP 191
  187. #define CURSOR          192
  188. #define XERRORBARS      193
  189. #define YERRORBARS      194
  190. #define BOXPLOTDATA     196
  191. #define USERBOXPLOT     197
  192. #define USERBOXPLOTDATA 198
  193. #define ROTATION_CENTER 199
  194. #define KILLROTATE      200
  195. #define CANVASTYPE      201
  196. #define NOXAXIS         202
  197. #define NOYAXIS         203
  198. #define BOXPLOT         204
  199. #define COLORPALETTE    205
  200. #define FILLALL         206
  201. #define XYOFFSET        207
  202. #define XOFFSET         208
  203. #define YOFFSET         209
  204. #define CENTERED        210
  205. #define RESETOFFSET     211
  206. #define TEXTFILL        212
  207. #define FILLPATTERN     213
  208. #define NUMBERLINE      214
  209. #define ELLIPSES        215
  210. #define IMAGEPALETTE    216
  211. #define CURVEDARROW2    217
  212. #define CURVEDARROW     218
  213. #define CURVEDARROWS    219
  214. #define CURVEDARROWS2   220
  215. #define LATEX           221
  216. #define ALLOW_DUPLICATES        223
  217. #define LINEAR          224
  218. #define KILLLINEAR      225
  219. #define OBABEL          226
  220. #define CHEMTEX         227
  221. #define NORESET         228
  222. #define ARCARROW        229
  223. #define KILL            230
  224. #define RANGE           231
  225. #define NEWRANGE        232
  226. #define RESET           233
  227. /* the js_function[] dcollection : js-code without configurable argumens see canvasutil.c  */
  228. #define MAX_JS_FUNCTIONS        52
  229.  
  230. #define DRAW_GRID       0
  231. #define DRAW_CROSSHAIRS 1
  232. #define DRAW_GRIDFILL   2
  233. #define DRAW_XML        3
  234. #define DRAW_ARCS       4
  235. #define DRAW_LATTICE    5
  236. #define DRAW_INPUTS     6
  237. #define DRAW_TEXTAREAS  7
  238. #define DRAW_HTTP       8
  239. #define DRAW_AUDIO      9
  240. #define DRAW_VIDEO      10
  241. #define DRAW_DOTFILL    11
  242. #define DRAW_HATCHFILL  12
  243. #define DRAW_IMAGEFILL  13
  244. #define DRAW_FLOODFILL  14
  245. #define DRAW_FILLTOBORDER       15
  246. #define DRAW_PIXELS     16
  247. #define DRAW_LINES      17
  248. #define DRAW_PIECHART   18
  249. #define DRAW_CLOCK      19
  250. #define DRAW_EXTERNAL_IMAGE     20
  251. #define DRAW_DIAMONDFILL        21
  252. #define DRAW_SGRAPH     22
  253. #define DRAW_YLOGSCALE  23
  254. #define DRAW_XLOGSCALE  24
  255. #define DRAW_XYLOGSCALE 25
  256. #define DRAW_CENTERSTRING       26
  257. #define DRAW_JSFUNCTION 27
  258. #define DRAW_BEZIER     28
  259. #define DRAW_BOXPLOT    29
  260. #define DRAW_JSBOXPLOT  30
  261. #define DRAW_NUMBERLINE 31
  262. #define JS_FIND_ANGLE   32
  263. #define DRAW_TEXTFILL   33
  264. #define INTERACTIVE     34
  265. #define JS_ROTATE_MOUSE 35
  266. #define JS_TRANSFORM_MOUSE      36
  267. #define DRAW_FILL_PATTERN       37
  268. #define JS_ZOOM 38
  269. #define DRAG_AND_ZOOM   39
  270. #define USERDRAW_AND_ZOOM       40
  271. #define JS_RAWMATH      41
  272. #define JS_LOAD_IMAGE   42
  273. #define JS_SAFE_EVAL    43
  274. #define JS_PLOT 44
  275. #define JS_MATH 45
  276. #define DRAW_TEXTS      46
  277. #define DRAG_EXTERNAL_IMAGE     47
  278. #define ADD_USER_INPUTS 48
  279. #define JSPLOT_AND_ZOOM 49
  280. #define JS_ARROWHEAD    50
  281. #define DRAW_SUBSUP     51
  282. /*  end js_function[]  */
  283. /* default canvasses, eg png images xsize x ysize */
  284. #define EXTERNAL_IMAGE_CANVAS 0 /* this is created first !!! in order to draw on it */
  285. #define BG_CANVAS       1
  286. #define STATIC_CANVAS   2
  287. #define MOUSE_CANVAS    3
  288. #define GRID_CANVAS     4
  289. #define DRAG_CANVAS     5
  290. #define DRAW_CANVAS     6
  291. #define TEXT_CANVAS     7
  292. #define CLOCK_CANVAS    8
  293. #define ANIMATE_CANVAS  9
  294. #define TRACE_CANVAS    10
  295. #define JSPLOT_CANVAS   100 /* JSPLOT_canvas will be increased with every added inputfield...should not conflict with other images*/
  296. #define FILL_CANVAS     200 /* will be increase with every fill */
  297. #define USERDRAW_JSPLOT 300 /* USERDRAW_JSPLOT will be increased with every added inputfield...should not conflict with other images*/
  298. #define CLICKFILL_CANVAS 400 /* will be increase with every click fill */
  299. #define BOXPLOT_CANVAS  500 /* will increase with every new boxplot */
  300. #define NUMBERLINE_CANVAS 600
  301. #define MULTIDRAW_CANVAS        1000 /* + >25 draw types... 1001=points*/
  302. #define ZOOM_CANVAS     1100
  303. #define STATIC_IMAGE_CANVAS 700
  304. #ifndef STD_H
  305. #define STD_H
  306.  
  307. #ifndef bool
  308. #define bool            char
  309. #endif
  310. #ifndef TRUE
  311. #define TRUE            1
  312. #endif
  313. #ifndef FALSE
  314. #define FALSE           0
  315. #endif
  316.  
  317. #endif
  318. void    add_to_buffer(char *tmp); /* add tmp_buffer to the buffer */
  319. void    check_string_length(int length);
  320. extern void *tmp_buffer;
  321.  
  322. void rotate(int num,double angle,double center[],int incr);
  323. void transform(int num,int incr);
  324. void add_read_canvas(int type_reply,int reply_precision);
  325. void add_javascript_function();
  326. void add_drag_code(int canvas_cnt,int use_dragstuff, int stuff[],int reply_format);
  327. 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);
  328. void add_setlimits(int font_size,char *css_class);
  329. void add_safe_eval();
  330. void add_calc_y(char *jsmath,int font_size,char *css_class);
  331. void add_slider(int anim);
  332. void add_slider_display(int precision,int font_size,char *font_color,double stroke_opacity);
  333. 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);
  334. void *my_newmem(size_t size);
  335. void canvas_error(char *msg);
  336. char *eval(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int xsteps,int precision,double rotationcenter[]);
  337. 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[]);
  338. char *eval_levelcurve(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int plotsteps,int precision,double level);
  339. char *getMML(char *tex);
  340. char *getSVGMOL(char *inputtype,char *keys);
  341. char *data2js_array(int data[],int len);
  342. char *double_xy2js_array(double xy[],int len,int decimals);
  343. char *doubledata2js_array(double data[],int len, int decimals);
  344. char *list2js_array(char *list,char *s);
  345. int find_number_of_digits(int i);
  346. int x2px(double x);
  347. int y2px(double y);
  348. char *str_replace(const char *str, const char *old, const char *new);
  349. void add_clear_button(char *css_class,char *button_text);
  350. void add_js_mouse(int canvas_cnt,int precision,char *stroke_color,int font_size,double stroke_opacity,int type);
  351. void add_js_filltoborder(int canvas_type);
  352. void add_js_multidraw(char *draw_types,char *button_style,int use_offset,int use_controls,int crosshair_size,int use_zoom);
  353. 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);
  354. /* these should  be harmonized via switch key !!*/
  355. void add_input_circle(int type,int num);
  356. void add_input_segment(int num);
  357. void add_input_demiline(int num);
  358. void add_input_line(int num);
  359. void add_input_polyline();
  360. void add_input_crosshair(int num);
  361. void add_input_arrow(int num);
  362. void add_input_xy(int font_size,char *css_class);
  363. void add_input_xyr(int font_size,char *css_class);
  364. void add_input_x1y1x2y2(int font_size,char *css_class);
  365. void add_textarea_xy(char *css_class);
  366. void add_js_zoom_buttons(char *stroke_color,double stroke_opacity);
  367. void add_js_tooltip(char *tooltip_text,char *bgcolor);
  368. void add_js_popup(char *getfile_cmd);
  369. 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);
  370. 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);
  371. 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);
  372. void add_color_palette(char *css_class);
  373. void add_js_images(int use_offset,int snap);
  374. int count_substring(char* string, char* substring);
  375. extern int NUMBER_OF_COLORNAMES;
  376. extern struct colors { char *hex; char *name; char *rgb; } colors[];
  377. extern int js_function[MAX_JS_FUNCTIONS];
  378. extern int reply_format;
  379. extern int xsize;
  380. extern int ysize;
  381. extern unsigned int canvas_root_id;
  382. extern int user_input_xy;
  383. extern char *css_class;
  384. extern int font_size;
  385. extern char *draw_type;
  386. extern char *function_label;
  387. extern int input_cnt;
  388. extern int use_dashed;
  389. extern int dashtype[];
  390. extern int jsplot_cnt;
  391. extern int linegraph_cnt;
  392. extern int barchart_cnt;
  393. extern int legend_cnt;
  394. extern int use_axis;
  395. extern int use_axis_numbering;
  396.  
  397. extern FILE     *js_include_file;
  398. /* used multidraw primitives : identifier in canvasmultidraw.c is index of this array
  399. static char multidraw_primitives[MAX_MULTI_PRIMITIVES][32] = {"point","points","circle","circles",
  400. "line","lines","segment","segments",
  401. "arrow","arrows","triangle","triangles",
  402. "closedpoly","text","rect","rects",
  403. "poly","polys","parallelogram","parallelograms",
  404. "images","curvedarrow","curvedarrows","curvedarrow2","curvedarrows2",
  405. "crosshair","crosshairs"};
  406. size of words "point","points",... == 6,7,..
  407. 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,
  408. 13,13,12,10,11};
  409. */
  410.