updated copyright statement
[gpiv.git] / src / piveval.c
blobc0de61fb521f3cbd80b34b39ee4e5ad67456559a
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, 2005, 2006, 2007, 2008
9 Gerber van der Graaf
11 This file is part of gpiv.
13 Gpiv is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
16 any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ----------------------------------------------------------------------*/
30 * (callback) functions for Piv evaluation window/tabulator
31 * $Log: piveval.c,v $
32 * Revision 1.23 2008-04-28 12:00:57 gerber
33 * hdf-formatted files are now with .hdf extension (previously: .gpi)
35 * Revision 1.22 2007-11-23 16:24:07 gerber
36 * release 0.5.0: Kafka
38 * Revision 1.21 2007-06-06 17:00:48 gerber
39 * Retreives images/data from URI using Gnome Virtual File System.
41 * Revision 1.20 2007-03-22 16:00:32 gerber
42 * Added image processing tabulator
44 * Revision 1.19 2007-02-16 17:09:48 gerber
45 * added Gauss weighting on I.A. and SPOF filtering (on correlation function)
47 * Revision 1.18 2007/02/05 15:17:09 gerber
48 * auto stretching, broadcast display settings to buffers from preferences
50 * Revision 1.17 2007-01-29 11:27:43 gerber
51 * added image formats png, gif, tif png, bmp, improved buffer display
53 * Revision 1.16 2006-09-18 07:27:06 gerber
54 * *** empty log message ***
56 * Revision 1.15 2006/01/31 14:28:12 gerber
57 * version 0.3.0
59 * Revision 1.13 2005/02/26 09:43:30 gerber
60 * parameter flags (parameter_logic) defined as gboolean
62 * Revision 1.12 2005/02/26 09:17:14 gerber
63 * structured of interrogate function by using gpiv_piv_isiadapt
65 * Revision 1.11 2005/01/19 15:53:42 gerber
66 * Initiation of Data Acquisition (DAC); trigerring of lasers and camera
67 * by using RTAI and Realtime Linux, recording images from IEEE1394
68 * (Firewire) IIDC compliant camera's
70 * Revision 1.10 2004/10/15 19:24:05 gerber
71 * GPIV_ and Gpiv prefix to defines and structure names of libgpiv
73 * Revision 1.9 2004/06/14 21:19:23 gerber
74 * Image depth up to 16 bits.
75 * Improvement "single int" and "drag int" in Eval tab.
76 * Viewer's pop-up menu.
77 * Adaption for gpiv_matrix_* and gpiv_vector_*.
78 * Resizing console.
79 * See Changelog for further info.
81 * Revision 1.8 2003/09/01 11:17:15 gerber
82 * improved monitoring of interrogation process
84 * Revision 1.7 2003/08/22 15:24:52 gerber
85 * interactive spatial scaling
87 * Revision 1.6 2003/07/13 14:38:18 gerber
88 * changed error handling of libgpiv
90 * Revision 1.5 2003/07/12 21:21:16 gerber
91 * changed error handling libgpiv
93 * Revision 1.3 2003/07/10 11:56:07 gerber
94 * added man page
96 * Revision 1.2 2003/06/27 13:47:26 gerber
97 * display ruler, line/point evaluation
99 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
100 * Imported gpiv
105 #include "gpiv_gui.h"
106 #include "utils.h"
107 #include "piveval.h"
108 #include "piveval_interrogate.h"
109 #include "display.h"
113 * Private piv evaluation functions
117 static void
118 display_img (float **img,
119 gint int_size,
120 gint *int_size_old,
121 gint i_min,
122 gint i_max,
123 gint j_min,
124 gint j_max,
125 gint rgb_width,
126 guchar **rgbbuf,
127 GtkWidget *canvas,
128 GnomeCanvasItem **gci,
129 double affine[6],
130 gboolean scale
132 /* ----------------------------------------------------------------------------
133 * Displaying routine in gnome canvas
136 guchar *pos;
137 gint i, j;
138 float min = 1000.0, max = -1000.0;
140 GdkPixbuf *pixbuf = NULL;
141 guint16 fact = 1;
142 gint depth = 8;
144 assert (img[0] != NULL);
146 fact = fact << (gl_image_par->depth - depth);
147 /* g_message ("DISPLAY_IMG:: fact = %d", fact); */
149 if (*rgbbuf != NULL) {
150 g_free(*rgbbuf);
151 *rgbbuf = NULL;
154 if (*rgbbuf == NULL) {
156 * row stride; each row is a 4-byte buffer array
158 rgb_width = (i_max - i_min) * 3;
159 while ((rgb_width) % 4 != 0) {
160 rgb_width++;
163 *rgbbuf = g_malloc (rgb_width * 3 * (j_max - j_min));
167 if (*gci != NULL) {
168 gtk_object_destroy (GTK_OBJECT(*gci));
169 *gci = NULL;
173 pixbuf = gdk_pixbuf_new_from_data (*rgbbuf,
174 GDK_COLORSPACE_RGB,
175 FALSE,
176 depth,
177 i_max - i_min,
178 j_max - j_min,
179 rgb_width,
180 NULL,
181 NULL);
185 *gci = gnome_canvas_item_new (gnome_canvas_root( GNOME_CANVAS
186 (canvas)),
187 gnome_canvas_pixbuf_get_type (),
188 "pixbuf", pixbuf,
189 NULL);
190 /* BUGFIX: new (check mem) */
191 /* gdk_pixbuf_unref (pixbuf); */
194 affine[4] = (GPIV_MAX_INTERR_SIZE - gpiv_var->piv_disproc_zoom
195 * int_size) / 2.0;
196 affine[5] = (GPIV_MAX_INTERR_SIZE - gpiv_var->piv_disproc_zoom
197 * int_size) / 2.0;
198 gnome_canvas_item_affine_absolute (*gci, affine);
201 * As the mean has been subtracted from the image data, image intensities
202 * will have to be tilted above zero
204 if (scale) {
205 for (j = j_min; j < j_max; j++) {
206 for (i = i_min; i < i_max; i++) {
207 if (img[j][i] < min)
208 min = img[j][i];
209 if (img[j][i] > max)
210 max = img[j][i];
214 pos = *rgbbuf;
215 for (j = j_min; j < j_max; j++) {
216 for (i = i_min; i < i_max; i++) {
217 img[j][i] -= min;
218 img[j][i] = (255.0 / (max - min)) * img[j][i];
219 *pos++ = (unsigned char) img[j][i];
220 *pos++ = (unsigned char) img[j][i];
221 *pos++ = (unsigned char) img[j][i];
223 *pos = *pos++;
224 *pos = *pos++;
225 *pos = *pos++;
229 } else {
230 for (j = j_min; j < j_max; j++) {
231 for (i = i_min; i < i_max; i++) {
232 if (img[j][i] < min)
233 min = img[j][i];
237 /* if ( min < display_act->img.img_mean) */
238 /* display_act->img.img_mean = min; */
241 pos = *rgbbuf;
242 for (j = j_min; j < j_max; j++) {
243 for (i = i_min; i < i_max; i++) {
244 /* *pos++ = (unsigned char) img[j][i] - (unsigned char) min */
245 /* + (unsigned char) display_act->img.img_mean; */
246 /* *pos++ = (unsigned char) img[j][i] - (unsigned char) min */
247 /* + (unsigned char) display_act->img.img_mean; */
248 /* *pos++ = (unsigned char) img[j][i] - (unsigned char) min */
249 /* + (unsigned char) display_act->img.img_mean; */
251 * BUGFIX: display image intars with: 8 < depth < 16
252 * 6 March 2004
254 *pos++ = (guchar) ((img[j][i] - /* (guchar) */ min +
255 /* (guchar) */ display_act->img->img_mean)
256 / fact);
257 *pos++ = (guchar) ((img[j][i] - /* (guchar) */ min +
258 /* (guchar) */ display_act->img->img_mean)
259 / fact);
260 *pos++ = (guchar) ((img[j][i] - /* (guchar) */ min +
261 /* (guchar) */ display_act->img->img_mean)
262 / fact);
268 gdk_pixbuf_unref (pixbuf);
269 *int_size_old = int_size;
270 /* g_free(rgbbuf); */
271 /* rgbbuf = NULL; */
276 static void
277 alloc_bufmem_per_intarea (int index_y,
278 int index_x,
279 PivData *pida,
280 GpivImagePar image_par,
281 int int_size_0
283 /* ----------------------------------------------------------------------------
284 * Memory allocation of covariance in a packed interrogation area array
291 static void
292 free_bufmem_per_intarea (int index_y,
293 int index_x,
294 PivData *pida,
295 GpivImagePar image_par,
296 int int_size_0
298 /*-----------------------------------------------------------------------------
305 static void
306 adjust_radio_button_intsize_f (GpivPivPar *piv_par,
307 PivEval *eval
309 /* ----------------------------------------------------------------------------
310 * Adjust radio button interrogation size 1 in PIV interrogation tab
313 if (piv_par->int_size_f == 16) {
314 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
315 (eval->radiobutton_intsize_f_2), TRUE);
316 } else if (piv_par->int_size_f == 32) {
317 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
318 (eval->radiobutton_intsize_f_3), TRUE);
319 } else if (piv_par->int_size_f == 64) {
320 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
321 (eval->radiobutton_intsize_f_4), TRUE);
322 } else if (piv_par->int_size_f == 128) {
323 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
324 (eval->radiobutton_intsize_f_5), TRUE);
330 static void
331 adjust_radio_button_intsize_i (GpivPivPar *piv_par,
332 PivEval *eval
334 /* ----------------------------------------------------------------------------
335 * Adjust radio button interrogation size 1 in PIV interrogation tab
338 if (piv_par->int_size_i == 16) {
339 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
340 (eval->radiobutton_intsize_i_2), TRUE);
341 } else if (piv_par->int_size_i == 32) {
342 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
343 (eval->radiobutton_intsize_i_3), TRUE);
344 } else if (piv_par->int_size_i == 64) {
345 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
346 (eval->radiobutton_intsize_i_4), TRUE);
347 } else if (piv_par->int_size_i == 128) {
348 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
349 (eval->radiobutton_intsize_i_5), TRUE);
356 static void
357 adjust_radio_button_intshift (GpivPivPar *piv_par,
358 PivEval *eval)
359 /* ----------------------------------------------------------------------------
360 * Adjust radio button interrogation area shift in PIV interrogation tab
363 if (piv_par->int_shift == 8) {
364 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
365 (eval->radiobutton_intshift_1), TRUE);
366 } else if (piv_par->int_shift == 16) {
367 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
368 (eval->radiobutton_intshift_2), TRUE);
369 } else if (piv_par->int_shift == 32) {
370 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
371 (eval->radiobutton_intshift_3), TRUE);
372 } else if (piv_par->int_shift == 64) {
373 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
374 (eval->radiobutton_intshift_4), TRUE);
375 } else if (piv_par->int_shift == 128) {
376 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
377 (eval->radiobutton_intshift_5), TRUE);
384 * Display functions in PIV tabulator canvas
388 void
389 display_piv_vector (guint i,
390 guint j,
391 GpivPivData *piv_data,
392 PivEval *eval
394 /* ----------------------------------------------------------------------------
395 * Displays values in PIV tabulator of the GUI
398 /* float **dx = piv_data->dx, **dy = piv_data->dy; */
399 /* int **peak_no = piv_data->peak_no; */
400 GnomeCanvasPoints *points;
401 float dl = sqrt (piv_data->dx[i][j] * piv_data->dx[i][j] +
402 piv_data->dy[i][j] * piv_data->dy[i][j]);
403 gchar *color;
404 points = gnome_canvas_points_new (2);
406 eval->monitor->pi_da->dx[0][0] = piv_data->dx[i][j];
407 eval->monitor->pi_da->dy[0][0] = piv_data->dy[i][j];
408 eval->monitor->pi_da->peak_no[0][0] = piv_data->peak_no[i][j];
410 if (eval->monitor->pi_da->peak_no[0][0] == -1) {
411 color="red";
412 } else if (eval->monitor->pi_da->peak_no[0][0] == 0) {
413 color="lightblue";
414 } else if (eval->monitor->pi_da->peak_no[0][0] == 1) {
415 color="green";
416 } else if (eval->monitor->pi_da->peak_no[0][0] == 2) {
417 color="yellow";
418 } else {
419 /* if (eval->monitor->pi_da->peak_no[i][j] == 3) */
420 color="gray";
423 points->coords[0] = GPIV_MAX_INTERR_SIZE / 2;
424 points->coords[1] = GPIV_MAX_INTERR_SIZE / 2;
425 points->coords[2] = GPIV_MAX_INTERR_SIZE / 2 + eval->monitor->pi_da->dx[0][0]
426 * gpiv_var->piv_disproc_vlength;
427 points->coords[3] = GPIV_MAX_INTERR_SIZE / 2 + eval->monitor->pi_da->dy[0][0]
428 * gpiv_var->piv_disproc_vlength;
431 if (eval->monitor->gci_vec != NULL) {
432 gnome_canvas_item_set (eval->monitor->gci_vec,
433 "points", points,
434 "fill_color", color,
435 "width_units", (double) THICKNESS,
436 "first_arrowhead", FALSE,
437 "last_arrowhead", TRUE,
438 "arrow_shape_a", (double) ARROW_LENGTH *
439 ARROW_FACT *dl * gpiv_par->display__vector_scale +
440 ARROW_ADD,
441 "arrow_shape_b", (double) ARROW_EDGE *
442 ARROW_FACT * dl * gpiv_par->display__vector_scale +
443 ARROW_ADD,
444 "arrow_shape_c", (double) ARROW_WIDTH *
445 ARROW_FACT * dl * gpiv_par->display__vector_scale +
446 ARROW_ADD,
447 NULL);
448 } else {
449 eval->monitor->gci_vec =
450 gnome_canvas_item_new (gnome_canvas_root
451 (GNOME_CANVAS(eval->canvas_monitor_vec)),
452 gnome_canvas_line_get_type(),
453 "points", points,
454 "fill_color", color,
455 "width_units",(double) THICKNESS,
456 "first_arrowhead", TRUE,
457 "arrow_shape_a", (double) ARROW_LENGTH *
458 ARROW_FACT *dl * gpiv_par->display__vector_scale +
459 ARROW_ADD,
460 "arrow_shape_b", (double) ARROW_EDGE *
461 ARROW_FACT * dl * gpiv_par->display__vector_scale +
462 ARROW_ADD,
463 "arrow_shape_c", (double) ARROW_WIDTH *
464 ARROW_FACT * dl * gpiv_par->display__vector_scale +
465 ARROW_ADD,
467 /* "arrow_shape_a", (double) THICKNESS, */
468 NULL);
472 gnome_canvas_points_free (points);
477 void
478 display_img_intreg1 (float **intreg1,
479 guint int_size,
480 PivEval *eval
482 /* ----------------------------------------------------------------------------
483 * Displays image of intreg1 for drawing area
484 * row stride; each row is a 4-byte buffer array
487 display_img (intreg1,
488 int_size,
489 &eval->monitor->int_size_old,
491 int_size,
493 int_size,
494 eval->monitor->rgb_int_width,
495 &eval->monitor->rgbbuf_int1,
496 eval->canvas_monitor_int1,
497 &eval->monitor->gci_int1,
498 eval->monitor->affine,
499 FALSE);
504 void display_img_intreg2 (float **intreg2,
505 guint int_size,
506 PivEval *eval
508 /* ----------------------------------------------------------------------------
509 * Displays image of intreg2 for drawing area
512 display_img (intreg2,
513 int_size,
514 &eval->monitor->int_size_old,
516 int_size,
518 int_size,
519 eval->monitor->rgb_int_width,
520 &eval->monitor->rgbbuf_int2,
521 eval->canvas_monitor_int2,
522 &eval->monitor->gci_int2,
523 eval->monitor->affine,
524 FALSE);
530 void display_img_cov (GpivCov *cov,
531 guint int_size,
532 PivEval *eval
534 /* ----------------------------------------------------------------------------
535 * Displays image of intreg1 for drawing area
538 display_img (cov->z,
539 int_size,
540 &eval->monitor->cov_size_old,
541 cov->z_cl,
542 cov->z_ch,
543 cov->z_rl,
544 cov->z_rh,
545 eval->monitor->rgb_cov_width,
546 &eval->monitor->rgbbuf_cov,
547 eval->canvas_monitor_cov,
548 &eval->monitor->gci_cov,
549 eval->monitor->affine,
550 TRUE);
556 * Piv evaluation window/tabulator callbacks
560 void
561 on_radiobutton_piv_mouse (GtkWidget *widget,
562 gpointer data
564 /*-----------------------------------------------------------------------------
567 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
568 m_select = atoi(gtk_object_get_data(GTK_OBJECT(widget),
569 "mouse_select"));
571 /* g_message ("on_radiobutton_piv_mouse:: 0 m_select = %d", m_select); */
572 if (m_select == NO_MS) {
573 gl_piv_par->int_geo = GPIV_AOI;
575 } else if (m_select == AOI_MS) {
576 gl_piv_par->int_geo = GPIV_AOI;
577 } else if (m_select == SINGLE_POINT_MS) {
578 gl_piv_par->int_geo = GPIV_POINT;
579 } else if (m_select == V_LINE_MS) {
580 /* gl_piv_par->int_geo = GPIV_LINE_C; */
581 gl_piv_par->int_geo = GPIV_AOI;
582 } else if (m_select == H_LINE_MS) {
583 /* gl_piv_par->int_geo = GPIV_LINE_R; */
584 gl_piv_par->int_geo = GPIV_AOI;
585 } else if (m_select == SINGLE_AREA_MS ||
586 m_select == DRAG_MS) {
587 gl_piv_par->int_geo = GPIV_POINT;
591 * (Re)setting interrogation scheme if necessary
593 if ((m_select == SINGLE_AREA_MS
594 || m_select == DRAG_MS
595 || m_select == SINGLE_POINT_MS
596 || m_select == V_LINE_MS
597 || m_select == H_LINE_MS)
598 && gl_piv_par->int_scheme == GPIV_IMG_DEFORM
600 char message[2 * GPIV_MAX_CHARS];
601 g_snprintf (message, 2 * GPIV_MAX_CHARS,
602 _("Image deformation is impossibe with this Mouse select.\n\
603 Setting Interrogation scheme to Central difference.\n\
604 This will be reset automatically after interrogating."));
605 warning_gpiv (message);
606 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
607 (gpiv->piveval->radiobutton_centraldiff),
608 TRUE);
609 int_scheme_autochanged = TRUE;
610 } else {
611 if (int_scheme_autochanged) {
612 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
613 (gpiv->piveval->radiobutton_imgdeform),
614 TRUE);
615 int_scheme_autochanged = FALSE;
622 void
623 on_radiobutton_piv_mouse1_enter (GtkWidget *widget,
624 gpointer data
626 /*-----------------------------------------------------------------------------
629 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
630 gchar *msg = _("No mouse activity within displayer");
631 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
636 void
637 on_radiobutton_piv_mouse2_enter (GtkWidget *widget,
638 gpointer data
640 /*-----------------------------------------------------------------------------
643 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
644 gchar *msg = _("Selects an area within the image to be analyzed");
645 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
650 void
651 on_radiobutton_piv_mouse3_enter (GtkWidget *widget,
652 gpointer data
654 /*-----------------------------------------------------------------------------
657 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
658 gchar *msg = _("Piv evaluation at a single interrogation area. "
659 "Conserves other existing data");
660 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
665 void
666 on_radiobutton_piv_mouse4_enter (GtkWidget *widget,
667 gpointer data
669 /*-----------------------------------------------------------------------------
672 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
673 gchar *msg = _("Piv evaluation at a single point in the image. "
674 "Rejects all existing data!!");
675 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
680 void
681 on_radiobutton_piv_mouse5_enter (GtkWidget *widget,
682 gpointer data
684 /*-----------------------------------------------------------------------------
687 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
688 gchar *msg = _("Displaces a single interrogation area and analyzes");
689 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
694 void
695 on_radiobutton_piv_mouse6_enter (GtkWidget *widget,
696 gpointer data
698 /*-----------------------------------------------------------------------------
701 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
702 gchar *msg = _("Evaluation at a vertical line. ");
703 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
708 void
709 on_radiobutton_piv_mouse7_enter (GtkWidget *widget,
710 gpointer data
712 /*-----------------------------------------------------------------------------
715 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
716 gchar *msg = _("Evaluation at a horizontal line. ");
717 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
722 void
723 on_spinbutton_piv_int (GtkSpinButton *widget,
724 GtkWidget *entry
726 /*-----------------------------------------------------------------------------
729 char *err_msg = NULL;
730 PivEval *eval = gtk_object_get_data(GTK_OBJECT (widget), "eval");
731 guint nx = 0, ny = 0;
732 guint nx_img = 0, ny_img = 0;
733 gboolean renew = TRUE, lo_display_intregs = FALSE;
735 enum VariableType {
736 COL_START = 0,
737 COL_END = 1,
738 PRESHIFT_COL = 2,
739 ROWSTART = 3,
740 ROWEND = 4,
741 PRESHIFT_ROW = 5,
742 INT_SIZE_F = 6,
743 INT_SIZE_I = 7,
744 INT_SHIFT = 8
745 } var_type;
748 /* eval = gtk_object_get_data(GTK_OBJECT(widget), "eval"); */
750 * Locale vars
752 /* Display display_act; */
753 /* display_act = gtk_object_get_data(widget, display_act); */
756 * Select which variable has to be modified
758 setby_spinbutton = 1;
759 var_type = atoi(gtk_object_get_data (GTK_OBJECT (widget), "var_type"));
761 if (var_type == COL_START) {
762 gl_piv_par->col_start = gtk_spin_button_get_value_as_int (widget);
764 } else if (var_type == COL_END) {
765 gl_piv_par->col_end = gtk_spin_button_get_value_as_int (widget);
767 } else if (var_type == PRESHIFT_COL) {
768 gl_piv_par->pre_shift_col = gtk_spin_button_get_value_as_int (widget);
770 } else if (var_type == ROWSTART) {
771 gl_piv_par->row_start = gtk_spin_button_get_value_as_int (widget);
773 } else if (var_type == ROWEND) {
774 gl_piv_par->row_end = gtk_spin_button_get_value_as_int (widget);
776 } else if (var_type == PRESHIFT_ROW) {
777 gl_piv_par->pre_shift_row = gtk_spin_button_get_value_as_int (widget);
779 } else if (var_type == INT_SIZE_F) {
780 gl_piv_par->int_size_f = gtk_spin_button_get_value_as_int (widget);
783 * Adapt spinbutton of int_size_i
785 GTK_ADJUSTMENT(eval->spinbutton_adj_intsize_i)->lower =
786 (gfloat) gl_piv_par->int_size_f;
787 GTK_ADJUSTMENT(eval->spinbutton_adj_intsize_i)->upper =
788 (gfloat) 128.0;
789 gtk_adjustment_changed (GTK_ADJUSTMENT(eval->spinbutton_adj_intsize_i));
790 gtk_adjustment_set_value (GTK_ADJUSTMENT(eval->spinbutton_adj_intsize_i),
791 (gfloat) gl_piv_par->int_size_f);
794 * Adjust radio buttons for final interrogation size
796 adjust_radio_button_intsize_f (gl_piv_par, eval);
798 } else if (var_type == INT_SIZE_I) {
799 char message[GPIV_MAX_CHARS];
801 gl_piv_par->int_size_i = gtk_spin_button_get_value_as_int (widget);
802 if ((gl_piv_par->int_scheme == GPIV_NO_CORR
803 || gl_piv_par->int_scheme == GPIV_LK_WEIGHT)
804 && gl_piv_par->int_size_i > gl_piv_par->int_size_f) {
805 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
806 (eval->radiobutton_imgdeform),
807 TRUE);
808 g_snprintf (message, GPIV_MAX_CHARS,
809 _("Int Size 2 > Int Size 1 \nSetting Interrogation scheme to Image deformation"));
810 warning_gpiv(message);
812 /* } else { */
813 /* gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON */
814 /* (eval->radiobutton_zerooff), */
815 /* FALSE); */
819 * Adjust radio buttons for initial interrogation size
821 adjust_radio_button_intsize_i (gl_piv_par, eval);
823 } else if (var_type == INT_SHIFT) {
824 gl_piv_par->int_shift = gtk_spin_button_get_value_as_int (widget);
827 * Adjust radio buttons for interrogation area shift
829 adjust_radio_button_intshift (gl_piv_par, eval);
833 * Update eventually interrogation region contours.
835 if (display_act != NULL) {
836 if ((err_msg =
837 gpiv_piv_testadjust_parameters (display_act->img->image->header,
838 gl_piv_par))
839 != NULL) {
840 warning_gpiv ("%s", err_msg);
841 return;
844 display_act->intreg->par->row_start = gl_piv_par->row_start;
845 display_act->intreg->par->row_end = gl_piv_par->row_end;
846 display_act->intreg->par->col_start = gl_piv_par->col_start;
847 display_act->intreg->par->col_end = gl_piv_par->col_end;
848 display_act->intreg->par->int_shift = gl_piv_par->int_shift;
849 display_act->intreg->par->int_size_f = gl_piv_par->int_size_f;
850 display_act->intreg->par->int_size_i = gl_piv_par->int_size_i;
851 display_act->intreg->par->pre_shift_row = gl_piv_par->pre_shift_row;
852 display_act->intreg->par->pre_shift_col = gl_piv_par->pre_shift_col;
854 display_act->intreg->par->row_start__set = TRUE;
855 display_act->intreg->par->row_end__set = TRUE;
856 display_act->intreg->par->col_start__set = TRUE;
857 display_act->intreg->par->col_end__set = TRUE;
858 display_act->intreg->par->int_size_f__set = TRUE;
859 display_act->intreg->par->int_size_i__set = TRUE;
860 display_act->intreg->par->int_shift__set = TRUE;
861 display_act->intreg->par->pre_shift_row__set = TRUE;
862 display_act->intreg->par->pre_shift_col__set = TRUE;
864 if (display_act->intreg->exist_int) {
865 nx = display_act->intreg->data->nx;
866 ny = display_act->intreg->data->ny;
868 if ((err_msg =
869 gpiv_piv_count_pivdata_fromimage (display_act->img->image->header,
870 display_act->intreg->par,
871 &nx_img,
872 &ny_img))
873 != NULL) {
874 warning_gpiv ("on_spinbutton_piv_int: %s", err_msg);
875 g_warning ("on_spinbutton_piv_int: %s", err_msg);
876 return;
879 * For some operations the intregs have to be renewed unconditionally,
880 * for others only in case if the number of intregs has been changed
882 if (var_type == COL_START || var_type == COL_END
883 || var_type == ROWSTART || var_type == ROWEND) {
884 if (nx == nx_img
885 && ny == ny_img) {
886 renew = FALSE;
887 } else {
888 renew = TRUE;
892 if (renew) {
893 lo_display_intregs = display_act->display_intregs;
894 destroy_all_intregs (display_act);
895 create_all_intregs (display_act);
896 display_act->display_intregs = lo_display_intregs;
897 if (display_act->display_intregs) show_all_intregs(display_act);
903 setby_spinbutton = 0;
908 void
909 on_radiobutton_piv_int (GtkWidget *widget,
910 gpointer data
912 /*-----------------------------------------------------------------------------
915 gint int_size_f_tmp;
916 gboolean lo_display_intregs = FALSE;
917 gint nx_tmp = 0, ny_tmp = 0;
918 /* gint setby_spinbutton = atoi(gtk_object_get_data(GTK_OBJECT(widget), */
919 /* "setby_spinbutton")); */
920 PivEval *eval = gtk_object_get_data(GTK_OBJECT (widget), "eval");
921 Display *disp = display_act;
922 int nx, ny;
924 enum VariableType {
925 SIZE_F = 0,
926 SIZE_I = 1,
927 SHIFT = 2
928 } var_type;
931 if (disp != NULL
932 && disp->intreg->exist_int) {
933 nx = disp->intreg->data->nx;
934 ny = disp->intreg->data->ny;
935 } else {
936 nx = 0;
937 ny = 0;
940 if (GTK_TOGGLE_BUTTON(widget)->active) {
941 var_type = atoi(gtk_object_get_data (GTK_OBJECT(widget),
942 "var_type"));
945 * Select which variable has to be modified
947 if (var_type == SIZE_F) {
948 int_size_f_tmp = gl_piv_par->int_size_f;
949 gl_piv_par->int_size_f = atoi (gtk_object_get_data
950 (GTK_OBJECT(widget),
951 "intsize_f"));
953 * switch off temporarly display_intregs
955 if (disp != NULL) {
956 lo_display_intregs = disp->display_intregs;
957 disp->display_intregs = FALSE;
959 nx_tmp = nx;
960 ny_tmp = ny;
961 adjust_radiobutton_piv_int (eval, gl_piv_par->int_size_f);
964 * return display_intregs to original value
966 if (disp != NULL) {
967 disp->display_intregs = lo_display_intregs;
969 nx = nx_tmp;
970 ny = ny_tmp;
972 * BUGFIX: REMOVE Reset weight and zero_off
974 if (gl_piv_par->int_size_i > int_size_f_tmp) {
975 /* gtk_widget_set_sensitive(eval->radiobutton_zerooff, TRUE); */
976 /* gtk_widget_set_sensitive(checkbutton_piv_weightkernel, TRUE); */
979 if (int_scheme_tmp != GPIV_ZERO_OFF_FORWARD
980 && int_scheme_tmp != GPIV_ZERO_OFF_CENTRAL) {
981 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
982 (eval->radiobutton_zerooff),
983 FALSE);
984 gtk_widget_set_sensitive(eval->radiobutton_zerooff, TRUE);
985 gtk_widget_set_sensitive(eval->radiobutton_weightkernel,
986 TRUE);
987 if (int_scheme_tmp == GPIV_LK_WEIGHT) {
988 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
989 (eval->radiobutton_weightkernel),
990 FALSE);
991 gtk_widget_set_sensitive(eval->radiobutton_zerooff,
992 TRUE);
993 gtk_widget_set_sensitive(eval->radiobutton_weightkernel, TRUE);
994 } else {
995 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
996 (eval->radiobutton_weightkernel),
997 TRUE);
998 gtk_widget_set_sensitive(eval->radiobutton_zerooff,
999 FALSE);
1000 gtk_widget_set_sensitive(eval->radiobutton_weightkernel,
1001 TRUE);
1003 } else {
1004 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1005 (eval->radiobutton_zerooff),
1006 TRUE);
1007 gtk_widget_set_sensitive(eval->radiobutton_zerooff, TRUE);
1008 gtk_widget_set_sensitive(eval->radiobutton_weightkernel,
1009 FALSE);
1015 * Also calls on_spinbutton_piv_int, which, on its turn, may call this function
1016 * again resulting into an infinite loop
1018 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1019 (eval->spinbutton_intsize_f),
1020 gl_piv_par->int_size_f);
1023 } else if (var_type == SIZE_I) {
1024 gl_piv_par->int_size_i =
1025 atoi (gtk_object_get_data (GTK_OBJECT(widget), "intsize_i"));
1028 * Adjust spinner
1030 gtk_adjustment_set_value (GTK_ADJUSTMENT
1031 (eval->spinbutton_adj_intsize_i),
1032 (gfloat) gl_piv_par->int_size_i);
1034 * Save origanal settings of weight and zero_off for later resetting
1036 if (gl_piv_par->int_size_i > gl_piv_par->int_size_f) {
1037 int_scheme_tmp = gl_piv_par->int_scheme;
1039 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1040 (eval->radiobutton_weightkernel), FALSE);
1041 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1042 (eval->radiobutton_zerooff), TRUE);
1043 gtk_widget_set_sensitive(eval->radiobutton_zerooff, FALSE);
1047 * Reset weight and zero_off
1049 } else {
1050 /* if (zero_off_tmp == 0) {
1051 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1052 (eval->radiobutton_zerooff), FALSE);
1053 if (weight_tmp == 0) {
1054 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1055 (eval->radiobutton_weightkernel), FALSE);
1056 } else {
1057 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1058 (eval->radiobutton_weightkernel), TRUE);
1060 } else {
1061 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1062 (eval->radiobutton_zerooff), TRUE);
1064 gtk_widget_set_sensitive(eval->radiobutton_zerooff, TRUE);
1069 } else if (var_type == SHIFT) {
1070 gl_piv_par->int_shift =
1071 atoi (gtk_object_get_data (GTK_OBJECT(widget),
1072 "intshift"));
1074 * Adjust spinner
1076 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1077 (eval->spinbutton_intshift),
1078 gl_piv_par->int_shift);
1081 if (disp != NULL
1082 && disp->intreg->exist_int
1084 lo_display_intregs = disp->display_intregs;
1085 destroy_all_intregs (disp);
1086 create_all_intregs (disp);
1087 disp->display_intregs = lo_display_intregs;
1088 if (disp->display_intregs) show_all_intregs(disp);
1098 void
1099 on_radiobutton_fit_enter (GtkWidget *widget,
1100 gpointer data
1102 /*-----------------------------------------------------------------------------
1105 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1106 gchar *msg = _("Interpolation scheme for sub-pixel estimation");
1107 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1113 void
1114 on_radiobutton_peak_enter (GtkWidget *widget,
1115 gpointer data
1117 /*-----------------------------------------------------------------------------
1120 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1121 gchar *msg = _("Chooses n-th highest top number of correlation as estimator");
1122 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1128 void
1129 on_radiobutton_interrogatescheme_enter (GtkWidget *widget,
1130 gpointer data
1132 /*-----------------------------------------------------------------------------
1135 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
1136 gchar *msg = _("Bias correction scheme");
1137 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1143 void
1144 on_radiobutton_interrogatescheme_imgdeform_enter (GtkWidget *widget,
1145 gpointer data
1147 /*-----------------------------------------------------------------------------
1150 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT(widget), "gpiv");
1151 gchar *msg = _("Deforms image from PIV estimators");
1152 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1158 void
1159 on_toggle_piv (GtkWidget *widget,
1160 gpointer data
1162 /*-----------------------------------------------------------------------------
1165 PivEval *eval = gtk_object_get_data(GTK_OBJECT (widget), "eval");
1166 enum VariableType {
1167 IFIT,
1168 PEAK_NR,
1169 SCHEME,
1170 CORRELATION
1171 } var_type;
1174 * Select which variable has to be modified
1176 var_type = atoi (gtk_object_get_data (GTK_OBJECT(widget), "var_type"));
1178 if (var_type == IFIT) {
1179 gl_piv_par->ifit = atoi (gtk_object_get_data (GTK_OBJECT(widget),
1180 "ifit"));
1182 } else if (var_type == PEAK_NR) {
1183 gl_piv_par->peak = atoi (gtk_object_get_data (GTK_OBJECT(widget),
1184 "peak"));
1187 } else if (var_type == SCHEME) {
1188 gl_piv_par->int_scheme = atoi(gtk_object_get_data(GTK_OBJECT(widget),
1189 "scheme"));
1191 } else if (var_type == CORRELATION) {
1192 gl_image_par->x_corr = atoi (gtk_object_get_data (GTK_OBJECT(widget),
1193 "x_corr"));
1200 void
1201 on_checkbutton_weight_ia_enter (GtkWidget *widget,
1202 gpointer data
1204 /*-----------------------------------------------------------------------------
1207 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1208 gchar *msg =
1209 _("Gauss weighting on the Interrogation Area");
1210 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1215 void
1216 on_checkbutton_weight_ia (GtkWidget *widget,
1217 gpointer data)
1218 /*-----------------------------------------------------------------------------
1221 PivEval *eval = gtk_object_get_data (GTK_OBJECT(widget), "eval");
1224 if (GTK_TOGGLE_BUTTON(widget)->active) {
1225 gl_piv_par->gauss_weight_ia = TRUE;
1226 } else {
1227 gl_piv_par->gauss_weight_ia = FALSE;
1232 void
1233 on_checkbutton_spof_enter (GtkWidget *widget,
1234 gpointer data
1236 /*-----------------------------------------------------------------------------
1239 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1240 gchar *msg =
1241 _("Symmetric Phase Only Filtering on the FT images");
1242 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1247 void
1248 on_checkbutton_spof (GtkWidget *widget,
1249 gpointer data)
1250 /*-----------------------------------------------------------------------------
1253 PivEval *eval = gtk_object_get_data (GTK_OBJECT(widget), "eval");
1256 if (GTK_TOGGLE_BUTTON(widget)->active) {
1257 gl_piv_par->spof_filter = TRUE;
1258 } else {
1259 gl_piv_par->spof_filter = FALSE;
1264 void
1265 adjust_radiobutton_piv_int (PivEval *eval,
1266 guint int_size_f
1268 /* ----------------------------------------------------------------------------
1269 * adjusting and disabling int_size_i and its toggle buttons
1272 /* if (int_size_f == 8) { */
1273 /* gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON */
1274 /* (eval->radiobutton_intsize_i_1), TRUE); */
1275 /* } else */
1277 if (int_size_f == 16) {
1278 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1279 (eval->radiobutton_intsize_i_2), TRUE);
1281 } else if (int_size_f == 32) {
1282 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1283 (eval->radiobutton_intsize_i_3), TRUE);
1285 } else if (int_size_f == 64) {
1286 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1287 (eval->radiobutton_intsize_i_4), TRUE);
1289 } else if (int_size_f >= 128) {
1290 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1291 (eval->radiobutton_intsize_i_5), TRUE);
1295 if (int_size_f <= 64) {
1296 gtk_widget_set_sensitive (GTK_WIDGET(eval->radiobutton_intsize_i_4),
1297 TRUE);
1298 if (int_size_f <= 32) {
1299 gtk_widget_set_sensitive (GTK_WIDGET
1300 (eval->radiobutton_intsize_i_3),
1301 TRUE);
1302 if (int_size_f <= 16) {
1303 gtk_widget_set_sensitive (GTK_WIDGET
1304 (eval->radiobutton_intsize_i_2),
1305 TRUE);
1306 /* if (int_size_f <= 8) { */
1307 /* gtk_widget_set_sensitive(GTK_WIDGET */
1308 /* (eval->radiobutton_intsize_i_1), */
1309 /* TRUE); */
1310 /* } */
1317 if (int_size_f >= 16) {
1318 /* gtk_widget_set_sensitive(GTK_WIDGET(eval->radiobutton_intsize_i_1), */
1319 /* FALSE); */
1320 if (int_size_f >= 32) {
1321 gtk_widget_set_sensitive (GTK_WIDGET
1322 (eval->radiobutton_intsize_i_2),
1323 FALSE);
1324 if (int_size_f >= 64) {
1325 gtk_widget_set_sensitive (GTK_WIDGET
1326 (eval->radiobutton_intsize_i_3),
1327 FALSE);
1328 if (int_size_f >= 128) {
1329 gtk_widget_set_sensitive (GTK_WIDGET
1330 (eval->radiobutton_intsize_i_4),
1331 FALSE);
1341 void
1342 on_checkbutton_piv_monitor_enter (GtkWidget *widget,
1343 gpointer data
1345 /*-----------------------------------------------------------------------------
1348 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT (widget), "gpiv");
1349 gchar *msg =
1350 _("Displays subimages, correlation function and PIV vector");
1351 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1356 void
1357 on_checkbutton_piv_monitor (GtkWidget *widget,
1358 gpointer data)
1359 /*-----------------------------------------------------------------------------
1362 PivEval *eval = gtk_object_get_data (GTK_OBJECT(widget), "eval");
1365 if (GTK_TOGGLE_BUTTON(widget)->active) {
1366 gpiv_var->piv_disproc = TRUE;
1368 eval->monitor->gci_vec_background =
1369 gnome_canvas_item_new (gnome_canvas_root
1370 (GNOME_CANVAS(eval->canvas_monitor_vec)),
1371 gnome_canvas_rect_get_type(),
1372 "x1", (double) 0,
1373 "y1", (double) 0,
1374 "x2", (double) GPIV_MAX_INTERR_SIZE,
1375 "y2", (double) GPIV_MAX_INTERR_SIZE,
1376 "fill_color", "darkblue",
1377 "width_units", 1.0,
1378 NULL);
1381 eval->monitor->gci_int1_background =
1382 gnome_canvas_item_new (gnome_canvas_root
1383 (GNOME_CANVAS(eval->canvas_monitor_int1)),
1384 gnome_canvas_rect_get_type(),
1385 "x1", (double) 0,
1386 "y1", (double) 0,
1387 "x2", (double) GPIV_MAX_INTERR_SIZE,
1388 "y2", (double) GPIV_MAX_INTERR_SIZE,
1389 "fill_color", "darkgreen",
1390 "width_units", 1.0,
1391 NULL);
1394 eval->monitor->gci_int2_background =
1395 gnome_canvas_item_new (gnome_canvas_root
1396 (GNOME_CANVAS(eval->canvas_monitor_int2)),
1397 gnome_canvas_rect_get_type(),
1398 "x1", (double) 0,
1399 "y1", (double) 0,
1400 "x2", (double) GPIV_MAX_INTERR_SIZE,
1401 "y2", (double) GPIV_MAX_INTERR_SIZE,
1402 "fill_color", "darkgreen",
1403 "width_units", 1.0,
1404 NULL);
1407 eval->monitor->gci_background_cov =
1408 gnome_canvas_item_new (gnome_canvas_root
1409 (GNOME_CANVAS(eval->canvas_monitor_cov)),
1410 gnome_canvas_rect_get_type(),
1411 "x1", (double) 0,
1412 "y1", (double) 0,
1413 "x2", (double) GPIV_MAX_INTERR_SIZE,
1414 "y2", (double) GPIV_MAX_INTERR_SIZE,
1415 "fill_color", "darkred",
1416 "width_units", 1.0,
1417 NULL);
1418 } else {
1419 gpiv_var->piv_disproc = FALSE;
1421 * Destroy intreg1 image
1423 if (eval->monitor->gci_int1_background != NULL) {
1424 gtk_object_destroy (GTK_OBJECT(eval->monitor->
1425 gci_int1_background));
1426 eval->monitor->gci_int1_background = NULL;
1429 if (eval->monitor->rgbbuf_int1 != NULL) {
1430 g_free (eval->monitor->rgbbuf_int1);
1431 eval->monitor->rgbbuf_int1 = NULL;
1434 if (eval->monitor->gci_int1 != NULL) {
1435 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_int1));
1436 eval->monitor->gci_int1 = NULL;
1440 * Destroy intreg2 image
1442 if (eval->monitor->gci_int2_background != NULL) {
1443 gtk_object_destroy (GTK_OBJECT(eval->monitor->
1444 gci_int2_background));
1445 eval->monitor->gci_int2_background = NULL;
1448 if (eval->monitor->rgbbuf_int2 != NULL) {
1449 g_free (eval->monitor->rgbbuf_int2);
1450 eval->monitor->rgbbuf_int2 = NULL;
1453 if (eval->monitor->gci_int2 != NULL) {
1454 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_int2));
1455 eval->monitor->gci_int2 = NULL;
1459 * Destroy correlation image
1461 if (eval->monitor->gci_background_cov != NULL) {
1462 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_background_cov));
1463 eval->monitor->gci_background_cov = NULL;
1466 if (eval->monitor->rgbbuf_cov != NULL) {
1467 g_free (eval->monitor->rgbbuf_cov);
1468 eval->monitor->rgbbuf_cov = NULL;
1471 if (eval->monitor->gci_cov != NULL) {
1472 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_cov));
1473 eval->monitor->gci_cov = NULL;
1477 * Destroy vector
1479 if (eval->monitor->gci_vec_background != NULL) {
1480 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_vec_background));
1481 eval->monitor->gci_vec_background = NULL;
1485 if (eval->monitor->gci_vec != NULL) {
1486 gtk_object_destroy (GTK_OBJECT(eval->monitor->gci_vec));
1487 eval->monitor->gci_vec = NULL;
1495 void
1496 on_spinbutton_piv_monitor_zoom (GtkSpinButton *widget,
1497 gpointer data
1499 /*-----------------------------------------------------------------------------
1502 PivEval *eval = gtk_object_get_data (GTK_OBJECT(widget), "eval");
1503 /* gfloat piv_disproc_zoom */
1505 gpiv_var->piv_disproc_zoom = gtk_spin_button_get_value_as_float (widget);
1506 gnome_config_push_prefix("/gpiv/RuntimeVariables/");
1507 gnome_config_set_float ("zoom_factor", gpiv_var->piv_disproc_zoom);
1508 gnome_config_pop_prefix ();
1509 gnome_config_sync();
1511 eval->monitor->affine[0] = gpiv_var->piv_disproc_zoom;
1512 eval->monitor->affine[3] = gpiv_var->piv_disproc_zoom;
1513 eval->monitor->affine[4] =
1514 (GPIV_MAX_INTERR_SIZE - gpiv_var->piv_disproc_zoom
1515 * gl_piv_par->int_size_f) /2.0;
1516 eval->monitor->affine[5] =
1517 (GPIV_MAX_INTERR_SIZE - gpiv_var->piv_disproc_zoom
1518 * gl_piv_par->int_size_f) /2.0;
1520 if(eval->monitor->gci_int1 != NULL) {
1521 gnome_canvas_item_affine_absolute (eval->monitor->gci_int1,
1522 eval->monitor->affine);
1525 if(eval->monitor->gci_int2 != NULL) {
1526 gnome_canvas_item_affine_absolute (eval->monitor->gci_int2,
1527 eval->monitor->affine);
1531 if(eval->monitor->gci_cov != NULL) {
1532 gnome_canvas_item_affine_absolute (eval->monitor->gci_cov,
1533 eval->monitor->affine);
1541 void
1542 on_spinbutton_piv_monitor_vectorscale (GtkSpinButton *widget,
1543 gpointer data
1545 /*-----------------------------------------------------------------------------
1548 PivEval *eval = gtk_object_get_data (GTK_OBJECT (widget), "eval");
1549 /* gint piv_disproc_vlength */
1551 gpiv_var->piv_disproc_vlength = gtk_spin_button_get_value_as_int (widget);
1552 gnome_config_set_int ("vector_length", gpiv_var->piv_disproc_vlength);
1553 gnome_config_sync ();
1556 * Try to re-scale vector
1558 if(eval->monitor->gci_vec != NULL) {
1559 GnomeCanvasPoints *points = gnome_canvas_points_new (2);
1561 points->coords[0] = GPIV_MAX_INTERR_SIZE / 2;
1562 points->coords[1] = GPIV_MAX_INTERR_SIZE / 2;
1563 points->coords[2] = GPIV_MAX_INTERR_SIZE / 2 + eval->monitor->pi_da->dx[0][0] *
1564 gpiv_var->piv_disproc_vlength;
1565 points->coords[3] = GPIV_MAX_INTERR_SIZE / 2 + eval->monitor->pi_da->dy[0][0] *
1566 gpiv_var->piv_disproc_vlength;
1568 gnome_canvas_item_set (eval->monitor->gci_vec,
1569 "points", points,
1570 NULL);
1572 gnome_canvas_points_free (points);
1578 void
1579 on_button_piv_enter (GtkWidget *widget,
1580 gpointer data
1582 /*-----------------------------------------------------------------------------
1585 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
1586 gchar *msg = _("Analyses a PIV image (pair)");
1587 gnome_appbar_set_status (GNOME_APPBAR(gpiv->appbar), msg);
1592 void
1593 on_button_piv (GtkWidget *widget,
1594 gpointer data
1596 /* ----------------------------------------------------------------------------
1597 * The actual calculation of particle image displacements
1600 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
1601 gint row, ibuf;
1603 cancel_process = FALSE;
1605 if (nbufs > 0) {
1606 for (row = gpiv->first_selected_row; row <= gpiv->last_selected_row;
1607 row++) {
1608 display_act = gtk_clist_get_row_data (GTK_CLIST (gpiv->clist_buf),
1609 row);
1610 ibuf = display_act->id;
1611 if (display[ibuf] != NULL
1612 && display_act->mwin != NULL
1613 && GTK_WIDGET_VISIBLE (GTK_WIDGET (display_act->mwin))) {
1614 gdk_window_show (GTK_WIDGET (display_act->mwin)->window);
1615 gdk_window_raise (GTK_WIDGET (display_act->mwin)->window);
1618 exec_piv (gpiv);