1 /***************************************************************************
2  * base_cf.h is part of Math Graphic Library
3  * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU Lesser General Public License  as       *
7  *   published by the Free Software Foundation; either version 3 of the    *
8  *   License, or (at your option) any later version.                       *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU Lesser General Public     *
16  *   License along with this program; if not, write to the                 *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 #ifndef _MGL_BASE_CF_H_
21 #define _MGL_BASE_CF_H_
22 #include "mgl2/abstract.h"
23 //-----------------------------------------------------------------------------
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /// Check if MathGL version is valid (return 0) or not (return 1)
29 int MGL_EXPORT mgl_check_version(const char *ver);
30 int MGL_EXPORT mgl_check_version_(const char *ver, int);
31 /// Suppress printing warnings to stderr
32 void MGL_EXPORT mgl_suppress_warn(int on);
33 void MGL_EXPORT mgl_suppress_warn_(int *on);
34 /// Get last warning code
35 int MGL_EXPORT_PURE mgl_get_warn(HMGL gr);
36 int MGL_EXPORT_PURE mgl_get_warn_(uintptr_t *gr);
37 /// Set warning code ant fill message
38 void MGL_EXPORT mgl_set_warn(HMGL gr, int code, const char *text);
39 void MGL_EXPORT mgl_set_warn_(uintptr_t *gr, int *code, const char *text,int);
40 /// Get text of warning message(s)
41 MGL_EXPORT_PURE const char *mgl_get_mess(HMGL gr);
42 int MGL_EXPORT mgl_get_mess_(uintptr_t *gr, char *out, int len);
43 
44 /// Set name of plot for saving filename
45 void MGL_EXPORT mgl_set_plotid(HMGL gr, const char *id);
46 void MGL_EXPORT mgl_set_plotid_(uintptr_t *gr, const char *id,int);
47 /// Get name of plot for saving filename
48 MGL_EXPORT_PURE const char *mgl_get_plotid(HMGL gr);
49 int MGL_EXPORT mgl_get_plotid_(uintptr_t *gr, char *out, int len);
50 
51 /// Ask to stop drawing
52 void MGL_EXPORT mgl_ask_stop(HMGL gr, int stop);
53 void MGL_EXPORT mgl_ask_stop_(uintptr_t *gr, int *stop);
54 /// Check if plot termination is asked
55 int MGL_EXPORT mgl_need_stop(HMGL gr);
56 int MGL_EXPORT mgl_need_stop_(uintptr_t *gr);
57 /// Set callback function for event processing
58 void MGL_EXPORT mgl_set_event_func(HMGL gr, void (*func)(void *), void *par);
59 
60 /// Get plot quality
61 int MGL_EXPORT_PURE mgl_get_quality(HMGL gr);
62 int MGL_EXPORT_PURE mgl_get_quality_(uintptr_t *gr);
63 /// Set plot quality
64 /** qual=0 -- no face drawing (fastest),
65  *  qual=1 -- no color interpolation (fast),
66  *  qual=2 -- high quality (normal),
67  *  qual|4 -- direct bitmap drawing (low memory usage);
68  *  qual|8 for dots drawing instead of primitives (extremely fast). */
69 void MGL_EXPORT mgl_set_quality(HMGL gr, int qual);
70 void MGL_EXPORT mgl_set_quality_(uintptr_t *gr, int *qual);
71 /// Set drawing region for Quality&4
72 void MGL_EXPORT mgl_set_draw_reg(HMGL gr, long nx, long ny, long m);
73 void MGL_EXPORT mgl_set_draw_reg_(uintptr_t *gr, int *nx, int *ny, int *m);
74 
75 /// Check if support of frames is enabled (i.e. MGL_VECT_FRAME is set and Quality&MGL_DRAW_LMEM==0)
76 int MGL_EXPORT_PURE mgl_is_frames(HMGL gr);
77 /// Get bit-value flag of HMGL state (for advanced users only)
78 int MGL_EXPORT_PURE mgl_get_flag(HMGL gr, uint32_t flag);
79 int MGL_EXPORT_PURE mgl_get_flag_(uintptr_t *gr, unsigned long *flag);
80 /// Set bit-value flag of HMGL state (for advanced users only)
81 void MGL_EXPORT mgl_set_flag(HMGL gr, int val, uint32_t flag);
82 void MGL_EXPORT mgl_set_flag_(uintptr_t *gr, int *val, unsigned long *flag);
83 /// Change counter of HMGL uses (for advanced users only). Non-zero counter prevent automatic object removing.
84 long MGL_EXPORT mgl_use_graph(HMGL gr, int inc);
85 long MGL_EXPORT mgl_use_graph_(uintptr_t *gr, int *inc);
86 void MGL_EXPORT mgl_set_rdc_acc(HMGL gr, int reduce);
87 void MGL_EXPORT mgl_set_rdc_acc_(uintptr_t *gr, int *reduce);
88 
89 /// Start group of objects
90 void MGL_EXPORT mgl_start_group(HMGL gr, const char *name);
91 void MGL_EXPORT mgl_start_group_(uintptr_t *gr, const char *name,int);
92 /// End group of objects
93 void MGL_EXPORT mgl_end_group(HMGL gr);
94 void MGL_EXPORT mgl_end_group_(uintptr_t *gr);
95 /// Highlight objects with given id
96 void MGL_EXPORT mgl_highlight(HMGL gr, int id);
97 void MGL_EXPORT mgl_highlight_(uintptr_t *gr, int *id);
98 
99 /// Set default palette
100 void MGL_EXPORT mgl_set_palette(HMGL gr, const char *colors);
101 void MGL_EXPORT mgl_set_palette_(uintptr_t *gr, const char *colors, int);
102 void MGL_EXPORT mgl_set_pal_color_(uintptr_t *gr, int *n, mreal *r, mreal *g, mreal *b);
103 void MGL_EXPORT mgl_set_pal_num_(uintptr_t *gr, int *num);
104 /// Sets RGB values for color with given id
105 void MGL_EXPORT mgl_set_color(char id, double r, double g, double b);
106 void MGL_EXPORT mgl_set_color_(char *id, mreal *r, mreal *g, mreal *b, int);
107 /// Set default color scheme
108 void MGL_EXPORT mgl_set_def_sch(HMGL gr, const char *sch);
109 void MGL_EXPORT mgl_set_def_sch_(uintptr_t *gr, const char *sch,int);
110 /// Set mask for face coloring as array of type 'unsigned char[8]'
111 void MGL_EXPORT mgl_set_mask(char id, const char *mask);
112 void MGL_EXPORT mgl_set_mask_(const char *id, const char *mask,int,int);
113 /// Set mask for face coloring as unsigned long number
114 void MGL_EXPORT mgl_set_mask_val(char id, uint64_t mask);
115 void MGL_EXPORT mgl_set_mask_val_(const char *id, uint64_t *mask,int);
116 /// Set default mask rotation angle
117 void MGL_EXPORT mgl_set_mask_angle(HMGL gr, int angle);
118 void MGL_EXPORT mgl_set_mask_angle_(uintptr_t *gr, int *angle);
119 
120 /// Set default value of alpha-channel
121 void MGL_EXPORT mgl_set_alpha_default(HMGL gr, double alpha);
122 void MGL_EXPORT mgl_set_alpha_default_(uintptr_t *gr, mreal *alpha);
123 /// Set relative width of rectangles in Bars, Barh, BoxPlot, Candle, OHLC (default is 0.7)
124 void MGL_EXPORT mgl_set_bar_width(HMGL gr, double width);
125 void MGL_EXPORT mgl_set_bar_width_(uintptr_t *gr, mreal *width);
126 /// Set number of mesh lines (use 0 to draw all of them)
127 void MGL_EXPORT mgl_set_meshnum(HMGL gr, int num);
128 void MGL_EXPORT mgl_set_meshnum_(uintptr_t *gr, int *num);
129 /// Set number of visible faces (use 0 to draw all of them)
130 void MGL_EXPORT mgl_set_facenum(HMGL gr, int num);
131 void MGL_EXPORT mgl_set_facenum_(uintptr_t *gr, int *num);
132 /// Clear unused points and primitives. Useful only in combination with mgl_set_facenum().
133 void MGL_EXPORT mgl_clear_unused(HMGL gr);
134 void MGL_EXPORT mgl_clear_unused_(uintptr_t *gr);
135 /// Set TeX parsing at text drawing
136 void MGL_EXPORT mgl_set_tex_parse(HMGL gr, int val);
137 void MGL_EXPORT mgl_set_tex_parse_(uintptr_t *gr, int *val);
138 
139 /// Set ambient light brightness
140 void MGL_EXPORT mgl_set_ambbr(HMGL gr, double i);
141 void MGL_EXPORT mgl_set_ambbr_(uintptr_t *gr, mreal *i);
142 /// Set diffusive light brightness
143 void MGL_EXPORT mgl_set_difbr(HMGL gr, double i);
144 void MGL_EXPORT mgl_set_difbr_(uintptr_t *gr, mreal *i);
145 /// Use diffusive light (only for local light sources) -- OBSOLETE
146 void MGL_EXPORT mgl_set_light_dif(HMGL gr, int enable);
147 void MGL_EXPORT mgl_set_light_dif_(uintptr_t *gr, int *enable);
148 
149 /// Set cutting for points outside of bounding box
150 void MGL_EXPORT mgl_set_cut(HMGL gr, int cut);
151 void MGL_EXPORT mgl_set_cut_(uintptr_t *gr, int *cut);
152 /// Set additional cutting box
153 void MGL_EXPORT mgl_set_cut_box(HMGL gr, double x1,double y1,double z1,double x2,double y2,double z2);
154 void MGL_EXPORT mgl_set_cut_box_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2);
155 /// Set the cutting off condition (formula)
156 void MGL_EXPORT mgl_set_cutoff(HMGL gr, const char *EqC);
157 void MGL_EXPORT mgl_set_cutoff_(uintptr_t *gr, const char *EqC, int);
158 
159 /// Set values of axis range
160 void MGL_EXPORT mgl_set_ranges(HMGL gr, double x1, double x2, double y1, double y2, double z1, double z2);
161 void MGL_EXPORT mgl_set_ranges_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2, mreal *z1, mreal *z2);
162 /// Set range in direction dir as [v1, v2]
163 void MGL_EXPORT mgl_set_range_val(HMGL gr, char dir, double v1,double v2);
164 void MGL_EXPORT mgl_set_range_val_(uintptr_t *gr, const char *dir, mreal *v1, mreal *v2,int);
165 /// Add [v1, v2] to the current range in direction dir
166 void MGL_EXPORT mgl_add_range_val(HMGL gr, char dir, double v1,double v2);
167 void MGL_EXPORT mgl_add_range_val_(uintptr_t *gr, const char *dir, mreal *v1, mreal *v2,int);
168 /// Set range in direction dir as minimal and maximal values of data a
169 void MGL_EXPORT mgl_set_range_dat(HMGL gr, char dir, HCDT a, int add);
170 void MGL_EXPORT mgl_set_range_dat_(uintptr_t *gr, const char *dir, uintptr_t *a, int *add,int);
171 /// Set ranges for automatic variables
172 void MGL_EXPORT mgl_set_auto_ranges(HMGL gr, double x1, double x2, double y1, double y2, double z1, double z2, double c1, double c2);
173 void MGL_EXPORT mgl_set_auto_ranges_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2, mreal *z1, mreal *z2, mreal *c1, mreal *c2);
174 /// Set axis range scaling -- simplified way to shift/zoom axis range -- need to redraw whole image!
175 void MGL_EXPORT mgl_zoom_axis(HMGL gr, double x1,double y1,double z1,double c1,double x2,double y2,double z2,double c2);
176 void MGL_EXPORT mgl_zoom_axis_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *z1, mreal *c1, mreal *x2, mreal *y2, mreal *z2, mreal *c2);
177 
178 /// Set axis origin
179 void MGL_EXPORT mgl_set_origin(HMGL gr, double x0, double y0, double z0);
180 void MGL_EXPORT mgl_set_origin_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0);
181 /// Set the transformation formulas for coordinate. Use "" or NULL for built-in ones
182 void MGL_EXPORT mgl_set_func(HMGL gr, const char *EqX,const char *EqY,const char *EqZ,const char *EqA);
183 void MGL_EXPORT mgl_set_func_(uintptr_t *gr, const char *EqX, const char *EqY, const char *EqZ, const char *EqA, int, int, int, int);
184 /// Set one of predefined transformation rule
185 void MGL_EXPORT mgl_set_coor(HMGL gr, int how);
186 void MGL_EXPORT mgl_set_coor_(uintptr_t *gr, int *how);
187 /// Set to draw Ternary axis (triangle like axis, grid and so on)
188 /** val=1 for Ternary axis (a+b+c=1, z=z),
189  *  val=2 for Quaternary axis (a+b+c+d=1),
190  *  val|4 for projections. */
191 void MGL_EXPORT mgl_set_ternary(HMGL gr, int kind);
192 void MGL_EXPORT mgl_set_ternary_(uintptr_t *gr, int *kind);
193 
194 /// Set to use or not tick labels rotation
195 void MGL_EXPORT mgl_set_tick_rotate(HMGL gr, int enable);
196 void MGL_EXPORT mgl_set_tick_rotate_(uintptr_t *gr, int *enable);
197 /// Set to use or not tick labels skipping
198 void MGL_EXPORT mgl_set_tick_skip(HMGL gr, int enable);
199 void MGL_EXPORT mgl_set_tick_skip_(uintptr_t *gr, int *enable);
200 
201 /// Set default font for all new HMGL objects
202 void MGL_EXPORT mgl_def_font(const char *name, const char *path);
203 void MGL_EXPORT mgl_def_font_(const char *name, const char *path,int,int);
204 /// Set default size of marks (locally you can use "size" option)
205 void MGL_EXPORT mgl_set_mark_size(HMGL gr, double size);
206 void MGL_EXPORT mgl_set_mark_size_(uintptr_t *gr, mreal *size);
207 /// Set default size of arrows (locally you can use "size" option)
208 void MGL_EXPORT mgl_set_arrow_size(HMGL gr, double size);
209 void MGL_EXPORT mgl_set_arrow_size_(uintptr_t *gr, mreal *size);
210 /// Set default font size
211 void MGL_EXPORT mgl_set_font_size(HMGL gr, double size);
212 void MGL_EXPORT mgl_set_font_size_(uintptr_t *gr, mreal *size);
213 /// Set default font style and color
214 void MGL_EXPORT mgl_set_font_def(HMGL gr, const char *fnt);
215 void MGL_EXPORT mgl_set_font_def_(uintptr_t *gr, const char *fnt, int);
216 /// Set to use or not text rotation
217 void MGL_EXPORT mgl_set_rotated_text(HMGL gr, int enable);
218 void MGL_EXPORT mgl_set_rotated_text_(uintptr_t *gr, int *enable);
219 /// Set to scale text in relative subplots too
220 void MGL_EXPORT mgl_set_scale_text(HMGL gr, int enable);
221 void MGL_EXPORT mgl_set_scale_text_(uintptr_t *gr, int *enable);
222 /// Load font from file
223 void MGL_EXPORT mgl_load_font(HMGL gr, const char *name, const char *path);
224 void MGL_EXPORT mgl_load_font_(uintptr_t *gr, char *name, char *path, int l, int n);
225 /// Copy font from another mglGraph instance
226 void MGL_EXPORT mgl_copy_font(HMGL gr, HMGL gr_from);
227 void MGL_EXPORT mgl_copy_font_(uintptr_t *gr, uintptr_t *gr_from);
228 /// Restore font (load default font for new HMGL objects)
229 void MGL_EXPORT mgl_restore_font(HMGL gr);
230 void MGL_EXPORT mgl_restore_font_(uintptr_t *gr);
231 /// Add user-defined glyph for symbol and set its optional id
232 void MGL_EXPORT mgl_define_symbol(HMGL gr, char id, HCDT x, HCDT y);
233 void MGL_EXPORT mgl_define_symbol_(uintptr_t *gr, char *id, uintptr_t *x, uintptr_t *y,int);
234 
235 #ifdef __cplusplus
236 }
237 #endif
238 //-----------------------------------------------------------------------------
239 #endif
240