1 /*-- ggobi.h --*/ 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 GGOBI_H 18 #define GGOBI_H 19 20 #ifdef WIN32 21 #define GGOBI_EXPORT __declspec(dllexport) 22 #else 23 #define GGOBI_EXPORT 24 #endif 25 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 struct _ggobid; 32 33 #include <libxml/parser.h> 34 #include "defines.h" 35 #include "types.h" 36 #include "brushing.h" 37 #include "display.h" 38 #include "display_tree.h" 39 #include "read_init.h" 40 41 #include "fileio.h" 42 43 #include "colorscheme.h" 44 45 /* 46 These are hooks for other applications (e.g. R) to 47 facilitate callbacks at a higher level that GTK events/signals. 48 This one is used for responding to identifying points. 49 */ 50 typedef void (*IdentifyProc) (void *user_data, gint id, splotd * sp, 51 GtkWidget * w, ggobid * gg); 52 53 typedef struct { 54 IdentifyProc handler; 55 void *user_data; 56 } IdentifyHandler; 57 58 59 /* 60 This is a typedef that is used for registering a routine for handling 61 presses of the numbered keys 0, 1, ..., 9. 62 It gets the events from the regular event handler and also the key identifier. 63 See scatterplot_event_handled() in splot.c. 64 The idea is that people can register routines in a programming 65 language interface to ggobi such as Rggobi, or the Perl or Python 66 interfaces, and provide customized callbacks/handlers for the 67 numbered keys. 68 Note that if you register a handler for any of these keys, you have to handle 69 them all (i.e. 0, ..., 9). You can discard the ones you are not interested in. 70 In the future, we may set it up so that one can refuse to handle an event 71 and return false and have the scatterplot_event_handled() then process it 72 in the default way. Also, one can register an intermediate handler which 73 looks up a table for key-specific handlers for each the 0, .., 9 keys. 74 Then one could register that function with the general ggobi mechanism 75 and provide an interface 76 */ 77 typedef gboolean(*KeyEventHandlerFunc) (guint keyval, GtkWidget * w, 78 GdkEventKey * event, 79 cpaneld * cpanel, splotd * sp, 80 ggobid * gg, void *userData); 81 82 typedef void (*ReleaseData) (void *userData); 83 /* This is the variable that stores the registered handler */ 84 typedef struct { 85 KeyEventHandlerFunc handlerRoutine; 86 void *userData; 87 char *description; 88 ReleaseData *releaseData; 89 ProgrammingLanguage language; 90 } KeyEventHandler; 91 92 93 typedef struct { 94 /*-- ggobi --*/ 95 96 struct _ggobid *thisGG; 97 98 GtkAccelGroup *sp_accel_group; /*-- sp = scatterplot here --*/ 99 100 } GGobiMenus; 101 102 typedef struct _PrintOptions PrintOptions; 103 104 105 106 GType ggobi_ggobi_get_type(void); 107 108 #define GGOBI_TYPE_GGOBI ggobi_ggobi_get_type() 109 #define GGOBI_GGOBI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GGOBI_TYPE_GGOBI, ggobid)) 110 #define GGOBI_GGOBI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GGOBI_TYPE_GGOBI, GGobiGGobiClass)) 111 #define GGOBI_IS_GGOBI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GGOBI_TYPE_GGOBI)) 112 #define GGOBI_IS_GGOBI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GGOBI_TYPE_GGOBI)) 113 #define GGOBI_GGOBI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GGOBI_TYPE_GGOBI, GGobiGGobiClass)) 114 115 typedef struct _GGobiGGobiClass { 116 GObjectClass parent_class; 117 } GGobiGGobiClass; 118 119 120 /** 121 @defgroup ggobid the ggobid instance structure. 122 @brief This is the top-level structure representing a 123 ggobi instance. 124 */ 125 struct _ggobid { 126 127 GObject object; 128 129 /** 130 A tree 131 */ 132 DisplayTree display_tree; 133 GList *displays; 134 displayd *current_display; 135 splotd *current_splot; 136 gint buttondown;/*-- can be 0, 1, 2, or 3; could be useful in drawing --*/ 137 138 GGobiMenus app; 139 140 GSList *d; /* Datasets (datad elements) */ 141 /*-- first is default: cases, nodes; second might be edges --*/ 142 143 /* main_ui */ 144 GtkWidget *current_control_panel; 145 146 GList *control_panels; 147 148 GtkWidget *main_window, *main_menubar; 149 GtkUIManager *main_menu_manager; 150 GtkWidget *display_menu; /*-- menu labelled 'Window' --*/ 151 GtkAccelGroup *main_accel_group, *pmode_accel_group, *imode_accel_group; 152 GtkWidget *pmode_item, *imode_item; 153 GtkWidget *imode_frame; /* this should be cpanel_frame, actually */ 154 GtkTooltips *tips; 155 gboolean firsttime; 156 guint mode_merge_id; 157 158 /* status bar in main console window */ 159 void (*status_message_func) (gchar *, ggobid *); 160 gboolean statusbar_p; 161 162 gboolean close_pending; 163 #ifdef EXPLICIT_IDENTIFY_HANDLER 164 IdentifyHandler identify_handler; 165 #endif 166 167 /*--------------------------------------------------------------------*/ 168 /* reading in the data */ 169 /*--------------------------------------------------------------------*/ 170 171 InputDescription *input; /* Information about input files for the default 172 data source, such as the name of the 173 file, directory, data mode, extension, etc. 174 */ 175 176 /*----------------------- pipeline ---------------------------------*/ 177 178 ProjectionMode pmode, pmode_prev; 179 InteractionMode imode, imode_prev; 180 181 struct _VarTableUI { 182 GtkWidget *window; 183 GtkWidget *notebook; 184 } vartable_ui; 185 gboolean lims_use_visible; 186 187 188 /*--------------- clusters: hiding, excluding ----------------------*/ 189 190 struct _ClusterUI { 191 GtkWidget *window; 192 GtkWidget *notebook; 193 } cluster_ui; 194 195 /*---------------- brushing by categorical variable ----------------*/ 196 197 gboolean linkby_cv; 198 199 /*--------------------------------------------------------------------*/ 200 /* color */ 201 /*--------------------------------------------------------------------*/ 202 GdkGC *rectangle_GC; 203 GdkColor mediumgray, lightgray, darkgray; /* for 3d rectangles */ 204 GdkColor vcirc_freeze_color, vcirc_manip_color; /* for variable circles */ 205 gshort color_id, color_0; /* 0:ncolors-1 */ 206 gboolean mono_p; 207 208 struct _Color_UI { 209 GtkWidget *symbol_window; 210 GtkWidget *symbol_display, *line_display; 211 212 GtkWidget *colorseldlg; 213 GtkWidget *bg_da, *accent_da, *hidden_da, *fg_da[MAXNCOLORS], *current_da; 214 215 gint spacing; 216 gint margin; /* between glyphs in the symbol_display */ 217 } color_ui; 218 219 /*---------------------- graphics contexts -----------------------------*/ 220 221 GdkGC *plot_GC; 222 GdkGC *selvarfg_GC, *selvarbg_GC; /* white background, thick lines */ 223 GdkGC *unselvarfg_GC, *unselvarbg_GC; /* grey background, thin lines */ 224 GdkGC *manipvarfg_GC; /* white background, thin purple line */ 225 226 /*--------------------------- jittering --------------------------------*/ 227 228 struct _JitterUI { 229 GtkWidget *window; 230 } jitter_ui; 231 232 /*------------------------- writing out data ---------------------------*/ 233 234 struct _Save { 235 GtkWidget *tree_view; 236 gint format, stage, row_ind, column_ind, missing_ind; 237 gboolean jitter_p, edges_p; 238 } save; 239 240 /*---------------------- 1d plotting -----------------------------------*/ 241 242 struct _P1D { 243 /*-- cycling --*/ 244 gint cycle_id; 245 GtkAdjustment *cycle_delay_adj; 246 /*-- texture --*/ 247 gfloat *gy; 248 } p1d; 249 250 /*-------------------- 2d plotting -----------------------------------*/ 251 252 struct _XYPlot { 253 /*-- cycling --*/ 254 gint cycle_id; 255 GtkAdjustment *cycle_delay_adj; 256 } xyplot; 257 258 /*---------------------- touring -------------------------------------*/ 259 260 #ifndef NEW_TOUR_CLASSES 261 struct _Tour2d3 { 262 gint idled; 263 } tour2d3; 264 265 struct _Tour2d { 266 gint idled; 267 gboolean fade_vars; 268 gboolean all_vars; 269 } tour2d; 270 271 struct _Tour1d { 272 gint idled; 273 gboolean fade_vars; 274 gboolean all_vars; 275 } tour1d; 276 277 struct _TourCorr { 278 gint idled; 279 gboolean fade_vars; 280 } tourcorr; 281 #else 282 283 #endif 284 /*-------------------- parallel coordinates --------------------------*/ 285 286 struct _Parcoords { 287 GtkAccelGroup *accel_group; 288 GtkWidget *arrangement_box; 289 } parcoords; 290 291 /*---------------------time series------------------------------------*/ 292 293 /*XX */ 294 struct _TSPLOT { 295 GtkAccelGroup *accel_group; 296 GtkWidget *arrangement_box; 297 } tsplot; 298 299 300 301 /*------------------------ brushing ----------------------------------*/ 302 303 glyphd glyph_id, glyph_0; 304 305 struct _Brush_UI { 306 gboolean firsttime; 307 } brush; 308 309 struct _Plot { 310 /* 311 * Part of binning: the corners of the bin to be copied from 312 * pixmap0 to pixmap1. 313 * They're defined in splot_draw_to_pixmap0_binned and used in 314 * splot_pixmap0_to_pixmap1 when binned == true. 315 */ 316 icoords bin0, bin1; 317 icoords loc0, loc1; 318 } plot; 319 320 /*---------------------- identification ------------------------------*/ 321 322 /*---------------------- edge editing --------------------------------*/ 323 324 struct _EdgeEdit { 325 gint a; 326 } edgeedit; 327 328 /*--------------------- submenu management ---------------------------*/ 329 330 struct _Main_MiscMenu { 331 GtkWidget *options_item, *options_menu; 332 } menus; 333 334 /*-------------------- transformation --------------------------------*/ 335 336 struct _Transformation { 337 GtkWidget *window; 338 GtkAdjustment *boxcox_adj; 339 } tform_ui; 340 341 struct _Sphere { 342 GtkWidget *window; 343 GtkWidget *scree_da; 344 GdkPixmap *scree_pixmap; 345 346 GtkObject *npcs_adj; 347 GtkWidget *stdized_entry, *variance_entry, *condnum_entry; 348 GtkWidget *apply_btn, *restore_btn; 349 GtkWidget *tree_view; 350 351 /*-- a pointer to be compared with current_display->d --*/ 352 GGobiData *d; 353 } sphere_ui; 354 355 /*-------------------- subsetting ------------------------------------*/ 356 357 struct _SubsetUI { 358 GtkWidget *window; 359 GtkWidget *notebook; 360 } subset_ui; 361 362 /*---------------- color scheme selection -------------------------------*/ 363 364 struct _SchemeChooser { 365 GtkWidget *window, *entry_preview, *entry_applied, *da; 366 GdkPixmap *pix; 367 colorschemed *scheme; /*-- current color scheme --*/ 368 GdkGC *GC; 369 gfloat *pct; 370 gint npct; 371 } svis; 372 373 /*---------------- brushing by weights -------------------------------*/ 374 375 struct _WeightedVis { 376 GtkWidget *window, *da; 377 GdkPixmap *pix; 378 GdkGC *GC; 379 380 gfloat *pct; 381 gint npct; 382 gint *n; /*-- number of points that will take on each color --*/ 383 gint nearest_color; 384 385 gint motion_notify_id; 386 icoords mousepos; 387 gint binning_method; 388 gint update_method; 389 } wvis; 390 391 /*-------------------- scaling ---------------------------------------*/ 392 393 // Delete 394 struct _Scale { 395 rectd click_rect; 396 } scale; 397 398 /*-------------------- imputation ------------------------------------*/ 399 400 struct _Impute { 401 gboolean bgroup_p; 402 gint whichvars; 403 GtkWidget *window; 404 ImputeType type; 405 /* 406 GtkWidget *notebook; 407 GtkWidget *entry_above, *entry_below, *entry_val; 408 */ 409 } impute; 410 411 /*-------------------- moving points ---------------------------------*/ 412 413 struct _MovePts { 414 gboolean cluster_p; 415 enum directiond direction; 416 gcoords eps; 417 } movepts; 418 419 420 /*----------------- variable selection panel -------------------------*/ 421 422 struct _Varpanel_ui { 423 GtkWidget *notebook; 424 gboolean layoutByRow; 425 } varpanel_ui; 426 427 KeyEventHandler *NumberedKeyEventHandler; 428 429 PrintOptions *printOptions; 430 GList *pluginInstances; 431 432 GList *colorSchemes; 433 colorschemed *activeColorScheme; 434 435 GSList *pmodeRadioGroup; 436 GSList *imodeRadioGroup; 437 438 void *userData;/** A place to hang data for a host application, plugin, etc. 439 Since plugins, etc. may also use this, we might want 440 a hashtable here similar to pthread's thread-specific data. */ 441 442 }; /* ggobid; */ 443 444 #include "read_init.h" 445 446 typedef enum { GGOBI_SILENT, GGOBI_CHATTY, GGOBI_VERBOSE } GGobiOutputLevel; 447 448 /** 449 @defgroup SessionOptions Session Options 450 @brief This is used to store store values from the 451 command line arguments which can be used in subsequent 452 code. 453 */ 454 typedef struct { 455 456 /** 457 @ingroup SessionOptions 458 Controls whether messages explaining what is being done internally 459 are displayed. 460 */ 461 GGobiOutputLevel verbose; 462 463 /** 464 @ingroup SessionOptions 465 The default format for the data being read. 466 */ 467 DataMode data_mode; 468 469 gchar *data_type; 470 471 /** 472 @ingroup SessionOptions 473 The name of the data file containing the data. 474 */ 475 gchar *data_in; 476 /** 477 @ingroup SessionOptions 478 The command line arguments used to start ggobi. 479 */ 480 gchar **cmdArgs; 481 /** 482 @ingroup SessionOptions 483 The number of command line arguments used to start ggobi. 484 */ 485 gint numArgs; 486 487 488 /** 489 @ingroup SessionOptions 490 A logical value controlling whether the control window 491 of a ggobi instance is displayed. This can be used to hide 492 the control window when ggobi is embedded in other applications. 493 */ 494 gboolean showControlPanel; 495 496 /** 497 @ingroup SessionOptions 498 Data for the initialization settings. 499 */ 500 struct _GGobiInitInfo *info; 501 /** 502 @ingroup SessionOptions 503 The name of the initialization file from which to read any 504 session parameters not specified on the command line. 505 */ 506 gchar *initializationFile; 507 508 /** 509 @ingroup SessionOptions 510 The collection of color schemes read 511 available to ggobi, typically specified in the 512 initialization file. 513 514 */ 515 GList *colorSchemes; 516 /** 517 @ingroup SessionOptions 518 The name of the active color scheme, indexing the 519 list of colorSchemes. 520 */ 521 gchar *activeColorScheme; 522 523 gchar *restoreFile; 524 525 GSList *pluginFiles; 526 527 /** Directory in which the GGobi files are located. 528 */ 529 gchar *ggobiHome; 530 531 gfloat defaultTourSpeed; 532 gfloat defaultTour1dSpeed; 533 534 gboolean useRadioMenuItems; 535 536 } GGobiOptions; 537 538 539 /** 540 Information about move and identify events in ggobi reported 541 to listeners. 542 */ 543 typedef struct { 544 GGobiData *d; 545 int id; 546 } GGobiPointMoveEvent; 547 548 549 550 GSList* read_input(InputDescription * desc, ggobid * gg); 551 void start_ggobi(ggobid * gg, gboolean init_data, gboolean createPlot); 552 void process_initialization_files(); 553 554 extern GGobiOptions *sessionOptions; 555 556 /** 557 Identifiers for the different signal types generated by ggobi 558 */ 559 typedef enum { DATAD_ADDED_SIGNAL, 560 VARIABLE_ADDED_SIGNAL, /*-- not using this one presently --*/ 561 VARIABLE_LIST_CHANGED_SIGNAL, /*-- this works for variable lists --*/ 562 SPLOT_NEW_SIGNAL, 563 BRUSH_MOTION_SIGNAL, POINT_MOVE_SIGNAL, IDENTIFY_POINT_SIGNAL, 564 VARIABLE_SELECTION_SIGNAL, 565 STICKY_POINT_ADDED_SIGNAL, STICKY_POINT_REMOVED_SIGNAL, 566 CLUSTERS_CHANGED_SIGNAL, /*-- ggvis wants this --*/ 567 DISPLAY_NEW_SIGNAL, 568 DISPLAY_SELECTED_SIGNAL, 569 MAX_GGOBI_SIGNALS 570 } GGobiSignalType; 571 572 /** 573 Registered signal identifiers for the ggobi signals. 574 Indexed by the enum above. 575 */ 576 extern guint GGobiSignals[MAX_GGOBI_SIGNALS]; 577 578 579 /** 580 Should be in edges.h, if there were one. 581 */ 582 GGobiData *setDisplayEdge(displayd * dpy, GGobiData * e); 583 584 585 gchar *getOptValue(const char *const name, const char *const value); 586 const char *getCommandLineArgValue(const char *name); 587 void showHelp(); 588 589 #ifdef __cplusplus 590 extern "C" { 591 #endif 592 void globals_init(ggobid * gg); 593 594 guint getGGobiSignal(GGobiSignalType); 595 596 GSList *GGOBI(getExtendedDisplayTypes)(); 597 #ifdef __cplusplus 598 } 599 #endif 600 601 void gtk_marshal_NONE__INT_POINTER_POINTER_POINTER(GtkObject * object, 602 GtkSignalFunc func, 603 gpointer func_data, 604 GtkArg * args); 605 606 607 extern GSList *ExtendedDisplayTypes; 608 typedef GType(*GTypeLoad) (void); 609 610 gchar* ggobi_find_data_file(const gchar *name); 611 gchar* ggobi_find_config_file(const gchar *name); 612 613 GList *getInputPluginSelections(ggobid *gg); 614 615 extern const gchar *DefaultUnknownInputModeName; 616 617 618 InputDescription * 619 fileset_generate(const gchar * fileName, 620 const gchar *modeName, 621 GGobiPluginInfo *plugin, 622 ggobid * gg); 623 624 625 #include "GGobiEvents.h" 626 627 #include "GGobiApp.h" 628 GGobiApp *getGGobiApp(); 629 630 #ifdef __cplusplus 631 } /* end of extern "C" */ 632 #endif 633 634 #endif 635