1 /* -*- Mode1: 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
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 * main routines of gpiv
32 * Revision 1.30 2008-10-09 14:43:37 gerber
33 * paralellized with OMP and MPI
35 * Revision 1.29 2008-04-28 12:00:57 gerber
36 * hdf-formatted files are now with .hdf extension (previously: .gpi)
38 * Revision 1.28 2007-12-19 08:42:35 gerber
41 * Revision 1.27 2007-11-23 16:24:07 gerber
42 * release 0.5.0: Kafka
44 * Revision 1.26 2007-06-06 17:00:48 gerber
45 * Retreives images/data from URI using Gnome Virtual File System.
47 * Revision 1.25 2007-03-22 16:00:32 gerber
48 * Added image processing tabulator
50 * Revision 1.24 2007/02/05 15:17:09 gerber
51 * auto stretching, broadcast display settings to buffers from preferences
53 * Revision 1.23 2007-01-29 11:27:43 gerber
54 * added image formats png, gif, tif png, bmp, improved buffer display
56 * Revision 1.22 2006-09-18 07:27:06 gerber
57 * *** empty log message ***
59 * Revision 1.21 2006/01/31 15:15:33 gerber
60 * version 0.3.0b; minor change
62 * Revision 1.20 2006/01/31 14:28:12 gerber
65 * Revision 1.18 2005/03/04 12:52:01 gerber
66 * print message if gpiv_scan_resourcefiles returns with err_msg != NULL ==>
67 * this is not an error, but defaults are read
69 * Revision 1.17 2005/03/01 15:23:22 gerber
70 * removed warning message
72 * Revision 1.16 2005/03/01 14:43:46 gerber
73 * updated documentation
75 * Revision 1.15 2005/02/26 09:43:30 gerber
76 * parameter flags (parameter_logic) defined as gboolean
78 * Revision 1.14 2005/02/26 09:17:13 gerber
79 * structured of interrogate function by using gpiv_piv_isiadapt
81 * Revision 1.13 2005/01/19 15:53:42 gerber
82 * Initiation of Data Acquisition (DAC); trigerring of lasers and camera
83 * by using RTAI and Realtime Linux, recording images from IEEE1394
84 * (Firewire) IIDC compliant camera's
86 * Revision 1.12 2004/10/15 19:24:05 gerber
87 * GPIV_ and Gpiv prefix to defines and structure names of libgpiv
89 * Revision 1.11 2004/06/14 21:19:23 gerber
90 * Image depth up to 16 bits.
91 * Improvement "single int" and "drag int" in Eval tab.
92 * Viewer's pop-up menu.
93 * Adaption for gpiv_matrix_* and gpiv_vector_*.
95 * See Changelog for further info.
97 * Revision 1.10 2003/09/04 13:31:55 gerber
98 * init of printing (unfinished)
100 * Revision 1.9 2003/09/01 11:17:15 gerber
101 * improved monitoring of interrogation process
103 * Revision 1.8 2003/08/22 15:24:52 gerber
104 * interactive spatial scaling
106 * Revision 1.7 2003/07/25 15:40:23 gerber
107 * removed/disabled setting of correlation in Eval tab, Correlation type in Image info tab
109 * Revision 1.6 2003/07/13 14:38:18 gerber
110 * changed error handling of libgpiv
112 * Revision 1.5 2003/07/12 21:21:16 gerber
113 * changed error handling libgpiv
115 * Revision 1.3 2003/07/10 11:56:07 gerber
118 * Revision 1.2 2003/06/27 13:47:26 gerber
119 * display ruler, line/point evaluation
121 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
128 * some header inclusions for gtk/gnome (by glade)
137 * all variables are read by a header
139 #include "gpiv_gui.h"
141 /* #include "console_interface.h" */
144 #include "utils_par.h"
148 /* #define USAGE "\ */
149 /* Usage: gpiv-gui [-f filename][-s N][-t] \n\ */
152 /* -f filename: loads project \n\ */
153 /* -s N: vector scale N \n\ */
154 /* -t: show tooltips \n" */
157 /* -p: print parameters and other info to stdout \n\ */
161 /* #define HELP "\n\ */
162 /* gpiv processes and analyzes images for (Digital) Particle Image \n\ */
163 /* Velocimetry, post-processes the PIV data and visualizes its \n\ */
164 /* results in a graphical way. \n" */
169 /*-----------------------------------------------------------------------------
170 * Obtains parameter settings of the Graphic User Interface
174 gboolean used_default
= FALSE
;
175 Par
*ldp
= g_new (Par
, 1); /* Local default parameter */
176 /* Par *lgp = g_new (Par, 1); */
179 /* default_par = ldp; */
181 gnome_config_push_prefix ("/gpiv/General/");
184 gnome_config_get_bool_with_default ("print_par=FALSE", &used_default
);
186 g_message ("print_par = %d from default", ldp
->print_par
);
187 gnome_config_set_bool ("print_par", ldp
->print_par
);
191 gnome_config_get_bool_with_default ("verbose=FALSE", &used_default
);
193 g_message ("verbose = %d from default", ldp
->verbose
);
194 gnome_config_set_bool ("verbose", ldp
->verbose
);
198 ldp
->console__show_tooltips
=
199 gnome_config_get_bool_with_default ("console__show_tooltips=TRUE",
201 ldp
->console__show_tooltips__set
= TRUE
;
203 g_message ("console__show_tooltips = %d from default",
204 ldp
->console__show_tooltips
);
205 gnome_config_set_bool ("console__show_tooltips", ldp
->console__show_tooltips
);
209 ldp
->console__view_gpivbuttons
=
210 gnome_config_get_bool_with_default ("console__view_gpivbuttons=TRUE",
212 ldp
->console__view_gpivbuttons__set
= TRUE
;
214 g_message ("console__view_gpivbuttons = %d from default",
215 ldp
->console__view_gpivbuttons
);
216 gnome_config_set_bool ("view__gpivbuttons",
217 ldp
->console__view_gpivbuttons
);
221 ldp
->console__view_tabulator
=
222 gnome_config_get_bool_with_default ("console__view_tabulator=TRUE",
224 ldp
->console__view_tabulator__set
= TRUE
;
226 g_message ("console__view_tabulator = %d from default",
227 ldp
->console__view_tabulator
);
228 gnome_config_set_bool ("view__tabulator",
229 ldp
->console__view_tabulator
);
233 ldp
->console__nbins
=
234 gnome_config_get_int_with_default ("console__nbins=10", &used_default
);
235 ldp
->console__nbins__set
= TRUE
;
237 g_message ("console__nbins = %d from default", ldp
->console__nbins
);
238 gnome_config_set_int ("console__nbins", ldp
->console__nbins
);
243 gnome_config_get_int_with_default ("img_fmt=0", &used_default
);
244 ldp
->img_fmt__set
= TRUE
;
246 g_message ("img_fmt = %d from default ??", ldp
->img_fmt
);
247 gnome_config_set_bool ("img_fmt", ldp
->img_fmt
);
252 gnome_config_get_bool_with_default ("hdf=FALSE", &used_default
);
253 ldp
->hdf__set
= TRUE
;
255 g_message ("hdf = %d from default ??", ldp
->hdf
);
256 gnome_config_set_bool ("hdf", ldp
->hdf
);
261 gnome_config_get_int_with_default ("mpi_nodes=4", &used_default
);
262 ldp
->mpi_nodes__set
= TRUE
;
264 g_message ("mpi_nodes = %d from default", ldp
->mpi_nodes
);
265 gnome_config_set_int ("mpi_nodes", ldp
->mpi_nodes
);
267 #endif /* ENABLE_MPI */
271 gnome_config_push_prefix ("/gpiv/Image/");
274 gnome_config_get_bool_with_default ("x_corr=TRUE", &used_default
);
275 ldp
->x_corr__set
= TRUE
;
277 g_message ("x_corr = %d from default", ldp
->x_corr
);
278 gnome_config_set_bool ("x_corr", ldp
->x_corr
);
281 gnome_config_push_prefix ("/gpiv/Processes/");
285 gnome_config_get_bool_with_default ("process__cam=FALSE", &used_default
);
286 ldp
->process__cam__set
= TRUE
;
288 g_message ("process__cam = %d from default", ldp
->process__cam
);
289 gnome_config_set_bool ("process__cam", ldp
->process__cam
);
291 #endif /* ENABLE_CAM */
295 gnome_config_get_bool_with_default ("process__trig=FALSE", &used_default
);
296 ldp
->process__trig__set
= TRUE
;
298 g_message ("process__trig = %d from default", ldp
->process__trig
);
299 gnome_config_set_bool ("process__trig", ldp
->process__trig
);
301 #endif /* ENABLE_TRIG */
303 #ifdef ENABLE_IMGPROC
304 ldp
->process__imgproc
=
305 gnome_config_get_bool_with_default ("process__imgproc=FALSE", &used_default
);
306 ldp
->process__imgproc__set
= TRUE
;
308 g_message ("process__imgproc = %d from default", ldp
->process__imgproc
);
309 gnome_config_set_bool ("process__imgproc", ldp
->process__imgproc
);
311 #endif /* ENABLE_IMGPROC */
314 gnome_config_get_bool_with_default ("process__piv=TRUE", &used_default
);
315 ldp
->process__piv__set
= TRUE
;
317 g_message ("process__piv = %d from default", ldp
->process__piv
);
318 gnome_config_set_bool ("process__piv", ldp
->process__piv
);
322 ldp
->process__gradient
=
323 gnome_config_get_bool_with_default ("process__gradient=FALSE",
325 ldp
->process__gradient__set
= TRUE
;
327 g_message ("process__gradient = %d from default",
328 ldp
->process__gradient
);
329 gnome_config_set_bool ("process__gradient",
330 ldp
->process__gradient
);
334 ldp
->process__resstats
=
335 gnome_config_get_bool_with_default ("process__resstats=FALSE",
337 ldp
->process__resstats__set
= TRUE
;
339 g_message ("process__resstats = %d from default",
340 ldp
->process__resstats
);
341 gnome_config_set_bool ("process__resstats",
342 ldp
->process__resstats
);
346 ldp
->process__errvec
=
347 gnome_config_get_bool_with_default ("process__errvec=FALSE",
349 ldp
->process__errvec__set
= TRUE
;
351 g_message ("process__errvec = %d from default",
352 ldp
->process__errvec
);
353 gnome_config_set_bool ("process__errvec",
354 ldp
->process__errvec
);
358 ldp
->process__peaklock
=
359 gnome_config_get_bool_with_default ("process__peaklock=FALSE",
361 ldp
->process__peaklock__set
= TRUE
;
363 g_message ("process__peaklock = %d from default",
364 ldp
->process__peaklock
);
365 gnome_config_set_bool ("process__peaklock",
366 ldp
->process__peaklock
);
370 ldp
->process__average
=
371 gnome_config_get_bool_with_default ("process__average=FALSE",
373 ldp
->process__average__set
= TRUE
;
375 g_message ("process__average = %d from default",
376 ldp
->process__average
);
377 gnome_config_set_bool ("process__average",
378 ldp
->process__average
);
382 ldp
->process__scale
=
383 gnome_config_get_bool_with_default ("process__scale=FALSE",
385 ldp
->process__scale__set
= TRUE
;
387 g_message ("process__scale = %d from default",
388 ldp
->process__scale
);
389 gnome_config_set_bool ("process__scale",
390 ldp
->process__scale
);
394 ldp
->process__subtract
=
395 gnome_config_get_bool_with_default ("process__subtract=FALSE",
397 ldp
->process__subtract__set
= TRUE
;
399 g_message ("process__subtract = %d from default",
400 ldp
->process__subtract
);
401 gnome_config_set_bool ("process__subtract",
402 ldp
->process__subtract
);
406 ldp
->process__vorstra
=
407 gnome_config_get_bool_with_default ("process__vorstra=FALSE",
409 ldp
->process__vorstra__set
= TRUE
;
411 g_message ("process__vorstra = %d from default",
412 ldp
->process__vorstra
);
413 gnome_config_set_bool ("process__vorstra", ldp
->process__vorstra
);
418 gnome_config_push_prefix ("/gpiv/Display/");
420 ldp
->display__view_menubar
=
421 gnome_config_get_bool_with_default ("display__view_menubar=TRUE",
423 ldp
->display__view_menubar__set
= TRUE
;
425 g_message ("display__view_menubar = %d from default",
426 ldp
->display__view_menubar
);
427 gnome_config_set_bool ("display__view_menubar",
428 ldp
->display__view_menubar
);
432 ldp
->display__view_rulers
=
433 gnome_config_get_bool_with_default ("display__view_rulers=TRUE",
435 ldp
->display__view_rulers__set
= TRUE
;
437 g_message ("display__view_rulers = %d from default",
438 ldp
->display__view_rulers
);
439 gnome_config_set_bool ("display__view_rulers",
440 ldp
->display__view_rulers
);
444 ldp
->display__stretch_auto
=
445 gnome_config_get_bool_with_default ("display__stretch_auto=TRUE",
447 ldp
->display__stretch_auto__set
= TRUE
;
449 g_message ("display__stretch_auto = %d from default",
450 ldp
->display__stretch_auto
);
451 gnome_config_set_bool ("display__stretch_auto",
452 ldp
->display__stretch_auto
);
456 ldp
->display__backgrnd
=
457 gnome_config_get_int_with_default ("display__background=0", &used_default
);
458 ldp
->display__backgrnd__set
= TRUE
;
460 g_message ("display__background = %d from default", ldp
->display__backgrnd
);
461 gnome_config_set_int ("display__background", ldp
->display__backgrnd
);
465 ldp
->display__zoom_index
=
466 gnome_config_get_int_with_default ("display__zoom_index=1", &used_default
);
467 ldp
->display__zoom_index__set
= TRUE
;
469 g_message ("display__zoom_index = %d from default", ldp
->display__zoom_index
);
470 gnome_config_set_int ("display__zoom_index", ldp
->display__zoom_index
);
474 ldp
->display__vector_scale
=
475 gnome_config_get_int_with_default ("display__vector_scale=8", &used_default
);
476 ldp
->display__vector_scale__set
= TRUE
;
478 g_message ("display__vector_scale = %d from default", ldp
->display__vector_scale
);
479 gnome_config_set_int ("display__vector_scale", ldp
->display__vector_scale
);
483 ldp
->display__vector_color
=
484 gnome_config_get_int_with_default ("display__vector_color=SHOW_PEAKNR",
486 ldp
->display__vector_color__set
= TRUE
;
488 g_message ("display__vector_color = %d from default", ldp
->display__vector_color
);
489 gnome_config_set_int ("display__vector_color", ldp
->display__vector_color
);
492 /* ldp->stretch_window = */
493 /* gnome_config_get_int_with_default ("stretch_window=0", &used_default); */
494 /* if (used_default) { */
495 /* g_message ("stretch_window = %d from default", */
496 /* ldp->stretch_window); */
497 /* gnome_config_set_int ("stretch_window", ldp->stretch_window); */
501 ldp
->display__backgrnd
=
502 gnome_config_get_int_with_default ("display__backgrnd=SHOW_BG_IMG1",
504 ldp
->display__backgrnd__set
= TRUE
;
506 g_message ("display__backgrnd = %d from default", ldp
->display__backgrnd
);
507 gnome_config_set_int ("display__backgrnd", ldp
->display__backgrnd
);
511 ldp
->display__scalar
=
512 gnome_config_get_int_with_default ("display__scalar=SHOW_SC_NONE",
514 ldp
->display__scalar__set
= TRUE
;
516 g_message ("display__scalar = %d from default", ldp
->display__scalar
);
517 gnome_config_set_int ("display__scalar", ldp
->display__scalar
);
521 ldp
->display__intregs
=
522 gnome_config_get_bool_with_default ("display__intregs=TRUE",
524 ldp
->display__intregs__set
= TRUE
;
526 g_message ("display__intregs = %d from default",
527 ldp
->display__intregs
);
528 gnome_config_set_bool ("display__intregs", ldp
->display__intregs
);
533 gnome_config_get_bool_with_default ("display__piv=TRUE", &used_default
);
534 ldp
->display__piv__set
= TRUE
;
536 g_message ("display__piv = %d from default", ldp
->display__piv
);
537 gnome_config_set_bool ("display__piv", ldp
->display__piv
);
541 gnome_config_pop_prefix ();
550 /*-----------------------------------------------------------------------------
551 * Obtains additional variables, stored from previous sessions.
552 * Not all structure elements of gpiv_var are stored.
555 gboolean used_default
= FALSE
;
556 gchar fname_nr
[GPIV_MAX_CHARS
], fname_nr_default
[GPIV_MAX_CHARS
];
558 Var
*lgv
= g_new0 (Var
, 1);
561 gnome_config_push_prefix ("/gpiv/RuntimeVariables/");
564 gnome_config_get_int_with_default ("tab_pos=1", &used_default
);
566 g_message ("tab_pos = %d from default",
568 gnome_config_set_int ("tab_pos", lgv
->tab_pos
);
573 lgv
->number_fnames_last
=
574 gnome_config_get_int_with_default ("number_fnames_last=0",
577 g_message ("number_fnames_last = %d from default",
578 lgv
->number_fnames_last
);
579 gnome_config_set_int ("number_fnames_last",
580 lgv
->number_fnames_last
);
584 for (i
= 0; i
< lgv
->number_fnames_last
; i
++) {
585 g_snprintf(fname_nr
, GPIV_MAX_CHARS
,"fname_last_%d", i
);
586 g_snprintf(fname_nr_default
, GPIV_MAX_CHARS
,"fname_last_%d=./", i
);
589 gnome_config_get_string_with_default (fname_nr_default
,
592 g_message ("fnames_nr_default = %s from default",
594 gnome_config_set_string(fname_nr
, lgv
->fn_last
[i
]);
600 gnome_config_get_bool_with_default ("fname_date=FALSE",
603 g_message ("fname_date = %d from default",
605 gnome_config_set_bool ("fname_date", lgv
->fname_date
);
610 gnome_config_get_bool_with_default ("fname_time=FALSE",
613 g_message ("fname_time = %d from default",
615 gnome_config_set_bool ("fname_time", lgv
->fname_time
);
620 gnome_config_get_string_with_default ("fname_last=./", &used_default
);
622 g_message ("fname_last = %s from default", lgv
->fname_last
);
623 gnome_config_set_string("fname_last", lgv
->fname_last
);
628 gnome_config_get_float_with_default ("span=1.0", &used_default
);
630 g_message ("img_span_px = %f from default", lgv
->img_span_px
);
631 gnome_config_set_float("span", lgv
->img_span_px
);
635 gnome_config_get_float_with_default ("length=1.0", &used_default
);
637 g_message ("img_length_mm = %f from default", lgv
->img_length_mm
);
638 gnome_config_set_float("length", lgv
->img_length_mm
);
641 lgv
->piv_disproc_zoom
=
642 gnome_config_get_float_with_default ("zoom_factor=1.0", &used_default
);
644 g_message ("piv_disproc_zoom = %f from default",
645 lgv
->piv_disproc_zoom
);
646 gnome_config_set_float("piv_disproc_zoom", lgv
->piv_disproc_zoom
);
649 lgv
->piv_disproc_vlength
=
650 gnome_config_get_int_with_default ("piv_disproc_length=1", &used_default
);
652 g_message ("piv_disproc_length = %d from default",
653 lgv
->piv_disproc_vlength
);
654 gnome_config_set_int ("piv_disproc_length", lgv
->piv_disproc_vlength
);
658 gnome_config_pop_prefix ();
667 /*-----------------------------------------------------------------------------
668 * Reading parameters and variables from gnome parameter file (~/.gnome2/gpiv)
669 * See: http://developer.gnome.org/doc/GGAD/z79.html
671 * This workaround is because popt table is read when 'gnome_program_init' is.
672 * executed. The parameter structure loaded by popt (gp) needs to be compared
673 * with the values before reading the table, to find which parameters
674 * have been used as command arg. Therefore gp has been copied
675 * to gpiv_par before reading the table and is compared here.
676 * If not defined by command arg, defaults will be used. Defaults only can be
677 * read after 'gnome_program_init' as it uses gnome_config_get_*.
679 * Finally, the program variables are loaded here as well.
682 gchar
*err_msg
= NULL
;
685 set_parameters_ifdiff (&gp
, gpiv_par
);
687 default_par
= scan_parameters ();
688 /* cp_undef_parameters (default_par, gpiv_par); */
689 if ((err_msg
= cp_undef_parameters (default_par
, gpiv_par
)) != NULL
) {
690 gpiv_error ("par_init_args: failing cp_undef_parameters");
693 gpiv_var
= scan_variables ();
700 /*-----------------------------------------------------------------------------
701 * Setting and reading image parameters.
704 char *err_msg
= NULL
;
705 GpivImagePar
*lo_image_par
= g_new0 (GpivImagePar
, 1);
708 gl_image_par
= lo_image_par
;
709 gpiv_img_parameters_set (gl_image_par
, FALSE
);
711 gpiv_scan_resourcefiles (GPIV_IMGPAR_KEY
, gl_image_par
, gpiv_par
->print_par
))
712 != NULL
) g_message ("%s: %s", RCSID
, err_msg
);
714 g_snprintf (gl_image_par
->software
, GPIV_MAX_CHARS
, "%s %s", PACKAGE
, VERSION
);
715 gl_image_par
->software__set
= TRUE
;
717 g_snprintf (gl_image_par
->author
, GPIV_MAX_CHARS
, "%s", g_get_real_name ());
718 gl_image_par
->author__set
= TRUE
;
720 gpiv_img_default_parameters (gl_image_par
, FALSE
);
722 if (gpiv_par
->x_corr
) {
723 g_snprintf(IMAGE_CORRELATION_LABEL
, GPIV_MAX_CHARS
, "cross-correlation");
725 g_snprintf(IMAGE_CORRELATION_LABEL
, GPIV_MAX_CHARS
, "auto-correlation");
728 g_snprintf(IMAGE_WIDTH_LABEL
, GPIV_MAX_CHARS
, "%d", gl_image_par
->ncolumns
);
729 g_snprintf(IMAGE_HEIGHT_LABEL
, GPIV_MAX_CHARS
, "%d", gl_image_par
->nrows
);
730 g_snprintf(IMAGE_DEPTH_LABEL
, GPIV_MAX_CHARS
, "%d", gl_image_par
->depth
);
737 cam_par_init (gboolean cam_trig
)
738 /*-----------------------------------------------------------------------------
739 * parameter and variables initializing of data acquisition
740 * (trigger timings and cameraam)
744 GpivCamPar
*lo_cam_par
= g_new0 (GpivCamPar
, 1);
747 gl_cam_par
= lo_cam_par
;
748 gpiv_cam_parameters_set (gl_cam_par
, FALSE
);
750 gpiv_scan_resourcefiles (GPIV_CAMPAR_KEY
, gl_cam_par
, gpiv_par
->print_par
))
751 != NULL
) message_gpiv ("%s: %s", RCSID
, err_msg
);
752 gpiv_cam_check_parameters_read (gl_cam_par
, NULL
);
754 if ((cam_var
= gpiv_cam_get_camvar (gpiv_par
->verbose
)) == NULL
) {
755 if (gpiv_par
->verbose
)
756 warning_gpiv("cam_par_init: failing gpiv_cam_get_camvar");
760 if (cam_var
->numCameras
> 0) {
761 if (dc1394_setup_capture (cam_var
->camera
[0].handle
,
762 cam_var
->camera
[0].id
,
763 cam_var
->misc_info
[0].iso_channel
,
764 cam_var
->misc_info
[0].format
,
765 cam_var
->misc_info
[0].mode
,
767 /* cam_var->misc_info[0].framerate */ FRAMERATE_7_5
,
770 dc1394_release_camera (cam_var
->handle
, cam_var
->capture
[0]);
771 raw1394_destroy_handle (cam_var
->handle
);
772 g_warning("unable to setup camera-\n\
773 check line %d of %s to make sure\n\
774 that the video mode,framerate and format are\n\
775 supported by your camera\n",
779 gl_image_par
->ncolumns
= cam_var
->capture
[0].frame_width
;
780 gl_image_par
->nrows
= cam_var
->capture
[0].frame_height
;
781 gl_image_par
->ncolumns__set
= TRUE
;
782 gl_image_par
->nrows__set
= TRUE
;
783 raw1394_destroy_handle(cam_var
->handle
);
784 if (gpiv_par
->verbose
) {
785 g_message ("cam_par_init:: from camera: nrows = %d ncolumns = %d",
786 gl_image_par
->nrows
, gl_image_par
->ncolumns
);
790 #endif /* ENABLE_CAM */
797 /*-----------------------------------------------------------------------------
798 * parameter and variables initializing of data acquisition
802 GpivTrigPar
*lo_trig_par
= g_new0 (GpivTrigPar
, 1);
805 gl_trig_par
= lo_trig_par
;
806 gpiv_itrig_parameters_set (gl_trig_par
, FALSE
);
807 gpiv_trig_parameters_set(gl_trig_par
, FALSE
);
809 gpiv_scan_resourcefiles (GPIV_TRIGPAR_KEY
, gl_trig_par
, gpiv_par
->print_par
))
810 != NULL
) message_gpiv ("%s: %s", RCSID
, err_msg
);
811 gpiv_trig_check_parameters_read (gl_trig_par
, NULL
);
813 #endif /* ENABLE_TRIG */
817 #ifdef ENABLE_IMGPROC
819 imgproc_par_init (void)
820 /*-----------------------------------------------------------------------------
821 * Setting and reading image processing parameters.
824 char *err_msg
= NULL
;
825 GpivImageProcPar
*lo_imgproc_par
= g_new0 (GpivImageProcPar
, 1);
828 gl_imgproc_par
= lo_imgproc_par
;
829 gpiv_imgproc_parameters_set (gl_imgproc_par
, FALSE
);
831 gpiv_scan_resourcefiles (GPIV_IMGPROCPAR_KEY
, gl_imgproc_par
,
832 gpiv_par
->print_par
))
833 != NULL
) g_message ("%s: %s", RCSID
, err_msg
);
834 gpiv_imgproc_check_parameters_read (gl_imgproc_par
, NULL
);
836 #endif /* ENABLE_IMGPROC */
842 /*-----------------------------------------------------------------------------
843 * Reading piv interrogation parameters.
846 char *err_msg
= NULL
;
847 GpivPivPar
*lo_piv_par
= g_new0 (GpivPivPar
, 1);
850 gl_piv_par
= lo_piv_par
;
851 gpiv_piv_parameters_set (gl_piv_par
, FALSE
);
853 gpiv_scan_resourcefiles (GPIV_PIVPAR_KEY
, gl_piv_par
, gpiv_par
->print_par
))
854 != NULL
) g_message ("%s: %s", RCSID
, err_msg
);
855 gpiv_piv_check_parameters_read(gl_piv_par
, NULL
);
857 if (gl_piv_par
->col_start
> gl_image_par
->ncolumns
- gl_piv_par
->pre_shift_col
- 1) {
858 gl_piv_par
->col_start
= 0;
859 if (gpiv_par
->verbose
)
860 g_warning ("col_start larger than ncolumns; \nset to 0");
863 if (gl_piv_par
->col_end
> gl_image_par
->ncolumns
- gl_piv_par
->pre_shift_col
- 1) {
864 gl_piv_par
->col_end
= gl_image_par
->ncolumns
- gl_piv_par
->pre_shift_col
- 1;
865 if (gpiv_par
->verbose
)
866 g_warning("col_end larger than ncolumns; \nset to ncolumns %d",
867 gl_image_par
->ncolumns
- 1);
870 if (gl_piv_par
->row_start
> gl_image_par
->nrows
- gl_piv_par
->pre_shift_row
- 1) {
871 gl_piv_par
->row_start
= 0;
872 if (gpiv_par
->verbose
)
873 g_warning(_("row_start larger than nrows; \nset to zero"));
876 if (gl_piv_par
->row_end
> gl_image_par
->nrows
- gl_piv_par
->pre_shift_row
- 1) {
877 gl_piv_par
->row_end
= gl_image_par
->nrows
- gl_piv_par
->pre_shift_row
- 1;
878 if (gpiv_par
->verbose
)
879 g_warning("row_end larger than nrows; \nset to nrows %d",
880 gl_image_par
->nrows
- 1);
888 valid_par_init (void)
889 /*-----------------------------------------------------------------------------
890 * Reading piv validation parameters.
893 char *err_msg
= NULL
;
894 GpivValidPar
*lo_valid_par
= g_new0 (GpivValidPar
, 1);
897 gl_valid_par
= lo_valid_par
;
898 gpiv_valid_parameters_set (gl_valid_par
, FALSE
);
900 gpiv_scan_resourcefiles (GPIV_VALIDPAR_KEY
, gl_valid_par
, gpiv_par
->print_par
))
901 != NULL
) g_message ("%s: %s", RCSID
, err_msg
);
902 gpiv_valid_check_parameters_read (gl_valid_par
, NULL
);
909 /*-----------------------------------------------------------------------------
910 * Reading piv post-processing parameters.
913 char *err_msg
= NULL
;
914 GpivPostPar
*lo_post_par
= g_new0 (GpivPostPar
, 1);
917 gl_post_par
= lo_post_par
;
918 gpiv_post_parameters_set (gl_post_par
, FALSE
);
920 gpiv_scan_resourcefiles (GPIV_POSTPAR_KEY
, gl_post_par
, gpiv_par
->print_par
))
921 != NULL
) g_message ("%s: %s", RCSID
, err_msg
);
922 gpiv_post_check_parameters_read (gl_post_par
, NULL
);
928 load_images_from_commandline (GnomeProgram
*program
,
930 /*-----------------------------------------------------------------------------
931 * Loading the images from the command line while launching gpiv.
935 GValue value
= { 0, };
939 g_value_init (&value
, G_TYPE_POINTER
);
940 g_object_get_property (G_OBJECT (program
), GNOME_PARAM_POPT_CONTEXT
,
942 ctx
= g_value_get_pointer (&value
);
943 g_value_unset (&value
);
945 args
= (char**) poptGetArgs(ctx
);
947 for (i
= 0; args
[i
]; i
++) {
948 select_action_from_name (gpiv
, args
[i
]);
959 /*-----------------------------------------------------------------------------
960 * Main routine of gpiv
963 GnomeProgram
*program
;
964 /* GpivConsole *gpiv = g_new0 (GpivConsole, 1); */
967 char *err_msg
= NULL
;
968 gchar
*msg
= "Welcome to gpiv.";
969 GtkWidget
*menu_gpiv_popup
= NULL
;
970 GpivConsole
*gpiv
= NULL
;
971 gboolean trig_trig
= TRUE
, cam_trig
= TRUE
;
972 gint trig_init
, trig_start
, trig_stop
, trig_error
;
975 gboolean restored
= FALSE
;
978 setlocale (LC_ALL
, "");
979 bindtextdomain(PACKAGE
, PACKAGE_LOCALE_DIR
);
984 * parameter initializing of gpiv-gui, image
989 exec_process
= FALSE
;
990 cancel_process
= FALSE
;
996 if ((gpiv_par
= cp_parameters (&gp
)) == NULL
) {
997 gpiv_error ("main: failing cp_parameters");
1000 /* Initialize gnome program
1001 * command line keys: using POPT
1004 program
= gnome_program_init (PACKAGE
, VERSION
,
1005 LIBGNOMEUI_MODULE
, argc
, argv
,
1006 GNOME_PARAM_POPT_TABLE
, options
,
1007 GNOME_PARAM_HUMAN_READABLE_NAME
,
1008 _("Image analyser for Particle Image Velocimetry"),
1009 GNOME_PROGRAM_STANDARD_PROPERTIES
,
1013 * Used for authentification when loading/storing images from remote system
1016 gnome_authentication_manager_init ();
1019 * Reading program parameters, variables and process parameters
1026 cam_par_init (cam_trig
);
1033 #ifdef ENABLE_IMGPROC
1034 imgproc_par_init ();
1042 if (gl_image_par
->ncolumns
<= IMAGE_WIDTH_MAX
1043 && gl_image_par
->nrows
<= IMAGE_HEIGHT_MAX
1044 && gl_image_par
->depth
<= IMAGE_DEPTH_MAX
1047 * creating the Graphic interface
1049 gpiv
= create_gpiv ();
1050 gtk_widget_show (GTK_WIDGET (gpiv
->console
));
1051 menu_gpiv_popup
= create_menu_gpiv_popup (gpiv
);
1052 gtk_signal_connect_object (GTK_OBJECT(gpiv
->console
),
1053 "button_press_event",
1054 GTK_SIGNAL_FUNC (on_my_popup_handler
),
1055 GTK_OBJECT (menu_gpiv_popup
));
1057 gnome_appbar_set_default (GNOME_APPBAR(gpiv
->appbar
), msg_default
);
1058 gnome_appbar_push (GNOME_APPBAR(gpiv
->appbar
), msg
);
1060 if (gpiv_par
->console__show_tooltips
) {
1061 gtk_tooltips_enable(gpiv
->tooltips
);
1063 gtk_tooltips_disable(gpiv
->tooltips
);
1068 * Widgets will be enabled / disabled if trigger kernel modules
1069 * are loaded and accessible.
1070 * An info message will be displayed if features are absent
1072 if (!gpiv_trig_openrtfs (&trig_init
, &trig_start
, &trig_stop
,
1074 message_gpiv (_("Trigger system not available"));
1077 exec_trigger_stop ();
1078 sensitive (gpiv
, DAC_TRIG
, trig_trig
);
1079 sensitive (gpiv
, DAC_TIMING
, trig_trig
);
1080 #endif /* ENABLE_TRIG */
1084 * Widgets will be enabled / disabled if camera is connected.
1085 * An info message will be displayed if features are absent
1087 if (cam_var
->numCameras
> 0) {
1088 sensitive (gpiv
, DAC_CAM
, TRUE
);
1090 sensitive (gpiv
, DAC_TIMING
, TRUE
);
1093 sensitive (gpiv
, DAC_CAM
, FALSE
);
1095 sensitive (gpiv
, DAC_TIMING
, FALSE
);
1097 message_gpiv (_("No camera connected"));
1099 #endif /* ENABLE_CAM */
1101 sensitive (gpiv
, IMG
, TRUE
);
1102 sensitive (gpiv
, EVAL
, TRUE
);
1103 sensitive (gpiv
, INTREGS
, FALSE
);
1104 sensitive (gpiv
, VALID
, TRUE
);
1105 sensitive (gpiv
, POST
, TRUE
);
1107 load_images_from_commandline (program
, gpiv
);
1110 error_gpiv(_("Image dimensions or depth are larger than %dx%dx%d."),
1111 (int)IMAGE_WIDTH_MAX
, (int)IMAGE_HEIGHT_MAX
,
1112 (int)IMAGE_DEPTH_MAX
);