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) G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_plot3d_get_type (), GtkPlot3D) 31 #define G_TYPE_PLOT3D (gtk_plot3d_get_type ()) 32 #define GTK_PLOT3D_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gtk_plot3d_get_type(), GtkPlot3DClass) 33 #define GTK_IS_PLOT3D(obj) G_TYPE_CHECK_INSTANCE_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 /** 64 * GtkPlot3D: 65 * 66 * The GtkPlot3D struct contains only private data. 67 * It should only be accessed through the functions described below. 68 */ 69 70 struct _GtkPlot3D 71 { 72 GtkPlot plot; 73 74 GtkPlotVector e1, e2, e3; 75 GtkPlotVector center; 76 GtkPlotVector origin; 77 78 gdouble a1, a2, a3; 79 gdouble ncos[360]; 80 gdouble nsin[360]; 81 82 GtkPlotAxis *ax, *ay, *az; 83 84 gboolean xy_visible; 85 gboolean yz_visible; 86 gboolean zx_visible; 87 88 GdkRGBA color_xy; 89 GdkRGBA color_yz; 90 GdkRGBA color_zx; 91 92 GtkPlotLine frame; 93 GtkPlotLine corner; 94 gboolean corner_visible; 95 96 gdouble zmin, zmax; 97 GtkPlotScale zscale; 98 99 gint titles_offset; 100 101 GtkPlotAxis *xy, *xz; 102 GtkPlotAxis *yx, *yz; 103 GtkPlotAxis *zx, *zy; 104 105 gdouble xfactor, yfactor, zfactor; 106 }; 107 108 struct _GtkPlot3DClass 109 { 110 GtkPlotClass parent_class; 111 112 void (* get_pixel) (GtkWidget *widget, 113 gdouble x, gdouble y, gdouble z, 114 gdouble *px, gdouble *py, gdouble *pz); 115 }; 116 117 /* Plot3D */ 118 119 GType gtk_plot3d_get_type (void); 120 GtkWidget* gtk_plot3d_new (cairo_surface_t *drawable); 121 GtkWidget* gtk_plot3d_new_with_size (cairo_surface_t *drawable, 122 gdouble width, gdouble height); 123 void gtk_plot3d_construct (GtkPlot3D *plot, 124 cairo_surface_t *drawable); 125 void gtk_plot3d_construct_with_size (GtkPlot3D *plot, 126 cairo_surface_t *drawable, 127 gdouble width, gdouble height); 128 void gtk_plot3d_autoscale (GtkPlot3D *plot); 129 /* rotations around global axes */ 130 void gtk_plot3d_rotate (GtkPlot3D *plot, 131 gdouble angle_x, 132 gdouble angle_y, 133 gdouble angle_z); 134 void gtk_plot3d_rotate_vector (GtkPlot3D *plot, 135 GtkPlotVector *vector, 136 gdouble a1, 137 gdouble a2, 138 gdouble a3); 139 140 /* rotations around local axes */ 141 void gtk_plot3d_reset_angles (GtkPlot3D *plot); 142 void gtk_plot3d_rotate_x (GtkPlot3D *plot, 143 gdouble angle); 144 void gtk_plot3d_rotate_y (GtkPlot3D *plot, 145 gdouble angle); 146 void gtk_plot3d_rotate_z (GtkPlot3D *plot, 147 gdouble angle); 148 149 150 void gtk_plot3d_get_pixel (GtkPlot3D *plot, 151 gdouble x, 152 gdouble y, 153 gdouble z, 154 gdouble *px, 155 gdouble *py, 156 gdouble *pz); 157 void gtk_plot3d_set_xrange (GtkPlot3D *plot, 158 gdouble min, gdouble max); 159 void gtk_plot3d_set_yrange (GtkPlot3D *plot, 160 gdouble min, gdouble max); 161 void gtk_plot3d_set_zrange (GtkPlot3D *plot, 162 gdouble min, gdouble max); 163 void gtk_plot3d_set_xfactor (GtkPlot3D *plot, 164 gdouble xfactor); 165 void gtk_plot3d_set_yfactor (GtkPlot3D *plot, 166 gdouble yfactor); 167 void gtk_plot3d_set_zfactor (GtkPlot3D *plot, 168 gdouble zfactor); 169 gdouble gtk_plot3d_get_xfactor (GtkPlot3D *plot); 170 gdouble gtk_plot3d_get_yfactor (GtkPlot3D *plot); 171 gdouble gtk_plot3d_get_zfactor (GtkPlot3D *plot); 172 /* Planes */ 173 void gtk_plot3d_plane_set_color (GtkPlot3D *plot, 174 GtkPlotPlane plane, 175 const GdkRGBA *color); 176 void gtk_plot3d_plane_set_visible (GtkPlot3D *plot, 177 GtkPlotPlane plane, 178 gboolean visible); 179 gboolean gtk_plot3d_plane_visible (GtkPlot3D *plot, 180 GtkPlotPlane plane); 181 182 void gtk_plot3d_corner_set_visible (GtkPlot3D *plot, 183 gboolean visible); 184 gboolean gtk_plot3d_corner_visible (GtkPlot3D *plot); 185 186 void gtk_plot3d_corner_set_attributes(GtkPlot3D *plot, 187 GtkPlotLineStyle style, gfloat width, 188 const GdkRGBA *color); 189 void gtk_plot3d_corner_get_attributes(GtkPlot3D *plot, 190 GtkPlotLineStyle *style, 191 gfloat *width, 192 GdkRGBA *color); 193 void gtk_plot3d_frame_set_attributes (GtkPlot3D *plot, 194 GtkPlotLineStyle style, 195 gfloat width, 196 const GdkRGBA *color); 197 void gtk_plot3d_frame_get_attributes (GtkPlot3D *plot, 198 GtkPlotLineStyle *style, 199 gfloat *width, 200 GdkRGBA *color); 201 202 203 /* Axes */ 204 GtkPlotAxis * gtk_plot3d_get_axis (GtkPlot3D *plot, 205 GtkPlotOrientation orientation); 206 GtkPlotAxis * gtk_plot3d_get_side (GtkPlot3D *plot, 207 GtkPlotSide side); 208 void gtk_plot3d_show_major_ticks (GtkPlot3D *plot, 209 GtkPlotSide side, 210 gint ticks_mask); 211 void gtk_plot3d_show_minor_ticks (GtkPlot3D *plot, 212 GtkPlotSide side, 213 gint ticks_mask); 214 void gtk_plot3d_show_labels (GtkPlot3D *plot, 215 GtkPlotSide side, 216 gint label_mask); 217 void gtk_plot3d_show_title (GtkPlot3D *plot, 218 GtkPlotSide side); 219 void gtk_plot3d_hide_title (GtkPlot3D *plot, 220 GtkPlotSide side); 221 void gtk_plot3d_set_ticks (GtkPlot3D *plot, 222 GtkPlotOrientation direction, 223 gdouble major_step, 224 gint nminor); 225 void gtk_plot3d_set_major_ticks (GtkPlot3D *plot, 226 GtkPlotOrientation direction, 227 gdouble major_step); 228 void gtk_plot3d_set_minor_ticks (GtkPlot3D *plot, 229 GtkPlotOrientation direction, 230 gint nminor); 231 void gtk_plot3d_set_ticks_length (GtkPlot3D *plot, 232 GtkPlotOrientation direction, 233 gint length); 234 void gtk_plot3d_set_ticks_width (GtkPlot3D *plot, 235 GtkPlotOrientation direction, 236 gfloat width); 237 void gtk_plot3d_show_ticks (GtkPlot3D *plot, 238 GtkPlotSide side, 239 gint major_mask, 240 gint minor_mask); 241 void gtk_plot3d_set_titles_offset (GtkPlot3D *plot, 242 gint offset); 243 gint gtk_plot3d_get_titles_offset (GtkPlot3D *plot); 244 void gtk_plot3d_set_scale (GtkPlot3D *plot, 245 GtkPlotOrientation axis, 246 GtkPlotScale scale); 247 GtkPlotScale gtk_plot3d_get_scale (GtkPlot3D *plot, 248 GtkPlotOrientation axis); 249 /* Grids */ 250 void gtk_plot3d_major_grids_set_visible (GtkPlot3D *plot, 251 gboolean x, 252 gboolean y, 253 gboolean z); 254 void gtk_plot3d_minor_grids_set_visible (GtkPlot3D *plot, 255 gboolean x, 256 gboolean y, 257 gboolean z); 258 void gtk_plot3d_major_grids_visible (GtkPlot3D *plot, 259 gboolean *x, 260 gboolean *y, 261 gboolean *z); 262 void gtk_plot3d_minor_grids_visible (GtkPlot3D *plot, 263 gboolean *x, 264 gboolean *y, 265 gboolean *z); 266 void gtk_plot3d_major_zgrid_set_attributes (GtkPlot3D *plot, 267 GtkPlotLineStyle style, gfloat width, 268 const GdkRGBA *color); 269 void gtk_plot3d_major_zgrid_get_attributes (GtkPlot3D *plot, 270 GtkPlotLineStyle *style, 271 gfloat *width, 272 GdkRGBA *color); 273 void gtk_plot3d_minor_zgrid_set_attributes (GtkPlot3D *plot, 274 GtkPlotLineStyle style, 275 gfloat width, 276 const GdkRGBA *color); 277 void gtk_plot3d_minor_zgrid_get_attributes (GtkPlot3D *plot, 278 GtkPlotLineStyle *style, 279 gfloat *width, 280 GdkRGBA *color); 281 282 283 284 285 #ifdef __cplusplus 286 } 287 #endif /* __cplusplus */ 288 289 290 #endif /* __GTK_PLOT3D_H__ */ 291