1 /*-- splot.h: the variables required for each single plot --*/
2 /*
3  * ggobi
4  * Copyright (C) AT&T, Duncan Temple Lang, Dianne Cook 1999-2005
5  *
6  * ggobi is free software; you may use, redistribute, and/or modify it
7  * under the terms of the Eclipse Public License, which is distributed
8  * with the source code and displayed on the ggobi web site,
9  * www.ggobi.org.  For more information, contact the authors:
10  *
11  *   Deborah F. Swayne   dfs@research.att.com
12  *   Di Cook             dicook@iastate.edu
13  *   Duncan Temple Lang  duncan@wald.ucdavis.edu
14  *   Andreas Buja        andreas.buja@wharton.upenn.edu
15 */
16 
17 #ifndef SPLOT_H
18 #define SPLOT_H
19 
20 #include "defines.h"
21 
22 typedef struct _displayd displayd;
23 
24 #define GGOBI_TYPE_SPLOT     (ggobi_splot_get_type ())
25 #define GGOBI_SPLOT(obj)	 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GGOBI_TYPE_SPLOT, splotd))
26 #define GGOBI_SPLOT_CLASS(klass)	 (G_TYPE_CHECK_CLASS_CAST ((klass), GGOBI_TYPE_SPLOT, GGobiSPlotClass))
27 #define GGOBI_IS_SPLOT(obj)	 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GGOBI_TYPE_SPLOT))
28 #define GGOBI_IS_SPLOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GGOBI_TYPE_SPLOT))
29 #define GGOBI_SPLOT_GET_CLASS(obj)  		(G_TYPE_INSTANCE_GET_CLASS ((obj), GGOBI_TYPE_SPLOT, GGobiSPlotClass))
30 
31 
32 GType ggobi_splot_get_type(void);
33 
34 typedef struct
35 {
36     GtkDrawingAreaClass parent_class;
37 
38     RedrawStyle redraw; /* used by barchart to indicate it needs to do a full redraw from set_color_id. */
39 
40 } GGobiSPlotClass;
41 
42 
43 typedef struct
44 {
45 
46  GtkDrawingArea canvas;
47 
48  displayd *displayptr;  /* a pointer to the enclosing display */
49 
50  GtkWidget *da;                 /* drawing_area */
51  GdkPixmap *pixmap0, *pixmap1;  /* 2-stage drawing */
52 
53  GdkCursor *cursor;
54  gint jcursor;
55 
56  RedrawStyle redraw_style;
57 
58  /* Drawing area dimensions */
59  icoords max;
60 
61  /*
62   * line segments in scatterplot and scatmat
63  */
64  GdkSegment *arrowheads;
65  GdkSegment *edges;
66 
67  /*
68   * line segments in parallel coordinates plot
69  */
70  GdkSegment *whiskers;
71 
72  gcoords *planar;
73  icoords *screen;
74 
75  /*
76   * shift and scale
77  */
78  fcoords scale, tour_scale;
79  gcoords iscale;
80  gcoords pmid;	  /*-- center of the screen in planar/world coords --*/
81 
82 /*
83  * button and key event information
84 */
85  gint motion_id, press_id, release_id, key_press_id, scroll_id;
86  icoords mousedownpos, mousepos, mousepos_o;
87 
88  brush_coords brush_pos, brush_pos_o;
89 
90 /*
91  * plot1d  (used in parcoords as well as scatterplot)
92 */
93  gint p1dvar;
94  struct _p1d {
95    vector_f spread_data; /* the spreading data */
96    lims lim;      /* limits of the spreading data */
97    gfloat mean;
98    /*-- line segments in ASHes --*/
99    icoords ash_baseline;  /*-- for drawing segments from point to baseline --*/
100  } p1d;
101 
102 
103 /*
104  * tour1d (variables used to record the state of the 1D tour for this plot)
105  */
106  struct _tour1d {
107    gfloat mincnt;
108    gfloat maxcnt;
109    gfloat minscreenx;
110    gfloat maxscreenx;
111    gboolean initmax;
112    icoords ash_baseline;  /*-- for drawing segments from point to baseline --*/
113  } tour1d;
114 
115 /*
116  * tour2d: rescaling so that points don't go outside the planar space
117  */
118  struct _tour2d {
119    greal maxscreen;
120    gboolean initmax;
121  } tour2d;
122 
123 /*
124  * tour2d: rescaling so that points don't go outside the planar space
125  */
126  struct _tourcorr {
127    greal maxscreen;
128    gboolean initmax;
129  } tourcorr;
130 
131 /*
132  * xyplot
133 */
134  icoords xyvars;
135 
136 /*-- rotation implemented as a limited tour2d --*/
137  struct _tour2d3 {
138    greal maxscreen;
139    gboolean initmax;
140  } tour2d3;
141 
142 #ifdef WIN32
143  struct _win32 {
144    gint       npoints;
145    GdkPoint   *points;
146    GdkSegment *segs;
147    GdkSegment *whisker_segs;
148    GdkSegment *ash_segs;
149    rectd      *open_rects;
150    rectd      *filled_rects;
151    arcd       *open_arcs;
152    arcd       *filled_arcs;
153  } win32;
154 #endif
155 
156 } splotd;
157 
158 
159 #define GGOBI_TYPE_EXTENDED_SPLOT           (ggobi_extended_splot_get_type())
160 #define GGOBI_EXTENDED_SPLOT(obj)	        (G_TYPE_CHECK_INSTANCE_CAST ((obj), GGOBI_TYPE_EXTENDED_SPLOT, extendedSPlotd))
161 #define GGOBI_EXTENDED_SPLOT_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), GGOBI_TYPE_EXTENDED_SPLOT, GGobiExtendedSPlotClass))
162 #define GGOBI_IS_EXTENDED_SPLOT(obj)	 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GGOBI_TYPE_EXTENDED_SPLOT))
163 #define GGOBI_IS_EXTENDED_SPLOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GGOBI_TYPE_EXTENDED_SPLOT))
164 #define GGOBI_EXTENDED_SPLOT_GET_CLASS(obj)  		(G_TYPE_INSTANCE_GET_CLASS ((obj), GGOBI_TYPE_EXTENDED_SPLOT, GGobiExtendedSPlotClass))
165 
166 GType ggobi_extended_splot_get_type(void);
167 
168 #include "ggobi-data.h"
169 
170 typedef struct
171 {
172 
173    GGobiSPlotClass splot;
174 
175    gchar *(*tree_label)(splotd *sp, GGobiData *d, ggobid *gg);
176 
177    gboolean (*identify_notify)(icoords, splotd *, GGobiData *, ggobid *);
178 
179    void (*add_plot_labels)(splotd *, GdkDrawable *, ggobid *gg);
180    void (*add_markup_cues)(splotd *, GdkDrawable *, ggobid *);
181    void (*add_scaling_cues)(splotd *, GdkDrawable *, ggobid *);
182    void (*add_identify_cues)(gboolean, gint k, splotd *, GdkDrawable *, ggobid *);
183    void (*add_identify_edge_cues)(gint k, splotd *, GdkDrawable *, gboolean, ggobid *);
184 
185    gboolean (*redraw)(splotd *, GGobiData *, ggobid *, gboolean binned);
186 
187   void (*screen_to_tform)(cpaneld *, splotd *, icoords *, fcoords *, ggobid *);
188   void (*world_to_plane)(splotd *, GGobiData *, ggobid *);
189 
190 	/** Convenience to be called within the standard loop */
191    void (*sub_plane_to_screen)(splotd *sp, displayd *dpy, GGobiData *d, ggobid *gg);
192         /** Allows the class to take over the entire plane_to_screen.
193             Handling each row can be done using a method for sub_plane_to_screen. */
194    void (*plane_to_screen)(splotd *, GGobiData *, ggobid *);
195 
196    gint (*active_paint_points)(splotd *, GGobiData *, ggobid *);
197 
198 
199    GdkSegment *(*alloc_whiskers)(GdkSegment *, splotd *sp, gint nrows, GGobiData *d);
200 
201 	/** called from splot_plot_edge */
202    gboolean (*draw_edge_p)(splotd *sp, gint m, GGobiData *d, GGobiData *e, ggobid *gg);
203 	/** called from splot_plot_case. Should probably be the same as
204         draw_edge_p but doesn't take the edge argument! Could drop the
205         first datad in splot_plot_edge and just hand it the one dataset. */
206    gboolean (*draw_case_p)(splotd *sp, gint m, GGobiData *d, ggobid *gg);
207 
208    void (*within_draw_to_binned)(splotd *sp, gint m, GdkDrawable *drawable, GdkGC *gc);
209    void (*within_draw_to_unbinned)(splotd *sp, gint m, GdkDrawable *drawable, GdkGC *gc);
210 
211   void (*splot_assign_points_to_bins)(GGobiData *, splotd *, ggobid *);
212 
213    gint (*plotted_vars_get)(splotd *sp, gint *vars, GGobiData *d);
214 
215 
216    splotd * (*createWithVars)(displayd *dpy, gint *vars, gint nvars, ggobid *gg);
217 
218 } GGobiExtendedSPlotClass;
219 
220 typedef struct
221 {
222 
223    splotd splot;
224 
225 } extendedSPlotd;
226 
227 
228 
229 void splot_init(splotd *sp, displayd *display, struct _ggobid *gg);
230 
231 /* shared by barchart and parcoords. */
232 gint splot1DVariablesGet(splotd *sp, gint *cols, GGobiData *d);
233 
234 #endif
235