Subversion Repositories wimsdev

Rev

Rev 16700 | Rev 16828 | 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"
15111 schaersvoo 3
#define MAX_INT                 128
4
#define MAX_BUFFER              65536
15690 schaersvoo 5
#define MAX_DRAGSTUFF           27
16827 schaersvoo 6
#define MAX_MULTI_PRIMITIVES    29
15111 schaersvoo 7
/* wims : MAX_FWRITE_SIZE 64*1024=65536 == 2*MAX_BUFFER */
7614 schaersvoo 8
#define MAX_COLOR_STRING        32
15111 schaersvoo 9
#define MAX_SLIDERS             16
10
/* the commmand / keyword name collection */
7614 schaersvoo 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
15111 schaersvoo 42
#define CSS     35
7614 schaersvoo 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
8146 schaersvoo 77
#define CLEARBUTTON     75
7614 schaersvoo 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
7647 schaersvoo 99
#define DIAMONDFILL     99
7614 schaersvoo 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
7735 schaersvoo 108
#define XLOGBASE        108
7614 schaersvoo 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
8224 bpr 130
#define STATUS          133
7614 schaersvoo 131
#define SNAPTOGRID      134
7784 schaersvoo 132
#define XSNAPTOGRID     135
133
#define YSNAPTOGRID     136
134
#define USERINPUT_XY    137
135
#define SGRAPH          139
136
#define YLOGBASE        140
7785 schaersvoo 137
#define AFFINE          141
138
#define KILLAFFINE      142
7788 schaersvoo 139
#define LEVELCURVE      143
7823 schaersvoo 140
#define JSMATH          144
7858 schaersvoo 141
#define TRACE_JSCURVE   145
7838 schaersvoo 142
#define SETLIMITS       146
7858 schaersvoo 143
#define JSCURVE         147
7983 schaersvoo 144
#define CENTERSTRING    148
7991 schaersvoo 145
#define MOUSEX          149
146
#define MOUSEY          150
8071 schaersvoo 147
#define MOUSE_DEGREE    151
148
#define MOUSE_DISPLAY   152
149
#define XUNIT           153
150
#define YUNIT           154
8101 schaersvoo 151
#define KILLSLIDER      155
8105 schaersvoo 152
#define ANGLE           156
8193 schaersvoo 153
#define USERINPUT_FUNCTION 157
8222 schaersvoo 154
#define USERINPUT       158
8244 schaersvoo 155
#define HALFLINE        159
8297 schaersvoo 156
#define FUNCTION_LABEL  160
8299 schaersvoo 157
#define SEGMENTS        161
8304 schaersvoo 158
#define ARROWS          162
159
#define CIRCLES         163
8347 schaersvoo 160
#define ARROWS2         164
8351 schaersvoo 161
#define LINES           165
8364 schaersvoo 162
#define RECTS           166
8365 schaersvoo 163
#define HALFLINES       167
8366 schaersvoo 164
#define HLINES          168
165
#define VLINES          169
8370 schaersvoo 166
#define ROUNDRECTS      170
167
#define BEZIER          171
8379 schaersvoo 168
#define SNAPTOPOINTS    172
9213 schaersvoo 169
#define SLIDER_X        173
170
#define SLIDER_Y        174
171
#define SNAPTOFUNCTION  175
172
#define MULTIDRAW       176
173
#define MULTILINEWIDTH  177
174
#define MULTISTROKECOLORS       178
175
#define MULTISTROKEOPACITY      179
176
#define MULTIFILLCOLORS 180
177
#define MULTIFILLOPACITY        181
178
#define MULTIFILL       182
179
#define MULTILABEL      183
180
#define MULTIDASH       184
181
#define MULTISNAPTOGRID 185
182
#define MULTIUSERINPUT  186
9244 schaersvoo 183
#define PROTRACTOR      187
9289 schaersvoo 184
#define RULER           188
9306 schaersvoo 185
#define TRIANGLES       189
9329 schaersvoo 186
#define POPUP           190
9341 schaersvoo 187
#define X_AXIS_STRINGS_UP 191
9386 schaersvoo 188
#define CURSOR          192
9427 schaersvoo 189
#define XERRORBARS      193
190
#define YERRORBARS      194
9465 schaersvoo 191
#define BOXPLOTDATA     196
192
#define USERBOXPLOT     197
193
#define USERBOXPLOTDATA 198
9908 schaersvoo 194
#define ROTATION_CENTER 199
195
#define KILLROTATE      200
11006 schaersvoo 196
#define CANVASTYPE      201
11044 schaersvoo 197
#define NOXAXIS         202
198
#define NOYAXIS         203
11764 schaersvoo 199
#define BOXPLOT         204
11767 schaersvoo 200
#define COLORPALETTE    205
11772 schaersvoo 201
#define FILLALL         206
11802 schaersvoo 202
#define XYOFFSET        207
203
#define XOFFSET         208
11811 schaersvoo 204
#define YOFFSET         209
12063 schaersvoo 205
#define CENTERED        210
206
#define RESETOFFSET     211
207
#define TEXTFILL        212
208
#define FILLPATTERN     213
209
#define NUMBERLINE      214
12110 schaersvoo 210
#define ELLIPSES        215
14038 schaersvoo 211
#define IMAGEPALETTE    216
212
#define CURVEDARROW2    217
213
#define CURVEDARROW     218
214
#define CURVEDARROWS    219
215
#define CURVEDARROWS2   220
14225 schaersvoo 216
#define LATEX           221
15111 schaersvoo 217
#define ALLOW_DUPLICATES        223
218
#define LINEAR          224
219
#define KILLLINEAR      225
220
#define OBABEL          226
221
#define CHEMTEX         227
222
#define NORESET         228
15690 schaersvoo 223
#define ARCARROW        229
15716 schaersvoo 224
#define KILL            230
15773 schaersvoo 225
#define RANGE           231
15111 schaersvoo 226
/* the js_function[] dcollection : js-code without configurable argumens see canvasutil.c  */
16700 schaersvoo 227
#define MAX_JS_FUNCTIONS        52
15111 schaersvoo 228
 
7614 schaersvoo 229
#define DRAW_GRID       0
15111 schaersvoo 230
#define DRAW_CROSSHAIRS 1
231
#define DRAW_GRIDFILL   2
232
#define DRAW_XML        3
233
#define DRAW_ARCS       4
234
#define DRAW_LATTICE    5
235
#define DRAW_INPUTS     6
236
#define DRAW_TEXTAREAS  7
237
#define DRAW_HTTP       8
238
#define DRAW_AUDIO      9
239
#define DRAW_VIDEO      10
240
#define DRAW_DOTFILL    11
241
#define DRAW_HATCHFILL  12
242
#define DRAW_IMAGEFILL  13
243
#define DRAW_FLOODFILL  14
244
#define DRAW_FILLTOBORDER       15
245
#define DRAW_PIXELS     16
246
#define DRAW_LINES      17
247
#define DRAW_PIECHART   18
248
#define DRAW_CLOCK      19
249
#define DRAW_EXTERNAL_IMAGE     20
250
#define DRAW_DIAMONDFILL        21
251
#define DRAW_SGRAPH     22
252
#define DRAW_YLOGSCALE  23
253
#define DRAW_XLOGSCALE  24
254
#define DRAW_XYLOGSCALE 25
255
#define DRAW_CENTERSTRING       26
256
#define DRAW_JSFUNCTION 27
257
#define DRAW_BEZIER     28
258
#define DRAW_BOXPLOT    29
259
#define DRAW_JSBOXPLOT  30
260
#define DRAW_NUMBERLINE 31
261
#define JS_FIND_ANGLE   32
262
#define DRAW_TEXTFILL   33
263
#define INTERACTIVE     34
264
#define JS_ROTATE_MOUSE 35
265
#define JS_TRANSFORM_MOUSE      36
266
#define DRAW_FILL_PATTERN       37
267
#define JS_ZOOM 38
268
#define DRAG_AND_ZOOM   39
269
#define USERDRAW_AND_ZOOM       40
270
#define JS_RAWMATH      41
271
#define JS_LOAD_IMAGE   42
272
#define JS_SAFE_EVAL    43
273
#define JS_PLOT 44
274
#define JS_MATH 45
275
#define DRAW_TEXTS      46
276
#define DRAG_EXTERNAL_IMAGE     47
277
#define ADD_USER_INPUTS 48
278
#define JSPLOT_AND_ZOOM 49
15690 schaersvoo 279
#define JS_ARROWHEAD    50
16700 schaersvoo 280
#define DRAW_SUBSUP     51
15111 schaersvoo 281
/*  end js_function[]  */
282
/* default canvasses, eg png images xsize x ysize */
8448 schaersvoo 283
#define EXTERNAL_IMAGE_CANVAS 0 /* this is created first !!! in order to draw on it */
284
#define BG_CANVAS       1
285
#define STATIC_CANVAS   2
286
#define MOUSE_CANVAS    3
287
#define GRID_CANVAS     4
288
#define DRAG_CANVAS     5
289
#define DRAW_CANVAS     6
290
#define TEXT_CANVAS     7
291
#define CLOCK_CANVAS    8
292
#define ANIMATE_CANVAS  9
293
#define TRACE_CANVAS    10
11764 schaersvoo 294
#define JSPLOT_CANVAS   100 /* JSPLOT_canvas will be increased with every added inputfield...should not conflict with other images*/
11763 schaersvoo 295
#define FILL_CANVAS     200 /* will be increase with every fill */
11764 schaersvoo 296
#define USERDRAW_JSPLOT 300 /* USERDRAW_JSPLOT will be increased with every added inputfield...should not conflict with other images*/
297
#define CLICKFILL_CANVAS 400 /* will be increase with every click fill */
15348 bpr 298
#define BOXPLOT_CANVAS  500 /* will increase with every new boxplot */
11890 schaersvoo 299
#define NUMBERLINE_CANVAS 600
15111 schaersvoo 300
#define MULTIDRAW_CANVAS        1000 /* + >25 draw types... 1001=points*/
301
#define ZOOM_CANVAS     1100
302
#define STATIC_IMAGE_CANVAS 700
7614 schaersvoo 303
#ifndef STD_H
304
#define STD_H
305
 
306
#ifndef bool
307
#define bool            char
308
#endif
309
#ifndef TRUE
310
#define TRUE            1
311
#endif
312
#ifndef FALSE
313
#define FALSE           0
314
#endif
315
 
316
#endif
15111 schaersvoo 317
void    add_to_buffer(char *tmp); /* add tmp_buffer to the buffer */
318
void    check_string_length(int length);
15348 bpr 319
extern void *tmp_buffer;
7614 schaersvoo 320
 
15111 schaersvoo 321
void rotate(int num,double angle,double center[],int incr);
322
void transform(int num,int incr);
323
void add_read_canvas(int type_reply,int reply_precision);
324
void add_javascript_function();
325
void add_drag_code(int canvas_cnt,int use_dragstuff, int stuff[],int reply_format);
326
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);
327
void add_setlimits(int font_size,char *css_class);
328
void add_safe_eval();
329
void add_calc_y(char *jsmath,int font_size,char *css_class);
330
void add_slider(int anim);
331
void add_slider_display(int precision,int font_size,char *font_color,double stroke_opacity);
332
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 333
void *my_newmem(size_t size);
334
void canvas_error(char *msg);
15601 schaersvoo 335
char *eval(int xsize,int ysize,char *fun,double xmin,double xmax,double ymin,double ymax,int xsteps,int precision,double rotationcenter[]);
336
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 337
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 338
char *getMML(char *tex);
15111 schaersvoo 339
char *getSVGMOL(char *inputtype,char *keys);
14208 schaersvoo 340
char *data2js_array(int data[],int len);
8225 bpr 341
char *double_xy2js_array(double xy[],int len,int decimals);
15111 schaersvoo 342
char *doubledata2js_array(double data[],int len, int decimals);
343
char *list2js_array(char *list,char *s);
8225 bpr 344
int find_number_of_digits(int i);
345
int x2px(double x);
346
int y2px(double y);
15111 schaersvoo 347
char *str_replace(const char *str, const char *old, const char *new);
348
void add_clear_button(char *css_class,char *button_text);
349
void add_js_mouse(int canvas_cnt,int precision,char *stroke_color,int font_size,double stroke_opacity,int type);
350
void add_js_filltoborder(int canvas_type);
351
void add_js_multidraw(char *draw_types,char *button_style,int use_offset,int use_controls,int crosshair_size,int use_zoom);
352
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 353
/* these should  be harmonized via switch key !!*/
15111 schaersvoo 354
void add_input_circle(int type,int num);
355
void add_input_segment(int num);
356
void add_input_demiline(int num);
357
void add_input_line(int num);
358
void add_input_polyline();
359
void add_input_crosshair(int num);
360
void add_input_arrow(int num);
361
void add_input_xy(int font_size,char *css_class);
362
void add_input_xyr(int font_size,char *css_class);
363
void add_input_x1y1x2y2(int font_size,char *css_class);
364
void add_textarea_xy(char *css_class);
365
void add_js_zoom_buttons(char *stroke_color,double stroke_opacity);
366
void add_js_tooltip(char *tooltip_text,char *bgcolor);
367
void add_js_popup(char *getfile_cmd);
368
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);
369
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);
370
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);
371
void add_color_palette(char *css_class);
372
void add_js_images(int use_offset,int snap);
8225 bpr 373
extern int NUMBER_OF_COLORNAMES;
374
extern struct colors { char *hex; char *name; char *rgb; } colors[];
15111 schaersvoo 375
extern int js_function[MAX_JS_FUNCTIONS];
376
extern int reply_format;
377
extern int xsize;
378
extern int ysize;
379
extern unsigned int canvas_root_id;
380
extern int user_input_xy;
381
extern char *css_class;
382
extern int font_size;
383
extern char *draw_type;
384
extern char *function_label;
385
extern int input_cnt;
386
extern int use_dashed;
387
extern int dashtype[];
388
extern int jsplot_cnt;
389
extern int linegraph_cnt;
390
extern int barchart_cnt;
391
extern int legend_cnt;
392
extern int use_axis;
393
extern int use_axis_numbering;
394
 
15348 bpr 395
extern FILE     *js_include_file;
396
/* used multidraw primitives : identifier in canvasmultidraw.c is index of this array
15111 schaersvoo 397
static char multidraw_primitives[MAX_MULTI_PRIMITIVES][32] = {"point","points","circle","circles",
398
"line","lines","segment","segments",
399
"arrow","arrows","triangle","triangles",
400
"closedpoly","text","rect","rects",
401
"poly","polys","parallelogram","parallelograms",
402
"images","curvedarrow","curvedarrows","curvedarrow2","curvedarrows2",
403
"crosshair","crosshairs"};
404
size of words "point","points",... == 6,7,..
405
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,
406
13,13,12,10,11};
15348 bpr 407
*/