Adapted for use on cluster (using MPI/OMP) parallelised gpiv_rr from gpivtools)
[gpiv.git] / src / piveval.c
blob8254d906582cdf25ca28b5405660f0be4f422454
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, 2003, 2004 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.23 2008-04-28 12:00:57 gerber
32 * hdf-formatted files are now with .hdf extension (previously: .gpi)
34 * Revision 1.22 2007-11-23 16:24:07 gerber
35 * release 0.5.0: Kafka
37 * Revision 1.21 2007-06-06 17:00:48 gerber
38 * Retreives images/data from URI using Gnome Virtual File System.
40 * Revision 1.20 2007-03-22 16:00:32 gerber
41 * Added image processing tabulator
43 * Revision 1.19 2007-02-16 17:09:48 gerber
44 * added Gauss weighting on I.A. and SPOF filtering (on correlation function)
46 * Revision 1.18 2007/02/05 15:17:09 gerber
47 * auto stretching, broadcast display settings to buffers from preferences
49 * Revision 1.17 2007-01-29 11:27:43 gerber
50 * added image formats png, gif, tif png, bmp, improved buffer display
52 * Revision 1.16 2006-09-18 07:27:06 gerber
53 * *** empty log message ***
55 * Revision 1.15 2006/01/31 14:28:12 gerber
56 * version 0.3.0
58 * Revision 1.13 2005/02/26 09:43:30 gerber
59 * parameter flags (parameter_logic) defined as gboolean
61 * Revision 1.12 2005/02/26 09:17:14 gerber
62 * structured of interrogate function by using gpiv_piv_isiadapt
64 * Revision 1.11 2005/01/19 15:53:42 gerber
65 * Initiation of Data Acquisition (DAC); trigerring of lasers and camera
66 * by using RTAI and Realtime Linux, recording images from IEEE1394
67 * (Firewire) IIDC compliant camera's
69 * Revision 1.10 2004/10/15 19:24:05 gerber
70 * GPIV_ and Gpiv prefix to defines and structure names of libgpiv
72 * Revision 1.9 2004/06/14 21:19:23 gerber
73 * Image depth up to 16 bits.
74 * Improvement "single int" and "drag int" in Eval tab.
75 * Viewer's pop-up menu.
76 * Adaption for gpiv_matrix_* and gpiv_vector_*.
77 * Resizing console.
78 * See Changelog for further info.
80 * Revision 1.8 2003/09/01 11:17:15 gerber
81 * improved monitoring of interrogation process
83 * Revision 1.7 2003/08/22 15:24:52 gerber
84 * interactive spatial scaling
86 * Revision 1.6 2003/07/13 14:38:18 gerber
87 * changed error handling of libgpiv
89 * Revision 1.5 2003/07/12 21:21:16 gerber
90 * changed error handling libgpiv
92 * Revision 1.3 2003/07/10 11:56:07 gerber
93 * added man page
95 * Revision 1.2 2003/06/27 13:47:26 gerber
96 * display ruler, line/point evaluation
98 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
99 * Imported gpiv
104 #include "gpiv_gui.h"
105 #include "utils.h"
106 #include "piveval.h"
107 #include "piveval_interrogate.h"
108 #include "display.h"
112 * Private piv evaluation functions
116 static void
117 display_img (float **img,
118 gint int_size,
119 gint *int_size_old,
120 gint i_min,
121 gint i_max,
122 gint j_min,
123 gint j_max,
124 gint rgb_width,
125 guchar **rgbbuf,
126 GtkWidget *canvas,
127 GnomeCanvasItem **gci,
128 double affine[6],
129 gboolean scale
131 /* ----------------------------------------------------------------------------
132 * Displaying routine in gnome canvas
135 guchar *pos;
136 gint i, j;
137 float min = 1000.0, max = -1000.0;
139 GdkPixbuf *pixbuf = NULL;
140 guint16 fact = 1;
141 gint depth = 8;
143 assert (img[0] != NULL);
145 fact = fact << (gl_image_par->depth - depth);
146 /* g_message ("DISPLAY_IMG:: fact = %d", fact); */
148 if (*rgbbuf != NULL) {
149 g_free(*rgbbuf);
150 *rgbbuf = NULL;
153 if (*rgbbuf == NULL) {
155 * row stride; each row is a 4-byte buffer array
157 rgb_width = (i_max - i_min) * 3;
158 while ((rgb_width) % 4 != 0) {
159 rgb_width++;
162 *rgbbuf = g_malloc (rgb_width * 3 * (j_max - j_min));
166 if (*gci != NULL) {
167 gtk_object_destroy (GTK_OBJECT(*gci));
168 *gci = NULL;
172 pixbuf = gdk_pixbuf_new_from_data (*rgbbuf,
173 GDK_COLORSPACE_RGB,
174 FALSE,
175 depth,
176 i_max - i_min,
177 j_max - j_min,
178 rgb_width,
179 NULL,
180 NULL);
184 *gci = gnome_canvas_item_new (gnome_canvas_root( GNOME_CANVAS
185 (canvas)),
186 gnome_canvas_pixbuf_get_type (),
187 "pixbuf", pixbuf,
188 NULL);
189 /* BUGFIX: new (check mem) */
190 /* gdk_pixbuf_unref (pixbuf); */
193 affine[4] = (GPIV_MAX_INTERR_SIZE - gpiv_var->piv_disproc_zoom
194 * int_size) / 2.0;
195 affine[5] = (GPIV_MAX_INTERR_SIZE - gpiv_var->piv_disproc_zoom
196 * int_size) / 2.0;
197 gnome_canvas_item_affine_absolute (*gci, affine);
200 * As the mean has been subtracted from the image data, image intensities
201 * will have to be tilted above zero
203 if (scale) {
204 for (j = j_min; j < j_max; j++) {
205 for (i = i_min; i < i_max; i++) {
206 if (img[j][i] < min)
207 min = img[j][i];
208 if (img[j][i] > max)
209 max = img[j][i];
213 pos = *rgbbuf;
214 for (j = j_min; j < j_max; j++) {
215 for (i = i_min; i < i_max; i++) {
216 img[j][i] -= min;
217 img[j][i] = (255.0 / (max - min)) * img[j][i];
218 *pos++ = (unsigned char) img[j][i];
219 *pos++ = (unsigned char) img[j][i];
220 *pos++ = (unsigned char) img[j][i];
222 *pos = *pos++;
223 *pos = *pos++;
224 *pos = *pos++;
228 } else {
229 for (j = j_min; j < j_max; j++) {
230 for (i = i_min; i < i_max; i++) {
231 if (img[j][i] < min)
232 min = img[j][i];
236 /* if ( min < display_act->img.img_mean) */
237 /* display_act->img.img_mean = min; */
240 pos = *rgbbuf;
241 for (j = j_min; j < j_max; j++) {
242 for (i = i_min; i < i_max; i++) {
243 /* *pos++ = (unsigned char) img[j][i] - (unsigned char) min */
244 /* + (unsigned char) display_act->img.img_mean; */
245 /* *pos++ = (unsigned char) img[j][i] - (unsigned char) min */
246 /* + (unsigned char) display_act->img.img_mean; */
247 /* *pos++ = (unsigned char) img[j][i] - (unsigned char) min */
248 /* + (unsigned char) display_act->img.img_mean; */
250 * BUGFIX: display image intars with: 8 < depth < 16
251 * 6 March 2004
253 *pos++ = (guchar) ((img[j][i] - /* (guchar) */ min +
254 /* (guchar) */ display_act->img->img_mean)
255 / fact);
256 *pos++ = (guchar) ((img[j][i] - /* (guchar) */ min +
257 /* (guchar) */ display_act->img->img_mean)
258 / fact);
259 *pos++ = (guchar) ((img[j][i] - /* (guchar) */ min +
260 /* (guchar) */ display_act->img->img_mean)
261 / fact);
267 gdk_pixbuf_unref (pixbuf);
268 *int_size_old = int_size;
269 /* g_free(rgbbuf); */
270 /* rgbbuf = NULL; */
275 static void
276 alloc_bufmem_per_intarea (int index_y,
277 int index_x,
278 PivData *pida,
279 GpivImagePar image_par,
280 int int_size_0
282 /* ----------------------------------------------------------------------------
283 * Memory allocation of covariance in a packed interrogation area array
290 static void
291 free_bufmem_per_intarea (int index_y,
292 int index_x,
293 PivData *pida,
294 GpivImagePar image_par,
295 int int_size_0
297 /*-----------------------------------------------------------------------------
304 static void
305 adjust_radio_button_intsize_f (GpivPivPar *piv_par,
306 PivEval *eval
308 /* ----------------------------------------------------------------------------
309 * Adjust radio button interrogation size 1 in PIV interrogation tab
312 if (piv_par->int_size_f == 16) {
313 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
314 (eval->radiobutton_intsize_f_2), TRUE);
315 } else if (piv_par->int_size_f == 32) {
316 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
317 (eval->radiobutton_intsize_f_3), TRUE);
318 } else if (piv_par->int_size_f == 64) {
319 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
320 (eval->radiobutton_intsize_f_4), TRUE);
321 } else if (piv_par->int_size_f == 128) {
322 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
323 (eval->radiobutton_intsize_f_5), TRUE);
329 static void
330 adjust_radio_button_intsize_i (GpivPivPar *piv_par,
331 PivEval *eval
333 /* ----------------------------------------------------------------------------
334 * Adjust radio button interrogation size 1 in PIV interrogation tab
337 if (piv_par->int_size_i == 16) {
338 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
339 (eval->radiobutton_intsize_i_2), TRUE);
340 } else if (piv_par->int_size_i == 32) {
341 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
342 (eval->radiobutton_intsize_i_3), TRUE);
343 } else if (piv_par->int_size_i == 64) {
344 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
345 (eval->radiobutton_intsize_i_4), TRUE);
346 } else if (piv_par->int_size_i == 128) {
347 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
348 (eval->radiobutton_intsize_i_5), TRUE);
355 static void
356 adjust_radio_button_intshift (GpivPivPar *piv_par,
357 PivEval *eval)
358 /* ----------------------------------------------------------------------------
359 * Adjust radio button interrogation area shift in PIV interrogation tab
362 if (piv_par->int_shift == 8) {
363 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
364 (eval->radiobutton_intshift_1), TRUE);
365 } else if (piv_par->int_shift == 16) {
366 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
367 (eval->radiobutton_intshift_2), TRUE);
368 } else if (piv_par->int_shift == 32) {
369 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
370 (eval->radiobutton_intshift_3), TRUE);
371 } else if (piv_par->int_shift == 64) {
372 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
373 (eval->radiobutton_intshift_4), TRUE);
374 } else if (piv_par->int_shift == 128) {
375 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
376 (eval->radiobutton_intshift_5), TRUE);
383 * Display functions in PIV tabulator canvas
387 void
388 display_piv_vector (guint i,
389 guint j,
390 GpivPivData *piv_data,
391 PivEval *eval
393 /* ----------------------------------------------------------------------------
394 * Displays values in PIV tabulator of the GUI
397 /* float **dx = piv_data->dx, **dy = piv_data->dy; */
398 /* int **peak_no = piv_data->peak_no; */
399 GnomeCanvasPoints *points;
400 float dl = sqrt (piv_data->dx[i][j] * piv_data->dx[i][j] +
401 piv_data->dy[i][j] * piv_data->dy[i][j]);
402 gchar *color;
403 points = gnome_canvas_points_new (2);
405 eval->monitor->pi_da->dx[0][0] = piv_data->dx[i][j];
406 eval->monitor->pi_da->dy[0][0] = piv_data->dy[i][j];
407 eval->monitor->pi_da->peak_no[0][0] = piv_data->peak_no[i][j];
409 if (eval->monitor->pi_da->peak_no[0][0] == -1) {
410 color="red";
411 } else if (eval->monitor->pi_da->peak_no[0][0] == 0) {
412 color="lightblue";
413 } else if (eval->monitor->pi_da->peak_no[0][0] == 1) {
414 color="green";
415 } else if (eval->monitor->pi_da->peak_no[0][0] == 2) {
416 color="yellow";
417 } else {
418 /* if (eval->monitor->pi_da->peak_no[i][j] == 3) */
419 color="gray";
422 points->coords[0] = GPIV_MAX_INTERR_SIZE / 2;
423 points->coords[1] = GPIV_MAX_INTERR_SIZE / 2;
424 points->coords[2] = GPIV_MAX_INTERR_SIZE / 2 + eval->monitor->pi_da->dx[0][0]
425 * gpiv_var->piv_disproc_vlength;
426 points->coords[3] = GPIV_MAX_INTERR_SIZE / 2 + eval->monitor->pi_da->dy[0][0]
427 * gpiv_var->piv_disproc_vlength;
430 if (eval->monitor->gci_vec != NULL) {
431 gnome_canvas_item_set (eval->monitor->gci_vec,
432 "points", points,
433 "fill_color", color,
434 "width_units", (double) THICKNESS,
435 "first_arrowhead", FALSE,
436 "last_arrowhead", TRUE,
437 "arrow_shape_a", (double) ARROW_LENGTH *
438 ARROW_FACT *dl * gpiv_par->display__vector_scale +
439 ARROW_ADD,
440 "arrow_shape_b", (double) ARROW_EDGE *
441 ARROW_FACT * dl * gpiv_par->display__vector_scale +
442 ARROW_ADD,
443 "arrow_shape_c", (double) ARROW_WIDTH *
444 ARROW_FACT * dl * gpiv_par->display__vector_scale +
445 ARROW_ADD,
446 NULL);
447 } else {
448 eval->monitor->gci_vec =
449 gnome_canvas_item_new (gnome_canvas_root
450 (GNOME_CANVAS(eval->canvas_monitor_vec)),
451 gnome_canvas_line_get_type(),
452 "points", points,
453 "fill_color", color,
454 "width_units",(double) THICKNESS,
455 "first_arrowhead", TRUE,
456 "arrow_shape_a", (double) ARROW_LENGTH *
457 ARROW_FACT *dl * gpiv_par->display__vector_scale +
458 ARROW_ADD,
459 "arrow_shape_b", (double) ARROW_EDGE *
460 ARROW_FACT * dl * gpiv_par->display__vector_scale +
461 ARROW_ADD,
462 "arrow_shape_c", (double) ARROW_WIDTH *
463 ARROW_FACT * dl * gpiv_par->display__vector_scale +
464 ARROW_ADD,
466 /* "arrow_shape_a", (double) THICKNESS, */
467 NULL);
471 gnome_canvas_points_free (points);
476 void
477 display_img_intreg1 (float **intreg1,
478 guint int_size,
479 PivEval *eval
481 /* ----------------------------------------------------------------------------
482 * Displays image of intreg1 for drawing area
483 * row stride; each row is a 4-byte buffer array
486 display_img (intreg1,
487 int_size,
488 &eval->monitor->int_size_old,
490 int_size,
492 int_size,
493 eval->monitor->rgb_int_width,
494 &eval->monitor->rgbbuf_int1,
495 eval->canvas_monitor_int1,
496 &eval->monitor->gci_int1,
497 eval->monitor->affine,
498 FALSE);
503 void display_img_intreg2 (float **intreg2,
504 guint int_size,
505 PivEval *eval
507 /* ----------------------------------------------------------------------------
508 * Displays image of intreg2 for drawing area
511 display_img (intreg2,
512 int_size,
513 &eval->monitor->int_size_old,
515 int_size,
517 int_size,
518 eval->monitor->rgb_int_width,
519 &eval->monitor->rgbbuf_int2,
520 eval->canvas_monitor_int2,
521 &eval->monitor->gci_int2,
522 eval->monitor->affine,
523 FALSE);
529 void display_img_cov (GpivCov *cov,
530 guint int_size,
531 PivEval *eval
533 /* ----------------------------------------------------------------------------
534 * Displays image of intreg1 for drawing area
537 display_img (cov->z,
538 int_size,
539 &eval->monitor->cov_size_old,
540 cov->z_cl,
541 cov->z_ch,
542 cov->z_rl,
543 cov->z_rh,
544 eval->monitor->rgb_cov_width,
545 &eval->monitor->rgbbuf_cov,
546 eval->canvas_monitor_cov,
547 &eval->monitor->gci_cov,
548 eval->monitor->affine,
549 TRUE);
555 * Piv evaluation window/tabulator callbacks
559 void
560 on_radiobutton_piv_mouse (GtkWidget *widget,
561 gpointer data
563 /*-----------------------------------------------------------------------------
566 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
567 m_select = atoi(gtk_object_get_data(GTK_OBJECT(widget),
568 "mouse_select"));
570 /* g_message ("on_radiobutton_piv_mouse:: 0 m_select = %d", m_select); */
571 if (m_select == NO_MS) {
572 gl_piv_par->int_geo = GPIV_AOI;
574 } else if (m_select == AOI_MS) {
575 gl_piv_par->int_geo = GPIV_AOI;
576 } else if (m_select == SINGLE_POINT_MS) {
577 gl_piv_par->int_geo = GPIV_POINT;
578 } else if (m_select == V_LINE_MS) {
579 /* gl_piv_par->int_geo = GPIV_LINE_C; */
580 gl_piv_par->int_geo = GPIV_AOI;
581 } else if (m_select == H_LINE_MS) {
582 /* gl_piv_par->int_geo = GPIV_LINE_R; */
583 gl_piv_par->int_geo = GPIV_AOI;
584 } else if (m_select == SINGLE_AREA_MS ||
585 m_select == DRAG_MS) {
586 gl_piv_par->int_geo = GPIV_POINT;
590 * (Re)setting interrogation scheme if necessary
592 if ((m_select == SINGLE_AREA_MS
593 || m_select == DRAG_MS
594 || m_select == SINGLE_POINT_MS
595 || m_select == V_LINE_MS
596 || m_select == H_LINE_MS)
597 && gl_piv_par->int_scheme == GPIV_IMG_DEFORM
599 char message[2 * GPIV_MAX_CHARS];
600 g_snprintf (message, 2 * GPIV_MAX_CHARS,
601 _("Image deformation is impossibe with this Mouse select.\n\
602 Setting Interrogation scheme to Central difference.\n\
603 This will be reset automatically after interrogating."));
604 warning_gpiv (message);
605 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
606 (gpiv->piveval->radiobutton_centraldiff),
607 TRUE);
608 int_scheme_autochanged = TRUE;
609 } else {
610 if (int_scheme_autochanged) {
611 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
612 (gpiv->piveval->radiobutton_imgdeform),
613 TRUE);
614 int_scheme_autochanged = FALSE;
621 void
622 on_radiobutton_piv_mouse1_enter (GtkWidget *widget,
623 gpointer data
625 /*-----------------------------------------------------------------------------
628 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
629 gchar *msg = _("No mouse activity within displayer");
630 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
635 void
636 on_radiobutton_piv_mouse2_enter (GtkWidget *widget,
637 gpointer data
639 /*-----------------------------------------------------------------------------
642 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
643 gchar *msg = _("Selects an area within the image to be analyzed");
644 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
649 void
650 on_radiobutton_piv_mouse3_enter (GtkWidget *widget,
651 gpointer data
653 /*-----------------------------------------------------------------------------
656 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
657 gchar *msg = _("Piv evaluation at a single interrogation area. "
658 "Conserves other existing data");
659 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
664 void
665 on_radiobutton_piv_mouse4_enter (GtkWidget *widget,
666 gpointer data
668 /*-----------------------------------------------------------------------------
671 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
672 gchar *msg = _("Piv evaluation at a single point in the image. "
673 "Rejects all existing data!!");
674 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
679 void
680 on_radiobutton_piv_mouse5_enter (GtkWidget *widget,
681 gpointer data
683 /*-----------------------------------------------------------------------------
686 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
687 gchar *msg = _("Displaces a single interrogation area and analyzes");
688 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
693 void
694 on_radiobutton_piv_mouse6_enter (GtkWidget *widget,
695 gpointer data
697 /*-----------------------------------------------------------------------------
700 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
701 gchar *msg = _("Evaluation at a vertical line. ");
702 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
707 void
708 on_radiobutton_piv_mouse7_enter (GtkWidget *widget,
709 gpointer data
711 /*-----------------------------------------------------------------------------
714 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
715 gchar *msg = _("Evaluation at a horizontal line. ");
716 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
721 void
722 on_spinbutton_piv_int (GtkSpinButton *widget,
723 GtkWidget *entry
725 /*-----------------------------------------------------------------------------
728 char *err_msg = NULL;
729 PivEval *eval = gtk_object_get_data(GTK_OBJECT (widget), "eval");
730 guint nx = 0, ny = 0;
731 guint nx_img = 0, ny_img = 0;
732 gboolean renew = TRUE, lo_display_intregs = FALSE;
734 enum VariableType {
735 COL_START = 0,
736 COL_END = 1,
737 PRESHIFT_COL = 2,
738 ROWSTART = 3,
739 ROWEND = 4,
740 PRESHIFT_ROW = 5,
741 INT_SIZE_F = 6,
742 INT_SIZE_I = 7,
743 INT_SHIFT = 8
744 } var_type;
747 /* eval = gtk_object_get_data(GTK_OBJECT(widget), "eval"); */
749 * Locale vars
751 /* Display display_act; */
752 /* display_act = gtk_object_get_data(widget, display_act); */
755 * Select which variable has to be modified
757 setby_spinbutton = 1;
758 var_type = atoi(gtk_object_get_data (GTK_OBJECT (widget), "var_type"));
760 if (var_type == COL_START) {
761 gl_piv_par->col_start = gtk_spin_button_get_value_as_int (widget);
763 } else if (var_type == COL_END) {
764 gl_piv_par->col_end = gtk_spin_button_get_value_as_int (widget);
766 } else if (var_type == PRESHIFT_COL) {
767 gl_piv_par->pre_shift_col = gtk_spin_button_get_value_as_int (widget);
769 } else if (var_type == ROWSTART) {
770 gl_piv_par->row_start = gtk_spin_button_get_value_as_int (widget);
772 } else if (var_type == ROWEND) {
773 gl_piv_par->row_end = gtk_spin_button_get_value_as_int (widget);
775 } else if (var_type == PRESHIFT_ROW) {
776 gl_piv_par->pre_shift_row = gtk_spin_button_get_value_as_int (widget);
778 } else if (var_type == INT_SIZE_F) {
779 gl_piv_par->int_size_f = gtk_spin_button_get_value_as_int (widget);
782 * Adapt spinbutton of int_size_i
784 GTK_ADJUSTMENT(eval->spinbutton_adj_intsize_i)->lower =
785 (gfloat) gl_piv_par->int_size_f;
786 GTK_ADJUSTMENT(eval->spinbutton_adj_intsize_i)->upper =
787 (gfloat) 128.0;
788 gtk_adjustment_changed (GTK_ADJUSTMENT(eval->spinbutton_adj_intsize_i));
789 gtk_adjustment_set_value (GTK_ADJUSTMENT(eval->spinbutton_adj_intsize_i),
790 (gfloat) gl_piv_par->int_size_f);
793 * Adjust radio buttons for final interrogation size
795 adjust_radio_button_intsize_f (gl_piv_par, eval);
797 } else if (var_type == INT_SIZE_I) {
798 char message[GPIV_MAX_CHARS];
800 gl_piv_par->int_size_i = gtk_spin_button_get_value_as_int (widget);
801 if ((gl_piv_par->int_scheme == GPIV_NO_CORR
802 || gl_piv_par->int_scheme == GPIV_LK_WEIGHT)
803 && gl_piv_par->int_size_i > gl_piv_par->int_size_f) {
804 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
805 (eval->radiobutton_imgdeform),
806 TRUE);
807 g_snprintf (message, GPIV_MAX_CHARS,
808 _("Int Size 2 > Int Size 1 \nSetting Interrogation scheme to Image deformation"));
809 warning_gpiv(message);
811 /* } else { */
812 /* gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON */
813 /* (eval->radiobutton_zerooff), */
814 /* FALSE); */
818 * Adjust radio buttons for initial interrogation size
820 adjust_radio_button_intsize_i (gl_piv_par, eval);
822 } else if (var_type == INT_SHIFT) {
823 gl_piv_par->int_shift = gtk_spin_button_get_value_as_int (widget);
826 * Adjust radio buttons for interrogation area shift
828 adjust_radio_button_intshift (gl_piv_par, eval);
832 * Update eventually interrogation region contours.
834 if (display_act != NULL) {
835 if ((err_msg =
836 gpiv_piv_testadjust_parameters (display_act->img->image->header,
837 gl_piv_par))
838 != NULL) {
839 warning_gpiv ("%s", err_msg);
840 return;
843 display_act->intreg->par->row_start = gl_piv_par->row_start;
844 display_act->intreg->par->row_end = gl_piv_par->row_end;
845 display_act->intreg->par->col_start = gl_piv_par->col_start;
846 display_act->intreg->par->col_end = gl_piv_par->col_end;
847 display_act->intreg->par->int_shift = gl_piv_par->int_shift;
848 display_act->intreg->par->int_size_f = gl_piv_par->int_size_f;
849 display_act->intreg->par->int_size_i = gl_piv_par->int_size_i;
850 display_act->intreg->par->pre_shift_row = gl_piv_par->pre_shift_row;
851 display_act->intreg->par->pre_shift_col = gl_piv_par->pre_shift_col;
853 display_act->intreg->par->row_start__set = TRUE;
854 display_act->intreg->par->row_end__set = TRUE;
855 display_act->intreg->par->col_start__set = TRUE;
856 display_act->intreg->par->col_end__set = TRUE;
857 display_act->intreg->par->int_size_f__set = TRUE;
858 display_act->intreg->par->int_size_i__set = TRUE;
859 display_act->intreg->par->int_shift__set = TRUE;
860 display_act->intreg->par->pre_shift_row__set = TRUE;
861 display_act->intreg->par->pre_shift_col__set = TRUE;
863 if (display_act->intreg->exist_int) {
864 nx = display_act->intreg->data->nx;
865 ny = display_act->intreg->data->ny;
867 if ((err_msg =
868 gpiv_piv_count_pivdata_fromimage (display_act->img->image->header,
869 display_act->intreg->par,
870 &nx_img,
871 &ny_img))
872 != NULL) {
873 warning_gpiv ("on_spinbutton_piv_int: %s", err_msg);
874 g_warning ("on_spinbutton_piv_int: %s", err_msg);
875 return;
878 * For some operations the intregs have to be renewed unconditionally,
879 * for others only in case if the number of intregs has been changed
881 if (var_type == COL_START || var_type == COL_END
882 || var_type == ROWSTART || var_type == ROWEND) {
883 if (nx == nx_img
884 && ny == ny_img) {
885 renew = FALSE;
886 } else {
887 renew = TRUE;
891 if (renew) {
892 lo_display_intregs = display_act->display_intregs;
893 destroy_all_intregs (display_act);
894 create_all_intregs (display_act);
895 display_act->display_intregs = lo_display_intregs;
896 if (display_act->display_intregs) show_all_intregs(display_act);
902 setby_spinbutton = 0;
907 void
908 on_radiobutton_piv_int (GtkWidget *widget,
909 gpointer data
911 /*-----------------------------------------------------------------------------
914 gint int_size_f_tmp;
915 gboolean lo_display_intregs = FALSE;
916 gint nx_tmp = 0, ny_tmp = 0;
917 /* gint setby_spinbutton = atoi(gtk_object_get_data(GTK_OBJECT(widget), */
918 /* "setby_spinbutton")); */
919 PivEval *eval = gtk_object_get_data(GTK_OBJECT (widget), "eval");
920 Display *disp = display_act;
921 int nx, ny;
923 enum VariableType {
924 SIZE_F = 0,
925 SIZE_I = 1,
926 SHIFT = 2
927 } var_type;
930 if (disp != NULL
931 && disp->intreg->exist_int) {
932 nx = disp->intreg->data->nx;
933 ny = disp->intreg->data->ny;
934 } else {
935 nx = 0;
936 ny = 0;
939 if (GTK_TOGGLE_BUTTON(widget)->active) {
940 var_type = atoi(gtk_object_get_data (GTK_OBJECT(widget),
941 "var_type"));
944 * Select which variable has to be modified
946 if (var_type == SIZE_F) {
947 int_size_f_tmp = gl_piv_par->int_size_f;
948 gl_piv_par->int_size_f = atoi (gtk_object_get_data
949 (GTK_OBJECT(widget),
950 "intsize_f"));
952 * switch off temporarly display_intregs
954 if (disp != NULL) {
955 lo_display_intregs = disp->display_intregs;
956 disp->display_intregs = FALSE;
958 nx_tmp = nx;
959 ny_tmp = ny;
960 adjust_radiobutton_piv_int (eval, gl_piv_par->int_size_f);
963 * return display_intregs to original value
965 if (disp != NULL) {
966 disp->display_intregs = lo_display_intregs;
968 nx = nx_tmp;
969 ny = ny_tmp;
971 * BUGFIX: REMOVE Reset weight and zero_off
973 if (gl_piv_par->int_size_i > int_size_f_tmp) {
974 /* gtk_widget_set_sensitive(eval->radiobutton_zerooff, TRUE); */
975 /* gtk_widget_set_sensitive(checkbutton_piv_weightkernel, TRUE); */
978 if (int_scheme_tmp != GPIV_ZERO_OFF_FORWARD
979 && int_scheme_tmp != GPIV_ZERO_OFF_CENTRAL) {
980 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
981 (eval->radiobutton_zerooff),
982 FALSE);
983 gtk_widget_set_sensitive(eval->radiobutton_zerooff, TRUE);
984 gtk_widget_set_sensitive(eval->radiobutton_weightkernel,
985 TRUE);
986 if (int_scheme_tmp == GPIV_LK_WEIGHT) {
987 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
988 (eval->radiobutton_weightkernel),
989 FALSE);
990 gtk_widget_set_sensitive(eval->radiobutton_zerooff,
991 TRUE);
992 gtk_widget_set_sensitive(eval->radiobutton_weightkernel, TRUE);
993 } else {
994 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
995 (eval->radiobutton_weightkernel),
996 TRUE);
997 gtk_widget_set_sensitive(eval->radiobutton_zerooff,
998 FALSE);
999 gtk_widget_set_sensitive(eval->radiobutton_weightkernel,
1000 TRUE);
1002 } else {
1003 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1004 (eval->radiobutton_zerooff),
1005 TRUE);
1006 gtk_widget_set_sensitive(eval->radiobutton_zerooff, TRUE);
1007 gtk_widget_set_sensitive(eval->radiobutton_weightkernel,
1008 FALSE);
1014 * Also calls on_spinbutton_piv_int, which, on its turn, may call this function
1015 * again resulting into an infinite loop
1017 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1018 (eval->spinbutton_intsize_f),
1019 gl_piv_par->int_size_f);
1022 } else if (var_type == SIZE_I) {
1023 gl_piv_par->int_size_i =
1024 atoi (gtk_object_get_data (GTK_OBJECT(widget), "intsize_i"));
1027 * Adjust spinner
1029 gtk_adjustment_set_value (GTK_ADJUSTMENT
1030 (eval->spinbutton_adj_intsize_i),
1031 (gfloat) gl_piv_par->int_size_i);
1033 * Save origanal settings of weight and zero_off for later resetting
1035 if (gl_piv_par->int_size_i > gl_piv_par->int_size_f) {
1036 int_scheme_tmp = gl_piv_par->int_scheme;
1038 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1039 (eval->radiobutton_weightkernel), FALSE);
1040 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1041 (eval->radiobutton_zerooff), TRUE);
1042 gtk_widget_set_sensitive(eval->radiobutton_zerooff, FALSE);
1046 * Reset weight and zero_off
1048 } else {
1049 /* if (zero_off_tmp == 0) {
1050 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1051 (eval->radiobutton_zerooff), FALSE);
1052 if (weight_tmp == 0) {
1053 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1054 (eval->radiobutton_weightkernel), FALSE);
1055 } else {
1056 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1057 (eval->radiobutton_weightkernel), TRUE);
1059 } else {
1060 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1061 (eval->radiobutton_zerooff), TRUE);
1063 gtk_widget_set_sensitive(eval->radiobutton_zerooff, TRUE);
1068 } else if (var_type == SHIFT) {
1069 gl_piv_par->int_shift =
1070 atoi (gtk_object_get_data (GTK_OBJECT(widget),
1071 "intshift"));
1073 * Adjust spinner
1075 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1076 (eval->spinbutton_intshift),
1077 gl_piv_par->int_shift);
1080 if (disp != NULL
1081 && disp->intreg->exist_int
1083 lo_display_intregs = disp->display_intregs;
1084 destroy_all_intregs (disp);
1085 create_all_intregs (disp);
1086 disp->display_intregs = lo_display_intregs;
1087 if (disp->display_intregs) show_all_intregs(disp);
1097 void
1098 on_radiobutton_fit_enter (GtkWidget *widget,
1099 gpointer data
1101 /*-----------------------------------------------------------------------------
1104 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1105 gchar *msg = _("Interpolation scheme for sub-pixel estimation");
1106 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1112 void
1113 on_radiobutton_peak_enter (GtkWidget *widget,
1114 gpointer data
1116 /*-----------------------------------------------------------------------------
1119 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1120 gchar *msg = _("Chooses n-th highest top number of correlation as estimator");
1121 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1127 void
1128 on_radiobutton_interrogatescheme_enter (GtkWidget *widget,
1129 gpointer data
1131 /*-----------------------------------------------------------------------------
1134 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
1135 gchar *msg = _("Bias correction scheme");
1136 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1142 void
1143 on_radiobutton_interrogatescheme_imgdeform_enter (GtkWidget *widget,
1144 gpointer data
1146 /*-----------------------------------------------------------------------------
1149 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
1150 gchar *msg = _("Deforms image from PIV estimators");
1151 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1157 void
1158 on_toggle_piv (GtkWidget *widget,
1159 gpointer data
1161 /*-----------------------------------------------------------------------------
1164 PivEval *eval = gtk_object_get_data(GTK_OBJECT (widget), "eval");
1165 enum VariableType {
1166 IFIT,
1167 PEAK_NR,
1168 SCHEME,
1169 CORRELATION
1170 } var_type;
1173 * Select which variable has to be modified
1175 var_type = atoi (gtk_object_get_data (GTK_OBJECT(widget), "var_type"));
1177 if (var_type == IFIT) {
1178 gl_piv_par->ifit = atoi (gtk_object_get_data (GTK_OBJECT(widget),
1179 "ifit"));
1181 } else if (var_type == PEAK_NR) {
1182 gl_piv_par->peak = atoi (gtk_object_get_data (GTK_OBJECT(widget),
1183 "peak"));
1186 } else if (var_type == SCHEME) {
1187 gl_piv_par->int_scheme = atoi(gtk_object_get_data(GTK_OBJECT(widget),
1188 "scheme"));
1190 } else if (var_type == CORRELATION) {
1191 gl_image_par->x_corr = atoi (gtk_object_get_data (GTK_OBJECT(widget),
1192 "x_corr"));
1199 void
1200 on_checkbutton_weight_ia_enter (GtkWidget *widget,
1201 gpointer data
1203 /*-----------------------------------------------------------------------------
1206 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1207 gchar *msg =
1208 _("Gauss weighting on the Interrogation Area");
1209 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1214 void
1215 on_checkbutton_weight_ia (GtkWidget *widget,
1216 gpointer data)
1217 /*-----------------------------------------------------------------------------
1220 PivEval *eval = gtk_object_get_data (GTK_OBJECT(widget), "eval");
1223 if (GTK_TOGGLE_BUTTON(widget)->active) {
1224 gl_piv_par->gauss_weight_ia = TRUE;
1225 } else {
1226 gl_piv_par->gauss_weight_ia = FALSE;
1231 void
1232 on_checkbutton_spof_enter (GtkWidget *widget,
1233 gpointer data
1235 /*-----------------------------------------------------------------------------
1238 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1239 gchar *msg =
1240 _("Symmetric Phase Only Filtering on the FT images");
1241 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1246 void
1247 on_checkbutton_spof (GtkWidget *widget,
1248 gpointer data)
1249 /*-----------------------------------------------------------------------------
1252 PivEval *eval = gtk_object_get_data (GTK_OBJECT(widget), "eval");
1255 if (GTK_TOGGLE_BUTTON(widget)->active) {
1256 gl_piv_par->spof_filter = TRUE;
1257 } else {
1258 gl_piv_par->spof_filter = FALSE;
1263 void
1264 adjust_radiobutton_piv_int (PivEval *eval,
1265 guint int_size_f
1267 /* ----------------------------------------------------------------------------
1268 * adjusting and disabling int_size_i and its toggle buttons
1271 /* if (int_size_f == 8) { */
1272 /* gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON */
1273 /* (eval->radiobutton_intsize_i_1), TRUE); */
1274 /* } else */
1276 if (int_size_f == 16) {
1277 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1278 (eval->radiobutton_intsize_i_2), TRUE);
1280 } else if (int_size_f == 32) {
1281 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1282 (eval->radiobutton_intsize_i_3), TRUE);
1284 } else if (int_size_f == 64) {
1285 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1286 (eval->radiobutton_intsize_i_4), TRUE);
1288 } else if (int_size_f >= 128) {
1289 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1290 (eval->radiobutton_intsize_i_5), TRUE);
1294 if (int_size_f <= 64) {
1295 gtk_widget_set_sensitive (GTK_WIDGET(eval->radiobutton_intsize_i_4),
1296 TRUE);
1297 if (int_size_f <= 32) {
1298 gtk_widget_set_sensitive (GTK_WIDGET
1299 (eval->radiobutton_intsize_i_3),
1300 TRUE);
1301 if (int_size_f <= 16) {
1302 gtk_widget_set_sensitive (GTK_WIDGET
1303 (eval->radiobutton_intsize_i_2),
1304 TRUE);
1305 /* if (int_size_f <= 8) { */
1306 /* gtk_widget_set_sensitive(GTK_WIDGET */
1307 /* (eval->radiobutton_intsize_i_1), */
1308 /* TRUE); */
1309 /* } */
1316 if (int_size_f >= 16) {
1317 /* gtk_widget_set_sensitive(GTK_WIDGET(eval->radiobutton_intsize_i_1), */
1318 /* FALSE); */
1319 if (int_size_f >= 32) {
1320 gtk_widget_set_sensitive (GTK_WIDGET
1321 (eval->radiobutton_intsize_i_2),
1322 FALSE);
1323 if (int_size_f >= 64) {
1324 gtk_widget_set_sensitive (GTK_WIDGET
1325 (eval->radiobutton_intsize_i_3),
1326 FALSE);
1327 if (int_size_f >= 128) {
1328 gtk_widget_set_sensitive (GTK_WIDGET
1329 (eval->radiobutton_intsize_i_4),
1330 FALSE);
1340 void
1341 on_checkbutton_piv_monitor_enter (GtkWidget *widget,
1342 gpointer data
1344 /*-----------------------------------------------------------------------------
1347 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1348 gchar *msg =
1349 _("Displays subimages, correlation function and PIV vector");
1350 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1355 void
1356 on_checkbutton_piv_monitor (GtkWidget *widget,
1357 gpointer data)
1358 /*-----------------------------------------------------------------------------
1361 PivEval *eval = gtk_object_get_data (GTK_OBJECT(widget), "eval");
1364 if (GTK_TOGGLE_BUTTON(widget)->active) {
1365 gpiv_var->piv_disproc = TRUE;
1367 eval->monitor->gci_vec_background =
1368 gnome_canvas_item_new (gnome_canvas_root
1369 (GNOME_CANVAS(eval->canvas_monitor_vec)),
1370 gnome_canvas_rect_get_type(),
1371 "x1", (double) 0,
1372 "y1", (double) 0,
1373 "x2", (double) GPIV_MAX_INTERR_SIZE,
1374 "y2", (double) GPIV_MAX_INTERR_SIZE,
1375 "fill_color", "darkblue",
1376 "width_units", 1.0,
1377 NULL);
1380 eval->monitor->gci_int1_background =
1381 gnome_canvas_item_new (gnome_canvas_root
1382 (GNOME_CANVAS(eval->canvas_monitor_int1)),
1383 gnome_canvas_rect_get_type(),
1384 "x1", (double) 0,
1385 "y1", (double) 0,
1386 "x2", (double) GPIV_MAX_INTERR_SIZE,
1387 "y2", (double) GPIV_MAX_INTERR_SIZE,
1388 "fill_color", "darkgreen",
1389 "width_units", 1.0,
1390 NULL);
1393 eval->monitor->gci_int2_background =
1394 gnome_canvas_item_new (gnome_canvas_root
1395 (GNOME_CANVAS(eval->canvas_monitor_int2)),
1396 gnome_canvas_rect_get_type(),
1397 "x1", (double) 0,
1398 "y1", (double) 0,
1399 "x2", (double) GPIV_MAX_INTERR_SIZE,
1400 "y2", (double) GPIV_MAX_INTERR_SIZE,
1401 "fill_color", "darkgreen",
1402 "width_units", 1.0,
1403 NULL);
1406 eval->monitor->gci_background_cov =
1407 gnome_canvas_item_new (gnome_canvas_root
1408 (GNOME_CANVAS(eval->canvas_monitor_cov)),
1409 gnome_canvas_rect_get_type(),
1410 "x1", (double) 0,
1411 "y1", (double) 0,
1412 "x2", (double) GPIV_MAX_INTERR_SIZE,
1413 "y2", (double) GPIV_MAX_INTERR_SIZE,
1414 "fill_color", "darkred",
1415 "width_units", 1.0,
1416 NULL);
1417 } else {
1418 gpiv_var->piv_disproc = FALSE;
1420 * Destroy intreg1 image
1422 if (eval->monitor->gci_int1_background != NULL) {
1423 gtk_object_destroy (GTK_OBJECT(eval->monitor->
1424 gci_int1_background));
1425 eval->monitor->gci_int1_background = NULL;
1428 if (eval->monitor->rgbbuf_int1 != NULL) {
1429 g_free (eval->monitor->rgbbuf_int1);
1430 eval->monitor->rgbbuf_int1 = NULL;
1433 if (eval->monitor->gci_int1 != NULL) {
1434 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_int1));
1435 eval->monitor->gci_int1 = NULL;
1439 * Destroy intreg2 image
1441 if (eval->monitor->gci_int2_background != NULL) {
1442 gtk_object_destroy (GTK_OBJECT(eval->monitor->
1443 gci_int2_background));
1444 eval->monitor->gci_int2_background = NULL;
1447 if (eval->monitor->rgbbuf_int2 != NULL) {
1448 g_free (eval->monitor->rgbbuf_int2);
1449 eval->monitor->rgbbuf_int2 = NULL;
1452 if (eval->monitor->gci_int2 != NULL) {
1453 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_int2));
1454 eval->monitor->gci_int2 = NULL;
1458 * Destroy correlation image
1460 if (eval->monitor->gci_background_cov != NULL) {
1461 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_background_cov));
1462 eval->monitor->gci_background_cov = NULL;
1465 if (eval->monitor->rgbbuf_cov != NULL) {
1466 g_free (eval->monitor->rgbbuf_cov);
1467 eval->monitor->rgbbuf_cov = NULL;
1470 if (eval->monitor->gci_cov != NULL) {
1471 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_cov));
1472 eval->monitor->gci_cov = NULL;
1476 * Destroy vector
1478 if (eval->monitor->gci_vec_background != NULL) {
1479 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_vec_background));
1480 eval->monitor->gci_vec_background = NULL;
1484 if (eval->monitor->gci_vec != NULL) {
1485 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_vec));
1486 eval->monitor->gci_vec = NULL;
1494 void
1495 on_spinbutton_piv_monitor_zoom (GtkSpinButton *widget,
1496 gpointer data
1498 /*-----------------------------------------------------------------------------
1501 PivEval *eval = gtk_object_get_data (GTK_OBJECT(widget), "eval");
1502 /* gfloat piv_disproc_zoom */
1504 gpiv_var->piv_disproc_zoom = gtk_spin_button_get_value_as_float (widget);
1505 gnome_config_push_prefix("/gpiv/RuntimeVariables/");
1506 gnome_config_set_float ("zoom_factor", gpiv_var->piv_disproc_zoom);
1507 gnome_config_pop_prefix ();
1508 gnome_config_sync();
1510 eval->monitor->affine[0] = gpiv_var->piv_disproc_zoom;
1511 eval->monitor->affine[3] = gpiv_var->piv_disproc_zoom;
1512 eval->monitor->affine[4] =
1513 (GPIV_MAX_INTERR_SIZE - gpiv_var->piv_disproc_zoom
1514 * gl_piv_par->int_size_f) /2.0;
1515 eval->monitor->affine[5] =
1516 (GPIV_MAX_INTERR_SIZE - gpiv_var->piv_disproc_zoom
1517 * gl_piv_par->int_size_f) /2.0;
1519 if(eval->monitor->gci_int1 != NULL) {
1520 gnome_canvas_item_affine_absolute (eval->monitor->gci_int1,
1521 eval->monitor->affine);
1524 if(eval->monitor->gci_int2 != NULL) {
1525 gnome_canvas_item_affine_absolute (eval->monitor->gci_int2,
1526 eval->monitor->affine);
1530 if(eval->monitor->gci_cov != NULL) {
1531 gnome_canvas_item_affine_absolute (eval->monitor->gci_cov,
1532 eval->monitor->affine);
1540 void
1541 on_spinbutton_piv_monitor_vectorscale (GtkSpinButton *widget,
1542 gpointer data
1544 /*-----------------------------------------------------------------------------
1547 PivEval *eval = gtk_object_get_data (GTK_OBJECT (widget), "eval");
1548 /* gint piv_disproc_vlength */
1550 gpiv_var->piv_disproc_vlength = gtk_spin_button_get_value_as_int (widget);
1551 gnome_config_set_int ("vector_length", gpiv_var->piv_disproc_vlength);
1552 gnome_config_sync ();
1555 * Try to re-scale vector
1557 if(eval->monitor->gci_vec != NULL) {
1558 GnomeCanvasPoints *points = gnome_canvas_points_new (2);
1560 points->coords[0] = GPIV_MAX_INTERR_SIZE / 2;
1561 points->coords[1] = GPIV_MAX_INTERR_SIZE / 2;
1562 points->coords[2] = GPIV_MAX_INTERR_SIZE / 2 + eval->monitor->pi_da->dx[0][0] *
1563 gpiv_var->piv_disproc_vlength;
1564 points->coords[3] = GPIV_MAX_INTERR_SIZE / 2 + eval->monitor->pi_da->dy[0][0] *
1565 gpiv_var->piv_disproc_vlength;
1567 gnome_canvas_item_set (eval->monitor->gci_vec,
1568 "points", points,
1569 NULL);
1571 gnome_canvas_points_free (points);
1577 void
1578 on_button_piv_enter (GtkWidget *widget,
1579 gpointer data
1581 /*-----------------------------------------------------------------------------
1584 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
1585 gchar *msg = _("Analyses a PIV image (pair)");
1586 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1591 void
1592 on_button_piv (GtkWidget *widget,
1593 gpointer data
1595 /* ----------------------------------------------------------------------------
1596 * The actual calculation of particle image displacements
1599 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
1600 gint row, ibuf;
1602 cancel_process = FALSE;
1604 if (nbufs > 0) {
1605 for (row = gpiv->first_selected_row; row <= gpiv->last_selected_row;
1606 row++) {
1607 display_act = gtk_clist_get_row_data (GTK_CLIST (gpiv->clist_buf),
1608 row);
1609 ibuf = display_act->id;
1610 if (display[ibuf] != NULL
1611 && display_act->mwin != NULL
1612 && GTK_WIDGET_VISIBLE (GTK_WIDGET (display_act->mwin))) {
1613 gdk_window_show (GTK_WIDGET (display_act->mwin)->window);
1614 gdk_window_raise (GTK_WIDGET (display_act->mwin)->window);
1617 exec_piv (gpiv);