bugrepair: drag and drop
[gpiv.git] / src / display.c
blob134dde1a3f4da443e5fb296da9872975513ad972
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 the display
31 * $Log: display.c,v $
32 * Revision 1.24 2007-12-19 08:42:35 gerber
33 * debugged
35 * Revision 1.23 2007-11-23 16:24:07 gerber
36 * release 0.5.0: Kafka
38 * Revision 1.22 2007-03-22 16:00:32 gerber
39 * Added image processing tabulator
41 * Revision 1.21 2007/02/05 15:17:09 gerber
42 * auto stretching, broadcast display settings to buffers from preferences
44 * Revision 1.20 2007-01-29 11:27:43 gerber
45 * added image formats png, gif, tif png, bmp, improved buffer display
47 * Revision 1.19 2006/01/31 14:28:12 gerber
48 * version 0.3.0
50 * Revision 1.18 2005/06/15 15:03:54 gerber
51 * Optional Anti Aliased canvas for viewer
53 * Revision 1.17 2005/06/15 09:40:40 gerber
54 * debugged, optimized
56 * Revision 1.16 2005/02/26 09:17:13 gerber
57 * structured of interrogate function by using gpiv_piv_isiadapt
59 * Revision 1.15 2005/01/19 15:53:41 gerber
60 * Initiation of Data Acquisition (DAC); trigerring of lasers and camera
61 * by using RTAI and Realtime Linux, recording images from IEEE1394
62 * (Firewire) IIDC compliant camera's
64 * Revision 1.14 2004/10/15 19:24:05 gerber
65 * GPIV_ and Gpiv prefix to defines and structure names of libgpiv
67 * Revision 1.13 2004/06/14 21:19:23 gerber
68 * Image depth up to 16 bits.
69 * Improvement "single int" and "drag int" in Eval tab.
70 * Viewer's pop-up menu.
71 * Adaption for gpiv_matrix_* and gpiv_vector_*.
72 * Resizing console.
73 * See Changelog for further info.
75 * Revision 1.12 2003/09/01 11:17:14 gerber
76 * improved monitoring of interrogation process
78 * Revision 1.11 2003/08/22 15:24:52 gerber
79 * interactive spatial scaling
81 * Revision 1.10 2003/07/31 11:43:26 gerber
82 * display images in gnome canvas (HOERAreset)
84 * Revision 1.9 2003/07/13 14:38:18 gerber
85 * changed error handling of libgpiv
87 * Revision 1.8 2003/07/12 21:21:15 gerber
88 * changed error handling libgpiv
90 * Revision 1.6 2003/07/10 11:56:07 gerber
91 * added man page
93 * Revision 1.5 2003/07/05 13:14:57 gerber
94 * drag and drop of a _series_ of filenames from NAUTILUS
96 * Revision 1.4 2003/07/04 10:47:00 gerber
97 * cleaning up
99 * Revision 1.3 2003/07/03 17:08:02 gerber
100 * display ruler adjusted for scaled data
102 * Revision 1.2 2003/06/27 13:47:26 gerber
103 * display ruler, line/point evaluation
105 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
106 * Imported gpiv
110 #include "gpiv_gui.h"
111 #include "utils.h"
112 #include "display_interface.h"
113 #include "display.h"
114 #include "display_event.h"
115 #include "display_zoom.h"
116 #include "piveval.h"
117 #include "dialog_interface.h"
118 #include "console.h"
121 static void
122 on_adj_changed__adapt_hcanvas (Display *disp
124 static void
125 on_adj_changed__adapt_vcanvas (Display *disp
127 static void
128 on_adj_changed__adapt_hruler (Display *disp
130 static void
131 on_adj_changed__adapt_vruler (Display *disp
134 static void
135 synchronize_menu (GtkWidget *menu_src,
136 gboolean active,
137 GtkWidget *menu_dest
141 * Callback display functions
143 gint
144 on_button_display_origin_press_event (GtkWidget *widget,
145 GdkEventButton *event,
146 gpointer data
148 /*-----------------------------------------------------------------------------
151 gtk_menu_popup (GTK_MENU (display_act->display_popupmenu), NULL, NULL,
152 NULL, NULL, event->button, event->time);
153 return FALSE;
157 void
158 on_display_set_focus (GtkWidget *widget,
159 gpointer data
161 /*-----------------------------------------------------------------------------
164 Display *disp = gtk_object_get_data(GTK_OBJECT (widget), "disp");
165 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
166 gint i = 0, row_selected = 0;
167 gchar *text, labelno[GPIV_MAX_CHARS];
168 gtk_clist_set_selection_mode (GTK_CLIST (gpiv->clist_buf),
169 GTK_SELECTION_SINGLE);
171 g_snprintf (labelno, GPIV_MAX_CHARS,"%d", disp->id);
174 for (i = 0; i < nbufs; i++) {
175 gtk_clist_get_text (GTK_CLIST (gpiv->clist_buf), i, 0, &text);
177 if (strcmp(labelno, text) == 0) {
178 row_selected = i;
183 gtk_clist_select_row (GTK_CLIST (gpiv->clist_buf), row_selected, 0);
185 /* g_warning("on_display_set_focus:: disp->id=%d row_selected=%d", */
186 /* disp->id, row_selected); */
188 gtk_clist_set_selection_mode (GTK_CLIST (gpiv->clist_buf),
189 GTK_SELECTION_EXTENDED);
194 void
195 delete_display (GtkWidget *widget,
196 GdkEvent *event,
197 gpointer data
199 /*-----------------------------------------------------------------------------
202 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
203 Display *disp = gtk_object_get_data (GTK_OBJECT (widget), "disp");
206 close_buffer__check_saved (gpiv, disp);
211 void
212 on_adj_changed (GtkAdjustment *adj,
213 gpointer data
215 /*-----------------------------------------------------------------------------
218 Display *disp = gtk_object_get_data (GTK_OBJECT (adj), "disp");
220 enum variable_type {
221 X_ADJ = 0,
222 Y_ADJ = 1
223 } var_type;
225 var_type = atoi (gtk_object_get_data (GTK_OBJECT (adj), "var_type"));
226 /* g_message ("ON_ADJ_CHANGED:: " */
227 /* "value = %f lower = %f upper = %f page_size = %f", */
228 /* adj->value, adj->lower, adj->upper, adj->page_size); */
230 if (var_type == X_ADJ) {
231 disp->x_adj_value = (gdouble) adj->value;
232 disp->x_adj_upper = (gdouble) adj->upper;
233 disp->x_adj_lower = (gdouble) adj->lower;
234 disp->x_page_size = (gdouble) adj->page_size;
236 on_adj_changed__adapt_hcanvas (disp);
237 on_adj_changed__adapt_hruler (disp);
240 if (var_type == Y_ADJ) {
241 disp->y_adj_value = (gdouble) adj->value;
242 disp->y_adj_upper = (gdouble) adj->upper;
243 disp->y_adj_lower = (gdouble) adj->lower;
244 disp->y_page_size = (gdouble) adj->page_size;
246 on_adj_changed__adapt_vcanvas (disp);
247 on_adj_changed__adapt_vruler (disp);
249 /* g_message ("N_SCROLLEDWINDOW_DISPLAY_ADJ_CHANGED:: x_adj_value = %f" */
250 /* " x_adj_lower = %f x_adj_upper = %f x_page_size = %f", */
251 /* disp->x_adj_value, disp->x_adj_lower, disp->x_adj_upper, */
252 /* disp->x_page_size); */
257 * Callbacks for menus
259 void
260 on_menu_synchronize_popup (GtkMenuItem *menuitem,
261 gpointer user_data)
262 /*-----------------------------------------------------------------------------
263 * Synchronizing with popup menu item, which will actually change the
264 * displaying of the menubar.
267 Display *disp = display_act;
268 gint menu_id = (int) user_data;
269 GtkWidget *popupmenu;
272 if (menu_id == VIEW_MENUBAR) {
273 popupmenu = gtk_object_get_data(GTK_OBJECT(disp->mwin),
274 "view_menubar_popup_menu");
275 if (GTK_CHECK_MENU_ITEM(menuitem)->active == TRUE) {
276 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
277 } else {
278 synchronize_menu (GTK_WIDGET (menuitem), FALSE, popupmenu);
282 } else if (menu_id == VIEW_RULERS) {
283 popupmenu = gtk_object_get_data( GTK_OBJECT (disp->mwin),
284 "view_rulers_popup_menu");
285 if (GTK_CHECK_MENU_ITEM (menuitem)->active == TRUE) {
286 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
287 } else {
288 synchronize_menu (GTK_WIDGET (menuitem), FALSE, popupmenu);
292 } else if (menu_id == STRETCH_AUTO) {
293 popupmenu = gtk_object_get_data( GTK_OBJECT (disp->mwin),
294 "stretch_auto_popup_menu");
295 if (GTK_CHECK_MENU_ITEM (menuitem)->active == TRUE) {
296 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
297 } else {
298 synchronize_menu (GTK_WIDGET (menuitem), FALSE, popupmenu);
302 } else if (menu_id == VIEW_BLUE) {
303 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
304 "view_background_display0");
305 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
308 } else if (menu_id == VIEW_BLACK) {
309 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
310 "view_background_display1");
311 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
314 } else if (menu_id == VIEW_IMAGE_A) {
315 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
316 "view_background_display2");
317 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
320 } else if (menu_id == VIEW_IMAGE_B) {
321 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
322 "view_background_display3");
323 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
326 } else if (menu_id == VIEW_INTERROGATION_AREAS) {
327 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
328 "view_piv_display0");
329 if (GTK_CHECK_MENU_ITEM(menuitem)->active == TRUE) {
330 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
331 } else {
332 synchronize_menu (GTK_WIDGET (menuitem), FALSE, popupmenu);
336 } else if (menu_id == VIEW_VELOCITY_VECTORS) {
337 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
338 "view_piv_display1");
339 if (GTK_CHECK_MENU_ITEM (menuitem)->active == TRUE) {
340 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
341 } else {
342 synchronize_menu (GTK_WIDGET (menuitem), FALSE, popupmenu);
346 } else if (menu_id == VIEW_NONE_SCALARS) {
347 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
348 "view_scalardata_display0");
349 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
352 } else if (menu_id == VIEW_VORTICITY) {
353 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
354 "view_scalardata_display1");
355 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
358 } else if (menu_id == VIEW_SHEAR_STRAIN) {
359 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
360 "view_scalardata_display2");
361 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
364 } else if (menu_id == VIEW_NORMAL_STRAIN) {
365 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
366 "view_scalardata_display3");
367 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
370 } else if (menu_id == VECTOR_COLOR_PEAK) {
371 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
372 "vectorcolor_menu_display0");
373 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
376 } else if (menu_id == VECTOR_COLOR_SNR) {
377 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
378 "vectorcolor_menu_display1");
379 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
382 } else if (menu_id == VECTOR_COLOR_MAGNGRAY) {
383 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
384 "vectorcolor_menu_display2");
385 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
388 } else if (menu_id == VECTOR_COLOR_MAGNCOLOR) {
389 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
390 "vectorcolor_menu_display3");
391 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
397 void
398 on_stretch_activate (GtkMenuItem *menuitem,
399 gpointer user_data)
400 /*-----------------------------------------------------------------------------
403 Display *disp = display_act;
404 GtkAdjustment *hadj = GTK_ADJUSTMENT (disp->hadj);
405 (disp->vadj) ;
406 GtkAdjustment *vadj = GTK_ADJUSTMENT (disp->vadj) ;
408 check__zoom_factor (&disp->zoom_factor);
409 stretch_window (disp);
411 vadj->lower = 0.0;
412 vadj->upper = (gdouble) disp->img->image->header->nrows * disp->zoom_factor;
413 vadj->page_size = (gdouble) (disp->img->image->header->nrows
414 * disp->zoom_factor);
415 hadj->lower = 0.0;
416 hadj->upper = (gdouble) disp->img->image->header->ncolumns * disp->zoom_factor;
417 hadj->page_size = (gdouble) (disp->img->image->header->ncolumns
418 * disp->zoom_factor);
422 void
423 on_zoom_activate (GtkMenuItem *menuitem,
424 gpointer user_data)
425 /*-----------------------------------------------------------------------------
428 Display *disp = display_act;
429 gint zoom_index = (int) user_data;
430 gchar *key = NULL;
431 GtkWidget *popupmenu;
434 key = g_strdup_printf ("zmv_%d", (int) zoom_index);
435 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin), key);
437 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
438 g_free (key);
442 void
443 on_vector_scale_activate (GtkMenuItem *menuitem,
444 gpointer user_data)
445 /*-----------------------------------------------------------------------------
448 Display *disp = display_act;
449 gchar *key = NULL;
450 GtkWidget *popupmenu;
451 guint16 fact = 1;
453 fact = fact << (int) user_data;
454 gpiv_par->display__vector_scale = fact;
456 key = g_strdup_printf ("vs_mv_%d", (int) user_data);
457 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin), key);
458 synchronize_menu (GTK_WIDGET (menuitem), TRUE, popupmenu);
459 g_free (key);
464 * Callbacks for popup menus
466 void
467 view_toggle_menubar (GtkWidget *widget,
468 gpointer data
470 /*-----------------------------------------------------------------------------
473 Display *disp = display_act;
474 GtkWidget *menu =
475 gtk_object_get_data (GTK_OBJECT(disp->mwin),
476 "view_menubar");
479 * Synchronizing menu item from menu bar.
481 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
482 synchronize_menu (widget, TRUE, menu);
483 } else {
484 synchronize_menu (widget, FALSE, menu);
488 * Changing the displaying of menubar
490 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
491 gtk_widget_show (GTK_WIDGET (disp->menubar));
492 } else {
493 gtk_widget_hide (GTK_WIDGET (disp->menubar));
499 void
500 view_toggle_rulers (GtkWidget *widget,
501 gpointer data
503 /*-----------------------------------------------------------------------------
506 Display *disp = display_act;
510 * Synchronizing menu item from menu bar.
512 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
513 synchronize_menu (widget, TRUE, disp->view_rulers);
514 } else {
515 synchronize_menu (widget, FALSE, disp->view_rulers);
519 * Changing the displaying of rulers
521 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
522 gtk_widget_show (GTK_WIDGET (disp->hruler));
523 gtk_widget_show (GTK_WIDGET (disp->vruler));
524 } else {
525 gtk_widget_hide (GTK_WIDGET (disp->hruler));
526 gtk_widget_hide (GTK_WIDGET (disp->vruler));
532 void
533 view_toggle_stretch_display_auto (GtkWidget *widget,
534 gpointer data
536 /*-----------------------------------------------------------------------------
539 Display *disp = display_act;
543 * Synchronizing menu item from menu bar.
545 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
546 synchronize_menu (widget, TRUE, disp->stretch_auto);
547 } else {
548 synchronize_menu (widget, FALSE, disp->stretch_auto);
552 * Changing the displaying of rulers
554 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
555 gpiv_par->display__stretch_auto = TRUE;
556 check__zoom_factor (&disp->zoom_factor);
557 stretch_window (disp);
558 } else {
559 gpiv_par->display__stretch_auto = FALSE;
565 void
566 view_toggle_stretch_display (GtkWidget *widget,
567 gpointer data
569 /*-----------------------------------------------------------------------------
572 Display *disp = display_act;
573 gint screen_width = gdk_screen_width ();
574 gint screen_height = gdk_screen_height ();
577 check__zoom_factor (&disp->zoom_factor);
578 stretch_window (disp);
582 void
583 select_zoomscale (gpointer data,
584 guint action,
585 GtkWidget *widget
587 /*-----------------------------------------------------------------------------
590 Display *disp = display_act;
591 gint zoom_index = action;
592 gchar *key1 = NULL, *key2 = NULL;
593 GtkWidget *popupmenu, *menu;
596 key1 = g_strdup_printf ("zmv_%d", (int) zoom_index);
597 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin), key1);
599 key2 = g_strdup_printf ("zoom_menu_%d", (int) zoom_index);
600 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin), key2);
602 synchronize_menu (popupmenu, TRUE, menu);
604 zoom_display (disp, zoom_index);
605 g_free (key1);
606 g_free (key2);
611 void
612 select_view_background (gpointer data,
613 guint action,
614 GtkWidget *widget)
615 /*-----------------------------------------------------------------------------
618 gchar *color = NULL;
619 Display *disp = display_act;
620 GtkWidget *menu = NULL, *popupmenu = NULL;
622 gpiv_par->display__backgrnd = action;
623 hide_img1 (disp);
624 hide_img2 (disp);
627 * Select menu and popup menu widgets
629 if (action == SHOW_BG_DARKBLUE) {
630 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
631 "blue_background_menu");
632 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
633 "view_background_display0");
635 } else if (action == SHOW_BG_BLACK) {
636 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
637 "black_background_menu");
638 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
639 "view_background_display1");
641 } else if (action == SHOW_BG_IMG1) {
642 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
643 "image_a_background_menu");
644 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
645 "view_background_display2");
647 } else if (action == SHOW_BG_IMG2) {
648 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
649 "image_b_background_menu");
650 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
651 "view_background_display3");
655 * Synchronize
657 synchronize_menu (popupmenu, TRUE, menu);
660 * Perform action
662 if (action == SHOW_BG_DARKBLUE) {
663 color = "darkblue";
664 if (disp->gci_bg != NULL) {
665 gnome_canvas_item_set (GNOME_CANVAS_ITEM (disp->gci_bg),
666 "fill_color", color,
667 NULL);
670 } else if (action == SHOW_BG_BLACK) {
671 color = "black";
672 if (disp->gci_bg != NULL) {
673 gnome_canvas_item_set (GNOME_CANVAS_ITEM (disp->gci_bg),
674 "fill_color", color,
675 NULL);
678 } else if (action == SHOW_BG_IMG1) {
679 show_img1 (display_act);
681 } else if (action == SHOW_BG_IMG2) {
682 show_img2 (display_act);
684 } else {
685 color = "black";
686 if (disp->gci_bg != NULL) {
687 gnome_canvas_item_set (GNOME_CANVAS_ITEM (disp->gci_bg),
688 "fill_color", color,
689 NULL);
690 } else {
691 g_warning (_("select_view_background: should not arrive here"));
699 void
700 view_toggle_intregs (GtkWidget *widget,
701 gpointer data
703 /*-----------------------------------------------------------------------------
706 Display *disp = display_act;
709 * Synchronizing menu item from menu bar.
711 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
712 synchronize_menu (widget, TRUE, disp->view_interrogation_areas);
713 } else {
714 synchronize_menu (widget, FALSE, disp->view_interrogation_areas);
718 * Changing the displaying of interrogation area's
720 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
721 if (view_toggle_intregs_flag) {
722 if (display_act->display_intregs == FALSE) {
723 display_act->display_intregs = TRUE;
724 create_all_intregs (display_act);
725 show_all_intregs (display_act);
728 } else {
729 if (display_act->display_intregs == TRUE) {
730 destroy_all_intregs(display_act);
731 display_act->display_intregs = FALSE;
738 void
739 view_toggle_piv (GtkWidget *widget,
740 gpointer data
742 /*-----------------------------------------------------------------------------
745 Display *disp = display_act;
748 * Synchronizing menu item from menu bar.
750 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
751 synchronize_menu (widget, TRUE, disp->view_velocity_vectors);
752 } else {
753 synchronize_menu (widget, FALSE, disp->view_velocity_vectors);
757 * Changing the displaying of piv data (velocity vectors)
759 if (display_act->pida->exist_piv) {
760 if (GTK_CHECK_MENU_ITEM (widget)->active == TRUE) {
761 if (display_act->display_piv == FALSE) {
762 display_act->display_piv = TRUE;
763 create_all_vectors (display_act->pida);
765 } else {
766 if (display_act->display_piv == TRUE) {
767 display_act->display_piv = FALSE;
768 destroy_all_vectors (display_act->pida);
776 void
777 select_view_scalardata (gpointer data,
778 guint action,
779 GtkWidget *widget
781 /*-----------------------------------------------------------------------------
784 gchar *color = NULL;
785 Display *disp = display_act;
786 GtkWidget *menu = NULL, *popupmenu = NULL;
789 gpiv_par->display__scalar = action;
791 hide_all_scalars (disp, GPIV_VORTICITY);
792 hide_all_scalars (disp, GPIV_S_STRAIN);
793 hide_all_scalars (disp, GPIV_N_STRAIN);
796 * Select menu and popup menu widgets
798 if (action == SHOW_SC_NONE) {
799 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
800 "view_none_scalars");
801 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
802 "view_scalardata_display0");
804 } else if (action == SHOW_SC_VORTICITY) {
805 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
806 "view_vorticity");
807 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
808 "view_scalardata_display1");
810 } else if (action == SHOW_SC_SSTRAIN) {
811 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
812 "view_shear_strain");
813 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
814 "view_scalardata_display2");
816 } else if (action == SHOW_SC_NSTRAIN) {
817 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
818 "view_normal_strain");
819 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
820 "view_scalardata_display3");
824 synchronize_menu (popupmenu, TRUE, menu);
827 * Perform action
829 if (action == SHOW_SC_NONE) {
830 hide_all_scalars (disp, GPIV_VORTICITY);
831 hide_all_scalars (disp, GPIV_S_STRAIN);
832 hide_all_scalars (disp, GPIV_N_STRAIN);
834 } else if (action == SHOW_SC_VORTICITY) {
835 show_all_scalars (display_act, GPIV_VORTICITY);
837 } else if (action == SHOW_SC_SSTRAIN) {
838 show_all_scalars (display_act, GPIV_S_STRAIN);
840 } else if (action == SHOW_SC_NSTRAIN) {
841 show_all_scalars (display_act, GPIV_N_STRAIN);
843 } else {
844 color = "black";
845 if (disp->gci_bg != NULL) {
846 gnome_canvas_item_set (GNOME_CANVAS_ITEM (disp->gci_bg),
847 "fill_color", color,
848 NULL);
849 } else {
850 g_warning (_("select_view_scalardata: should not arrive here"));
858 void
859 select_vectorscale (gpointer data,
860 guint action,
861 GtkWidget *widget
863 /*-----------------------------------------------------------------------------
864 Setting vector_scale from display pop-up menu */
866 Display *disp = display_act;
867 gchar *key1 = NULL, *key2 = NULL;
868 GtkWidget *menu, *popupmenu;
869 guint16 fact = 1;
871 gpiv_par->display__vector_scale = fact << (int) action;;
873 key1 = g_strdup_printf ("vector_scale_menu_%d", (int) action);
874 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin), key1);
876 key2 = g_strdup_printf ("vs_mv_%d", (int) action);
877 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin), key2);
879 synchronize_menu (popupmenu, TRUE, menu);
881 update_all_vectors (display_act->pida);
882 g_free (key1);
883 g_free (key2);
888 void
889 select_vectorcolor (gpointer data,
890 guint action,
891 GtkWidget *widget
893 /*-----------------------------------------------------------------------------
894 Setting vector_color from display pop-up menu */
896 Display *disp = display_act;
897 GtkWidget *menu, *popupmenu;
900 * Select menu and popup menu widgets
902 if (action == SHOW_PEAKNR) {
903 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
904 "vector_color_peak_nr");
905 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
906 "vectorcolor_menu_display0");
908 } else if (action == SHOW_SNR) {
909 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
910 "vector_color_snr");
911 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
912 "vectorcolor_menu_display1");
914 } else if (action == SHOW_MAGNITUDE_GRAY) {
915 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
916 "vector_color_magngray");
917 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
918 "vectorcolor_menu_display2");
920 } else if (action == SHOW_MAGNITUDE) {
921 menu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
922 "vector_color_magncolor");
923 popupmenu = gtk_object_get_data (GTK_OBJECT (disp->mwin),
924 "vectorcolor_menu_display3");
928 * Synchronize
930 synchronize_menu (popupmenu, TRUE, menu);
933 * Perform action
935 gpiv_par->display__vector_color = action;
936 update_all_vectors (display_act->pida);
941 void
942 nav_popup_click_handler (GtkWidget *widget,
943 GdkEventButton *event,
944 gpointer data
946 /*-----------------------------------------------------------------------------
949 /* Seee gimp: nav_window.c */
954 void
955 on_view_options_clicked (GtkButton *button,
956 gpointer user_data
958 /*-----------------------------------------------------------------------------
966 * Local functions
968 static void
969 on_adj_changed__adapt_hcanvas (Display *disp
971 /*-----------------------------------------------------------------------------
974 int x_old, y_old;
975 gnome_canvas_get_scroll_offsets (GNOME_CANVAS (disp->canvas),
976 &x_old,
977 &y_old);
978 gnome_canvas_scroll_to (GNOME_CANVAS (disp->canvas),
979 (int) disp->x_adj_value,
980 y_old);
984 static void
985 on_adj_changed__adapt_vcanvas (Display *disp
987 /*-----------------------------------------------------------------------------
990 int x_old, y_old;
991 gnome_canvas_get_scroll_offsets (GNOME_CANVAS (disp->canvas),
992 &x_old,
993 &y_old);
994 gnome_canvas_scroll_to (GNOME_CANVAS (disp->canvas),
995 x_old,
996 (int) disp->y_adj_value);
999 static void
1000 on_adj_changed__adapt_hruler (Display *disp
1002 /*-----------------------------------------------------------------------------
1005 set__hrulerscale (disp);
1009 static void
1010 on_adj_changed__adapt_vruler (Display *disp
1012 /*-----------------------------------------------------------------------------
1015 set__vrulerscale (disp);
1019 static void
1020 synchronize_menu (GtkWidget *menu_src,
1021 gboolean state,
1022 GtkWidget *menu_dest
1024 /*-----------------------------------------------------------------------------
1025 * Synchronizes menu_dest with menu_src, which is in 'state' position.
1026 * Only change if the state between menu_src and menu_dest differ in order
1027 * to avoid a loop.
1030 if (GTK_CHECK_MENU_ITEM (menu_src) != NULL
1031 && GTK_CHECK_MENU_ITEM (menu_src)->active == state) {
1032 if (GTK_CHECK_MENU_ITEM (menu_dest) != NULL
1033 && gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_dest))
1034 == !state) {
1035 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_dest),
1036 state);