1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 c-style: "K&R" -*- */
3 /*----------------------------------------------------------------------
5 gpiv - Graphic program for Particle Image Velocimetry, based on gtk/gnome
8 Copyright (C) 2002 Gerber van der Graaf
10 This file is part of gpiv.
12 Gpiv is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ----------------------------------------------------------------------*/
29 * (Callback) functions for console
31 * Revision 1.5 2003-07-10 11:56:07 gerber
34 * Revision 1.4 2003/07/06 15:29:49 gerber
35 * repair message text closing buffer
37 * Revision 1.3 2003/07/05 13:14:57 gerber
38 * drag and drop of a _series_ of filenames from NAUTILUS
40 * Revision 1.2 2003/06/27 13:47:26 gerber
41 * display ruler, line/point evaluation
43 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
54 #include "console_interface.h"
55 #include "console_menus.h"
61 #include "preferences.h"
67 * loading images and (piv) data functions
73 file_ok_sel(GtkWidget
* w
,
74 GtkFileSelection
* fs
);
77 select_action_from_fname(GpivConsole
*gpiv
,
81 load_buffer(GpivConsole
*gpiv
,
87 enum ClistPut clist_put
);
90 open_img(char *fname_in
,
95 open_piv(char *fname_in
,
99 exec_save(Display
* disp
);
106 on_widget_leave(GtkContainer
* container
,
107 GtkDirectionType direction
, gpointer user_data
)
109 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(container
), "gpiv");
110 gnome_appbar_push(GNOME_APPBAR(gpiv
->appbar
), msg_default
);
115 * Callback functions for pop-up menus
119 on_my_popup_handler(GtkWidget
*widget
, GdkEvent
*event
)
122 GdkEventButton
*event_button
;
124 g_return_val_if_fail (widget
!= NULL
, FALSE
);
125 g_return_val_if_fail (GTK_IS_MENU (widget
), FALSE
);
126 g_return_val_if_fail (event
!= NULL
, FALSE
);
128 /* The "widget" is the menu that was supplied when
129 * gtk_signal_connect_object was called.
131 menu
= GTK_MENU (widget
);
133 if (event
->type
== GDK_BUTTON_PRESS
)
135 event_button
= (GdkEventButton
*) event
;
136 if (event_button
->button
== 3)
138 gtk_menu_popup (menu
, NULL
, NULL
, NULL
, NULL
,
139 event_button
->button
, event_button
->time
);
152 * Main gpiv-gui callbacks
157 on_clist_buf_rowselect(GtkWidget
* clist
,
160 GdkEventButton
* event
,
163 gchar
* text
, labelno
[MAX_CHARS
];
164 GpivConsole
* gpiv
= gtk_object_get_data(GTK_OBJECT(clist
), "gpiv");
166 gint cnt
= 0, buf_dum
= 0;
168 if (!exec_process
&& GTK_CLIST (clist
)->selection
) {
169 for (lis
= GTK_CLIST (clist
)->selection
; lis
; lis
= lis
->next
) {
170 row
=GPOINTER_TO_INT (lis
->data
);
171 gtk_clist_get_text(GTK_CLIST(clist
), row
, /* column */ 0, &text
);
172 display_act
= gtk_clist_get_row_data(GTK_CLIST(gpiv
->clist_buf
),
177 if (print_par
) g_warning("on_clist_buf_rowselect:: row=%d, text=%s",
182 gpiv
->first_selected_row
= row
;
184 gpiv
->last_selected_row
= row
;
187 * update variables of display before leaving the focus
189 if (display_act
->intreg
.exist
== TRUE
) {
190 display_act
->intreg
.row_start_old
= 0;
191 display_act
->intreg
.row_start
= piv_eval_par
.row_start
;
192 display_act
->intreg
.row_end
= piv_eval_par
.row_end
;
193 display_act
->intreg
.col_start_old
= 0;
194 display_act
->intreg
.col_start
= piv_eval_par
.col_start
;
195 display_act
->intreg
.col_end
= piv_eval_par
.col_end
;
196 display_act
->intreg
.int_size_1
= piv_eval_par
.int_size_1
;
197 display_act
->intreg
.int_size_2
= piv_eval_par
.int_size_2
;
198 display_act
->intreg
.int_shift
= piv_eval_par
.int_shift
;
199 display_act
->intreg
.pre_shift_row
= piv_eval_par
.pre_shift_row
;
200 display_act
->intreg
.pre_shift_col
= piv_eval_par
.pre_shift_col
;
204 /* if (GTK_WIDGET_REALIZED(display_act->gpd.display)) */
206 display_act
= gtk_clist_get_row_data(GTK_CLIST(gpiv
->clist_buf
),
209 * Set variables of new active display equal to parameters
211 if (display_act
->intreg
.exist
== TRUE
212 && (display_act
->intreg
.row_start
!= piv_eval_par
.row_start
213 || display_act
->intreg
.row_end
!= piv_eval_par
.row_end
214 || display_act
->intreg
.col_start
!= piv_eval_par
.col_start
215 || display_act
->intreg
.col_end
!= piv_eval_par
.col_end
216 || display_act
->intreg
.int_size_1
!= piv_eval_par
.int_size_1
217 || display_act
->intreg
.int_size_2
!= piv_eval_par
.int_size_2
218 || display_act
->intreg
.int_shift
!= piv_eval_par
.int_shift
219 || display_act
->intreg
.pre_shift_row
!= piv_eval_par
.pre_shift_row
220 || display_act
->intreg
.pre_shift_col
!= piv_eval_par
.pre_shift_col
)
222 destroy_all_intregs(display_act
);
223 create_all_intregs(display_act
);
226 if (display_act
->mwin
!= NULL
227 && GTK_WIDGET_VISIBLE(GTK_WIDGET(display_act
->mwin
)) )
229 gdk_window_show(GTK_WIDGET(display_act
->mwin
)->window
);
230 gdk_window_raise(GTK_WIDGET(display_act
->mwin
)->window
);
233 * update labels in image header tab/window
235 g_snprintf(labelno
, MAX_CHARS
,"%d", display_act
->count
);
236 gtk_label_set_text(GTK_LABEL(gpiv
->imgh
->label_bufno
),
238 gtk_label_set_text(GTK_LABEL(gpiv
->imgh
->label_name
),
239 display_act
->fname_base
);
240 gtk_entry_set_text(GTK_ENTRY(gpiv
->imgh
->entry_project
),
241 /* display_act->gpd. */ image_par
.project
);
242 gtk_entry_set_text(GTK_ENTRY(gpiv
->imgh
->entry_crdate
),
243 /* display_act->gpd. */ image_par
.creation_date
);
244 gtk_entry_set_text(GTK_ENTRY(gpiv
->imgh
->entry_location
),
245 /* display_act->gpd. */ image_par
.location
);
246 gtk_entry_set_text(GTK_ENTRY(gpiv
->imgh
->entry_comment
),
247 /* display_act->gpd. */ image_par
.comment
);
248 /* gtk_widget_grab_focus (display_act); */
255 gpiv
->last_selected_row
= gpiv
->first_selected_row
;
258 if (gpiv
->last_selected_row
< gpiv
->first_selected_row
) {
259 buf_dum
= gpiv
->last_selected_row
;
260 gpiv
->last_selected_row
= gpiv
->first_selected_row
;
261 gpiv
->first_selected_row
= buf_dum
;
267 if (print_par
) g_warning("on_clist_buf_rowselect:: first_selected_row = %d, ast_selected_row = %d",
268 gpiv
->first_selected_row
, gpiv
->last_selected_row
);
274 on_clist_buf_drag_data_received (GtkWidget
*widget
,
275 GdkDragContext
*context
,
278 GtkSelectionData
*data
,
282 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
288 g_print("Got: %s\n", data
->data
);
290 fname_v
= g_strsplit(data
->data
, "file:", MAX_BUFS
);
293 * Count the number of selected files
295 fname_cnt
= strtok(data
->data
, ":");
296 while (fname_cnt
!= NULL
&& count
< MAX_BUFS
) {
297 fname_cnt
= strtok(NULL
, ":");
302 * load the data from selected files
304 for (i
= 1; i
<= count
- 1; i
++) {
305 fname_in
= g_strdup(fname_v
[i
]);
306 g_strchomp (fname_in
);
307 select_action_from_fname(gpiv
, fname_in
);
316 on_open_activate(GtkMenuItem
* menuitem
,
320 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(menuitem
), "gpiv");
323 * Create a new file selection widget
324 * Connect the ok_button and cancel_button to file_ok_sel function
325 * set user data to filew
326 * Lets set a default filename
328 filew
= gtk_file_selection_new(/* "File selection" */"gpiv: open image");
329 gtk_signal_connect(GTK_OBJECT(filew
), "destroy",
330 (GtkSignalFunc
) destroy
, &filew
);
331 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew
)->ok_button
),
332 "clicked", (GtkSignalFunc
) file_ok_sel
,
334 gtk_signal_connect_object(GTK_OBJECT
335 (GTK_FILE_SELECTION(filew
)->ok_button
),
337 (GtkSignalFunc
) gtk_widget_destroy
,
339 gtk_object_set_data(GTK_OBJECT(GTK_FILE_SELECTION(filew
)->ok_button
),
342 gtk_signal_connect_object(GTK_OBJECT
343 (GTK_FILE_SELECTION(filew
)->cancel_button
),
345 (GtkSignalFunc
) gtk_widget_destroy
,
347 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew
),
349 gtk_widget_show(filew
);
350 gtk_object_set_data(GTK_OBJECT(GTK_FILE_SELECTION(filew
)),
359 on_save_activate(GtkMenuItem
* menuitem
,
362 GpivConsole
* gpiv
= gtk_object_get_data(GTK_OBJECT(menuitem
), "gpiv");
368 on_save_as_activate(GtkMenuItem
* menuitem
,
372 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(menuitem
), "gpiv");
376 * Create a new file selection widget
377 * Connect the ok_button and cancel_button to file_saveas_ok_sel function
378 * set user data to filew
379 * Lets set a default filename
381 filew
= gtk_file_selection_new("File selection");
382 gtk_signal_connect(GTK_OBJECT(filew
), "destroy",
383 (GtkSignalFunc
) destroy
, &filew
);
384 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew
)->ok_button
),
385 "clicked", (GtkSignalFunc
) file_saveas_ok_sel
,
387 gtk_signal_connect_object(GTK_OBJECT
388 (GTK_FILE_SELECTION(filew
)->ok_button
),
390 (GtkSignalFunc
) gtk_widget_destroy
,
392 gtk_object_set_data(GTK_OBJECT(GTK_FILE_SELECTION(filew
)->ok_button
),
395 gtk_signal_connect_object(GTK_OBJECT
396 (GTK_FILE_SELECTION(filew
)->cancel_button
),
398 (GtkSignalFunc
) gtk_widget_destroy
,
400 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew
),
402 gtk_widget_show(filew
);
403 gtk_object_set_data(GTK_OBJECT(GTK_FILE_SELECTION(filew
)),
407 g_warning("on_save_as_activate:: END");
412 file_saveas_ok_sel(GtkWidget
* widget
,
413 GtkFileSelection
* fs
415 /* ---------------------------------------------- PIV data file selection */
417 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(fs
), "gpiv");
423 gchar
*clist_buf_txt
[MAX_BUFS
][2], cl_int
[2];
426 fname_in
= g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs
)));
428 g_warning("file_saveas_ok_sel:: 0");
430 * Stripping file name
433 /*----------------------------------------------------------------------
435 * gchar* g_path_get_basename (const gchar *file_name);
436 * gchar* g_path_get_dirname (const gchar *file_name);
438 *----------------------------------------------------------------------*/
439 dirname
= g_strdup(g_dirname(fname_in
));
440 fname_base
= g_strdup(g_basename(fname_in
));
441 strtok(fname_base
, ".");
442 fname_ext
= g_strdup(g_strconcat(dirname
, G_DIR_SEPARATOR_S
,
446 * Substituting fname_base and storing data of display_act
448 gtk_clist_remove(GTK_CLIST(gpiv
->clist_buf
), display_act
->count
);
449 g_snprintf(cl_int
, 2, "%d", display_act
->count
);
450 g_snprintf(display_act
->fname_base
, MAX_CHARS
, "%s", fname_ext
);
451 clist_buf_txt
[display_act
->count
][0] = (gchar
*) cl_int
;
452 clist_buf_txt
[display_act
->count
][1] = fname_base
;
453 gtk_clist_insert(GTK_CLIST(gpiv
->clist_buf
), display_act
->count
,
454 clist_buf_txt
[display_act
->count
]);
456 g_snprintf(display_act
->msg_display_default
, MAX_CHARS
, "%s",
457 display_act
->fname_base
);
458 gnome_appbar_set_default(GNOME_APPBAR(display_act
->appbar
),
459 display_act
->msg_display_default
);
461 g_warning("file_saveas_ok_sel:: 1");
462 /* save_all_data(gpiv); */
463 exec_save(display_act
);
464 g_warning("file_saveas_ok_sel:: 2");
474 save_all_data(GpivConsole
* gpiv
)
479 for (row
= gpiv
->first_selected_row
; row
<= gpiv
->last_selected_row
;
481 display_act
= gtk_clist_get_row_data(GTK_CLIST(gpiv
->clist_buf
),
483 ibuf
= display_act
->count
;
484 if (display
[ibuf
] != NULL
485 && display_act
->mwin
!= NULL
486 && GTK_WIDGET_VISIBLE(GTK_WIDGET(display_act
->mwin
)) ) {
487 gdk_window_show(GTK_WIDGET(display_act
->mwin
)->window
);
488 gdk_window_raise(GTK_WIDGET(display_act
->mwin
)->window
);
491 exec_save(display_act
);
500 exec_save(Display
* disp
)
501 /*--------------------------------------------------------------------
502 * Store all data in display_act->fname_base.gpi in hdf5 format
505 char *err_msg
= NULL
;
506 gint return_val
, flag_vor
= 0;
507 char fname_out
[MAX_CHARS
], fname_par
[MAX_CHARS
];
512 if (print_par
) gpiv_warning("writing HDF5 fmt");
513 gpiv_io_make_fname(display_act
->fname_base
, EXT_GPIV
, fname_out
);
516 gpiv_fcreate_hdf5 (fname_out
))
517 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
520 gpiv_img_fwrite_hdf5_parameters (fname_out
,
521 &display_act
->img
.image_par
))
522 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
524 if (gpiv_par
.hdf_img
) {
526 gpiv_fwrite_hdf5_image (fname_out
, display_act
->img
.img1
,
527 display_act
->img
.img2
,
528 &display_act
->img
.image_par
))
529 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
534 if (display_act
->gpd
.exist_piv
) {
535 if (display_act
->gpd
.scaled_piv
) {
537 gpiv_fwrite_hdf5_piv_position
539 &display_act
->gpd
.piv_data_scaled
,
541 &display_act
->gpd
.scaled_piv
))
542 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
545 gpiv_fwrite_hdf5_pivdata
547 &display_act
->gpd
.piv_data_scaled
,
550 &display_act
->gpd
.scaled_piv
))
551 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
554 gpiv_fwrite_hdf5_piv_position
556 &display_act
->gpd
.piv_data
,
558 &display_act
->gpd
.scaled_piv
))
559 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
562 gpiv_fwrite_hdf5_pivdata
564 &display_act
->gpd
.piv_data
,
567 &display_act
->gpd
.scaled_piv
))
568 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
571 display_act
->gpd
.saved_piv
= TRUE
;
574 gpiv_piv_fwrite_hdf5_parameters
576 &display_act
->gpd
.piv_eval_par
))
577 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
581 if (display_act
->gpd
.exist_valid
) {
583 gpiv_valid_fwrite_hdf5_parameters
584 (fname_out
, &display_act
->gpd
.piv_valid_par
))
585 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
589 if (display_act
->gpd
.exist_vor
) {
590 if (display_act
->gpd
.scaled_piv
) {
592 gpiv_fwrite_hdf5_scdata(fname_out
,
597 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
600 gpiv_fwrite_hdf5_scdata(fname_out
,
601 &display_act
->gpd
.vor_data
,
604 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
606 display_act
->gpd
.saved_vor
= TRUE
;
610 if (display_act
->gpd
.exist_sstrain
) {
611 if (display_act
->gpd
.scaled_piv
) {
613 gpiv_fwrite_hdf5_scdata(fname_out
,
618 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
621 gpiv_fwrite_hdf5_scdata(fname_out
,
622 &display_act
->gpd
.sstrain_data
,
625 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
627 display_act
->gpd
.saved_sstrain
= TRUE
;
631 if (display_act
->gpd
.exist_nstrain
) {
632 if (display_act
->gpd
.scaled_piv
) {
634 gpiv_fwrite_hdf5_scdata(fname_out
,
639 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
642 gpiv_fwrite_hdf5_scdata(fname_out
,
643 &display_act
->gpd
.nstrain_data
,
646 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
648 display_act
->gpd
.saved_nstrain
= TRUE
;
653 gpiv_post_fwrite_hdf5_parameters (fname_out
,
654 &display_act
->gpd
.piv_post_par
))
655 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
660 * Store all data in ASCII format at different files
663 if (print_par
) gpiv_warning("writing ASCII fmt");
668 gpiv_io_make_fname(display_act
->fname_base
, EXT_HEADER
, fname_par
);
669 if ((fp_par
= fopen(fname_par
, "w")) == NULL
) {
670 gtk_error(_("Failure opening image header for output"));
672 fprintf(fp_par
, "#%s\n", RCSID
);
673 gpiv_img_fprint_header(fp_par
, display_act
->img
.image_par
);
680 gpiv_io_make_fname(display_act
->fname_base
, EXT_PAR
, fname_par
);
681 if ((fp_par
= fopen(fname_par
, "w")) == NULL
) {
682 gtk_error(_("Failure opening parameter file for output"));
684 fprintf(fp_par
, "#%s\n", RCSID
);
685 gpiv_img_fprint_header(fp_par
, display_act
->img
.image_par
);
691 if (display_act
->gpd
.exist_piv
) {
692 gpiv_io_make_fname(display_act
->fname_base
, EXT_PIV
,
695 if (display_act
->gpd
.scaled_piv
) {
697 gpiv_fwrite_pivdata(fname_out
,
698 &display_act
->gpd
.piv_data_scaled
,
701 display_act
->gpd
.scaled_piv
,
703 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
706 gpiv_fwrite_pivdata(fname_out
,
707 &display_act
->gpd
.piv_data
,
710 display_act
->gpd
.scaled_piv
,
712 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
715 display_act
->gpd
.saved_piv
= TRUE
;
716 gpiv_piv_fprint_parameters
717 (fp_par
, display_act
->gpd
.piv_eval_par
);
718 if (display_act
->gpd
.exist_valid
) {
719 gpiv_valid_fprint_parameters
720 (fp_par
, display_act
->gpd
.piv_valid_par
);
726 * (Eventual) scalar data
728 if (display_act
->gpd
.exist_vor
) {
729 gpiv_io_make_fname(display_act
->fname_base
, EXT_VOR
,
732 gpiv_fwrite_scdata(fname_out
,
733 &display_act
->gpd
.vor_data
,
736 display_act
->gpd
.scaled_piv
,
738 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
739 display_act
->gpd
.saved_vor
= TRUE
;
742 gpiv_post_print_parameters(display_act
->gpd
.piv_post_par
);
743 gpiv_post_fprint_parameters(fp_par
,
744 display_act
->gpd
.piv_post_par
);
749 if (display_act
->gpd
.exist_sstrain
) {
750 gpiv_io_make_fname(display_act
->fname_base
, EXT_SSTR
,
753 gpiv_fwrite_scdata(fname_out
,
754 &display_act
->gpd
.sstrain_data
,
756 nc_lines
, display_act
->gpd
.scaled_piv
,
758 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
759 display_act
->gpd
.saved_sstrain
= TRUE
;
762 gpiv_post_fprint_parameters(fp_par
,
763 display_act
->gpd
.piv_post_par
);
768 if (display_act
->gpd
.exist_nstrain
) {
769 gpiv_io_make_fname(display_act
->fname_base
, EXT_NSTR
,
772 gpiv_fwrite_scdata(fname_out
,
773 &display_act
->gpd
.nstrain_data
,
776 display_act
->gpd
.scaled_piv
,
778 != NULL
) gtk_error ("%s: %s", RCSID
, err_msg
);
779 display_act
->gpd
.saved_nstrain
= TRUE
;
782 gpiv_post_fprint_parameters(fp_par
,
783 display_act
->gpd
.piv_post_par
);
795 on_execute_activate(GtkMenuItem
* menuitem
,
798 GpivConsole
* gpiv
= gtk_object_get_data(GTK_OBJECT(menuitem
), "gpiv");
803 for (row
= gpiv
->first_selected_row
; row
<= gpiv
->last_selected_row
;
805 display_act
= gtk_clist_get_row_data(GTK_CLIST(gpiv
->clist_buf
),
807 ibuf
= display_act
->count
;
808 if (display
[ibuf
] != NULL
809 && GTK_WIDGET_VISIBLE(GTK_WIDGET(display_act
->mwin
)) ) {
810 gdk_window_show(GTK_WIDGET(display_act
->mwin
)->window
);
811 gdk_window_raise(GTK_WIDGET(display_act
->mwin
)->window
);
814 if (!cancel_process
&& gpiv_par
.process_piv
) {
818 if (!cancel_process
&& gpiv_par
.process_gradient
) {
822 if (!cancel_process
&& gpiv_par
.process_resstats
) {
823 piv_valid_par
.res_stats
= 1;
824 exec_errvec(gpiv
->pivvalid
);
827 if (!cancel_process
&& gpiv_par
.process_errvec
) {
828 piv_valid_par
.res_stats
= 0;
829 exec_errvec(gpiv
->pivvalid
);
832 if (!cancel_process
&& gpiv_par
.process_peaklock
) {
833 exec_peaklock(gpiv
->pivvalid
);
836 if (!cancel_process
&& gpiv_par
.process_scale
) {
837 exec_scale(gpiv
->pivpost
);
840 if (!cancel_process
&& gpiv_par
.process_average
) {
841 exec_savg(gpiv
->pivpost
);
844 if (!cancel_process
&& gpiv_par
.process_substract
) {
845 exec_subavg(gpiv
->pivpost
);
848 if (!cancel_process
&& gpiv_par
.process_vorstra
) {
854 exec_process
= FALSE
;
860 on_stop_activate(GtkMenuItem
* menuitem
,
863 /* gtk_warning(_("process has been stopped")); */
868 on_button_stop_press (GtkWidget
* widget
,
871 cancel_process
= TRUE
;
876 on_button_stop_release (GtkWidget
* widget
,
879 cancel_process
= FALSE
;
884 on_close_activate(GtkMenuItem
* menuitem
,
887 GpivConsole
* gpiv
= gtk_object_get_data(GTK_OBJECT(menuitem
), "gpiv");
889 char message
[2 * MAX_CHARS
];
894 for (row
= gpiv
->first_selected_row
; row
<= gpiv
->last_selected_row
;
896 display_act
= gtk_clist_get_row_data
897 (GTK_CLIST(gpiv
->clist_buf
), row
);
898 ibuf
= display_act
->count
;
899 if (display
[ibuf
] != NULL
) {
901 if(!display_act
->gpd
.saved_piv
902 || !display_act
->gpd
.saved_vor
903 || !display_act
->gpd
.saved_nstrain
904 || !display_act
->gpd
.saved_sstrain
) {
906 g_snprintf(message
, 2 * MAX_CHARS
,
907 _("There are unsaved data that will be lost.\n\
908 Are you sure you want to close buffer #%d ?"),
910 answer
= close_buffer_yes_no (gpiv
, message
);
913 printf ("User selected yes\n");
914 free_all_bufmems(display_act
);
915 ibuf
= display_act
->count
;
916 gtk_widget_destroy(GTK_WIDGET(display_act
->mwin
));
917 display
[ibuf
] = NULL
;
920 printf ("User selected no\n");
923 printf ("User closed the window with the window manager\n");
929 free_all_bufmems(display_act
);
930 ibuf
= display_act
->count
;
931 gtk_widget_destroy(GTK_WIDGET(display_act
->mwin
));
932 display
[ibuf
] = NULL
;
941 for (row
= gpiv
->first_selected_row
; row
<= gpiv
->last_selected_row
;
943 display_act
= gtk_clist_get_row_data
944 (GTK_CLIST(gpiv
->clist_buf
), gpiv
->first_selected_row
);
945 ibuf
= display_act
->count
;
946 if (display
[ibuf
] == NULL
) {
947 gtk_clist_remove(GTK_CLIST(gpiv
->clist_buf
),
948 gpiv
->first_selected_row
);
951 gpiv
->first_selected_row
++;
959 * Point display_act to an existing buffer
961 for (ibuf
= 0; ibuf
< nbufs
; ibuf
++) {
962 if(display
[ibuf
] != NULL
) {
963 gtk_clist_select_row(GTK_CLIST(gpiv
->clist_buf
),
966 display_act
= display
[ibuf
];
973 on_exit_activate(GtkMenuItem
* menuitem
,
976 /* GtkWidget *gpiv_exit; */
980 for (ibuf
= 0; ibuf
< nbufs
; ibuf
++) {
981 if (display
[ibuf
] != NULL
) display_act
= display
[ibuf
];
983 if(!display_act
->gpd
.saved_piv
984 || !display_act
->gpd
.saved_vor
985 || !display_act
->gpd
.saved_nstrain
986 || !display_act
->gpd
.saved_sstrain
) {
987 gpiv_exit
= create_exit ();
988 gtk_widget_show (gpiv_exit
);
990 free_all_bufmems(display_act
);
1002 void on_preferences_activate(GtkWidget
* widget
,
1003 /* GtkMenuItem * menuitem, */
1006 /* GtkWidget *gpiv_preferences; */
1008 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
1009 gpiv_preferences
= create_preferences(gpiv
);
1010 gtk_widget_show(gpiv_preferences
);
1015 void on_about_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
1018 about
= create_about();
1019 gtk_widget_show(about
);
1026 void on_manual_activate(GtkMenuItem
* menuitem
, gpointer user_data
)
1028 static GnomeHelpMenuEntry help_entry
= { "gpiv", "index.html" };
1029 /* /home/gerber/gpiv/doc/C/index.html */
1030 gnome_help_display(NULL
, &help_entry
);
1035 * Gnome toolbar buttons
1039 on_button_open_clicked(GtkButton
* button
,
1042 gchar
*msg
= "Opens PIV data";
1044 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(button
), "gpiv");
1048 * Create a new file selection widget
1049 * Connect the ok_button and cancel_button to file_ok_sel function
1050 * Set a default filename
1051 * set user data "gpiv" to filew
1053 filew
= gtk_file_selection_new(_("File selection"));
1054 gtk_signal_connect(GTK_OBJECT(filew
), "destroy",
1055 (GtkSignalFunc
) destroy
, &filew
);
1056 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew
)->ok_button
),
1057 "clicked", (GtkSignalFunc
) file_ok_sel
,
1059 gtk_signal_connect_object(GTK_OBJECT
1060 (GTK_FILE_SELECTION(filew
)->ok_button
),
1062 (GtkSignalFunc
) gtk_widget_destroy
,
1064 gtk_signal_connect_object(GTK_OBJECT
1065 (GTK_FILE_SELECTION(filew
)->cancel_button
),
1067 (GtkSignalFunc
) gtk_widget_destroy
,
1069 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew
),
1070 /* DEFAULT_TEST_IMAGE */ fname_last
);
1071 gtk_widget_show(filew
);
1072 gtk_object_set_data(GTK_OBJECT(GTK_FILE_SELECTION(filew
)),
1077 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
1081 void on_menubar_activate(GtkWidget
* widget
, gpointer data
)
1083 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
1084 if (GTK_CHECK_MENU_ITEM(widget
)->active
) {
1085 gtk_widget_show(gpiv
->menubar
);
1087 gtk_widget_hide(gpiv
->menubar
);
1092 void on_toolbuttons_activate(GtkWidget
* widget
, gpointer data
)
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), */
1111 void on_gpivbuttons_activate(GtkWidget
* widget
, gpointer data
)
1113 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
1114 if (GTK_CHECK_MENU_ITEM(widget
)->active
) {
1115 gtk_widget_show(gpiv
->handlebox1
);
1118 gtk_widget_hide(gpiv
->handlebox1
);
1123 void on_tabulator_activate(GtkWidget
* widget
, gpointer data
)
1125 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
1126 if (GTK_CHECK_MENU_ITEM(widget
)->active
) {
1127 gtk_widget_show(gpiv
->notebook
);
1129 gtk_widget_hide(gpiv
->notebook
);
1135 void on_tooltip_activate(GtkWidget
* widget
, gpointer data
)
1137 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
1138 if (GTK_CHECK_MENU_ITEM(widget
)->active
) {
1139 gtk_tooltips_enable(gpiv
->tooltips
);
1140 gtk_tooltips_enable(gpiv
->imgh
->tooltips
);
1141 gtk_tooltips_enable(gpiv
->piveval
->tooltips
);
1142 gtk_tooltips_enable(gpiv
->pivvalid
->tooltips
);
1143 gtk_tooltips_enable(gpiv
->pivpost
->tooltips
);
1145 gtk_tooltips_disable(gpiv
->tooltips
);
1146 gtk_tooltips_disable(gpiv
->imgh
->tooltips
);
1147 gtk_tooltips_disable(gpiv
->piveval
->tooltips
);
1148 gtk_tooltips_disable(gpiv
->pivvalid
->tooltips
);
1149 gtk_tooltips_disable(gpiv
->pivpost
->tooltips
);
1157 on_buffer_set_focus(GtkWindow
* window
,
1158 GtkWidget
* widget
, gpointer user_data
)
1160 /* SEE: on_clist_buf_rowselect */
1165 gtk_window_destroy(GtkButton
* button
,
1173 on_appbar_display_user_response(GnomeAppBar
* gnomeappbar
,
1181 on_button_open_enter(GtkContainer
* container
,
1182 GtkDirectionType direction
,
1185 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(container
), "gpiv");
1186 gchar
*msg
= _("Opens image/PIV data (and display)");
1187 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
1192 on_button_save_enter(GtkContainer
* container
,
1193 GtkDirectionType direction
,
1196 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(container
), "gpiv");
1197 gchar
*msg
= _("Saves data");
1198 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
1203 on_button_execute_enter(GtkContainer
* container
,
1204 GtkDirectionType direction
,
1207 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(container
), "gpiv");
1208 gchar
*msg
= _("Executes all tickmarked processes");
1209 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
1214 on_button_stop_enter(GtkContainer
* container
,
1215 GtkDirectionType direction
,
1218 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(container
), "gpiv");
1219 gchar
*msg
= _("Cancels any running processes");
1220 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
1225 on_button_close_enter(GtkContainer
* container
,
1226 GtkDirectionType direction
,
1229 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(container
), "gpiv");
1230 gchar
*msg
= _("Close active buffer(s)");
1231 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
1236 on_button_exit_enter(GtkContainer
* container
,
1237 GtkDirectionType direction
, gpointer user_data
)
1239 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(container
), "gpiv");
1240 gchar
*msg
= _("Exits GPIV");
1241 gnome_appbar_set_status(GNOME_APPBAR(gpiv
->appbar
), msg
);
1245 /*--------------------------------------------------------------------
1246 toolbar containing checkbutton for processes */
1247 void on_toolbar_checkbutton_piv(GtkWidget
* widget
, gpointer data
)
1249 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1250 gpiv_par
.process_piv
= TRUE
;
1252 gpiv_par
.process_piv
= FALSE
;
1257 void on_toolbar_checkbutton_gradient(GtkWidget
* widget
, gpointer data
)
1259 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1260 gpiv_par
.process_gradient
= TRUE
;
1262 gpiv_par
.process_gradient
= FALSE
;
1267 void on_toolbar_checkbutton_resstats(GtkWidget
* widget
, gpointer data
)
1269 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1270 gpiv_par
.process_resstats
= TRUE
;
1271 piv_valid_par
.res_stats
= 1;
1273 gpiv_par
.process_resstats
= FALSE
;
1274 piv_valid_par
.res_stats
= 0;
1280 on_toolbar_checkbutton_errvec(GtkWidget
* widget
,
1283 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1284 gpiv_par
.process_errvec
= TRUE
;
1286 gpiv_par
.process_errvec
= FALSE
;
1288 /* g_warning("on_toolbar_checkbutton_errvec:: process_errvec=%d", */
1293 on_toolbar_checkbutton_peaklck(GtkWidget
* widget
,
1296 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1297 gpiv_par
.process_peaklock
= TRUE
;
1299 gpiv_par
.process_peaklock
= FALSE
;
1305 on_toolbar_checkbutton_scale(GtkWidget
* widget
,
1308 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1309 gpiv_par
.process_scale
= TRUE
;
1311 gpiv_par
.process_scale
= FALSE
;
1317 on_toolbar_checkbutton_average(GtkWidget
* widget
,
1320 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1321 gpiv_par
.process_average
= TRUE
;
1323 gpiv_par
.process_average
= FALSE
;
1329 on_toolbar_checkbutton_subavg(GtkWidget
* widget
,
1332 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1333 gpiv_par
.process_substract
= TRUE
;
1335 gpiv_par
.process_substract
= FALSE
;
1340 void on_toolbar_checkbutton_vorstra(GtkWidget
* widget
, gpointer data
)
1342 if (GTK_TOGGLE_BUTTON(widget
)->active
) {
1343 gpiv_par
.process_vorstra
= TRUE
;
1345 gpiv_par
.process_vorstra
= FALSE
;
1352 /* GpivData * gpd_active = &display_act->gpd; */
1354 void on_button_quit_no_clicked(GtkButton
* button
, gpointer user_data
)
1356 /*--------------------------------------------------------------------
1357 exit, message dialog callbacks */
1358 g_warning("on_button_quit_no_clicked::");
1359 gnome_dialog_close(GNOME_DIALOG(gpiv_exit
));
1363 void on_button_quit_gpiv_yes_clicked(GtkButton
* button
, gpointer user_data
)
1365 g_warning("on_button_quit_gpiv_yes_clicked::");
1366 free_all_bufmems(display_act
);
1371 void on_button_message_clicked(GtkButton
* button
, gpointer user_data
)
1373 g_warning("on_button_message_clicked::");
1374 gnome_dialog_close(GNOME_DIALOG(gpiv_exit
));
1377 void on_button_error_clicked(GtkButton
* button
, gpointer user_data
)
1379 /* free_all_bufmems(); */
1385 * Other functions than callbacks
1389 * loading images and (piv) data
1393 file_ok_sel(GtkWidget
* widget
,
1394 GtkFileSelection
* fs
)
1395 /* -------------------------------------------------------------------
1396 PIV data file selection */
1399 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(fs
), "gpiv");
1402 gtk_clist_set_selection_mode(GTK_CLIST (gpiv
->clist_buf
),
1403 GTK_SELECTION_SINGLE
);
1406 g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs
)));
1409 if (print_par
) g_warning("file_ok_sel:: fname_in = %s", fname_in
);
1412 select_action_from_fname(gpiv
, fname_in
);
1419 select_action_from_fname(GpivConsole
*gpiv
,
1421 /* -------------------------------------------------------------------
1422 checks filename extension on valid image/data name, on existence of buffer,
1425 gint i
, j
, ibuf
, return_val
;
1430 gboolean exist_buf
= FALSE
;
1432 gchar
*clist_buf_txt
[MAX_BUFS
][2], cl_int
[2];
1435 ext
= g_strdup(strrchr(fname_in
, '.'));
1436 fname_last
= g_strdup(fname_in
);
1437 gnome_config_set_string("fname_last", fname_last
);
1438 gnome_config_sync();
1441 * Stripping file name
1444 /*----------------------------------------------------------------------
1446 * gchar* g_path_get_basename (const gchar *file_name);
1447 * gchar* g_path_get_dirname (const gchar *file_name);
1449 *----------------------------------------------------------------------*/
1450 dirname
= g_strdup(g_dirname(fname_in
));
1451 fname_base
= g_strdup(g_basename(fname_in
));
1452 strtok(fname_base
, ".");
1453 fname_ext
= g_strdup(g_strconcat(dirname
, G_DIR_SEPARATOR_S
,
1457 * reading image data from raw data format or hdf format
1459 if (strcmp(ext
, EXT_RAW_IMAGE
) == 0 || strcmp(ext
, EXT_GPIV
) == 0) {
1460 if (strcmp(ext
, EXT_GPIV
) == 0) {
1467 sensitive(gpiv
, IMG
, TRUE
);
1468 sensitive(gpiv
, EVAL
, TRUE
);
1472 * Check if file basename (and buffer/display) already exists
1473 * or if there is a gap in the numbering of th buffers
1475 for (ibuf
= 0; ibuf
< nbufs
; ibuf
++) {
1476 if (display
[ibuf
] != NULL
1477 && strcmp(fname_ext
, display
[ibuf
]->fname_base
) == 0 ) {
1479 open_img(fname_in
, &display_act
->img
, read_hdf
))
1481 /* gtk_warning(_("open_img failed")); */
1489 /* display_img(display_act); */
1492 } else if (display
[ibuf
] == NULL
) {
1493 load_buffer(gpiv
, fname_in
, fname_base
, fname_ext
,
1494 read_hdf
, ibuf
, INSERT
);
1503 * Create new buffer and launches a display if file basename doesn't exist
1504 * and append to the list
1509 load_buffer(gpiv
, fname_in
, fname_base
, fname_ext
, read_hdf
,
1518 } else if (strcmp(ext
, ".piv") == 0) {
1521 sensitive(gpiv
, EVAL
, TRUE
);
1523 /* -------------------------------------------------------------------
1524 Look if file base name (and buffer/display) already exists */
1525 for (ibuf
= 0; ibuf
< nbufs
; ibuf
++) {
1526 if (strcmp(fname_ext
, display_act
->fname_base
) == 0) {
1527 fprintf(stderr
, "piv load::using existing buffer: %d",
1529 open_piv(fname_in
, &display_act
->gpd
);
1530 display_all_vectors(&display_act
->gpd
);
1536 /* -------------------------------------------------------------------
1537 Create new buffer and launch a display if file base name doesn't exist */
1539 /* gint width, height; */
1542 display_act
->gpd
.exist_piv
= TRUE
;
1543 g_snprintf(display_act
->fname_base
, MAX_CHARS
, "%s", fname_ext
);
1544 open_piv(fname_in
, &display_act
->gpd
);
1546 /* display_act->gpd.zoom_factor = zfactor[gpiv_par.zoom_index]; */
1547 /* display_act->gpd.stretch_window = gpiv_par.stretch_window; */
1548 display
[ibuf
] = create_display(display_act
->fname_base
, ibuf
, gpiv
);
1549 display_act
= display
[ibuf
];
1550 gtk_widget_show(display_act
->mwin
);
1551 gtk_signal_connect_object(GTK_OBJECT(display_act
),
1552 "button_press_event",
1553 GTK_SIGNAL_FUNC (on_my_popup_handler
),
1554 GTK_OBJECT(display_act
->display_menu
));
1558 g_snprintf(display_act
->msg_display_default
, MAX_CHARS
, "%s",
1559 display_act
->fname_base
);
1560 gnome_appbar_set_default(GNOME_APPBAR(display_act
->appbar
),
1561 display_act
->msg_display_default
);
1563 g_snprintf(cl_int
, 2, "%d", ibuf
);
1564 gtk_object_set_data(GTK_OBJECT(display_act
), "buffer_nr",
1566 gtk_signal_connect(GTK_OBJECT(display_act
),
1568 GTK_SIGNAL_FUNC(on_display_set_focus
), NULL
);
1570 display_background(display_act
);
1571 for (i
= 0; i
< MAX_DATA
; i
++) {
1572 for (j
= 0; j
< MAX_DATA
; j
++) {
1573 display_act
->gpd
.gci_vector
[i
][j
] = NULL
;
1576 display_all_vectors(&display_act
->gpd
);
1578 clist_buf_txt
[ibuf
][0] = cl_int
;
1579 clist_buf_txt
[ibuf
][1] = fname_base
;
1580 gtk_clist_append(GTK_CLIST(gpiv
->clist_buf
),
1581 clist_buf_txt
[ibuf
]);
1582 fprintf(stderr
, "finished gtk_clist\n");
1583 if (gpiv_par
.display_intregs
== 1)
1584 create_all_intregs(display_act
);
1588 gtk_warning(_("load_buffer: non-valid file name"));
1591 gtk_clist_set_selection_mode(GTK_CLIST (gpiv
->clist_buf
),
1592 GTK_SELECTION_EXTENDED
);
1598 if (print_par
) gpiv_warning("load_buffer: fname_base = %s", display_act
->fname_base
);
1604 load_buffer(GpivConsole
*gpiv
,
1610 enum ClistPut clist_put
)
1611 /*--------------------------------------------------------------------
1612 * create display and its (popup) menu, load image and puts into clist
1615 gint return_val
= 0;
1616 gchar
*clist_buf_txt
[MAX_BUFS
][2], cl_int
[2];
1618 display
[ibuf
] = create_display(fname_ext
, ibuf
, gpiv
);
1619 display_act
= display
[ibuf
];
1620 gtk_widget_show(display_act
->mwin
);
1621 display_act
->display_menu
= create_display_menu(display_act
);
1622 gtk_widget_show(display_act
->display_menu
);
1623 gtk_signal_connect_object(GTK_OBJECT(display_act
->mwin
),
1624 "button_press_event",
1625 GTK_SIGNAL_FUNC (on_my_popup_handler
),
1626 GTK_OBJECT(display_act
->display_menu
));
1627 zoom_display(display_act
, display_act
->zoom_index
);
1633 g_snprintf(display_act
->fname_base
, MAX_CHARS
, "%s", fname_ext
);
1634 if((return_val
= open_img(fname_in
, &display_act
->img
, read_hdf
))
1636 /* gtk_warning(_("open_img failed")); */
1637 gtk_object_destroy(GTK_OBJECT(display
[ibuf
]->mwin
));
1640 display_act
= display
[ibuf
];
1648 display_background(display_act
);
1651 /* --------- TO BE IMPLEMENTED FOR IMAGES WITH RGB CANVAS --------------*/
1652 /* #ifdef DISPLAY_IMAGE */
1653 /* display_img(display_act); */
1655 /* ---------------------------------------------------------------------*/
1657 if (gpiv_par
.display_intregs
== 1)
1658 create_all_intregs(display_act
);
1660 /* --------- TO BE REMOVED WITH RGB CANVAS ----------------------------*/
1661 /* ---------------------------------------------------------------------*/
1664 * Add buffer to list
1666 g_snprintf(cl_int
, 2, "%d", ibuf
);
1667 clist_buf_txt
[ibuf
][0] = (gchar
*) cl_int
;
1668 clist_buf_txt
[ibuf
][1] = fname_base
;
1669 if (clist_put
== PREPEND
) {
1670 gtk_clist_prepend(GTK_CLIST(gpiv
->clist_buf
),
1671 clist_buf_txt
[ibuf
]);
1672 } else if (clist_put
== INSERT
) {
1673 gtk_clist_insert(GTK_CLIST(gpiv
->clist_buf
), ibuf
,
1674 clist_buf_txt
[ibuf
]);
1675 } else if (clist_put
== APPEND
) {
1676 gtk_clist_append(GTK_CLIST(gpiv
->clist_buf
),
1677 clist_buf_txt
[ibuf
]);
1679 gtk_error("non-existent CLIST enumerate");
1682 gtk_clist_set_row_data(GTK_CLIST(gpiv
->clist_buf
), ibuf
,
1690 open_img(char *fname_in
,
1694 /*--------------------------------------------------------------------
1698 char *err_msg
= NULL
;
1699 char fname_header
[MAX_CHARS
];
1700 char *fname_ext
= display_act
->fname_base
;
1703 * parameter initializing of image
1705 img
->image_par
.nbits_logic
= 0;
1706 img
->image_par
.ncolumns_logic
= 0;
1707 img
->image_par
.nrows_logic
= 0;
1708 img
->image_par
.x_corr_logic
= 0;
1709 img
->image_par
.s_scale_logic
= 0;
1710 img
->image_par
.t_scale_logic
= 0;
1711 img
->image_par
.z_off_logic
= 0;
1712 img
->image_par
.project_logic
= 0;
1713 img
->image_par
.creation_date_logic
= 0;
1714 img
->image_par
.location_logic
= 0;
1715 img
->image_par
.comment_logic
= 0;
1723 gpiv_img_fread_hdf5_parameters(fname_in
, &img
->image_par
);
1725 gtk_warning("%s: %s", RCSID
, err_msg
);
1728 if (img
->image_par
.nrows
!= gpiv_par
.img_height
1729 || img
->image_par
.ncolumns
!= gpiv_par
.img_width
) {
1730 gtk_warning(_("Image dimensions (%dx%d) differ from \n\
1731 parameter settings (%dx%d"),
1732 img
->image_par
.ncolumns
, img
->image_par
.nrows
,
1733 gpiv_par
.img_width
, gpiv_par
.img_height
);
1736 copy_img_par(image_par
, &img
->image_par
, FALSE
, print_par
);
1738 gpiv_img_check_header_read(img
->image_par
))
1740 gtk_warning("%s: %s", RCSID
, err_msg
);
1744 img
->img1
= gpiv_ucmatrix(0, img
->image_par
.nrows
- 1, 0,
1745 img
->image_par
.ncolumns
- 1);
1746 if (img
->image_par
.x_corr
!= image_par
.x_corr
) {
1747 gtk_warning(_("cross correlation parameter from image \n\
1748 not in agreement with GPIV setting"));
1751 if (img
->image_par
.x_corr
)
1752 img
->img2
= gpiv_ucmatrix(0, img
->image_par
.nrows
- 1, 0,
1753 img
->image_par
.ncolumns
- 1);
1755 gpiv_fread_hdf5_image (fname_in
, img
->img1
,
1756 img
->img2
, &img
->image_par
))
1758 gtk_warning ("%s: %s", RCSID
, err_msg
);
1765 * Reads raw data format
1766 * Reads image header data from file.h or copies from originanals
1768 g_snprintf(fname_header
, MAX_CHARS
, "%s%s", fname_ext
, EXT_HEADER
);
1769 if (print_par
) gpiv_warning("\n#image header is: %s", fname_header
);
1770 gpiv_scan_parameter( "", fname_header
, &img
->image_par
, print_par
);
1772 g_warning("open_img:: x_corr_logic = %d \n"
1773 "image_par.nrows = %d \n"
1774 "image_par.ncolumns = %d",
1775 img
->image_par
.x_corr_logic
,
1776 img
->image_par
.nrows
,
1777 img
->image_par
.ncolumns
);
1778 if (img
->image_par
.nrows
!= gpiv_par
.img_height
1779 || img
->image_par
.ncolumns
!= gpiv_par
.img_width
) {
1780 gtk_warning(_("Image dimensions (%dx%d) differ from \n\
1781 parameter settings (%dx%d)"),
1782 img
->image_par
.ncolumns
, img
->image_par
.nrows
,
1783 gpiv_par
.img_width
, gpiv_par
.img_height
);
1786 copy_img_par (image_par
, &img
->image_par
, FALSE
, print_par
);
1788 gpiv_img_check_header_read(img
->image_par
))
1790 gtk_warning ("%s: %s", RCSID
, err_msg
);
1794 * memory allocation of matrices and vectors
1795 * gpiv_alloc_imgdata(img->img1, image_par.nrows, image_par.ncolumns);
1797 img
->img1
= gpiv_ucmatrix(0, img
->image_par
.nrows
- 1, 0,
1798 img
->image_par
.ncolumns
- 1);
1799 if (img
->image_par
.x_corr
!= image_par
.x_corr
) {
1800 gtk_warning(_("cross correlation parameter from image \n\
1801 not in agreement with GPIV setting"));
1804 if (image_par
.x_corr
)
1805 img
->img2
= gpiv_ucmatrix(0, img
->image_par
.nrows
- 1, 0,
1806 img
->image_par
.ncolumns
- 1);
1810 * reads image data from file in binary format
1813 gpiv_fread_image(fname_in
, img
->img1
, img
->img2
, img
->image_par
);
1815 gtk_warning ("%s: %s", RCSID
, err_msg
);
1818 /* if (!img->img1 || !img->img2) { */
1819 /* gtk_warning(_("failure reading image")); */
1824 display_act
->img
.exist_img
= TRUE
;
1830 open_piv(char *fname
,
1833 /*------------------------ Opens piv data file and views in display */
1835 char *function_name
= "open_piv";
1838 /* var_scale = 0; */
1842 gpiv_fcount_pivdata(fname
, &gpd
->piv_data
)) == -1) {
1843 gpiv_error(_("%s: Failure calling gpiv_count_pivdata\n"), PROGNAME
);
1845 } else if (print_par
) {
1846 fprintf(stderr
, "%s: %s: scale=%d nx=%d ny=%d \n",
1847 function_name
, fname
, display_act
->gpd
.scaled_piv
, gpd
->piv_data
.nx
,
1852 gpiv_alloc_pivdata(&gpd
->piv_data
);
1853 gpd
->exist_piv
= TRUE
;
1856 gpiv_fread_pivdata(fname
, &gpd
->piv_data
, c_line
, &nc_lines
))
1858 gtk_warning ("%s: %s", RCSID
, err_msg
);
1863 gpiv_write_pivdata(&gpd
->piv_data
, c_line
, nc_lines
,
1864 display_act
->gpd
.scaled_piv
, RCSID
);