1 /* gtkplot - 2d scientific plots widget for gtk+
2  * Copyright 1999-2001  Adrian E. Feiguin <feiguin@ifir.edu.ar>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef __GTK_PLOT3D_H__
21 #define __GTK_PLOT3D_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 
27 #include "gtkplot.h"
28 
29 
30 #define GTK_PLOT3D(obj)        GTK_CHECK_CAST (obj, gtk_plot3d_get_type (), GtkPlot3D)
31 #define GTK_TYPE_PLOT3D        (gtk_plot3d_get_type ())
32 #define GTK_PLOT3D_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_plot3d_get_type(), GtkPlot3DClass)
33 #define GTK_IS_PLOT3D(obj)     GTK_CHECK_TYPE (obj, gtk_plot3d_get_type ())
34 #define GTK_PLOT3D_FLAGS(plot)         (GTK_PLOT3D(plot)->flags)
35 #define GTK_PLOT3D_SET_FLAGS(plot,flag) (GTK_PLOT3D_FLAGS(plot) |= (flag))
36 #define GTK_PLOT3D_UNSET_FLAGS(plot,flag) (GTK_PLOT3D_FLAGS(plot) &= ~(flag))
37 
38 #define GTK_PLOT3D_TRANSPARENT(plot) (GTK_PLOT3D_FLAGS(plot) & GTK_PLOT3D_TRANSPARENT)
39 
40 typedef struct _GtkPlot3D		GtkPlot3D;
41 typedef struct _GtkPlot3DClass		GtkPlot3DClass;
42 
43 typedef enum
44 {
45   GTK_PLOT_PLANE_XY	= 0,
46   GTK_PLOT_PLANE_YX	= 0,
47   GTK_PLOT_PLANE_XZ	= 1,
48   GTK_PLOT_PLANE_ZX	= 1,
49   GTK_PLOT_PLANE_YZ	= 2,
50   GTK_PLOT_PLANE_ZY	= 2,
51 } GtkPlotPlane;
52 
53 typedef enum
54 {
55   GTK_PLOT_SIDE_XY	= 1 << 0 ,
56   GTK_PLOT_SIDE_XZ	= 1 << 1 ,
57   GTK_PLOT_SIDE_YX	= 1 << 2 ,
58   GTK_PLOT_SIDE_YZ	= 1 << 3 ,
59   GTK_PLOT_SIDE_ZX	= 1 << 4 ,
60   GTK_PLOT_SIDE_ZY	= 1 << 5 ,
61 } GtkPlotSide;
62 
63 struct _GtkPlot3D
64 {
65   GtkPlot plot;
66 
67   GtkPlotVector e1, e2, e3;
68   GtkPlotVector center;
69   GtkPlotVector origin;
70 
71   gdouble a1, a2, a3;
72   gdouble ncos[360];
73   gdouble nsin[360];
74 
75   GtkPlotAxis *ax, *ay, *az;
76 
77   gboolean xy_visible;
78   gboolean yz_visible;
79   gboolean zx_visible;
80 
81   GdkColor color_xy;
82   GdkColor color_yz;
83   GdkColor color_zx;
84 
85   GtkPlotLine frame;
86   GtkPlotLine corner;
87   gboolean corner_visible;
88 
89   gdouble zmin, zmax;
90   GtkPlotScale zscale;
91 
92   gint titles_offset;
93 
94   GtkPlotAxis xy, xz;
95   GtkPlotAxis yx, yz;
96   GtkPlotAxis zx, zy;
97 
98   gdouble xfactor, yfactor, zfactor;
99 };
100 
101 struct _GtkPlot3DClass
102 {
103   GtkPlotClass parent_class;
104 
105   void	(* get_pixel) 		(GtkWidget *widget,
106                       		 gdouble x, gdouble y, gdouble z,
107                      		 gdouble *px, gdouble *py, gdouble *pz);
108 };
109 
110 /* Plot3D */
111 
112 GtkType		gtk_plot3d_get_type		(void);
113 GtkWidget*	gtk_plot3d_new			(GdkDrawable *drawable);
114 GtkWidget*	gtk_plot3d_new_with_size	(GdkDrawable *drawable,
115                                                  gdouble width, gdouble height);
116 void		gtk_plot3d_construct		(GtkPlot3D *plot,
117 						 GdkDrawable *drawable);
118 void		gtk_plot3d_construct_with_size	(GtkPlot3D *plot,
119 						 GdkDrawable *drawable,
120                                                  gdouble width, gdouble height);
121 void		gtk_plot3d_autoscale		(GtkPlot3D *plot);
122 /* rotations around global axes */
123 void		gtk_plot3d_rotate		(GtkPlot3D *plot,
124 						 gdouble angle_x,
125 						 gdouble angle_y,
126 						 gdouble angle_z);
127 void 		gtk_plot3d_rotate_vector	(GtkPlot3D *plot,
128                           			 GtkPlotVector *vector,
129                           			 gdouble a1,
130 						 gdouble a2,
131 						 gdouble a3);
132 
133 /* rotations around local axes */
134 void 		gtk_plot3d_reset_angles		(GtkPlot3D *plot);
135 void 		gtk_plot3d_rotate_x		(GtkPlot3D *plot,
136 						 gdouble angle);
137 void 		gtk_plot3d_rotate_y		(GtkPlot3D *plot,
138 						 gdouble angle);
139 void 		gtk_plot3d_rotate_z		(GtkPlot3D *plot,
140 						 gdouble angle);
141 
142 
143 void 		gtk_plot3d_get_pixel		(GtkPlot3D *plot,
144                           			 gdouble x,
145                                                  gdouble y,
146                                                  gdouble z,
147                                                  gdouble *px,
148                                                  gdouble *py,
149                                                  gdouble *pz);
150 void 		gtk_plot3d_set_xrange		(GtkPlot3D *plot,
151 						 gdouble min, gdouble max);
152 void 		gtk_plot3d_set_yrange		(GtkPlot3D *plot,
153 						 gdouble min, gdouble max);
154 void 		gtk_plot3d_set_zrange		(GtkPlot3D *plot,
155 						 gdouble min, gdouble max);
156 void 		gtk_plot3d_set_xfactor		(GtkPlot3D *plot,
157 						 gdouble xfactor);
158 void 		gtk_plot3d_set_yfactor		(GtkPlot3D *plot,
159 						 gdouble yfactor);
160 void 		gtk_plot3d_set_zfactor		(GtkPlot3D *plot,
161 						 gdouble zfactor);
162 gdouble 	gtk_plot3d_get_xfactor		(GtkPlot3D *plot);
163 gdouble 	gtk_plot3d_get_yfactor		(GtkPlot3D *plot);
164 gdouble 	gtk_plot3d_get_zfactor		(GtkPlot3D *plot);
165 /* Planes */
166 void		gtk_plot3d_plane_set_color	(GtkPlot3D *plot,
167 						 GtkPlotPlane plane,
168 						 const GdkColor *color);
169 void		gtk_plot3d_plane_set_visible	(GtkPlot3D *plot,
170 						 GtkPlotPlane plane,
171 						 gboolean visible);
172 gboolean	gtk_plot3d_plane_visible	(GtkPlot3D *plot,
173 						 GtkPlotPlane plane);
174 
175 void		gtk_plot3d_corner_set_visible	(GtkPlot3D *plot,
176 						 gboolean visible);
177 gboolean	gtk_plot3d_corner_visible	(GtkPlot3D *plot);
178 
179 void            gtk_plot3d_corner_set_attributes(GtkPlot3D *plot,
180 						 GtkPlotLineStyle style,
181 						 gfloat width,
182                                                  const GdkColor *color);
183 void            gtk_plot3d_corner_get_attributes(GtkPlot3D *plot,
184                                                  GtkPlotLineStyle *style,
185                                                  gfloat *width,
186                                                  GdkColor *color);
187 void            gtk_plot3d_frame_set_attributes	(GtkPlot3D *plot,
188                                                  GtkPlotLineStyle style,
189                                                  gfloat width,
190                                                  const GdkColor *color);
191 void            gtk_plot3d_frame_get_attributes	(GtkPlot3D *plot,
192                                                  GtkPlotLineStyle *style,
193                                                  gfloat *width,
194                                                  GdkColor *color);
195 
196 
197 /* Axes */
198 GtkPlotAxis *	gtk_plot3d_get_axis		(GtkPlot3D *plot,
199 						 GtkPlotOrientation orientation);
200 GtkPlotAxis *	gtk_plot3d_get_side		(GtkPlot3D *plot,
201 						 GtkPlotSide side);
202 void		gtk_plot3d_show_major_ticks	(GtkPlot3D *plot,
203                                                  GtkPlotSide side,
204 						 gint ticks_mask);
205 void		gtk_plot3d_show_minor_ticks	(GtkPlot3D *plot,
206                                                  GtkPlotSide side,
207 						 gint ticks_mask);
208 void		gtk_plot3d_show_labels		(GtkPlot3D *plot,
209                                                  GtkPlotSide side,
210 						 gint label_mask);
211 void		gtk_plot3d_show_title		(GtkPlot3D *plot,
212                                                  GtkPlotSide side);
213 void		gtk_plot3d_hide_title		(GtkPlot3D *plot,
214                                                  GtkPlotSide side);
215 void 		gtk_plot3d_set_ticks       	(GtkPlot3D *plot,
216 						 GtkPlotOrientation axis,
217                                  		 gdouble major_step,
218                                  		 gint nminor);
219 void 		gtk_plot3d_set_major_ticks 	(GtkPlot3D *plot,
220 						 GtkPlotOrientation axis,
221                                  		 gdouble major_step);
222 void 		gtk_plot3d_set_minor_ticks 	(GtkPlot3D *plot,
223 						 GtkPlotOrientation axis,
224                                  		 gint nminor);
225 void            gtk_plot3d_set_ticks_length	(GtkPlot3D *plot,
226                                                  GtkPlotOrientation axis,
227                                                  gint length);
228 void            gtk_plot3d_set_ticks_width 	(GtkPlot3D *plot,
229                                                  GtkPlotOrientation axis,
230                                                  gfloat width);
231 void            gtk_plot3d_show_ticks      	(GtkPlot3D *plot,
232                                                  GtkPlotSide side,
233                                                  gint major_mask,
234                                                  gint minor_mask);
235 void 		gtk_plot3d_set_titles_offset 	(GtkPlot3D *plot,
236                                                  gint offset);
237 gint 		gtk_plot3d_get_titles_offset 	(GtkPlot3D *plot);
238 void		gtk_plot3d_set_scale		(GtkPlot3D *plot,
239 						 GtkPlotOrientation axis,
240 						 GtkPlotScale scale);
241 GtkPlotScale	gtk_plot3d_get_scale		(GtkPlot3D *plot,
242 						 GtkPlotOrientation axis);
243 /* Grids */
244 void            gtk_plot3d_major_grids_set_visible    (GtkPlot3D *plot,
245 						       gboolean x,
246 						       gboolean y,
247 						       gboolean z);
248 void            gtk_plot3d_minor_grids_set_visible    (GtkPlot3D *plot,
249 						       gboolean x,
250 						       gboolean y,
251 						       gboolean z);
252 void            gtk_plot3d_major_grids_visible        (GtkPlot3D *plot,
253 						       gboolean *x,
254 						       gboolean *y,
255 						       gboolean *z);
256 void            gtk_plot3d_minor_grids_visible        (GtkPlot3D *plot,
257 						       gboolean *x,
258 						       gboolean *y,
259 						       gboolean *z);
260 void            gtk_plot3d_major_zgrid_set_attributes  (GtkPlot3D *plot,
261 							GtkPlotLineStyle style,
262 							gfloat width,
263                                                        const GdkColor *color);
264 void            gtk_plot3d_major_zgrid_get_attributes  (GtkPlot3D *plot,
265                                                        GtkPlotLineStyle *style,
266                                                        gfloat *width,
267                                                        GdkColor *color);
268 void            gtk_plot3d_minor_zgrid_set_attributes  (GtkPlot3D *plot,
269                                                        GtkPlotLineStyle style,
270                                                        gfloat width,
271                                                        const GdkColor *color);
272 void            gtk_plot3d_minor_zgrid_get_attributes  (GtkPlot3D *plot,
273                                                        GtkPlotLineStyle *style,
274                                                        gfloat *width,
275                                                        GdkColor *color);
276 
277 
278 
279 
280 #ifdef __cplusplus
281 }
282 #endif /* __cplusplus */
283 
284 
285 #endif /* __GTK_PLOT3D_H__ */
286