1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 c-style: "K&R" -*- */
3 /*----------------------------------------------------------------------
5 gpiv - Graphic program for Particle Image Velocimetry, based on gtk/gnome
8 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
9 Gerber van der Graaf <gerber_graaf@users.sourceforge.net>
11 This file is part of gpiv.
13 Gpiv is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ----------------------------------------------------------------------*/
30 * (Callback) functions for console
32 * Revision 1.30 2008-05-07 08:34:20 gerber
33 * uses .h5 and .H5 extension for hdf files (previously: .gpi)
35 * Revision 1.29 2008-04-28 12:00:57 gerber
36 * hdf-formatted files are now with .hdf extension (previously: .gpi)
38 * Revision 1.28 2007-12-19 08:42:35 gerber
41 * Revision 1.27 2007-11-23 16:24:07 gerber
42 * release 0.5.0: Kafka
44 * Revision 1.26 2007-06-06 17:00:48 gerber
45 * Retreives images/data from URI using Gnome Virtual File System.
47 * Revision 1.25 2007-03-22 16:00:32 gerber
48 * Added image processing tabulator
50 * Revision 1.24 2007/02/05 15:17:09 gerber
51 * auto stretching, broadcast display settings to buffers from preferences
53 * Revision 1.23 2007-01-29 11:27:43 gerber
54 * added image formats png, gif, tif png, bmp, improved buffer display
56 * Revision 1.22 2006-09-18 07:27:03 gerber
57 * *** empty log message ***
59 * Revision 1.21 2006/01/31 14:28:11 gerber
62 * Revision 1.19 2005/02/26 09:43:30 gerber
63 * parameter flags (parameter_logic) defined as gboolean
65 * Revision 1.18 2005/02/26 09:17:13 gerber
66 * structured of interrogate function by using gpiv_piv_isiadapt
68 * Revision 1.17 2005/02/12 13:09:21 gerber
69 * Changing some structure and constant names for DAC
71 * Revision 1.16 2005/01/19 15:53:41 gerber
72 * Initiation of Data Acquisition (DAC); trigerring of lasers and camera
73 * by using RTAI and Realtime Linux, recording images from IEEE1394
74 * (Firewire) IIDC compliant camera's
76 * Revision 1.15 2004/10/15 19:24:05 gerber
77 * GPIV_ and Gpiv prefix to defines and structure names of libgpiv
79 * Revision 1.14 2004/06/14 21:19:23 gerber
80 * Image depth up to 16 bits.
81 * Improvement "single int" and "drag int" in Eval tab.
82 * Viewer's pop-up menu.
83 * Adaption for gpiv_matrix_* and gpiv_vector_*.
85 * See Changelog for further info.
87 * Revision 1.13 2003/09/04 13:31:54 gerber
88 * init of printing (unfinished)
90 * Revision 1.12 2003/09/01 11:17:14 gerber
91 * improved monitoring of interrogation process
93 * Revision 1.11 2003/08/22 15:24:52 gerber
94 * interactive spatial scaling
96 * Revision 1.10 2003/07/31 11:43:26 gerber
97 * display images in gnome canvas (HOERAreset)
99 * Revision 1.9 2003/07/25 15:40:23 gerber
100 * removed/disabled setting of correlation in Eval tab, Correlation type in Image info tab
102 * Revision 1.8 2003/07/13 14:38:18 gerber
103 * changed error handling of libgpiv
105 * Revision 1.7 2003/07/12 21:21:15 gerber
106 * changed error handling libgpiv
108 * Revision 1.5 2003/07/10 11:56:07 gerber
111 * Revision 1.4 2003/07/06 15:29:49 gerber
112 * repair message text closing buffer
114 * Revision 1.3 2003/07/05 13:14:57 gerber
115 * drag and drop of a _series_ of filenames from NAUTILUS
117 * Revision 1.2 2003/06/27 13:47:26 gerber
118 * display ruler, line/point evaluation
120 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
130 #include "gpiv_gui.h"
131 #include "console_interface.h"
132 #include "dialog_interface.h"
133 #include "console_menus.h"
139 #endif /* ENABLE_DAC */
142 #include "dac_trig.h"
143 #endif /* ENABLE_TRIG */
147 #endif /* ENABLE_CAM */
149 #include "piveval_interrogate.h"
150 #include "pivvalid.h"
152 #include "preferences.h"
161 file_saveas_accept (GpivConsole
*gpiv
,
165 typedef enum _Format Format
;
174 exec_save (Display
* disp
);
180 exec_save (Display
* disp
)
181 /*-----------------------------------------------------------------------------
182 * Store all data in display_act->file_uri_name.h5 in hdf5 format
185 char *err_msg
= NULL
;
186 char *fname_out_nosuf
, *fname_par
;
188 gchar
*uri_string_out
, *uri_string_tmp
;
189 GnomeVFSURI
*uri_out
= NULL
, *uri_tmp
= NULL
;
193 * Create a valid uri_out to build the local or tmp fname_out_nosuf.
194 * Type of suffix doesn't actually matter as the correct suffix will
195 * be extended later to fname_out
197 if (gpiv_par
->verbose
) g_message ("exec_save:: file_uri_name = %s", display_act
->file_uri_name
);
199 gnome_vfs_make_uri_from_input (g_strdup_printf
200 ("%s%s" ,display_act
->file_uri_name
,
202 uri_out
= gnome_vfs_uri_new (uri_string_out
);
203 g_free (uri_string_out
);
205 if (gnome_vfs_uri_is_local (uri_out
)) {
206 fname_out_nosuf
= g_strdup_printf ("%s" , display_act
->file_uri_name
);
207 if (gpiv_par
->verbose
) g_message ("exec_save:: LOCAL fname_out_nosuf = %s", fname_out_nosuf
);
209 const gchar
*tmp_dir
= g_get_tmp_dir ();
210 const gchar
*user_name
= g_get_user_name ();
211 fname_out_nosuf
= g_strdup_printf ("%s/%s/%s" , tmp_dir
,
213 strtok (gnome_vfs_uri_extract_short_name
215 if (gpiv_par
->verbose
) g_message ("exec_save:: URI fname_out_suf for to tmp: %s", fname_out_nosuf
);
220 if (gpiv_par
->verbose
) g_message ("exec_save:: STARTING THE REAL JOB");
222 write_hdf_img_data (fname_out_nosuf
, uri_out
);
226 * Store all data in ASCII format at different files
230 write_img (fname_out_nosuf
, uri_out
);
231 #endif /* SAVE_IMG */
232 write_ascii_parameters (fname_out_nosuf
, uri_out
, GPIV_EXT_PAR
);
233 write_ascii_data (fname_out_nosuf
, uri_out
);
236 g_free (fname_out_nosuf
);
242 * Main gpiv-gui callbacks
247 delete_console (GtkWidget
*widget
,
250 /*-----------------------------------------------------------------------------
253 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (widget
), "gpiv");
255 GtkDialog
*gpiv_exit
= NULL
;
258 exec_trigger_stop ();
259 #endif /* ENABLE_TRIG */
262 #endif /* ENABLE_CAM */
265 for (i
= 0; i
< nbufs
; i
++) {
266 /* if (display[i] != NULL) display_act = display[i]; */
267 display_act
= gtk_clist_get_row_data (GTK_CLIST (gpiv
->clist_buf
), i
);
268 if (!display_act
->img
->saved_img
269 || !display_act
->pida
->saved_piv
270 || !display_act
->pida
->saved_histo
271 || !display_act
->pida
->saved_vor
272 || !display_act
->pida
->saved_nstrain
273 || !display_act
->pida
->saved_sstrain
) {
274 gpiv_exit
= create_exit_dialog ();
275 gtk_widget_show_all (GTK_WIDGET (gpiv_exit
));
277 free_all_bufmems (display_act
);
291 on_clist_buf_rowselect (GtkWidget
*clist
,
294 GdkEventButton
*event
,
296 /*-----------------------------------------------------------------------------
300 GpivConsole
* gpiv
= gtk_object_get_data (GTK_OBJECT (clist
), "gpiv");
302 gint cnt
= 0, buf_dum
= 0;
303 gboolean saved_img_local
;
306 if (!exec_process
&& GTK_CLIST (clist
)->selection
) {
307 for (lis
= GTK_CLIST (clist
)->selection
; lis
; lis
= lis
->next
) {
308 row
= GPOINTER_TO_INT (lis
->data
);
309 /* g_message ("on_clist_buf_rowselect:: row = %d", row); */
310 gtk_clist_get_text (GTK_CLIST (clist
), row
, /* column */ 0, &text
);
311 display_act
= gtk_clist_get_row_data (GTK_CLIST (clist
/*= gpiv->clist_buf */),
313 saved_img_local
= display_act
->img
->saved_img
;
316 gpiv
->first_selected_row
= row
;
318 gpiv
->last_selected_row
= row
;
321 * BUGFIX: update variables of display before leaving the focus.
322 * BUGFIX: Already done when creating display
324 if (display_act
->intreg
->exist_int
) {
325 display_act
->intreg
->row_start_old
= 0;
326 display_act
->intreg
->col_start_old
= 0;
327 display_act
->intreg
->par
->row_start
= gl_piv_par
->row_start
;
328 display_act
->intreg
->par
->row_end
= gl_piv_par
->row_end
;
329 display_act
->intreg
->par
->col_start
= gl_piv_par
->col_start
;
330 display_act
->intreg
->par
->col_end
= gl_piv_par
->col_end
;
331 display_act
->intreg
->par
->int_size_f
= gl_piv_par
->int_size_f
;
332 display_act
->intreg
->par
->int_size_i
= gl_piv_par
->int_size_i
;
333 display_act
->intreg
->par
->int_shift
= gl_piv_par
->int_shift
;
334 display_act
->intreg
->par
->pre_shift_row
= gl_piv_par
->pre_shift_row
;
335 display_act
->intreg
->par
->pre_shift_col
= gl_piv_par
->pre_shift_col
;
339 /* if (GTK_WIDGET_REALIZED (display_act->pida.display)) */
341 /* display_act = gtk_clist_get_row_data (GTK_CLIST (gpiv->clist_buf), */
345 * Set variables of new active display equal to parameters
347 if (display_act
->intreg
->exist_int
348 && (display_act
->intreg
->par
->row_start
!= gl_piv_par
->row_start
349 || display_act
->intreg
->par
->row_end
!= gl_piv_par
->row_end
350 || display_act
->intreg
->par
->col_start
!= gl_piv_par
->col_start
351 || display_act
->intreg
->par
->col_end
!= gl_piv_par
->col_end
352 || display_act
->intreg
->par
->int_size_f
!= gl_piv_par
->int_size_f
353 || display_act
->intreg
->par
->int_size_i
!= gl_piv_par
->int_size_i
354 || display_act
->intreg
->par
->int_shift
!= gl_piv_par
->int_shift
355 || display_act
->intreg
->par
->pre_shift_row
!= gl_piv_par
->pre_shift_row
356 || display_act
->intreg
->par
->pre_shift_col
!= gl_piv_par
->pre_shift_col
)
358 destroy_all_intregs (display_act
);
359 create_all_intregs (display_act
);
362 if (display_act
->mwin
!= NULL
363 && GTK_WIDGET_VISIBLE (GTK_WIDGET (display_act
->mwin
))
365 /* gchar *author = "Guppie GRAAF"; */
366 gdk_window_show (GTK_WIDGET (display_act
->mwin
)->window
);
367 gdk_window_raise (GTK_WIDGET (display_act
->mwin
)->window
);
370 * update labels and entries in image header tab/window
372 update_imgh_entries (gpiv
, display_act
->img
->image
->header
);
373 display_act
->img
->saved_img
= saved_img_local
;
374 update_eval_entries (gpiv
, display_act
->img
->image
->header
);
382 gpiv
->last_selected_row
= gpiv
->first_selected_row
;
386 * exchange first and last
388 if (gpiv
->last_selected_row
< gpiv
->first_selected_row
) {
389 buf_dum
= gpiv
->last_selected_row
;
390 gpiv
->last_selected_row
= gpiv
->first_selected_row
;
391 gpiv
->first_selected_row
= buf_dum
;
395 /* g_message("on_clist_buf_rowselect:: nbufs = %d, first=%d last = %d", */
396 /* nbufs, gpiv->first_selected_row, gpiv->last_selected_row); */
403 on_clist_buf_drag_data_received (GtkWidget
*widget
,
404 GdkDragContext
*context
,
407 GtkSelectionData
*selection_data
,
410 /*-----------------------------------------------------------------------------
411 * load the data from selected uris with drag and drop
414 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (widget
), "gpiv");
419 if (info
!= TARGET_URI_LIST
) {
420 g_message ("on_clist_buf_drag_data_received: info != TARGET_URI_LIST");
423 if (selection_data
== NULL
) {
424 g_message ("on_clist_buf_drag_data_received: selection_data == NULL");
427 if(selection_data
->length
< 0) {
428 g_message ("on_clist_buf_drag_data_received: selection_data->length < 0");
432 uri_v
= g_uri_list_extract_uris ((gchar
*) selection_data
->data
);
434 for (i
= 0; uri_v
[i
] != NULL
; i
++) {
435 if (gpiv_par
->verbose
) g_message ("on_clist_buf_drag_data_received:: uri_v[%d] = %s", i
, uri_v
[i
]);
436 fname_in
= g_strdup (uri_v
[i
]);
437 g_strchomp (fname_in
);
438 select_action_from_name (gpiv
, fname_in
);
447 on_open_activate_response (GtkDialog
*dialog
,
451 /*-----------------------------------------------------------------------------
454 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT(dialog
), "gpiv");
455 /* Display *disp = gtk_object_get_data (GTK_OBJECT(dialog), "display"); */
459 g_assert ( response
== GTK_RESPONSE_ACCEPT
460 || response
== GTK_RESPONSE_CANCEL
);
463 case GTK_RESPONSE_ACCEPT
:
464 filename
= gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog
));
465 if (gpiv_par
->verbose
) g_message ("on_open_activate:: filename = %s", filename
);
466 select_action_from_name (gpiv
, filename
);
470 case GTK_RESPONSE_CANCEL
:
474 g_warning("on_open_activate_response: should not arrive here");
482 on_open_activate (GtkMenuItem
*menuitem
,
484 /*-----------------------------------------------------------------------------
487 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (menuitem
), "gpiv");
490 if (gpiv_par
->verbose
) g_message ("on_open_activate:: fname_last = %s",
491 gpiv_var
->fname_last
);
492 dialog
= gtk_file_chooser_dialog_new ("Open Uri/File",
493 GTK_WINDOW (gpiv
->console
),
494 GTK_FILE_CHOOSER_ACTION_OPEN
,
495 GTK_STOCK_CANCEL
, GTK_RESPONSE_CANCEL
,
496 GTK_STOCK_OPEN
, GTK_RESPONSE_ACCEPT
,
499 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog
), FALSE
);
500 gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog
), gpiv_var
->fname_last
);
504 /* Will not open dialog when pressing ^O */
505 g_signal_connect (dialog
,
507 G_CALLBACK (on_open_activate_response
),
510 g_signal_connect_swapped (GTK_DIALOG (dialog
),
512 G_CALLBACK (gtk_widget_destroy
),
515 gtk_object_set_data (GTK_OBJECT (dialog
),
520 if (gtk_dialog_run (GTK_DIALOG (dialog
)) == GTK_RESPONSE_ACCEPT
) {
523 filename
= gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog
));
524 if (gpiv_par
->verbose
) g_message ("on_open_activate:: filename = %s", filename
);
525 select_action_from_name (gpiv
, filename
);
529 gtk_widget_destroy (dialog
);
530 #endif /* USE_CALLBACK */
538 on_save_activate (GtkMenuItem
* menuitem
,
540 /*-----------------------------------------------------------------------------
543 GpivConsole
* gpiv
= gtk_object_get_data (GTK_OBJECT (menuitem
), "gpiv");
544 save_all_data (gpiv
);
549 on_save_as_activate (GtkMenuItem
*menuitem
,
551 /*-----------------------------------------------------------------------------
554 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (menuitem
), "gpiv");
557 dialog
= gtk_file_chooser_dialog_new ("Save as",
558 GTK_WINDOW (gpiv
->console
),
559 GTK_FILE_CHOOSER_ACTION_SAVE
,
560 GTK_STOCK_CANCEL
, GTK_RESPONSE_CANCEL
,
561 GTK_STOCK_SAVE
, GTK_RESPONSE_ACCEPT
,
564 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog
), FALSE
);
565 gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog
), gpiv_var
->fname_last
);
567 if (gtk_dialog_run (GTK_DIALOG (dialog
)) == GTK_RESPONSE_ACCEPT
) {
568 char *fname
= gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog
));
569 if (gpiv_par
->verbose
) g_message ("on_save_as_activate:: fname = %s", fname
);
570 file_saveas_accept (gpiv
, fname
/* dialog */);
574 gtk_widget_destroy (dialog
);
579 file_saveas_accept (GpivConsole
*gpiv
,
582 /* ----------------------------------------------------------------------------
583 * Stores PIV image, data and related under different name
586 gchar
*text_uri
, *suffix
;
587 GnomeVFSURI
* uri
= NULL
;
588 gchar
*fname_base
; /* file name without suffix and directory name */
589 gchar
*clist_buf_txt
[MAX_BUFS
][2], cl_int
[3];
590 gboolean local_hdf_par
;
593 * Set gpiv_par->hdf if filename has suffix GPIV_EXT_GPIV.
594 * Reset after calling exec_save.
595 * Set saved_img to FALSE to guarantee saving image.
597 suffix
= g_strdup (strrchr (fname
, '.'));
598 if (strcmp (suffix
, GPIV_EXT_GPIV
) == 0) {
599 local_hdf_par
= gpiv_par
->hdf
;
600 gpiv_par
->img_fmt
= IMG_FMT_HDF
;
602 display_act
->img
->saved_img
= FALSE
;
605 * Check if uri is local filesystem
606 * create proper local filename or uri and short name
608 text_uri
= gnome_vfs_make_uri_from_shell_arg (fname
);
609 uri
= gnome_vfs_uri_new (text_uri
);
612 if (gnome_vfs_uri_is_local (uri
)) {
613 const gchar
*path
= gnome_vfs_uri_get_path (uri
);
614 gchar
*dirname
, /* directory name */
615 *fname_nosuf
, /* filename including dirname/uri, without suffix */
616 *fname_home
; /* filename with $HOME substituted by ~, without suffix */
618 fname_home
= replace_home_dir_with_tilde (path
);
619 dirname
= g_strdup (g_path_get_dirname (fname_home
));
622 /* dirname = g_strdup (g_path_get_dirname */
623 /* (replace_home_dir_with_tilde (path))); */
625 fname_base
= g_strdup (strtok (/*g_path_get_basename (path) */ dirname
, "."));
626 strtok (fname_base
, ".");
627 fname_nosuf
= g_strdup (g_strconcat (dirname
, G_DIR_SEPARATOR_S
, fname_base
, NULL
));
628 fname_home
= replace_home_dir_with_tilde (fname_nosuf
);
629 if (gpiv_par
->verbose
) g_message ("file_saveas_accept:: LOCAL dirname = %s fname_base = %s fname_home = %s",
630 dirname
, fname_base
, fname_home
);
632 display_act
->file_uri_name
= g_strdup_printf ("%s", fname_home
);
636 g_free (fname_nosuf
);
639 fname_base
= strtok (gnome_vfs_uri_extract_short_name (uri
), ".");
640 g_snprintf (display_act
->file_uri_name
, GPIV_MAX_CHARS
, "%s",
641 strtok (gnome_vfs_uri_to_string (uri
, TRUE
), "."));
645 * Substituting file_uri_name in display_act
646 * Changing fname in clist and in Image tab of the console
647 * storing data of display_act
648 * Resetting gpiv_par->hdf (and gpiv_par->img_fmt)
650 gtk_clist_remove (GTK_CLIST (gpiv
->clist_buf
), display_act
->id
);
651 g_snprintf (cl_int
, 3, "%d", display_act
->id
);
652 clist_buf_txt
[display_act
->id
][0] = (gchar
*) cl_int
;
653 clist_buf_txt
[display_act
->id
][1] = fname_base
;
654 gtk_clist_insert (GTK_CLIST (gpiv
->clist_buf
), display_act
->id
,
655 clist_buf_txt
[display_act
->id
]);
656 g_snprintf (display_act
->msg_display_default
, GPIV_MAX_CHARS
, "%s",
657 display_act
->file_uri_name
);
658 gnome_appbar_set_default (GNOME_APPBAR (display_act
->appbar
),
659 display_act
->msg_display_default
);
660 update_imgh_entries (gpiv
, display_act
->img
->image
->header
);
661 exec_save (display_act
);
663 if (strcmp (suffix
, GPIV_EXT_GPIV
) == 0) {
664 /* gpiv_par->hdf = local_hdf_par; */
665 gpiv_par
->img_fmt
= default_par
->img_fmt
;
675 save_all_data (GpivConsole
* gpiv
)
676 /*-----------------------------------------------------------------------------
682 for (row
= gpiv
->first_selected_row
; row
<= gpiv
->last_selected_row
;
684 display_act
= gtk_clist_get_row_data (GTK_CLIST (gpiv
->clist_buf
),
686 ibuf
= display_act
->id
;
687 if (display
[ibuf
] != NULL
688 && display_act
->mwin
!= NULL
689 && GTK_WIDGET_VISIBLE (GTK_WIDGET (display_act
->mwin
)) ) {
690 gdk_window_show (GTK_WIDGET (display_act
->mwin
)->window
);
691 gdk_window_raise (GTK_WIDGET (display_act
->mwin
)->window
);
694 exec_save (display_act
);
703 on_print_activate (GtkMenuItem
* menuitem
,
705 /*-----------------------------------------------------------------------------
708 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (menuitem
), "gpiv");
709 GtkDialog
*gpiv_print_dialog
= create_print_dialog (gpiv
);
710 gtk_widget_show (GTK_WIDGET (gpiv_print_dialog
));
716 on_execute_activate (GtkMenuItem
* menuitem
,
718 /*-----------------------------------------------------------------------------
721 GpivConsole
* gpiv
= gtk_object_get_data (GTK_OBJECT (menuitem
), "gpiv");
724 cancel_process
= FALSE
;
729 * RTA may trigger camera, but camera and RTAI trigger system may also be used
732 if (/* !cancel_process && */ gpiv_par
->process__trig
733 && gpiv_par
->process__cam
) {
734 exec_cam_start (gpiv
);
735 exec_trigger_start ();
736 if (trig_par
->ttime
->mode
== GPIV_TIMER_MODE__DURATION
) {
737 gpiv
->first_selected_row
= 0;
738 gpiv
->last_selected_row
= trig_par
->ttime
->cycles
- 1;
740 } else if (/* !cancel_process && */ gpiv_par
->process__cam
) {
741 exec_cam_start (gpiv
);
742 if (gl_cam_par
->mode
== GPIV_CAM_MODE__DURATION
) {
743 gpiv
->first_selected_row
= 0;
744 gpiv
->last_selected_row
= gl_cam_par
->cycles
- 1;
746 } else if (/* !cancel_process && */ gpiv_par
->process__trig
) {
747 exec_trigger_start ();
749 #else /* ENABLE_TRIG */
751 * RTA triggering disabled, only camera may be used
753 if (/* !cancel_process && */ gpiv_par
->process__cam
) {
754 exec_cam_start (gpiv
);
755 if (gl_cam_par
->mode
== GPIV_CAM_MODE__DURATION
) {
756 gpiv
->first_selected_row
= 0;
757 gpiv
->last_selected_row
= gl_cam_par
->cycles
- 1;
760 #endif /* ENABLE_TRIG */
761 #else /* ENABLE_CAM */
764 * Only RTA triggering may be used, camera disabled
766 if (/* !cancel_process && */ gpiv_par
->process__trig
) {
767 exec_trigger_start ();
769 #endif /* ENABLE_TRIG */
770 #endif /* ENABLE_CAM */
775 for (row
= gpiv
->first_selected_row
; row
<= gpiv
->last_selected_row
;
777 display_act
= gtk_clist_get_row_data (GTK_CLIST (gpiv
->clist_buf
),
779 if (display
[display_act
->id
] != NULL
780 && GTK_WIDGET_VISIBLE (GTK_WIDGET (display_act
->mwin
)) ) {
781 gdk_window_show (GTK_WIDGET (display_act
->mwin
)->window
);
782 gdk_window_raise (GTK_WIDGET (display_act
->mwin
)->window
);
785 #ifdef ENABLE_IMGPROC
786 if (!cancel_process
&& gpiv_par
->process__imgproc
) {
791 if (!cancel_process
&& gpiv_par
->process__piv
) {
795 if (!cancel_process
&& gpiv_par
->process__gradient
) {
799 if (!cancel_process
&& gpiv_par
->process__resstats
) {
800 gpiv_var
->residu_stats
= TRUE
;
801 exec_errvec (gpiv
->pivvalid
);
804 if (!cancel_process
&& gpiv_par
->process__errvec
) {
805 gpiv_var
->residu_stats
= FALSE
;
806 exec_errvec (gpiv
->pivvalid
);
809 if (!cancel_process
&& gpiv_par
->process__peaklock
) {
810 exec_peaklock (gpiv
->pivvalid
);
813 if (!cancel_process
&& gpiv_par
->process__scale
) {
814 exec_scale (gpiv
->pivpost
);
817 if (!cancel_process
&& gpiv_par
->process__average
) {
818 exec_savg (gpiv
->pivpost
);
821 if (!cancel_process
&& gpiv_par
->process__subtract
) {
822 exec_subavg (gpiv
->pivpost
);
825 if (!cancel_process
&& gpiv_par
->process__vorstra
) {
831 exec_process
= FALSE
;
837 on_stop_activate (GtkMenuItem
*menuitem
,
839 /*-----------------------------------------------------------------------------
842 /* warning_gpiv(_("process has been stopped")); */
847 on_button_stop_press (GtkWidget
* widget
,
849 /*-----------------------------------------------------------------------------
852 cancel_process
= TRUE
;
853 message_gpiv (_("cancel_process = TRUE"));
858 on_button_stop_release (GtkWidget
* widget
,
860 /*-----------------------------------------------------------------------------
863 cancel_process
= FALSE
;
864 message_gpiv (_("cancel_process = FALSE"));
865 /* process has been stopped */
869 /* static gboolean */
870 /* on_display_delete(GtkWidget *widget, */
871 /* GdkEvent *event, */
879 on_close_activate (GtkMenuItem
* menuitem
,
881 /*-----------------------------------------------------------------------------
882 * Remove multiple selected displays
885 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (menuitem
), "gpiv");
886 Display
*disp
= NULL
;
890 guint row_close
= gpiv
->first_selected_row
; /* row to be closed */
891 guint first
= gpiv
->first_selected_row
; /* first_selected_row will be modified! */
892 guint last
= gpiv
->last_selected_row
; /* last_selected_row will be modified! */
893 guint loc_nbufs
= nbufs
;
894 gboolean buf_closed
= TRUE
;
897 if ((err_msg
= gpiv_cam_free_camvar (&cam_var
)) != NULL
) {
898 error_gpiv ("from: on_close_activate\n from: gpiv_cam_free_camvar\n %s",
901 #endif /* ENABLE_CAM */
905 * Depending on the response if a display/buffer with unsaved data will be closed,
906 * the same or next row in the clist_buf will taken for selecting next display.
908 for (row
= first
; row
<= last
; row
++) {
910 if (row_close
< nbufs
- 1) {
914 disp
= gtk_clist_get_row_data (GTK_CLIST (gpiv
->clist_buf
),
916 close_buffer__check_saved (gpiv
, disp
);
919 * Check if a buffer has been closed
921 if (loc_nbufs
== nbufs
) {
931 update_imgh_entries (gpiv
, gl_image_par
);
932 update_eval_entries (gpiv
, gl_image_par
);
935 #ifdef ENABLE_IMGPROC
936 set_imgproc_filtervar (gpiv
, GPIV_IMGFI_SUBACK
, nbufs
- 1);
943 on_exit_activate (GtkMenuItem
* menuitem
,
945 /*-----------------------------------------------------------------------------
948 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (menuitem
), "gpiv");
949 GtkDialog
*gpiv_exit
;
953 exec_trigger_stop ();
954 #endif /* ENABLE_TRIG */
958 #endif /* ENABLE_CAM */
961 for (i
= 0; i
< nbufs
; i
++) {
962 /* if (display[i] != NULL) display_act = display[i]; */
963 display_act
= gtk_clist_get_row_data (GTK_CLIST (gpiv
->clist_buf
), i
);
965 if (!display_act
->img
->saved_img
966 || !display_act
->pida
->saved_piv
967 || !display_act
->pida
->saved_histo
968 || !display_act
->pida
->saved_vor
969 || !display_act
->pida
->saved_nstrain
970 || !display_act
->pida
->saved_sstrain
) {
971 gpiv_exit
= create_exit_dialog ();
972 gtk_widget_show (GTK_WIDGET (gpiv_exit
));
974 free_all_bufmems (display_act
);
987 on_preferences_activate (GtkWidget
* widget
,
989 /*-----------------------------------------------------------------------------
992 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (widget
), "gpiv");
993 GtkDialog
*preferences
= NULL
;
995 preferences
= create_preferences (gpiv
);
1000 void on_about_activate (GtkMenuItem
* menuitem
,
1002 /*-----------------------------------------------------------------------------
1006 about
= create_about ();
1013 void on_manual_activate (GtkMenuItem
* menuitem
,
1015 /*-----------------------------------------------------------------------------
1018 GError
* error
= NULL
;
1020 if (!gnome_help_display ("index.html", NULL
, &error
)) {
1021 g_warning ("%s", error
);
1022 g_error_free (error
);
1029 * Gnome toolbar buttons
1034 on_button_open_clicked (GtkButton
*button
,
1036 /*-----------------------------------------------------------------------------
1040 gchar
*msg
= "Opens PIV image";
1041 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (button
), "gpiv");
1042 GtkWidget
*dialog
= NULL
;
1045 if (gpiv_par
->verbose
) g_message ("on_button_open_activate:: fname_last = %s", gpiv_var
->fname_last
);
1046 dialog
= gtk_file_chooser_dialog_new ("Open Uri/File",
1047 GTK_WINDOW (gpiv
->console
),
1048 GTK_FILE_CHOOSER_ACTION_OPEN
,
1049 GTK_STOCK_CANCEL
, GTK_RESPONSE_CANCEL
,
1050 GTK_STOCK_OPEN
, GTK_RESPONSE_ACCEPT
,
1053 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog
), FALSE
);
1054 gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog
), gpiv_var
->fname_last
);
1056 if (gtk_dialog_run (GTK_DIALOG (dialog
)) == GTK_RESPONSE_ACCEPT
) {
1057 char *filename
= NULL
;
1059 filename
= gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog
));
1060 if (gpiv_par
->verbose
) g_message ("on_button_open_activate:: filename = %s", filename
);
1061 select_action_from_name (gpiv
, filename
);
1065 gtk_widget_destroy (dialog
);
1067 gnome_appbar_set_status (GNOME_APPBAR (gpiv
->appbar
), msg
);
1073 on_menubar_activate (GtkWidget
* widget
,
1075 /*-----------------------------------------------------------------------------
1078 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (widget
), "gpiv");
1079 if (GTK_CHECK_MENU_ITEM (widget
)->active
) {
1080 gtk_widget_show (gpiv
->menubar
);
1082 gtk_widget_hide (gpiv
->menubar
);
1089 on_toolbuttons_activate (GtkWidget
* widget
,
1091 /*-----------------------------------------------------------------------------
1094 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (widget
), "gpiv");
1095 if (GTK_CHECK_MENU_ITEM (widget
)->active
) {
1096 gtk_widget_show (gpiv
->toolbar1
);
1097 /* gtk_widget_ref(settings_menu_gpiv_popup[1].widget); */
1098 /* gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM */
1099 /* (settings_menu_gpiv_popup[1].widget), */
1102 gtk_widget_hide (gpiv
->toolbar1
);
1103 /* gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM */
1104 /* (settings_menu_gpiv_popup[1].widget), */
1113 on_gpivbuttons_activate (GtkWidget
* widget
,
1115 /*-----------------------------------------------------------------------------
1118 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (widget
), "gpiv");
1119 if (GTK_CHECK_MENU_ITEM (widget
)->active
) {
1120 gtk_widget_show (gpiv
->handlebox1
);
1123 gtk_widget_hide (gpiv
->handlebox1
);
1130 on_tabulator_activate (GtkWidget
* widget
,
1132 /*-----------------------------------------------------------------------------
1135 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (widget
), "gpiv");
1136 if (GTK_CHECK_MENU_ITEM (widget
)->active
) {
1137 gtk_widget_show (gpiv
->notebook
);
1139 gtk_widget_hide (gpiv
->notebook
);
1147 on_tooltip_activate (GtkWidget
* widget
,
1149 /*-----------------------------------------------------------------------------
1152 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (widget
), "gpiv");
1153 if (GTK_CHECK_MENU_ITEM (widget
)->active
) {
1154 gtk_tooltips_enable (gpiv
->tooltips
);
1156 gtk_tooltips_disable (gpiv
->tooltips
);
1165 on_buffer_set_focus (GtkWindow
* window
,
1168 /*-----------------------------------------------------------------------------
1171 /* SEE: on_clist_buf_rowselect */
1177 gtk_window_destroy (GtkButton
* button
,
1179 /*-----------------------------------------------------------------------------
1188 on_appbar_display_user_response (GnomeAppBar
* gnomeappbar
,
1190 /*-----------------------------------------------------------------------------
1199 on_button_open_enter (GtkContainer
* container
,
1200 GtkDirectionType direction
,
1202 /*-----------------------------------------------------------------------------
1205 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (container
), "gpiv");
1206 gchar
*msg
= _("Opens image/PIV data (and display)");
1207 gnome_appbar_set_status (GNOME_APPBAR (gpiv
->appbar
), msg
);
1213 on_button_save_enter (GtkContainer
* container
,
1214 GtkDirectionType direction
,
1216 {/*-----------------------------------------------------------------------------
1219 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (container
), "gpiv");
1220 gchar
*msg
= _("Saves data");
1221 gnome_appbar_set_status (GNOME_APPBAR (gpiv
->appbar
), msg
);
1227 on_button_print_enter (GtkContainer
* container
,
1228 GtkDirectionType direction
,
1230 /*-----------------------------------------------------------------------------
1233 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (container
), "gpiv");
1234 gchar
*msg
= _("Prints selected buffer(s)");
1235 gnome_appbar_set_status (GNOME_APPBAR (gpiv
->appbar
), msg
);
1241 on_button_execute_enter (GtkContainer
* container
,
1242 GtkDirectionType direction
,
1244 /*-----------------------------------------------------------------------------
1247 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (container
), "gpiv");
1248 gchar
*msg
= _("Executes all tickmarked processes");
1249 gnome_appbar_set_status (GNOME_APPBAR (gpiv
->appbar
), msg
);
1255 on_button_stop_enter (GtkContainer
* container
,
1256 GtkDirectionType direction
,
1258 /*-----------------------------------------------------------------------------
1261 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (container
), "gpiv");
1262 gchar
*msg
= _("Cancels any running processes");
1263 gnome_appbar_set_status (GNOME_APPBAR (gpiv
->appbar
), msg
);
1269 on_button_close_enter (GtkContainer
* container
,
1270 GtkDirectionType direction
,
1272 /*-----------------------------------------------------------------------------
1275 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (container
), "gpiv");
1276 gchar
*msg
= _("Close active buffer(s)");
1277 gnome_appbar_set_status (GNOME_APPBAR (gpiv
->appbar
), msg
);
1283 on_button_exit_enter (GtkContainer
* container
,
1284 GtkDirectionType direction
,
1286 /*-----------------------------------------------------------------------------
1289 GpivConsole
*gpiv
= gtk_object_get_data (GTK_OBJECT (container
), "gpiv");
1290 gchar
*msg
= _("Exits GPIV");
1291 gnome_appbar_set_status (GNOME_APPBAR (gpiv
->appbar
), msg
);
1298 on_toolbar_checkbutton_cam (GtkWidget
* widget
,
1300 /*-----------------------------------------------------------------------------
1301 * toolbar containing checkbutton for recording process
1304 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1305 gpiv_par
->process__cam
= TRUE
;
1307 gpiv_par
->process__cam
= FALSE
;
1310 #endif /* ENABLE_CAM */
1315 on_toolbar_checkbutton_trig (GtkWidget
* widget
,
1317 /*-----------------------------------------------------------------------------
1318 * toolbar containing checkbutton for triggering process
1321 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1322 gpiv_par
->process__trig
= TRUE
;
1324 gpiv_par
->process__trig
= FALSE
;
1327 #endif /* ENABLE_TRIG */
1330 #ifdef ENABLE_IMGPROC
1332 on_toolbar_checkbutton_imgproc (GtkWidget
* widget
,
1334 /*-----------------------------------------------------------------------------
1335 * toolbar containing checkbutton for image process
1338 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1339 gpiv_par
->process__imgproc
= TRUE
;
1341 gpiv_par
->process__imgproc
= FALSE
;
1344 #endif /* ENABLE_IMGPROC */
1349 on_toolbar_checkbutton_piv (GtkWidget
* widget
,
1351 /*-----------------------------------------------------------------------------
1352 * toolbar containing checkbutton for processes
1355 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1356 gpiv_par
->process__piv
= TRUE
;
1358 gpiv_par
->process__piv
= FALSE
;
1365 on_toolbar_checkbutton_gradient (GtkWidget
* widget
,
1367 /*-----------------------------------------------------------------------------
1370 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1371 gpiv_par
->process__gradient
= TRUE
;
1373 gpiv_par
->process__gradient
= FALSE
;
1380 on_toolbar_checkbutton_resstats (GtkWidget
* widget
,
1382 /*-----------------------------------------------------------------------------
1385 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1386 gpiv_par
->process__resstats
= TRUE
;
1387 gpiv_var
->residu_stats
= TRUE
;
1389 gpiv_par
->process__resstats
= FALSE
;
1390 gpiv_var
->residu_stats
= FALSE
;
1397 on_toolbar_checkbutton_errvec (GtkWidget
* widget
,
1399 /*-----------------------------------------------------------------------------
1402 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1403 gpiv_par
->process__errvec
= TRUE
;
1405 gpiv_par
->process__errvec
= FALSE
;
1412 on_toolbar_checkbutton_peaklck (GtkWidget
* widget
,
1414 /*-----------------------------------------------------------------------------
1417 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1418 gpiv_par
->process__peaklock
= TRUE
;
1420 gpiv_par
->process__peaklock
= FALSE
;
1427 on_toolbar_checkbutton_scale (GtkWidget
* widget
,
1429 /*-----------------------------------------------------------------------------
1432 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1433 gpiv_par
->process__scale
= TRUE
;
1435 gpiv_par
->process__scale
= FALSE
;
1442 on_toolbar_checkbutton_average (GtkWidget
* widget
,
1444 /*-----------------------------------------------------------------------------
1447 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1448 gpiv_par
->process__average
= TRUE
;
1450 gpiv_par
->process__average
= FALSE
;
1457 on_toolbar_checkbutton_subavg (GtkWidget
* widget
,
1459 /*-----------------------------------------------------------------------------
1462 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1463 gpiv_par
->process__subtract
= TRUE
;
1465 gpiv_par
->process__subtract
= FALSE
;
1472 on_toolbar_checkbutton_vorstra (GtkWidget
* widget
,
1474 /*-----------------------------------------------------------------------------
1477 if (GTK_TOGGLE_BUTTON (widget
)->active
) {
1478 gpiv_par
->process__vorstra
= TRUE
;
1480 gpiv_par
->process__vorstra
= FALSE
;
1487 /* PivData *pida_active = &display_act->pida; */
1490 on_button_quit_no_clicked (GtkButton
* button
,
1492 /*-----------------------------------------------------------------------------
1493 * exit, message dialog callbacks
1496 /* gnome_dialog_close (GTK_DIALOG (gpiv_exit)); */
1500 /* gtk_widget_destroy (GTK_DIALOG (GTK_DIALOG (gpiv_exit))); */
1506 on_button_quit_gpiv_yes_clicked (GtkButton
* button
,
1508 /*-----------------------------------------------------------------------------
1511 free_all_bufmems (display_act
);
1518 /* on_button_message_clicked (GtkButton * button, */
1519 /* gpointer user_data) */
1520 /* BUGFIX: obsolete function: on_button_message_clicked; clean up */
1522 on_button_message_clicked (GtkDialog
*dialog
,
1526 /*-----------------------------------------------------------------------------
1529 g_assert (response
== GTK_RESPONSE_ACCEPT
);
1532 case GTK_RESPONSE_ACCEPT
:
1533 /* gnome_dialog_close (GNOME_DIALOG (gpiv_exit)); */
1534 /* gtk_widget_destroy (GTK_DIALOG (gpiv_exit)); */
1537 g_warning ("on_message_clicked: should not arrive here");
1545 on_notebook_switch_page (GtkNotebook
*notebook
,
1546 GtkNotebookPage
*page
,
1550 /*-----------------------------------------------------------------------------
1553 gpiv_var
->tab_pos
= page_num
;
1555 gnome_config_push_prefix ("/gpiv/RuntimeVariables/");
1556 gnome_config_set_int ("tab_pos", gpiv_var
->tab_pos
);
1557 gnome_config_pop_prefix ();
1558 gnome_config_sync ();