1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 c-style: "K&R" -*- */
3 /*----------------------------------------------------------------------
5 gpiv - Graphic program for Particle Image Velocimetry, based on gtk/gnome
8 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
9 Gerber van der Graaf <gerber_graaf@users.sourceforge.net>
11 This file is part of gpiv.
13 Gpiv is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ----------------------------------------------------------------------*/
30 * Graphical User Interface for gpiv
31 * $Log: gpiv_gui.h,v $
32 * Revision 1.6 2008-10-09 14:43:37 gerber
33 * paralellized with OMP and MPI
35 * Revision 1.5 2008-09-25 13:32:22 gerber
36 * Adapted for use on cluster (using MPI/OMP) parallelised gpiv_rr from gpivtools)
38 * Revision 1.4 2008-09-16 10:13:56 gerber
39 * 2nd update because of cvs conflict
41 * Revision 1.3 2008-09-16 10:11:02 gerber
42 * Updated because of cvs conflict
44 * Revision 1.2 2005-06-15 15:06:22 gerber
45 * Optional Anti Aliased canvas for viewer
47 * Revision 1.1 2005/06/15 09:40:40 gerber
50 * Revision 1.9 2005/01/19 15:53:41 gerber
51 * Initiation of Data Acquisition (DAC); trigerring of lasers and camera
52 * by using RTAI and Realtime Linux, recording images from IEEE1394
53 * (Firewire) IIDC compliant camera's
55 * Revision 1.8 2004/10/15 19:24:05 gerber
56 * GPIV_ and Gpiv prefix to defines and structure names of libgpiv
58 * Revision 1.7 2004/06/14 21:19:23 gerber
59 * Image depth up to 16 bits.
60 * Improvement "single int" and "drag int" in Eval tab.
61 * Viewer's pop-up menu.
62 * Adaption for gpiv_matrix_* and gpiv_vector_*.
64 * See Changelog for further info.
66 * Revision 1.6 2003/09/04 13:31:55 gerber
67 * init of printing (unfinished)
69 * Revision 1.5 2003/09/01 11:17:14 gerber
70 * improved monitoring of interrogation process
72 * Revision 1.4 2003/08/22 15:24:52 gerber
73 * interactive spatial scaling
75 * Revision 1.3 2003/07/25 15:40:23 gerber
76 * removed/disabled setting of correlation in Eval tab, Correlation type in Image info tab
78 * Revision 1.2 2003/06/27 13:47:26 gerber
79 * display ruler, line/point evaluation
81 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
89 #include <sys/types.h>
91 #include <unistd.h> /* for the "pause" function: */
95 #include <math.h> /* for isnan */
100 #include <libgnomevfs/gnome-vfs.h>
101 #include <libgnomevfs/gnome-vfs-utils.h>
102 #ifdef HAVE_GNOME_PRINT
103 #include <libgnomeprint/gnome-print.h>
104 #include <libgnomeprint/gnome-print-job.h>
105 #include <libgnomeprint/gnome-font.h>
106 #include <libgnomeprintui/gnome-print-dialog.h>
107 #include <libgnomeprintui/gnome-print-job-preview.h>
108 #endif /* HAVE_GNOME_PRINT */
111 /* Revision Control System (RCS) version */
112 #define RCSID "$Id: gpiv_gui.h,v 1.6 2008-10-09 14:43:37 gerber Exp $"
113 #define ERR_IVAL = 99 /* Some arbitrary integer error value */
114 #define ADJ_MIN -50.0 /* minimum value for adjustment */
115 #define ADJ_MAX 50.0 /* maximum value for adjustment */
116 #define ADJ_STEP 0.001 /* Step increment for adjustment */
117 #define ADJ_PAGE 0.1 /* Page increment for adjustment */
118 #define ADJ_ISTEP 1 /* Step increment for adjustment for integers */
119 #define ADJ_IPAGE 10 /* Page increment for adjustment for integers*/
124 #define MPIRUN_CMD "mpirun -np"
129 * Sony PCR-100 video camera: 1152 x 864
131 #ifndef IMAGE_WIDTH_MAX
132 #define IMAGE_WIDTH_MAX GPIV_MAX_IMG_SIZE /* Maximum allowed image width */
133 #endif /* IMAGE_WIDTH_MAX */
135 #ifndef IMAGE_HEIGHT_MAX
136 #define IMAGE_HEIGHT_MAX GPIV_MAX_IMG_SIZE /* Maximum allowed image height */
137 #endif /* IMAGE_HEIGHT_MAX */
139 #ifndef IMAGE_DEPTH_MAX
140 #define IMAGE_DEPTH_MAX GPIV_MAX_IMG_DEPTH /* Maximum allowed image depth */
141 #endif /* IMAGE_DEPTH_MAX */
144 gchar IMAGE_CORRELATION_LABEL
[GPIV_MAX_CHARS
];
145 gchar IMAGE_WIDTH_LABEL
[GPIV_MAX_CHARS
];
146 gchar IMAGE_HEIGHT_LABEL
[GPIV_MAX_CHARS
];
147 gchar IMAGE_DEPTH_LABEL
[GPIV_MAX_CHARS
];
150 * Definitions for conssole
152 #define CONSOLE_WIDTH 100
153 #define CONSOLE_HEIGHT 400
155 * Extra marge for display
157 /* #define VIEW_HMARGE 38 */
158 /* #define VIEW_VMARGE 62 */
159 #define VIEW_HMARGE 19 /* horizontal marge in the display window */
160 #define VIEW_VMARGE 31 /* vertical marge in the display window */
161 /* #define VIEW_HMARGE 0 */
162 /* #define VIEW_VMARGE 0 */
163 #define RULER_WIDTH 17 /* width of the rulers in the display window */
165 #define MAX_DATA (IMAGE_WIDTH_MAX / GPIV_MIN_INTERR_SIZE) /* Maximum number of data/estimators/Interr. Areas per row */
166 #define MAX_BUFS GPIV_NIMG_MAX /* maximum number of buffers (=displays) */
168 /* #define MAX_SWEEP 6 */
170 #define CANVAS_AA /* Use Anti Aliased canvas for viewer */
171 /* BUGFIX: Color presenation for AA */
172 #define THICKNESS 1 /* line thickness to be drawn in te canvases */
173 #define ARROW_LENGTH 0.4 /* length of (piv) vector arrow head */
174 #define ARROW_EDGE 0.6 /* edge of (piv) vector arrow head */
175 #define ARROW_WIDTH 0.2 /* width of (piv) vector arrow head */
176 #define ARROW_ADD 2.0 /* additional quantity for arrow head */
177 #define ARROW_FACT 0.2 /* magnification factor of vector_scale for arrow head */
180 #define BITSHIFT_RED 24 /* bitshift for color red value (used in display_all_scalar_intregs) */
181 #define BITSHIFT_GREEN 16 /* bitshift for color green value */
182 #define BITSHIFT_BLUE 8 /* bitshift for color blue value */
184 #define ENABLE_IMGPROC
185 #undef IMGPROC_SAVE_IMG
186 #ifdef ENABLE_IMGPROC
187 #define IMG_FILTERS 5 /* number of image processes or filters in create_imgproc */
188 #endif /* ENABLE_IMGPROC
190 #define DISPLAY_ZOOMFACTOR_MIN 0.25 /* Minimum zoom factor for display viewer */
191 #define DISPLAY_ZOOMFACTOR_MAX 4.0 /* Maximum zoom factor for display viewer */
192 #define DISPLAY_ZOOMFACTOR_STEP 1.1 /* Increase / decrease change in zoomfactor */
194 #include "console_interface.h"
195 #include "display_interface.h"
199 * Image data / header will be stored to this format
214 #ifdef ENABLE_IMGPROC
224 enum ShowBackground
{
252 static float zfactor
[] = {
272 VECTOR_SCALE_7
= 128,
324 typedef struct __GpivVar Var
;
326 * Variables of gpiv that will be stored for future sessions, but are not
327 * defined as command line keys during launching gpiv:
330 enum TablabelPage tab_pos
; /* page of the notebook to be shown */
331 guint number_fnames_last
;
332 gchar
*fn_last
[MAX_LIST
]; /* last image name that has been loaded */
333 gboolean fname_last__set
; /* flag if fname_last has been set */
334 gchar
*fname_last
; /* last image name that has been loaded */
335 gchar
*fname_last_print
; /* last filename that has been printed to */
336 gboolean fname_date
; /* Extends the name with current date */
337 gboolean fname_time
; /* Extends the name with current time */
338 gfloat img_span_px
; /* spanned length that takes N mm in the img */
339 gfloat img_length_mm
; /* length in mm to be measured in img */
340 gboolean piv_disproc
; /* displaying Interrogation Areas and PIV estimator during interrogation */
341 gfloat piv_disproc_zoom
; /* magnification factor for displaying correlation in PIV evaluation tabulator */
342 guint piv_disproc_vlength
; /* vector length of PIV estimator in PIV evaluation tabulator */
343 gfloat dl_min
; /* minimum displacement of a piv data-set */
344 gfloat dl_max
; /* maximum displacement of a piv data-set */
345 #ifdef ENABLE_IMGPROC
346 guint imgproc_count
; /* number of image processes */
349 gboolean residu_stats
; /* perform residual statistics on PIV data while validating */
350 gboolean residu_stats__set
;
351 gboolean auto_thresh
; /* perform auto thresholding while validaton PIV data on outlyers */
352 gboolean auto_thresh__set
;
357 * Parameters of gpiv:
359 typedef struct __GpivPar Par
;
364 gboolean x_corr
; /* images for cross correlation */
365 gboolean x_corr__set
; /* images for cross correlation */
367 enum ImgFmt img_fmt
; /* Image data / header will be stored to this format */
368 gboolean img_fmt__set
;
370 gboolean hdf
; /* store data in hdf 5 format, with .h5 extension */
371 gboolean hdf__set
; /* store data in hdf 5 format, with .h5 extension */
373 gboolean print_par
; /* Prints parameters to stdout */
374 gboolean print_par__set
;
376 gboolean verbose
; /* Prints behaviour to stdout */
377 gboolean verbose__set
;
380 * Console related parameters
382 gboolean console__show_tooltips
; /* flag to show tooltips or hints (in pop-up window) */
383 gboolean console__show_tooltips__set
; /* flag to show tooltips or hints (in pop-up window) */
385 gboolean console__view_tabulator__set
; /* display tabulator of process parameters in main window */
386 gboolean console__view_tabulator
; /* display tabulator of process parameters in main window */
388 gboolean console__view_gpivbuttons
; /* display gpiv buttons in main window */
389 gboolean console__view_gpivbuttons__set
; /* display gpiv buttons in main window */
391 gint console__nbins
; /* number of bins to display histograms */
392 gboolean console__nbins__set
; /* number of bins to display histograms */
394 gboolean console__trigger_cam
; /* enable/disable camera and laser triggering */
395 gboolean console__trigger_cam__set
; /* enable/disable camera and laser triggering */
398 * Display viewer related parameters
400 gboolean display__stretch_auto
; /* stretch automatic window after zooming in */
401 gboolean display__stretch_auto__set
; /* stretch automatic window after sooming in has been defined */
403 enum ZoomIndex display__zoom_index
; /* index for displayed zooming */
404 gboolean display__zoom_index__set
; /* index for displayed zooming has been defined */
406 enum VectorScale display__vector_scale
; /* scale of vectors to be displayed */
407 gboolean display__vector_scale__set
; /* scale of vectors to be displayed has been defined */
409 enum VectorColor display__vector_color
; /* color representation of vectors */
410 gboolean display__vector_color__set
; /* color representation of vectors has been defined */
412 gboolean display__stretch_window
; /* stretch display window for image area */
413 gboolean display__stretch_window__set
; /* stretch display window for image area has been defined */
415 gboolean display__view_menubar
; /* view menubar of the buffer display */
416 gboolean display__view_menubar__set
; /* view menubar of the buffer display has been defined */
418 gboolean display__view_rulers
; /* view rulers of the buffer display */
419 gboolean display__view_rulers__set
; /* view rulers of the buffer display has been defined */
421 gboolean display__stretch__set
; /* stretch buffer display when zooming in */
422 gboolean display__stretch
; /* stretch buffer display when zooming in has been defined */
424 enum ShowBackground display__backgrnd
; /* display background color */
425 gboolean display__backgrnd__set
; /* display background color has been defined */
427 gboolean display__intregs
; /* display interrogation regions in display */
428 gboolean display__intregs__set
; /* display interrogation regions in display has been defined */
430 gboolean display__piv
; /* display piv vectors in display */
431 gboolean display__piv__set
; /* display piv vectors in display has been defined */
433 enum ShowScalar display__scalar
; /* displaying of scalar data */
434 gboolean display__scalar__set
; /* displaying of scalar data has been defined */
436 gboolean display__process
; /* display interrogation areas and covariance function during image analyzing process */
437 gboolean display__process__set
; /* display interrogation areas and covariance function during image analyzing process */
440 * Chain processing related parameters
442 gboolean process__cam
; /* used by gpiv toolbar to run camera */
443 gboolean process__cam__set
; /* used by gpiv toolbar to run camera */
445 gboolean process__trig
; /* used by gpiv toolbar to run trigger */
446 gboolean process__trig__set
; /* used by gpiv toolbar to run trigger */
448 gboolean process__imgproc
; /* used by gpiv toolbar to run image processing */
449 gboolean process__imgproc__set
; /* used by gpiv toolbar to run image processing */
451 gboolean process__piv
; /* used by gpiv toolbar to run piv */
452 gboolean process__piv__set
; /* used by gpiv toolbar to run piv */
454 gboolean process__gradient
; /* used by gpiv toolbar to run gradient */
455 gboolean process__gradient__set
; /* used by gpiv toolbar to run gradient */
457 gboolean process__resstats
; /* used by gpiv toolbar to run resstats */
458 gboolean process__resstats__set
; /* used by gpiv toolbar to run resstats */
460 gboolean process__errvec
; /* used by gpiv toolbar to run errvec */
461 gboolean process__errvec__set
; /* used by gpiv toolbar to run errvec */
463 gboolean process__peaklock
; /* used by gpiv toolbar to run peaklock */
464 gboolean process__peaklock__set
; /* used by gpiv toolbar to run peaklock */
466 gboolean process__average
; /* used by gpiv toolbar to run average */
467 gboolean process__average__set
; /* used by gpiv toolbar to run average */
469 gboolean process__scale
; /* used by gpiv toolbar to run scale */
470 gboolean process__scale__set
; /* used by gpiv toolbar to run scale */
472 gboolean process__subtract
; /* used by gpiv toolbar to run subtract */
473 gboolean process__subtract__set
; /* used by gpiv toolbar to run subtract */
475 gboolean process__vorstra
; /* used by gpiv toolbar to run vorstra */
476 gboolean process__vorstra__set
; /* used by gpiv toolbar to run vorstra */
479 gint mpi_nodes
; /* number of cluster nodes used for parallel MPI execution */
480 gboolean mpi_nodes__set
; /* number of cluster nodes used for parallel MPI execution */
481 #endif /* ENBALE MPI */
483 } gp
, *default_par
, *gpiv_par
;
487 * Global parameters and variables for each process:
488 * ImagePar should be unique for each image
491 GpivCamPar
*gl_cam_par
; /* global camera parameters */
493 #endif /* ENABLE_CAM */
496 GpivTrigPar
*gl_trig_par
; /* global trigger parameters */
497 #endif /* ENABLE_TRIG */
499 #ifdef ENABLE_IMGPROC
500 GpivImageProcPar
*gl_imgproc_par
; /* global image processing parameters */
501 #endif /* ENABLE_IMGPROC */
503 GpivImagePar
*gl_image_par
; /* global image parameters */
504 GpivPivPar
*gl_piv_par
; /* global PIV evaluation / interrogation parameters */
505 GpivValidPar
*gl_valid_par
; /* global PIV validation parameters */
506 GpivPostPar
*gl_post_par
; /* global PIV post processing parameters */
510 * Other global variables
512 GnomeProgram
*Gpiv_app
;
513 GnomeCanvasItem
*gci_aoi
, *gci_line
;
515 gchar fname
[GPIV_MAX_CHARS
];
516 gboolean exec_process
, cancel_process
;
518 Display
*display
[MAX_BUFS
], *display_act
;
522 gchar
*msg_default
, msg_display
[40];
523 gchar c_line
[GPIV_MAX_LINES_C
][GPIV_MAX_CHARS
];
524 guint var_scale
, display_intregs
;
525 guint m_select_index_y
, m_select_index_x
;
527 /* flag to suppres creating intregs during load_buffer; after displaying
528 * results into correct effect */
529 gboolean view_toggle_intregs_flag
;