Subversion Repositories wimsdev

Rev

Rev 14230 | Rev 14546 | Go to most recent revision | 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"
7976 schaersvoo 3
#define MAX_INT         128
7614 schaersvoo 4
#define MAX_BUFFER 16384
5
#define MAX_COLOR_STRING        32
6
#define MAX_JS_FUNCTIONS 64
14208 schaersvoo 7
#define MAX_SLIDERS     16
9433 schaersvoo 8
/* the commmand / keyword name collecton */
7614 schaersvoo 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
8146 schaersvoo 75
#define CLEARBUTTON     75
7614 schaersvoo 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
7647 schaersvoo 97
#define DIAMONDFILL     99
7614 schaersvoo 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
7735 schaersvoo 106
#define XLOGBASE        108
7614 schaersvoo 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
8224 bpr 128
#define STATUS          133
7614 schaersvoo 129
#define SNAPTOGRID      134
7784 schaersvoo 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
7785 schaersvoo 136
#define AFFINE          141
137
#define KILLAFFINE      142
7788 schaersvoo 138
#define LEVELCURVE      143
7823 schaersvoo 139
#define JSMATH          144
7858 schaersvoo 140
#define TRACE_JSCURVE   145
7838 schaersvoo 141
#define SETLIMITS       146
7858 schaersvoo 142
#define JSCURVE         147
7983 schaersvoo 143
#define CENTERSTRING    148
7991 schaersvoo 144
#define MOUSEX          149
145
#define MOUSEY          150
8071 schaersvoo 146
#define MOUSE_DEGREE    151
147
#define MOUSE_DISPLAY   152
148
#define XUNIT           153
149
#define YUNIT           154
8101 schaersvoo 150
#define KILLSLIDER      155
8105 schaersvoo 151
#define ANGLE           156
8193 schaersvoo 152
#define USERINPUT_FUNCTION 157
8222 schaersvoo 153
#define USERINPUT       158
8244 schaersvoo 154
#define HALFLINE        159
8297 schaersvoo 155
#define FUNCTION_LABEL  160
8299 schaersvoo 156
#define SEGMENTS        161
8304 schaersvoo 157
#define ARROWS          162
158
#define CIRCLES         163
8347 schaersvoo 159
#define ARROWS2         164
8351 schaersvoo 160
#define LINES           165
8364 schaersvoo 161
#define RECTS           166
8365 schaersvoo 162
#define HALFLINES       167
8366 schaersvoo 163
#define HLINES          168
164
#define VLINES          169
8370 schaersvoo 165
#define ROUNDRECTS      170
166
#define BEZIER          171
8379 schaersvoo 167
#define SNAPTOPOINTS    172
9213 schaersvoo 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
9244 schaersvoo 182
#define PROTRACTOR      187
9289 schaersvoo 183
#define RULER           188
9306 schaersvoo 184
#define TRIANGLES       189
9329 schaersvoo 185
#define POPUP           190
9341 schaersvoo 186
#define X_AXIS_STRINGS_UP 191
9386 schaersvoo 187
#define CURSOR          192
9427 schaersvoo 188
#define XERRORBARS      193
189
#define YERRORBARS      194
9465 schaersvoo 190
#define BOXPLOTDATA     196
191
#define USERBOXPLOT     197
192
#define USERBOXPLOTDATA 198
9908 schaersvoo 193
#define ROTATION_CENTER 199
194
#define KILLROTATE      200
11006 schaersvoo 195
#define CANVASTYPE      201
11044 schaersvoo 196
#define NOXAXIS         202
197
#define NOYAXIS         203
11764 schaersvoo 198
#define BOXPLOT         204
11767 schaersvoo 199
#define COLORPALETTE    205
11772 schaersvoo 200
#define FILLALL         206
11802 schaersvoo 201
#define XYOFFSET        207
202
#define XOFFSET         208
11811 schaersvoo 203
#define YOFFSET         209
12063 schaersvoo 204
#define CENTERED        210
205
#define RESETOFFSET     211
206
#define TEXTFILL        212
207
#define FILLPATTERN     213
208
#define NUMBERLINE      214
12110 schaersvoo 209
#define ELLIPSES        215
14038 schaersvoo 210
#define IMAGEPALETTE    216
211
#define CURVEDARROW2    217
212
#define CURVEDARROW     218
213
#define CURVEDARROWS    219
214
#define CURVEDARROWS2   220
14225 schaersvoo 215
#define LATEX           221
14393 schaersvoo 216
#define ALLOW_DUPLICATES        222
9433 schaersvoo 217
/* the draw_function collection */
7614 schaersvoo 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
7988 schaersvoo 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
8448 schaersvoo 248
#define DRAW_EXTERNAL_IMAGE     32
7988 schaersvoo 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
8193 schaersvoo 256
#define DRAW_JSFUNCTION 40
8244 schaersvoo 257
#define DRAW_DEMILINES  41
8370 schaersvoo 258
#define DRAW_BEZIER     42
9433 schaersvoo 259
#define DRAW_BOXPLOT    43
260
#define DRAW_JSBOXPLOT  44
11890 schaersvoo 261
#define DRAW_NUMBERLINE 45
262
#define JS_FIND_ANGLE   46
263
#define DRAW_TEXTFILL   47
264
#define ADD_LOAD_IMAGE  48
7614 schaersvoo 265
 
8448 schaersvoo 266
#define EXTERNAL_IMAGE_CANVAS 0 /* this is created first !!! in order to draw on it */
267
#define BG_CANVAS       1
268
#define STATIC_CANVAS   2
269
#define MOUSE_CANVAS    3
270
#define GRID_CANVAS     4
271
#define DRAG_CANVAS     5
272
#define DRAW_CANVAS     6
273
#define TEXT_CANVAS     7
274
#define CLOCK_CANVAS    8
275
#define ANIMATE_CANVAS  9
276
#define TRACE_CANVAS    10
11764 schaersvoo 277
#define JSPLOT_CANVAS   100 /* JSPLOT_canvas will be increased with every added inputfield...should not conflict with other images*/
11763 schaersvoo 278
#define FILL_CANVAS     200 /* will be increase with every fill */
11764 schaersvoo 279
#define USERDRAW_JSPLOT 300 /* USERDRAW_JSPLOT will be increased with every added inputfield...should not conflict with other images*/
280
#define CLICKFILL_CANVAS 400 /* will be increase with every click fill */
281
#define BOXPLOT_CANVAS  500 /* will increase with every new boxplot */ 
11890 schaersvoo 282
#define NUMBERLINE_CANVAS 600
7858 schaersvoo 283
 
7614 schaersvoo 284
#ifndef STD_H
285
#define STD_H
286
 
287
#ifndef bool
288
#define bool            char
289
#endif
290
#ifndef TRUE
291
#define TRUE            1
292
#endif
293
#ifndef FALSE
294
#define FALSE           0
295
#endif
296
 
297
#endif
298
 
8225 bpr 299
void add_drag_code(FILE *js_include_file,int canvas_cnt,int canvas_root_id);
8815 schaersvoo 300
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);
301
void add_setlimits(FILE *js_include_file, int canvas_root_id,int font_size,char *input_style);
8225 bpr 302
void add_safe_eval(FILE *js_include_file);
303
void add_to_js_math(FILE *js_include_file);
8815 schaersvoo 304
void add_calc_y(FILE *js_include_file,int canvas_root_id,char *jsmath,int font_size,char *input_style);
8225 bpr 305
void add_jsplot(FILE *js_include_file,int canvas_root_id);
14208 schaersvoo 306
void add_slider(FILE *js_include_file,int canvas_root_id);
8225 bpr 307
void add_slider_display(FILE *js_include_file, int canvas_root_id,int precision,int font_size,char *font_color,double stroke_opacity);
14208 schaersvoo 308
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);
8225 bpr 309
void *my_newmem(size_t size);
310
void canvas_error(char *msg);
311
char *eval(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int xsteps,int precision);
312
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);
313
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 314
char *getMML(char *tex);
14208 schaersvoo 315
char *data2js_array(int data[],int len);
8225 bpr 316
char *double_xy2js_array(double xy[],int len,int decimals);
317
int find_number_of_digits(int i);
318
int x2px(double x);
319
int y2px(double y);
320
 
321
void add_clear_button(FILE *js_include_file,int canvas_root_id,char *input_style,char *button_text);
14044 schaersvoo 322
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);
8225 bpr 323
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);
14044 schaersvoo 324
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);
325
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);
326
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);
327
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);
328
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);
329
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);
330
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);
331
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);
332
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);
333
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);
334
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);
335
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);
336
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);
337
void add_js_clickfill(FILE *js_include_file,int canvas_root_id,char *clickcolor,int opacity,int use_snap);
11006 schaersvoo 338
void add_js_filltoborder(FILE *js_include_file,int canvas_root_id,int canvas_type);
14044 schaersvoo 339
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);
340
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);
14038 schaersvoo 341
void add_js_multidraw(FILE *js_include_file,int canvas_root_id,char *draw_types,char *button_style,int use_offset);
8244 schaersvoo 342
/* these should  be harmonized via switch key !!*/
8225 bpr 343
void add_input_circle(FILE *js_include_file,int type,int num);
344
void add_input_segment(FILE *js_include_file,int num);
8244 schaersvoo 345
void add_input_demiline(FILE *js_include_file,int num);
8225 bpr 346
void add_input_line(FILE *js_include_file,int num);
347
void add_input_polyline(FILE *js_include_file);
348
void add_textarea_polygon(FILE *js_include_file);
349
void add_input_crosshair(FILE *js_include_file,int num);
350
void add_input_arrow(FILE *js_include_file,int num);
8815 schaersvoo 351
void add_input_xy(FILE *js_include_file, int canvas_root_id,int font_size,char *input_style);
352
void add_input_xyr(FILE *js_include_file, int canvas_root_id,int font_size,char *input_style);
353
void add_input_x1y1x2y2(FILE *js_include_file, int canvas_root_id,int font_size,char *input_style);
354
void add_textarea_xy(FILE *js_include_file, int canvas_root_id,char *input_style);
8225 bpr 355
void add_zoom_buttons(FILE *js_include_file,int canvas_root_id,char *stroke_color,double stroke_opacity);
356
void add_js_tooltip(int canvas_root_id,char *tooltip_text,char *bgcolor,int xsize,int ysize);
9329 schaersvoo 357
void add_js_popup(int canvas_root_id,int xsize,int ysize,char *getfile_cmd);
8815 schaersvoo 358
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);
8297 schaersvoo 359
void add_rawmath(FILE *js_include_file);
14057 schaersvoo 360
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);
361
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);
11767 schaersvoo 362
void add_color_palette(FILE *js_include_file,int canvas_root_id,char *input_style);
11854 schaersvoo 363
void add_js_load_image(FILE *js_include_file,int canvas_root_id);
14038 schaersvoo 364
void add_js_images(FILE *js_include_file,int canvas_root_id,int use_offset,int snap);
8225 bpr 365
extern int NUMBER_OF_COLORNAMES;
366
extern struct colors { char *hex; char *name; char *rgb; } colors[];