Retreives images/data from URI using Gnome Virtual File System.
[gpiv.git] / src / display_event.c
blob3e5c842dc88024af00493ce004bead4d2b9c6d51
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) 2006 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 #include "gpiv_gui.h"
30 #include "display.h"
31 #include "display_zoom.h"
33 GdkCursor *cursor;
35 static void
36 canvas_display_motion_notify__NO_MS (Display *disp,
37 gint x,
38 gint y,
39 gint *index_x,
40 gint *index_y
43 static void
44 canvas_display_button_release__AOI_MS (Display *disp,
45 GpivConsole *gpiv,
46 GtkWidget * view_piv_display0,
47 gdouble x,
48 gdouble y
51 static void
52 canvas_display_motion_notify__DRAGINT_MS (Display *disp,
53 gint x,
54 gint y,
55 gint *index_x,
56 gint *index_y
59 static void
60 canvas_display_motion_notify__SINGLE_POINT_MS (Display *disp,
61 gint x,
62 gint y
66 static char *
67 canvas_display_button_press__SINGLE_AREA_MS (GpivConsole *gpiv,
68 Display *disp,
69 gint x,
70 gint y
73 static char *
74 canvas_display_button_release__SINGLE_AREA_MS (GpivConsole *gpiv,
75 Display *disp,
76 gdouble x,
77 gdouble y
80 static void
81 canvas_display_button_press__SINGLE_POINT_MS (GpivConsole *gpiv,
82 Display *disp,
83 gint x,
84 gint y
87 static void
88 canvas_display_button_release__HVLINE_MS (Display *disp,
89 GpivConsole *gpiv,
90 GtkWidget * view_piv_display0,
91 gdouble x,
92 gdouble y
94 static void
95 canvas_display_button_press__DISABLE_POINT_MS (Display *disp,
96 gint x,
97 gint y
99 static void
100 set__NO_MS (GpivConsole *gpiv,
101 Display *disp
104 static void
105 search_nearest_index (Display * disp,
106 gint x,
107 gint y,
108 gint * index_x,
109 gint * index_y,
110 gint data_type
113 static void
114 highlight_intreg (gint index_y,
115 gint index_x,
116 Display * disp
119 static void
120 create_msg_display_with_pivdata (GpivPivData piv_data,
121 gint index_y,
122 gint index_x,
123 gint scale
126 static void
127 create_msg_display_with_scdata (GpivScalarData sc_data,
128 gchar *sc_type,
129 gint index_y,
130 gint index_x,
131 gint scale
133 static void
134 create_msg_display_with_pivscdata (GpivPivData piv_data,
135 GpivScalarData sc_data,
136 gchar *sc_type,
137 gint index_y,
138 gint index_x,
139 gint scale
142 static void
143 create_line (Display *disp,
144 gint x1,
145 gint y1,
146 gint x2,
147 gint y2
150 static void
151 update_line (gint x1,
152 gint y1,
153 gint x2,
154 gint y2
157 static void
158 destroy_line ();
160 static void
161 update_rect (gint x,
162 gint y
165 static void
166 create_rect (Display *disp,
167 gint x,
168 gint y
171 static void
172 destroy_rect ();
174 static void
175 pane_canvas (Display *disp,
176 gfloat x,
177 gfloat y
180 static void
181 pane_canvas_x (Display *disp,
182 gfloat x
185 static void
186 pane_canvas_y (Display *disp,
187 gfloat y
190 * Public display functions
192 gboolean
193 canvas_display_enter_notify (GtkWidget * widget,
194 GdkEventMotion * event,
195 gpointer data
197 /*-----------------------------------------------------------------------------
200 Display *disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
201 GtkWidget *view_piv_display0 =
202 gtk_object_get_data(GTK_OBJECT(disp->mwin),
203 "view_piv_display0");
205 disp->index_x_old = 0;
206 disp->index_y_old = 0;
207 disp->index_old = FALSE;
210 if (m_select == NO_MS) {
211 cursor = gdk_cursor_new(GDK_DOTBOX);
213 } else if (m_select == SINGLE_AREA_MS
214 || m_select == ENABLE_POINT_MS
215 || m_select == DISABLE_POINT_MS) {
216 cursor = gdk_cursor_new(GDK_CROSSHAIR);
220 } else if ( m_select == DRAG_MS ) {
221 cursor = gdk_cursor_new(GDK_CROSS);
225 } else if (m_select == SINGLE_POINT_MS
226 || m_select == V_LINE_MS
227 || m_select == H_LINE_MS
229 if (m_select == V_LINE_MS) {
230 cursor = gdk_cursor_new (GDK_SB_V_DOUBLE_ARROW);
232 if (m_select == H_LINE_MS) {
233 cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
236 if (m_select == SINGLE_POINT_MS) {
237 cursor = gdk_cursor_new(GDK_CROSS);
241 if (display_act->pida.exist_piv && disp->display_piv) {
242 hide_all_vectors(&display_act->pida);
245 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
246 hide_all_intregs(disp);
251 } else if (m_select == AOI_MS
252 || m_select == ENABLE_AREA_MS
253 || m_select == DISABLE_AREA_MS) {
254 cursor = gdk_cursor_new(GDK_CROSSHAIR);
256 if (m_select == AOI_MS) {
257 if (display_act->pida.exist_piv && disp->display_piv) {
258 hide_all_vectors(&display_act->pida);
261 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
262 hide_all_intregs(disp);
268 } else if (m_select == SPANLENGTH_MS
269 || m_select == V_SPANLENGTH_MS
270 || m_select == H_SPANLENGTH_MS
272 cursor = gdk_cursor_new(GDK_CROSS);
275 gdk_window_set_cursor(disp->mwin->window, cursor);
277 return TRUE;
282 gboolean
283 canvas_display_motion_notify (GtkWidget * widget,
284 GdkEventMotion * event,
285 gpointer data
287 /*-----------------------------------------------------------------------------
290 Display *disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
291 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
292 GtkAdjustment *hadj = GTK_ADJUSTMENT (disp->hadj);
293 GtkAdjustment *vadj = GTK_ADJUSTMENT (disp->hadj);
295 gdouble x, y;
296 gint x_grab, y_grab;
297 gint index_y = 0, index_x = 0;
299 GdkModifierType state;
300 GnomeCanvasPoints *points;
301 points = gnome_canvas_points_new(2);
304 if (event->is_hint) {
305 gdk_window_get_pointer (event->window, &x_grab, &y_grab, &state);
307 x = x_grab;
308 y = y_grab;
310 } else {
311 x = event->x;
312 y = event->y;
314 state = event->state;
318 /* g_message ("canvas_display_motion_notify:: x = %f y = %f x/zoom = %f y/zoom = %f", */
319 /* x, y, x / disp->zoom_factor, y / disp->zoom_factor); */
321 /* if (x >= hadj->value && x < hadj->value + hadj->page_size */
322 /* && y >= vadj->value && y < vadj->value + vadj->page_size) { */
325 if (x >= 0 && x < disp->img.image_par.ncolumns * disp->zoom_factor
326 && y >= 0 && y < disp->img.image_par.nrows * disp->zoom_factor) {
329 * display particle displacements / velocities and its attributes,
331 if (m_select == NO_MS
332 || m_select == SINGLE_AREA_MS
333 || m_select == DRAG_MS
334 || m_select == ENABLE_POINT_MS
335 || m_select == DISABLE_POINT_MS) {
339 * display locations of interrogation area's and estimators,
340 * only display locations of interrogation area's,
341 * or nothing
344 canvas_display_motion_notify__NO_MS (disp,
345 (gint) (x / disp->zoom_factor),
346 (gint) (y / disp->zoom_factor),
347 &index_x,
348 &index_y);
351 * Pane (moving) the canvas. Identic effect as moving the scroll bars.
353 if (m_select == NO_MS) {
354 if (state & GDK_BUTTON1_MASK) {
355 pane_canvas (disp, x, y);
360 if ( m_select == DRAG_MS ) {
361 canvas_display_motion_notify__DRAGINT_MS (disp,
362 (gint) (x / disp->zoom_factor),
363 (gint) (y / disp->zoom_factor),
364 &index_x,
365 &index_y);
368 disp->index_x_old = index_x;
369 disp->index_y_old = index_y;
373 * Only displays pointer position
375 } else if (m_select == AOI_MS
376 || m_select == ENABLE_AREA_MS
377 || m_select == DISABLE_AREA_MS ) {
378 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d px y=%d px",
379 (gint) (x / disp->zoom_factor),
380 (gint) (y / disp->zoom_factor));
383 * Update the drawing of the rectangle
385 if (state & GDK_BUTTON1_MASK) {
386 if (gci_aoi != NULL) {
387 update_rect((gint) (x / disp->zoom_factor),
388 (gint) (y / disp->zoom_factor));
394 } else if ( m_select == SINGLE_POINT_MS) {
395 canvas_display_motion_notify__SINGLE_POINT_MS (disp,
396 (gint) x / disp->zoom_factor,
397 (gint) y / disp->zoom_factor);
402 * Update a vertical line
404 } else if (m_select == V_LINE_MS) {
405 if (state & GDK_BUTTON1_MASK) {
406 g_snprintf (msg_display, GPIV_MAX_CHARS, "x=%d px y=%d px",
407 (gint) (disp->xgrab_first / disp->zoom_factor),
408 (gint) (y / disp->zoom_factor));
409 if ( gci_line != NULL ) {
410 update_line ((gint) (disp->xgrab_first / disp->zoom_factor) ,
411 (gint) (disp->ygrab_first / disp->zoom_factor),
412 (gint) (disp->xgrab_first / disp->zoom_factor),
413 (gint) (y / disp->zoom_factor));
415 } else {
416 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d px y=%d px",
417 (gint) (x / disp->zoom_factor),
418 (gint) (y / disp->zoom_factor));
424 * Update a horizontal line
426 } else if (m_select == H_LINE_MS) {
427 if (state & GDK_BUTTON1_MASK) {
428 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d y=%d",
429 (gint) (x / disp->zoom_factor),
430 (gint) (disp->ygrab_first / disp->zoom_factor));
431 if (gci_line != NULL ) {
432 update_line ((gint) (disp->xgrab_first / disp->zoom_factor),
433 (gint) (disp->ygrab_first / disp->zoom_factor),
434 (gint) (x / disp->zoom_factor),
435 (gint) (disp->ygrab_first / disp->zoom_factor));
437 } else {
438 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d px y=%d px",
439 (gint) (x / disp->zoom_factor),
440 (gint) (y / disp->zoom_factor));
445 } else if (m_select == SPANLENGTH_MS) {
446 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d px y=%d px",
447 (gint) (x / disp->zoom_factor),
448 (gint) (y / disp->zoom_factor));
450 if (state & GDK_BUTTON1_MASK && gci_line != NULL ) {
451 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d y=%d",
452 (gint) (x / disp->zoom_factor),
453 (gint) (y / disp->zoom_factor));
454 update_line ((gint) (disp->xgrab_first / disp->zoom_factor),
455 (gint) (disp->ygrab_first / disp->zoom_factor),
456 (gint) (x / disp->zoom_factor),
457 (gint) (y / disp->zoom_factor));
460 } else if (m_select == V_SPANLENGTH_MS) {
461 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d px y=%d px",
462 (gint) (x / disp->zoom_factor),
463 (gint) (y / disp->zoom_factor));
465 if (state & GDK_BUTTON1_MASK && gci_line != NULL ) {
466 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d y=%d",
467 (gint) (disp->xgrab_first / disp->zoom_factor),
468 (gint) (y / disp->zoom_factor));
469 update_line ((gint) (disp->xgrab_first / disp->zoom_factor),
470 (gint) (disp->ygrab_first / disp->zoom_factor),
471 (gint) (disp->xgrab_first / disp->zoom_factor),
472 (gint) (y / disp->zoom_factor));
475 } else if (m_select == H_SPANLENGTH_MS) {
476 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d px y=%d px",
477 (gint) (x / disp->zoom_factor),
478 (gint) (y / disp->zoom_factor));
480 if (state & GDK_BUTTON1_MASK && gci_line != NULL ) {
481 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d y=%d",
482 (gint) (x / disp->zoom_factor),
483 (gint) (disp->ygrab_first / disp->zoom_factor));
484 update_line ((gint) (disp->xgrab_first / disp->zoom_factor),
485 (gint) (disp->ygrab_first / disp->zoom_factor),
486 (gint) (x / disp->zoom_factor),
487 (gint) (disp->ygrab_first / disp->zoom_factor));
494 gnome_appbar_push(GNOME_APPBAR(disp->appbar), msg_display);
495 gnome_appbar_push(GNOME_APPBAR(gpiv->appbar), msg_display);
500 /* } else { */
501 /* g_message("canvas_display_motion_notify: out of image borders"); */
504 gnome_canvas_points_free(points);
505 return TRUE;
510 gboolean
511 canvas_display_button_press (GtkWidget * widget,
512 GdkEventButton * event,
513 gpointer data
515 /*-----------------------------------------------------------------------------
518 Display * disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
519 GpivConsole * gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
520 gdouble x, y;
521 gint x_grab, y_grab;
522 gint index_x = 0, index_y = 0;
523 GdkModifierType state;
524 GnomeCanvasPoints *points;
525 GtkWidget * view_piv_display0 =
526 gtk_object_get_data(GTK_OBJECT(disp->mwin),
527 "view_piv_display0");
529 points = gnome_canvas_points_new(2);
530 GtkMenu *menu = GTK_MENU (disp->display_popupmenu);
532 gdk_window_get_pointer(event->window, &x_grab, &y_grab, &state);
533 x = x_grab ;
534 y = y_grab ;
538 if (event->button == 1) {
539 disp->xgrab_first = x;
540 disp->ygrab_first = y;
541 /* g_message ("canvas_display_button_press:: xgrab_first = %f ygrab_first = %f", */
542 /* disp->xgrab_first, disp->ygrab_first); */
544 * No mouse select
546 if (m_select == NO_MS) {
547 cursor = gdk_cursor_new (GDK_FLEUR );
548 gdk_window_set_cursor (disp->mwin->window, cursor);
549 /* g_message ("canvas_display_button_press:: x_grab = %d y_grab = %d", */
550 /* x_grab, y_grab); */
551 /* g_message ("CANVAS_DISPLAY_BUTTON_PRESS:: x = %f y = %f", x, y); */
555 * select Area Of Interest
557 } else if (m_select == AOI_MS) {
559 * storige of original AOI
561 disp->intreg.col_start_old = disp->pida.eval_par.col_start;
562 disp->intreg.row_start_old = disp->pida.eval_par.row_start;
564 /* g_message ("CANVAS_DISPLAY_BUTTON_PRESS (AOI):: x_grab = %d y_grab = %d", */
565 /* x_grab, y_grab); */
566 create_rect (disp,
567 disp->xgrab_first / disp->zoom_factor,
568 disp->ygrab_first / disp->zoom_factor);
571 * select at single interrogation area
573 } else if ((m_select == SINGLE_AREA_MS || m_select == DRAG_MS) &&
574 disp->img.exist_img) {
575 canvas_display_button_press__SINGLE_AREA_MS (gpiv, disp,
576 x / disp->zoom_factor,
577 y / disp->zoom_factor);
580 * select a single point
582 } else if (m_select == SINGLE_POINT_MS && disp->img.exist_img) {
583 canvas_display_button_press__SINGLE_POINT_MS (gpiv, disp,
584 x / disp->zoom_factor,
585 y / disp->zoom_factor);
589 * select a vertical line
591 } else if (m_select == V_LINE_MS && display_act->img.exist_img) {
592 /* g_message ("CANVAS_DISPLAY_BUTTON_PRESS (V_LINE_MS) 11:: x_grab = %d y_grab = %d", */
593 /* x_grab, y_grab); */
594 if (gci_line != NULL) destroy_line();
595 create_line (disp,
596 disp->xgrab_first / disp->zoom_factor,
597 disp->ygrab_first / disp->zoom_factor,
598 disp->xgrab_first / disp->zoom_factor,
599 disp->ygrab_first / disp->zoom_factor);
603 * select a horizontal line
605 } else if (m_select == H_LINE_MS && disp->img.exist_img) {
606 /* g_message ("CANVAS_DISPLAY_BUTTON_PRESS (H_LINE_MS) 1:: x_grab = %d y_grab = %d", */
607 /* x_grab, y_grab); */
608 if (gci_line != NULL) destroy_line();
609 create_line (disp,
610 disp->xgrab_first / disp->zoom_factor,
611 disp->ygrab_first / disp->zoom_factor,
612 disp->xgrab_first / disp->zoom_factor,
613 disp->ygrab_first / disp->zoom_factor);
615 } else if ( m_select == ENABLE_POINT_MS ) {
617 * Only active with piv data
619 if (disp->pida.exist_piv && disp->display_piv
620 /* && GTK_CHECK_MENU_ITEM(view_piv_display0)->active */
622 search_nearest_index (disp, x, y, &index_x, &index_y,
623 /* DATA_TYPE__INTREG); */
624 DATA_TYPE__PIV);
625 disp->pida.piv_data.peak_no[index_y][index_x] = 1;
626 update_vector (&disp->pida, index_y, index_x);
631 * Enabling and disabling only active with piv data
633 } else if ((m_select == DISABLE_POINT_MS
634 || m_select == ENABLE_AREA_MS
635 || m_select == DISABLE_AREA_MS)
636 && disp->pida.exist_piv && disp->display_piv) {
637 canvas_display_button_press__DISABLE_POINT_MS (disp, x, y);
640 } else if (m_select == SPANLENGTH_MS
641 && disp->img.exist_img) {
642 if (gci_line != NULL) destroy_line();
643 create_line (disp,
644 disp->xgrab_first / disp->zoom_factor,
645 disp->ygrab_first / disp->zoom_factor,
646 disp->xgrab_first / disp->zoom_factor,
647 disp->ygrab_first / disp->zoom_factor);
651 } else if (m_select == V_SPANLENGTH_MS
652 && disp->img.exist_img) {
653 if (gci_line != NULL) destroy_line();
654 create_line (disp,
655 disp->xgrab_first / disp->zoom_factor,
656 disp->ygrab_first / disp->zoom_factor,
657 disp->xgrab_first / disp->zoom_factor,
658 disp->ygrab_first / disp->zoom_factor);
662 } else if (m_select == H_SPANLENGTH_MS
663 && disp->img.exist_img) {
664 if (gci_line != NULL) destroy_line();
665 create_line (disp,
666 disp->xgrab_first / disp->zoom_factor,
667 disp->ygrab_first / disp->zoom_factor,
668 disp->xgrab_first / disp->zoom_factor,
669 disp->ygrab_first / disp->zoom_factor);
672 } else {
673 g_warning(_("canvas_display_button_press: should not arrive here; m_select=%d"),
674 m_select);
678 } else if (event->button == 3) {
679 gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
680 event->button, event->time);
683 gnome_canvas_points_free(points);
684 return TRUE;
688 gboolean
689 canvas_display_button_release (GtkWidget * widget,
690 GdkEventButton * event,
691 gpointer data
693 /*-----------------------------------------------------------------------------
696 Display *disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
697 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
698 GtkWidget *view_piv_display0 =
699 gtk_object_get_data(GTK_OBJECT(disp->mwin),
700 "view_piv_display0");
701 gdouble x, y;
702 gint x_grab, y_grab;
703 gint i, j;
704 GdkModifierType state;
706 shift_pressed = event->state & GDK_SHIFT_MASK;
707 gdk_window_get_pointer (event->window, &x_grab, &y_grab, &state);
709 /* BUGFIX: repair for different mouse selections */
710 x = x_grab;
711 y = y_grab;
714 /* g_message ("canvas_display_button_release:: x = %f y = %f", x, y); */
715 if (event->button == 1) {
717 if (m_select == AOI_MS && gci_aoi != NULL) {
718 canvas_display_button_release__AOI_MS (disp, gpiv,
719 view_piv_display0,
720 (gdouble) (x),
721 (gdouble) (y));
725 } else if ((m_select == V_LINE_MS || m_select == H_LINE_MS)
726 && disp->img.exist_img) {
727 /* g_message ("CANVAS_DISPLAY_BUTTON_RELEASE (HV_LINE):: x_grab = %d y_grab = %d", */
728 /* x_grab, y_grab); */
729 canvas_display_button_release__HVLINE_MS (disp, gpiv,
730 view_piv_display0,
731 (gdouble) (x),
732 (gdouble) (y));
737 * analyse at single interrogation area
739 } else if ((m_select == SINGLE_AREA_MS || m_select == DRAG_MS) &&
740 disp->img.exist_img) {
741 canvas_display_button_release__SINGLE_AREA_MS(gpiv, disp,
742 (gdouble) (x),
743 (gdouble) (y));
747 } else if (m_select == ENABLE_AREA_MS && gci_aoi != NULL) {
748 enable_col_end = x;
749 enable_row_end = y;
750 if (disp->pida.exist_piv) {
751 for (i = 0; i < disp->pida.piv_data.ny; i++) {
752 for (j = 0; j < disp->pida.piv_data.nx; j++) {
753 if (disp->pida.piv_data.point_x[i][j] >=
754 enable_col_start
755 && disp->pida.piv_data.point_x[i][j] <
756 enable_col_end
757 && disp->pida.piv_data.point_y[i][j] >=
758 enable_row_start
759 && disp->pida.piv_data.point_y[i][j] <
760 enable_row_end) {
761 disp->pida.piv_data.peak_no[i][j] = 1;
762 if (disp->display_piv)
763 update_vector(&disp->pida, i, j);
769 if (gci_aoi != NULL) destroy_rect();
773 } else if (m_select == DISABLE_AREA_MS && gci_aoi != NULL) {
774 enable_col_end = x;
775 enable_row_end = y;
776 if (disp->pida.exist_piv) {
777 for (i = 0; i < disp->pida.piv_data.ny; i++) {
778 for (j = 0; j < disp->pida.piv_data.nx; j++) {
779 if (disp->pida.piv_data.point_x[i][j] >=
780 enable_col_start
781 && disp->pida.piv_data.point_x[i][j] <
782 enable_col_end
783 && disp->pida.piv_data.point_y[i][j] >=
784 enable_row_start
785 && disp->pida.piv_data.point_y[i][j] <
786 enable_row_end) {
787 disp->pida.piv_data.peak_no[i][j] = -1;
788 disp->pida.piv_data.snr[i][j] = GPIV_SNR_DISABLE;
790 if (disp->pida.post_par.set == TRUE) {
791 disp->pida.piv_data.dx[i][j] =
792 disp->pida.post_par.set_dx;
793 disp->pida.piv_data.dy[i][j] =
794 disp->pida.post_par.set_dx;
797 if (disp->display_piv)
798 update_vector(&disp->pida, i, j);
804 if (gci_aoi != NULL) destroy_rect();
808 } else if (m_select == SPANLENGTH_MS
809 && disp->img.exist_img
810 && gci_line != NULL
812 gfloat hdist = abs ((x - disp->xgrab_first) / disp->zoom_factor);
813 gfloat vdist = abs ((y - disp->ygrab_first) / disp->zoom_factor);
815 gpiv_var.img_span_px = sqrt (hdist * hdist + vdist * vdist);
816 if (gci_line != NULL) destroy_line ();
817 gtk_spin_button_set_value (GTK_SPIN_BUTTON
818 (gpiv->imgh->spinbutton_sscale_px),
819 gpiv_var.img_span_px
824 } else if (m_select == V_SPANLENGTH_MS
825 && disp->img.exist_img
826 && gci_line != NULL
828 gpiv_var.img_span_px = abs ((y - disp->ygrab_first) / disp->zoom_factor);
829 if (gci_line != NULL) destroy_line ();
830 gtk_spin_button_set_value (GTK_SPIN_BUTTON
831 (gpiv->imgh->spinbutton_sscale_px),
832 gpiv_var.img_span_px);
836 } else if (m_select == H_SPANLENGTH_MS
837 && disp->img.exist_img
838 && gci_line != NULL
840 gpiv_var.img_span_px = abs ((x - disp->xgrab_first) / disp->zoom_factor);
841 if (gci_line != NULL) destroy_line ();
842 gtk_spin_button_set_value (GTK_SPIN_BUTTON
843 (gpiv->imgh->spinbutton_sscale_px),
844 gpiv_var.img_span_px);
849 * No action
851 } else if (m_select == GPIV_NONE
852 || m_select == SINGLE_POINT_MS
853 || m_select == ENABLE_POINT_MS
854 || m_select == DISABLE_POINT_MS
856 cursor = gdk_cursor_new (GDK_DOTBOX);
857 gdk_window_set_cursor (disp->mwin->window, cursor);
859 } else {
860 g_warning(_("canvas_display_button_release: should not arrive here; m_select=%d"),
861 m_select);
865 return TRUE;
871 gboolean
872 canvas_display_leave_notify (GtkWidget * widget,
873 GdkEventMotion * event,
874 gpointer data
876 /*-----------------------------------------------------------------------------
879 Display * disp = gtk_object_get_data(GTK_OBJECT(widget), "disp");
880 GpivConsole *gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
881 GtkWidget * view_piv_display0 =
882 gtk_object_get_data(GTK_OBJECT(disp->mwin),
883 "view_piv_display0");
885 gnome_appbar_push(GNOME_APPBAR(disp->appbar),
886 disp->msg_display_default);
887 gnome_appbar_push(GNOME_APPBAR(gpiv->appbar), msg_default);
890 if (m_select == SINGLE_POINT_MS
891 && GTK_CHECK_MENU_ITEM(view_piv_display0)->active
893 if (!disp->intreg.exist_int) {
894 update_intreg1(disp, m_select_index_y, m_select_index_x);
895 update_intreg2(disp, m_select_index_y, m_select_index_x);
898 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
899 show_all_intregs(disp);
903 if (disp->pida.exist_piv && disp->display_piv) {
904 show_all_vectors(&disp->pida);
908 } else if (m_select == DRAG_MS) {
909 if (!disp->intreg.exist_int) {
910 update_intreg1(disp, disp->index_y_old, disp->index_x_old);
911 update_intreg2(disp, disp->index_y_old, disp->index_x_old);
914 } else if (m_select == SINGLE_AREA_MS && disp->intreg.exist_int) {
915 if (!disp->intreg.exist_int) {
916 update_intreg1(disp, 0, 0);
917 update_intreg2(disp, 0, 0);
921 } else if (m_select == AOI_MS
922 || m_select == V_LINE_MS
923 || m_select == H_LINE_MS) {
924 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
925 show_all_intregs(disp);
928 if (disp->pida.exist_piv && disp->display_piv) {
929 show_all_vectors(&disp->pida);
932 if (gci_line != NULL) {
933 gtk_object_destroy(GTK_OBJECT(gci_line));
934 gci_line = NULL;
941 if (GDK_BUTTON1_MASK) {
943 * Cancel AOI_MS selection
945 if (m_select == AOI_MS) {
946 if (gci_aoi != NULL) {
947 disp->pida.eval_par.col_start = disp->intreg.col_start_old;
948 disp->pida.eval_par.row_start = disp->intreg.row_start_old;
949 gtk_spin_button_set_value(GTK_SPIN_BUTTON
950 (gpiv->piveval->spinbutton_colstart),
951 disp->pida.eval_par.col_start);
952 gtk_spin_button_set_value(GTK_SPIN_BUTTON
953 (gpiv->piveval->spinbutton_rowstart),
954 disp->pida.eval_par.row_start);
955 if (gci_aoi != NULL) destroy_rect();
958 /* show_all_intregs(disp); */
960 } else if ( m_select == ENABLE_AREA_MS
961 || m_select == DISABLE_AREA_MS) {
962 enable_col_start = 0;
963 enable_row_start = 0;
964 enable_col_end = 0;
965 enable_row_end = 0;
966 if (gci_aoi != NULL) destroy_rect();
969 * Cancel V_LINE_MS, LINE_MS selection
970 * (V_, H_) SPANLENGTH_MS
972 } else if (m_select == V_LINE_MS
973 || m_select == H_LINE_MS
974 || m_select == SPANLENGTH_MS
975 || m_select == V_SPANLENGTH_MS
976 || m_select == H_SPANLENGTH_MS
978 if (gci_line != NULL) destroy_line();
986 * General
988 if (cursor != NULL) {
989 gdk_cursor_destroy(cursor);
990 cursor = NULL;
993 if (disp->intreg.gci_intreg2[disp->index_y_old][disp->index_x_old]
994 != NULL) {
995 update_intreg2(disp, disp->index_y_old, disp->index_x_old);
998 if (disp->intreg.gci_intreg1[disp->index_y_old][disp->index_x_old]
999 != NULL) {
1000 update_intreg1(disp, disp->index_y_old, disp->index_x_old);
1003 disp->index_x_old = 0;
1004 disp->index_y_old = 0;
1006 return TRUE;
1010 * Private display functions
1014 static void
1015 canvas_display_motion_notify__NO_MS (Display *disp,
1016 gint x,
1017 gint y,
1018 gint *index_x,
1019 gint *index_y
1021 /*-----------------------------------------------------------------------------
1022 * Moves pointer over the display canvas if no mouse selection (NO_MS) is set
1025 GpivPivData piv_data = disp->pida.piv_data;
1026 GpivPivData piv_data_scaled = disp->pida.piv_data_scaled;
1027 GpivScalarData vor_data = disp->pida.vor_data;
1028 GpivScalarData vor_data_scaled = disp->pida.vor_data_scaled;
1029 GpivScalarData sstrain_data = disp->pida.sstrain_data;
1030 GpivScalarData sstrain_data_scaled = disp->pida.sstrain_data_scaled;
1031 GpivScalarData nstrain_data = disp->pida.nstrain_data;
1032 GpivScalarData nstrain_data_scaled = disp->pida.nstrain_data_scaled;
1033 GtkWidget * view_piv_display0 =
1034 gtk_object_get_data(GTK_OBJECT(disp->mwin),
1035 "view_piv_display0");
1037 *index_y = 0;
1038 *index_x = 0;
1041 * BUGFIX REPAIRED 26.5.03
1042 * if area of interest is created without displaying intregs, no intregs are
1043 * created, resulting into no displaying of piv values
1044 * Check on existance of intregs here
1046 * Changed policy 8..4.05; if no intregs exist and shown, piv values will be
1047 * displayed,
1049 if ((disp->pida.exist_piv && disp->display_piv
1050 && GTK_CHECK_MENU_ITEM(view_piv_display0)->active
1051 && piv_data.ny == disp->intreg.data.ny
1052 && piv_data.nx == disp->intreg.data.nx
1053 && piv_data.point_y[0][0] == disp->intreg.data.point_y[0][0]
1054 && piv_data.point_x[0][0] == disp->intreg.data.point_x[0][0]
1055 && piv_data.point_y[piv_data.ny - 1][piv_data.nx - 1] ==
1056 disp->intreg.data.point_y[disp->intreg.data.ny - 1]
1057 [disp->intreg.data.nx - 1]
1058 && piv_data.point_x[piv_data.ny - 1][piv_data.nx - 1] ==
1059 disp->intreg.data.point_x[disp->intreg.data.ny - 1]
1060 [disp->intreg.data.nx - 1] )
1061 || (disp->pida.exist_piv && disp->display_piv
1062 && !GTK_CHECK_MENU_ITEM(view_piv_display0)->active)
1065 search_nearest_index(disp, x, y, index_x, index_y, DATA_TYPE__PIV);
1066 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1067 highlight_intreg(*index_y, *index_x, disp);
1071 if (disp->pida.exist_vor && disp->display_vor) {
1072 if (disp->pida.scaled_piv) {
1073 create_msg_display_with_pivscdata(piv_data_scaled,
1074 vor_data_scaled,
1075 "vor",
1076 *index_y,
1077 *index_x,
1078 disp->pida.scaled_piv);
1079 } else {
1080 create_msg_display_with_pivscdata(piv_data,
1081 vor_data,
1082 "vor",
1083 *index_y,
1084 *index_x,
1085 disp->pida.scaled_piv);
1088 } else if (disp->pida.exist_sstrain && disp->display_sstrain) {
1089 if (disp->pida.scaled_piv) {
1090 create_msg_display_with_pivscdata(piv_data_scaled,
1091 sstrain_data_scaled,
1092 "sstrain",
1093 *index_y,
1094 *index_x,
1095 disp->pida.scaled_piv);
1096 } else {
1097 create_msg_display_with_pivscdata(piv_data,
1098 sstrain_data,
1099 "sstrain",
1100 *index_y,
1101 *index_x,
1102 disp->pida.scaled_piv);
1105 } else if (disp->pida.exist_nstrain && disp->display_nstrain) {
1106 if (disp->pida.scaled_piv) {
1107 create_msg_display_with_pivscdata(piv_data_scaled,
1108 nstrain_data_scaled,
1109 "nstrain",
1110 *index_y,
1111 *index_x,
1112 disp->pida.scaled_piv);
1113 } else {
1114 create_msg_display_with_pivscdata(piv_data,
1115 nstrain_data,
1116 "nstrain",
1117 *index_y,
1118 *index_x,
1119 disp->pida.scaled_piv);
1122 } else {
1123 if (disp->pida.scaled_piv) {
1124 create_msg_display_with_pivdata(piv_data_scaled,
1125 *index_y,
1126 *index_x,
1127 disp->pida.scaled_piv);
1129 } else {
1130 create_msg_display_with_pivdata(piv_data,
1131 *index_y,
1132 *index_x,
1133 disp->pida.scaled_piv);
1139 * piv data exist, but are not displayed
1140 * displays eventually piv-derived scalar data
1142 } else if ((disp->pida.exist_piv
1143 && !disp->display_piv
1144 && GTK_CHECK_MENU_ITEM(view_piv_display0)->active
1145 && piv_data.ny == disp->intreg.data.ny
1146 && piv_data.nx == disp->intreg.data.nx
1147 && piv_data.point_y[0][0] == disp->intreg.data.point_y[0][0]
1148 && piv_data.point_x[0][0] == disp->intreg.data.point_x[0][0]
1149 && piv_data.point_y[piv_data.ny - 1][piv_data.nx - 1] ==
1150 disp->intreg.data.point_y[disp->intreg.data.ny - 1]
1151 [disp->intreg.data.nx - 1]
1152 && piv_data.point_x[piv_data.ny - 1][piv_data.nx - 1] ==
1153 disp->intreg.data.point_x[disp->intreg.data.ny - 1]
1154 [disp->intreg.data.nx - 1]
1155 && ((disp->pida.exist_vor && disp->display_vor)
1156 || (disp->pida.exist_sstrain && disp->display_sstrain)
1157 || (disp->pida.exist_nstrain && disp->display_nstrain))
1159 || (disp->pida.exist_piv
1160 && !disp->display_piv
1161 && !GTK_CHECK_MENU_ITEM(view_piv_display0)->active
1162 && ((disp->pida.exist_vor && disp->display_vor)
1163 || (disp->pida.exist_sstrain && disp->display_sstrain)
1164 || (disp->pida.exist_nstrain && disp->display_nstrain))
1168 search_nearest_index(disp, x, y, index_x, index_y,
1169 DATA_TYPE__PIV);
1170 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1171 highlight_intreg(*index_y, *index_x, disp);
1174 if (disp->pida.exist_vor && disp->display_vor) {
1175 if (disp->pida.scaled_piv) {
1176 create_msg_display_with_scdata(vor_data_scaled,
1177 "vor",
1178 *index_y,
1179 *index_x,
1180 disp->pida.scaled_piv);
1181 } else {
1182 create_msg_display_with_scdata(vor_data,
1183 "vor",
1184 *index_y,
1185 *index_x,
1186 disp->pida.scaled_piv);
1189 } else if (disp->pida.exist_sstrain && disp->display_sstrain) {
1190 if (disp->pida.scaled_piv) {
1191 create_msg_display_with_scdata(sstrain_data_scaled,
1192 "sstrain",
1193 *index_y,
1194 *index_x,
1195 disp->pida.scaled_piv);
1196 } else {
1197 create_msg_display_with_scdata(sstrain_data,
1198 "sstrain",
1199 *index_y,
1200 *index_x,
1201 disp->pida.scaled_piv);
1204 } else if (disp->pida.exist_nstrain && disp->display_nstrain) {
1205 if (disp->pida.scaled_piv) {
1206 create_msg_display_with_scdata(nstrain_data_scaled,
1207 "nstrain",
1208 *index_y,
1209 *index_x,
1210 disp->pida.scaled_piv);
1211 } else {
1212 create_msg_display_with_scdata(nstrain_data,
1213 "nstrain",
1214 *index_y,
1215 *index_x,
1216 disp->pida.scaled_piv);
1221 * PIV data (and resulting derivatives) do not exist are and not displayed
1222 * Interrogation area's are displayed
1224 } else if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1225 search_nearest_index(disp, x, y, index_x, index_y, DATA_TYPE__INTREG);
1226 highlight_intreg(*index_y, *index_x, disp);
1228 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%3.2f y=%3.2f i=%d j=%d ",
1229 disp->intreg.data.point_x[*index_y][*index_x],
1230 disp->intreg.data.point_y[*index_y][*index_x],
1231 *index_y, *index_x);
1235 * Only image is displayed
1237 } else if (disp->display_img1) {
1238 if (disp->pida.scaled_piv) {
1239 g_snprintf(msg_display, GPIV_MAX_CHARS,
1240 "xp=%d px ==> %5.4f m yp=%d px ==> %5.4f m img #1: pixval=%d",
1242 disp->img.image_par.s_scale * x * 1e-3
1243 + disp->img.image_par.z_off_x,
1245 disp->img.image_par.s_scale * y * 1e-3
1246 + disp->img.image_par.z_off_y,
1247 disp->img.img1[y][x]
1249 } else {
1250 g_snprintf(msg_display, GPIV_MAX_CHARS,
1251 "xp=%d px yp=%d px img #1: pixval=%d",
1252 x, y,
1253 disp->img.img1[y][x]
1257 } else if (disp->display_img2) {
1258 if (disp->pida.scaled_piv) {
1259 g_snprintf(msg_display, GPIV_MAX_CHARS,
1260 "xp=%d px ==> %5.4f m yp=%d px ==> %5.4f m img #1: pixval=%d",
1262 disp->img.image_par.s_scale * x * 1e-3
1263 + disp->img.image_par.z_off_x,
1265 disp->img.image_par.s_scale * y * 1e-3
1266 + disp->img.image_par.z_off_y,
1267 disp->img.img2[y][x]
1269 } else {
1270 g_snprintf(msg_display, GPIV_MAX_CHARS,
1271 "xp=%d px yp=%d px img #2: pixval=%d",
1272 x, y,
1273 disp->img.img2[y][x]
1277 } else {
1278 g_snprintf(msg_display, GPIV_MAX_CHARS, "No data are displayed");
1285 static void
1286 canvas_display_button_release__AOI_MS (Display *disp,
1287 GpivConsole *gpiv,
1288 GtkWidget * view_piv_display0,
1289 gdouble x,
1290 gdouble y
1292 /*-----------------------------------------------------------------------------
1293 * Performs action on mouse button release when AOI_MS has been enabled
1296 PivEval *eval = gpiv->piveval;
1297 gdouble l_col_start, l_col_end, l_row_start, l_row_end;
1299 if (gci_aoi != NULL) destroy_rect();
1301 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1302 destroy_all_intregs(disp);
1306 /* g_message ("canvas_display_button_release__AOI_MS:: x = %f y = %f" */
1307 /* " xgrab_first = %f ygrab_first = %f", */
1308 /* x, y, disp->xgrab_first, disp->ygrab_first); */
1310 if (x >= disp->xgrab_first) {
1311 l_col_start = disp->xgrab_first / disp->zoom_factor;
1312 l_col_end = x / disp->zoom_factor;
1313 disp->pida.eval_par.col_start = (gint) l_col_start;
1314 disp->pida.eval_par.col_end = (gint) l_col_end;
1315 } else {
1316 l_col_end = disp->xgrab_first / disp->zoom_factor;
1317 l_col_start = x / disp->zoom_factor;
1318 disp->pida.eval_par.col_end = (gint) l_col_end;
1319 disp->pida.eval_par.col_start = (gint) l_col_start;
1322 if (y >= disp->ygrab_first) {
1323 l_row_start = disp->ygrab_first / disp->zoom_factor;
1324 l_row_end = y / disp->zoom_factor;
1325 disp->pida.eval_par.row_start = (gint) l_row_start;
1326 disp->pida.eval_par.row_end = (gint) l_row_end;
1327 } else {
1328 l_row_end = disp->ygrab_first / disp->zoom_factor;
1329 l_row_start = y / disp->zoom_factor;
1330 disp->pida.eval_par.row_end = (gint) l_row_end;
1331 disp->pida.eval_par.row_start = (gint) l_row_start;
1336 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1337 (eval->spinbutton_colstart),
1338 (gdouble)l_col_start);
1340 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1341 (eval->spinbutton_colend),
1342 (gdouble) l_col_end);
1344 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1345 (eval->spinbutton_rowstart),
1346 (gdouble) l_row_start);
1348 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1349 (eval->spinbutton_rowend),
1350 (gdouble) l_row_end);
1352 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1353 create_all_intregs (disp);
1360 static void
1361 canvas_display_motion_notify__DRAGINT_MS (Display *disp,
1362 gint x,
1363 gint y,
1364 gint *index_x,
1365 gint *index_y
1367 /*-----------------------------------------------------------------------------
1368 * displaces interrogation area nearest to pointer
1371 if (disp->intreg.exist_int) {
1372 if (!disp->index_old) {
1373 disp->index_x_old = *index_x;
1374 disp->index_y_old = *index_y;
1375 disp->index_old = TRUE;
1378 if (*index_x == disp->index_x_old
1379 && *index_y == disp->index_y_old) {
1381 gnome_canvas_item_set
1382 (GNOME_CANVAS_ITEM(disp->intreg.
1383 gci_intreg1[*index_y][*index_x]),
1384 "x1", (double) x - disp->pida.eval_par.int_size_1 / 2,
1385 "y1", (double) y - disp->pida.eval_par.int_size_1 / 2,
1386 "x2", (double) x + disp->pida.eval_par.int_size_1 / 2,
1387 "y2", (double) y + disp->pida.eval_par.int_size_1 / 2,
1388 NULL);
1390 gnome_canvas_item_set
1391 (GNOME_CANVAS_ITEM(disp->intreg.
1392 gci_intreg2[*index_y][*index_x]),
1393 "x1", (double) x - disp->pida.eval_par.int_size_2 /
1394 2 + disp->pida.eval_par.pre_shift_col,
1395 "y1", (double) y - disp->pida.eval_par.int_size_2 /
1396 2 + disp->pida.eval_par.pre_shift_row,
1397 "x2", (double) x + disp->pida.eval_par.int_size_2 /
1398 2 + disp->pida.eval_par.pre_shift_col,
1399 "y2", (double) y + disp->pida.eval_par.int_size_2 /
1400 2 + disp->pida.eval_par.pre_shift_row,
1401 NULL);
1403 * put the interrogation area back to its original location
1405 } else {
1406 update_intreg1(disp, disp->index_y_old, disp->index_x_old);
1407 update_intreg2(disp, disp->index_y_old, disp->index_x_old);
1414 static void
1415 canvas_display_motion_notify__SINGLE_POINT_MS (Display *disp,
1416 gint x,
1417 gint y
1419 /*-----------------------------------------------------------------------------
1420 * Interrogates at a single arbitrary point in the image.
1421 * I am using the first interrogation area ([0][0]) temporarly for
1422 * displaying
1425 GtkWidget * view_piv_display0 =
1426 gtk_object_get_data(GTK_OBJECT(disp->mwin),
1427 "view_piv_display0");
1429 if (disp->intreg.gci_intreg1[0][0] != NULL &&
1430 disp->intreg.gci_intreg2[0][0] != NULL
1432 if (!GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1434 if (disp->intreg.gci_intreg1[0][0] != NULL) {
1435 gnome_canvas_item_show
1436 (GNOME_CANVAS_ITEM(disp->intreg.gci_intreg1[0][0]));
1438 if (disp->intreg.gci_intreg2[0][0] != NULL) {
1439 gnome_canvas_item_show
1440 (GNOME_CANVAS_ITEM(disp->intreg.gci_intreg2[0][0]));
1442 disp->display_intregs = TRUE;
1445 if (disp->pida.exist_piv && disp->pida.scaled_piv) {
1446 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%3.2f mm y=%3.2f mm",
1447 (gfloat) x * disp->img.image_par.s_scale *10e2
1448 + (gfloat) disp->img.image_par.z_off_x *10e2,
1449 (gfloat) y * disp->img.image_par.s_scale *10e2
1450 + (gfloat) disp->img.image_par.z_off_y *10e2);
1451 } else {
1452 g_snprintf(msg_display, GPIV_MAX_CHARS, "x=%d px y=%d px", x, y);
1455 gnome_canvas_item_set
1456 (GNOME_CANVAS_ITEM(disp->intreg.gci_intreg1[0][0]),
1457 "x1", (double) x - disp->pida.eval_par.int_size_1 / 2,
1458 "y1", (double) y - disp->pida.eval_par.int_size_1 / 2,
1459 "x2", (double) x + disp->pida.eval_par.int_size_1 / 2,
1460 "y2", (double) y + disp->pida.eval_par.int_size_1 / 2,
1461 NULL);
1463 gnome_canvas_item_set
1464 (GNOME_CANVAS_ITEM(disp->intreg.gci_intreg2[0][0]),
1465 "x1", (double) x - disp->pida.eval_par.int_size_1 / 2
1466 + disp->pida.eval_par.pre_shift_col,
1467 "y1", (double) y - disp->pida.eval_par.int_size_1 / 2
1468 + disp->pida.eval_par.pre_shift_row,
1469 "x2", (double) x + disp->pida.eval_par.int_size_1 / 2
1470 + disp->pida.eval_par.pre_shift_col,
1471 "y2", (double) y + disp->pida.eval_par.int_size_1 / 2
1472 + disp->pida.eval_par.pre_shift_row,
1473 NULL);
1475 } else {
1476 create_intreg1 (disp, 0, 0);
1477 create_intreg2 (disp, 0, 0);
1484 static char *
1485 canvas_display_button_press__SINGLE_AREA_MS (GpivConsole *gpiv,
1486 Display *disp,
1487 gint x,
1488 gint y
1490 /*-----------------------------------------------------------------------------
1491 * Performs action on mouse button press when SINGLE_AREA_MS has been enabled
1494 char * err_msg = NULL;
1495 gint index_x = 0, index_y = 0;
1496 GtkWidget * view_piv_display0 =
1497 gtk_object_get_data(GTK_OBJECT(disp->mwin),
1498 "view_piv_display0");
1500 if (disp->pida.exist_piv
1501 /* && GTK_CHECK_MENU_ITEM(view_piv_display0)->active */
1502 /* && disp->intreg.data.nx == disp->pida.piv_data.nx */
1503 /* && disp->intreg.data.ny == disp->pida.piv_data.ny */
1507 /* search_nearest_index(disp, x, y, &index_x, &index_y, */
1508 /* DATA_TYPE__INTREG); */
1509 search_nearest_index (disp, x, y, &index_x, &index_y,
1510 DATA_TYPE__PIV);
1513 if (m_select == SINGLE_AREA_MS) {
1514 /* if (disp->intreg.data.point_x[index_y][index_x] == */
1515 /* disp->pida.piv_data.point_x[index_y][index_x] */
1516 /* && disp->intreg.data.point_y[index_y][index_x] == */
1517 /* disp->pida.piv_data.point_y[index_y][index_x] */
1518 /* ) { */
1519 m_select_index_x = index_x;
1520 m_select_index_y = index_y;
1521 /* gpiv_warning("canvas_display_button_press__SINGLE_AREA_MS:: index_x=%d index_y = %d", index_x, index_y); */
1522 /* } else { */
1523 /* set__NO_MS(gpiv, disp); */
1524 /* err_msg = "Interrogation area's have to be at the same positions \nas the already existing piv data"; */
1525 /* warning_gpiv(err_msg); */
1526 /* return err_msg; */
1527 /* } */
1528 /* g_message("x=%d point_x=%d y=%d point_x=%d */
1530 } else if (m_select == DRAG_MS) {
1531 m_select_index_x = index_x;
1532 m_select_index_y = index_y;
1533 disp->pida.piv_data.point_x[m_select_index_y]
1534 [m_select_index_x] = (float) x;
1535 disp->pida.piv_data.point_y[m_select_index_y]
1536 [m_select_index_x] = (float) y;
1537 /* BUGFIXED ? */
1538 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1539 disp->intreg.data.point_x[m_select_index_y]
1540 [m_select_index_x] = (float) x;
1541 disp->intreg.data.point_y[m_select_index_y]
1542 [m_select_index_x] = (float) y;
1544 } else {
1545 err_msg = "canvas_display_button_press__SINGLE_AREA_MS: should not arrive here";
1546 error_gpiv(err_msg);
1551 return err_msg;
1556 static char *
1557 canvas_display_button_release__SINGLE_AREA_MS (GpivConsole *gpiv,
1558 Display *disp,
1559 gdouble x,
1560 gdouble y
1562 /*-----------------------------------------------------------------------------
1563 * Performs action on mouse button release when SINGLE_AREA_MS has been enabled
1566 char * err_msg = NULL;
1567 gint index_x = 0, index_y = 0;
1568 GtkWidget * view_piv_display0 =
1569 gtk_object_get_data(GTK_OBJECT(disp->mwin),
1570 "view_piv_display0");
1572 /* g_message ("canvas_display_button_release__SINGLE_AREA_MS:: x = %f y = %f" */
1573 /* " xgrab_first = %f ygrab_first = %f " */
1574 /* "m_select_index_x = %d m_select_index_y = %d", */
1575 /* x, y, disp->xgrab_first, disp->ygrab_first, */
1576 /* m_select_index_x, m_select_index_y */
1577 /* ); */
1579 if (disp->pida.exist_piv
1580 /* && GTK_CHECK_MENU_ITEM(view_piv_display0)->active */
1581 /* && disp->intreg.data.nx == disp->pida.piv_data.nx */
1582 /* && disp->intreg.data.ny == disp->pida.piv_data.ny */
1586 * There will only be action if the pointer, during pressing the button (as
1587 * defined in canvas_display_button_press__SINGLE_AREA_MS), is at identical
1588 * position as during releasing the button.
1590 search_nearest_index(disp, (gint) x, (gint) y, &index_x, &index_y,
1591 DATA_TYPE__PIV);
1592 /* gpiv_warning("canvas_display_button_release__SINGLE_AREA_MS:: index_x=%d index_y = %d", index_x, index_y); */
1596 if (m_select_index_x == index_x
1597 && m_select_index_y == index_y
1599 gl_eval_par.int_point_col = m_select_index_x;
1600 gl_eval_par.int_point_row = m_select_index_y;
1601 gpiv_piv_cp_parameters (gl_eval_par, &disp->pida.eval_par, TRUE,
1602 FALSE);
1603 /* g_message ("canvas_display_button_release__SINGLE_AREA_MS:: calling interrogate"); */
1604 #ifdef NEW_INTERFACE
1605 disp->pida.piv_data = interrogate (disp->img.img1,
1606 disp->img.img2, disp->img.image_par,
1607 disp->pida.eval_par, gpiv);
1608 #else
1609 interrogate (&disp->pida.piv_data, disp->img.img1,
1610 disp->img.img2, disp->img.image_par,
1611 disp->pida.eval_par, gpiv);
1612 #endif
1613 /* exec_piv (gpiv); */
1614 /* g_message ("canvas_display_button_release__SINGLE_AREA_MS:: back from interrogate"); */
1615 if (disp->pida.gci_vector[m_select_index_y][m_select_index_x]
1616 != NULL) {
1617 update_vector (&disp->pida, m_select_index_y, m_select_index_x);
1618 } else {
1619 create_vector (&disp->pida, m_select_index_y, m_select_index_x);
1622 /* g_message ("canvas_display_button_release__SINGLE_AREA_MS:: display vector"); */
1623 /* disp->pida.exist_piv = TRUE; */
1624 disp->display_piv = TRUE;
1625 if (m_select == DRAG_MS) {
1626 if (disp->intreg.
1627 gci_intreg1[m_select_index_y][m_select_index_x]
1628 != NULL)
1629 update_intreg1 (disp, m_select_index_y, m_select_index_x);
1630 if (disp->intreg.
1631 gci_intreg2[m_select_index_y][m_select_index_x]
1632 != NULL)
1633 update_intreg2 (disp, m_select_index_y, m_select_index_x);
1636 } else {
1637 err_msg = "moved pointer too far away from \nintar to be interrogated";
1638 return err_msg;
1641 } else {
1642 /* err_msg = "Interrogation area's and piv data must already exist \n and must be of identic quantity!"; */
1643 err_msg = "Piv data must exist!";
1644 warning_gpiv (err_msg);
1645 return err_msg;
1649 if (!shift_pressed) set__NO_MS(gpiv, disp);
1650 return err_msg;
1655 static void
1656 canvas_display_button_press__SINGLE_POINT_MS (GpivConsole *gpiv,
1657 Display *disp,
1658 gint x,
1659 gint y
1661 /*-----------------------------------------------------------------------------
1662 * Performs action on mouse button release when SINGLE_POINT_MS has
1663 * been enabled
1666 GtkWidget *view_piv_display0 =
1667 gtk_object_get_data(GTK_OBJECT(disp->mwin),
1668 "view_piv_display0");
1670 if (disp->pida.exist_piv) {
1671 destroy_all_vectors(&disp->pida);
1672 gpiv_free_pivdata (&disp->pida.piv_data);
1673 disp->pida.exist_piv = FALSE;
1674 if (disp->pida.scaled_piv) {
1675 gpiv_free_pivdata (&disp->pida.piv_data_scaled);
1676 disp->pida.scaled_piv = FALSE;
1680 free_post_bufmems(disp);
1681 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1682 destroy_all_intregs(disp);
1684 m_select_index_x = 0;
1685 m_select_index_y = 0;
1686 disp->pida.eval_par.int_point_col = (float) x;
1687 disp->pida.eval_par.int_point_row = (float) y;
1688 disp->pida.piv_data.nx = 1;
1689 disp->pida.piv_data.ny = 1;
1690 gpiv_alloc_pivdata(&disp->pida.piv_data);
1691 disp->pida.exist_piv = TRUE;
1693 disp->pida.piv_data.point_x[0][0] = (float) x;
1694 disp->pida.piv_data.point_y[0][0] = (float) y;
1696 disp->intreg.data.nx = 1;
1697 disp->intreg.data.ny = 1;
1698 create_all_intregs(disp);
1699 disp->intreg.exist_int = TRUE;
1701 disp->intreg.data.point_x[0][0] = (float) x;
1702 disp->intreg.data.point_y[0][0] = (float) y;
1703 show_all_intregs(disp);
1704 disp->display_intregs = TRUE;
1706 interrogate(&disp->pida.piv_data,
1707 disp->img.img1,
1708 disp->img.img2,
1709 disp->img.image_par,
1710 disp->pida.eval_par,
1711 gpiv);
1712 disp->display_piv = TRUE;
1714 create_all_vectors(&disp->pida);
1715 gnome_canvas_update_now(GNOME_CANVAS(disp->canvas));
1717 if (!shift_pressed) set__NO_MS(gpiv, disp);
1722 static void
1723 canvas_display_button_release__HVLINE_MS (Display *disp,
1724 GpivConsole *gpiv,
1725 GtkWidget * view_piv_display0,
1726 gdouble x,
1727 gdouble y
1729 /*-----------------------------------------------------------------------------
1730 * Performs action on mouse button release when H_LINE_MS or V_LINE_MS has
1731 * been enabled
1734 gdouble l_col_start,l_col_end, l_row_start, l_row_end;
1735 gboolean reset_display_intregs;
1737 /* g_message ("canvas_display_button_release__HVLINE_MS:: x = %f y = %f" */
1738 /* " xgrab_first = %f ygrab_first = %f", */
1739 /* x, y, disp->xgrab_first, disp->ygrab_first); */
1741 if (GTK_CHECK_MENU_ITEM (view_piv_display0)->active) {
1743 * Remove exixting intreg contours
1744 * Disable displaying temporarly to avoid several calls to
1745 * the 'on_spinbutton_piv_int' function
1747 destroy_all_intregs (disp);
1748 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
1749 (view_piv_display0),
1750 FALSE);
1751 reset_display_intregs = TRUE;
1754 /* if (disp->pida.exist_piv) { */
1755 /* destroy_all_vectors(&disp->pida); */
1756 /* disp->display_piv = FALSE; */
1757 /* } */
1760 m_select_index_x = 0;
1761 m_select_index_y = 0;
1764 * Vertical line selected
1766 if (m_select == V_LINE_MS) {
1767 if (y >= disp->ygrab_first) {
1768 l_row_start = (gdouble) (disp->ygrab_first / disp->zoom_factor);
1769 l_row_end = (gdouble) (y / disp->zoom_factor);
1770 disp->pida.eval_par.row_start = (gint) l_row_start;
1771 disp->pida.eval_par.row_end = (gint) l_row_end;
1772 disp->pida.eval_par.int_line_row_end = (gint) l_row_end;
1773 } else {
1774 l_row_start = (gdouble) (y / disp->zoom_factor);
1775 l_row_end = (gdouble) (disp->ygrab_first / disp->zoom_factor);
1776 disp->pida.eval_par.row_start = (gint) l_row_start;
1777 disp->pida.eval_par.row_end = (gint) l_row_end;
1778 disp->pida.eval_par.int_line_row_end = (gint) l_row_end;
1781 l_col_start = (gdouble) (disp->xgrab_first / disp->zoom_factor -
1782 disp->pida.eval_par.int_size_2 / 2 + 1);
1783 disp->pida.eval_par.col_start = (gint) l_col_start;
1785 l_col_end = (gdouble) (disp->xgrab_first / disp->zoom_factor +
1786 disp->pida.eval_par.int_size_2 / 2 +
1787 disp->pida.eval_par.pre_shift_col);
1788 disp->pida.eval_par.col_end = (gint) l_col_end;
1792 * Horizontal line selected
1794 } else if (m_select == H_LINE_MS) {
1795 if (x >= disp->xgrab_first) {
1796 l_col_start = (gdouble) (disp->xgrab_first / disp->zoom_factor);
1797 l_col_end = (gdouble) (x / disp->zoom_factor);
1798 disp->pida.eval_par.col_start = (gint) l_col_start;
1799 disp->pida.eval_par.col_end = (gint) l_col_end;
1800 disp->pida.eval_par.int_line_col_end = (gint) l_col_end;
1801 } else {
1802 l_col_start = (gdouble) (x / disp->zoom_factor);
1803 l_col_end = (gdouble) (disp->xgrab_first / disp->zoom_factor);
1804 disp->pida.eval_par.col_start = (gint) l_col_start;
1805 disp->pida.eval_par.col_end = (gint) l_col_end;
1806 disp->pida.eval_par.int_line_col_end = (gint) l_col_end;
1809 l_row_start = (gdouble) (disp->ygrab_first / disp->zoom_factor -
1810 disp->pida.eval_par.int_size_2 / 2 + 1);
1811 disp->pida.eval_par.row_start = (gint) l_row_start;
1813 l_row_end = (gdouble) (disp->ygrab_first / disp->zoom_factor +
1814 disp->pida.eval_par.int_size_2 / 2 +
1815 disp->pida.eval_par.pre_shift_col);
1816 disp->pida.eval_par.row_end = (gint) l_row_end;
1819 } else {
1820 g_warning("canvas_display_button_release__HVLINE_MS: H_LINE_MS or V_LINE_MS inactive");
1823 if (gci_line != NULL) destroy_line();
1824 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1825 create_all_intregs(disp);
1829 * updating entry's for col/row_start_end
1831 /* g_message ("canvas_display_button_release__HVLINE_MS:: zoom_factor = %f col_start = %f col_end = %f" */
1832 /* " row_start = %f row_end = %f", */
1833 /* disp->zoom_factor, l_col_start, l_col_end, l_row_start, l_row_end); */
1835 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1836 (gpiv->piveval->spinbutton_colstart),
1837 (gdouble) l_col_start);
1839 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1840 (gpiv->piveval->spinbutton_rowstart),
1841 (gdouble) l_row_start);
1843 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1844 (gpiv->piveval->spinbutton_colend),
1845 (gdouble) l_col_end);
1848 * The last call to on_spinbutton_piv_int will update the contours of the intregs
1850 if (reset_display_intregs) {
1851 /* g_message ("release__HV:: resetting"); */
1852 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
1853 (view_piv_display0),
1854 TRUE);
1857 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1858 (gpiv->piveval->spinbutton_rowend),
1859 (gdouble) l_row_end);
1861 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1862 /* create_all_intregs (disp); */
1869 static void
1870 canvas_display_button_press__DISABLE_POINT_MS (Display *disp,
1871 gint x,
1872 gint y
1874 /*-----------------------------------------------------------------------------
1875 * Performs action on mouse button press when DISABLE_POINT_MS has
1876 * been enabled
1879 gchar *err_msg;
1880 gint index_x = 0, index_y = 0;
1881 GtkWidget * view_piv_display0 =
1882 gtk_object_get_data(GTK_OBJECT(disp->mwin),
1883 "view_piv_display0");
1885 if ( m_select == DISABLE_POINT_MS ) {
1886 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active) {
1887 search_nearest_index(disp, x, y, &index_x, &index_y,
1888 DATA_TYPE__INTREG);
1889 } else {
1890 search_nearest_index(disp, x, y, &index_x, &index_y,
1891 DATA_TYPE__PIV);
1894 disp->pida.piv_data.peak_no[index_y][index_x] = -1;
1895 disp->pida.piv_data.snr[index_y][index_x] = GPIV_SNR_DISABLE;
1897 if (disp->pida.post_par.set == TRUE) {
1898 disp->pida.piv_data.dx[index_y][index_x] =
1899 disp->pida.post_par.set_dx;
1900 disp->pida.piv_data.dy[index_y][index_x] =
1901 disp->pida.post_par.set_dx;
1903 update_vector(&disp->pida, index_y, index_x);
1905 } else if ( m_select == ENABLE_AREA_MS ) {
1906 enable_col_start = x;
1907 enable_row_start = y;
1908 assert( gci_aoi == NULL);
1909 gci_aoi =
1910 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(disp->canvas)
1912 gnome_canvas_rect_get_type(),
1913 "x1", (double) x,
1914 "y1", (double) y,
1915 "x2", (double) x,
1916 "y2", (double) y,
1917 "outline_color", "yellow",
1918 "width_units", (double) THICKNESS,
1919 NULL);
1922 } else if ( m_select == DISABLE_AREA_MS) {
1923 enable_col_start = x;
1924 enable_row_start = y;
1925 assert( gci_aoi == NULL);
1926 gci_aoi =
1927 gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(disp->canvas)
1929 gnome_canvas_rect_get_type(),
1930 "x1", (double) x,
1931 "y1", (double) y,
1932 "x2", (double) x,
1933 "y2", (double) y,
1934 "outline_color", "yellow",
1935 "width_units", (double) THICKNESS,
1936 NULL);
1937 } else {
1938 err_msg = _("no image or piv data");
1939 warning_gpiv(err_msg);
1946 static void
1947 set__NO_MS (GpivConsole *gpiv,
1948 Display *disp
1950 /*-----------------------------------------------------------------------------
1951 * Reset mouse selection to inactive
1954 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1955 (gpiv->piveval->radiobutton_mouse_1),
1956 TRUE);
1957 cursor = gdk_cursor_new (GDK_DOTBOX);
1958 gdk_window_set_cursor (disp->mwin->window, cursor);
1963 static void
1964 search_nearest_index (Display * disp,
1965 gint x,
1966 gint y,
1967 gint * index_x,
1968 gint * index_y,
1969 gint data_type
1971 /*-----------------------------------------------------------------------------
1972 * Search nearest index belongin to x an y points
1975 gint i, j, x_min = 10e4, y_min = 10e4, dif;
1977 if (data_type == DATA_TYPE__INTREG) {
1978 for (i = 0, j = 0; i < disp->intreg.data.ny; i++) {
1979 dif = abs(y - (int) disp->intreg.data.point_y[i][j]);
1980 if (dif < y_min) {
1981 y_min = dif;
1982 *index_y = i;
1986 for (i = 0, j = 0; j < disp->intreg.data.nx; j++) {
1987 dif = abs(x - (int) disp->intreg.data.point_x[i][j]);
1988 if (dif < x_min) {
1989 x_min = dif;
1990 *index_x = j;
1995 } else if (data_type == DATA_TYPE__PIV) {
1996 for (i = 0, j = 0; i < disp->pida.piv_data.ny; i++) {
1997 dif = abs(y - (int) disp->pida.piv_data.point_y[i][j]);
1998 if (dif < y_min) {
1999 y_min = dif;
2000 *index_y = i;
2004 for (i = 0, j = 0; j < disp->pida.piv_data.nx; j++) {
2005 dif = abs(x - (int) disp->pida.piv_data.point_x[i][j]);
2006 if (dif < x_min) {
2007 x_min = dif;
2008 *index_x = j;
2012 } else {
2013 g_warning("search_nearest_index: Inavalid Data Type");
2020 static void
2021 highlight_intreg (gint index_y,
2022 gint index_x,
2023 Display * disp
2025 /*-----------------------------------------------------------------------------
2026 * Highlights first and second interrogation area's
2029 GtkWidget * view_piv_display0 =
2030 gtk_object_get_data(GTK_OBJECT(disp->mwin),
2031 "view_piv_display0");
2033 if (GTK_CHECK_MENU_ITEM(view_piv_display0)->active
2034 && index_y <= disp->intreg.data.ny
2035 && index_x <= disp->intreg.data.nx) {
2037 if (disp->intreg.gci_intreg1[disp->index_y_old][disp->index_x_old]
2038 != NULL) {
2039 gnome_canvas_item_set(disp->intreg.gci_intreg1
2040 [disp->index_y_old][disp->index_x_old],
2041 "outline_color", "red",
2042 NULL);
2045 if (disp->intreg.gci_intreg2[disp->index_y_old][disp->index_x_old]
2046 != NULL) {
2047 gnome_canvas_item_set(disp->intreg.gci_intreg2
2048 [disp->index_y_old][disp->index_x_old],
2049 "outline_color", "blue",
2050 NULL);
2053 if (disp->intreg.gci_intreg1[index_y][index_x] != NULL) {
2054 gnome_canvas_item_set(disp->intreg.gci_intreg1[index_y][index_x],
2055 "outline_color", "yellow",
2056 NULL);
2057 gnome_canvas_item_raise_to_top(disp->intreg.
2058 gci_intreg1[index_y][index_x]);
2061 if (disp->intreg.gci_intreg2[index_y][index_x] != NULL) {
2062 gnome_canvas_item_set(disp->intreg.gci_intreg2[index_y][index_x],
2063 "outline_color", "green",
2064 NULL);
2065 gnome_canvas_item_raise_to_top(disp->intreg.
2066 gci_intreg2[index_y][index_x]);
2074 static void
2075 create_msg_display_with_pivdata (GpivPivData piv_data,
2076 gint index_y,
2077 gint index_x,
2078 gint scale
2080 /*-----------------------------------------------------------------------------
2081 * Displays message with piv data values
2085 if (scale) {
2086 if (piv_data.snr[index_y][index_x] == GPIV_SNR_NAN) {
2087 g_snprintf (msg_display, GPIV_MAX_CHARS,
2088 "xp=%3.2fmm yp=%3.2fmm %s",
2089 piv_data.point_x[index_y][index_x] * 1e3,
2090 piv_data.point_y[index_y][index_x] * 1e3,
2091 _("Disabled: not a number"));
2092 } else if (piv_data.snr[index_y][index_x] == GPIV_SNR_DISABLE) {
2093 g_snprintf (msg_display, GPIV_MAX_CHARS,
2094 "xp=%3.2fmm yp=%3.2fmm %s",
2095 piv_data.point_x[index_y][index_x] * 1e3,
2096 piv_data.point_y[index_y][index_x] * 1e3,
2097 _("Disabled manually"));
2098 } else {
2099 g_snprintf (msg_display, GPIV_MAX_CHARS,
2100 "xp=%3.2fmm yp=%3.2fmm U=%3.2fm/s V=%3.2fm/s"
2101 " snr=%3.2f peak #%d",
2102 piv_data.point_x[index_y][index_x] * 1e3,
2103 piv_data.point_y[index_y][index_x] * 1e3,
2104 piv_data.dx[index_y][index_x],
2105 piv_data.dy[index_y][index_x],
2106 piv_data.snr[index_y][index_x],
2107 piv_data.peak_no[index_y][index_x]);
2110 } else {
2111 if (piv_data.snr[index_y][index_x] == GPIV_SNR_NAN) {
2112 g_snprintf (msg_display, GPIV_MAX_CHARS,
2113 "xp=%3.0fpx yp=%3.0fpx %s",
2114 piv_data.point_x[index_y][index_x],
2115 piv_data.point_y[index_y][index_x],
2116 _("Disabled: not a number"));
2117 } else if (piv_data.snr[index_y][index_x] == GPIV_SNR_DISABLE) {
2118 g_snprintf (msg_display, GPIV_MAX_CHARS,
2119 "xp=%3.0fpx yp=%3.0fpx %s",
2120 piv_data.point_x[index_y][index_x],
2121 piv_data.point_y[index_y][index_x],
2122 _("Disabled manually"));
2123 } else {
2124 g_snprintf (msg_display, GPIV_MAX_CHARS,
2125 "xp=%3.0fpx yp=%3.0fpx dx=%3.2fpx dy=%3.2fpx"
2126 " snr=%3.2f peak #%d",
2127 piv_data.point_x[index_y][index_x],
2128 piv_data.point_y[index_y][index_x],
2129 piv_data.dx[index_y][index_x],
2130 piv_data.dy[index_y][index_x],
2131 piv_data.snr[index_y][index_x],
2132 piv_data.peak_no[index_y][index_x]);
2140 static void
2141 create_msg_display_with_scdata (GpivScalarData sc_data,
2142 gchar *sc_type,
2143 gint index_y,
2144 gint index_x,
2145 gint scale
2147 /*-----------------------------------------------------------------------------
2148 * Displays message with scalar data values
2151 if (scale) {
2152 g_snprintf (msg_display, GPIV_MAX_CHARS,
2153 "xp=%3.2fmm yp=%3.2fmm %s=%3.2f1/s",
2154 sc_data.point_x[index_y][index_x] * 1e3,
2155 sc_data.point_y[index_y][index_x] * 1e3,
2156 sc_type,
2157 sc_data.scalar[index_y][index_x]);
2158 } else {
2159 g_snprintf (msg_display, GPIV_MAX_CHARS,
2160 "xp=%3.0fpx yp=%3.0fpx %s=%3.2f",
2161 sc_data.point_x[index_y][index_x],
2162 sc_data.point_y[index_y][index_x],
2163 sc_type,
2164 sc_data.scalar[index_y][index_x]);
2170 static void
2171 create_msg_display_with_pivscdata (GpivPivData piv_data,
2172 GpivScalarData sc_data,
2173 gchar *sc_type,
2174 gint index_y,
2175 gint index_x,
2176 gint scale
2178 /*-----------------------------------------------------------------------------
2179 * Displays message with piv and scalar data values
2182 if (scale) {
2183 g_snprintf (msg_display, GPIV_MAX_CHARS,
2184 "xp=%3.2fmm yp=%3.2fmm U=%3.2fm/s V=%3.2fm/s "
2185 "snr=%3.2f peak #%d %s=%3.2f1/s",
2186 piv_data.point_x[index_y][index_x] * 1e3,
2187 piv_data.point_y[index_y][index_x] * 1e3,
2188 piv_data.dx[index_y][index_x],
2189 piv_data.dy[index_y][index_x],
2190 piv_data.snr[index_y][index_x],
2191 piv_data.peak_no[index_y][index_x],
2192 sc_type,
2193 sc_data.scalar[index_y][index_x]);
2194 } else {
2195 g_snprintf (msg_display, GPIV_MAX_CHARS,
2196 "xp=%3.0fpx yp=%3.0fpx dx=%3.2fpx dy=%3.2fpx "
2197 "snr=%3.2f peak #%d %s=%3.2f",
2198 piv_data.point_x[index_y][index_x],
2199 piv_data.point_y[index_y][index_x],
2200 piv_data.dx[index_y][index_x],
2201 piv_data.dy[index_y][index_x],
2202 piv_data.snr[index_y][index_x],
2203 piv_data.peak_no[index_y][index_x],
2204 sc_type,
2205 sc_data.scalar[index_y][index_x]);
2211 static void
2212 create_line (Display *disp,
2213 gint x1,
2214 gint y1,
2215 gint x2,
2216 gint y2
2218 /*-----------------------------------------------------------------------------
2221 GnomeCanvasPoints *points;
2222 points = gnome_canvas_points_new (2);
2224 /* g_message("CREATE_LINE:: x1 = %d y1 = %d x2 = %d y2 = %d", x1, y1, x2, y2); */
2226 if (disp != NULL
2227 && gci_line == NULL) {
2229 points->coords[0] = x1;
2230 points->coords[1] = y1;
2231 points->coords[2] = x2;
2232 points->coords[3] = y2;
2233 gci_line =
2234 gnome_canvas_item_new (gnome_canvas_root(GNOME_CANVAS(disp->canvas)),
2235 gnome_canvas_line_get_type(),
2236 "points", points,
2237 "fill_color", "yellow",
2238 "width_units", (double) THICKNESS,
2239 NULL);
2241 gnome_canvas_points_free (points);
2246 static void
2247 update_line (gint x1,
2248 gint y1,
2249 gint x2,
2250 gint y2
2252 /*-----------------------------------------------------------------------------
2255 GnomeCanvasPoints *points;
2256 points = gnome_canvas_points_new (2);
2258 /* g_message("UPDATE_LINE:: x1 = %d y1 = %d x2 = %d y2 = %d", x1, y1, x2, y2); */
2260 if (gci_line != NULL) {
2262 points->coords[0] = x1;
2263 points->coords[1] = y1;
2264 points->coords[2] = x2;
2265 points->coords[3] = y2;
2267 gnome_canvas_item_set (GNOME_CANVAS_ITEM(/* disp-> */gci_line),
2268 "points", points,
2269 "fill_color", "yellow",
2270 "width_units", (double) THICKNESS,
2271 NULL);
2273 gnome_canvas_points_free (points);
2278 static void
2279 destroy_line ()
2280 /*-----------------------------------------------------------------------------
2283 if (gci_line != NULL) {
2285 gtk_object_destroy(GTK_OBJECT (gci_line));
2286 gci_line = NULL;
2292 static void
2293 create_rect (Display *disp,
2294 gint x,
2295 gint y
2297 /*-----------------------------------------------------------------------------
2300 if (disp != NULL
2301 && gci_aoi == NULL) {
2303 /* g_message("CREATE_RECT:: x = %d y = %d", x, y); */
2305 gci_aoi =
2306 gnome_canvas_item_new (gnome_canvas_root
2307 (GNOME_CANVAS(disp->canvas)),
2308 gnome_canvas_rect_get_type(),
2309 "x1", (double) x,
2310 "y1", (double) y,
2311 "x2", (double) x,
2312 "y2", (double) y,
2313 "outline_color", "yellow",
2314 "width_units", (double) THICKNESS,
2315 NULL);
2321 static void
2322 update_rect (gint x,
2323 gint y
2325 /*-----------------------------------------------------------------------------
2328 if (gci_aoi != NULL) {
2330 gnome_canvas_item_set (GNOME_CANVAS_ITEM(gci_aoi),
2331 "x2", (double) x,
2332 "y2", (double) y,
2333 NULL);
2338 static void
2339 destroy_rect ()
2340 /*-----------------------------------------------------------------------------
2343 if (gci_aoi != NULL) {
2345 gtk_object_destroy (GTK_OBJECT (gci_aoi));
2346 gci_aoi = NULL;
2351 gdouble
2352 gtk_adjustment_get_lower (GtkAdjustment *adjustment)
2354 /* g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), 0.); */
2356 return adjustment->lower;
2361 static void
2362 pane_canvas (Display *disp,
2363 gfloat x,
2364 gfloat y
2366 /*-----------------------------------------------------------------------------
2369 pane_canvas_x (disp, x);
2370 pane_canvas_y (disp, y);
2375 static void
2376 pane_canvas_x (Display *disp,
2377 gfloat x
2379 /*-----------------------------------------------------------------------------
2382 GtkAdjustment *adj = GTK_ADJUSTMENT (disp->hadj);
2383 /* gdouble adj_value = gtk_adjustment_get_value */
2384 (GTK_ADJUSTMENT (disp->hadj));
2385 gdouble diff;
2386 gdouble adj_new;
2388 diff = x - disp->xgrab_first;
2389 /* g_message ("PANE_CANVAS_X:: x = %f x_first = %f => diff = %f", */
2390 /* x, disp->xgrab_first, diff); */
2392 adj_new = (adj->value - diff);
2393 /* g_message ("PANE_CANVAS_X:: value = %f lower = %f upper = %f page_s = %f => adj_new = %f", */
2394 /* adj->value, adj->lower, adj->upper, adj->page_size, adj_new); */
2396 if (adj_new >= adj->lower
2397 && adj_new < adj->upper - adj->page_size) {
2398 /* g_message ("PANE_CANVAS_X:: passed if ()"); */
2400 gtk_adjustment_set_value (GTK_ADJUSTMENT (disp->hadj),
2401 adj_new
2409 static void
2410 pane_canvas_y (Display *disp,
2411 gfloat y
2413 /*-----------------------------------------------------------------------------
2416 GtkAdjustment *adj = GTK_ADJUSTMENT (disp->vadj);
2417 /* gdouble adj_value = gtk_adjustment_get_value */
2418 /* (GTK_ADJUSTMENT (disp->vadj)); */
2419 gdouble diff;
2420 gdouble adj_new;
2422 diff = y - disp->ygrab_first;
2423 adj_new = (adj->value - diff);
2424 if (adj_new >= 0
2425 && adj_new < adj->upper - adj->page_size) {
2426 gtk_adjustment_set_value (GTK_ADJUSTMENT (disp->vadj),
2427 adj_new