Subversion Repositories wimsdev

Rev

Rev 14393 | Rev 14548 | Go to most recent revision | 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 16384
  5. #define MAX_COLOR_STRING        32
  6. #define MAX_JS_FUNCTIONS 64
  7. #define MAX_SLIDERS     16
  8. /* the commmand / keyword name collecton */
  9. #define END             -1
  10. #define COMMENT         -2
  11. #define SIZE            1
  12. #define XRANGE          2
  13. #define YRANGE          3
  14. #define FONTFAMILY      4
  15. #define MATHML          5
  16. #define INPUT           6
  17. #define TEXTAREA        7
  18. #define LINEWIDTH       8
  19. #define POLYLINE        9
  20. #define POLY            10
  21. #define SEGMENT         15
  22. #define LINE            16
  23. #define DLINE           17
  24. #define RECT            18
  25. #define ARC             19
  26. #define NEW             20
  27. #define STRING          21
  28. #define STRINGUP        22
  29. #define COPY            23
  30. #define COPYRESIZED     24
  31. #define TRANSPARENT     25
  32. #define POINT           26
  33. #define CIRCLE          27
  34. #define GETPIXEL        28
  35. #define SQUARE          29
  36. #define ELLIPSE         31
  37. #define ROTATE          32
  38. #define TYPE            33
  39. #define QUALITY         34
  40. #define INPUTSTYLE      35
  41. #define POINTS          36
  42. #define TRIANGLE        37
  43. #define HLINE           38
  44. #define VLINE           39
  45. #define GRID            40
  46. #define ZOOM            41
  47. #define ARROW           42
  48. #define DARROW          43
  49. #define AXIS            44
  50. #define FONTSIZE        46
  51. #define CURVE           50
  52. #define PLOTSTEPS       51
  53. #define TRANGE          53
  54. #define MOUSE_PRECISION 54
  55. #define FLY_TEXT        55
  56. #define FLY_TEXTUP      56
  57. #define BGIMAGE         57
  58. #define DASHED          58
  59. #define PARALLEL        59
  60. #define LATTICE         60
  61. #define OPACITY         61
  62. #define AXIS_NUMBERING  62
  63. #define RAYS            63
  64. #define OUTPUT          64
  65. #define CLOCK           65
  66. #define STYLE           66
  67. #define USERDRAW        67
  68. #define MOUSE           68
  69. #define AUDIO           69
  70. #define AUDIOOBJECT     70
  71. #define STOP            71
  72. #define RESTART         72
  73. #define FILLCOLOR       73
  74. #define CUBE            74
  75. #define CLEARBUTTON     75
  76. #define ONCLICK         76
  77. #define CROSSHAIR       77
  78. #define CROSSHAIRS      78
  79. #define BLINK           79
  80. #define DASHTYPE        80
  81. #define HTML            81
  82. #define CROSSHAIRSIZE   82
  83. #define ARROWHEAD       83
  84. #define DRAG            84
  85. #define HTTP            85
  86. #define SLIDER          86
  87. #define CLICKTILE       88
  88. #define CLICKTILE_COLORS        89
  89. #define TRANSLATION     90
  90. #define KILLTRANSLATION 91
  91. #define ARROW2          92
  92. #define DARROW2         93
  93. #define SVGCODE         95
  94. #define ROUNDRECT       96
  95. #define HATCHFILL       97
  96. #define PATTERNFILL     98
  97. #define DIAMONDFILL     99
  98. #define DOTFILL         100
  99. #define GRIDFILL        101
  100. #define IMAGEFILL       102
  101. #define FILL            103
  102. #define FILLED          104
  103. #define XYLOGSCALE      105
  104. #define XLOGSCALE       106
  105. #define YLOGSCALE       107
  106. #define XLOGBASE        108
  107. #define INTOOLTIP       109
  108. #define REPLYFORMAT     110
  109. #define VIDEO           111
  110. #define BGCOLOR         112
  111. #define FLOODFILL       113
  112. #define FILLTOBORDER    114
  113. #define SETPIXEL        117
  114. #define PIXELS          118
  115. #define PIXELSIZE       119
  116. #define X_AXIS_STRINGS  121
  117. #define Y_AXIS_STRINGS  122
  118. #define FONTCOLOR       123
  119. #define PIECHART        124
  120. #define LEGEND          125
  121. #define BARCHART        126
  122. #define LINEGRAPH       127
  123. #define STROKECOLOR     128
  124. #define XLABEL          129
  125. #define YLABEL          130
  126. #define LEGENDCOLORS    131
  127. #define ANIMATE         132
  128. #define STATUS          133
  129. #define SNAPTOGRID      134
  130. #define XSNAPTOGRID     135
  131. #define YSNAPTOGRID     136
  132. #define USERINPUT_XY    137
  133. #define USERTEXTAREA_XY 138
  134. #define SGRAPH          139
  135. #define YLOGBASE        140
  136. #define AFFINE          141
  137. #define KILLAFFINE      142
  138. #define LEVELCURVE      143
  139. #define JSMATH          144
  140. #define TRACE_JSCURVE   145
  141. #define SETLIMITS       146
  142. #define JSCURVE         147
  143. #define CENTERSTRING    148
  144. #define MOUSEX          149
  145. #define MOUSEY          150
  146. #define MOUSE_DEGREE    151
  147. #define MOUSE_DISPLAY   152
  148. #define XUNIT           153
  149. #define YUNIT           154
  150. #define KILLSLIDER      155
  151. #define ANGLE           156
  152. #define USERINPUT_FUNCTION 157
  153. #define USERINPUT       158
  154. #define HALFLINE        159
  155. #define FUNCTION_LABEL  160
  156. #define SEGMENTS        161
  157. #define ARROWS          162
  158. #define CIRCLES         163
  159. #define ARROWS2         164
  160. #define LINES           165
  161. #define RECTS           166
  162. #define HALFLINES       167
  163. #define HLINES          168
  164. #define VLINES          169
  165. #define ROUNDRECTS      170
  166. #define BEZIER          171
  167. #define SNAPTOPOINTS    172
  168. #define SLIDER_X        173
  169. #define SLIDER_Y        174
  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        222
  217. /* the draw_function collection */
  218. #define DRAW_GRID       0
  219. #define DRAW_SEGMENTS   1
  220. #define DRAW_CROSSHAIRS 2
  221. #define DRAW_RECTS      3
  222. #define DRAW_ROUNDRECTS 4
  223. #define DRAW_ARROWS     6
  224. #define DRAW_GRIDFILL   7
  225. #define DRAW_XML        8
  226. #define DRAW_CIRCLES    9
  227. #define DRAW_ARCS       10
  228. #define DRAW_ELLIPSES   11
  229. #define DRAW_TEXTS      12
  230. #define DRAW_CURVE      13
  231. #define DRAW_PATHS      14
  232. #define DRAW_LATTICE    15
  233. #define DRAW_INPUTS     16
  234. #define DRAW_TEXTAREAS  17
  235. #define DRAW_HTTP       18
  236. #define DRAW_AUDIO      19
  237. #define DRAW_VIDEO      20
  238. #define DRAW_DOTFILL    21
  239. #define DRAW_HATCHFILL  22
  240. #define DRAW_IMAGEFILL  23
  241. #define DRAW_FLOODFILL  24
  242. #define DRAW_FILLTOBORDER       25
  243. #define DRAW_PIXELS     26
  244. #define DRAW_POLY       27
  245. #define DRAW_LINES      28
  246. #define DRAW_PIECHART   29
  247. #define DRAW_CLOCK      30
  248. #define DRAW_EXTERNAL_IMAGE     32
  249. #define DRAW_DIAMONDFILL        33
  250. #define DRAW_SGRAPH     34
  251. #define DRAW_POLYLINE   35
  252. #define DRAW_YLOGSCALE  36
  253. #define DRAW_XLOGSCALE  37
  254. #define DRAW_XYLOGSCALE 38
  255. #define DRAW_CENTERSTRING 39
  256. #define DRAW_JSFUNCTION 40
  257. #define DRAW_DEMILINES  41
  258. #define DRAW_BEZIER     42
  259. #define DRAW_BOXPLOT    43
  260. #define DRAW_JSBOXPLOT  44
  261. #define DRAW_NUMBERLINE 45
  262. #define JS_FIND_ANGLE   46
  263. #define DRAW_TEXTFILL   47
  264. #define ADD_LOAD_IMAGE  48
  265. #define ADD_JS_ROTATE_MOUSE 49
  266.  
  267. #define EXTERNAL_IMAGE_CANVAS 0 /* this is created first !!! in order to draw on it */
  268. #define BG_CANVAS       1
  269. #define STATIC_CANVAS   2
  270. #define MOUSE_CANVAS    3
  271. #define GRID_CANVAS     4
  272. #define DRAG_CANVAS     5
  273. #define DRAW_CANVAS     6
  274. #define TEXT_CANVAS     7
  275. #define CLOCK_CANVAS    8
  276. #define ANIMATE_CANVAS  9
  277. #define TRACE_CANVAS    10
  278. #define JSPLOT_CANVAS   100 /* JSPLOT_canvas will be increased with every added inputfield...should not conflict with other images*/
  279. #define FILL_CANVAS     200 /* will be increase with every fill */
  280. #define USERDRAW_JSPLOT 300 /* USERDRAW_JSPLOT will be increased with every added inputfield...should not conflict with other images*/
  281. #define CLICKFILL_CANVAS 400 /* will be increase with every click fill */
  282. #define BOXPLOT_CANVAS  500 /* will increase with every new boxplot */
  283. #define NUMBERLINE_CANVAS 600
  284.  
  285. #ifndef STD_H
  286. #define STD_H
  287.  
  288. #ifndef bool
  289. #define bool            char
  290. #endif
  291. #ifndef TRUE
  292. #define TRUE            1
  293. #endif
  294. #ifndef FALSE
  295. #define FALSE           0
  296. #endif
  297.  
  298. #endif
  299.  
  300. void add_drag_code(FILE *js_include_file,int canvas_cnt,int canvas_root_id);
  301. void add_trace_js_mouse(FILE *js_include_file,int canvas_cnt,int canvas_root_id,char *stroke_color,char *jsmath,int font_size,double stroke_opacity,int line_width,int crosshair_size,char *input_style);
  302. void add_setlimits(FILE *js_include_file, int canvas_root_id,int font_size,char *input_style);
  303. void add_safe_eval(FILE *js_include_file);
  304. void add_to_js_math(FILE *js_include_file);
  305. void add_calc_y(FILE *js_include_file,int canvas_root_id,char *jsmath,int font_size,char *input_style);
  306. void add_jsplot(FILE *js_include_file,int canvas_root_id);
  307. void add_slider(FILE *js_include_file,int canvas_root_id);
  308. void add_slider_display(FILE *js_include_file, int canvas_root_id,int precision,int font_size,char *font_color,double stroke_opacity);
  309. void add_xyslider(FILE *js_include_file, int canvas_root_id,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);
  310. void *my_newmem(size_t size);
  311. void canvas_error(char *msg);
  312. char *eval(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int xsteps,int precision);
  313. 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);
  314. char *eval_levelcurve(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int plotsteps,int precision,double level);
  315. char *getMML(char *tex);
  316. char *data2js_array(int data[],int len);
  317. char *double_xy2js_array(double xy[],int len,int decimals);
  318. int find_number_of_digits(int i);
  319. int x2px(double x);
  320. int y2px(double y);
  321.  
  322. void add_clear_button(FILE *js_include_file,int canvas_root_id,char *input_style,char *button_text);
  323. void add_js_inputs(FILE *js_include_file,int canvas_root_id,int num,int input_cnt,char *input_style,int line_width,int use_offset,int use_snap);
  324. void add_js_mouse(FILE *js_include_file,int canvas_cnt,int canvas_root_id,int precision,char *stroke_color,int font_size,double stroke_opacity,int type);
  325. void add_js_points(FILE *js_include_file,int num,char *draw_type,int line_width, int radius ,char *stroke_color,double stroke_opacity,int use_filled,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  326. void add_js_circles(FILE *js_include_file,int num,char *draw_type, int line_width, int radius , char *stroke_color,double stroke_opacity,int use_filled,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  327. void add_js_segments(FILE *js_include_file,int num,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  328. void add_js_demilines(FILE *js_include_file,int num,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  329. void add_js_polyline(FILE *js_include_file,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  330. void add_js_lines(FILE *js_include_file,int num,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  331. void add_js_hlines(FILE *js_include_file,int num,char *draw_type,int line_width, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  332. void add_js_arrows(FILE *js_include_file,int num,char *draw_type,int line_width,int type, char *stroke_color,double stroke_opacity,int use_dashed,int dashtype0,int dashtype1,int arrow_head,int use_snap);
  333. void add_js_curvedarrow(FILE *js_include_file,int canvas_root_id,int num,int line_width,char *stroke_color,double stroke_opacity,int use_dashed,int arrow_head,int type,int use_snap);
  334. void add_js_crosshairs(FILE *js_include_file,int num,char *draw_type,int line_width, int crosshair_size ,char *stroke_color,double stroke_opacity,int use_snap);
  335. void add_js_paths(FILE *js_include_file,int num,char *draw_type,int line_width, int closed_path,char *stroke_color,double stroke_opacity,int use_filled, char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  336. void add_js_poly(FILE *js_include_file,int num,char *draw_type,int line_width,char *stroke_color,double stroke_opacity,int use_filled,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  337. void add_js_rect(FILE *js_include_file,int num,int roundrect,char *draw_type,int line_width,char *stroke_color,double stroke_opacity,int use_filled,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1,int use_snap);
  338. void add_js_clickfill(FILE *js_include_file,int canvas_root_id,char *clickcolor,int opacity,int use_snap);
  339. void add_js_filltoborder(FILE *js_include_file,int canvas_root_id,int canvas_type);
  340. void add_js_arc(FILE *js_include_file,int canvas_root_id,int num,int line_width,char *stroke_color,double stroke_opacity,char *fill_color,double fill_opacity,int use_dashed,int dashtype0,int dashtype1,int use_filled,int use_snap);
  341. void add_js_text(FILE *js_include_file,int canvas_root_id,int font_size,char *font_family,char *font_color,double stroke_opacity,int use_snap);
  342. void add_js_multidraw(FILE *js_include_file,int canvas_root_id,char *draw_types,char *button_style,int use_offset);
  343. /* these should  be harmonized via switch key !!*/
  344. void add_input_circle(FILE *js_include_file,int type,int num);
  345. void add_input_segment(FILE *js_include_file,int num);
  346. void add_input_demiline(FILE *js_include_file,int num);
  347. void add_input_line(FILE *js_include_file,int num);
  348. void add_input_polyline(FILE *js_include_file);
  349. void add_textarea_polygon(FILE *js_include_file);
  350. void add_input_crosshair(FILE *js_include_file,int num);
  351. void add_input_arrow(FILE *js_include_file,int num);
  352. void add_input_xy(FILE *js_include_file, int canvas_root_id,int font_size,char *input_style);
  353. void add_input_xyr(FILE *js_include_file, int canvas_root_id,int font_size,char *input_style);
  354. void add_input_x1y1x2y2(FILE *js_include_file, int canvas_root_id,int font_size,char *input_style);
  355. void add_textarea_xy(FILE *js_include_file, int canvas_root_id,char *input_style);
  356. void add_zoom_buttons(FILE *js_include_file,int canvas_root_id,char *stroke_color,double stroke_opacity);
  357. void add_js_tooltip(int canvas_root_id,char *tooltip_text,char *bgcolor,int xsize,int ysize);
  358. void add_js_popup(int canvas_root_id,int xsize,int ysize,char *getfile_cmd);
  359. void add_input_jsfunction(FILE *js_include_file, int canvas_root_id,char *input_style,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);
  360. void add_rawmath(FILE *js_include_file);
  361. void add_js_protractor(FILE *js_include_file,int canvas_root_id,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);
  362. void add_js_ruler(FILE *js_include_file,int canvas_root_id,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);
  363. void add_color_palette(FILE *js_include_file,int canvas_root_id,char *input_style);
  364. void add_js_load_image(FILE *js_include_file,int canvas_root_id);
  365. void add_js_images(FILE *js_include_file,int canvas_root_id,int use_offset,int snap);
  366. extern int NUMBER_OF_COLORNAMES;
  367. extern struct colors { char *hex; char *name; char *rgb; } colors[];
  368.