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 Gerber van der Graaf
10 This file is part of gpiv.
12 Gpiv is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ----------------------------------------------------------------------*/
29 * (callback) functions for Piv evaluation window/tabulator
31 * Revision 1.8 2003-09-01 11:17:15 gerber
32 * improved monitoring of interrogation process
34 * Revision 1.7 2003/08/22 15:24:52 gerber
35 * interactive spatial scaling
37 * Revision 1.6 2003/07/13 14:38:18 gerber
38 * changed error handling of libgpiv
40 * Revision 1.5 2003/07/12 21:21:16 gerber
41 * changed error handling libgpiv
43 * Revision 1.3 2003/07/10 11:56:07 gerber
46 * Revision 1.2 2003/06/27 13:47:26 gerber
47 * display ruler, line/point evaluation
49 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
62 display_img(float **img
,
72 GnomeCanvasItem
**gci
,
79 alloc_bufmem_per_intarea(int index_y
,
84 /* --------------------------------------------------------------------
85 Memory allocation of covariance in a packed interrogation area array */
88 gpiv_piv_bounds_cov(&gpd
->cov
[index_y
][index_x
],
89 int_size_0
, image_par
);
91 gpd
->cov
[index_y
][index_x
].z
=
92 gpiv_matrix(gpd
->cov
[index_y
][index_x
].z_rl
,
93 gpd
->cov
[index_y
][index_x
].z_rh
,
94 gpd
->cov
[index_y
][index_x
].z_cl
,
95 gpd
->cov
[index_y
][index_x
].z_ch
);
98 * Memory allocation of interrogation area's
100 gpd
->intreg1
[index_y
][index_x
] =
101 gpiv_matrix(0, int_size_0
- 1, 0, int_size_0
- 1);
102 gpd
->intreg2
[index_y
][index_x
] =
103 gpiv_matrix(0, int_size_0
- 1, 0, int_size_0
- 1);
104 memset(gpd
->intreg1
[index_y
][index_x
][0], 0,
105 (sizeof(float)) * int_size_0
* int_size_0
);
106 memset(gpd
->intreg2
[index_y
][index_x
][0], 0,
107 (sizeof(float)) * int_size_0
* int_size_0
);
113 free_bufmem_per_intarea(int index_y
,
119 gpiv_piv_bounds_cov(&gpd
->cov
[index_y
][index_x
],
120 int_size_0
, image_par
);
122 gpiv_free_matrix(gpd
->cov
[index_y
][index_x
].z
,
123 gpd
->cov
[index_y
][index_x
].z_rl
,
124 gpd
->cov
[index_y
][index_x
].z_rh
,
125 gpd
->cov
[index_y
][index_x
].z_cl
,
126 gpd
->cov
[index_y
][index_x
].z_ch
);
128 gpiv_free_matrix(gpd
->intreg1
[index_y
][index_x
], 0, int_size_0
- 1,
131 gpiv_free_matrix(gpd
->intreg2
[index_y
][index_x
], 0, int_size_0
- 1,
134 gpd
->intreg1
[index_y
][index_x
] = NULL
;
135 gpd
->intreg2
[index_y
][index_x
] = NULL
;
141 * Piv evaluation window/tabulator callbacks
145 on_radiobutton_piv_mouse(GtkWidget
* widget
,
148 m_select
= atoi(gtk_object_get_data(GTK_OBJECT(widget
),
151 if (m_select
== NO_MS
) {
152 piv_eval_par
.int_geo
= AOI
;
153 } else if (m_select
== AOI_MS
) {
154 piv_eval_par
.int_geo
= AOI
;
155 } else if (m_select
== SINGLE_POINT_MS
) {
156 piv_eval_par
.int_geo
= POINT
;
157 } else if (m_select
== V_LINE_MS
) {
158 piv_eval_par
.int_geo
= LINE_C
;
159 } else if (m_select
== H_LINE_MS
) {
160 piv_eval_par
.int_geo
= LINE_R
;
161 } else if (m_select
== SINGLE_AREA_MS
||
162 m_select
== DRAG_MS
) {
163 piv_eval_par
.int_geo
= POINT
;
170 on_radiobutton_piv_mouse1_enter(GtkWidget
* widget
,
173 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
174 gchar
*msg
= _("No mouse activity within displayer");
175 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
180 on_radiobutton_piv_mouse2_enter(GtkWidget
* widget
,
183 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
184 gchar
*msg
= _("Selects an area within the image to be analyzed");
185 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
190 on_radiobutton_piv_mouse3_enter(GtkWidget
* widget
,
193 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
194 gchar
*msg
= _("Piv evaluation at a single interrogation area. "
195 "Conserves other existing data");
196 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
201 on_radiobutton_piv_mouse4_enter(GtkWidget
* widget
,
204 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
205 gchar
*msg
= _("Piv evaluation at a single point in the image. "
206 "Rejects all existing data!!");
207 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
212 on_radiobutton_piv_mouse5_enter(GtkWidget
* widget
,
215 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
216 gchar
*msg
= _("Displaces a single interrogation area and analyzes");
217 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
222 on_radiobutton_piv_mouse6_enter(GtkWidget
* widget
,
225 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
226 gchar
*msg
= _("Evaluation at a vertical line. ");
227 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
232 on_radiobutton_piv_mouse7_enter(GtkWidget
* widget
,
235 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
236 gchar
*msg
= _("Evaluation at a horizontal line. ");
237 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
242 on_spinbutton_piv_int(GtkSpinButton
* widget
,
245 char *err_msg
= NULL
;
246 PivEval
* eval
= gtk_object_get_data(GTK_OBJECT(widget
), "eval");
262 /* eval = gtk_object_get_data(GTK_OBJECT(widget), "eval"); */
266 /* Display display_act; */
267 /* display_act = gtk_object_get_data(widget, display_act); */
270 * Select which variable has to be modified
272 setby_spinbutton
= 1;
273 var_type
= atoi(gtk_object_get_data(GTK_OBJECT(widget
), "var_type"));
275 if (var_type
== COL_START
) {
276 piv_eval_par
.col_start
= gtk_spin_button_get_value_as_int(widget
);
278 } else if (var_type
== COL_END
) {
279 piv_eval_par
.col_end
= gtk_spin_button_get_value_as_int(widget
);
281 } else if (var_type
== PRE_SHIFT_COL
) {
282 piv_eval_par
.pre_shift_col
= gtk_spin_button_get_value_as_int(widget
);
284 } else if (var_type
== ROWSTART
) {
285 piv_eval_par
.row_start
= gtk_spin_button_get_value_as_int(widget
);
287 } else if (var_type
== ROWEND
) {
288 piv_eval_par
.row_end
= gtk_spin_button_get_value_as_int(widget
);
290 } else if (var_type
== PRESHIFTROW
) {
291 piv_eval_par
.pre_shift_row
= gtk_spin_button_get_value_as_int(widget
);
293 } else if (var_type
== INT_SIZE_1
) {
294 piv_eval_par
.int_size_1
= gtk_spin_button_get_value_as_int(widget
);
297 GTK_ADJUSTMENT(eval
->spinbutton_adj_intsize2
)->lower
=
298 (gfloat
) piv_eval_par
.int_size_1
;
299 GTK_ADJUSTMENT(eval
->spinbutton_adj_intsize2
)->upper
=
301 gtk_adjustment_changed (GTK_ADJUSTMENT(eval
->spinbutton_adj_intsize2
));
302 gtk_adjustment_set_value(GTK_ADJUSTMENT(eval
->spinbutton_adj_intsize2
),
303 (gfloat
) piv_eval_par
.int_size_1
);
306 * Adjust radio buttons for in. size 1
308 if (piv_eval_par
.int_size_1
== 16) {
309 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
310 (eval
->radiobutton_intsize1_2
),
313 } else if (piv_eval_par
.int_size_1
== 32) {
314 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
315 (eval
->radiobutton_intsize1_3
), TRUE
);
317 } else if (piv_eval_par
.int_size_1
== 64) {
318 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
319 (eval
->radiobutton_intsize1_4
), TRUE
);
320 } else if (piv_eval_par
.int_size_1
== 128) {
321 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
322 (eval
->radiobutton_intsize1_5
), TRUE
);
326 } else if (var_type
== INT_SIZE_2
) {
327 piv_eval_par
.int_size_2
= gtk_spin_button_get_value_as_int(widget
);
328 if (piv_eval_par
.int_size_2
> piv_eval_par
.int_size_1
) {
329 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
330 (eval
->checkbutton_zerooff
),
333 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
334 (eval
->checkbutton_zerooff
),
339 * Adjust radio buttons for in. size 2
341 if (piv_eval_par
.int_size_2
== 16) {
342 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
343 (eval
->radiobutton_intsize2_2
), TRUE
);
344 } else if (piv_eval_par
.int_size_2
== 32) {
345 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
346 (eval
->radiobutton_intsize2_3
), TRUE
);
347 } else if (piv_eval_par
.int_size_2
== 64) {
348 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
349 (eval
->radiobutton_intsize2_4
), TRUE
);
350 } else if (piv_eval_par
.int_size_2
== 128) {
351 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
352 (eval
->radiobutton_intsize2_5
), TRUE
);
355 } else if (var_type
== INT_SHIFT
) {
356 piv_eval_par
.int_shift
= gtk_spin_button_get_value_as_int(widget
);
358 if (piv_eval_par
.int_shift
== 8) {
359 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
360 (eval
->radiobutton_intshift_1
), TRUE
);
361 } else if (piv_eval_par
.int_shift
== 16) {
362 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
363 (eval
->radiobutton_intshift_2
), TRUE
);
364 } else if (piv_eval_par
.int_shift
== 32) {
365 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
366 (eval
->radiobutton_intshift_3
), TRUE
);
367 } else if (piv_eval_par
.int_shift
== 64) {
368 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
369 (eval
->radiobutton_intshift_4
), TRUE
);
370 } else if (piv_eval_par
.int_shift
== 128) {
371 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
372 (eval
->radiobutton_intshift_5
), TRUE
);
376 if (display_act
!= NULL
) {
377 nx
= display_act
->intreg
.data
.nx
;
378 ny
= display_act
->intreg
.data
.ny
;
380 gpiv_piv_count_pivdata_fromimage(&l_intreg
, image_par
,
382 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
386 * For some operations the intregs have to be renewed unconditionally,
387 * for others only in case if the number of intregs has been changed
389 if (var_type
== COL_START
|| var_type
== COL_END
390 || var_type
== ROWSTART
|| var_type
== ROWEND
) {
391 if (nx
== l_intreg
.nx
392 && ny
== l_intreg
.ny
) {
397 if (renew
== 1 && display_act
->display_intregs
== 1) {
398 destroy_all_intregs(display_act
);
399 create_all_intregs(display_act
);
402 setby_spinbutton
= 0;
408 on_radiobutton_piv_int(GtkWidget
* widget
,
411 gint int_size_1_tmp
, display_intregs_tmp
= 0,
412 nx_tmp
= 0, ny_tmp
= 0;
413 /* gint setby_spinbutton = atoi(gtk_object_get_data(GTK_OBJECT(widget), */
414 /* "setby_spinbutton")); */
415 PivEval
*eval
= gtk_object_get_data(GTK_OBJECT(widget
), "eval");
416 Display
*disp
= display_act
;
425 nx
= disp
->intreg
.data
.nx
;
426 ny
= disp
->intreg
.data
.ny
;
432 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
433 var_type
= atoi(gtk_object_get_data(GTK_OBJECT(widget
),
437 * Select which variable has to be modified
439 if (var_type
== SIZE_1
) {
440 int_size_1_tmp
= piv_eval_par
.int_size_1
;
441 piv_eval_par
.int_size_1
= atoi(gtk_object_get_data
445 * switch off d_intregs temporarly
448 display_intregs_tmp
= disp
->display_intregs
;
449 disp
->display_intregs
= 0;
453 adjust_radiobutton_piv_int(eval
, piv_eval_par
.int_size_1
);
456 * return d_intregs to original value
459 disp
->display_intregs
= display_intregs_tmp
;
464 * Reset weight and zero_off
466 if (piv_eval_par
.int_size_2
> int_size_1_tmp
) {
467 /* gtk_widget_set_sensitive(eval->checkbutton_zerooff, TRUE); */
468 /* gtk_widget_set_sensitive(checkbutton_piv_weightkernel, TRUE); */
469 if (zero_off_tmp
== 0) {
470 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
471 (eval
->checkbutton_zerooff
),
473 gtk_widget_set_sensitive(eval
->checkbutton_zerooff
, TRUE
);
474 gtk_widget_set_sensitive(eval
->checkbutton_weightkernel
,
476 if (weight_tmp
== 0) {
477 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
478 (eval
->checkbutton_weightkernel
),
480 gtk_widget_set_sensitive(eval
->checkbutton_zerooff
,
482 gtk_widget_set_sensitive(eval
->checkbutton_weightkernel
, TRUE
);
484 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
485 (eval
->checkbutton_weightkernel
),
487 gtk_widget_set_sensitive(eval
->checkbutton_zerooff
,
489 gtk_widget_set_sensitive(eval
->checkbutton_weightkernel
,
493 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
494 (eval
->checkbutton_zerooff
),
496 gtk_widget_set_sensitive(eval
->checkbutton_zerooff
, TRUE
);
497 gtk_widget_set_sensitive(eval
->checkbutton_weightkernel
,
503 * Also calls on_spinbutton_piv_int, which, on its turn, may call this function
504 * again resulting into an infinite loop
506 gtk_spin_button_set_value(GTK_SPIN_BUTTON
507 (eval
->spinbutton_intsize1
),
508 piv_eval_par
.int_size_1
);
511 } else if (var_type
== SIZE_2
) {
512 piv_eval_par
.int_size_2
= atoi(gtk_object_get_data(GTK_OBJECT(widget
),
518 gtk_adjustment_set_value(GTK_ADJUSTMENT
519 (eval
->spinbutton_adj_intsize2
),
520 (gfloat
) piv_eval_par
.int_size_2
);
522 * Save origanal settings of weight and zero_off for later resetting
524 if (piv_eval_par
.int_size_2
> piv_eval_par
.int_size_1
) {
525 zero_off_tmp
= piv_eval_par
.zero_off
;
526 weight_tmp
= piv_eval_par
.weight
;
527 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
528 (eval
->checkbutton_weightkernel
), FALSE
);
529 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
530 (eval
->checkbutton_zerooff
), TRUE
);
531 gtk_widget_set_sensitive(eval
->checkbutton_zerooff
, FALSE
);
535 * Reset weight and zero_off
538 if (zero_off_tmp
== 0) {
539 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
540 (eval
->checkbutton_zerooff
), FALSE
);
541 if (weight_tmp
== 0) {
542 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
543 (eval
->checkbutton_weightkernel
), FALSE
);
545 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
546 (eval
->checkbutton_weightkernel
), TRUE
);
549 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
550 (eval
->checkbutton_zerooff
), TRUE
);
552 gtk_widget_set_sensitive(eval
->checkbutton_zerooff
, TRUE
);
556 } else if (var_type
== SHIFT
) {
557 piv_eval_par
.int_shift
= atoi(gtk_object_get_data(GTK_OBJECT(widget
),
562 gtk_spin_button_set_value(GTK_SPIN_BUTTON
563 (eval
->spinbutton_intshift
),
564 piv_eval_par
.int_shift
);
567 if (disp
!= NULL
&& disp
->display_intregs
== 1) {
568 destroy_all_intregs(display_act
);
569 create_all_intregs(display_act
);
578 on_toggle_piv(GtkWidget
* widget
,
581 PivEval
* eval
= gtk_object_get_data(GTK_OBJECT(widget
), "eval");
592 * Select which variable has to be modified
594 var_type
= atoi(gtk_object_get_data(GTK_OBJECT(widget
), "var_type"));
596 if (var_type
== SCHEME
) {
597 piv_eval_par
.ifit
= atoi(gtk_object_get_data(GTK_OBJECT(widget
),
600 } else if (var_type
== PEAK_NR
) {
601 piv_eval_par
.peak
= atoi(gtk_object_get_data(GTK_OBJECT(widget
),
605 } else if (var_type
== WEIGHT
) {
606 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
607 piv_eval_par
.weight
= 1;
608 gtk_widget_set_sensitive(eval
->checkbutton_zerooff
, FALSE
);
609 gtk_widget_set_sensitive(eval
->checkbutton_centraldiff
, FALSE
);
611 * toggle adaptive interr and zero-off
614 piv_eval_par
.weight
= 0;
615 gtk_widget_set_sensitive(eval
->checkbutton_zerooff
, TRUE
);
616 gtk_widget_set_sensitive(eval
->checkbutton_centraldiff
, TRUE
);
620 } else if (var_type
== ZERO_OFF
) {
621 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
622 piv_eval_par
.zero_off
= 1;
623 gtk_widget_set_sensitive(eval
->checkbutton_weightkernel
, FALSE
);
625 piv_eval_par
.zero_off
= 0;
626 gtk_widget_set_sensitive(eval
->checkbutton_weightkernel
, TRUE
);
630 } else if (var_type
== CENTRAL_INT
) {
631 if (gtk_toggle_button_get_active
632 (GTK_TOGGLE_BUTTON(eval
->checkbutton_centraldiff
))) {
633 piv_eval_par
.central_diff
= 1;
635 piv_eval_par
.central_diff
= 0;
639 } else if (var_type
== CORRELATION
) {
640 image_par
.x_corr
= atoi(gtk_object_get_data(GTK_OBJECT(widget
),
649 adjust_radiobutton_piv_int(PivEval
* eval
,
653 * adjusting and disabling int_size_2 and its toggle buttons
657 /* if (int_size_1 == 8) { */
658 /* gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON */
659 /* (eval->radiobutton_intsize2_1), TRUE); */
660 /* } else */if (int_size_1
== 16) {
661 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
662 (eval
->radiobutton_intsize2_2
), TRUE
);
663 } else if (int_size_1
== 32) {
664 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
665 (eval
->radiobutton_intsize2_3
), TRUE
);
666 } else if (int_size_1
== 64) {
667 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
668 (eval
->radiobutton_intsize2_4
), TRUE
);
669 } else if (int_size_1
>= 128) {
670 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
671 (eval
->radiobutton_intsize2_5
), TRUE
);
675 if (int_size_1
<= 64) {
676 gtk_widget_set_sensitive(GTK_WIDGET(eval
->radiobutton_intsize2_4
),
678 if (int_size_1
<= 32) {
679 gtk_widget_set_sensitive(GTK_WIDGET
680 (eval
->radiobutton_intsize2_3
),
682 if (int_size_1
<= 16) {
683 gtk_widget_set_sensitive(GTK_WIDGET
684 (eval
->radiobutton_intsize2_2
),
686 /* if (int_size_1 <= 8) { */
687 /* gtk_widget_set_sensitive(GTK_WIDGET */
688 /* (eval->radiobutton_intsize2_1), */
697 if (int_size_1
>= 16) {
698 /* gtk_widget_set_sensitive(GTK_WIDGET(eval->radiobutton_intsize2_1), */
700 if (int_size_1
>= 32) {
701 gtk_widget_set_sensitive(GTK_WIDGET
702 (eval
->radiobutton_intsize2_2
),
704 if (int_size_1
>= 64) {
705 gtk_widget_set_sensitive(GTK_WIDGET
706 (eval
->radiobutton_intsize2_3
),
708 if (int_size_1
>= 128) {
709 gtk_widget_set_sensitive(GTK_WIDGET
710 (eval
->radiobutton_intsize2_4
),
722 on_checkbutton_piv_monitor_enter(GtkWidget
*widget
,
725 GpivConsole
* gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
727 _("Displays subimages, correlation function and PIV vector");
728 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
733 void on_checkbutton_piv_monitor(GtkWidget
* widget
, gpointer data
)
735 PivEval
* eval
= gtk_object_get_data(GTK_OBJECT(widget
), "eval");
738 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
739 piv_eval_par
.print_cov
= 1;
741 eval
->mon
.gci_vec_background
=
742 gnome_canvas_item_new(gnome_canvas_root
743 (GNOME_CANVAS(eval
->canvas_monitor_vec
)),
744 gnome_canvas_rect_get_type(),
747 "x2", (double) MAX_INTERR_SIZE
,
748 "y2", (double) MAX_INTERR_SIZE
,
749 "fill_color", "darkblue",
754 eval
->mon
.gci_int1_background
=
755 gnome_canvas_item_new(gnome_canvas_root
756 (GNOME_CANVAS(eval
->canvas_monitor_int1
)),
757 gnome_canvas_rect_get_type(),
760 "x2", (double) MAX_INTERR_SIZE
,
761 "y2", (double) MAX_INTERR_SIZE
,
762 "fill_color", "darkgreen",
767 eval
->mon
.gci_int2_background
=
768 gnome_canvas_item_new(gnome_canvas_root
769 (GNOME_CANVAS(eval
->canvas_monitor_int2
)),
770 gnome_canvas_rect_get_type(),
773 "x2", (double) MAX_INTERR_SIZE
,
774 "y2", (double) MAX_INTERR_SIZE
,
775 "fill_color", "darkgreen",
780 eval
->mon
.gci_background_cov
=
781 gnome_canvas_item_new(gnome_canvas_root
782 (GNOME_CANVAS(eval
->canvas_monitor_cov
)),
783 gnome_canvas_rect_get_type(),
786 "x2", (double) MAX_INTERR_SIZE
,
787 "y2", (double) MAX_INTERR_SIZE
,
788 "fill_color", "darkred",
792 piv_eval_par
.print_cov
= 0;
794 * Destroy intreg1 image
796 if (eval
->mon
.gci_int1_background
!= NULL
) {
797 gtk_object_destroy(GTK_OBJECT(eval
->mon
.
798 gci_int1_background
));
799 eval
->mon
.gci_int1_background
= NULL
;
803 if (eval
->mon
.rgbbuf_int1
!= NULL
) {
804 g_free(eval
->mon
.rgbbuf_int1
);
805 eval
->mon
.rgbbuf_int1
= NULL
;
808 if (eval
->mon
.gci_int1
!= NULL
) {
809 gtk_object_destroy(GTK_OBJECT(eval
->mon
.gci_int1
));
810 eval
->mon
.gci_int1
= NULL
;
814 * Destroy intreg2 image
816 if (eval
->mon
.gci_int2_background
!= NULL
) {
817 gtk_object_destroy(GTK_OBJECT(eval
->mon
.
818 gci_int2_background
));
819 eval
->mon
.gci_int2_background
= NULL
;
823 if (eval
->mon
.rgbbuf_int2
!= NULL
) {
824 g_free(eval
->mon
.rgbbuf_int2
);
825 eval
->mon
.rgbbuf_int2
= NULL
;
828 if (eval
->mon
.gci_int2
!= NULL
) {
829 gtk_object_destroy(GTK_OBJECT(eval
->mon
.gci_int2
));
830 eval
->mon
.gci_int2
= NULL
;
834 * Destroy correlation image
836 if (eval
->mon
.gci_background_cov
!= NULL
) {
837 gtk_object_destroy(GTK_OBJECT(eval
->mon
.gci_background_cov
));
838 eval
->mon
.gci_background_cov
= NULL
;
842 if (eval
->mon
.rgbbuf_cov
!= NULL
) {
843 g_free(eval
->mon
.rgbbuf_cov
);
844 eval
->mon
.rgbbuf_cov
= NULL
;
847 if (eval
->mon
.gci_cov
!= NULL
) {
848 gtk_object_destroy(GTK_OBJECT(eval
->mon
.gci_cov
));
849 eval
->mon
.gci_cov
= NULL
;
855 if (eval
->mon
.gci_vec_background
!= NULL
) {
856 gtk_object_destroy(GTK_OBJECT(eval
->mon
.gci_vec_background
));
857 eval
->mon
.gci_vec_background
= NULL
;
861 if (eval
->mon
.gci_vec
!= NULL
) {
862 gtk_object_destroy(GTK_OBJECT(eval
->mon
.gci_vec
));
863 eval
->mon
.gci_vec
= NULL
;
872 on_spinbutton_piv_monitor_zoom(GtkSpinButton
*widget
,
875 PivEval
* eval
= gtk_object_get_data(GTK_OBJECT(widget
), "eval");
876 /* gfloat piv_disproc_zoom */
878 gpiv_var
.piv_disproc_zoom
= gtk_spin_button_get_value_as_float(widget
);
879 gnome_config_set_float("zoom_factor", gpiv_var
.piv_disproc_zoom
);
882 eval
->mon
.affine
[0] = gpiv_var
.piv_disproc_zoom
;
883 eval
->mon
.affine
[3] = gpiv_var
.piv_disproc_zoom
;
884 eval
->mon
.affine
[4] =
885 (MAX_INTERR_SIZE
- gpiv_var
.piv_disproc_zoom
886 * piv_eval_par
.int_size_1
) /2.0;
887 eval
->mon
.affine
[5] =
888 (MAX_INTERR_SIZE
- gpiv_var
.piv_disproc_zoom
889 * piv_eval_par
.int_size_1
) /2.0;
891 if(eval
->mon
.gci_int1
!= NULL
) {
892 gnome_canvas_item_affine_absolute(eval
->mon
.gci_int1
,
896 if(eval
->mon
.gci_int2
!= NULL
) {
897 gnome_canvas_item_affine_absolute(eval
->mon
.gci_int2
,
902 if(eval
->mon
.gci_cov
!= NULL
) {
903 gnome_canvas_item_affine_absolute(eval
->mon
.gci_cov
,
911 on_spinbutton_piv_monitor_vectorscale(GtkSpinButton
*widget
,
914 PivEval
* eval
= gtk_object_get_data(GTK_OBJECT(widget
), "eval");
915 /* gint piv_disproc_vlength */
917 gpiv_var
.piv_disproc_vlength
= gtk_spin_button_get_value_as_int(widget
);
918 gnome_config_set_int("vector_length", gpiv_var
.piv_disproc_vlength
);
922 * Try to re-scale vector
924 if(eval
->mon
.gci_vec
!= NULL
) {
925 GnomeCanvasPoints
*points
= gnome_canvas_points_new(2);
927 points
->coords
[0] = MAX_INTERR_SIZE
/ 2;
928 points
->coords
[1] = MAX_INTERR_SIZE
/ 2;
929 points
->coords
[2] = MAX_INTERR_SIZE
/ 2 + eval
->mon
.pi_da
.dx
[0][0] *
930 gpiv_var
.piv_disproc_vlength
;
931 points
->coords
[3] = MAX_INTERR_SIZE
/ 2 + eval
->mon
.pi_da
.dy
[0][0] *
932 gpiv_var
.piv_disproc_vlength
;
934 gnome_canvas_item_set(eval
->mon
.gci_vec
,
938 gnome_canvas_points_free(points
);
945 on_button_piv_enter(GtkWidget
*widget
,
948 GpivConsole
* gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
949 gchar
*msg
= _("Analyses a PIV image (pair)");
950 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
955 on_button_piv(GtkWidget
* widget
,
957 /* -------------------------------------------------------------------
958 The actual calculation of particle image displacements */
960 GpivConsole
* gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
964 for (row
= gpiv
->first_selected_row
; row
<= gpiv
->last_selected_row
;
966 display_act
= gtk_clist_get_row_data(GTK_CLIST(gpiv
->clist_buf
),
968 ibuf
= display_act
->count
;
969 if (display
[ibuf
] != NULL
970 && display_act
->mwin
!= NULL
971 && GTK_WIDGET_VISIBLE(GTK_WIDGET(display_act
->mwin
)) ) {
972 gdk_window_show(GTK_WIDGET(display_act
->mwin
)->window
);
973 gdk_window_raise(GTK_WIDGET(display_act
->mwin
)->window
);
984 exec_piv(GpivConsole
* gpiv
)
986 char *err_msg
= NULL
;
987 char c_line
[MAX_LINES_C
][MAX_CHARS
];
988 int nc_lines
= 0, return_val
= 0;
989 char fname_piv
[MAX_CHARS
], fname_old_piv
[MAX_CHARS
], sdum
[MAX_CHARS
];
991 * Free memory of pivdata and clean the display from its vectors
993 if (display_act
->gpd
.exist_piv
) {
994 destroy_all_vectors(&display_act
->gpd
);
995 gpiv_free_pivdata (&display_act
->gpd
.piv_data
);
996 display_act
->gpd
.exist_piv
= FALSE
;
997 if (display_act
->gpd
.scaled_piv
) {
998 gpiv_free_pivdata(&display_act
->gpd
.piv_data_scaled
);
999 display_act
->gpd
.scaled_piv
= FALSE
;
1004 * Free eventually existing memory of vor_data and clean the display
1005 * as they does not belong to the piv data anymore
1007 free_post_bufmems(display_act
);
1009 if (display_act
->img
.exist_img
&& !cancel_process
) {
1010 exec_process
= TRUE
;
1013 * Reads old PIV data filemame.EXT_OLD for refined calculation
1015 /* TODO??: NOT IMPLEMENTED IN GUI */
1016 if (piv_eval_par
.old_piv
== 1) {
1017 if (!display_act
->gpd
.exist_piv
) {
1018 g_snprintf(fname_old_piv
, MAX_CHARS
, "%s%s", display_act
->fname_base
, EXT_OLD
);
1019 g_snprintf(fname_piv
, MAX_CHARS
, "%s%s", display_act
->fname_base
, EXT_PIV
);
1020 g_snprintf(sdum
, MAX_CHARS
, "mv %s %s", fname_piv
, fname_old_piv
);
1022 if ((return_val
= gpiv_fcount_pivdata(fname_old_piv
, &display_act
->gpd
.piv_data
))
1024 gpiv_error(_("Failure calling gpiv_count_pivdata for %s"),
1030 gpiv_piv_count_pivdata_fromimage(&display_act
->gpd
.piv_data
,
1031 image_par
, piv_eval_par
))
1032 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
1036 * Set mouse selection to None
1038 if (m_select
== SINGLE_POINT_MS
1039 || m_select
== SINGLE_AREA_MS
1040 || m_select
== DRAG_MS
) {
1041 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1042 (gpiv
->piveval
->radiobutton_mouse_1
),
1047 * Allocating memory for output data, now the number of points are
1048 * known (from old piv data or from the area of interest within the image
1049 * and interrogation area sizes)
1052 /* if (m_select != SINGLE_AREA_MS || */
1053 /* (m_select == SINGLE_AREA_MS && ) { */
1055 gpiv_alloc_pivdata(&display_act
->gpd
.piv_data
);
1056 display_act
->gpd
.exist_piv
= TRUE
;
1059 if (piv_eval_par
.old_piv
== 1) {
1061 gpiv_fread_pivdata(fname_old_piv
, &display_act
->gpd
.piv_data
,
1063 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
1066 /* gpiv_write_pivdata(oldpiv_data, c_line, 0, 0, RCSID); */
1069 * Determine locations of Interrogation Area's
1071 if (piv_eval_par
.old_piv
!= 1 &&
1072 m_select
!= SINGLE_AREA_MS
&&
1073 m_select
!= SINGLE_POINT_MS
&&
1074 m_select
!= DRAG_MS
) {
1076 gpiv_piv_select_int_point(&display_act
->gpd
.piv_data
,
1077 image_par
, piv_eval_par
))
1078 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
1080 /* fprintf (stderr, "%s:: returned from gpiv_piv_select_int_point\n", function_name); */
1081 /* fprintf (stderr, "%s:: display_act->gpd.point_x = %f display_act->gpd.point_y = %f\n", */
1082 /* function_name, display_act->gpd.piv_data.point_x[0][0], */
1083 /* display_act->gpd.piv_data.point_y[0][0]); */
1087 interrogate(&display_act
->gpd
.piv_data
, display_act
->img
.img1
,
1088 display_act
->img
.img2
, gpiv
);
1094 * Copy parameters in Buffer structure for saving and, eventual, later use
1096 copy_img_par(image_par
, &display_act
->img
.image_par
, TRUE
, FALSE
);
1097 copy_piv_par(piv_eval_par
, &display_act
->gpd
.piv_eval_par
, TRUE
,
1099 exec_process
= FALSE
;
1103 _("At first, open an image. "
1104 "Than we'll further see what will happen.");
1105 g_warning(msg_error
);
1106 gtk_warning(msg_error
);
1114 interrogate(PivData
* piv_data
,
1115 unsigned char **img1
,
1116 unsigned char **img2
,
1118 /* --------------------------------------------------------------------
1119 PIV analyses of an image pair */
1121 char *err_msg
= NULL
;
1122 /* #define EXT_PIV ".piv" */
1124 int index_x
= 0, index_y
= 0, int_size_0
, fname_logic
= 1;
1125 gfloat progres_value
;
1126 gchar progres_string
[MAX_CHARS
];
1128 unsigned char **img1_ACT
= NULL
, **img2_ACT
= NULL
;
1129 ImagePar image_par_ACT
;
1130 PivEvalPar piv_eval_par_ACT
;
1131 PivData piv_data_ACT
/* = *piv_data */;
1133 /* Covariance *cov = display_act->gpd.cov; */
1134 int sweep
= 1, sweep_last
= 0, exit_while
= 0,
1136 char *fftwis
, *fftwis_inv
;
1140 * Testing parameters on consistency and initializing derived
1141 * parameters/variables
1144 gpiv_piv_test_parameter(&image_par
, &piv_eval_par
, fname_logic
))
1145 != NULL
) gpiv_error ("%s: %s", RCSID
, err_msg
);
1147 copy_img_par(image_par
, &image_par_ACT
, TRUE
, FALSE
);
1148 copy_piv_par(piv_eval_par
, &piv_eval_par_ACT
, TRUE
, FALSE
);
1150 if (piv_eval_par_ACT
.ad_int
== 1) {
1151 piv_eval_par_ACT
.int_size_1
= piv_eval_par
.int_size_2
;
1153 piv_eval_par_ACT
.int_size_1
= piv_eval_par
.int_size_1
;
1158 if (piv_eval_par
.zero_off
|| piv_eval_par
.ad_int
) {
1160 /* piv_eval_par_ACT.ifit = 0; */
1163 /* piv_eval_par_ACT.ifit = piv_eval_par.ifit; */
1168 * Reads eventually existing fftw wisdom
1170 fftwis
= gpiv_fread_fftw_wisdom(1);
1171 fftwis_inv
= gpiv_fread_fftw_wisdom(-1);
1175 * Scanning int. area(s)
1177 while ((!cancel_process
1178 && piv_eval_par
.zero_off
!= 1 && sweep
<= 1)
1179 || (piv_eval_par
.zero_off
== 1 && piv_eval_par_ACT
.ad_int
!= 1 &&
1181 || (piv_eval_par_ACT
.ad_int
== 1 && exit_while
== 0 )) {
1182 /* (piv_eval_par_ACT.ad_int == 1 && */
1183 /* piv_eval_par_ACT.int_size_2*cmpr_fact >= */
1184 /* piv_eval_par.int_size_1)) { */
1187 /* gpiv_img_print_header("", image_par_ACT); */
1188 /* gpiv_piv_print_parameters("EVAL.", piv_eval_par_ACT); */
1189 int_size_0
= ZEROPAD_FACT
* piv_eval_par_ACT
.int_size_2
;
1192 if (m_select
!= SINGLE_AREA_MS
&& m_select
!= DRAG_MS
) {
1193 destroy_all_vectors(&display_act
->gpd
);
1194 gnome_canvas_update_now(GNOME_CANVAS(display_act
->canvas
));
1199 * cleans drawing areas for displaying interrogation areas
1201 /* if (print_cov == 1) { */
1202 /* memset(graybuf_int1, 215, */
1203 /* (sizeof(guchar)) * (MAX_INTERR_SIZE * MAX_INTERR_SIZE)); */
1204 /* memset(graybuf_int2, 215, */
1205 /* (sizeof(guchar)) * (MAX_INTERR_SIZE * MAX_INTERR_SIZE)); */
1206 /* memset(graybuf_cov, 215, */
1207 /* (sizeof(guchar)) * (MAX_INTERR_SIZE * MAX_INTERR_SIZE)); */
1213 * Analyze at a single point
1215 if (piv_eval_par_ACT
.int_geo
== POINT
1216 || m_select
== SINGLE_AREA_MS
1217 || m_select
== SINGLE_POINT_MS
1218 || m_select
== DRAG_MS
) {
1220 img1_ACT
= &img1
[0];
1221 img2_ACT
= &img2
[0];
1222 piv_data_ACT
= *piv_data
;
1226 * Weight kernel for single int.area
1228 gpiv_piv_bounds_cov(&w_k
, int_size_0
, image_par_ACT
);
1229 w_k
.z
= gpiv_matrix(w_k
.z_rl
, w_k
.z_rh
, w_k
.z_cl
, w_k
.z_ch
);
1230 if (piv_eval_par
.weight
== 1) {
1231 gpiv_piv_weight_kernel_lin(&w_k
, int_size_0
);
1233 gpiv_piv_weight_kernel_1(&w_k
);
1236 alloc_bufmem_per_intarea(m_select_index_y
, m_select_index_x
,
1237 &display_act
->gpd
, image_par_ACT
,
1242 * Piv evaluation of ** A SINGLE** interrogation area
1245 gpiv_piv_eval_int_reg(m_select_index_y
,
1249 display_act
->gpd
.intreg1
[m_select_index_y
][m_select_index_x
],
1250 display_act
->gpd
.intreg2
[m_select_index_y
][m_select_index_x
],
1251 &display_act
->gpd
.cov
[m_select_index_y
][m_select_index_x
],
1260 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
1264 * Printing the progress of processing
1267 100 * (index_y
* piv_data
->nx
+ index_x
+
1268 1) / (piv_data
->nx
* piv_data
->ny
);
1269 if (piv_eval_par
.zero_off
&& piv_eval_par
.ad_int
) {
1270 g_snprintf(progres_string
, MAX_CHARS
,
1272 "(int. size = %d): "
1275 piv_eval_par_ACT
.int_size_2
,
1276 (gint
) progres_value
);
1277 } else if (piv_eval_par
.zero_off
&& piv_eval_par
.ad_int
== 0) {
1278 g_snprintf(progres_string
, MAX_CHARS
,
1282 (gint
) progres_value
);
1284 g_snprintf(progres_string
, MAX_CHARS
,
1286 (gint
) progres_value
);
1289 while (g_main_iteration(FALSE
));
1290 gtk_progress_set_value(gnome_appbar_get_progress
1291 (GNOME_APPBAR(gpiv
->appbar
)),
1293 gnome_appbar_push(GNOME_APPBAR(gpiv
->appbar
),
1298 * display piv values, draw interrogation areas and covariance function
1299 * WATCH OUT WITH CMPR!!
1301 if (piv_eval_par
.print_cov
== 1) {
1302 display_piv_vector(m_select_index_y
, m_select_index_x
,
1303 display_act
->gpd
.piv_data
,
1305 display_img_intreg1(display_act
->gpd
.intreg1
[m_select_index_y
]
1307 piv_eval_par_ACT
.int_size_2
,
1309 display_img_intreg2(display_act
->gpd
.intreg2
[m_select_index_y
]
1311 piv_eval_par_ACT
.int_size_2
,
1313 display_img_cov(&display_act
->gpd
.cov
[m_select_index_y
]
1315 piv_eval_par_ACT
.int_size_2
,
1319 free_bufmem_per_intarea(m_select_index_y
, m_select_index_x
,
1320 &display_act
->gpd
, image_par_ACT
, int_size_0
);
1324 * Anlyze at a grid of points within the Area Of Interest
1329 * Speedup the process
1334 * Free memory of pivdata and clean the display from its vectors
1337 /* if (display_act->gpd.exist_display_act->gpd.intregs) { */
1338 /* destroy_all_intregs1(&display_act->gpd); */
1339 /* destroy_all_intregs2(&display_act->gpd); */
1340 /* free_intregs(&display_act->gpd.intregs); */
1341 /* display_act->gpd.exist_intregs = FALSE; */
1342 /* display_act->display_intregs = 0; */
1345 * SPEEDUP PROCEDURES
1347 /* if (piv_eval_par.zero_off) { */
1348 /* if (piv_eval_par.int_shift < piv_eval_par.int_size_2) { */
1349 /* speedup_ishi(&image_par_ACT,
1350 piv_eval_par_ACT, &piv_eval_par_ACT, */
1351 /* piv_data, &piv_data_ACT, sweep, sweep_last); */
1354 /* Enable/disable in combination with speedup_ishi */
1355 /* piv_data_ACT = *piv_data; */
1358 /* speedup_cmpr(img1, &img1_ACT, img2, &img2_ACT, image_par, */
1359 /* &image_par_ACT, piv_eval_par, &piv_eval_par_ACT, */
1360 /* &piv_data_ACT, &cmpr_fact, &int_size_0, sweep, sweep_last); */
1362 /* Enable when switched off speedup_cmpr: */
1363 /* img1_ACT = &img1[0]; */
1364 /* img2_ACT = &img2[0]; */
1367 img1_ACT
= &img1
[0];
1368 img2_ACT
= &img2
[0];
1369 piv_data_ACT
= *piv_data
;
1374 * SPEEDUP PROCEDURES END
1377 /* gpiv_piv_count_pivdata_fromimage(&display_act->gpd.intregs, */
1378 /* image_par_ACT, */
1379 /* piv_eval_par_ACT); */
1380 /* g_warning("intregs.nx=%d intregs.ny=%d\n", */
1381 /* display_act->gpd.intregs.nx, display_act->gpd.intregs.ny); */
1382 /* gpiv_alloc_scdata(&display[ibuf].intregs); */
1383 /* display_act->gpd.exist_intregs = TRUE; */
1384 /* gpiv_piv_select_int_point(&display_act->gpd.intregs, image_par_ACT, */
1385 /* piv_eval_par_ACT); */
1386 /* create_all_intregs1(&display_act->gpd); */
1387 /* create_all_intregs2(&display_act->gpd); */
1390 gpiv_piv_bounds_cov(&w_k
, int_size_0
, image_par_ACT
); /* piv_eval_par_ACT.int_size_2 ?? */
1391 w_k
.z
= gpiv_matrix(w_k
.z_rl
, w_k
.z_rh
, w_k
.z_cl
, w_k
.z_ch
);
1393 if (piv_eval_par
.weight
== 1) {
1394 gpiv_piv_weight_kernel_lin(&w_k
, int_size_0
);
1396 gpiv_piv_weight_kernel_1(&w_k
);
1403 /* if (piv_eval_par.zero_off && sweep_last == 1) { */
1404 /* gpiv_img_print_header(image_par_ACT); */
1405 /* gpiv_piv_print_parameters(piv_eval_par_ACT); */
1408 for (index_y
= 0; index_y
< piv_data_ACT
.ny
; index_y
++) {
1409 for (index_x
= 0; index_x
< piv_data_ACT
.nx
; index_x
++) {
1410 if (cancel_process
) break;
1411 alloc_bufmem_per_intarea(index_y
, index_x
, &display_act
->gpd
,
1412 image_par_ACT
, int_size_0
);
1417 * Printing the progress of processing
1420 100 * (index_y
* piv_data
->nx
+ index_x
+
1421 1) / (piv_data
->nx
* piv_data
->ny
);
1422 if (piv_eval_par
.zero_off
&& piv_eval_par
.ad_int
) {
1423 g_snprintf(progres_string
, MAX_CHARS
,
1425 "(int. size = %d): "
1428 piv_eval_par_ACT
.int_size_2
,
1429 (gint
) progres_value
);
1430 } else if (piv_eval_par
.zero_off
&& piv_eval_par
.ad_int
== 0) {
1431 g_snprintf(progres_string
, MAX_CHARS
,
1435 (gint
) progres_value
);
1437 g_snprintf(progres_string
, MAX_CHARS
,
1439 (gint
) progres_value
);
1442 while (g_main_iteration(FALSE
));
1443 gtk_progress_set_value(gnome_appbar_get_progress
1444 (GNOME_APPBAR(gpiv
->appbar
)),
1446 gnome_appbar_push(GNOME_APPBAR(gpiv
->appbar
),
1451 * Evaluates an interrogation area.
1452 * In the call int_size_1 might be defined equal to
1453 * piv_eval_par_ACT.int_size_2 as well;
1454 * this will reduce the snr during interrogation
1458 gpiv_piv_eval_int_reg(index_y
,
1462 display_act
->gpd
.intreg1
[index_y
][index_x
],
1463 display_act
->gpd
.intreg2
[index_y
][index_x
],
1464 &display_act
->gpd
.cov
[index_y
][index_x
],
1473 != NULL
) gpiv_error ("%s: %s", RCSID
, err_msg
);
1477 * Check on validity of data
1479 if (isnan(/* (double) */ display_act
->gpd
.piv_data
.dx
[index_y
][index_x
]) != 0
1480 || isnan(/* (double) */ display_act
->gpd
.piv_data
.dy
[index_y
][index_x
]) != 0) {
1481 display_act
->gpd
.piv_data
.dx
[index_y
][index_x
] = 0.0;
1482 display_act
->gpd
.piv_data
.dy
[index_y
][index_x
] = 0.0;
1483 display_act
->gpd
.piv_data
.snr
[index_y
][index_x
] = 99.9;
1484 display_act
->gpd
.piv_data
.peak_no
[index_y
][index_x
] = -1;
1489 /* printf("sweep =%d x=%f y=%f\n", sweep, */
1490 /* piv_data_ACT.point_x[index_y][index_x], */
1491 /* piv_data_ACT.point_y[index_y][index_x]); */
1494 * Only draw the vectors for last sweep
1498 /* while (!(my_in=getchar())) sleep(10); */
1499 /* fprintf(stderr, "interrogate:: i=%d j=%d x=%f y=%f dx=%f dy=%f\n", */
1500 /* index_y, index_x, */
1501 /* piv_data_ACT.point_x[index_y][index_x], */
1502 /* piv_data_ACT.point_y[index_y][index_x], */
1503 /* piv_data_ACT.dx[index_y][index_x], */
1504 /* piv_data_ACT.dy[index_y][index_x]); */
1506 /* if ( buf->gci_vector[index_y][index_x] == NULL) { */
1508 display_vector(index_y
, index_x
, &display_act
->gpd
);
1512 /* update_vector(index_y, index_x, &display_act->gpd); */
1515 /* if (display_act->gpd.exist_intregs) { */
1516 /* update_intreg2(index_y, index_x, &display_act->gpd); */
1517 /* update_intreg1(index_y, index_x, &display_act->gpd); */
1523 * Draw interrogation areas, covariance function, display piv vector
1524 * WATCH OUT WITH CMPR!!
1526 if (piv_eval_par
.print_cov
== 1) {
1527 display_piv_vector(index_y
,
1529 display_act
->gpd
.piv_data
,
1531 display_img_intreg1(display_act
->gpd
.intreg1
[index_y
][index_x
],
1532 piv_eval_par_ACT
.int_size_2
,
1534 display_img_intreg2(display_act
->gpd
.intreg2
[index_y
][index_x
],
1535 piv_eval_par_ACT
.int_size_2
,
1537 display_img_cov(&display_act
->gpd
.cov
[index_y
][index_x
],
1538 piv_eval_par_ACT
.int_size_2
,
1544 * Freeing memory; **Disable** to keep data with print_cov for viewing later
1546 /* => to exec_piv */
1549 free_bufmem_per_intarea(index_y
, index_x
,
1551 image_par_ACT
, int_size_0
);
1554 /* fprintf(stderr, "\n::i=%d j=%d zero_off=%d ad_int=%d int_size_1=%d" */
1555 /* "piv_eval_par_ACT.int_size_2=%d int_size_0=%d sweep=%d\n", */
1556 /* index_y, index_x, piv_eval_par.zero_off, */
1557 /* piv_eval_par.ad_int, piv_eval_par_ACT.int_size_1, */
1558 /* piv_eval_par_ACT.int_size_2, int_size_0, sweep); */
1567 * Once allocated for entire image: should be freed for new int area size
1569 gpiv_free_matrix(w_k
.z
, w_k
.z_rl
, w_k
.z_rh
, w_k
.z_cl
, w_k
.z_ch
);
1573 * Adjust piv_eval_par_ACT.int_size_2 in case int_size_1 is not a power of two
1576 if (piv_eval_par_ACT
.ad_int
== 1) {
1577 /* fprintf(stderr, "\n::int_size_1=%d int_size_1_ACT=%d" */
1578 /* "piv_eval_par.int_size_2_ACT=%d cmpr_fact=%d", */
1579 /* piv_eval_par.int_size_1, piv_eval_par_ACT.int_size_1, */
1580 /* piv_eval_par_ACT.int_size_2, cmpr_fact); */
1581 if (sweep_last
== 1) exit_while
= 1;
1582 if (piv_eval_par_ACT
.int_size_2
*cmpr_fact
/2 == piv_eval_par
.int_size_1
||
1583 piv_eval_par_ACT
.int_size_2
*cmpr_fact
/4 < piv_eval_par
.int_size_1
) {
1584 piv_eval_par_ACT
.int_size_1
= piv_eval_par
.int_size_1
/ cmpr_fact
;
1585 piv_eval_par_ACT
.int_size_2
= piv_eval_par
.int_size_1
/ cmpr_fact
;
1588 piv_eval_par_ACT
.int_size_1
= piv_eval_par_ACT
.int_size_2
/ 2;
1589 piv_eval_par_ACT
.int_size_2
= piv_eval_par_ACT
.int_size_2
/ 2;
1593 if (piv_eval_par
.zero_off
== 1 && piv_eval_par_ACT
.ad_int
!= 1) {
1598 if (sweep
== MAX_SWEEP
) {
1600 piv_eval_par_ACT
.ifit
= piv_eval_par
.ifit
;
1602 /* fprintf(stderr, "\n"); */
1603 /* fprintf(stderr, "\n"); */
1610 * Writes existing fftw wisdom
1612 gpiv_fwrite_fftw_wisdom(1, fftwis
);
1613 gpiv_fwrite_fftw_wisdom(-1, fftwis_inv
);
1616 display_act
->gpd
.scaled_piv
= FALSE
;
1617 display_act
->gpd
.saved_piv
= FALSE
;
1618 /* display_act->display_piv = TRUE; */
1620 /* gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(viewmenu_uiinfo[5].widget), TRUE); */
1622 display_act
->gpd
.exist_cov
= TRUE
;
1624 /* gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(viewmenu_uiinfo[6].widget), TRUE); */
1632 * Display functions in PIV tabulator canvas
1637 display_piv_vector(gint i
,
1641 /* ------------------------- Displays values in PIV tabulator of the GUI */
1643 /* float **dx = piv_data.dx, **dy = piv_data.dy; */
1644 /* int **peak_no = piv_data.peak_no; */
1645 GnomeCanvasPoints
*points
;
1647 points
= gnome_canvas_points_new(2);
1649 eval
->mon
.pi_da
.dx
[0][0] = piv_data
.dx
[i
][j
];
1650 eval
->mon
.pi_da
.dy
[0][0] = piv_data
.dy
[i
][j
];
1651 eval
->mon
.pi_da
.peak_no
[0][0] = piv_data
.peak_no
[i
][j
];
1653 if (eval
->mon
.pi_da
.peak_no
[0][0] == -1) {
1655 } else if (eval
->mon
.pi_da
.peak_no
[0][0] == 0) {
1657 } else if (eval
->mon
.pi_da
.peak_no
[0][0] == 1) {
1659 } else if (eval
->mon
.pi_da
.peak_no
[0][0] == 2) {
1662 /* if (eval->mon.pi_da.peak_no[i][j] == 3) */
1666 points
->coords
[0] = MAX_INTERR_SIZE
/ 2;
1667 points
->coords
[1] = MAX_INTERR_SIZE
/ 2;
1668 points
->coords
[2] = MAX_INTERR_SIZE
/ 2 + eval
->mon
.pi_da
.dx
[0][0]
1669 * gpiv_var
.piv_disproc_vlength
;
1670 points
->coords
[3] = MAX_INTERR_SIZE
/ 2 + eval
->mon
.pi_da
.dy
[0][0]
1671 * gpiv_var
.piv_disproc_vlength
;
1674 if (eval
->mon
.gci_vec
!= NULL
) {
1675 gnome_canvas_item_set(eval
->mon
.gci_vec
,
1677 "fill_color", color
,
1678 "width_units", (double) THICKNESS
,
1679 "first_arrowhead", FALSE
,
1680 "last_arrowhead", TRUE
,
1681 "arrow_shape_a", (double) ARROW_LENGTH
,
1682 "arrow_shape_b", (double) ARROW_EDGE
,
1683 "arrow_shape_c", (double) ARROW_WIDTH
,
1687 gnome_canvas_item_new(gnome_canvas_root
1688 (GNOME_CANVAS(eval
->canvas_monitor_vec
)),
1689 gnome_canvas_line_get_type(),
1691 "fill_color", color
,
1692 "width_units",(double) THICKNESS
,
1693 "first_arrowhead", TRUE
,
1694 "arrow_shape_a", (double) THICKNESS
,
1700 gnome_canvas_points_free(points
);
1705 display_img_intreg1(float **intreg1
,
1708 /* -------- Displays image of intreg1 for drawing area */
1709 /* -------------------------------------------------------------------
1710 * intreg1 in gnome canvas
1711 * row stride; each row is a 4-byte buffer array
1714 display_img(intreg1
,
1716 &eval
->mon
.int_size_old
,
1721 eval
->mon
.rgb_int_width
,
1722 eval
->mon
.rgbbuf_int1
,
1723 eval
->canvas_monitor_int1
,
1724 &eval
->mon
.gci_int1
,
1731 void display_img_intreg2(float **intreg2
,
1734 /* ------------------------- Displays image of intreg2 for drawing area */
1736 display_img(intreg2
,
1738 &eval
->mon
.int_size_old
,
1743 eval
->mon
.rgb_int_width
,
1744 eval
->mon
.rgbbuf_int2
,
1745 eval
->canvas_monitor_int2
,
1746 &eval
->mon
.gci_int2
,
1754 void display_img_cov(Covariance
* cov
,
1757 /* ------------------------- Displays image of intreg1 for drawing area */
1761 &eval
->mon
.cov_size_old
,
1766 eval
->mon
.rgb_cov_width
,
1767 eval
->mon
.rgbbuf_cov
,
1768 eval
->canvas_monitor_cov
,
1777 display_img(float **img
,
1787 GnomeCanvasItem
**gci
,
1792 /* -------------------------------------------------------------------
1793 * Displaying routine in gnome canvas
1797 float min
= 1000. ,max
= -1000.;
1799 GdkPixbuf
*pixbuf
= NULL
;
1803 if (*int_size_old
!= i_max
- i_min
&& rgbbuf
!= NULL
) {
1808 if (rgbbuf
== NULL
) {
1810 * row stride; each row is a 4-byte buffer array
1812 rgb_width
= (i_max
- i_min
) * 3;
1813 while ((rgb_width
) % 4 != 0) {
1817 rgbbuf
= g_malloc(rgb_width
* 3 * (j_max
- j_min
));
1822 gtk_object_destroy(GTK_OBJECT(*gci
));
1827 /*---------------------------------------*/
1828 pixbuf
= gdk_pixbuf_new_from_data(rgbbuf
,
1840 *gci
= gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS
1842 gnome_canvas_pixbuf_get_type (),
1847 affine
[4] = (MAX_INTERR_SIZE
- gpiv_var
.piv_disproc_zoom
1849 affine
[5] = (MAX_INTERR_SIZE
- gpiv_var
.piv_disproc_zoom
1851 gnome_canvas_item_affine_absolute(*gci
, affine
);
1853 /*---------------------------------------*/
1857 * As the mean has been substracted from the image data, values have to be
1861 for (j
= j_min
; j
< j_max
; j
++) {
1862 for (i
= i_min
; i
< i_max
; i
++) {
1863 if (img
[j
][i
] < min
)
1865 if (img
[j
][i
] > max
)
1871 for (j
= j_min
; j
< j_max
; j
++) {
1872 for (i
= i_min
; i
< i_max
; i
++) {
1874 img
[j
][i
] = (255.0 / (max
- min
)) * img
[j
][i
];
1875 *pos
++ = (unsigned char) img
[j
][i
];
1876 *pos
++ = (unsigned char) img
[j
][i
];
1877 *pos
++ = (unsigned char) img
[j
][i
];
1886 for (j
= j_min
; j
< j_max
; j
++) {
1887 for (i
= i_min
; i
< i_max
; i
++) {
1888 if (img
[j
][i
] < min
)
1893 /* if ( min < display_act->img.img_mean) */
1894 /* display_act->img.img_mean = min; */
1898 for (j
= j_min
; j
< j_max
; j
++) {
1899 for (i
= i_min
; i
< i_max
; i
++) {
1900 *pos
++ = (unsigned char) img
[j
][i
] - (unsigned char) min
1901 + (unsigned char) display_act
->img
.img_mean
;
1902 *pos
++ = (unsigned char) img
[j
][i
] - (unsigned char) min
1903 + (unsigned char) display_act
->img
.img_mean
;
1904 *pos
++ = (unsigned char) img
[j
][i
] - (unsigned char) min
1905 + (unsigned char) display_act
->img
.img_mean
;
1911 gdk_pixbuf_unref (pixbuf
);
1912 *int_size_old
= int_size
;