1 /* Generated by GOB (v2.0.20) (do not edit directly) */
2
3 /* End world hunger, donate to the World Food Programme, http://www.wfp.org */
4
5 #define GOB_VERSION_MAJOR 2
6 #define GOB_VERSION_MINOR 0
7 #define GOB_VERSION_PATCHLEVEL 20
8
9 #define selfp (self->_priv)
10
11 #include <string.h> /* memset() */
12
13 #include "ggobi-data.h"
14
15 #ifdef G_LIKELY
16 #define ___GOB_LIKELY(expr) G_LIKELY(expr)
17 #define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
18 #else /* ! G_LIKELY */
19 #define ___GOB_LIKELY(expr) (expr)
20 #define ___GOB_UNLIKELY(expr) (expr)
21 #endif /* G_LIKELY */
22
23 #line 93 "data.gob"
24
25 #include "vars.h"
26 #include "externs.h"
27
28 #line 29 "ggobi-data.c"
29 /* self casting macros */
30 #define SELF(x) GGOBI_DATA(x)
31 #define SELF_CONST(x) GGOBI_DATA_CONST(x)
32 #define IS_SELF(x) GGOBI_IS_DATA(x)
33 #define TYPE_SELF GGOBI_TYPE_DATA
34 #define SELF_CLASS(x) GGOBI_DATA_CLASS(x)
35
36 #define SELF_GET_CLASS(x) GGOBI_DATA_GET_CLASS(x)
37
38 /* self typedefs */
39 typedef GGobiData Self;
40 typedef GGobiDataClass SelfClass;
41
42 /* here are local prototypes */
43 static void ___object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
44 static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
45 static void ggobi_data_class_init (GGobiDataClass * c) G_GNUC_UNUSED;
46 #line 191 "data.gob"
47 static void ggobi_data_rows_in_plot_changed (GGobiData * self, int arg1, int arg2, ggobid * arg3) G_GNUC_UNUSED;
48 #line 49 "ggobi-data.c"
49 #line 195 "data.gob"
50 static void ggobi_data_init (GGobiData * self) G_GNUC_UNUSED;
51 #line 52 "ggobi-data.c"
52 #line 204 "data.gob"
53 static GObject * ___8_ggobi_data_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) G_GNUC_UNUSED;
54 #line 55 "ggobi-data.c"
55
56 /*
57 * Signal connection wrapper macro shortcuts
58 */
59 #define self_connect__rows_in_plot_changed(object,func,data) ggobi_data_connect__rows_in_plot_changed((object),(func),(data))
60 #define self_connect_after__rows_in_plot_changed(object,func,data) ggobi_data_connect_after__rows_in_plot_changed((object),(func),(data))
61 #define self_connect_data__rows_in_plot_changed(object,func,data,destroy_data,flags) ggobi_data_connect_data__rows_in_plot_changed((object),(func),(data),(destroy_data),(flags))
62 #define self_connect__col_name_changed(object,func,data) ggobi_data_connect__col_name_changed((object),(func),(data))
63 #define self_connect_after__col_name_changed(object,func,data) ggobi_data_connect_after__col_name_changed((object),(func),(data))
64 #define self_connect_data__col_name_changed(object,func,data,destroy_data,flags) ggobi_data_connect_data__col_name_changed((object),(func),(data),(destroy_data),(flags))
65
66 typedef void (*___Sig1) (GGobiData *, gint , gint , gpointer , gpointer);
67
68 static void
___marshal_Sig1(GClosure * closure,GValue * return_value G_GNUC_UNUSED,guint n_param_values,const GValue * param_values,gpointer invocation_hint G_GNUC_UNUSED,gpointer marshal_data)69 ___marshal_Sig1 (GClosure *closure,
70 GValue *return_value G_GNUC_UNUSED,
71 guint n_param_values,
72 const GValue *param_values,
73 gpointer invocation_hint G_GNUC_UNUSED,
74 gpointer marshal_data)
75 {
76 register ___Sig1 callback;
77 register GCClosure *cc = (GCClosure*) closure;
78 register gpointer data1, data2;
79
80 g_return_if_fail (n_param_values == 4);
81
82 if (G_CCLOSURE_SWAP_DATA (closure)) {
83 data1 = closure->data;
84 data2 = g_value_peek_pointer (param_values + 0);
85 } else {
86 data1 = g_value_peek_pointer (param_values + 0);
87 data2 = closure->data;
88 }
89
90 callback = (___Sig1) (marshal_data != NULL ? marshal_data : cc->callback);
91
92 callback ((GGobiData *)data1,
93 (gint ) g_value_get_int (param_values + 1),
94 (gint ) g_value_get_int (param_values + 2),
95 (gpointer ) g_value_get_pointer (param_values + 3),
96 data2);
97 }
98
99
100 typedef void (*___Sig2) (GGobiData *, gint , gpointer);
101
102 static void
___marshal_Sig2(GClosure * closure,GValue * return_value G_GNUC_UNUSED,guint n_param_values,const GValue * param_values,gpointer invocation_hint G_GNUC_UNUSED,gpointer marshal_data)103 ___marshal_Sig2 (GClosure *closure,
104 GValue *return_value G_GNUC_UNUSED,
105 guint n_param_values,
106 const GValue *param_values,
107 gpointer invocation_hint G_GNUC_UNUSED,
108 gpointer marshal_data)
109 {
110 register ___Sig2 callback;
111 register GCClosure *cc = (GCClosure*) closure;
112 register gpointer data1, data2;
113
114 g_return_if_fail (n_param_values == 2);
115
116 if (G_CCLOSURE_SWAP_DATA (closure)) {
117 data1 = closure->data;
118 data2 = g_value_peek_pointer (param_values + 0);
119 } else {
120 data1 = g_value_peek_pointer (param_values + 0);
121 data2 = closure->data;
122 }
123
124 callback = (___Sig2) (marshal_data != NULL ? marshal_data : cc->callback);
125
126 callback ((GGobiData *)data1,
127 (gint ) g_value_get_int (param_values + 1),
128 data2);
129 }
130
131
132 enum {
133 ROWS_IN_PLOT_CHANGED_SIGNAL,
134 COL_NAME_CHANGED_SIGNAL,
135 LAST_SIGNAL
136 };
137
138 enum {
139 PROP_0,
140 PROP_NROWS,
141 PROP_NCOLS
142 };
143
144 static guint object_signals[LAST_SIGNAL] = {0};
145
146 /* pointer to the class of our parent */
147 static GObjectClass *parent_class = NULL;
148
149 /* Short form macros */
150 #define self_get_nrows ggobi_data_get_nrows
151 #define self_set_nrows ggobi_data_set_nrows
152 #define self_get_ncols ggobi_data_get_ncols
153 #define self_set_ncols ggobi_data_set_ncols
154 #define self_rows_in_plot_changed ggobi_data_rows_in_plot_changed
155 #define self_col_name_changed ggobi_data_col_name_changed
156 #define self_new ggobi_data_new
157 #define self_get_name ggobi_data_get_name
158 #define self_set_name ggobi_data_set_name
159 #define self_get_n_cols ggobi_data_get_n_cols
160 #define self_get_n_rows ggobi_data_get_n_rows
161 #define self_get_col_name ggobi_data_get_col_name
162 #define self_set_col_name ggobi_data_set_col_name
163 #define self_get_transformed_col_name ggobi_data_get_transformed_col_name
164 #define self_set_transformed_col_name ggobi_data_set_transformed_col_name
165 #define self_set_missing ggobi_data_set_missing
166 #define self_is_missing ggobi_data_is_missing
167 #define self_has_missings ggobi_data_has_missings
168 #define self_get_col_n_missing ggobi_data_get_col_n_missing
169 #define self_set_raw_values ggobi_data_set_raw_values
170 #define self_set_raw_value ggobi_data_set_raw_value
171 #define self_get_string_value ggobi_data_get_string_value
172 #define self_has_edges ggobi_data_has_edges
173 #define self_has_variables ggobi_data_has_variables
174 GType
ggobi_data_get_type(void)175 ggobi_data_get_type (void)
176 {
177 static GType type = 0;
178
179 if ___GOB_UNLIKELY(type == 0) {
180 static const GTypeInfo info = {
181 sizeof (GGobiDataClass),
182 (GBaseInitFunc) NULL,
183 (GBaseFinalizeFunc) NULL,
184 (GClassInitFunc) ggobi_data_class_init,
185 (GClassFinalizeFunc) NULL,
186 NULL /* class_data */,
187 sizeof (GGobiData),
188 0 /* n_preallocs */,
189 (GInstanceInitFunc) ggobi_data_init,
190 NULL
191 };
192
193 type = g_type_register_static (G_TYPE_OBJECT, "GGobiData", &info, (GTypeFlags)0);
194 }
195
196 return type;
197 }
198
199 /* a macro for creating a new object of our type */
200 #define GET_NEW ((GGobiData *)g_object_new(ggobi_data_get_type(), NULL))
201
202 /* a function for creating a new object of our type */
203 #include <stdarg.h>
204 static GGobiData * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
205 static GGobiData *
GET_NEW_VARG(const char * first,...)206 GET_NEW_VARG (const char *first, ...)
207 {
208 GGobiData *ret;
209 va_list ap;
210 va_start (ap, first);
211 ret = (GGobiData *)g_object_new_valist (ggobi_data_get_type (), first, ap);
212 va_end (ap);
213 return ret;
214 }
215
216 static void
ggobi_data_class_init(GGobiDataClass * c G_GNUC_UNUSED)217 ggobi_data_class_init (GGobiDataClass * c G_GNUC_UNUSED)
218 {
219 #define __GOB_FUNCTION__ "GGobi:Data::class_init"
220 GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;
221
222 parent_class = g_type_class_ref (G_TYPE_OBJECT);
223
224 object_signals[ROWS_IN_PLOT_CHANGED_SIGNAL] =
225 g_signal_new ("rows_in_plot_changed",
226 G_TYPE_FROM_CLASS (g_object_class),
227 (GSignalFlags)(G_SIGNAL_RUN_LAST),
228 G_STRUCT_OFFSET (GGobiDataClass, rows_in_plot_changed),
229 NULL, NULL,
230 ___marshal_Sig1,
231 G_TYPE_NONE, 3,
232 G_TYPE_INT,
233 G_TYPE_INT,
234 G_TYPE_POINTER);
235 if ___GOB_UNLIKELY(sizeof(int ) != sizeof(gint ) || sizeof(int ) != sizeof(gint ) || sizeof(ggobid * ) != sizeof(gpointer ) || parent_class == NULL /* avoid warning */) {
236 g_error("data.gob line 191: Type mismatch of \"rows_in_plot_changed\" signal signature");
237 }
238 object_signals[COL_NAME_CHANGED_SIGNAL] =
239 g_signal_new ("col_name_changed",
240 G_TYPE_FROM_CLASS (g_object_class),
241 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
242 G_STRUCT_OFFSET (GGobiDataClass, col_name_changed),
243 NULL, NULL,
244 ___marshal_Sig2,
245 G_TYPE_NONE, 1,
246 G_TYPE_INT);
247 if ___GOB_UNLIKELY(sizeof(int ) != sizeof(gint ) || parent_class == NULL /* avoid warning */) {
248 g_error("data.gob line 193: Type mismatch of \"col_name_changed\" signal signature");
249 }
250
251 c->rows_in_plot_changed = NULL;
252 c->col_name_changed = NULL;
253 #line 204 "data.gob"
254 g_object_class->constructor = ___8_ggobi_data_constructor;
255 #line 256 "ggobi-data.c"
256 g_object_class->get_property = ___object_get_property;
257 g_object_class->set_property = ___object_set_property;
258 {
259 GParamSpec *param_spec;
260
261 param_spec = g_param_spec_uint
262 ("nrows" /* name */,
263 "nrows" /* nick */,
264 "Number of rows in the dataset" /* blurb */,
265 0 /* minimum */,
266 INT_MAX /* maximum */,
267 0 /* default_value */,
268 (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
269 g_object_class_install_property (g_object_class,
270 PROP_NROWS,
271 param_spec);
272 param_spec = g_param_spec_uint
273 ("ncols" /* name */,
274 "ncols" /* nick */,
275 "Number of cols in the dataset" /* blurb */,
276 0 /* minimum */,
277 INT_MAX /* maximum */,
278 0 /* default_value */,
279 (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
280 g_object_class_install_property (g_object_class,
281 PROP_NCOLS,
282 param_spec);
283 }
284 }
285 #undef __GOB_FUNCTION__
286 #line 195 "data.gob"
287 static void
ggobi_data_init(GGobiData * self G_GNUC_UNUSED)288 ggobi_data_init (GGobiData * self G_GNUC_UNUSED)
289 {
290 #line 291 "ggobi-data.c"
291 #define __GOB_FUNCTION__ "GGobi:Data::init"
292 {
293 #line 195 "data.gob"
294
295 sphere_init(self);
296
297 self_set_name(self, "unknown", NULL);
298
299 self->nearest_point = -1;
300 self->missings_show_p = true;
301
302 #line 303 "ggobi-data.c"
303 }
304 }
305 #undef __GOB_FUNCTION__
306
307 static void
___object_set_property(GObject * object,guint property_id,const GValue * VAL G_GNUC_UNUSED,GParamSpec * pspec G_GNUC_UNUSED)308 ___object_set_property (GObject *object,
309 guint property_id,
310 const GValue *VAL G_GNUC_UNUSED,
311 GParamSpec *pspec G_GNUC_UNUSED)
312 #define __GOB_FUNCTION__ "GGobi:Data::set_property"
313 {
314 GGobiData *self G_GNUC_UNUSED;
315
316 self = GGOBI_DATA (object);
317
318 switch (property_id) {
319 case PROP_NROWS:
320 {
321 #line 182 "data.gob"
322 self->nrows = g_value_get_uint (VAL);
323 #line 324 "ggobi-data.c"
324 }
325 break;
326 case PROP_NCOLS:
327 {
328 #line 186 "data.gob"
329 self->ncols = g_value_get_uint (VAL);
330 #line 331 "ggobi-data.c"
331 }
332 break;
333 default:
334 /* Apparently in g++ this is needed, glib is b0rk */
335 #ifndef __PRETTY_FUNCTION__
336 # undef G_STRLOC
337 # define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__)
338 #endif
339 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
340 break;
341 }
342 }
343 #undef __GOB_FUNCTION__
344
345 static void
___object_get_property(GObject * object,guint property_id,GValue * VAL G_GNUC_UNUSED,GParamSpec * pspec G_GNUC_UNUSED)346 ___object_get_property (GObject *object,
347 guint property_id,
348 GValue *VAL G_GNUC_UNUSED,
349 GParamSpec *pspec G_GNUC_UNUSED)
350 #define __GOB_FUNCTION__ "GGobi:Data::get_property"
351 {
352 GGobiData *self G_GNUC_UNUSED;
353
354 self = GGOBI_DATA (object);
355
356 switch (property_id) {
357 case PROP_NROWS:
358 {
359 #line 182 "data.gob"
360 g_value_set_uint (VAL, self->nrows);
361 #line 362 "ggobi-data.c"
362 }
363 break;
364 case PROP_NCOLS:
365 {
366 #line 186 "data.gob"
367 g_value_set_uint (VAL, self->ncols);
368 #line 369 "ggobi-data.c"
369 }
370 break;
371 default:
372 /* Apparently in g++ this is needed, glib is b0rk */
373 #ifndef __PRETTY_FUNCTION__
374 # undef G_STRLOC
375 # define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__)
376 #endif
377 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
378 break;
379 }
380 }
381 #undef __GOB_FUNCTION__
382
383
384 #line 182 "data.gob"
385 guint
ggobi_data_get_nrows(GGobiData * self)386 ggobi_data_get_nrows (GGobiData * self)
387 {
388 #line 389 "ggobi-data.c"
389 #define __GOB_FUNCTION__ "GGobi:Data::get_nrows"
390 {
391 #line 182 "data.gob"
392 guint val; g_object_get (G_OBJECT (self), "nrows", &val, NULL); return val;
393 }}
394 #line 395 "ggobi-data.c"
395 #undef __GOB_FUNCTION__
396
397 #line 182 "data.gob"
398 void
ggobi_data_set_nrows(GGobiData * self,guint val)399 ggobi_data_set_nrows (GGobiData * self, guint val)
400 {
401 #line 402 "ggobi-data.c"
402 #define __GOB_FUNCTION__ "GGobi:Data::set_nrows"
403 {
404 #line 182 "data.gob"
405 g_object_set (G_OBJECT (self), "nrows", val, NULL);
406 }}
407 #line 408 "ggobi-data.c"
408 #undef __GOB_FUNCTION__
409
410 #line 186 "data.gob"
411 guint
ggobi_data_get_ncols(GGobiData * self)412 ggobi_data_get_ncols (GGobiData * self)
413 {
414 #line 415 "ggobi-data.c"
415 #define __GOB_FUNCTION__ "GGobi:Data::get_ncols"
416 {
417 #line 186 "data.gob"
418 guint val; g_object_get (G_OBJECT (self), "ncols", &val, NULL); return val;
419 }}
420 #line 421 "ggobi-data.c"
421 #undef __GOB_FUNCTION__
422
423 #line 186 "data.gob"
424 void
ggobi_data_set_ncols(GGobiData * self,guint val)425 ggobi_data_set_ncols (GGobiData * self, guint val)
426 {
427 #line 428 "ggobi-data.c"
428 #define __GOB_FUNCTION__ "GGobi:Data::set_ncols"
429 {
430 #line 186 "data.gob"
431 g_object_set (G_OBJECT (self), "ncols", val, NULL);
432 }}
433 #line 434 "ggobi-data.c"
434 #undef __GOB_FUNCTION__
435
436 #line 191 "data.gob"
437 static void
ggobi_data_rows_in_plot_changed(GGobiData * self,int arg1,int arg2,ggobid * arg3)438 ggobi_data_rows_in_plot_changed (GGobiData * self, int arg1, int arg2, ggobid * arg3)
439 {
440 #line 441 "ggobi-data.c"
441 GValue ___param_values[4];
442 GValue ___return_val;
443
444 memset (&___return_val, 0, sizeof (___return_val));
445 memset (&___param_values, 0, sizeof (___param_values));
446
447 #line 191 "data.gob"
448 g_return_if_fail (self != NULL);
449 #line 191 "data.gob"
450 g_return_if_fail (GGOBI_IS_DATA (self));
451 #line 452 "ggobi-data.c"
452
453 ___param_values[0].g_type = 0;
454 g_value_init (&___param_values[0], G_TYPE_FROM_INSTANCE (self));
455 g_value_set_instance (&___param_values[0], (gpointer) self);
456
457 ___param_values[1].g_type = 0;
458 g_value_init (&___param_values[1], G_TYPE_INT);
459 g_value_set_int (&___param_values[1], (gint ) arg1);
460
461 ___param_values[2].g_type = 0;
462 g_value_init (&___param_values[2], G_TYPE_INT);
463 g_value_set_int (&___param_values[2], (gint ) arg2);
464
465 ___param_values[3].g_type = 0;
466 g_value_init (&___param_values[3], G_TYPE_POINTER);
467 g_value_set_pointer (&___param_values[3], (gpointer ) arg3);
468
469 g_signal_emitv (___param_values,
470 object_signals[ROWS_IN_PLOT_CHANGED_SIGNAL],
471 0 /* detail */,
472 &___return_val);
473
474 g_value_unset (&___param_values[0]);
475 g_value_unset (&___param_values[1]);
476 g_value_unset (&___param_values[2]);
477 g_value_unset (&___param_values[3]);
478 }
479
480 #line 193 "data.gob"
481 void
ggobi_data_col_name_changed(GGobiData * self,int j)482 ggobi_data_col_name_changed (GGobiData * self, int j)
483 {
484 #line 485 "ggobi-data.c"
485 GValue ___param_values[2];
486 GValue ___return_val;
487
488 memset (&___return_val, 0, sizeof (___return_val));
489 memset (&___param_values, 0, sizeof (___param_values));
490
491 #line 193 "data.gob"
492 g_return_if_fail (self != NULL);
493 #line 193 "data.gob"
494 g_return_if_fail (GGOBI_IS_DATA (self));
495 #line 496 "ggobi-data.c"
496
497 ___param_values[0].g_type = 0;
498 g_value_init (&___param_values[0], G_TYPE_FROM_INSTANCE (self));
499 g_value_set_instance (&___param_values[0], (gpointer) self);
500
501 ___param_values[1].g_type = 0;
502 g_value_init (&___param_values[1], G_TYPE_INT);
503 g_value_set_int (&___param_values[1], (gint ) j);
504
505 g_signal_emitv (___param_values,
506 object_signals[COL_NAME_CHANGED_SIGNAL],
507 0 /* detail */,
508 &___return_val);
509
510 g_value_unset (&___param_values[0]);
511 g_value_unset (&___param_values[1]);
512 }
513
514
515 #line 204 "data.gob"
516 static GObject *
___8_ggobi_data_constructor(GType type G_GNUC_UNUSED,guint n_construct_properties,GObjectConstructParam * construct_properties)517 ___8_ggobi_data_constructor (GType type G_GNUC_UNUSED, guint n_construct_properties, GObjectConstructParam * construct_properties)
518 #line 519 "ggobi-data.c"
519 #define PARENT_HANDLER(___type,___n_construct_properties,___construct_properties) \
520 ((G_OBJECT_CLASS(parent_class)->constructor)? \
521 (* G_OBJECT_CLASS(parent_class)->constructor)(___type,___n_construct_properties,___construct_properties): \
522 ((GObject * )0))
523 {
524 #define __GOB_FUNCTION__ "GGobi:Data::constructor"
525 {
526 #line 206 "data.gob"
527
528 GGobiData* d = (GGobiData*) PARENT_HANDLER(type, n_construct_properties, construct_properties);
529 /* we can put these here OR we can put them in the setter for the 'ncols'
530 property, since we know that comes last (after 'nrows' has been set) */
531
532 d->nrows_in_plot = d->nrows; /*-- for now --*/
533
534 arrayf_alloc (&d->raw, d->nrows, d->ncols); //FIXME: probably leaks memory
535 //arrays_alloc (&d->missing, d->nrows, d->ncols);
536 arrays_alloc_zero (&d->missing, d->nrows, d->ncols);
537
538 rowlabels_alloc (d);
539
540 vartable_alloc (d);
541 vartable_init (d);
542
543 br_glyph_ids_alloc (d);
544 br_glyph_ids_init (d);
545
546 br_color_ids_alloc (d);
547 br_color_ids_init (d);
548
549 br_hidden_alloc (d);
550 br_hidden_init (d);
551
552
553 return((GObject *)d);
554 }}
555 #line 556 "ggobi-data.c"
556 #undef __GOB_FUNCTION__
557 #undef PARENT_HANDLER
558
559 #line 235 "data.gob"
560 GGobiData *
ggobi_data_new(guint nrows,guint ncols)561 ggobi_data_new (guint nrows, guint ncols)
562 {
563 #line 564 "ggobi-data.c"
564 #define __GOB_FUNCTION__ "GGobi:Data::new"
565 {
566 #line 237 "data.gob"
567
568 GGobiData* d = (GGobiData*) g_object_new(GGOBI_TYPE_DATA, "ncols", ncols, "nrows", nrows, NULL);
569 return(d);
570 }}
571 #line 572 "ggobi-data.c"
572 #undef __GOB_FUNCTION__
573
574 #line 248 "data.gob"
575 gchar *
ggobi_data_get_name(GGobiData * self)576 ggobi_data_get_name (GGobiData * self)
577 {
578 #line 579 "ggobi-data.c"
579 #define __GOB_FUNCTION__ "GGobi:Data::get_name"
580 #line 248 "data.gob"
581 g_return_val_if_fail (self != NULL, (gchar * )0);
582 #line 248 "data.gob"
583 g_return_val_if_fail (GGOBI_IS_DATA (self), (gchar * )0);
584 #line 585 "ggobi-data.c"
585 {
586 #line 250 "data.gob"
587
588 return (g_strdup(self->name));
589 }}
590 #line 591 "ggobi-data.c"
591 #undef __GOB_FUNCTION__
592
593 #line 254 "data.gob"
594 void
ggobi_data_set_name(GGobiData * self,gchar * name,gchar * nickname)595 ggobi_data_set_name (GGobiData * self, gchar * name, gchar * nickname)
596 {
597 #line 598 "ggobi-data.c"
598 #define __GOB_FUNCTION__ "GGobi:Data::set_name"
599 #line 254 "data.gob"
600 g_return_if_fail (self != NULL);
601 #line 254 "data.gob"
602 g_return_if_fail (GGOBI_IS_DATA (self));
603 #line 604 "ggobi-data.c"
604 {
605 #line 256 "data.gob"
606
607 if (name == NULL) name = g_strdup("unknown");
608 if (nickname == NULL) nickname = g_strndup(name, 5);
609
610 self->name = g_strdup(name);
611 self->nickname = g_strndup(name, 5);
612 }}
613 #line 614 "ggobi-data.c"
614 #undef __GOB_FUNCTION__
615
616 #line 264 "data.gob"
617 guint
ggobi_data_get_n_cols(GGobiData * self)618 ggobi_data_get_n_cols (GGobiData * self)
619 {
620 #line 621 "ggobi-data.c"
621 #define __GOB_FUNCTION__ "GGobi:Data::get_n_cols"
622 #line 264 "data.gob"
623 g_return_val_if_fail (self != NULL, (guint )0);
624 #line 264 "data.gob"
625 g_return_val_if_fail (GGOBI_IS_DATA (self), (guint )0);
626 #line 627 "ggobi-data.c"
627 {
628 #line 265 "data.gob"
629
630 return self->ncols;
631 }}
632 #line 633 "ggobi-data.c"
633 #undef __GOB_FUNCTION__
634
635 #line 269 "data.gob"
636 guint
ggobi_data_get_n_rows(GGobiData * self)637 ggobi_data_get_n_rows (GGobiData * self)
638 {
639 #line 640 "ggobi-data.c"
640 #define __GOB_FUNCTION__ "GGobi:Data::get_n_rows"
641 #line 269 "data.gob"
642 g_return_val_if_fail (self != NULL, (guint )0);
643 #line 269 "data.gob"
644 g_return_val_if_fail (GGOBI_IS_DATA (self), (guint )0);
645 #line 646 "ggobi-data.c"
646 {
647 #line 270 "data.gob"
648
649 return self->nrows;
650 }}
651 #line 652 "ggobi-data.c"
652 #undef __GOB_FUNCTION__
653
654 #line 275 "data.gob"
655 gchar *
ggobi_data_get_col_name(GGobiData * self,guint j)656 ggobi_data_get_col_name (GGobiData * self, guint j)
657 {
658 #line 659 "ggobi-data.c"
659 #define __GOB_FUNCTION__ "GGobi:Data::get_col_name"
660 #line 275 "data.gob"
661 g_return_val_if_fail (self != NULL, (gchar * )0);
662 #line 275 "data.gob"
663 g_return_val_if_fail (GGOBI_IS_DATA (self), (gchar * )0);
664 #line 665 "ggobi-data.c"
665 {
666 #line 277 "data.gob"
667
668 vartabled* vt = vartable_element_get (j, self);
669 return(vt->collab);
670 }}
671 #line 672 "ggobi-data.c"
672 #undef __GOB_FUNCTION__
673
674 #line 282 "data.gob"
675 void
ggobi_data_set_col_name(GGobiData * self,guint j,gchar * value)676 ggobi_data_set_col_name (GGobiData * self, guint j, gchar * value)
677 {
678 #line 679 "ggobi-data.c"
679 #define __GOB_FUNCTION__ "GGobi:Data::set_col_name"
680 #line 282 "data.gob"
681 g_return_if_fail (self != NULL);
682 #line 282 "data.gob"
683 g_return_if_fail (GGOBI_IS_DATA (self));
684 #line 685 "ggobi-data.c"
685 {
686 #line 284 "data.gob"
687
688 vartabled* vt = vartable_element_get (j, self);
689
690 //if (vt->collab) g_object_unref(vt->collab);
691 //if (vt->nickname) g_object_unref(vt->nickname);
692 //if (vt->collab_tform) g_object_unref(vt->collab_tform);
693
694 if (value == NULL) value = g_strdup_printf("V%d", j + 1);
695
696 vt->collab = g_strdup(value);
697 vt->collab_tform = g_strdup(value);
698 vt->nickname = g_strndup (vt->collab, 2);
699
700 g_signal_emit_by_name (self, "col_name_changed", (gpointer) self, j);
701
702 // SEND COLUMN NAME CHANGED SIGNAL
703 // Listeners:
704 // * vartable_collab_set_by_var (j, d);
705 // * varpanel_label_set (j, d); /*-- checkboxes --*/
706 // * varcircle_label_set (j, d); /*-- variable circles --*/
707 // * tform_label_update (jvar, d);
708
709 }}
710 #line 711 "ggobi-data.c"
711 #undef __GOB_FUNCTION__
712
713 #line 309 "data.gob"
714 gchar *
ggobi_data_get_transformed_col_name(GGobiData * self,guint j)715 ggobi_data_get_transformed_col_name (GGobiData * self, guint j)
716 {
717 #line 718 "ggobi-data.c"
718 #define __GOB_FUNCTION__ "GGobi:Data::get_transformed_col_name"
719 #line 309 "data.gob"
720 g_return_val_if_fail (self != NULL, (gchar * )0);
721 #line 309 "data.gob"
722 g_return_val_if_fail (GGOBI_IS_DATA (self), (gchar * )0);
723 #line 724 "ggobi-data.c"
724 {
725 #line 311 "data.gob"
726
727 vartabled* vt = vartable_element_get (j, self);
728 return(vt->collab_tform);
729 }}
730 #line 731 "ggobi-data.c"
731 #undef __GOB_FUNCTION__
732
733 #line 316 "data.gob"
734 void
ggobi_data_set_transformed_col_name(GGobiData * self,guint j,gchar * value)735 ggobi_data_set_transformed_col_name (GGobiData * self, guint j, gchar * value)
736 {
737 #line 738 "ggobi-data.c"
738 #define __GOB_FUNCTION__ "GGobi:Data::set_transformed_col_name"
739 #line 316 "data.gob"
740 g_return_if_fail (self != NULL);
741 #line 316 "data.gob"
742 g_return_if_fail (GGOBI_IS_DATA (self));
743 #line 744 "ggobi-data.c"
744 {
745 #line 318 "data.gob"
746
747 vartabled* vt = vartable_element_get (j, self);
748 //if (vt->collab_tform) g_object_unref(vt->collab_tform); //is this necessary?
749 vt->collab_tform = g_strdup(value);
750 }}
751 #line 752 "ggobi-data.c"
752 #undef __GOB_FUNCTION__
753
754 /**
755 * ggobi_data_set_missing:
756 *
757 * Set specified cell to be a missing value
758 **/
759 #line 330 "data.gob"
760 void
ggobi_data_set_missing(GGobiData * self,guint i,guint j)761 ggobi_data_set_missing (GGobiData * self, guint i, guint j)
762 {
763 #line 764 "ggobi-data.c"
764 #define __GOB_FUNCTION__ "GGobi:Data::set_missing"
765 #line 330 "data.gob"
766 g_return_if_fail (self != NULL);
767 #line 330 "data.gob"
768 g_return_if_fail (GGOBI_IS_DATA (self));
769 #line 770 "ggobi-data.c"
770 {
771 #line 332 "data.gob"
772
773 self->missing.vals[i][j] = 1;
774 self->raw.vals[i][j] = 0;
775 self->missings = TRUE;
776 }}
777 #line 778 "ggobi-data.c"
778 #undef __GOB_FUNCTION__
779
780 #line 338 "data.gob"
781 gboolean
ggobi_data_is_missing(GGobiData * self,guint i,guint j)782 ggobi_data_is_missing (GGobiData * self, guint i, guint j)
783 {
784 #line 785 "ggobi-data.c"
785 #define __GOB_FUNCTION__ "GGobi:Data::is_missing"
786 #line 338 "data.gob"
787 g_return_val_if_fail (self != NULL, (gboolean )0);
788 #line 338 "data.gob"
789 g_return_val_if_fail (GGOBI_IS_DATA (self), (gboolean )0);
790 #line 791 "ggobi-data.c"
791 {
792 #line 340 "data.gob"
793
794 return self->missings && (self->missing.vals[i][j] == 1);
795 }}
796 #line 797 "ggobi-data.c"
797 #undef __GOB_FUNCTION__
798
799 #line 344 "data.gob"
800 gboolean
ggobi_data_has_missings(GGobiData * self)801 ggobi_data_has_missings (GGobiData * self)
802 {
803 #line 804 "ggobi-data.c"
804 #define __GOB_FUNCTION__ "GGobi:Data::has_missings"
805 #line 344 "data.gob"
806 g_return_val_if_fail (self != NULL, (gboolean )0);
807 #line 344 "data.gob"
808 g_return_val_if_fail (GGOBI_IS_DATA (self), (gboolean )0);
809 #line 810 "ggobi-data.c"
810 {
811 #line 346 "data.gob"
812
813 return self->missings;
814 }}
815 #line 816 "ggobi-data.c"
816 #undef __GOB_FUNCTION__
817
818 #line 351 "data.gob"
819 guint
ggobi_data_get_col_n_missing(GGobiData * self,guint j)820 ggobi_data_get_col_n_missing (GGobiData * self, guint j)
821 {
822 #line 823 "ggobi-data.c"
823 #define __GOB_FUNCTION__ "GGobi:Data::get_col_n_missing"
824 #line 351 "data.gob"
825 g_return_val_if_fail (self != NULL, (guint )0);
826 #line 351 "data.gob"
827 g_return_val_if_fail (GGOBI_IS_DATA (self), (guint )0);
828 #line 829 "ggobi-data.c"
829 {
830 #line 352 "data.gob"
831
832 guint i, n = 0;
833
834 for(i = 0; i < self->nrows; i++) {
835 if (self_is_missing(self, i, j)) n++;
836 }
837
838 return(n);
839 }}
840 #line 841 "ggobi-data.c"
841 #undef __GOB_FUNCTION__
842
843 #line 362 "data.gob"
844 void
ggobi_data_set_raw_values(GGobiData * self,guint j,gdouble * values)845 ggobi_data_set_raw_values (GGobiData * self, guint j, gdouble * values)
846 {
847 #line 848 "ggobi-data.c"
848 #define __GOB_FUNCTION__ "GGobi:Data::set_raw_values"
849 #line 362 "data.gob"
850 g_return_if_fail (self != NULL);
851 #line 362 "data.gob"
852 g_return_if_fail (GGOBI_IS_DATA (self));
853 #line 854 "ggobi-data.c"
854 {
855 #line 364 "data.gob"
856
857 gint i;
858 for (i = 0; i < self->nrows; i++) {
859 self_set_raw_value(self, i, j, values[i]);
860 }
861 }}
862 #line 863 "ggobi-data.c"
863 #undef __GOB_FUNCTION__
864
865 #line 371 "data.gob"
866 void
ggobi_data_set_raw_value(GGobiData * self,guint i,guint j,gdouble value)867 ggobi_data_set_raw_value (GGobiData * self, guint i, guint j, gdouble value)
868 {
869 #line 870 "ggobi-data.c"
870 #define __GOB_FUNCTION__ "GGobi:Data::set_raw_value"
871 #line 371 "data.gob"
872 g_return_if_fail (self != NULL);
873 #line 371 "data.gob"
874 g_return_if_fail (GGOBI_IS_DATA (self));
875 #line 876 "ggobi-data.c"
876 {
877 #line 373 "data.gob"
878
879 if(GGobiMissingValue && GGobiMissingValue(value))
880 self_set_missing(self, i, j);
881 else self->raw.vals[i][j] = value;
882 }}
883 #line 884 "ggobi-data.c"
884 #undef __GOB_FUNCTION__
885
886 #line 419 "data.gob"
887 gchar *
ggobi_data_get_string_value(GGobiData * self,guint i,guint j,gboolean transformed)888 ggobi_data_get_string_value (GGobiData * self, guint i, guint j, gboolean transformed)
889 {
890 #line 891 "ggobi-data.c"
891 #define __GOB_FUNCTION__ "GGobi:Data::get_string_value"
892 #line 419 "data.gob"
893 g_return_val_if_fail (self != NULL, (gchar * )0);
894 #line 419 "data.gob"
895 g_return_val_if_fail (GGOBI_IS_DATA (self), (gchar * )0);
896 #line 897 "ggobi-data.c"
897 {
898 #line 421 "data.gob"
899
900 gint n = 0, lval = -1;
901 vartabled *vt = vartable_element_get(j, self);
902 gdouble raw = transformed ? self->tform.vals[i][j] : self->raw.vals[i][j];
903
904 if (self_is_missing(self, i, j))
905 return g_strdup("NA");
906 if (vt->vartype != categorical)
907 return g_strdup_printf("%g", raw);
908
909 for (n = 0; n < vt->nlevels; n++) {
910 if (vt->level_values[n] == raw) {
911 lval = n;
912 break;
913 }
914 }
915 if (lval == -1) {
916 g_printerr ("The levels for %s aren't specified correctly\n", vt->collab);
917 return(NULL);
918 }
919
920 return vt->level_names[lval];
921 }}
922 #line 923 "ggobi-data.c"
923 #undef __GOB_FUNCTION__
924
925 #line 445 "data.gob"
926 gboolean
ggobi_data_has_edges(GGobiData * self)927 ggobi_data_has_edges (GGobiData * self)
928 {
929 #line 930 "ggobi-data.c"
930 #define __GOB_FUNCTION__ "GGobi:Data::has_edges"
931 #line 445 "data.gob"
932 g_return_val_if_fail (self != NULL, (gboolean )0);
933 #line 445 "data.gob"
934 g_return_val_if_fail (GGOBI_IS_DATA (self), (gboolean )0);
935 #line 936 "ggobi-data.c"
936 {
937 #line 447 "data.gob"
938
939 return (self->edge.n > 0);
940 }}
941 #line 942 "ggobi-data.c"
942 #undef __GOB_FUNCTION__
943
944 #line 451 "data.gob"
945 gboolean
ggobi_data_has_variables(GGobiData * self)946 ggobi_data_has_variables (GGobiData * self)
947 {
948 #line 949 "ggobi-data.c"
949 #define __GOB_FUNCTION__ "GGobi:Data::has_variables"
950 #line 451 "data.gob"
951 g_return_val_if_fail (self != NULL, (gboolean )0);
952 #line 451 "data.gob"
953 g_return_val_if_fail (GGOBI_IS_DATA (self), (gboolean )0);
954 #line 955 "ggobi-data.c"
955 {
956 #line 453 "data.gob"
957
958 return (self->ncols > 0);
959 }}
960 #line 961 "ggobi-data.c"
961 #undef __GOB_FUNCTION__
962
963 #line 475 "data.gob"
964
965 void
datad_free(GGobiData * d,ggobid * gg)966 datad_free (GGobiData *d, ggobid *gg)
967 {
968 arrayf_free (&d->raw, 0, 0);
969 pipeline_arrays_free (d, gg);
970
971 arrays_free (&d->missing, 0, 0);
972
973 /* rowIds and idTable are intrinsically linked !*/
974 if(d->idTable) {
975 g_hash_table_foreach(d->idTable, freeLevelHashEntry, d->idTable);
976 g_hash_table_destroy(d->idTable);
977 }
978
979 if(d->rowIds)
980 g_free(d->rowIds);
981
982 g_free (d);
983 }
984
985 displayd *
datad_init(GGobiData * d,ggobid * gg,gboolean cleanup)986 datad_init (GGobiData *d, ggobid *gg, gboolean cleanup)
987 {
988 /* GGobi assumes datasets have at least one row */
989 g_return_val_if_fail(d->nrows > 0, NULL);
990 d->gg = gg;
991 gg->d = g_slist_append (gg->d, d);
992 displayd *display = NULL;
993
994 if (cleanup) {
995 varpanel_clear (d, gg);
996 }
997
998 varpanel_populate (d, gg); /*-- toggles */
999 /*-- circles: build but don't show --*/
1000 varcircles_populate (d, gg);
1001
1002 pipeline_init (d, gg);
1003 clusters_set (d, gg); /*-- find the clusters for data just read in --*/
1004
1005 if (cleanup || g_list_length(gg->displays) == 0) {
1006 display_free_all (gg); /*-- destroy any existing displays --*/
1007 gg->pmode = NULL_PMODE;
1008
1009 /*-- initialize the first display --*/
1010 if(sessionOptions->info->createInitialScatterPlot && d->ncols > 0) {
1011 /*XXX allow this to be specified as a gtk type name on the command
1012 line, initialization file, etc. and invoke the corresponding
1013 create() method. */
1014 display = scatterplot_new (true, false, NULL, d, gg);
1015 /* Need to make certain this is the only one there. */
1016
1017 if (display != NULL) {
1018 gg->displays = g_list_append (gg->displays, (gpointer) display);
1019 gg->current_splot = (splotd *)
1020 g_list_nth_data (display->splots, 0);
1021 display->current_splot = gg->current_splot;
1022 display_set_current (display, gg);
1023
1024 /*-- turn on event handling in the very first plot --*/
1025 /*-- ... but will it cause trouble for later plots? ok so far
1026 --*/
1027 /* Is imode set yet? I hope so. */
1028 sp_event_handlers_toggle (gg->current_splot, on, gg->pmode, gg->imode);
1029 }
1030 }
1031 }
1032
1033 if (gg->current_display != NULL)
1034 varpanel_refresh (gg->current_display, gg);
1035
1036 if (g_slist_index(gg->d, (gpointer)d) == 0)
1037 varpanel_set_sensitive (d, true, gg);
1038
1039 g_signal_emit (G_OBJECT (gg), GGobiSignals[DATAD_ADDED_SIGNAL], 0, d);
1040
1041 display_menu_build (gg);
1042
1043 return (display);
1044 }
1045
1046
1047
1048
1049 /*------------------------------------------------------------------------*/
1050 /* row labels */
1051 /*------------------------------------------------------------------------*/
1052 /* This initializes rowIds to row numbers if ids are not provided */
1053 void
datad_record_ids_set(GGobiData * d,gchar ** ids,gboolean duplicate)1054 datad_record_ids_set(GGobiData *d, gchar **ids, gboolean duplicate)
1055 {
1056 gint i;
1057 guint *index;
1058 gchar *tmp;
1059
1060 d->idTable = g_hash_table_new(g_str_hash, g_str_equal);
1061 d->rowIds = (gchar **) g_malloc(sizeof(gchar *) * d->nrows);
1062 for(i = 0; i < d->nrows; i++) {
1063 if(ids)
1064 tmp = duplicate ? g_strdup(ids[i]) : ids[i];
1065 else {
1066 char buf[10];
1067 sprintf(buf, "%d", i+1);
1068 tmp = g_strdup(buf);
1069 }
1070 index = (guint *) g_malloc(sizeof(guint));
1071 *index = i;
1072 g_hash_table_insert(d->idTable, tmp, index);
1073 d->rowIds[i] = tmp;
1074 /* do not free anything here */
1075 }
1076 }
1077
1078 /* Add a record id */
1079 void
datad_record_id_add(gchar * id,GGobiData * d)1080 datad_record_id_add (gchar *id, GGobiData *d)
1081 {
1082 gint i;
1083 guint *index;
1084
1085 d->rowIds = (gchar **) g_realloc (d->rowIds, sizeof(gchar *) * d->nrows);
1086 i = d->nrows - 1;
1087
1088 index = (guint *) g_malloc(sizeof(guint));
1089 *index = i;
1090 g_hash_table_insert (d->idTable, id, index);
1091 d->rowIds[i] = id;
1092
1093 /*
1094 * I don't really understand why I can't free this
1095 * when it's freed in datad_record_ids_set, but purify is
1096 * quite clear on this point. -- dfs
1097 */
1098 /*g_free (index);*/
1099 }
1100
1101 /* FIXME: this only works the first time */
1102 void
ggobi_data_set_row_labels(GGobiData * d,gchar ** labels)1103 ggobi_data_set_row_labels(GGobiData *d, gchar **labels)
1104 {
1105 gint i;
1106 for (i = 0; i < d->nrows; i++) {
1107 gchar *label;
1108 if (labels && labels[i])
1109 label = g_strdup(labels[i]);
1110 else label = g_strdup_printf("%d", i);
1111 g_array_append_val(d->rowlab, label);
1112 }
1113 }
1114
1115 void
rowlabels_free(GGobiData * d)1116 rowlabels_free (GGobiData *d)
1117 {
1118 g_array_free (d->rowlab, true);
1119 }
1120
1121
1122 void
rowlabels_alloc(GGobiData * d)1123 rowlabels_alloc (GGobiData *d)
1124 {
1125 if (d->rowlab != NULL) rowlabels_free (d);
1126 d->rowlab = g_array_sized_new (false, false, sizeof (gchar *), d->nrows);
1127 }
1128
1129 void
rowlabel_add(gchar * label,GGobiData * d)1130 rowlabel_add (gchar *label, GGobiData *d)
1131 {
1132 g_array_append_val (d->rowlab, label);
1133
1134 g_assert (d->rowlab->len == d->nrows);
1135 }
1136
1137
1138
1139 #line 1140 "ggobi-data.c"
1140