1 /* 2 * wavewin.h - part of the gwave waveform viewer 3 * Declarations related to main waveform window. 4 * 5 * Copyright (C) 1998, 1999 Stephen G. Tell 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public 18 * License along with this software; if not, write to the Free 19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * 21 */ 22 23 #ifndef WAVEWIN_H 24 #define WAVEWIN_H 25 26 #ifndef SCWM_GUILE_H__ 27 #include <scwm_guile.h> 28 #endif 29 30 #undef EXTERN 31 #undef EXTERN_SET 32 #ifdef WAVEWIN_IMPLEMENTATION 33 #define EXTERN 34 #define EXTERN_SET(x,y) x = y 35 #else 36 #define EXTERN extern 37 #define EXTERN_SET(x,y) extern x 38 #endif 39 40 /* 41 * WavePanel -- describes a single panel containing zero or more waveforms. 42 */ 43 struct _WavePanel { 44 SCM smob; 45 int outstanding_smob; /* if guile has a pointer, defer freeing. */ 46 int valid; /* 1 if valid, 0 if awaiting deletion */ 47 int selected; 48 49 GList *vwlist; /* list of VisibleWaves shown in this panel. 50 Like any GList, NULL if list empty */ 51 double min_yval; /* min/max data x/y values over whole vwlist */ 52 double max_yval; 53 double min_xval; 54 double max_xval; 55 56 /* starting and ending drawn x-value (independent var), 57 * copied from corresponding wtable values when we scroll/zoom, 58 * later we may allow individual panels to be "locked" 59 * from global scroll/zoom or otherwise controlled independently */ 60 double start_xval; 61 double end_xval; 62 /* ditto for the y-value dimension; start_yval is the bottom. 63 * invariant: if man_yzoom is false these are 64 * the same as min_yval and max_yval. 65 */ 66 double start_yval; 67 double end_yval; 68 int man_yzoom; 69 70 GtkWidget *lmvbox; 71 GtkWidget *lmtable; /* label and measurement table */ 72 GtkWidget *lab_min, *lab_max; 73 GtkWidget *lab_min_hbox, *lab_max_hbox; 74 GtkWidget *lab_logscale; 75 GtkWidget *drawing; /* DrawingArea for waveforms */ 76 GdkPixmap *pixmap; 77 int req_height; /* requested height */ 78 int width, height; /* actual size */ 79 int nextcolor; /* color to use for next added waveform */ 80 int logy; /* Y axis scaling: 0=linear 1=log base 10 */ 81 }; 82 83 84 /* Stuff to wrap WavePanel as a SMOB */ 85 86 EXTERN long scm_tc16_scwm_WavePanel; 87 88 #define WavePanel_P(X) (SCM_NIMP(X) && SCM_SMOB_PREDICATE(scm_tc16_scwm_WavePanel, X)) 89 #define WavePanel(X) ((WavePanel *)SCM_SMOB_DATA(X)) 90 #define SAFE_WavePanel(X) (WavePanel_P((X))? WavePanel((X)) : NULL) 91 92 #define VALIDATE_ARG_WavePanel(pos,scm) \ 93 do { \ 94 if (!WavePanel_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ 95 } while (0) 96 97 #define VALIDATE_ARG_WavePanel_COPY(pos,scm,cvar) \ 98 do { \ 99 if (!WavePanel_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ 100 else cvar = WavePanel(scm); \ 101 } while (0) 102 103 #define VALIDATE_ARG_WavePanel_COPY_USE_NULL(pos,scm,cvar) \ 104 do { \ 105 if (UNSET_SCM(scm) || scm == SCM_BOOL_F) cvar = NULL; \ 106 else if (!WavePanel_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ 107 else cvar = WavePanel(scm); \ 108 } while (0) 109 110 111 /*********************************************************************** 112 * VisibleWave -- a waveform shown in a panel. 113 */ 114 115 struct _VisibleWave { 116 SCM smob; 117 int outstanding_smob; /* if guile has a pointer, defer freeing. */ 118 int valid; /* 1 if valid, 0 if awaiting deletion */ 119 WaveVar *var; 120 GWDataFile *gdf; 121 WavePanel *wp; 122 char *varname; /* the variable name from the file */ 123 int colorn; 124 GdkGC *gc; 125 GtkWidget *button; 126 GtkWidget *label; 127 MeasureBtn *mbtn[2]; 128 }; 129 130 /* VisibleWave as a SMOB */ 131 EXTERN long scm_tc16_scwm_VisibleWave; 132 133 #define VisibleWave_P(X) (SCM_NIMP(X) && SCM_SMOB_PREDICATE(scm_tc16_scwm_VisibleWave, X)) 134 #define VisibleWave(X) ((VisibleWave *)SCM_SMOB_DATA(X)) 135 #define SAFE_VisibleWave(X) (VisibleWave_P((X))? VisibleWave((X)) : NULL) 136 137 #define VALIDATE_ARG_VisibleWave(pos,scm) \ 138 do { \ 139 if (!VisibleWave_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ 140 } while (0) 141 142 #define VALIDATE_ARG_VisibleWave_COPY(pos,scm,cvar) \ 143 do { \ 144 if (!VisibleWave_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ 145 else cvar = VisibleWave(scm); \ 146 } while (0) 147 148 #define VALIDATE_ARG_VisibleWave_COPY_USE_NULL(pos,scm,cvar) \ 149 do { \ 150 if (UNSET_SCM(scm) || scm == SCM_BOOL_F) cvar = NULL; \ 151 else if (!VisibleWave_P(scm)) scm_wrong_type_arg(FUNC_NAME,pos,scm); \ 152 else cvar = VisibleWave(scm); \ 153 } while (0) 154 155 // this one always gets the WaveVarH* 156 #define VALIDATE_ARG_VisibleWaveOrWaveVar_COPY(pos,scm,cvar) \ 157 do { \ 158 if (VisibleWave_P(scm)) cvar = VisibleWave(scm)->var; \ 159 else if(WaveVarH_P(scm)) cvar = SAFE_WaveVar(scm); \ 160 else scm_wrong_type_arg(FUNC_NAME,pos,scm); \ 161 } while (0) 162 163 /*********************************************************************** 164 * state related to selecting ranges/regions in X, Y, and XY 165 * pixel space of a wavepanel. 166 */ 167 typedef enum _SelRangeType SelRangeType; 168 enum _SelRangeType { SR_X=1, SR_Y=2, SR_XY=3 }; 169 170 struct _SelRange { 171 int drawn; 172 SelRangeType type; 173 WavePanel *wp; 174 GdkGC *gc; 175 GdkColor gdk_color; 176 int y1, y2; 177 int x1, x2; 178 int x1_root, y1_root; 179 SCM done_proc; 180 }; 181 182 /* defined in wavewin.c */ 183 extern WavePanel *new_wave_panel(); 184 extern void create_wdata_submenuitem(GWDataFile *wdata, GtkWidget *submenu); 185 extern void setup_waveform_window(); 186 extern void vw_get_label_string(char *buf, int buflen, VisibleWave *vw); 187 extern void vw_wp_create_button(VisibleWave *vw, WavePanel *wp); 188 extern void wavewin_insert_panel(WavePanel *wp, int minheight, int showlabels); 189 extern void wavewin_delete_panel(WavePanel *wp); 190 extern void cmd_popup_delete_panel(GtkWidget *w); 191 extern void cmd_popup_insert_panel(GtkWidget *w); 192 extern void cmd_append_panel(GtkWidget *w); 193 extern void wavepanel_draw_labels(WavePanel *wp); 194 extern WavePanel *first_selected_wavepanel(); 195 196 extern SCM wavepanel_mouse_binding[]; 197 extern void draw_wavepanel_labels(WavePanel *wp); 198 extern void setup_wavepanel_lmtable(WavePanel *wp, int showlabels); 199 extern void destroy_wave_panel(WavePanel *wp); 200 extern void setup_wave_panel(WavePanel *wp, int minheight, int showlabels); 201 202 #endif 203