improved monitoring of interrogation process
[gpiv.git] / src / display.c
blobc529179c19769263bbb8a03c8af7d0c17bc29b5c
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 Gerber van der Graaf
10 This file is part of gpiv.
12 Gpiv is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
15 any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ----------------------------------------------------------------------*/
29 * (callback) functions for the display
30 * $Log: display.c,v $
31 * Revision 1.12 2003-09-01 11:17:14 gerber
32 * improved monitoring of interrogation process
34 * Revision 1.11 2003/08/22 15:24:52 gerber
35 * interactive spatial scaling
37 * Revision 1.10 2003/07/31 11:43:26 gerber
38 * display images in gnome canvas (HOERAreset)
40 * Revision 1.9 2003/07/13 14:38:18 gerber
41 * changed error handling of libgpiv
43 * Revision 1.8 2003/07/12 21:21:15 gerber
44 * changed error handling libgpiv
46 * Revision 1.6 2003/07/10 11:56:07 gerber
47 * added man page
49 * Revision 1.5 2003/07/05 13:14:57 gerber
50 * drag and drop of a _series_ of filenames from NAUTILUS
52 * Revision 1.4 2003/07/04 10:47:00 gerber
53 * cleaning up
55 * Revision 1.3 2003/07/03 17:08:02 gerber
56 * display ruler adjusted for scaled data
58 * Revision 1.2 2003/06/27 13:47:26 gerber
59 * display ruler, line/point evaluation
61 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
62 * Imported gpiv
66 #include "gpiv_gtk.h"
67 #include "utils.h"
68 #include "display_interface.h"
69 #include "display.h"
70 #include "piveval.h"
73 static void
74 search_nearest_index(Display * disp,
75 gint x,
76 gint y,
77 gint * index_x,
78 gint * index_y)
80 gint i, j, x_min = 10e4, y_min = 10e4, dif;
82 for (i = 0; i < disp->intreg.data.ny; i++) {
83 for (j = 0; j < disp->intreg.data.nx; j++) {
84 dif = abs(y - (int) disp->intreg.data.point_y[i][j]);
85 if (dif < y_min) {
86 y_min = dif;
87 *index_y = i;
89 dif = abs(x - (int) disp->intreg.data.point_x[i][j]);
90 if (dif < x_min) {
91 x_min = dif;
92 *index_x = j;
100 static void
101 highlight_intreg(gint index_y,
102 gint index_x,
103 Display * disp)
105 if (disp->intreg.exist && disp->display_intregs
106 && index_y <= disp->intreg.data.ny
107 && index_x <= disp->intreg.data.nx) {
109 if (disp->intreg.gci_intreg2[disp->index_y_old][disp->index_x_old]
110 != NULL)
111 gnome_canvas_item_set(disp->intreg.
112 gci_intreg2[disp->index_y_old][disp->index_x_old],
113 "outline_color", "yellow",
114 NULL);
116 if (disp->intreg.gci_intreg1[disp->index_y_old][disp->index_x_old] != NULL)
117 gnome_canvas_item_set(disp->intreg.
118 gci_intreg1[disp->index_y_old][disp->index_x_old],
119 "outline_color", "blue",
120 NULL);
123 if (disp->intreg.gci_intreg2[index_y][index_x] != NULL) {
124 gnome_canvas_item_set(disp->intreg.gci_intreg2[index_y][index_x],
125 "outline_color", "red",
126 NULL);
127 gnome_canvas_item_raise_to_top(disp->intreg.
128 gci_intreg2[index_y][index_x]);
133 if (disp->intreg.gci_intreg1[index_y][index_x] != NULL) {
134 gnome_canvas_item_set(disp->intreg.gci_intreg1[index_y][index_x],
135 "outline_color", "green",
136 NULL);
137 gnome_canvas_item_raise_to_top(disp->intreg.
138 gci_intreg1[index_y][index_x]);
144 static void
145 create_msg_display_with_pivdata(PivData piv_data,
146 gint index_y,
147 gint index_x,
148 gint scale)
150 if (scale) {
151 g_snprintf(msg_display, MAX_CHARS,
152 "xp=%3.2fmm yp=%3.2fmm U=%3.2fm/s V=%3.2fm/s"
153 " snr=%3.2f peak #%d",
154 piv_data.point_x[index_y][index_x] * 1e3,
155 piv_data.point_y[index_y][index_x] * 1e3,
156 piv_data.dx[index_y][index_x],
157 piv_data.dy[index_y][index_x],
158 piv_data.snr[index_y][index_x],
159 piv_data.peak_no[index_y][index_x]);
160 } else {
161 g_snprintf(msg_display, MAX_CHARS,
162 "xp=%3.0fpx yp=%3.0fpx dx=%3.2fpx dy=%3.2fpx"
163 " snr=%3.2f peak #%d",
164 piv_data.point_x[index_y][index_x],
165 piv_data.point_y[index_y][index_x],
166 piv_data.dx[index_y][index_x],
167 piv_data.dy[index_y][index_x],
168 piv_data.snr[index_y][index_x],
169 piv_data.peak_no[index_y][index_x]);
175 static void
176 create_msg_display_with_pivscdata(PivData piv_data,
177 ScalarData sc_data,
178 gint index_y,
179 gint index_x,
180 gint scale)
182 if (scale) {
183 g_snprintf(msg_display, MAX_CHARS,
184 "xp=%3.2fmm yp=%3.2fmm U=%3.2fm/s V=%3.2fm/s "
185 "snr=%3.2f peak #%d scal=%3.2f",
186 piv_data.point_x[index_y][index_x] * 1e3,
187 piv_data.point_y[index_y][index_x] * 1e3,
188 piv_data.dx[index_y][index_x],
189 piv_data.dy[index_y][index_x],
190 piv_data.snr[index_y][index_x],
191 piv_data.peak_no[index_y][index_x],
192 sc_data.scalar[index_y][index_x]);
193 } else {
194 g_snprintf(msg_display, MAX_CHARS,
195 "xp=%3.0fpx yp=%3.0fpx dx=%3.2fpx dy=%3.2fpx "
196 "snr=%3.2f peak #%d scal=%3.2f",
197 piv_data.point_x[index_y][index_x],
198 piv_data.point_y[index_y][index_x],
199 piv_data.dx[index_y][index_x],
200 piv_data.dy[index_y][index_x],
201 piv_data.snr[index_y][index_x],
202 piv_data.peak_no[index_y][index_x],
203 sc_data.scalar[index_y][index_x]);
208 static void
209 create_line(Display *disp, gint x1, gint y1, gint x2, gint y2)
211 GnomeCanvasPoints *points;
212 points = gnome_canvas_points_new(2);
214 assert (disp != NULL);
215 assert (gci_line == NULL);
217 points->coords[0] = x1;
218 points->coords[1] = y1;
219 points->coords[2] = x2;
220 points->coords[3] = y2;
221 gci_line =
222 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(disp->canvas)
224 gnome_canvas_line_get_type(),
225 "points", points,
226 "fill_color", "yellow",
227 "width_units", (double) THICKNESS,
228 NULL);
230 gnome_canvas_points_free(points);
233 static void
234 update_line(gint x1, gint y1, gint x2, gint y2)
236 GnomeCanvasPoints *points;
237 points = gnome_canvas_points_new(2);
239 assert (gci_line != NULL);
241 points->coords[0] = x1;
242 points->coords[1] = y1;
243 points->coords[2] = x2;
244 points->coords[3] = y2;
246 gnome_canvas_item_set(GNOME_CANVAS_ITEM(/* disp-> */gci_line),
247 "points", points,
248 "fill_color", "yellow",
249 "width_units", (double) THICKNESS,
250 NULL);
252 gnome_canvas_points_free(points);
255 static void
256 destroy_line()
258 assert (gci_line != NULL);
260 gtk_object_destroy(GTK_OBJECT(gci_line));
261 gci_line = NULL;
264 static void
265 create_rect(Display *disp, gint x, gint y)
267 assert (disp != NULL);
268 assert( gci_aoi == NULL);
270 gci_aoi =
271 gnome_canvas_item_new(gnome_canvas_root
272 (GNOME_CANVAS(disp->canvas)),
273 gnome_canvas_rect_get_type(),
274 "x1", (double) x,
275 "y1", (double) y,
276 "x2", (double) x,
277 "y2", (double) y,
278 "outline_color", "yellow",
279 "width_units", (double) THICKNESS,
280 NULL);
284 static void
285 update_rect(gint x, gint y)
287 /* assert (disp != NULL); */
288 assert (gci_aoi != NULL);
290 gnome_canvas_item_set(GNOME_CANVAS_ITEM(gci_aoi),
291 "x2", (double) x,
292 "y2", (double) y,
293 NULL);
297 static void
298 destroy_rect()
300 assert (gci_aoi != NULL);
302 gtk_object_destroy(GTK_OBJECT(gci_aoi));
303 gci_aoi = NULL;
308 * Callbacks for img_display
311 gint
312 on_button_display_origin_press_event(GtkWidget *widget,
313 GdkEventButton *event,
314 gpointer data)
316 gtk_menu_popup(GTK_MENU(display_act->display_menu), NULL, NULL, NULL, NULL,
317 event->button, event->time);
318 return FALSE;
323 void
324 on_display_set_focus(GtkWidget * widget,
325 gpointer data)
327 Display *disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
328 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
330 gtk_clist_set_selection_mode(GTK_CLIST (gpiv->clist_buf),
331 GTK_SELECTION_SINGLE);
332 gtk_clist_select_row(GTK_CLIST(gpiv->clist_buf), disp->count, 0);
333 gtk_clist_set_selection_mode(GTK_CLIST (gpiv->clist_buf),
334 GTK_SELECTION_EXTENDED);
338 void
339 on_scrolledwindow_display_adj_changed (GtkAdjustment *adj,
340 gpointer data)
343 * Adjusts x_offset, x_lower and x_upper when scrolling
344 * Ruler adjustments for zooming and scaling of data
346 * Disp->stretch_window_tmp is a flag that is set when the window is at
347 * full-scale by invoking stretch window or by picking a smaller zoom-scale
348 * than the acual one.
350 Display * disp = gtk_object_get_data(GTK_OBJECT(adj), "disp");
351 gfloat x_start = 0, x_end = 0, y_start = 0, y_end = 0;
352 enum variable_type {
353 X_ADJ = 0,
354 Y_ADJ = 1
355 } var_type;
357 var_type = atoi(gtk_object_get_data(GTK_OBJECT(adj), "var_type"));
359 if (disp->stretch_window_tmp) {
360 if (var_type == X_ADJ) {
361 x_offset = (gint) adj->value;
362 x_lower = (gint) adj->lower;
363 x_upper = (gint) adj->upper;
366 if (disp->gpd.exist_piv && display_act->gpd.scaled_piv) {
367 x_start = (gfloat) x_offset * image_par.s_scale +
368 image_par.z_off_x *10e2;
369 x_end = (gfloat) gpiv_par.img_width * image_par.s_scale - 1.0
370 + image_par.z_off_x *10e2;
372 } else {
374 x_start = 0.0;
375 x_end = (gfloat) (gpiv_par.img_width - 1);
378 gtk_ruler_set_range(GTK_RULER(disp->hruler),
379 x_start,
380 x_end,
381 x_start,
382 x_end);
384 gtk_widget_set_usize (disp->hruler,
385 (gint) (disp->zoom_factor *
386 gpiv_par.img_width),
387 RULER_WIDTH);
388 gtk_widget_set_uposition (disp->hruler, RULER_WIDTH, 0);
391 if (var_type == Y_ADJ) {
392 y_offset = (gint) adj->value;
393 y_lower = (gint) adj->lower;
394 y_upper = (gint) adj->upper;
396 if (disp->gpd.exist_piv && display_act->gpd.scaled_piv) {
397 y_start = (gfloat) y_offset * image_par.s_scale +
398 image_par.z_off_y *10e2;
400 y_end = (gfloat) gpiv_par.img_height * image_par.s_scale - 1.0
401 + image_par.z_off_y *10e2;
403 } else {
405 y_start = 0.0;
406 y_end = (gfloat) (gpiv_par.img_height - 1);
409 gtk_ruler_set_range(GTK_RULER(disp->vruler),
410 y_start,
411 y_end,
412 y_start,
413 y_end);
414 gtk_widget_set_usize (disp->vruler,
415 RULER_WIDTH,
416 (gint) (disp->zoom_factor *
417 gpiv_par.img_height));
418 gtk_widget_set_uposition (disp->vruler, 0, RULER_WIDTH);
422 } else {
423 if (var_type == X_ADJ) {
424 x_offset = (gint) adj->value;
425 x_lower = (gint) adj->lower;
426 x_upper = (gint) adj->upper;
428 if (disp->gpd.exist_piv && display_act->gpd.scaled_piv) {
429 x_start = (gfloat) x_offset / (gfloat) disp->zoom_factor
430 * image_par.s_scale *10e2 + image_par.z_off_x *10e2;
431 x_end = (gfloat) x_offset / (gfloat) disp->zoom_factor
432 * image_par.s_scale *10e2 + image_par.z_off_x *10e2
433 + (gfloat) (gpiv_par.img_width - 1.0)
434 * image_par.s_scale *10e2
435 * (gfloat) disp->zoom_factor_old
436 / (gfloat) disp->zoom_factor;
438 } else {
440 x_start = (gfloat) (x_offset) / (gfloat) disp->zoom_factor;
441 x_end = (gfloat) x_offset
442 / (gfloat) disp->zoom_factor
443 + (gfloat) (gpiv_par.img_width - 1)
444 * (gfloat) disp->zoom_factor_old
445 / (gfloat) disp->zoom_factor;
448 gtk_ruler_set_range(GTK_RULER(disp->hruler),
449 x_start,
450 x_end,
451 x_start,
452 x_end);
456 if (var_type == Y_ADJ) {
457 y_offset = (gint) adj->value;
458 y_lower = (gint) adj->lower;
459 y_upper = (gint) adj->upper;
461 if (disp->gpd.exist_piv && display_act->gpd.scaled_piv) {
462 y_start = (gfloat) y_offset / (gfloat) disp->zoom_factor
463 * image_par.s_scale *10e2 + image_par.z_off_y *10e2;
464 y_end = (gfloat) y_offset / (gfloat) disp->zoom_factor
465 * image_par.s_scale *10e2 + image_par.z_off_y *10e2
466 + (gfloat) (gpiv_par.img_height - 1.0)
467 * image_par.s_scale *10e2
468 * (gfloat) disp->zoom_factor_old
469 / (gfloat) disp->zoom_factor;
471 } else {
473 y_start = (gfloat) (y_offset) / (gfloat) disp->zoom_factor;
474 y_end = (gfloat) y_offset
475 / (gfloat) disp->zoom_factor
476 + (gfloat) (gpiv_par.img_height - 1)
477 * (gfloat) disp->zoom_factor_old
478 / (gfloat) disp->zoom_factor;
481 gtk_ruler_set_range(GTK_RULER(disp->vruler),
482 y_start,
483 y_end,
484 y_start,
485 y_end);
496 * Callback functions for pop-up menus
499 gint
500 on_displaypopup_handler(GtkWidget *widget, GdkEvent *event)
502 GtkMenu *menu;
503 GdkEventButton *event_button;
505 g_return_val_if_fail (widget != NULL, FALSE);
506 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
507 g_return_val_if_fail (event != NULL, FALSE);
509 /* The "widget" is the menu that was supplied when
510 * gtk_signal_connect_object was called.
512 menu = GTK_MENU (widget);
514 if (event->type == GDK_BUTTON_PRESS)
516 event_button = (GdkEventButton *) event;
517 if (event_button->button == 3)
519 gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
520 event_button->button, event_button->time);
521 return TRUE;
525 return FALSE;
532 /* void */
533 /* select_zoomscale(GtkMenuItem * menuitem, */
534 /* gpointer data, */
535 /* guint action */
536 /* ) */
537 void
538 select_zoomscale(gpointer data,
539 guint action,
540 GtkWidget * widget)
542 /* Display *disp = gtk_object_get_data(GTK_OBJECT(widget), "disp"); */
543 Display *disp = display_act;
544 gint zoom_index = action;
545 /* gtk_object_get_data(GTK_OBJECT(menuitem), "zoom_index"); */
547 zoom_display(disp, zoom_index);
550 void
551 zoom_display(Display *disp, gint zoom_index)
553 gint screen_width = gdk_screen_width();
554 gint screen_height = gdk_screen_height();
555 gint width = 0, height = 0;
556 gint new_width = 0;
557 gint new_height = 0;
559 if (disp != NULL) {
560 disp->zoom_factor = zfactor[zoom_index];
561 new_width = (gint) (disp->zoom_factor * gpiv_par.img_width + VIEW_HMARGE);
562 new_height = (gint) (disp->zoom_factor * gpiv_par.img_height + VIEW_VMARGE);
564 gdk_window_get_size(disp->mwin->window, &width, &height);
565 /* gdk_win_hints_get_expanded_size(disp->mwin->window, &width, &height); */
567 /* gnome_win_hints_get_expanded_size(display_act, */
568 /* &x, */
569 /* &y, */
570 /* &width, */
571 /* &height); */
574 if ((new_width < width || new_height < height)
575 || (gpiv_par.stretch_window ) ) {
577 if (new_width < screen_width && new_height < screen_height) {
578 gnome_win_hints_set_state(disp->mwin, 0);
579 gdk_window_resize(disp->mwin->window,
580 new_width, new_height);
582 } else if (new_width > screen_width && new_height < screen_height) {
583 gnome_win_hints_set_state(disp->mwin,
584 WIN_STATE_MAXIMIZED_HORIZ);
586 } else if (new_width < screen_width && new_height > screen_height) {
587 gnome_win_hints_set_state(disp->mwin,
588 WIN_STATE_MAXIMIZED_VERT);
590 } else if (new_width > screen_width && new_height > screen_height) {
591 g_warning("zoom_display:: setting max hor and vert");
592 gnome_win_hints_set_state(disp->mwin,
593 WIN_STATE_MAXIMIZED_HORIZ +
594 WIN_STATE_MAXIMIZED_VERT);
596 } else {
597 g_warning("select_zoomscale: should not arrive here");
600 } else {
601 disp->stretch_window_tmp = FALSE;
604 /* gnome_win_hints_set_expanded_size(disp->mwin, x, y, width, */
605 /* height); */
609 gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(disp->canvas),
610 disp->zoom_factor);
612 if (new_width < width && new_height < height) {
613 /* g_warning("select_zoomscale:: set_usize stretch_window fact=%f fact_old=%f", */
614 /* disp->zoom_factor, zoom_factor_tmp); */
615 gtk_widget_set_usize (disp->canvas,
616 (gint) (disp->zoom_factor * gpiv_par.img_width),
617 (gint) (disp->zoom_factor * gpiv_par.img_height));
618 disp->stretch_window_tmp = TRUE;
619 disp->zoom_factor_old = disp->zoom_factor;
629 * Callback functions for actions within display
632 gint
633 canvas_display_enter_notify(GtkWidget * widget,
634 GdkEventMotion * event)
636 Display *disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
637 /* GtkWidget * view_menu_display4 = */
638 /* gtk_object_get_data(GTK_OBJECT(disp->mwin), */
639 /* "view_menu_display4"); */
641 disp->index_x_old = 0;
642 disp->index_y_old = 0;
643 disp->index_old = FALSE;
645 /* g_warning("canvas_display_enter_notify:: viewer count = %d", disp->count); */
646 if (m_select == NO_MS) {
647 cursor = gdk_cursor_new(GDK_DOTBOX);
648 /* g_warning("canvas_display_enter_notify:: NO_MS"); */
652 } else if (m_select == SINGLE_AREA_MS
653 || m_select == ENABLE_POINT_MS
654 || m_select == DISABLE_POINT_MS) {
655 cursor = gdk_cursor_new(GDK_CROSSHAIR);
659 } else if ( m_select == DRAG_MS ) {
660 cursor = gdk_cursor_new(GDK_CROSS);
664 } else if (m_select == SINGLE_POINT_MS
665 || m_select == V_LINE_MS
666 || m_select == H_LINE_MS
668 cursor = gdk_cursor_new(GDK_CROSS);
669 if (display_act->gpd.exist_piv && disp->display_piv) {
670 hide_all_vectors(&display_act->gpd);
671 disp->display_piv = FALSE;
674 if (disp->intreg.exist && disp->display_intregs) {
675 hide_all_intregs(disp);
676 disp->display_intregs = FALSE;
681 } else if (m_select == AOI_MS
682 || m_select == ENABLE_AREA_MS
683 || m_select == DISABLE_AREA_MS) {
684 cursor = gdk_cursor_new(GDK_FLEUR);
685 if (m_select == AOI_MS) {
686 hide_all_intregs(disp);
687 disp->display_intregs = FALSE;
692 } else if (m_select == SPANLENGTH_MS
693 || m_select == V_SPANLENGTH_MS
694 || m_select == H_SPANLENGTH_MS
696 cursor = gdk_cursor_new(GDK_CROSS);
699 gdk_window_set_cursor(disp->mwin->window, cursor);
701 return TRUE;
707 gint
708 canvas_display_motion_notify(GtkWidget * widget,
709 GdkEventMotion * event)
711 Display *disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
712 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
714 gint x, y /*, i, j , x_min = 10e4, y_min = 10e4, dif */;
715 gint index_y = 0, index_x = 0;
717 GdkModifierType state;
718 PivData piv_data = disp->gpd.piv_data;
719 PivData piv_data_scaled = disp->gpd.piv_data_scaled;
720 ScalarData vor_data = disp->gpd.vor_data;
721 ScalarData vor_data_scaled = disp->gpd.vor_data_scaled;
723 GnomeCanvasPoints *points;
724 points = gnome_canvas_points_new(2);
727 /* gdk_window_get_pointer (widget->mwin, &x, &y, NULL); */
728 /* x = event->x; */
729 /* y = event->y; */
732 if (event->is_hint) {
733 gdk_window_get_pointer(event->window, &x, &y, &state);
734 x = (x + x_offset)/ disp->zoom_factor;
735 y = (y + y_offset) / disp->zoom_factor;
736 } else {
737 x = (event->x + x_offset) / disp->zoom_factor;
738 y = (event->y + y_offset) / disp->zoom_factor;
739 state = event->state;
744 if (m_select == NO_MS
745 || m_select == SINGLE_AREA_MS
746 || m_select == DRAG_MS
747 || m_select == ENABLE_POINT_MS
748 || m_select == DISABLE_POINT_MS) {
750 * search index nearest to pointer
751 * display particle displacements / velocities and its attributes,
753 if (disp->display_intregs)
755 search_nearest_index(disp, x, y, &index_x, &index_y);
756 highlight_intreg(index_y, index_x, disp);
759 * display locations of interrogation area's and estimators,
760 * only display locations of interrogation area's,
761 * or nothing
763 if (disp->gpd.exist_piv && disp->display_piv
764 && piv_data.ny == disp->intreg.data.ny
765 && piv_data.nx == disp->intreg.data.nx
766 && piv_data.point_y[0][0] == disp->intreg.data.point_y[0][0]
767 && piv_data.point_x[0][0] == disp->intreg.data.point_x[0][0]
769 highlight_intreg(index_y, index_x, disp);
771 if (display_act->gpd.exist_vor && display_act->display_vor) {
772 if (display_act->gpd.scaled_piv) {
773 create_msg_display_with_pivscdata(piv_data_scaled,
774 vor_data_scaled,
775 index_y,
776 index_x,
777 display_act->
778 gpd.scaled_piv);
779 } else {
780 create_msg_display_with_pivscdata(piv_data,
781 vor_data,
782 index_y,
783 index_x,
784 display_act->
785 gpd.scaled_piv);
787 } else {
788 if (display_act->gpd.scaled_piv) {
789 create_msg_display_with_pivdata(piv_data_scaled,
790 index_y,
791 index_x,
792 display_act->
793 gpd.scaled_piv);
795 } else {
796 create_msg_display_with_pivdata(piv_data,
797 index_y,
798 index_x,
799 display_act->
800 gpd.scaled_piv);
804 } else if (disp->display_intregs) {
805 highlight_intreg(index_y, index_x, disp);
806 g_snprintf(msg_display, MAX_CHARS, "x=%3.2f y=%3.2f i=%d j=%d ",
807 disp->intreg.data.point_x[index_y][index_x],
808 disp->intreg.data.point_y[index_y][index_x],
809 index_y, index_x);
811 } else {
812 g_snprintf(msg_display, MAX_CHARS, " ");
818 * display correlation function
819 * DISABLED
821 if (piv_eval_par.print_cov == 1
822 && display_act->gpd.exist_cov) {
823 /* memset(graybuf_int1, 215, */
824 /* (sizeof(guchar)) * (MAX_INTERR_SIZE * */
825 /* MAX_INTERR_SIZE)); */
826 /* memset(graybuf_int2, 215, */
827 /* (sizeof(guchar)) * (MAX_INTERR_SIZE * */
828 /* MAX_INTERR_SIZE)); */
829 /* memset(graybuf_cov, 215, */
830 /* (sizeof(guchar)) * (MAX_INTERR_SIZE * */
831 /* MAX_INTERR_SIZE)); */
833 /* display_vector(index_y, index_x, display_act->gpd.piv_data); */
835 /* display_img_intreg1(display_act->gpd. */
836 /* intreg1[index_y][index_x], */
837 /* piv_eval_par.int_size_2, */
838 /* gpiv->piveval); */
839 /* display_img_intreg2(display_act->gpd. */
840 /* intreg2[index_y][index_x], */
841 /* piv_eval_par.int_size_2, */
842 /* gpiv->piveval); */
843 /* display_img_cov(&display_act->gpd.cov[index_y][index_x], */
844 /* piv_eval_par.int_size_2, */
845 /* gpiv->piveval); */
851 * displaces interrogation area nearest to pointer
853 if ( m_select == DRAG_MS ) {
854 if (!disp->index_old) {
855 disp->index_x_old = index_x;
856 disp->index_y_old = index_y;
857 disp->index_old = TRUE;
860 if (index_x == disp->index_x_old
861 && index_y == disp->index_y_old) {
863 gnome_canvas_item_set
864 (GNOME_CANVAS_ITEM(disp->intreg.
865 gci_intreg1[index_y][index_x]),
866 "x1", (double) x - piv_eval_par.int_size_1 / 2,
867 "y1", (double) y - piv_eval_par.int_size_1 / 2,
868 "x2", (double) x + piv_eval_par.int_size_1 / 2,
869 "y2", (double) y + piv_eval_par.int_size_1 / 2,
870 NULL);
872 gnome_canvas_item_set
873 (GNOME_CANVAS_ITEM(disp->intreg.
874 gci_intreg2[index_y][index_x]),
875 "x1", (double) x - piv_eval_par.int_size_2 /
876 2 + piv_eval_par.pre_shift_col,
877 "y1", (double) y - piv_eval_par.int_size_2 /
878 2 + piv_eval_par.pre_shift_row,
879 "x2", (double) x + piv_eval_par.int_size_2 /
880 2 + piv_eval_par.pre_shift_col,
881 "y2", (double) y + piv_eval_par.int_size_2 /
882 2 + piv_eval_par.pre_shift_row,
883 NULL);
885 * put the interrogation area back to its original location
887 } else {
888 update_intreg1(disp->index_y_old, disp->index_x_old, disp);
889 update_intreg2(disp->index_y_old, disp->index_x_old, disp);
893 disp->index_x_old = index_x;
894 disp->index_y_old = index_y;
899 * Only prints pointer position
901 } else if (m_select == AOI_MS
902 || m_select == ENABLE_AREA_MS
903 || m_select == DISABLE_AREA_MS ) {
904 g_snprintf(msg_display, MAX_CHARS, "x=%d px y=%d px", x, y);
907 } else if ( m_select == SINGLE_POINT_MS) {
909 * I am using the first interrogation area ([0][0]) temporarly for
910 * displaying
912 if (disp->intreg.gci_intreg1[0][0] != NULL &&
913 disp-> intreg.gci_intreg2[0][0] != NULL
915 if (!disp->display_intregs) {
916 gnome_canvas_item_show
917 (GNOME_CANVAS_ITEM(disp->intreg.gci_intreg1[0][0]));
918 gnome_canvas_item_show
919 (GNOME_CANVAS_ITEM(disp->intreg.gci_intreg2[0][0]));
920 disp->display_intregs = TRUE;
923 if (disp->gpd.exist_piv && display_act->gpd.scaled_piv) {
924 g_snprintf(msg_display, MAX_CHARS, "x=%3.2f mm y=%3.2f mm",
925 (gfloat) x * image_par.s_scale *10e2
926 + (gfloat) image_par.z_off_x *10e2,
927 (gfloat) y * image_par.s_scale *10e2
928 + (gfloat) image_par.z_off_y *10e2);
929 } else {
930 g_snprintf(msg_display, MAX_CHARS, "x=%d px y=%d px", x, y);
933 gnome_canvas_item_set
934 (GNOME_CANVAS_ITEM(disp->intreg.gci_intreg1[0][0]),
935 "x1", (double) x - piv_eval_par.int_size_1 / 2,
936 "y1", (double) y - piv_eval_par.int_size_1 / 2,
937 "x2", (double) x + piv_eval_par.int_size_1 / 2,
938 "y2", (double) y + piv_eval_par.int_size_1 / 2,
939 NULL);
941 gnome_canvas_item_set
942 (GNOME_CANVAS_ITEM(disp->intreg.gci_intreg2[0][0]),
943 "x1", (double) x - piv_eval_par.int_size_1 / 2
944 + piv_eval_par.pre_shift_col,
945 "y1", (double) y - piv_eval_par.int_size_1 / 2
946 + piv_eval_par.pre_shift_row,
947 "x2", (double) x + piv_eval_par.int_size_1 / 2
948 + piv_eval_par.pre_shift_col,
949 "y2", (double) y + piv_eval_par.int_size_1 / 2
950 + piv_eval_par.pre_shift_row,
951 NULL);
953 } else {
954 create_intreg1(0, 0, display_act);
955 create_intreg2(0, 0, display_act);
961 * Update a line
963 } else if (m_select == V_LINE_MS) {
964 g_snprintf(msg_display, MAX_CHARS, "x=%d px y=%d px", x, y);
966 if (state & GDK_BUTTON1_MASK && gci_line != NULL ) {
967 g_snprintf(msg_display, MAX_CHARS, "x=%d px y=%d px",
968 piv_eval_par.int_line_col, y);
969 update_line(piv_eval_par.int_line_col,
970 piv_eval_par.int_line_row_start,
971 piv_eval_par.int_line_col,
976 } else if (m_select == H_LINE_MS) {
977 g_snprintf(msg_display, MAX_CHARS, "x=%d px y=%d px", x, y);
979 if (state & GDK_BUTTON1_MASK && gci_line != NULL ) {
980 g_snprintf(msg_display, MAX_CHARS, "x=%d y=%d",
981 x, piv_eval_par.int_line_row);
982 update_line(piv_eval_par.int_line_col_start,
983 piv_eval_par.int_line_row,
985 piv_eval_par.int_line_row);
989 } else if (m_select == SPANLENGTH_MS) {
990 g_snprintf(msg_display, MAX_CHARS, "x=%d px y=%d px", x, y);
992 if (state & GDK_BUTTON1_MASK && gci_line != NULL ) {
993 g_snprintf(msg_display, MAX_CHARS, "x=%d y=%d",
994 x, y);
995 update_line(disp->xgrab_first,
996 disp->ygrab_first,
1001 } else if (m_select == V_SPANLENGTH_MS) {
1002 g_snprintf(msg_display, MAX_CHARS, "x=%d px y=%d px", x, y);
1004 if (state & GDK_BUTTON1_MASK && gci_line != NULL ) {
1005 g_snprintf(msg_display, MAX_CHARS, "x=%d y=%d",
1006 disp->xgrab_first, y);
1007 update_line(disp->xgrab_first,
1008 disp->ygrab_first,
1009 disp->xgrab_first,
1013 } else if (m_select == H_SPANLENGTH_MS) {
1014 g_snprintf(msg_display, MAX_CHARS, "x=%d px y=%d px", x, y);
1016 if (state & GDK_BUTTON1_MASK && gci_line != NULL ) {
1017 g_snprintf(msg_display, MAX_CHARS, "x=%d y=%d",
1018 x, disp->ygrab_first);
1019 update_line(disp->xgrab_first,
1020 disp->ygrab_first,
1022 disp->ygrab_first);
1029 gnome_appbar_push(GNOME_APPBAR(disp->appbar), msg_display);
1030 gnome_appbar_push(GNOME_APPBAR(gpiv->appbar), msg_display);
1032 if (state & GDK_BUTTON1_MASK) {
1033 if ((m_select == AOI_MS
1034 || m_select == ENABLE_AREA_MS
1035 || m_select == DISABLE_AREA_MS)
1036 && gci_aoi != NULL) {
1037 update_rect(x, y);
1042 gnome_canvas_points_free(points);
1044 return TRUE;
1049 gint
1050 canvas_display_button_press(GtkWidget * widget,
1051 GdkEventButton * event)
1053 Display * disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
1054 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
1055 gint x, y;
1056 gint index_x = 0, index_y = 0;
1057 /* Intreg *intreg = disp->intreg; */
1058 GdkModifierType state;
1059 GnomeCanvasPoints *points;
1060 points = gnome_canvas_points_new(2);
1062 gdk_window_get_pointer(event->window, &x, &y, &state);
1063 x = (x + x_offset)/ disp->zoom_factor;
1064 y = (y + y_offset) / disp->zoom_factor;
1066 if (event->button == 1) {
1067 if (m_select == NO_MS) {
1071 * select Area Of Interest
1073 } else if (m_select == AOI_MS) {
1075 * storige of original AOI
1077 disp->intreg.col_start_old = piv_eval_par.col_start;
1078 disp->intreg.row_start_old = piv_eval_par.row_start;
1080 disp->xgrab_first = x;
1081 disp->ygrab_first = y;
1082 create_rect(disp, x, y);
1085 * analyse at single interrogation area
1087 } else if ((m_select == SINGLE_AREA_MS || m_select == DRAG_MS) &&
1088 display_act->img.exist_img) {
1089 if (disp->intreg.exist && display_act->gpd.exist_piv) {
1090 search_nearest_index(disp, x, y, &index_x, &index_y);
1091 m_select_index_x = index_x;
1092 m_select_index_y = index_y;
1094 if (m_select == DRAG_MS) {
1095 disp->gpd.piv_data.point_x[m_select_index_y]
1096 [m_select_index_x] = (float) x;
1097 disp->gpd.piv_data.point_y[m_select_index_y
1098 ][m_select_index_x] = (float) y;
1099 disp->intreg.data.point_x[m_select_index_y]
1100 [m_select_index_x] = (float) x;
1101 disp->intreg.data.point_y[m_select_index_y]
1102 [m_select_index_x] = (float) y;
1106 interrogate(&display_act->gpd.piv_data, display_act->img.img1,
1107 display_act->img.img2, gpiv);
1109 if (display_act->gpd.gci_vector[m_select_index_y]
1110 [m_select_index_x] != NULL) {
1111 update_vector(m_select_index_y, m_select_index_x,
1112 &display_act->gpd);
1113 } else {
1114 display_vector(m_select_index_y, m_select_index_x,
1115 &display_act->gpd);
1118 /* display_act->gpd.exist_piv = TRUE; */
1119 disp->display_piv = TRUE;
1120 if (m_select == DRAG_MS) {
1121 if (disp->intreg.
1122 gci_intreg1[m_select_index_y][m_select_index_x]
1123 != NULL)
1124 update_intreg1
1125 (m_select_index_y, m_select_index_x,
1126 disp);
1127 if (disp->intreg.
1128 gci_intreg2[m_select_index_y][m_select_index_x]
1129 != NULL)
1130 update_intreg2(m_select_index_y, m_select_index_x,
1131 disp);
1134 } else {
1135 msg_error = "Interrogation area's and piv data must already exist!";
1136 gtk_warning(msg_error);
1140 * Reset mouse selection to inactive
1141 * DISABELED
1143 /* gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON */
1144 /* (gpiv->piveval->radiobutton_mouse_1), */
1145 /* TRUE); */
1146 /* cursor = gdk_cursor_new(GDK_DOTBOX); */
1147 /* gdk_window_set_cursor(disp->mwin->window, cursor); */
1150 * analyse at single point
1152 } else if (m_select == SINGLE_POINT_MS && disp->img.exist_img) {
1153 if (disp->gpd.exist_piv) {
1154 destroy_all_vectors(&disp->gpd);
1155 gpiv_free_pivdata (&disp->gpd.piv_data);
1156 disp->gpd.exist_piv = FALSE;
1157 if (disp->gpd.scaled_piv) {
1158 gpiv_free_pivdata(&disp->gpd.piv_data_scaled);
1159 disp->gpd.scaled_piv = FALSE;
1163 free_post_bufmems(disp);
1164 destroy_all_intregs(disp);
1166 m_select_index_x = 0;
1167 m_select_index_y = 0;
1168 piv_eval_par.int_point_col = (float) x;
1169 piv_eval_par.int_point_row = (float) y;
1170 gpiv_alloc_pivdata(&disp->gpd.piv_data);
1171 display_act->gpd.exist_piv = TRUE;
1173 disp->gpd.piv_data.point_x[0][0] = (float) x;
1174 disp->gpd.piv_data.point_y[0][0] = (float) y;
1176 disp->intreg.data.nx = 1;
1177 disp->intreg.data.ny = 1;
1178 create_all_intregs(disp);
1179 disp->intreg.exist = 1;
1181 disp->intreg.data.point_x[0][0] = (float) x;
1182 disp->intreg.data.point_y[0][0] = (float) y;
1183 show_all_intregs(disp);
1184 disp->display_intregs = TRUE;
1186 interrogate(&disp->gpd.piv_data,
1187 disp->img.img1,
1188 disp->img.img2,
1189 gpiv);
1190 disp->display_piv = TRUE;
1192 display_all_vectors(&display_act->gpd);
1193 gnome_canvas_update_now(GNOME_CANVAS(disp->canvas));
1196 * Reset mouse selection to inactive
1198 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
1199 (gpiv->piveval->radiobutton_mouse_1),
1200 TRUE);
1201 cursor = gdk_cursor_new(GDK_DOTBOX);
1202 gdk_window_set_cursor(disp->mwin->window, cursor);
1206 } else if (m_select == V_LINE_MS && display_act->img.exist_img) {
1207 piv_eval_par.int_line_col = x;
1208 piv_eval_par.int_line_row_start = y;
1209 if (gci_line != NULL) destroy_line();
1210 create_line(disp, x, y, x, y);
1213 } else if (m_select == H_LINE_MS && display_act->img.exist_img) {
1214 piv_eval_par.int_line_col_start = x;
1215 piv_eval_par.int_line_row = y;
1216 if (gci_line != NULL) destroy_line();
1217 create_line(disp, x, y, x, y);
1220 } else if ( m_select == ENABLE_POINT_MS ) {
1222 * Only active with piv data
1224 if (display_act->gpd.exist_piv && disp->display_piv &&
1225 disp->intreg.exist && disp->display_intregs) {
1226 search_nearest_index(disp, x, y, &index_x, &index_y);
1227 display_act->gpd.piv_data.peak_no[index_y][index_x] = 1;
1228 update_vector(index_y, index_x, &display_act->gpd);
1233 * Enabling and disabling only active with piv data
1235 } else if ((m_select == DISABLE_POINT_MS
1236 || m_select == ENABLE_AREA_MS
1237 || m_select == DISABLE_AREA_MS)
1238 && display_act->gpd.exist_piv && disp->display_piv) {
1239 if ( m_select == DISABLE_POINT_MS ) {
1240 search_nearest_index(disp, x, y, &index_x, &index_y);
1241 display_act->gpd.piv_data.peak_no[index_y][index_x] = -1;
1242 update_vector(index_y, index_x, &display_act->gpd);
1245 } else if ( m_select == ENABLE_AREA_MS ) {
1246 enable_col_start = x;
1247 enable_row_start = y;
1248 assert( gci_aoi == NULL);
1249 gci_aoi =
1250 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(disp->canvas)
1252 gnome_canvas_rect_get_type(),
1253 "x1", (double) x,
1254 "y1", (double) y,
1255 "x2", (double) x,
1256 "y2", (double) y,
1257 "outline_color", "yellow",
1258 "width_units", (double) THICKNESS,
1259 NULL);
1262 } else if ( m_select == DISABLE_AREA_MS) {
1263 enable_col_start = x;
1264 enable_row_start = y;
1265 assert( gci_aoi == NULL);
1266 gci_aoi =
1267 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(disp->canvas)
1269 gnome_canvas_rect_get_type(),
1270 "x1", (double) x,
1271 "y1", (double) y,
1272 "x2", (double) x,
1273 "y2", (double) y,
1274 "outline_color", "yellow",
1275 "width_units", (double) THICKNESS,
1276 NULL);
1277 } else {
1278 msg_error = _("no image or piv data");
1279 gtk_warning(msg_error);
1283 } else if (m_select == SPANLENGTH_MS
1284 && display_act->img.exist_img) {
1285 disp->xgrab_first = x;
1286 disp->ygrab_first = y;
1287 if (gci_line != NULL) destroy_line();
1288 create_line(disp, x, y, x, y);
1292 } else if (m_select == V_SPANLENGTH_MS
1293 && display_act->img.exist_img) {
1294 disp->xgrab_first = x;
1295 disp->ygrab_first = y;
1296 if (gci_line != NULL) destroy_line();
1297 create_line(disp, x, y, x, y);
1301 } else if (m_select == H_SPANLENGTH_MS
1302 && display_act->img.exist_img) {
1303 disp->xgrab_first = x;
1304 disp->ygrab_first = y;
1305 if (gci_line != NULL) destroy_line();
1306 create_line(disp, x, y, x, y);
1309 } else {
1310 g_warning("canvas_display_button_press: should not arrive here m_select=%d", m_select);
1316 gnome_canvas_points_free(points);
1317 return TRUE;
1322 gint
1323 canvas_display_button_release(GtkWidget * widget, GdkEventButton * event)
1325 Display *disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
1326 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
1327 GtkWidget * view_menu_display4 =
1328 gtk_object_get_data(GTK_OBJECT(disp->mwin),
1329 "view_menu_display4");
1330 gint x, y, i, j;
1331 GdkModifierType state;
1332 /* Intreg *intreg = disp->intreg; */
1334 gdk_window_get_pointer(event->window, &x, &y, &state);
1335 x = (x + x_offset)/ disp->zoom_factor;
1336 y = (y + y_offset) / disp->zoom_factor;
1339 if (event->button == 1) {
1341 if (m_select == AOI_MS && gci_aoi != NULL) {
1342 if (display_act->gpd.exist_piv) {
1343 /* free_pivdata(&display_act->gpd.piv_data); */
1344 /* destroy_all_vectors(&display_act->gpd); */
1347 if (x >= disp->xgrab_first) {
1348 piv_eval_par.col_start = disp->xgrab_first;
1349 piv_eval_par.col_end = x;
1350 } else {
1351 piv_eval_par.col_end = disp->xgrab_first;
1352 piv_eval_par.col_start = x;
1355 if (y >= disp->ygrab_first) {
1356 piv_eval_par.row_start = disp->ygrab_first;
1357 piv_eval_par.row_end = y;
1358 } else {
1359 piv_eval_par.row_end = disp->ygrab_first;
1360 piv_eval_par.row_start = y;
1364 create_all_intregs(disp);
1365 if (GTK_CHECK_MENU_ITEM(view_menu_display4)->active) {
1366 show_all_intregs(disp);
1367 disp->display_intregs = TRUE;
1368 } else {
1369 hide_all_intregs(disp);
1370 disp->display_intregs = FALSE;
1373 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1374 (gpiv->piveval->spinbutton_colstart),
1375 piv_eval_par.col_start);
1376 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1377 (gpiv->piveval->spinbutton_rowstart),
1378 piv_eval_par.row_start);
1379 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1380 (gpiv->piveval->spinbutton_colend),
1381 piv_eval_par.col_end);
1382 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1383 (gpiv->piveval->spinbutton_rowend),
1384 piv_eval_par.row_end);
1385 if (gci_aoi != NULL) destroy_rect();
1389 } else if ((m_select == V_LINE_MS || m_select == H_LINE_MS)
1390 && display_act->img.exist_img) {
1391 if (display_act->gpd.exist_piv) {
1392 destroy_all_vectors(&display_act->gpd);
1393 disp->display_piv = FALSE;
1396 if (disp->intreg.exist) destroy_all_intregs(disp);
1399 m_select_index_x = 0;
1400 m_select_index_y = 0;
1402 if (m_select == V_LINE_MS) {
1403 piv_eval_par.int_line_row_end = y;
1405 piv_eval_par.row_start = piv_eval_par.int_line_row_start;
1406 piv_eval_par.row_end = piv_eval_par.int_line_row_end;
1407 piv_eval_par.col_start = piv_eval_par.int_line_col -
1408 piv_eval_par.int_size_2 / 2
1409 /* + piv_eval_par.pre_shift_col */
1410 + 1;
1412 piv_eval_par.col_end = piv_eval_par.int_line_col +
1413 piv_eval_par.int_size_2 / 2 +
1414 piv_eval_par.pre_shift_col ;
1416 } else {
1417 piv_eval_par.int_line_col_end = x;
1419 piv_eval_par.col_start = piv_eval_par.int_line_col_start;
1420 piv_eval_par.col_end = piv_eval_par.int_line_col_end;
1421 piv_eval_par.row_start = piv_eval_par.int_line_row -
1422 piv_eval_par.int_size_2 / 2
1423 /* + piv_eval_par.pre_shift_row */
1424 + 1;
1426 piv_eval_par.row_end = piv_eval_par.int_line_row +
1427 piv_eval_par.int_size_2 / 2 +
1428 piv_eval_par.pre_shift_col;
1431 if (gci_line != NULL) destroy_line();
1432 if (!disp->display_intregs
1433 && GTK_CHECK_MENU_ITEM(view_menu_display4)->active) {
1434 show_all_intregs(disp);
1435 disp->display_intregs = TRUE;
1438 * updating entry's for col/row_start_end
1441 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1442 (gpiv->piveval->spinbutton_colstart),
1443 piv_eval_par.col_start);
1444 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1445 (gpiv->piveval->spinbutton_rowstart),
1446 piv_eval_par.row_start);
1447 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1448 (gpiv->piveval->spinbutton_colend),
1449 piv_eval_par.col_end);
1450 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1451 (gpiv->piveval->spinbutton_rowend),
1452 piv_eval_par.row_end);
1456 } else if (m_select == ENABLE_AREA_MS && gci_aoi != NULL) {
1457 enable_col_end = x;
1458 enable_row_end = y;
1459 if (display_act->gpd.exist_piv) {
1460 for (i = 0; i < display_act->gpd.piv_data.ny; i++) {
1461 for (j = 0; j < display_act->gpd.piv_data.nx; j++) {
1462 if (disp->gpd.piv_data.point_x[i][j] >=
1463 enable_col_start
1464 && disp->gpd.piv_data.point_x[i][j] <
1465 enable_col_end
1466 && disp->gpd.piv_data.point_y[i][j] >=
1467 enable_row_start
1468 && disp->gpd.piv_data.point_y[i][j] <
1469 enable_row_end) {
1470 disp->gpd.piv_data.peak_no[i][j] = 1;
1471 if (disp->display_piv)
1472 update_vector(i, j, &display_act->gpd);
1478 if (gci_aoi != NULL) destroy_rect();
1482 } else if (m_select == DISABLE_AREA_MS && gci_aoi != NULL) {
1483 enable_col_end = x;
1484 enable_row_end = y;
1485 if (display_act->gpd.exist_piv) {
1486 for (i = 0; i < display_act->gpd.piv_data.ny; i++) {
1487 for (j = 0; j < display_act->gpd.piv_data.nx; j++) {
1488 if (display_act->gpd.piv_data.point_x[i][j] >=
1489 enable_col_start
1490 && display_act->gpd.piv_data.point_x[i][j] <
1491 enable_col_end
1492 && display_act->gpd.piv_data.point_y[i][j] >=
1493 enable_row_start
1494 && display_act->gpd.piv_data.point_y[i][j] <
1495 enable_row_end) {
1496 display_act->gpd.piv_data.peak_no[i][j] = -1;
1497 if (disp->display_piv)
1498 update_vector(i, j, &display_act->gpd);
1504 if (gci_aoi != NULL) destroy_rect();
1508 } else if (m_select == SPANLENGTH_MS
1509 && display_act->img.exist_img
1510 && gci_line != NULL
1512 gpiv_var.img_span_px =
1513 sqrt((x - disp->xgrab_first) * (x - disp->xgrab_first)
1514 + (y - disp->ygrab_first) * (y - disp->ygrab_first));
1515 if (gci_line != NULL) destroy_line ();
1517 g_warning("::Hor distance = %d Vert distance = %d; Abs distance = %f",
1518 abs(x - disp->xgrab_first),
1519 abs(y - disp->ygrab_first),
1520 gpiv_var.img_span_px);
1521 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1522 (gpiv->imgh->spinbutton_sscale_px),
1523 gpiv_var.img_span_px
1528 } else if (m_select == V_SPANLENGTH_MS
1529 && display_act->img.exist_img
1530 && gci_line != NULL
1532 gpiv_var.img_span_px = abs(y - disp->ygrab_first);
1533 if (gci_line != NULL) destroy_line ();
1534 g_warning("::distance_y = %d", (gint) gpiv_var.img_span_px);
1535 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1536 (gpiv->imgh->spinbutton_sscale_px),
1537 gpiv_var.img_span_px);
1541 } else if (m_select == H_SPANLENGTH_MS
1542 && display_act->img.exist_img
1543 && gci_line != NULL
1545 gpiv_var.img_span_px = abs(x - disp->xgrab_first);
1546 if (gci_line != NULL) destroy_line ();
1547 g_warning("::distance_x = %d", (gint) gpiv_var.img_span_px);
1548 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1549 (gpiv->imgh->spinbutton_sscale_px),
1550 gpiv_var.img_span_px);
1554 } else if (m_select == NONE
1555 || m_select == SINGLE_AREA_MS
1556 || m_select == SINGLE_POINT_MS
1557 || m_select == DRAG_MS) {
1559 * No action
1561 } else {
1562 g_warning("canvas_display_button_release: should not arrive here");
1566 return TRUE;
1572 gint
1573 canvas_display_leave_notify(GtkWidget * widget,
1574 GdkEventMotion * event)
1576 /* gint x, y; */
1577 /* GdkModifierType state; */
1578 Display * disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
1579 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
1580 GtkWidget * view_menu_display4 =
1581 gtk_object_get_data(GTK_OBJECT(disp->mwin),
1582 "view_menu_display4");
1583 /* Intreg *intreg = disp->intreg; */
1585 gnome_appbar_push(GNOME_APPBAR(disp->appbar),
1586 disp->msg_display_default);
1587 gnome_appbar_push(GNOME_APPBAR(gpiv->appbar), msg_default);
1590 if (m_select == SINGLE_POINT_MS && disp->intreg.exist
1591 /* && !disp->display_intregs */
1594 update_intreg1(m_select_index_y, m_select_index_x, disp);
1595 update_intreg2(m_select_index_y, m_select_index_x, disp);
1597 if (disp->display_intregs) {
1598 show_all_intregs(disp);
1599 disp->display_intregs = TRUE;
1602 if (display_act->gpd.exist_piv && !disp->display_piv) {
1603 show_all_vectors(&display_act->gpd);
1604 disp->display_piv = TRUE;
1608 } else if (m_select == DRAG_MS) {
1609 update_intreg1(disp->index_y_old, disp->index_x_old, disp);
1610 update_intreg2(disp->index_y_old, disp->index_x_old, disp);
1613 } else if (m_select == SINGLE_AREA_MS && disp->intreg.exist) {
1614 update_intreg1(0, 0, disp);
1615 update_intreg2(0, 0, disp);
1619 } else if (m_select == AOI_MS
1620 || m_select == V_LINE_MS
1621 || m_select == H_LINE_MS) {
1622 if (disp->intreg.exist && !disp->display_intregs
1623 && GTK_CHECK_MENU_ITEM(view_menu_display4)->active) {
1624 show_all_intregs(disp);
1625 disp->display_intregs = TRUE;
1628 if (display_act->gpd.exist_piv && !disp->display_piv) {
1629 show_all_vectors(&display_act->gpd);
1630 disp->display_piv = TRUE;
1633 if (gci_line != NULL) {
1634 gtk_object_destroy(GTK_OBJECT(gci_line));
1635 gci_line = NULL;
1642 if (GDK_BUTTON1_MASK) {
1644 * Cancel AOI_MS selection
1646 if (m_select == AOI_MS) {
1647 if (gci_aoi != NULL) {
1648 piv_eval_par.col_start = disp->intreg.col_start_old;
1649 piv_eval_par.row_start = disp->intreg.row_start_old;
1650 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1651 (gpiv->piveval->spinbutton_colstart),
1652 piv_eval_par.col_start);
1653 gtk_spin_button_set_value(GTK_SPIN_BUTTON
1654 (gpiv->piveval->spinbutton_rowstart),
1655 piv_eval_par.row_start);
1656 if (gci_aoi != NULL) destroy_rect();
1659 /* show_all_intregs(disp); */
1661 } else if ( m_select == ENABLE_AREA_MS
1662 || m_select == DISABLE_AREA_MS) {
1663 enable_col_start = 0;
1664 enable_row_start = 0;
1665 enable_col_end = 0;
1666 enable_row_end = 0;
1667 if (gci_aoi != NULL) destroy_rect();
1670 * Cancel V_LINE_MS, LINE_MS selection
1671 * (V_, H_) SPANLENGTH_MS
1673 } else if (m_select == V_LINE_MS
1674 || m_select == H_LINE_MS
1675 || m_select == SPANLENGTH_MS
1676 || m_select == V_SPANLENGTH_MS
1677 || m_select == H_SPANLENGTH_MS
1679 if (gci_line != NULL) destroy_line();
1687 * General
1689 if (cursor != NULL) {
1690 gdk_cursor_destroy(cursor);
1691 cursor = NULL;
1694 if (disp->intreg.gci_intreg2[disp->index_y_old][disp->index_x_old]
1695 != NULL) {
1696 update_intreg2(disp->index_y_old, disp->index_x_old, disp);
1699 if (disp->intreg.gci_intreg1[disp->index_y_old][disp->index_x_old]
1700 != NULL) {
1701 update_intreg1(disp->index_y_old, disp->index_x_old, disp);
1704 disp->index_x_old = 0;
1705 disp->index_y_old = 0;
1707 return TRUE;
1712 void
1713 view_toggle_stretch_display(GtkWidget * widget,
1714 gpointer data)
1716 Display * disp = display_act;
1717 gint screen_width = gdk_screen_width();
1718 gint screen_height = gdk_screen_height();
1719 gint new_width = (gint) (disp->zoom_factor * gpiv_par.img_width +
1720 VIEW_HMARGE);
1721 gint new_height = (gint) (disp->zoom_factor * gpiv_par.img_height +
1722 VIEW_VMARGE);
1724 if (new_width < screen_width && new_height < screen_height) {
1725 gnome_win_hints_set_state(disp->mwin, 0);
1726 gdk_window_resize(disp->mwin->window,
1727 new_width, new_height);
1729 } else if (new_width > screen_width && new_height < screen_height) {
1730 gnome_win_hints_set_state(disp->mwin,
1731 WIN_STATE_MAXIMIZED_HORIZ);
1733 } else if (new_width < screen_width && new_height > screen_height) {
1734 gnome_win_hints_set_state(disp->mwin,
1735 WIN_STATE_MAXIMIZED_VERT);
1737 } else if (new_width > screen_width && new_height > screen_height) {
1738 gnome_win_hints_set_state(disp->mwin,
1739 WIN_STATE_MAXIMIZED_HORIZ +
1740 WIN_STATE_MAXIMIZED_VERT);
1741 } else {
1742 g_warning("view_toggle_stretch_display: Should not arrive here");
1746 gtk_widget_set_usize (disp->canvas,
1747 (gint) (disp->zoom_factor * gpiv_par.img_width),
1748 (gint) (disp->zoom_factor * gpiv_par.img_height));
1749 disp->stretch_window_tmp = TRUE;
1750 disp->zoom_factor_old = disp->zoom_factor;
1753 void
1754 view_toggle_img1(GtkWidget * widget,
1755 gpointer data)
1757 if (display_act->img.exist_img) {
1758 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1759 display_act->display_img1 = TRUE;
1760 show_img1(display_act);
1761 } else {
1762 display_act->display_img1 = FALSE;
1763 hide_img1(display_act);
1769 void view_toggle_img2(GtkWidget * widget, gpointer data)
1771 if (display_act->img.exist_img) {
1772 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1773 display_act->display_img2 = TRUE;
1774 show_img2(display_act);
1775 } else {
1776 display_act->display_img2 = FALSE;
1777 hide_img2(display_act);
1783 void view_toggle_intregs(GtkWidget * widget, gpointer data)
1785 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1786 show_all_intregs(display_act);
1787 /* if (display_act->intreg.exist != 1) */
1788 /* create_all_intregs(display_act); */
1789 display_act->display_intregs = TRUE;
1790 } else {
1791 hide_all_intregs(display_act);
1792 display_act->display_intregs = FALSE;
1797 void view_toggle_piv(GtkWidget * widget, gpointer data)
1799 if (display_act->gpd.exist_piv) {
1800 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1801 display_act->display_piv = TRUE;
1802 show_all_vectors(&display_act->gpd);
1803 } else {
1804 display_act->display_piv = FALSE;
1805 hide_all_vectors(&display_act->gpd);
1811 void view_toggle_vor(GtkWidget * widget, gpointer data)
1813 if (display_act->gpd.exist_vor) {
1814 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1815 display_act->display_vor = TRUE;
1816 show_all_scalars(&display_act->gpd.vor_data, VORTICITY);
1817 } else {
1818 display_act->display_vor = FALSE;
1819 hide_all_scalars(&display_act->gpd.vor_data, VORTICITY);
1825 void
1826 view_toggle_sstrain(GtkWidget *widget, gpointer data)
1828 if (display_act->gpd.exist_sstrain) {
1829 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1830 display_act->display_sstrain = TRUE;
1831 show_all_scalars(&display_act->gpd.sstrain_data, S_STRAIN);
1832 } else {
1833 display_act->display_sstrain = FALSE;
1834 hide_all_scalars(&display_act->gpd.sstrain_data, S_STRAIN);
1840 void
1841 view_toggle_nstrain(GtkWidget *widget, gpointer data)
1843 if (display_act->gpd.exist_nstrain) {
1844 if (GTK_CHECK_MENU_ITEM(widget)->active) {
1845 display_act->display_nstrain = TRUE;
1846 show_all_scalars(&display_act->gpd.nstrain_data, N_STRAIN);
1847 } else {
1848 display_act->display_nstrain = FALSE;
1849 hide_all_scalars(&display_act->gpd.nstrain_data, N_STRAIN);
1855 void select_vectorscale(gpointer data, guint action, GtkWidget * widget)
1856 /*--------------------- Setting vectr_scale from display pop-up menu */
1858 /* if (display () == NULL) return; */
1859 gpiv_par.vector_scale = action;
1860 update_all_vectors(&display_act->gpd);
1864 void
1865 nav_popup_click_handler(GtkWidget * widget, GdkEventButton * event,
1866 gpointer data)
1868 /* Seee gimp: nav_window.c */
1873 void on_view_options_clicked(GtkButton * button, gpointer user_data)
1881 * img_display callbacks
1883 /* gboolean */
1884 /* on_darea_img_expose(GtkWidget * widget, */
1885 /* GdkEventExpose * event, gpointer user_data) */
1886 /* { */
1887 /* gdk_draw_gray_image(widget->window, */
1888 /* widget->style->fg_gc[GTK_STATE_NORMAL], */
1889 /* 0, */
1890 /* 0, */
1892 * 4-byte aligned width
1894 /* display_act->img.rgb_img_width, */
1895 /* gpiv_par.img_height, */
1896 /* GDK_RGB_DITHER_MAX, */
1897 /* display_act->img.graybuf_img, */
1899 * WIDTH
1901 /* display_act->img.rgb_img_width); */
1903 /* return TRUE; */
1904 /* } */
1908 * Other image function
1911 void
1912 create_img(Display * disp)
1913 /* -------------------------------------------------------------------
1914 * image in gnome canvas
1915 * row stride; each row is a 4-byte buffer array
1919 ImagePar image_par = disp->img.image_par;
1920 guchar *pos1 = NULL, *pos2 = NULL;
1921 gint i, j;
1922 GdkPixbuf *pixbuf1 = NULL, *pixbuf2 = NULL;
1924 gint depth = 8;
1926 assert (disp != NULL);
1927 assert (disp->img.img1 != NULL);
1928 assert (disp->img.exist_img == 1);
1931 disp->img.rgb_img_width = gpiv_par.img_width * 3;
1932 while ((disp->img.rgb_img_width) % 4 != 0) {
1933 disp->img.rgb_img_width++;
1936 disp->img.rgbbuf_img1 = g_malloc(disp->img.rgb_img_width * 3 *
1937 gpiv_par.img_height);
1939 pixbuf1 = gdk_pixbuf_new_from_data(disp->img.rgbbuf_img1,
1940 GDK_COLORSPACE_RGB,
1941 FALSE, /* gboolean has_alpha */
1942 depth, /* image_par.nbits */
1943 gpiv_par.img_width,
1944 gpiv_par.img_height,
1945 disp->img.rgb_img_width, /* rowstride */
1946 NULL,
1947 NULL);
1949 disp->img.gci_img1 =
1950 gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS
1951 (disp->canvas)),
1952 gnome_canvas_pixbuf_get_type (),
1953 "pixbuf", pixbuf1,
1954 NULL);
1956 pos1 = disp->img.rgbbuf_img1;
1958 for (i = 0; i < gpiv_par.img_height; i++) {
1959 for (j = 0; j < gpiv_par.img_width; j++) {
1960 *pos1++ = disp->img.img1[i][j];
1961 *pos1++ = disp->img.img1[i][j];
1962 *pos1++ = disp->img.img1[i][j];
1966 gdk_pixbuf_unref (pixbuf1);
1968 if(image_par.x_corr) {
1969 pos2 = NULL;
1971 disp->img.rgbbuf_img2 = g_malloc(disp->img.rgb_img_width * 3 *
1972 gpiv_par.img_height);
1974 pixbuf2 = gdk_pixbuf_new_from_data(disp->img.rgbbuf_img2,
1975 GDK_COLORSPACE_RGB,
1976 FALSE, /* gboolean has_alpha */
1977 depth, /* image_par.nbits */
1978 gpiv_par.img_width,
1979 gpiv_par.img_height,
1980 disp->img.rgb_img_width, /* rowstride */
1981 NULL,
1982 NULL);
1984 disp->img.gci_img2 =
1985 gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS
1986 (disp->canvas)),
1987 gnome_canvas_pixbuf_get_type (),
1988 "pixbuf", pixbuf2,
1989 NULL);
1991 pos2 = disp->img.rgbbuf_img2;
1993 for (i = 0; i < gpiv_par.img_height; i++) {
1994 for (j = 0; j < gpiv_par.img_width; j++) {
1995 *pos2++ = disp->img.img2[i][j];
1996 *pos2++ = disp->img.img2[i][j];
1997 *pos2++ = disp->img.img2[i][j];
2001 gdk_pixbuf_unref (pixbuf2 );
2003 } else {
2004 disp->img.gci_img2 = disp->img.gci_img2;
2010 void
2011 hide_img1(Display * disp)
2013 assert (disp != NULL);
2014 assert (disp->img.exist_img == 1);
2015 gnome_canvas_item_hide(GNOME_CANVAS_ITEM
2016 (disp->img.gci_img1));
2020 void
2021 show_img1(Display * disp)
2023 assert (disp != NULL);
2024 assert (disp->img.exist_img == 1);
2025 gnome_canvas_item_show(GNOME_CANVAS_ITEM
2026 (disp->img.gci_img1));
2030 void
2031 hide_img2(Display * disp)
2033 assert (disp != NULL);
2034 assert (disp->img.exist_img == 1);
2035 gnome_canvas_item_hide(GNOME_CANVAS_ITEM
2036 (disp->img.gci_img2));
2040 void
2041 show_img2(Display * disp)
2043 assert (disp != NULL);
2044 assert (disp->img.exist_img == 1);
2045 gnome_canvas_item_show(GNOME_CANVAS_ITEM
2046 (disp->img.gci_img2));
2051 void
2052 destroy_img(Display * disp)
2054 assert (disp->img.gci_img1 != NULL);
2055 gtk_object_destroy(GTK_OBJECT
2056 (disp->img.gci_img1));
2057 /* g_free(disp->img.gci_img1); */
2058 disp->img.gci_img1 = NULL;
2060 if(image_par.x_corr) {
2061 gtk_object_destroy(GTK_OBJECT
2062 (disp->img.gci_img2));
2063 disp->img.gci_img2 = NULL;
2070 * Other display functions than callbacks
2074 void
2075 create_background(Display *disp)
2076 /* --------------------------------------------- Displays backgroundcolor */
2078 disp->gci_bg = gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(disp->canvas)),
2079 gnome_canvas_rect_get_type(),
2080 "x1", (double) 0,
2081 "y1", (double) 0,
2082 "x2", (double) gpiv_par.img_width,
2083 "y2", (double) gpiv_par.img_height,
2084 "fill_color", "darkblue",
2085 "width_units", 1.0,
2086 NULL);
2091 void
2092 destroy_background(Display *disp)
2094 assert (disp->gci_bg != NULL);
2095 gtk_object_destroy(GTK_OBJECT
2096 (disp->gci_bg));
2097 disp->gci_bg = NULL;
2102 void
2103 create_all_intregs(Display * disp)
2104 /* ----------------------------------- Creates all interrogation areas */
2106 if (disp != NULL) {
2107 if (disp->intreg.exist != 1) {
2108 create_intreg_data(disp);
2110 create_all_intregs2(disp);
2111 create_all_intregs1(disp);
2112 disp->intreg.exist = TRUE;
2113 disp->display_intregs = TRUE;
2115 disp->intreg.row_start_old = 0;
2116 disp->intreg.row_start = piv_eval_par.row_start;
2117 disp->intreg.row_end = piv_eval_par.row_end;
2118 disp->intreg.col_start_old = 0;
2119 disp->intreg.col_start = piv_eval_par.col_start;
2120 disp->intreg.col_end = piv_eval_par.col_end;
2121 disp->intreg.int_size_1 = piv_eval_par.int_size_1;
2122 disp->intreg.int_size_2 = piv_eval_par.int_size_2;
2123 disp->intreg.int_shift = piv_eval_par.int_shift;
2124 disp->intreg.pre_shift_row = piv_eval_par.pre_shift_row;
2125 disp->intreg.pre_shift_col = piv_eval_par.pre_shift_col;
2130 void
2131 destroy_all_intregs(Display * disp)
2132 /* ----------------------------------- Destroys all interrogation areas */
2134 if (disp != NULL) {
2135 hide_all_intregs1(disp);
2136 destroy_all_intregs1(disp);
2137 hide_all_intregs2(disp);
2138 destroy_all_intregs2(disp);
2139 destroy_intreg_data(disp);
2140 disp->display_intregs = FALSE;
2145 void
2146 show_all_intregs(Display * disp)
2147 /* ----------------------------------- Shows all interrogation areas */
2149 assert (disp != NULL);
2151 if (disp->intreg.exist == 0) {
2152 create_all_intregs(disp);
2154 show_all_intregs2(disp);
2155 show_all_intregs1(disp);
2156 /* disp->display_intregs = TRUE; */
2157 /* } */
2161 void
2162 hide_all_intregs(Display * disp)
2163 /* ----------------------------------- Hides all interrogation areas */
2165 assert (disp != NULL);
2166 /* assert (disp->intreg != NULL); */
2167 /* assert (disp->intreg.data != NULL); */
2169 hide_all_intregs2(disp);
2170 hide_all_intregs1(disp);
2171 /* disp->display_intregs = FALSE; */
2175 void
2176 create_intreg_data(Display * disp)
2178 char *err_msg = NULL;
2179 PivData data;
2180 data.point_x = NULL;
2181 data.point_y = NULL;
2182 data.dx = NULL;
2183 data.dy = NULL;
2184 data.snr = NULL;
2185 data.peak_no = NULL;
2187 if ((err_msg =
2188 gpiv_piv_count_pivdata_fromimage(&data, image_par, piv_eval_par))
2189 != NULL) gtk_error ("%s: %s", RCSID, err_msg);
2191 gpiv_alloc_pivdata(&data);
2192 disp->intreg.exist = TRUE;
2193 if ((err_msg =
2194 gpiv_piv_select_int_point(&data, image_par, piv_eval_par))
2195 != NULL) gtk_error ("%s: %s", RCSID, err_msg);
2197 disp->intreg.data = data;
2201 void
2202 destroy_intreg_data(Display * disp)
2204 if ( disp->intreg.gci_intreg1[0][0] == NULL
2205 && disp->intreg.gci_intreg1[0][0] == NULL) {
2206 gpiv_free_pivdata(&disp->intreg.data);
2207 /* disp->intreg.data = NULL; */
2208 disp->intreg.exist = 0;
2209 /* disp->intreg = NULL; */
2214 void
2215 create_all_intregs1(Display * disp)
2216 /* ------------------------- Displays all first interrogation areas */
2218 int i = 0, j;
2219 gint nx = 0;
2220 gint ny = 0;
2222 assert (disp != NULL);
2223 if (disp->intreg.exist != 1)
2224 create_intreg_data(disp);
2226 nx = disp->intreg.data.nx;
2227 ny = disp->intreg.data.ny;
2228 for (i = 0; i < ny; i++) {
2229 for (j = 0; j < nx ; j++) {
2230 create_intreg1(i, j, disp);
2237 void create_intreg1(gint i,
2238 gint j,
2239 Display * disp)
2240 /* ------------------------------------ Displays first interrogation area */
2242 int start_x = 0, start_y = 0, end_x = 0, end_y = 0;
2243 float x, y;
2245 assert (disp != NULL);
2246 assert (disp->intreg.exist == 1);
2248 x = disp->intreg.data.point_x[i][j];
2249 y = disp->intreg.data.point_y[i][j];
2252 /* ------------------------------ Using centre points of interr regs */
2253 start_x = (int) x - piv_eval_par.int_size_1 / 2;
2254 start_y = (int) y - piv_eval_par.int_size_1 / 2;
2255 end_x = (int) x + piv_eval_par.int_size_1 / 2;
2256 end_y = (int) y + piv_eval_par.int_size_1 / 2;
2258 disp->intreg.gci_intreg1[i][j] =
2259 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS
2260 (disp->canvas)),
2261 gnome_canvas_rect_get_type(),
2262 "x1", (double) start_x,
2263 "y1", (double) start_y,
2264 "x2", (double) end_x,
2265 "y2", (double) end_y,
2266 "outline_color", "blue",
2267 "width_units", (double) THICKNESS,
2268 NULL);
2273 void
2274 update_intreg1(gint i,
2275 gint j,
2276 Display * disp)
2277 /* ------------------------------------ Updates first interrogation area */
2279 int start_x = 0, start_y = 0, end_x = 0, end_y = 0;
2280 float x, y;
2282 assert (disp != NULL);
2283 assert (disp->intreg.exist == 1);
2284 assert (disp->intreg.gci_intreg1[i][j] != NULL);
2286 x = disp->intreg.data.point_x[i][j];
2287 y = disp->intreg.data.point_y[i][j];
2289 /* ------------------------------ Using centre points of interr regs */
2290 start_x = (int) x - piv_eval_par.int_size_1 / 2;
2291 start_y = (int) y - piv_eval_par.int_size_1 / 2;
2292 end_x = (int) x + piv_eval_par.int_size_1 / 2;
2293 end_y = (int) y + piv_eval_par.int_size_1 / 2;
2295 gnome_canvas_item_set(GNOME_CANVAS_ITEM
2296 (disp->intreg.gci_intreg1[i][j]),
2297 "x1", (double) start_x,
2298 "y1", (double) start_y,
2299 "x2", (double) end_x,
2300 "y2", (double) end_y,
2301 "outline_color", "blue",
2302 "width_units", (double) THICKNESS,
2303 NULL);
2307 void
2308 show_all_intregs1(Display * disp)
2309 /* ----------------------------------- Shows 1st interrogation areas */
2311 int i = 0, j = 0;
2312 gint nx = 0, ny = 0;
2314 assert (disp != NULL);
2315 assert (disp->intreg.exist == 1);
2317 nx = disp->intreg.data.nx;
2318 ny = disp->intreg.data.ny;
2320 for (i = 0; i < ny; i++) {
2321 for (j = 0; j < nx; j++) {
2322 assert (disp->intreg.gci_intreg1[i][j] != NULL);
2323 gnome_canvas_item_show(GNOME_CANVAS_ITEM
2324 (disp->intreg.gci_intreg1[i][j]));
2332 void
2333 hide_all_intregs1(Display * disp)
2334 /* ----------------------------------- Hides 1st interrogation areas */
2336 int i = 0, j = 0;
2337 gint nx = 0, ny = 0;
2339 assert (disp != NULL);
2340 assert (disp->intreg.exist == 1);
2342 nx = disp->intreg.data.nx;
2343 ny = disp->intreg.data.ny;
2344 for (i = 0; i < ny; i++) {
2345 for (j = 0; j < nx; j++) {
2346 assert (disp->intreg.gci_intreg1[i][j] != NULL);
2347 gnome_canvas_item_hide(GNOME_CANVAS_ITEM
2348 (disp->intreg.gci_intreg1[i][j]));
2354 void
2355 destroy_all_intregs1(Display * disp)
2356 /* ------------------------------- Destroys 1st interrogation areas */
2358 int i = 0, j = 0;
2359 int nx = 0, ny = 0;
2361 assert (disp != NULL);
2362 assert (disp->intreg.exist == 1);
2364 nx = disp->intreg.data.nx;
2365 ny = disp->intreg.data.ny;
2367 for (i = 0; i < ny; i++) {
2368 for (j = 0; j < nx; j++) {
2369 assert (disp->intreg.gci_intreg1[i][j] != NULL);
2370 gtk_object_destroy(GTK_OBJECT
2371 (disp->intreg.gci_intreg1[i][j]));
2372 disp->intreg.gci_intreg1[i][j] = NULL;
2380 void
2381 create_all_intregs2(Display * disp)
2382 /* ----------------------- Displays all second interrogation areas */
2384 int i, j;
2385 int nx, ny;
2387 assert (disp != NULL);
2388 if (disp->intreg.exist != 1)
2389 create_intreg_data(disp);
2391 nx = disp->intreg.data.nx;
2392 ny = disp->intreg.data.ny;
2394 for (i = 0; i < ny; i++) {
2395 for (j = 0; j < nx; j++) {
2396 create_intreg2(i, j, disp);
2403 void
2404 create_intreg2(gint i,
2405 gint j,
2406 Display * disp)
2407 /* ----------------------------- Displays second interrogation area */
2409 int start_x, start_y, end_x, end_y;
2410 float x, y;
2412 assert (disp != NULL);
2413 assert (disp->intreg.exist == 1);
2415 x = disp->intreg.data.point_x[i][j];
2416 y = disp->intreg.data.point_y[i][j];
2418 /* --------------------------------------------------------with lines */
2419 start_x = (int) x - piv_eval_par.int_size_2 / 2 +
2420 piv_eval_par.pre_shift_col;
2421 start_y = (int) y - piv_eval_par.int_size_2 / 2 +
2422 piv_eval_par.pre_shift_row;
2423 end_x = (int) x + piv_eval_par.int_size_2 / 2 +
2424 piv_eval_par.pre_shift_col;
2425 end_y = (int) y + piv_eval_par.int_size_2 / 2 +
2426 piv_eval_par.pre_shift_row;
2428 disp->intreg.gci_intreg2[i][j] =
2429 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS
2430 (disp->canvas)),
2431 gnome_canvas_rect_get_type(),
2432 "x1", (double) start_x,
2433 "y1", (double) start_y,
2434 "x2", (double) end_x,
2435 "y2", (double) end_y,
2436 "outline_color", "yellow",
2437 "width_units", (double) THICKNESS,
2438 NULL);
2442 void
2443 update_intreg2(gint i, gint j, Display * disp)
2444 /* ------------------------------------ Updates second interrogation area */
2446 int start_x, start_y, end_x, end_y;
2447 float x, y;
2449 assert (disp != NULL);
2450 assert (disp->intreg.exist == 1);
2451 assert (disp->intreg.gci_intreg1[i][j] != NULL);
2453 x = disp->intreg.data.point_x[i][j] + piv_eval_par.pre_shift_col;
2454 y = disp->intreg.data.point_y[i][j] + piv_eval_par.pre_shift_row;
2456 /* ------------------------------ Using centre points of interr regs */
2457 start_x = (int) x - piv_eval_par.int_size_2 / 2;
2458 start_y = (int) y - piv_eval_par.int_size_2 / 2;
2459 end_x = (int) x + piv_eval_par.int_size_2 / 2;
2460 end_y = (int) y + piv_eval_par.int_size_2 / 2;
2462 if (disp->intreg.gci_intreg2[i][j] != NULL) {
2463 gnome_canvas_item_set(GNOME_CANVAS_ITEM
2464 (disp->intreg.gci_intreg2[i][j]),
2465 "x1", (double) start_x,
2466 "y1", (double) start_y,
2467 "x2", (double) end_x,
2468 "y2", (double) end_y,
2469 "outline_color", "yellow",
2470 "width_units", (double) THICKNESS,
2471 NULL);
2476 void
2477 show_all_intregs2(Display * disp)
2478 /* ----------------------------------- Shows 2nd interrogation areas */
2480 int i, j;
2481 int nx, ny;
2483 assert (disp != NULL);
2484 assert (disp->intreg.exist == 1);
2486 nx = disp->intreg.data.nx;
2487 ny = disp->intreg.data.ny;
2489 for (i = 0; i < ny; i++) {
2490 for (j = 0; j < nx; j++) {
2491 assert (disp->intreg.gci_intreg2[i][j] != NULL);
2492 gnome_canvas_item_show(GNOME_CANVAS_ITEM
2493 (disp->intreg.gci_intreg2[i][j]));
2501 void
2502 hide_all_intregs2(Display * disp)
2503 /* ----------------------------------- Hides 2nd interrogation areas */
2505 int i, j;
2506 int nx, ny;
2508 assert (disp != NULL);
2509 assert (disp->intreg.exist == 1);
2511 nx = disp->intreg.data.nx;
2512 ny = disp->intreg.data.ny;
2514 for (i = 0; i < ny; i++) {
2515 for (j = 0; j < nx; j++) {
2516 assert (disp->intreg.gci_intreg2[i][j] != NULL);
2517 gnome_canvas_item_hide(GNOME_CANVAS_ITEM
2518 (disp->intreg.gci_intreg2[i][j]));
2525 void
2526 destroy_all_intregs2(Display * disp)
2527 /* ----------------------------------- Destroys 2nd interrogation areas */
2529 int i, j;
2530 int nx, ny;
2532 assert (disp != NULL);
2533 assert (disp->intreg.exist == 1);
2535 nx = disp->intreg.data.nx;
2536 ny = disp->intreg.data.ny;
2538 for (i = 0; i < ny; i++) {
2539 for (j = 0; j < nx; j++) {
2540 assert (disp->intreg.gci_intreg2[i][j] != NULL);
2541 gtk_object_destroy(GTK_OBJECT
2542 (disp->intreg.gci_intreg2[i][j]));
2543 disp->intreg.gci_intreg2[i][j] = NULL;
2550 void
2551 display_vector(gint i, gint j,
2552 GpivData * gpd /* PivData piv_data */)
2553 /* ----------------------- Displays a single PIV vector on a Gnome canvas */
2555 GnomeCanvasPoints *points;
2556 Display *disp = display_act;
2558 float **point_x = gpd->piv_data.point_x;
2559 float **point_y = gpd->piv_data.point_y;
2560 float **dx = gpd->piv_data.dx, **dy = gpd->piv_data.dy;
2561 int **peak_no = gpd->piv_data.peak_no;
2562 /* GtkWidget *display=gpd->display; */
2563 /* fprintf(stderr,"\nentering display_all_pivdata\n"); */
2564 gchar *color;
2565 points = gnome_canvas_points_new(2);
2567 /*---------------------------------------------------------------------
2568 fill out the points */
2570 points->coords[0] = point_x[i][j];
2571 points->coords[1] = point_y[i][j];
2572 points->coords[2] = point_x[i][j] + dx[i][j] * gpiv_par.vector_scale;
2573 points->coords[3] = point_y[i][j] + dy[i][j] * gpiv_par.vector_scale;
2575 if (peak_no[i][j] == -1) {
2576 color="gray";
2577 } else if (peak_no[i][j] == 0) {
2578 color="lightblue";
2579 } else if (peak_no[i][j] == 1) {
2580 color="green";
2581 } else if (peak_no[i][j] == 2) {
2582 color="yellow";
2583 } else {
2584 /* if (peak_no[i][j] == 3) */
2585 color="red";
2589 gpd->gci_vector[i][j] =
2590 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(disp->canvas)),
2591 gnome_canvas_line_get_type(),
2592 "points", points,
2593 "fill_color", color,
2594 "width_units", (double) THICKNESS,
2595 "last_arrowhead", TRUE,
2596 "arrow_shape_a", (double) ARROW_LENGTH,
2597 "arrow_shape_b", (double) ARROW_EDGE,
2598 "arrow_shape_c", (double) ARROW_WIDTH,
2599 NULL);
2601 gnome_canvas_points_free(points);
2607 void
2608 update_vector(gint i,
2609 gint j,
2610 GpivData * gpd)
2611 /* ------------------- Updates a single PIV vector on a Gnome canvas */
2614 GnomeCanvasPoints *points;
2616 float **point_x = gpd->piv_data.point_x, **point_y =
2617 gpd->piv_data.point_y;
2618 float **dx = gpd->piv_data.dx, **dy = gpd->piv_data.dy;
2619 float **snr = gpd->piv_data.snr;
2620 int **peak_no = gpd->piv_data.peak_no;
2622 /* GtkWidget *display=gpd->display; */
2623 /* fprintf(stderr,"\nentering display_all_pivdata\n"); */
2625 gchar *color = NULL;
2626 points = gnome_canvas_points_new(2);
2627 /*-- fill out the points -----------------------------------------------*/
2628 points->coords[0] = point_x[i][j];
2629 points->coords[1] = point_y[i][j];
2630 points->coords[2] = point_x[i][j] + dx[i][j] * gpiv_par.vector_scale;
2631 points->coords[3] = point_y[i][j] + dy[i][j] * gpiv_par.vector_scale;
2634 if (v_color == SHOW_PEAKNR) {
2635 if (peak_no[i][j] == -1) {
2636 color = "red";
2637 } else if (peak_no[i][j] == 0) {
2638 color = "lightblue";
2639 } else if (peak_no[i][j] == 1) {
2640 color = "green";
2641 } else if (peak_no[i][j] == 2) {
2642 color = "yellow";
2643 } else {
2644 /* if (peak_no[i][j] == 3) */
2645 color = "gray";
2647 } else if (v_color == SHOW_SNR) {
2648 if (snr[i][j] >= piv_valid_par.residu_max) {
2649 color = "red";
2650 } else {
2651 color = "green";
2655 if (gpd->gci_vector[i][j] != NULL) {
2656 gnome_canvas_item_set(GNOME_CANVAS_ITEM(gpd->gci_vector[i][j]),
2657 "points", points,
2658 "fill_color", color,
2659 "width_units", (double) THICKNESS,
2660 "last_arrowhead", TRUE,
2661 "arrow_shape_a", (double) ARROW_LENGTH,
2662 "arrow_shape_b", (double) ARROW_EDGE,
2663 "arrow_shape_c", (double) ARROW_WIDTH,
2664 NULL);
2667 gnome_canvas_points_free(points);
2672 void
2673 destroy_vector(gint i,
2674 gint j,
2675 GpivData * gpd)
2676 /* ------------------- Detroys a single PIV vector on a Gnome canvas */
2680 if (gpd->gci_vector[i][j] != NULL) {
2681 gtk_object_destroy(GTK_OBJECT (gpd->gci_vector[i][j]));
2682 gpd->gci_vector[i][j] = NULL;
2688 void
2689 display_all_vectors(GpivData * gpd)
2690 /* ---------------------- Displays all PIV vectors on a Gnome canvas */
2692 int i, j;
2693 gint nx = gpd->piv_data.nx, ny = gpd->piv_data.ny;
2695 for (i = 0; i < ny; i++) {
2696 for (j = 0; j < nx; j++) {
2697 display_vector(i, j, gpd);
2705 void
2706 show_all_vectors(GpivData * gpd)
2707 /* ------------------------- Shows all PIV vectors on a Gnome canvas */
2709 int i, j;
2710 gint nx = gpd->piv_data.nx, ny = gpd->piv_data.ny;
2712 for (i = 0; i < ny; i++) {
2713 for (j = 0; j < nx; j++) {
2714 gnome_canvas_item_show(GNOME_CANVAS_ITEM
2715 (gpd->gci_vector[i][j]));
2721 void
2722 hide_all_vectors(GpivData * gpd)
2723 /* ------------------------ Hides all PIV vectors on a Gnome canvas */
2725 int i, j;
2726 gint nx = gpd->piv_data.nx, ny = gpd->piv_data.ny;
2728 for (i = 0; i < ny; i++) {
2729 for (j = 0; j < nx; j++) {
2730 gnome_canvas_item_hide(GNOME_CANVAS_ITEM
2731 (gpd->gci_vector[i][j]));
2737 void
2738 update_all_vectors(GpivData * gpd)
2739 /* ----------------------------- Scales PIV vectors for Gnome canvas */
2741 int i, j;
2742 GnomeCanvasPoints *points;
2744 int nx = gpd->piv_data.nx, ny = gpd->piv_data.ny;
2746 points = gnome_canvas_points_new(2);
2748 for (i = 0; i < ny; i++) {
2749 for (j = 0; j < nx; j++) {
2750 update_vector(i, j, gpd);
2758 void
2759 destroy_all_vectors(GpivData * gpd)
2760 /* ---------------------- Destroys all PIV vectors on a Gnome canvas */
2762 int i, j;
2763 gint nx = gpd->piv_data.nx, ny = gpd->piv_data.ny;
2765 for (i = 0; i < ny; i++) {
2766 for (j = 0; j < nx; j++) {
2767 destroy_vector(i, j, gpd);
2775 void
2776 display_scalar(gint i,
2777 gint j,
2778 ScalarData * scalar_data,
2779 gint type,
2780 /* GnomeCanvasItem * gci_scalar, */
2781 guint col_val)
2782 /* ------------------------------------ Displays a scalar gnome canvas item
2783 by coloring the interrogation area */
2785 float **x = scalar_data->point_x, **y = scalar_data->point_y;
2786 int start_x, start_y, end_x, end_y;
2788 GnomeCanvasPoints *points;
2789 points = gnome_canvas_points_new(5);
2792 /* ------------------------------ Using centre points of interr regs */
2793 start_x = (int) x[i][j] - piv_eval_par.int_size_1 / 2;
2794 start_y = (int) y[i][j] - piv_eval_par.int_size_1 / 2;
2795 end_x = (int) x[i][j] + piv_eval_par.int_size_1 / 2;
2796 end_y = (int) y[i][j] + piv_eval_par.int_size_1 / 2;
2798 if (type == VORTICITY) {
2799 display_act->gpd.gci_scalar_vor[i][j] =
2800 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(display_act->canvas)),
2801 gnome_canvas_rect_get_type(),
2802 "x1", (double) start_x,
2803 "y1", (double) start_y,
2804 "x2", (double) end_x,
2805 "y2", (double) end_y,
2806 "fill_color_rgba", col_val,
2807 NULL);
2810 if (type == S_STRAIN) {
2811 display_act->gpd.gci_scalar_sstrain[i][j] =
2812 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(display_act->canvas)),
2813 gnome_canvas_rect_get_type(),
2814 "x1", (double) start_x,
2815 "y1", (double) start_y,
2816 "x2", (double) end_x,
2817 "y2", (double) end_y,
2818 "fill_color_rgba", col_val,
2819 NULL);
2822 if (type == N_STRAIN) {
2823 display_act->gpd.gci_scalar_nstrain[i][j] =
2824 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(display_act->canvas)),
2825 gnome_canvas_rect_get_type(),
2826 "x1", (double) start_x,
2827 "y1", (double) start_y,
2828 "x2", (double) end_x,
2829 "y2", (double) end_y,
2830 "fill_color_rgba", col_val,
2831 NULL);
2834 gnome_canvas_points_free(points);
2839 void
2840 display_all_scalars(ScalarData * scalar_data,
2841 /* GnomeCanvasItem * **gci_scalar */
2842 gint type)
2843 /* ------------------------- Displays all scalar gnome canvas items */
2845 int i, j;
2846 int nx = scalar_data->nx, ny = scalar_data->ny, **flag = scalar_data->flag;
2848 float **sc = scalar_data->scalar;
2849 float sc_min = 10000.0, sc_max = -10000.0;
2850 guint col_val = 0;
2852 float scale_factor = 0.0;
2853 /* g_warning("display_all_scalars:: enter scalar_nx=%d scalar_ny=%d" */
2854 /* "piv_nx=% piv_ny=%d intreg_nx=%d intreg_ny=%d", */
2855 /* nx, ny, */
2856 /* display_act->gpd.piv_data.nx, display_act->gpd.piv_data.ny, */
2857 /* intreg.data.nx, intreg.data.ny */
2858 /* ); */
2859 /* --------------------------------------------------------------------
2860 normalizing data between 0 and 1 */
2861 for (i = 0; i < ny; i++) {
2862 for (j = 0; j < nx; j++) {
2863 if (flag[i][j] != -1) {
2864 if (sc[i][j] < sc_min) sc_min = sc[i][j];
2865 if (sc[i][j] > sc_max) sc_max = sc[i][j];
2870 if (sc_min < 0) {
2871 if (-sc_min >= sc_max) {
2872 scale_factor = 1.0 / -sc_min;
2873 } else {
2874 scale_factor = 1.0 / sc_max;
2876 } else {
2877 scale_factor = 1.0 / sc_max;
2881 for (i = 0; i < ny; i++) {
2882 for (j = 0; j < nx; j++) {
2883 if (flag[i][j] != -1) {
2884 if (sc_min < 0) {
2885 if (sc[i][j] <0) {
2886 col_val = (int) (-sc[i][j] * 255 * scale_factor);
2887 col_val = (col_val << BITSHIFT_RED);
2888 } else {
2889 col_val = (int) (sc[i][j] * 255 * scale_factor);
2890 col_val = (col_val << BITSHIFT_BLUE);
2892 } else {
2893 col_val = (int) (sc[i][j] * 255 * scale_factor);
2894 col_val = (col_val << BITSHIFT_BLUE);
2896 } else {
2897 col_val = 128 << BITSHIFT_GREEN;
2899 display_scalar(i, j, scalar_data, type, /* gci_scalar[i][j], */
2900 col_val);
2904 if (display_act->display_piv) {
2905 for (i = 0; i < ny; i++) {
2906 for (j = 0; j < nx; j++) {
2907 gnome_canvas_item_raise_to_top (display_act->intreg.gci_intreg1[i][j]);
2908 gnome_canvas_item_raise_to_top (display_act->intreg.gci_intreg2[i][j]);
2913 if (display_act->display_intregs) {
2914 for (i = 0; i < ny; i++) {
2915 for (j = 0; j < nx; j++) {
2916 gnome_canvas_item_raise_to_top (display_act->gpd.gci_vector[i][j]);
2924 void
2925 show_all_scalars(ScalarData * scalar_data,
2926 gint type
2927 /* GnomeCanvasItem * **gci_scalar */
2929 /* ----------------------------------- Shows scalar gnome canvas items */
2931 int i, j;
2932 int nx = scalar_data->nx, ny = scalar_data->ny;
2934 if (type == VORTICITY) {
2935 for (i = 0; i < ny; i++) {
2936 for (j = 0; j < nx; j++) {
2937 gnome_canvas_item_show(GNOME_CANVAS_ITEM(display_act->gpd.gci_scalar_vor[i][j]));
2942 if (type == S_STRAIN) {
2943 for (i = 0; i < ny; i++) {
2944 for (j = 0; j < nx; j++) {
2945 gnome_canvas_item_show(GNOME_CANVAS_ITEM(display_act->gpd.gci_scalar_sstrain[i][j]));
2950 if (type == N_STRAIN) {
2951 for (i = 0; i < ny; i++) {
2952 for (j = 0; j < nx; j++) {
2953 gnome_canvas_item_show(GNOME_CANVAS_ITEM(display_act->gpd.gci_scalar_nstrain[i][j]));
2961 void
2962 hide_all_scalars(ScalarData * scalar_data,
2963 gint type
2964 /* GnomeCanvasItem * **gci_scalar */
2966 /* ----------------------------------- Hides all scalar gnome canvas items */
2968 int i, j;
2969 int nx = scalar_data->nx, ny = scalar_data->ny;
2971 if (type == VORTICITY) {
2972 for (i = 0; i < ny; i++) {
2973 for (j = 0; j < nx; j++) {
2974 gnome_canvas_item_hide(GNOME_CANVAS_ITEM(display_act->gpd.gci_scalar_vor[i][j]));
2979 if (type == S_STRAIN) {
2980 for (i = 0; i < ny; i++) {
2981 for (j = 0; j < nx; j++) {
2982 gnome_canvas_item_hide(GNOME_CANVAS_ITEM(display_act->gpd.gci_scalar_sstrain[i][j]));
2987 if (type == N_STRAIN) {
2988 for (i = 0; i < ny; i++) {
2989 for (j = 0; j < nx; j++) {
2990 gnome_canvas_item_hide(GNOME_CANVAS_ITEM(display_act->gpd.gci_scalar_nstrain[i][j]));
2999 void
3000 destroy_all_scalars(ScalarData * scalar_data,
3001 gint type
3002 /* GnomeCanvasItem * **gci_scalar */
3004 /* ------------------------------- Destroys scalar canvas items */
3006 int i, j;
3007 int nx = scalar_data->nx, ny = scalar_data->ny;
3009 if (type == VORTICITY) {
3010 for (i = 0; i < ny; i++) {
3011 for (j = 0; j < nx; j++) {
3012 if (display_act->gpd.gci_scalar_vor[i][j] != NULL) {
3013 gtk_object_destroy(GTK_OBJECT(display_act->gpd.
3014 gci_scalar_vor[i][j]));
3015 display_act->gpd.gci_scalar_vor[i][j] = NULL;
3021 if (type == S_STRAIN) {
3022 for (i = 0; i < ny; i++) {
3023 for (j = 0; j < nx; j++) {
3024 if (display_act->gpd.gci_scalar_sstrain[i][j] != NULL) {
3025 gtk_object_destroy(GTK_OBJECT(display_act->gpd.
3026 gci_scalar_sstrain[i][j]));
3027 display_act->gpd.gci_scalar_sstrain[i][j] = NULL;
3033 if (type == N_STRAIN) {
3034 for (i = 0; i < ny; i++) {
3035 for (j = 0; j < nx; j++) {
3036 if (display_act->gpd.gci_scalar_nstrain[i][j] != NULL) {
3037 gtk_object_destroy(GTK_OBJECT(display_act->gpd.
3038 gci_scalar_nstrain[i][j]));
3039 display_act->gpd.gci_scalar_nstrain[i][j] = NULL;