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
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 * utility functions for gpiv
31 * $Log: utils_par.c,v $
32 * Revision 1.2 2008-10-09 14:43:37 gerber
33 * paralellized with OMP and MPI
35 * Revision 1.1 2008-09-16 11:24:37 gerber
42 #include "utils_par.h"
49 set_par_bool_ifdiff (gboolean
*val_src
,
54 set_par_int_ifdiff (gint
*val_src
,
59 print_par_bool (gchar
*parname
,
64 print_par_int (gchar
*parname
,
69 par_ovwrt_parameters (Par
*par_src
,
75 * Program-wide public functions
78 parameters_set (Par
*par
,
81 /*-----------------------------------------------------------------------------
82 * Defines each parameter member of par_dest->*__set to bool
86 par
->img_fmt__set
= bool;
88 par
->print_par__set
= bool;
89 par
->verbose__set
= bool;
90 par
->x_corr__set
= bool;
91 par
->console__show_tooltips__set
= bool;
92 par
->console__view_tabulator__set
= bool;
93 par
->console__view_gpivbuttons__set
= bool;
94 par
->console__nbins__set
= bool;
97 par
->process__cam
= bool;
98 #endif /* ENABLE_CAM */
101 par
->process__trig
= bool;
102 #endif /* ENABLE_DAC */
104 #ifdef ENABLE_IMGPROC
105 par
->process__imgproc
= bool;
106 #endif /* ENABLE_IMGPROC */
108 par
->process__piv
= bool;
109 par
->process__gradient
= bool;
110 par
->process__resstats
= bool;
111 par
->process__errvec
= bool;
112 par
->process__peaklock
= bool;
113 par
->process__scale
= bool;
114 par
->process__average
= bool;
115 par
->process__subtract
= bool;
116 par
->process__vorstra
= bool;
117 par
->display__view_menubar
= bool;
118 par
->display__view_rulers
= bool;
119 par
->display__stretch_auto
= bool;
120 par
->display__vector_scale
= bool;
121 par
->display__vector_color
= bool;
122 par
->display__zoom_index
= bool;
123 par
->display__backgrnd__set
= bool;
124 par
->display__intregs
= bool;
125 par
->display__piv
= bool;
126 par
->display__scalar__set
= bool;
129 par
->mpi_nodes__set
= bool;
130 #endif /* ENABLE_MPI */
137 set_parameters_ifdiff (Par
*par_src
,
140 /*-----------------------------------------------------------------------------
141 * Defines each parameter member of par_dest->*__set to TRUE if par_src differs
145 set_par_int_ifdiff ((int *) &par_src
->img_fmt
,
146 (int *) &par_dest
->img_fmt
,
147 &par_dest
->img_fmt__set
);
149 set_par_bool_ifdiff (&par_src
->hdf
,
151 &par_dest
->hdf__set
);
153 set_par_bool_ifdiff (&par_src
->print_par
,
154 &par_dest
->print_par
,
155 &par_dest
->print_par__set
);
157 set_par_bool_ifdiff (&par_src
->verbose
,
159 &par_dest
->verbose__set
);
161 set_par_bool_ifdiff (&par_src
->x_corr
,
163 &par_dest
->x_corr__set
);
165 set_par_bool_ifdiff (&par_src
->console__show_tooltips
,
166 &par_dest
->console__show_tooltips
,
167 &par_dest
->console__show_tooltips__set
);
169 set_par_bool_ifdiff (&par_src
->console__view_tabulator
,
170 &par_dest
->console__view_tabulator
,
171 &par_dest
->console__view_tabulator__set
);
173 set_par_bool_ifdiff (&par_src
->console__view_gpivbuttons
,
174 &par_dest
->console__view_gpivbuttons
,
175 &par_dest
->console__view_gpivbuttons__set
);
177 set_par_int_ifdiff (&par_src
->console__nbins
,
178 &par_dest
->console__nbins
,
179 &par_dest
->console__nbins__set
);
182 set_par_bool_ifdiff (&par_src
->process__cam
,
183 &par_dest
->process__cam
,
184 &par_dest
->process__cam__set
);
185 #endif /* ENABLE_CAM */
188 set_par_bool_ifdiff (&par_src
->process__trig
,
189 &par_dest
->process__trig
,
190 &par_dest
->process__trig__set
);
191 #endif /* ENABLE_DAC */
193 #ifdef ENABLE_IMGPROC
194 set_par_bool_ifdiff (&par_src
->process__imgproc
,
195 &par_dest
->process__imgproc
,
196 &par_dest
->process__imgproc__set
);
197 #endif /* ENABLE_IMGPROC */
199 set_par_bool_ifdiff (&par_src
->process__piv
,
200 &par_dest
->process__piv
,
201 &par_dest
->process__piv__set
);
203 set_par_bool_ifdiff (&par_src
->process__gradient
,
204 &par_dest
->process__gradient
,
205 &par_dest
->process__gradient__set
);
207 set_par_bool_ifdiff (&par_src
->process__resstats
,
208 &par_dest
->process__resstats
,
209 &par_dest
->process__resstats__set
);
211 set_par_bool_ifdiff (&par_src
->process__errvec
,
212 &par_dest
->process__errvec
,
213 &par_dest
->process__errvec__set
);
215 set_par_bool_ifdiff (&par_src
->process__peaklock
,
216 &par_dest
->process__peaklock
,
217 &par_dest
->process__peaklock__set
);
220 set_par_bool_ifdiff (&par_src
->process__scale
,
221 &par_dest
->process__scale
,
222 &par_dest
->process__scale__set
);
225 set_par_bool_ifdiff (&par_src
->process__average
,
226 &par_dest
->process__average
,
227 &par_dest
->process__average__set
);
230 set_par_bool_ifdiff (&par_src
->process__subtract
,
231 &par_dest
->process__subtract
,
232 &par_dest
->process__subtract__set
);
235 set_par_bool_ifdiff (&par_src
->process__vorstra
,
236 &par_dest
->process__vorstra
,
237 &par_dest
->process__vorstra__set
);
240 set_par_bool_ifdiff (&par_src
->display__view_menubar
,
241 &par_dest
->display__view_menubar
,
242 &par_dest
->display__view_menubar__set
);
245 set_par_bool_ifdiff (&par_src
->display__view_rulers
,
246 &par_dest
->display__view_rulers
,
247 &par_dest
->display__view_rulers__set
);
250 set_par_bool_ifdiff (&par_src
->display__stretch_auto
,
251 &par_dest
->display__stretch_auto
,
252 &par_dest
->display__stretch_auto__set
);
255 set_par_int_ifdiff ((int *) &par_src
->display__vector_scale
,
256 (int *) &par_dest
->display__vector_scale
,
257 &par_dest
->display__vector_scale__set
);
260 set_par_int_ifdiff ((int *) &par_src
->display__vector_color
,
261 (int *) &par_dest
->display__vector_color
,
262 &par_dest
->display__vector_color__set
);
265 set_par_int_ifdiff ((int *) &par_src
->display__zoom_index
,
266 (int *) &par_dest
->display__zoom_index
,
267 &par_dest
->display__zoom_index__set
);
270 set_par_int_ifdiff ((int *) &par_src
->display__backgrnd
,
271 (int *) &par_dest
->display__backgrnd
,
272 &par_dest
->display__backgrnd__set
);
275 set_par_bool_ifdiff (&par_src
->display__intregs
,
276 &par_dest
->display__intregs
,
277 &par_dest
->display__intregs__set
);
280 set_par_bool_ifdiff (&par_src
->display__piv
,
281 &par_dest
->display__piv
,
282 &par_dest
->display__piv__set
);
285 set_par_int_ifdiff ((int *) &par_src
->display__scalar
,
286 (int *) &par_dest
->display__scalar
,
287 &par_dest
->display__scalar__set
);
290 set_par_int_ifdiff (&par_src
->mpi_nodes
,
291 &par_dest
->mpi_nodes
,
292 &par_dest
->mpi_nodes__set
);
293 #endif /* ENABLE_MPI */
300 print_parameters (Par
*par
302 /*-----------------------------------------------------------------------------
306 print_par_int ("img_fmt", par
->img_fmt
,
309 print_par_bool ("hdf", par
->hdf
,
312 print_par_bool ("print_par", par
->print_par
,
313 par
->print_par__set
);
315 print_par_bool ("verbose", par
->verbose
,
318 print_par_bool ("x_corr", par
->x_corr
,
321 print_par_bool ("console__show_tooltips", par
->console__show_tooltips
,
322 par
->console__show_tooltips__set
);
324 print_par_bool ("console__view_tabulator", par
->console__view_tabulator
,
325 par
->console__view_tabulator__set
);
327 print_par_bool ("console__view_gpivbuttons", par
->console__view_gpivbuttons
,
328 par
->console__view_gpivbuttons__set
);
330 print_par_int ("console__nbins", par
->console__nbins
,
331 par
->console__nbins__set
);
334 print_par_bool ("process__cam", par
->process__cam
,
335 par
->process__cam__set
);
336 #endif /* ENABLE_CAM */
339 print_par_bool ("process__trig", par
->process__trig
,
340 par
->process__trig__set
);
341 #endif /* ENABLE_DAC */
343 #ifdef ENABLE_IMGPROC
344 print_par_bool ("process__imgproc", par
->process__imgproc
,
345 par
->process__imgproc__set
);
346 #endif /* ENABLE_IMGPROC */
348 print_par_bool ("process__piv", par
->process__piv
,
349 par
->process__piv__set
);
351 print_par_bool ("process__gradient", par
->process__gradient
,
352 par
->process__gradient__set
);
354 print_par_bool ("process__resstats", par
->process__resstats
,
355 par
->process__resstats__set
);
357 print_par_bool ("process__errvec", par
->process__errvec
,
358 par
->process__errvec__set
);
360 print_par_bool ("process__peaklock", par
->process__peaklock
,
361 par
->process__peaklock__set
);
364 print_par_bool ("process__scale", par
->process__scale
,
365 par
->process__scale__set
);
368 print_par_bool ("process__average", par
->process__average
,
369 par
->process__average__set
);
372 print_par_bool ("process__subtract", par
->process__subtract
,
373 par
->process__subtract__set
);
376 print_par_bool ("process__vorstra", par
->process__vorstra
,
377 par
->process__vorstra__set
);
380 print_par_bool ("display__view_menubar", par
->display__view_menubar
,
381 par
->display__view_menubar__set
);
384 print_par_bool ("display__view_rulers", par
->display__view_rulers
,
385 par
->display__view_rulers__set
);
388 print_par_bool ("display__stretch_auto", par
->display__stretch_auto
,
389 par
->display__stretch_auto__set
);
392 print_par_bool ("display__vector_scale", par
->display__vector_scale
,
393 par
->display__vector_scale__set
);
396 print_par_bool ("display__vector_color", par
->display__vector_color
,
397 par
->display__vector_color__set
);
400 print_par_bool ("display__zoom_index", par
->display__zoom_index
,
401 par
->display__zoom_index__set
);
404 print_par_bool ("display__background", par
->display__backgrnd
,
405 par
->display__backgrnd__set
);
408 print_par_bool ("display__intregs", par
->display__intregs
,
409 par
->display__intregs__set
);
412 print_par_bool ("display__piv", par
->display__piv
,
413 par
->display__piv__set
);
416 print_par_bool ("display__scalar", par
->display__scalar
,
417 par
->display__scalar__set
);
420 print_par_int ("mpi_nodes", par
->mpi_nodes
,
421 par
->mpi_nodes__set
);
423 #endif /* ENABLE_MPI */
429 cp_undef_parameters (Par
*par_src
,
432 /*-----------------------------------------------------------------------------
434 * Copies only those gpiv parameters from src to dest if dest has not
438 * par_src: source gpiv parameters
439 * force: flag to force the copying, even if destination
441 * print_par: verbose output. Not implemented, yet.
444 * par_dest: destination piv parameters
448 *---------------------------------------------------------------------------*/
450 gchar
*err_msg
= NULL
;
451 gboolean force
= FALSE
;
454 par_ovwrt_parameters (par_src
, par_dest
, force
);
463 cp_parameters (Par
*par_src
465 /*-----------------------------------------------------------------------------
467 * Copies all gpiv parameters
470 * par_src: source gpiv parameters
471 * force: flag to force the copying, even if destination
473 * print_par: verbose output. Not implemented, yet.
476 * par_dest: destination piv parameters
480 *---------------------------------------------------------------------------*/
482 Par
*par_dest
= g_new0 (Par
, 1);
483 gboolean force
= TRUE
;
486 par_ovwrt_parameters (par_src
, par_dest
, force
);
498 set_par_bool_ifdiff (gboolean
*val_src
,
501 /*-----------------------------------------------------------------------------
504 if (*val_src
!= *val_dest
) {
505 *val_dest
= *val_src
;
515 set_par_int_ifdiff (gint
*val_src
,
518 /*-----------------------------------------------------------------------------
521 if (*val_src
!= *val_dest
) {
522 *val_dest
= *val_src
;
532 print_par_bool (gchar
*parname
,
535 /*-----------------------------------------------------------------------------
539 g_message ("%s__set is TRUE", parname
);
541 g_message ("%s__set is FALSE", parname
);
545 g_message ("%s is set to: TRUE", parname
);
547 g_message ("%s is set to: FALSE", parname
);
553 print_par_int (gchar
*parname
,
556 /*-----------------------------------------------------------------------------
560 g_message ("%s__set is TRUE", parname
);
562 g_message ("%s__set is FALSE", parname
);
565 g_message ("%s is set to: %d", parname
, val
);
570 par_ovwrt_parameters (Par
*par_src
,
574 /*-----------------------------------------------------------------------------
576 * Copies gpiv parameters
579 * par_src: source gpiv parameters
580 * par_dest: destination gpiv parameters
581 * force: flag to force the copying, even if destination
585 * par_dest: destination piv parameters
589 *---------------------------------------------------------------------------*/
593 || ( par_src
->img_fmt__set
594 && !par_dest
->img_fmt__set
)) {
595 par_dest
->img_fmt
= par_src
->img_fmt
;
596 par_dest
->img_fmt__set
= TRUE
;
600 || ( par_src
->hdf__set
601 && !par_dest
->hdf__set
)) {
602 par_dest
->hdf
= par_src
->hdf
;
603 par_dest
->hdf__set
= TRUE
;
607 || ( par_src
->print_par__set
608 && !par_dest
->print_par__set
)) {
609 par_dest
->print_par
= par_src
->print_par
;
610 par_dest
->print_par__set
= TRUE
;
614 || ( par_src
->verbose__set
615 && !par_dest
->verbose__set
)) {
616 par_dest
->verbose
= par_src
->verbose
;
617 par_dest
->verbose__set
= TRUE
;
621 || ( par_src
->x_corr__set
622 && !par_dest
->x_corr__set
)) {
623 par_dest
->x_corr
= par_src
->x_corr
;
624 par_dest
->x_corr__set
= TRUE
;
628 || ( par_src
->console__show_tooltips__set
629 && !par_dest
->console__show_tooltips__set
)) {
630 par_dest
->console__show_tooltips
= par_src
->console__show_tooltips
;
631 par_dest
->console__show_tooltips__set
= TRUE
;
635 || ( par_src
->console__view_tabulator__set
636 && !par_dest
->console__view_tabulator__set
)) {
637 par_dest
->console__view_tabulator
= par_src
->console__view_tabulator
;
638 par_dest
->console__view_tabulator__set
= TRUE
;
642 || ( par_src
->console__view_gpivbuttons__set
643 && !par_dest
->console__view_gpivbuttons__set
)) {
644 par_dest
->console__view_gpivbuttons
= par_src
->console__view_gpivbuttons
;
645 par_dest
->console__view_gpivbuttons__set
= TRUE
;
649 || ( par_src
->console__nbins__set
650 && !par_dest
->console__nbins__set
)) {
651 par_dest
->console__nbins
= par_src
->console__nbins
;
652 par_dest
->console__nbins__set
= TRUE
;
657 || ( par_src
->process__cam__set
658 && !par_dest
->process__cam__set
)) {
659 par_dest
->process__cam
= par_src
->process__cam
;
660 par_dest
->process__cam__set
= TRUE
;
662 #endif /* ENABLE_CAM */
666 || ( par_src
->process__trig__set
667 && !par_dest
->process__trig__set
)) {
668 par_dest
->process__trig
= par_src
->process__trig
;
669 par_dest
->process__trig__set
= TRUE
;
671 #endif /* ENABLE_DAC */
673 #ifdef ENABLE_IMGPROC
675 || ( par_src
->process__imgproc__set
676 && !par_dest
->process__imgproc__set
)) {
677 par_dest
->process__piv
= par_src
->process__piv
;
678 par_dest
->process__imgproc__set
= TRUE
;
680 #endif /* ENABLE_IMGPROC */
683 || ( par_src
->process__piv__set
684 && !par_dest
->process__piv__set
)) {
685 par_dest
->process__piv
= par_src
->process__piv
;
686 par_dest
->process__piv__set
= TRUE
;
690 || ( par_src
->process__gradient__set
691 && !par_dest
->process__gradient__set
)) {
692 par_dest
->process__gradient
= par_src
->process__gradient
;
693 par_dest
->process__gradient__set
= TRUE
;
697 || ( par_src
->process__resstats__set
698 && !par_dest
->process__resstats__set
)) {
699 par_src
->process__resstats
= par_dest
->process__resstats
;
700 par_dest
->process__resstats__set
= TRUE
;
704 || ( par_src
->process__errvec__set
705 && !par_dest
->process__errvec__set
)) {
706 par_dest
->process__errvec
= par_src
->process__errvec
;
707 par_dest
->process__errvec__set
= TRUE
;
711 || ( par_src
->process__peaklock__set
712 && !par_dest
->process__peaklock__set
)) {
713 par_dest
->process__peaklock
= par_src
->process__peaklock
;
714 par_dest
->process__peaklock__set
= TRUE
;
718 || ( par_src
->process__scale__set
719 && !par_dest
->process__scale__set
)) {
720 par_dest
->process__scale
= par_src
->process__scale
;
721 par_dest
->process__scale__set
= TRUE
;
725 || ( par_src
->process__average__set
726 && !par_dest
->process__average__set
)) {
727 par_dest
->process__average
= par_src
->process__average
;
728 par_dest
->process__average__set
= TRUE
;
732 || ( par_src
->process__subtract__set
733 && !par_dest
->process__subtract__set
)) {
734 par_dest
->process__subtract
= par_src
->process__subtract
;
735 par_dest
->process__subtract__set
= TRUE
;
739 || ( par_src
->process__vorstra__set
740 && !par_dest
->process__vorstra__set
)) {
741 par_dest
->process__vorstra
= par_src
->process__vorstra
;
742 par_dest
->process__vorstra__set
= TRUE
;
746 || ( par_src
->display__view_menubar__set
747 && !par_dest
->display__view_menubar__set
)) {
748 par_dest
->display__view_menubar
= par_src
->display__view_menubar
;
749 par_dest
->display__view_menubar__set
= TRUE
;
753 || ( par_src
->display__view_rulers__set
754 && !par_dest
->display__view_rulers__set
)) {
755 par_dest
->display__view_rulers
= par_src
->display__view_rulers
;
756 par_dest
->display__view_rulers__set
= TRUE
;
760 || ( par_src
->display__stretch_auto__set
761 && !par_dest
->display__stretch_auto__set
)) {
762 par_dest
->display__view_rulers
= par_src
->display__view_rulers
;
763 par_dest
->display__stretch_auto__set
= TRUE
;
767 || ( par_src
->display__vector_scale__set
768 && !par_dest
->display__vector_scale__set
)) {
769 par_dest
->display__vector_scale
= par_src
->display__vector_scale
;
770 par_dest
->display__vector_scale__set
= TRUE
;
774 || ( par_src
->display__vector_color__set
775 && !par_dest
->display__vector_color__set
)) {
776 par_dest
->display__vector_color
= par_src
->display__vector_color
;
777 par_dest
->display__vector_color__set
= TRUE
;
781 || ( par_src
->display__zoom_index__set
782 && !par_dest
->display__zoom_index__set
)) {
783 par_dest
->display__zoom_index
= par_src
->display__zoom_index
;
784 par_dest
->display__zoom_index__set
= TRUE
;
788 || ( par_src
->display__backgrnd__set
789 && !par_dest
->display__backgrnd__set
)) {
790 par_dest
->display__backgrnd
= par_src
->display__backgrnd
;
791 par_dest
->display__backgrnd__set
= TRUE
;
795 || ( par_src
->display__intregs__set
796 && !par_dest
->display__intregs__set
)) {
797 par_dest
->display__intregs
= par_src
->display__intregs
;
798 par_dest
->display__intregs__set
= TRUE
;
802 || ( par_src
->display__piv__set
803 && !par_dest
->display__piv__set
)) {
804 par_dest
->display__piv
= par_src
->display__piv
;
805 par_dest
->display__piv__set
= TRUE
;
809 || ( par_src
->display__scalar__set
810 && !par_dest
->display__scalar__set
)) {
811 par_dest
->display__scalar
= par_src
->display__scalar
;
812 par_dest
->display__scalar__set
= TRUE
;
817 || ( par_src
->mpi_nodes__set
818 && !par_dest
->mpi_nodes__set
)) {
819 par_dest
->mpi_nodes
= par_src
->mpi_nodes
;
820 par_dest
->mpi_nodes__set
= TRUE
;
822 #endif /* ENABLE_MPI */