added man page
[gpiv.git] / src / piveval.c
blob0e32ac230db3742c602f28e8200bab9bf7575835
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
6 libraries.
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)
15 any later version.
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
30 * $Log: piveval.c,v $
31 * Revision 1.3 2003-07-10 11:56:07 gerber
32 * added man page
34 * Revision 1.2 2003/06/27 13:47:26 gerber
35 * display ruler, line/point evaluation
37 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
38 * Imported gpiv
43 #include "gpiv_gtk.h"
44 #include "utils.h"
45 #include "piveval.h"
46 #include "display.h"
49 static void
50 alloc_bufmem_per_intarea(int index_y,
51 int index_x,
52 GpivData * gpd,
53 ImagePar image_par,
54 int int_size_0)
55 /* --------------------------------------------------------------------
56 Memory allocation of covariance in a packed interrogation area array */
59 gpiv_piv_bounds_cov(&gpd->cov[index_y][index_x],
60 int_size_0, image_par);
62 gpd->cov[index_y][index_x].z =
63 gpiv_matrix(gpd->cov[index_y][index_x].z_rl,
64 gpd->cov[index_y][index_x].z_rh,
65 gpd->cov[index_y][index_x].z_cl,
66 gpd->cov[index_y][index_x].z_ch);
69 * Memory allocation of interrogation area's
71 gpd->intreg1[index_y][index_x] =
72 gpiv_matrix(0, int_size_0 - 1, 0, int_size_0 - 1);
73 gpd->intreg2[index_y][index_x] =
74 gpiv_matrix(0, int_size_0 - 1, 0, int_size_0 - 1);
75 memset(gpd->intreg1[index_y][index_x][0], 0,
76 (sizeof(float)) * int_size_0 * int_size_0);
77 memset(gpd->intreg2[index_y][index_x][0], 0,
78 (sizeof(float)) * int_size_0 * int_size_0);
83 static void
84 free_bufmem_per_intarea(int index_y,
85 int index_x,
86 GpivData * gpd,
87 ImagePar image_par,
88 int int_size_0)
90 gpiv_piv_bounds_cov(&gpd->cov[index_y][index_x],
91 int_size_0, image_par);
93 gpiv_free_matrix(gpd->cov[index_y][index_x].z,
94 gpd->cov[index_y][index_x].z_rl,
95 gpd->cov[index_y][index_x].z_rh,
96 gpd->cov[index_y][index_x].z_cl,
97 gpd->cov[index_y][index_x].z_ch);
99 gpiv_free_matrix(gpd->intreg1[index_y][index_x], 0, int_size_0 - 1,
100 0, int_size_0 - 1);
102 gpiv_free_matrix(gpd->intreg2[index_y][index_x], 0, int_size_0 - 1,
103 0, int_size_0 - 1);
105 gpd->intreg1[index_y][index_x] = NULL;
106 gpd->intreg2[index_y][index_x] = NULL;
112 * Piv evaluation window/tabulator callbacks
115 void
116 on_radiobutton_piv_mouse(GtkWidget * widget,
117 gpointer data)
119 m_select = atoi(gtk_object_get_data(GTK_OBJECT(widget),
120 "mouse_select"));
122 if (m_select == NO_MS) {
123 piv_eval_par.int_geo = AOI;
124 } else if (m_select == AOI_MS) {
125 piv_eval_par.int_geo = AOI;
126 } else if (m_select == SINGLE_POINT_MS) {
127 piv_eval_par.int_geo = POINT;
128 } else if (m_select == VLINE_MS) {
129 piv_eval_par.int_geo = LINE_C;
130 } else if (m_select == HLINE_MS) {
131 piv_eval_par.int_geo = LINE_R;
132 } else if (m_select == SINGLE_AREA_MS ||
133 m_select == DRAG_MS) {
134 piv_eval_par.int_geo = POINT;
140 void
141 on_radiobutton_piv_mouse1_enter(GtkWidget * widget,
142 gpointer data)
144 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
145 gchar *msg = _("No mouse activity within displayer");
146 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
150 void
151 on_radiobutton_piv_mouse2_enter(GtkWidget * widget,
152 gpointer data)
154 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
155 gchar *msg = _("Selects an area within the image to be analyzed");
156 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
160 void
161 on_radiobutton_piv_mouse3_enter(GtkWidget * widget,
162 gpointer data)
164 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
165 gchar *msg = _("Piv evaluation at a single interrogation area. "
166 "Conserves other existing data");
167 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
171 void
172 on_radiobutton_piv_mouse4_enter(GtkWidget * widget,
173 gpointer data)
175 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
176 gchar *msg = _("Piv evaluation at a single point in the image. "
177 "Rejects all existing data!!");
178 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
182 void
183 on_radiobutton_piv_mouse5_enter(GtkWidget * widget,
184 gpointer data)
186 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
187 gchar *msg = _("Displaces a single interrogation area and analyzes");
188 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
192 void
193 on_radiobutton_piv_mouse6_enter(GtkWidget * widget,
194 gpointer data)
196 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
197 gchar *msg = _("Evaluation at a vertical line. ");
198 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
202 void
203 on_radiobutton_piv_mouse7_enter(GtkWidget * widget,
204 gpointer data)
206 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
207 gchar *msg = _("Evaluation at a horizontal line. ");
208 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
212 void
213 on_spinbutton_piv_int(GtkSpinButton * widget,
214 GtkWidget * entry)
216 PivEval * eval = gtk_object_get_data(GTK_OBJECT(widget), "eval");
217 gint nx = 0, ny = 0;
218 PivData l_intreg;
219 gint renew = 1;
220 enum VariableType {
221 COL_START = 0,
222 COL_END = 1,
223 PRE_SHIFT_COL = 2,
224 ROWSTART = 3,
225 ROWEND = 4,
226 PRESHIFTROW = 5,
227 INT_SIZE_1 = 6,
228 INT_SIZE_2 = 7,
229 INT_SHIFT = 8
230 } var_type;
232 /* eval = gtk_object_get_data(GTK_OBJECT(widget), "eval"); */
234 * Locale vars
236 /* Display display_act; */
237 /* display_act = gtk_object_get_data(widget, display_act); */
240 * Select which variable has to be modified
242 setby_spinbutton = 1;
243 var_type = atoi(gtk_object_get_data(GTK_OBJECT(widget), "var_type"));
245 if (var_type == COL_START) {
246 piv_eval_par.col_start = gtk_spin_button_get_value_as_int(widget);
248 } else if (var_type == COL_END) {
249 piv_eval_par.col_end = gtk_spin_button_get_value_as_int(widget);
251 } else if (var_type == PRE_SHIFT_COL) {
252 piv_eval_par.pre_shift_col = gtk_spin_button_get_value_as_int(widget);
254 } else if (var_type == ROWSTART) {
255 piv_eval_par.row_start = gtk_spin_button_get_value_as_int(widget);
257 } else if (var_type == ROWEND) {
258 piv_eval_par.row_end = gtk_spin_button_get_value_as_int(widget);
260 } else if (var_type == PRESHIFTROW) {
261 piv_eval_par.pre_shift_row = gtk_spin_button_get_value_as_int(widget);
263 } else if (var_type == INT_SIZE_1) {
264 piv_eval_par.int_size_1 = gtk_spin_button_get_value_as_int(widget);
267 GTK_ADJUSTMENT(eval->spinbutton_adj_intsize2)->lower =
268 (gfloat) piv_eval_par.int_size_1;
269 GTK_ADJUSTMENT(eval->spinbutton_adj_intsize2)->upper =
270 (gfloat) 128.0;
271 gtk_adjustment_changed (GTK_ADJUSTMENT(eval->spinbutton_adj_intsize2));
272 gtk_adjustment_set_value(GTK_ADJUSTMENT(eval->spinbutton_adj_intsize2),
273 (gfloat) piv_eval_par.int_size_1);
276 * Adjust radio buttons for in. size 1
278 if (piv_eval_par.int_size_1 == 16) {
279 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
280 (eval->radiobutton_intsize1_2),
281 TRUE);
283 } else if (piv_eval_par.int_size_1 == 32) {
284 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
285 (eval->radiobutton_intsize1_3), TRUE);
287 } else if (piv_eval_par.int_size_1 == 64) {
288 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
289 (eval->radiobutton_intsize1_4), TRUE);
290 } else if (piv_eval_par.int_size_1 == 128) {
291 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
292 (eval->radiobutton_intsize1_5), TRUE);
296 } else if (var_type == INT_SIZE_2) {
297 piv_eval_par.int_size_2 = gtk_spin_button_get_value_as_int(widget);
298 if (piv_eval_par.int_size_2 > piv_eval_par.int_size_1) {
299 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
300 (eval->checkbutton_zerooff),
301 TRUE);
302 } else {
303 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
304 (eval->checkbutton_zerooff),
305 FALSE);
309 * Adjust radio buttons for in. size 2
311 if (piv_eval_par.int_size_2 == 16) {
312 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
313 (eval->radiobutton_intsize2_2), TRUE);
314 } else if (piv_eval_par.int_size_2 == 32) {
315 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
316 (eval->radiobutton_intsize2_3), TRUE);
317 } else if (piv_eval_par.int_size_2 == 64) {
318 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
319 (eval->radiobutton_intsize2_4), TRUE);
320 } else if (piv_eval_par.int_size_2 == 128) {
321 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
322 (eval->radiobutton_intsize2_5), TRUE);
325 } else if (var_type == INT_SHIFT) {
326 piv_eval_par.int_shift = gtk_spin_button_get_value_as_int(widget);
328 if (piv_eval_par.int_shift == 8) {
329 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
330 (eval->radiobutton_intshift_1), TRUE);
331 } else if (piv_eval_par.int_shift == 16) {
332 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
333 (eval->radiobutton_intshift_2), TRUE);
334 } else if (piv_eval_par.int_shift == 32) {
335 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
336 (eval->radiobutton_intshift_3), TRUE);
337 } else if (piv_eval_par.int_shift == 64) {
338 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
339 (eval->radiobutton_intshift_4), TRUE);
340 } else if (piv_eval_par.int_shift == 128) {
341 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
342 (eval->radiobutton_intshift_5), TRUE);
346 if (display_act != NULL) {
347 nx = display_act->intreg.data.nx;
348 ny = display_act->intreg.data.ny;
349 if ((err_msg =
350 gpiv_piv_count_pivdata_fromimage(&l_intreg, image_par,
351 piv_eval_par))
352 != NULL) gtk_error ("%s: %s", RCSID, err_msg);
356 * For some operations the intregs have to be renewed unconditionally,
357 * for others only in case if the number of intregs has been changed
359 if (var_type == COL_START || var_type == COL_END
360 || var_type == ROWSTART || var_type == ROWEND) {
361 if (nx == l_intreg.nx
362 && ny == l_intreg.ny) {
363 renew = 0;
367 if (renew == 1 && display_act->display_intregs == 1) {
368 destroy_all_intregs(display_act);
369 create_all_intregs(display_act);
372 setby_spinbutton = 0;
377 void
378 on_radiobutton_piv_int(GtkWidget * widget,
379 gpointer data)
381 gint int_size_1_tmp, display_intregs_tmp = 0,
382 nx_tmp = 0, ny_tmp = 0;
383 /* gint setby_spinbutton = atoi(gtk_object_get_data(GTK_OBJECT(widget), */
384 /* "setby_spinbutton")); */
385 PivEval *eval = gtk_object_get_data(GTK_OBJECT(widget), "eval");
386 Display *disp = display_act;
387 int nx, ny;
388 enum VariableType {
389 SIZE_1 = 0,
390 SIZE_2 = 1,
391 SHIFT = 2
392 } var_type;
394 if (disp != NULL) {
395 nx = disp->intreg.data.nx;
396 ny = disp->intreg.data.ny;
397 } else {
398 nx = 0;
399 ny = 0;
402 if (GTK_TOGGLE_BUTTON(widget)->active) {
403 var_type = atoi(gtk_object_get_data(GTK_OBJECT(widget),
404 "var_type"));
407 * Select which variable has to be modified
409 if (var_type == SIZE_1) {
410 int_size_1_tmp = piv_eval_par.int_size_1;
411 piv_eval_par.int_size_1 = atoi(gtk_object_get_data
412 (GTK_OBJECT(widget),
413 "intsize1"));
415 * switch off d_intregs temporarly
417 if (disp != NULL) {
418 display_intregs_tmp = disp->display_intregs;
419 disp->display_intregs = 0;
421 nx_tmp = nx;
422 ny_tmp = ny;
423 adjust_radiobutton_piv_int(eval, piv_eval_par.int_size_1);
426 * return d_intregs to original value
428 if (disp != NULL)
429 disp->display_intregs = display_intregs_tmp;
430 nx = nx_tmp;
431 ny = ny_tmp;
434 * Reset weight and zero_off
436 if (piv_eval_par.int_size_2 > int_size_1_tmp) {
437 /* gtk_widget_set_sensitive(eval->checkbutton_zerooff, TRUE); */
438 /* gtk_widget_set_sensitive(checkbutton_piv_weightkernel, TRUE); */
439 if (zero_off_tmp == 0) {
440 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
441 (eval->checkbutton_zerooff),
442 FALSE);
443 gtk_widget_set_sensitive(eval->checkbutton_zerooff, TRUE);
444 gtk_widget_set_sensitive(eval->checkbutton_weightkernel,
445 TRUE);
446 if (weight_tmp == 0) {
447 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
448 (eval->checkbutton_weightkernel),
449 FALSE);
450 gtk_widget_set_sensitive(eval->checkbutton_zerooff,
451 TRUE);
452 gtk_widget_set_sensitive(eval->checkbutton_weightkernel, TRUE);
453 } else {
454 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
455 (eval->checkbutton_weightkernel),
456 TRUE);
457 gtk_widget_set_sensitive(eval->checkbutton_zerooff,
458 FALSE);
459 gtk_widget_set_sensitive(eval->checkbutton_weightkernel,
460 TRUE);
462 } else {
463 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
464 (eval->checkbutton_zerooff),
465 TRUE);
466 gtk_widget_set_sensitive(eval->checkbutton_zerooff, TRUE);
467 gtk_widget_set_sensitive(eval->checkbutton_weightkernel,
468 FALSE);
473 * Also calls on_spinbutton_piv_int, which, on its turn, may call this function
474 * again resulting into an infinite loop
476 gtk_spin_button_set_value(GTK_SPIN_BUTTON
477 (eval->spinbutton_intsize1),
478 piv_eval_par.int_size_1);
481 } else if (var_type == SIZE_2) {
482 piv_eval_par.int_size_2 = atoi(gtk_object_get_data(GTK_OBJECT(widget),
483 "intsize2"));
486 * Adjust spinner
488 gtk_adjustment_set_value(GTK_ADJUSTMENT
489 (eval->spinbutton_adj_intsize2),
490 (gfloat) piv_eval_par.int_size_2);
492 * Save origanal settings of weight and zero_off for later resetting
494 if (piv_eval_par.int_size_2 > piv_eval_par.int_size_1) {
495 zero_off_tmp = piv_eval_par.zero_off;
496 weight_tmp = piv_eval_par.weight;
497 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
498 (eval->checkbutton_weightkernel), FALSE);
499 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
500 (eval->checkbutton_zerooff), TRUE);
501 gtk_widget_set_sensitive(eval->checkbutton_zerooff, FALSE);
505 * Reset weight and zero_off
507 } else {
508 if (zero_off_tmp == 0) {
509 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
510 (eval->checkbutton_zerooff), FALSE);
511 if (weight_tmp == 0) {
512 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
513 (eval->checkbutton_weightkernel), FALSE);
514 } else {
515 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
516 (eval->checkbutton_weightkernel), TRUE);
518 } else {
519 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
520 (eval->checkbutton_zerooff), TRUE);
522 gtk_widget_set_sensitive(eval->checkbutton_zerooff, TRUE);
526 } else if (var_type == SHIFT) {
527 piv_eval_par.int_shift = atoi(gtk_object_get_data(GTK_OBJECT(widget),
528 "intshift"));
530 * Adjust spinner
532 gtk_spin_button_set_value(GTK_SPIN_BUTTON
533 (eval->spinbutton_intshift),
534 piv_eval_par.int_shift);
537 if (disp != NULL && disp->display_intregs == 1) {
538 destroy_all_intregs(display_act);
539 create_all_intregs(display_act);
547 void
548 on_toggle_piv(GtkWidget * widget,
549 gpointer data)
551 PivEval * eval = gtk_object_get_data(GTK_OBJECT(widget), "eval");
552 enum VariableType {
553 SCHEME = 0,
554 PEAK_NR = 1,
555 WEIGHT = 2,
556 ZERO_OFF = 3,
557 CENTRAL_INT = 4,
558 CORRELATION = 5
559 } var_type;
562 * Select which variable has to be modified
564 var_type = atoi(gtk_object_get_data(GTK_OBJECT(widget), "var_type"));
566 if (var_type == SCHEME) {
567 piv_eval_par.ifit = atoi(gtk_object_get_data(GTK_OBJECT(widget),
568 "ifit"));
570 } else if (var_type == PEAK_NR) {
571 piv_eval_par.peak = atoi(gtk_object_get_data(GTK_OBJECT(widget),
572 "peak"));
575 } else if (var_type == WEIGHT) {
576 if (GTK_TOGGLE_BUTTON(widget)->active) {
577 piv_eval_par.weight = 1;
578 gtk_widget_set_sensitive(eval->checkbutton_zerooff, FALSE);
579 gtk_widget_set_sensitive(eval->checkbutton_centraldiff, FALSE);
581 * toggle adaptive interr and zero-off
583 } else {
584 piv_eval_par.weight = 0;
585 gtk_widget_set_sensitive(eval->checkbutton_zerooff, TRUE);
586 gtk_widget_set_sensitive(eval->checkbutton_centraldiff, TRUE);
590 } else if (var_type == ZERO_OFF) {
591 if (GTK_TOGGLE_BUTTON(widget)->active) {
592 piv_eval_par.zero_off = 1;
593 gtk_widget_set_sensitive(eval->checkbutton_weightkernel, FALSE);
594 } else {
595 piv_eval_par.zero_off = 0;
596 gtk_widget_set_sensitive(eval->checkbutton_weightkernel, TRUE);
600 } else if (var_type == CENTRAL_INT) {
601 if (gtk_toggle_button_get_active
602 (GTK_TOGGLE_BUTTON(eval->checkbutton_centraldiff))) {
603 piv_eval_par.central_diff = 1;
604 } else {
605 piv_eval_par.central_diff = 0;
609 } else if (var_type == CORRELATION) {
610 image_par.x_corr = atoi(gtk_object_get_data(GTK_OBJECT(widget),
611 "x_corr"));
618 void
619 adjust_radiobutton_piv_int(PivEval * eval,
620 int int_size_1)
623 * adjusting and disabling int_size_2 and its toggle buttons
627 /* if (int_size_1 == 8) { */
628 /* gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON */
629 /* (eval->radiobutton_intsize2_1), TRUE); */
630 /* } else */if (int_size_1 == 16) {
631 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
632 (eval->radiobutton_intsize2_2), TRUE);
633 } else if (int_size_1 == 32) {
634 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
635 (eval->radiobutton_intsize2_3), TRUE);
636 } else if (int_size_1 == 64) {
637 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
638 (eval->radiobutton_intsize2_4), TRUE);
639 } else if (int_size_1 >= 128) {
640 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
641 (eval->radiobutton_intsize2_5), TRUE);
645 if (int_size_1 <= 64) {
646 gtk_widget_set_sensitive(GTK_WIDGET(eval->radiobutton_intsize2_4),
647 TRUE);
648 if (int_size_1 <= 32) {
649 gtk_widget_set_sensitive(GTK_WIDGET
650 (eval->radiobutton_intsize2_3),
651 TRUE);
652 if (int_size_1 <= 16) {
653 gtk_widget_set_sensitive(GTK_WIDGET
654 (eval->radiobutton_intsize2_2),
655 TRUE);
656 /* if (int_size_1 <= 8) { */
657 /* gtk_widget_set_sensitive(GTK_WIDGET */
658 /* (eval->radiobutton_intsize2_1), */
659 /* TRUE); */
660 /* } */
667 if (int_size_1 >= 16) {
668 /* gtk_widget_set_sensitive(GTK_WIDGET(eval->radiobutton_intsize2_1), */
669 /* FALSE); */
670 if (int_size_1 >= 32) {
671 gtk_widget_set_sensitive(GTK_WIDGET
672 (eval->radiobutton_intsize2_2),
673 FALSE);
674 if (int_size_1 >= 64) {
675 gtk_widget_set_sensitive(GTK_WIDGET
676 (eval->radiobutton_intsize2_3),
677 FALSE);
678 if (int_size_1 >= 128) {
679 gtk_widget_set_sensitive(GTK_WIDGET
680 (eval->radiobutton_intsize2_4),
681 FALSE);
691 void
692 on_checkbutton_piv_disprocess_enter(GtkWidget *widget,
693 gpointer data)
695 GpivConsole * gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
696 gchar *msg =
697 _("Displays subimages, correlation image and cov. peak location");
698 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
701 void on_checkbutton_piv_disprocess(GtkWidget * widget, gpointer data)
703 PivEval * eval = gtk_object_get_data(GTK_OBJECT(widget), "eval");
704 if (piv_eval_par.print_cov == 0) {
705 piv_eval_par.print_cov = 1;
706 gci_background_piv_disprocess =
707 gnome_canvas_item_new(gnome_canvas_root
708 (GNOME_CANVAS(eval->canvas_disprocess_dval)),
709 gnome_canvas_rect_get_type(),
710 "x1", (double) 0,
711 "y1", (double) 0,
712 "x2", (double) 128,
713 "y2", (double) 128,
714 "fill_color", "darkblue",
715 "width_units", 1.0,
716 NULL);
717 } else {
718 piv_eval_par.print_cov = 0;
720 g_warning("checkbutton_piv_disprocess clicked, print_cov = %d",
721 piv_eval_par.print_cov);
727 * showing interrogation area's and correlation function
729 gboolean
730 on_darea_piv_disprocess_int1_expose(GtkWidget * widget,
731 GdkEventExpose * event,
732 gpointer user_data)
734 gdk_draw_gray_image(widget->window,
735 widget->style->fg_gc[GTK_STATE_NORMAL], 0, 0,
736 MAX_INTERR_SIZE, MAX_INTERR_SIZE, GDK_RGB_DITHER_MAX,
737 graybuf_int1, MAX_INTERR_SIZE);
739 return TRUE;
743 gboolean
744 on_darea_piv_disprocess_int2_expose(GtkWidget * widget,
745 GdkEventExpose * event,
746 gpointer user_data)
748 gdk_draw_gray_image(widget->window,
749 widget->style->fg_gc[GTK_STATE_NORMAL], 0, 0,
750 MAX_INTERR_SIZE, MAX_INTERR_SIZE, GDK_RGB_DITHER_MAX,
751 graybuf_int2, MAX_INTERR_SIZE);
753 return TRUE;
757 gboolean
758 on_darea_piv_disprocess_cov_expose(GtkWidget * widget,
759 GdkEventExpose * event,
760 gpointer user_data)
762 gdk_draw_gray_image(widget->window,
763 widget->style->fg_gc[GTK_STATE_NORMAL], 0, 0,
764 MAX_INTERR_SIZE, MAX_INTERR_SIZE, GDK_RGB_DITHER_MAX,
765 graybuf_cov, MAX_INTERR_SIZE);
767 return TRUE;
772 void
773 on_button_piv_enter(GtkWidget *widget,
774 gpointer data)
776 GpivConsole * gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
777 gchar *msg = _("Analyses a PIV image (pair)");
778 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
782 void
783 on_button_piv(GtkWidget * widget,
784 gpointer data)
785 /* -------------------------------------------------------------------
786 The actual calculation of particle image displacements */
788 GpivConsole * gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
789 gint row, ibuf;
791 if (nbufs > 0) {
792 for (row = gpiv->first_selected_row; row <= gpiv->last_selected_row;
793 row++) {
794 display_act = gtk_clist_get_row_data(GTK_CLIST(gpiv->clist_buf),
795 row);
796 ibuf = display_act->count;
797 if (display[ibuf] != NULL
798 && display_act->mwin != NULL
799 && GTK_WIDGET_VISIBLE(GTK_WIDGET(display_act->mwin)) ) {
800 gdk_window_show(GTK_WIDGET(display_act->mwin)->window);
801 gdk_window_raise(GTK_WIDGET(display_act->mwin)->window);
804 exec_piv(gpiv);
811 void
812 exec_piv(GpivConsole * gpiv)
814 char *err_msg = NULL;
815 char c_line[MAX_LINES_C][MAX_CHARS];
816 int nc_lines = 0, return_val = 0;
817 char fname_piv[MAX_CHARS], fname_old_piv[MAX_CHARS], sdum[MAX_CHARS];
819 * Free memory of pivdata and clean the display from its vectors
821 if (display_act->gpd.exist_piv) {
822 destroy_all_vectors(&display_act->gpd);
823 gpiv_free_pivdata (&display_act->gpd.piv_data);
824 display_act->gpd.exist_piv = FALSE;
825 if (display_act->gpd.scaled_piv) {
826 gpiv_free_pivdata(&display_act->gpd.piv_data_scaled);
827 display_act->gpd.scaled_piv = FALSE;
832 * Free eventually existing memory of vor_data and clean the display
833 * as they does not belong to the piv data anymore
835 free_post_bufmems(display_act);
837 if (display_act->img.exist_img && !cancel_process) {
838 exec_process = TRUE;
841 * Reads old PIV data filemame.EXT_OLD for refined calculation
843 /* TODO??: NOT IMPLEMENTED IN GUI */
844 if (piv_eval_par.old_piv == 1) {
845 if (!display_act->gpd.exist_piv) {
846 g_snprintf(fname_old_piv, MAX_CHARS, "%s%s", display_act->fname_base, EXT_OLD);
847 g_snprintf(fname_piv, MAX_CHARS, "%s%s", display_act->fname_base, EXT_PIV);
848 g_snprintf(sdum, MAX_CHARS, "mv %s %s", fname_piv, fname_old_piv);
849 system(sdum);
850 if ((return_val = gpiv_fcount_pivdata(fname_old_piv, &display_act->gpd.piv_data))
851 == -1) {
852 gpiv_error(_("Failure calling gpiv_count_pivdata for %s"),
853 fname_old_piv);
856 } else {
857 if ((err_msg =
858 gpiv_piv_count_pivdata_fromimage(&display_act->gpd.piv_data,
859 image_par, piv_eval_par))
860 != NULL) gtk_error ("%s: %s", RCSID, err_msg);
864 * Set mouse selection to None
866 if (m_select == SINGLE_POINT_MS
867 || m_select == SINGLE_AREA_MS
868 || m_select == DRAG_MS) {
869 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
870 (gpiv->piveval->radiobutton_mouse_1),
871 TRUE);
875 * Allocating memory for output data, now the number of points are
876 * known (from old piv data or from the area of interest within the image
877 * and interrogation area sizes)
880 /* if (m_select != SINGLE_AREA_MS || */
881 /* (m_select == SINGLE_AREA_MS && ) { */
883 gpiv_alloc_pivdata(&display_act->gpd.piv_data);
884 display_act->gpd.exist_piv = TRUE;
887 if (piv_eval_par.old_piv == 1) {
888 if ((err_msg =
889 gpiv_fread_pivdata(fname_old_piv, &display_act->gpd.piv_data,
890 c_line, &nc_lines))
891 != NULL) gtk_error ("%s: %s", RCSID, err_msg);
894 /* gpiv_write_pivdata(oldpiv_data, c_line, 0, 0, RCSID); */
897 * Determine locations of Interrogation Area's
899 if (piv_eval_par.old_piv != 1 &&
900 m_select != SINGLE_AREA_MS &&
901 m_select != SINGLE_POINT_MS &&
902 m_select != DRAG_MS) {
903 if ((err_msg =
904 gpiv_piv_select_int_point(&display_act->gpd.piv_data,
905 image_par, piv_eval_par))
906 != NULL) gtk_error ("%s: %s", RCSID, err_msg);
908 /* fprintf (stderr, "%s:: returned from gpiv_piv_select_int_point\n", function_name); */
909 /* fprintf (stderr, "%s:: display_act->gpd.point_x = %f display_act->gpd.point_y = %f\n", */
910 /* function_name, display_act->gpd.piv_data.point_x[0][0], */
911 /* display_act->gpd.piv_data.point_y[0][0]); */
915 interrogate(&display_act->gpd.piv_data, display_act->img.img1,
916 display_act->img.img2, gpiv);
922 * Copy parameters in Buffer structure for saving and, eventual, later use
925 copy_img_par(image_par, &display_act->img.image_par, TRUE, print_par);
926 copy_piv_par(piv_eval_par, &display_act->gpd.piv_eval_par, TRUE,
927 print_par);
928 exec_process = FALSE;
930 } else {
931 msg_error =
932 _("At first, open an image. "
933 "Than we'll further see what will happen.");
934 g_warning(msg_error);
935 gtk_warning(msg_error);
942 void
943 interrogate(PivData * piv_data,
944 unsigned char **img1,
945 unsigned char **img2,
946 GpivConsole * gpiv)
947 /* --------------------------------------------------------------------
948 PIV analyses of an image pair */
950 /* #define EXT_PIV ".piv" */
952 int index_x = 0, index_y = 0, int_size_0, fname_logic = 1;
953 gfloat progres_value;
954 gchar progres_string[MAX_CHARS];
956 unsigned char **img1_ACT = NULL, **img2_ACT = NULL;
957 ImagePar image_par_ACT;
958 PivEvalPar piv_eval_par_ACT;
959 PivData piv_data_ACT/* = *piv_data */;
960 Covariance w_k;
961 /* Covariance *cov = display_act->gpd.cov; */
962 int sweep = 1, sweep_last = 0, exit_while = 0,
963 cmpr_fact = 1;
964 char *fftwis, *fftwis_inv;
968 * Testing parameters on consistency and initializing derived
969 * parameters/variables
971 if ((err_msg =
972 gpiv_piv_test_parameter(&image_par, &piv_eval_par, fname_logic))
973 != NULL) gpiv_error ("%s: %s", RCSID, err_msg);
975 copy_img_par(image_par, &image_par_ACT, TRUE, print_par);
976 copy_piv_par(piv_eval_par, &piv_eval_par_ACT, TRUE, print_par);
978 if (piv_eval_par_ACT.ad_int == 1) {
979 piv_eval_par_ACT.int_size_1 = piv_eval_par.int_size_2;
980 } else {
981 piv_eval_par_ACT.int_size_1 = piv_eval_par.int_size_1;
986 if (piv_eval_par.zero_off || piv_eval_par.ad_int) {
987 sweep_last = 0;
988 /* piv_eval_par_ACT.ifit = 0; */
989 } else {
990 sweep_last = 1;
991 /* piv_eval_par_ACT.ifit = piv_eval_par.ifit; */
996 * Reads eventually existing fftw wisdom
998 fftwis = gpiv_fread_fftw_wisdom(1);
999 fftwis_inv = gpiv_fread_fftw_wisdom(-1);
1003 * Scanning int. area(s)
1005 while ((!cancel_process
1006 && piv_eval_par.zero_off != 1 && sweep <= 1)
1007 || (piv_eval_par.zero_off == 1 && piv_eval_par_ACT.ad_int != 1 &&
1008 sweep <= 2)
1009 || (piv_eval_par_ACT.ad_int == 1 && exit_while == 0 )) {
1010 /* (piv_eval_par_ACT.ad_int == 1 && */
1011 /* piv_eval_par_ACT.int_size_2*cmpr_fact >= */
1012 /* piv_eval_par.int_size_1)) { */
1015 /* gpiv_img_print_header("", image_par_ACT); */
1016 /* gpiv_piv_print_parameters("EVAL.", piv_eval_par_ACT); */
1017 int_size_0 = ZEROPAD_FACT * piv_eval_par_ACT.int_size_2;
1020 if (m_select != SINGLE_AREA_MS && m_select != DRAG_MS) {
1021 destroy_all_vectors(&display_act->gpd);
1022 gnome_canvas_update_now(GNOME_CANVAS(display_act->canvas));
1027 * cleans drawing areas for displaying interrogation areas
1029 /* if (print_cov == 1) { */
1030 /* memset(graybuf_int1, 215, */
1031 /* (sizeof(guchar)) * (MAX_INTERR_SIZE * MAX_INTERR_SIZE)); */
1032 /* memset(graybuf_int2, 215, */
1033 /* (sizeof(guchar)) * (MAX_INTERR_SIZE * MAX_INTERR_SIZE)); */
1034 /* memset(graybuf_cov, 215, */
1035 /* (sizeof(guchar)) * (MAX_INTERR_SIZE * MAX_INTERR_SIZE)); */
1036 /* } */
1041 * Analyze at a single point
1043 if (piv_eval_par_ACT.int_geo == POINT
1044 || m_select == SINGLE_AREA_MS
1045 || m_select == SINGLE_POINT_MS
1046 || m_select == DRAG_MS) {
1048 img1_ACT = &img1[0];
1049 img2_ACT = &img2[0];
1050 piv_data_ACT = *piv_data;
1054 * Weight kernel for single int.area
1056 gpiv_piv_bounds_cov(&w_k, int_size_0, image_par_ACT);
1057 w_k.z = gpiv_matrix(w_k.z_rl, w_k.z_rh, w_k.z_cl, w_k.z_ch);
1058 if (piv_eval_par.weight == 1) {
1059 gpiv_piv_weight_kernel_lin(&w_k, int_size_0);
1060 } else {
1061 gpiv_piv_weight_kernel_1(&w_k);
1064 alloc_bufmem_per_intarea(m_select_index_y, m_select_index_x,
1065 &display_act->gpd, image_par_ACT,
1066 int_size_0);
1070 * Piv evaluation of ** A SINGLE** interrogation area
1072 if ((err_msg =
1073 gpiv_piv_eval_int_reg(m_select_index_y,
1074 m_select_index_x,
1075 img1_ACT,
1076 img2_ACT,
1077 display_act->gpd.intreg1[m_select_index_y][m_select_index_x],
1078 display_act->gpd.intreg2[m_select_index_y][m_select_index_x],
1079 &display_act->gpd.cov[m_select_index_y][m_select_index_x],
1080 &w_k,
1081 &fftwis,
1082 &fftwis_inv,
1083 &piv_data_ACT,
1084 sweep,
1085 sweep_last,
1086 image_par_ACT,
1087 piv_eval_par_ACT))
1088 != NULL) gtk_error ("%s: %s", RCSID, err_msg);
1092 * display piv values, draw interrogation areas and covariance function
1093 * WATCH OUT WITH CMPR!!
1095 if (piv_eval_par.print_cov == 1) {
1096 display_piv_vector(m_select_index_y, m_select_index_x,
1097 display_act->gpd.piv_data,
1098 gpiv->piveval);
1099 display_img_intreg1(display_act->gpd.intreg1 [m_select_index_y]
1100 [m_select_index_x],
1101 piv_eval_par_ACT.int_size_2,
1102 gpiv->piveval);
1103 display_img_intreg2(display_act->gpd.intreg2[m_select_index_y]
1104 [m_select_index_x],
1105 piv_eval_par_ACT.int_size_2,
1106 gpiv->piveval);
1107 display_img_cov(&display_act->gpd.cov[m_select_index_y]
1108 [m_select_index_x],
1109 piv_eval_par_ACT.int_size_2,
1110 gpiv->piveval);
1113 free_bufmem_per_intarea(m_select_index_y, m_select_index_x,
1114 &display_act->gpd, image_par_ACT, int_size_0);
1118 * Anlyze all points wthin Area Of Interest
1120 } else {
1123 * Speedup the process
1127 * Free memory of pivdata and clean the display from its vectors
1130 /* if (display_act->gpd.exist_display_act->gpd.intregs) { */
1131 /* destroy_all_intregs1(&display_act->gpd); */
1132 /* destroy_all_intregs2(&display_act->gpd); */
1133 /* free_intregs(&display_act->gpd.intregs); */
1134 /* display_act->gpd.exist_intregs = FALSE; */
1135 /* display_act->display_intregs = 0; */
1136 /* } */
1138 * SPEEDUP PROCEDURES
1140 /* if (piv_eval_par.zero_off) { */
1141 /* if (piv_eval_par.int_shift < piv_eval_par.int_size_2) { */
1142 /* speedup_ishi(&image_par_ACT,
1143 piv_eval_par_ACT, &piv_eval_par_ACT, */
1144 /* piv_data, &piv_data_ACT, sweep, sweep_last); */
1146 /* } else { */
1147 /* Enable/disable in combination with speedup_ishi */
1148 /* piv_data_ACT = *piv_data; */
1149 /* } */
1151 /* speedup_cmpr(img1, &img1_ACT, img2, &img2_ACT, image_par, */
1152 /* &image_par_ACT, piv_eval_par, &piv_eval_par_ACT, */
1153 /* &piv_data_ACT, &cmpr_fact, &int_size_0, sweep, sweep_last); */
1155 /* Enable when switched off speedup_cmpr: */
1156 /* img1_ACT = &img1[0]; */
1157 /* img2_ACT = &img2[0]; */
1159 /* } else { */
1160 img1_ACT = &img1[0];
1161 img2_ACT = &img2[0];
1162 piv_data_ACT = *piv_data;
1164 /* } */
1167 * SPEEDUP PROCEDURES END
1170 /* gpiv_piv_count_pivdata_fromimage(&display_act->gpd.intregs, */
1171 /* image_par_ACT, */
1172 /* piv_eval_par_ACT); */
1173 /* g_warning("intregs.nx=%d intregs.ny=%d\n", */
1174 /* display_act->gpd.intregs.nx, display_act->gpd.intregs.ny); */
1175 /* gpiv_alloc_scdata(&display[ibuf].intregs); */
1176 /* display_act->gpd.exist_intregs = TRUE; */
1177 /* gpiv_piv_select_int_point(&display_act->gpd.intregs, image_par_ACT, */
1178 /* piv_eval_par_ACT); */
1179 /* create_all_intregs1(&display_act->gpd); */
1180 /* create_all_intregs2(&display_act->gpd); */
1183 gpiv_piv_bounds_cov(&w_k, int_size_0, image_par_ACT); /* piv_eval_par_ACT.int_size_2 ?? */
1184 w_k.z = gpiv_matrix(w_k.z_rl, w_k.z_rh, w_k.z_cl, w_k.z_ch);
1186 if (piv_eval_par.weight == 1) {
1187 gpiv_piv_weight_kernel_lin(&w_k, int_size_0);
1188 } else {
1189 gpiv_piv_weight_kernel_1(&w_k);
1194 * Print statement
1196 /* if (piv_eval_par.zero_off && sweep_last == 1) { */
1197 /* gpiv_img_print_header(image_par_ACT); */
1198 /* gpiv_piv_print_parameters(piv_eval_par_ACT); */
1199 /* } */
1201 for (index_y = 0; index_y < piv_data_ACT.ny; index_y++) {
1202 for (index_x = 0; index_x < piv_data_ACT.nx; index_x++) {
1203 if (cancel_process) break;
1204 alloc_bufmem_per_intarea(index_y, index_x, &display_act->gpd,
1205 image_par_ACT, int_size_0);
1210 * Printing the progress of processing
1212 progres_value =
1213 100 * (index_y * piv_data->nx + index_x +
1214 1) / (piv_data->nx * piv_data->ny);
1215 if (piv_eval_par.zero_off && piv_eval_par.ad_int) {
1216 g_snprintf(progres_string, MAX_CHARS,
1217 "piv sweep #%d "
1218 "(int. size = %d): "
1219 "%d%% processed",
1220 sweep,
1221 piv_eval_par_ACT.int_size_2,
1222 (gint) progres_value);
1223 } else if (piv_eval_par.zero_off && piv_eval_par.ad_int == 0) {
1224 g_snprintf(progres_string, MAX_CHARS,
1225 "piv sweep #%d: "
1226 "%d%% processed",
1227 sweep,
1228 (gint) progres_value);
1229 } else {
1230 g_snprintf(progres_string, MAX_CHARS,
1231 "%d%% processed",
1232 (gint) progres_value);
1235 while (g_main_iteration(FALSE));
1236 gtk_progress_set_value(gnome_appbar_get_progress
1237 (GNOME_APPBAR(gpiv->appbar)),
1238 progres_value);
1239 gnome_appbar_push(GNOME_APPBAR(gpiv->appbar),
1240 progres_string);
1244 * Evaluates an interrogation area.
1245 * In the call int_size_1 might be defined equal to
1246 * piv_eval_par_ACT.int_size_2 as well;
1247 * this will reduce the snr during integration
1250 if ((err_msg =
1251 gpiv_piv_eval_int_reg(index_y,
1252 index_x,
1253 img1_ACT,
1254 img2_ACT,
1255 display_act->gpd.intreg1[index_y][index_x],
1256 display_act->gpd.intreg2[index_y][index_x],
1257 &display_act->gpd.cov[index_y][index_x],
1258 &w_k,
1259 &fftwis,
1260 &fftwis_inv,
1261 &piv_data_ACT,
1262 sweep,
1263 sweep_last,
1264 image_par_ACT,
1265 piv_eval_par_ACT))
1266 != NULL) gpiv_error ("%s: %s", RCSID, err_msg);
1270 * Check on validity of data
1272 if (isnan(/* (double) */ display_act->gpd.piv_data.dx[index_y][index_x]) != 0
1273 || isnan(/* (double) */ display_act->gpd.piv_data.dy[index_y][index_x]) != 0) {
1274 display_act->gpd.piv_data.dx[index_y][index_x] = 0.0;
1275 display_act->gpd.piv_data.dy[index_y][index_x] = 0.0;
1276 display_act->gpd.piv_data.snr[index_y][index_x] = 99.9;
1277 display_act->gpd.piv_data.peak_no[index_y][index_x] = -1;
1282 /* printf("sweep =%d x=%f y=%f\n", sweep, */
1283 /* piv_data_ACT.point_x[index_y][index_x], */
1284 /* piv_data_ACT.point_y[index_y][index_x]); */
1287 * Only draw the vectors for last sweep
1289 if (sweep_last) {
1291 /* while (!(my_in=getchar())) sleep(10); */
1292 /* fprintf(stderr, "interrogate:: i=%d j=%d x=%f y=%f dx=%f dy=%f\n", */
1293 /* index_y, index_x, */
1294 /* piv_data_ACT.point_x[index_y][index_x], */
1295 /* piv_data_ACT.point_y[index_y][index_x], */
1296 /* piv_data_ACT.dx[index_y][index_x], */
1297 /* piv_data_ACT.dy[index_y][index_x]); */
1299 /* if ( buf->gci_vector[index_y][index_x] == NULL) { */
1301 display_vector(index_y, index_x, &display_act->gpd);
1304 /* } else { */
1305 /* update_vector(index_y, index_x, &display_act->gpd); */
1306 /* } */
1308 /* if (display_act->gpd.exist_intregs) { */
1309 /* update_intreg2(index_y, index_x, &display_act->gpd); */
1310 /* update_intreg1(index_y, index_x, &display_act->gpd); */
1311 /* } */
1316 * Draw interrogation areas, covariance function, display piv vector
1317 * WATCH OUT WITH CMPR!!
1319 if (piv_eval_par.print_cov == 1) {
1320 display_piv_vector(index_y,
1321 index_x,
1322 display_act->gpd.piv_data,
1323 gpiv->piveval);
1324 display_img_intreg1(display_act->gpd.intreg1[index_y][index_x],
1325 piv_eval_par_ACT.int_size_2,
1326 gpiv->piveval);
1327 display_img_intreg2(display_act->gpd.intreg2[index_y][index_x],
1328 piv_eval_par_ACT.int_size_2,
1329 gpiv->piveval);
1330 display_img_cov(&display_act->gpd.cov[index_y][index_x],
1331 piv_eval_par_ACT.int_size_2,
1332 gpiv->piveval);
1337 * Freeing memory; **Disable** to keep data with print_cov for viewing later
1339 /* => to exec_piv */
1342 free_bufmem_per_intarea(index_y, index_x,
1343 &display_act->gpd,
1344 image_par_ACT, int_size_0);
1347 /* fprintf(stderr, "\n::i=%d j=%d zero_off=%d ad_int=%d int_size_1=%d" */
1348 /* "piv_eval_par_ACT.int_size_2=%d int_size_0=%d sweep=%d\n", */
1349 /* index_y, index_x, piv_eval_par.zero_off, */
1350 /* piv_eval_par.ad_int, piv_eval_par_ACT.int_size_1, */
1351 /* piv_eval_par_ACT.int_size_2, int_size_0, sweep); */
1360 * Once allocated for entire image: should be freed for new int area size
1362 gpiv_free_matrix(w_k.z, w_k.z_rl, w_k.z_rh, w_k.z_cl, w_k.z_ch);
1366 * Adjust piv_eval_par_ACT.int_size_2 in case int_size_1 is not a power of two
1369 if (piv_eval_par_ACT.ad_int == 1) {
1370 /* fprintf(stderr, "\n::int_size_1=%d int_size_1_ACT=%d" */
1371 /* "piv_eval_par.int_size_2_ACT=%d cmpr_fact=%d", */
1372 /* piv_eval_par.int_size_1, piv_eval_par_ACT.int_size_1, */
1373 /* piv_eval_par_ACT.int_size_2, cmpr_fact); */
1374 if (sweep_last == 1) exit_while = 1;
1375 if (piv_eval_par_ACT.int_size_2*cmpr_fact/2 == piv_eval_par.int_size_1 ||
1376 piv_eval_par_ACT.int_size_2*cmpr_fact/4 < piv_eval_par.int_size_1) {
1377 piv_eval_par_ACT.int_size_1 = piv_eval_par.int_size_1 / cmpr_fact;
1378 piv_eval_par_ACT.int_size_2 = piv_eval_par.int_size_1 / cmpr_fact;
1379 sweep_last = 1;
1380 } else {
1381 piv_eval_par_ACT.int_size_1 = piv_eval_par_ACT.int_size_2 / 2;
1382 piv_eval_par_ACT.int_size_2 = piv_eval_par_ACT.int_size_2 / 2;
1386 if (piv_eval_par.zero_off == 1 && piv_eval_par_ACT.ad_int != 1) {
1387 sweep_last = 1;
1390 sweep++;
1391 if (sweep == MAX_SWEEP) {
1392 sweep_last = 1;
1393 piv_eval_par_ACT.ifit = piv_eval_par.ifit;
1395 fprintf(stderr, "\n");
1396 fprintf(stderr, "\n");
1403 * Writes existing fftw wisdom
1405 gpiv_fwrite_fftw_wisdom(1, fftwis);
1406 gpiv_fwrite_fftw_wisdom(-1, fftwis_inv);
1409 display_act->gpd.scaled_piv = FALSE;
1410 display_act->gpd.saved_piv = FALSE;
1411 /* display_act->display_piv = TRUE; */
1413 /* gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(viewmenu_uiinfo[5].widget), TRUE); */
1415 display_act->gpd.exist_cov = TRUE;
1417 /* gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(viewmenu_uiinfo[6].widget), TRUE); */
1425 * Display functions in PIV tabulator canvas
1429 void
1430 display_piv_vector(gint i,
1431 gint j,
1432 PivData piv_data,
1433 PivEval * eval)
1434 /* ------------------------- Displays values in PIV tabulator of the GUI */
1436 float **dx = piv_data.dx, **dy = piv_data.dy;
1437 int **peak_no = piv_data.peak_no;
1438 GnomeCanvasPoints *points;
1439 gchar *color;
1440 points = gnome_canvas_points_new(2);
1442 if (peak_no[i][j] == -1) {
1443 color="gray";
1444 } else if (peak_no[i][j] == 0) {
1445 color="lightblue";
1446 } else if (peak_no[i][j] == 1) {
1447 color="green";
1448 } else if (peak_no[i][j] == 2) {
1449 color="yellow";
1450 } else {
1451 /* if (peak_no[i][j] == 3) */
1452 color="red";
1455 /* fprintf(stderr, "\nDISPLAY_VECTOR:: 1"); */
1456 points->coords[0] = MAX_INTERR_SIZE / 2;
1457 points->coords[1] = MAX_INTERR_SIZE / 2;
1458 points->coords[2] = MAX_INTERR_SIZE / 2 + dx[i][j] * gpiv_par.vector_scale;
1459 points->coords[3] = MAX_INTERR_SIZE / 2 + dy[i][j] * gpiv_par.vector_scale;
1462 if (gci_vector_piv_disprocess != NULL) {
1463 gnome_canvas_item_set(gci_vector_piv_disprocess,
1464 "points", points,
1465 "fill_color", color,
1466 "width_units", (double) THICKNESS,
1467 "first_arrowhead", FALSE,
1468 "last_arrowhead", TRUE,
1469 "arrow_shape_a", (double) ARROW_LENGTH,
1470 "arrow_shape_b", (double) ARROW_EDGE,
1471 "arrow_shape_c", (double) ARROW_WIDTH,
1472 NULL);
1473 } else {
1474 gci_vector_piv_disprocess =
1475 gnome_canvas_item_new(gnome_canvas_root
1476 (GNOME_CANVAS(eval->canvas_disprocess_dval)),
1477 gnome_canvas_line_get_type(),
1478 "points", points,
1479 "fill_color", "red",
1480 "width_units",(double) THICKNESS,
1481 "first_arrowhead", TRUE,
1482 "arrow_shape_a", (double) THICKNESS,
1483 NULL);
1487 gnome_canvas_points_free(points);
1492 void
1493 display_img_intreg1(float **intreg1,
1494 int int_size,
1495 PivEval * eval)
1496 /* ------------------------- Displays image of intreg1 for drawing area */
1498 guchar *pos;
1499 gint i, j;
1500 float min = 1000.;
1503 * As the mean has been substracted from the data, values have to be
1504 * tilted above zero
1506 for (i = 0; i < int_size; i++) {
1507 for (j = 0; j < int_size; j++) {
1508 if (intreg1[i][j] < min)
1509 min = intreg1[i][j];
1513 pos = graybuf_int1;
1514 pos += (MAX_INTERR_SIZE - int_size) / 2 * (MAX_INTERR_SIZE + 1);
1515 for (i = 0; i < int_size; i++) {
1516 for (j = 0; j < int_size; j++) {
1517 *pos++ = (unsigned char) intreg1[i][j] - (unsigned char) min;
1519 pos = pos + (MAX_INTERR_SIZE - int_size);
1521 gtk_widget_draw(GTK_WIDGET(eval->darea_disprocess_int1), pos);
1526 void display_img_intreg2(float **intreg2,
1527 int int_size,
1528 PivEval * eval)
1529 /* ------------------------- Displays image of intreg1 for drawing area */
1531 guchar *pos;
1532 gint i, j;
1533 float min = 1000.;
1536 * As the mean has been substracted from the data, values have to be tilted
1537 * above zero
1539 for (i = 0; i < int_size; i++) {
1540 for (j = 0; j < int_size; j++) {
1541 if (intreg2[i][j] < min)
1542 min = intreg2[i][j];
1547 pos = graybuf_int2;
1548 pos += (MAX_INTERR_SIZE - int_size) / 2 * (MAX_INTERR_SIZE + 1);
1549 for (i = 0; i < int_size; i++) {
1550 for (j = 0; j < int_size; j++) {
1551 *pos++ = (unsigned char) intreg2[i][j] - (unsigned char) min;
1553 pos += (MAX_INTERR_SIZE - int_size);
1555 gtk_widget_draw(GTK_WIDGET(eval->darea_disprocess_int2), pos);
1559 void display_img_cov(Covariance * cov,
1560 int int_size,
1561 PivEval * eval)
1562 /* ------------------------- Displays image of intreg1 for drawing area */
1564 guchar *pos;
1565 gint i, j;
1566 float min = 1000., max = -1000.;
1568 int z_rl = cov->z_rl, z_rh = cov->z_rh, z_cl = cov->z_cl, z_ch =
1569 cov->z_ch;
1573 * Scaling
1575 for (i = z_rl; i < z_rh; i++) {
1576 for (j = z_cl; j < z_ch; j++) {
1577 if (cov->z[i][j] < min)
1578 min = cov->z[i][j];
1579 if (cov->z[i][j] > max)
1580 max = cov->z[i][j];
1585 pos = graybuf_cov;
1586 pos += (MAX_INTERR_SIZE - int_size) / 2 * (MAX_INTERR_SIZE + 1);
1587 /* pos += (MAX_INTERR_SIZE - int_size/2)/2 * (MAX_INTERR_SIZE+1); */
1589 /* pos += (MAX_INTERR_SIZE - 3*int_size/4)/2; */
1592 for (i = z_rl; i < z_rh; i++) {
1593 for (j = z_cl; j < z_ch; j++) {
1594 cov->z[i][j] -= min;
1595 cov->z[i][j] = (255.0 / (max - min)) * cov->z[i][j];
1596 *pos++ = (unsigned char) cov->z[i][j];
1598 pos += (MAX_INTERR_SIZE - int_size) + 1;
1601 gtk_widget_draw(GTK_WIDGET(eval->darea_disprocess_cov), pos);