1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 c-style: "K&R" -*- */
3 /*----------------------------------------------------------------------
5 gpiv - Graphic program for Particle Image Velocimetry, based on gtk/gnome
8 Copyright (C) 2006, 2007, 2008
11 This file is part of gpiv.
13 Gpiv is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ----------------------------------------------------------------------*/
32 #include "display_zoom.h"
33 #include "piveval_interrogate.h"
38 canvas_display_motion_notify__NO_MS (Display
*disp
,
46 canvas_display_button_release__AOI_MS (Display
*disp
,
48 GtkWidget
*view_piv_display0
,
54 canvas_display_motion_notify__DRAGINT_MS (Display
*disp
,
62 canvas_display_motion_notify__SINGLE_POINT_MS (Display
*disp
,
69 canvas_display_button_press__SINGLE_AREA_MS (GpivConsole
*gpiv
,
76 canvas_display_button_release__SINGLE_AREA_MS (GpivConsole
*gpiv
,
83 canvas_display_button_press__SINGLE_POINT_MS (GpivConsole
*gpiv
,
90 canvas_display_button_release__HVLINE_MS (Display
*disp
,
92 GtkWidget
*view_piv_display0
,
97 canvas_display_button_press__DISABLE_POINT_MS (Display
*disp
,
102 set__NO_MS (GpivConsole
*gpiv
,
107 search_nearest_index (Display
*disp
,
116 highlight_intreg (gint index_y
,
122 create_msg_display_with_pivdata (GpivPivData
*piv_data
,
129 create_msg_display_with_scdata (GpivScalarData
*sc_data
,
136 create_msg_display_with_pivscdata (GpivPivData
*piv_data
,
137 GpivScalarData
*sc_data
,
145 create_line (Display
*disp
,
153 update_line (gint x1
,
168 create_rect (Display
*disp
,
177 pane_canvas (Display
*disp
,
183 pane_canvas_x (Display
*disp
,
188 pane_canvas_y (Display
*disp
,
193 * Public display functions
196 canvas_display_enter_notify (GtkWidget
*widget
,
197 GdkEventMotion
*event
,
200 /*-----------------------------------------------------------------------------
203 Display
*disp
= gtk_object_get_data(GTK_OBJECT(widget
), "disp");
204 GtkWidget
*view_piv_display0
=
205 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
206 "view_piv_display0");
209 disp
->index_x_old
= 0;
210 disp
->index_y_old
= 0;
211 disp
->index_old
= FALSE
;
214 if (m_select
== NO_MS
) {
215 cursor
= gdk_cursor_new(GDK_DOTBOX
);
217 } else if (m_select
== SINGLE_AREA_MS
218 || m_select
== ENABLE_POINT_MS
219 || m_select
== DISABLE_POINT_MS
) {
220 cursor
= gdk_cursor_new(GDK_CROSSHAIR
);
224 } else if ( m_select
== DRAG_MS
) {
225 cursor
= gdk_cursor_new(GDK_CROSS
);
229 } else if (m_select
== SINGLE_POINT_MS
230 || m_select
== V_LINE_MS
231 || m_select
== H_LINE_MS
233 if (m_select
== V_LINE_MS
) {
234 cursor
= gdk_cursor_new (GDK_SB_V_DOUBLE_ARROW
);
236 if (m_select
== H_LINE_MS
) {
237 cursor
= gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW
);
240 if (m_select
== SINGLE_POINT_MS
) {
241 cursor
= gdk_cursor_new(GDK_CROSS
);
245 if (display_act
->pida
->exist_piv
&& disp
->display_piv
) {
246 hide_all_vectors(display_act
->pida
);
249 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
250 hide_all_intregs(disp
);
255 } else if (m_select
== AOI_MS
256 || m_select
== ENABLE_AREA_MS
257 || m_select
== DISABLE_AREA_MS
) {
258 cursor
= gdk_cursor_new(GDK_CROSSHAIR
);
260 if (m_select
== AOI_MS
) {
261 if (display_act
->pida
->exist_piv
&& disp
->display_piv
) {
262 hide_all_vectors(display_act
->pida
);
265 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
266 hide_all_intregs(disp
);
272 } else if (m_select
== SPANLENGTH_MS
273 || m_select
== V_SPANLENGTH_MS
274 || m_select
== H_SPANLENGTH_MS
276 cursor
= gdk_cursor_new(GDK_CROSS
);
279 gdk_window_set_cursor(disp
->mwin
->window
, cursor
);
288 canvas_display_motion_notify (GtkWidget
*widget
,
289 GdkEventMotion
*event
,
292 /*-----------------------------------------------------------------------------
295 Display
*disp
= gtk_object_get_data(GTK_OBJECT(widget
), "disp");
296 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
297 GtkAdjustment
*hadj
= GTK_ADJUSTMENT (disp
->hadj
);
298 GtkAdjustment
*vadj
= GTK_ADJUSTMENT (disp
->hadj
);
302 gint index_y
= 0, index_x
= 0;
304 GdkModifierType state
;
305 GnomeCanvasPoints
*points
;
308 points
= gnome_canvas_points_new(2);
310 if (event
->is_hint
) {
311 gdk_window_get_pointer (event
->window
, &x_grab
, &y_grab
, &state
);
320 state
= event
->state
;
324 /* g_message ("canvas_display_motion_notify:: x = %f y = %f x/zoom = %f y/zoom = %f", */
325 /* x, y, x / disp->zoom_factor, y / disp->zoom_factor); */
327 /* if (x >= hadj->value && x < hadj->value + hadj->page_size */
328 /* && y >= vadj->value && y < vadj->value + vadj->page_size) { */
331 if (x
>= 0 && x
< disp
->img
->image
->header
->ncolumns
* disp
->zoom_factor
332 && y
>= 0 && y
< disp
->img
->image
->header
->nrows
* disp
->zoom_factor
) {
335 * display particle displacements / velocities and its attributes,
337 if (m_select
== NO_MS
338 || m_select
== SINGLE_AREA_MS
339 || m_select
== DRAG_MS
340 || m_select
== ENABLE_POINT_MS
341 || m_select
== DISABLE_POINT_MS
) {
345 * display locations of interrogation area's and estimators,
346 * only display locations of interrogation area's,
350 canvas_display_motion_notify__NO_MS (disp
,
351 (gint
) (x
/ disp
->zoom_factor
),
352 (gint
) (y
/ disp
->zoom_factor
),
357 * Pane (moving) the canvas. Identic effect as moving the scroll bars.
359 if (m_select
== NO_MS
) {
360 if (state
& GDK_BUTTON1_MASK
) {
361 pane_canvas (disp
, x
, y
);
366 if ( m_select
== DRAG_MS
) {
367 canvas_display_motion_notify__DRAGINT_MS (disp
,
368 (gint
) (x
/ disp
->zoom_factor
),
369 (gint
) (y
/ disp
->zoom_factor
),
374 disp
->index_x_old
= index_x
;
375 disp
->index_y_old
= index_y
;
379 * Only displays pointer position
381 } else if (m_select
== AOI_MS
382 || m_select
== ENABLE_AREA_MS
383 || m_select
== DISABLE_AREA_MS
) {
384 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d px y=%d px",
385 (gint
) (x
/ disp
->zoom_factor
),
386 (gint
) (y
/ disp
->zoom_factor
));
389 * Update the drawing of the rectangle
391 if (state
& GDK_BUTTON1_MASK
) {
392 if (gci_aoi
!= NULL
) {
393 update_rect((gint
) (x
/ disp
->zoom_factor
),
394 (gint
) (y
/ disp
->zoom_factor
));
400 } else if ( m_select
== SINGLE_POINT_MS
) {
401 canvas_display_motion_notify__SINGLE_POINT_MS (disp
,
402 (gint
) x
/ disp
->zoom_factor
,
403 (gint
) y
/ disp
->zoom_factor
);
408 * Update a vertical line
410 } else if (m_select
== V_LINE_MS
) {
411 if (state
& GDK_BUTTON1_MASK
) {
412 g_snprintf (msg_display
, GPIV_MAX_CHARS
, "x=%d px y=%d px",
413 (gint
) (disp
->xgrab_first
/ disp
->zoom_factor
),
414 (gint
) (y
/ disp
->zoom_factor
));
415 if ( gci_line
!= NULL
) {
416 update_line ((gint
) (disp
->xgrab_first
/ disp
->zoom_factor
) ,
417 (gint
) (disp
->ygrab_first
/ disp
->zoom_factor
),
418 (gint
) (disp
->xgrab_first
/ disp
->zoom_factor
),
419 (gint
) (y
/ disp
->zoom_factor
));
422 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d px y=%d px",
423 (gint
) (x
/ disp
->zoom_factor
),
424 (gint
) (y
/ disp
->zoom_factor
));
430 * Update a horizontal line
432 } else if (m_select
== H_LINE_MS
) {
433 if (state
& GDK_BUTTON1_MASK
) {
434 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d y=%d",
435 (gint
) (x
/ disp
->zoom_factor
),
436 (gint
) (disp
->ygrab_first
/ disp
->zoom_factor
));
437 if (gci_line
!= NULL
) {
438 update_line ((gint
) (disp
->xgrab_first
/ disp
->zoom_factor
),
439 (gint
) (disp
->ygrab_first
/ disp
->zoom_factor
),
440 (gint
) (x
/ disp
->zoom_factor
),
441 (gint
) (disp
->ygrab_first
/ disp
->zoom_factor
));
444 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d px y=%d px",
445 (gint
) (x
/ disp
->zoom_factor
),
446 (gint
) (y
/ disp
->zoom_factor
));
451 } else if (m_select
== SPANLENGTH_MS
) {
452 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d px y=%d px",
453 (gint
) (x
/ disp
->zoom_factor
),
454 (gint
) (y
/ disp
->zoom_factor
));
456 if (state
& GDK_BUTTON1_MASK
&& gci_line
!= NULL
) {
457 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d y=%d",
458 (gint
) (x
/ disp
->zoom_factor
),
459 (gint
) (y
/ disp
->zoom_factor
));
460 update_line ((gint
) (disp
->xgrab_first
/ disp
->zoom_factor
),
461 (gint
) (disp
->ygrab_first
/ disp
->zoom_factor
),
462 (gint
) (x
/ disp
->zoom_factor
),
463 (gint
) (y
/ disp
->zoom_factor
));
466 } else if (m_select
== V_SPANLENGTH_MS
) {
467 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d px y=%d px",
468 (gint
) (x
/ disp
->zoom_factor
),
469 (gint
) (y
/ disp
->zoom_factor
));
471 if (state
& GDK_BUTTON1_MASK
&& gci_line
!= NULL
) {
472 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d y=%d",
473 (gint
) (disp
->xgrab_first
/ disp
->zoom_factor
),
474 (gint
) (y
/ disp
->zoom_factor
));
475 update_line ((gint
) (disp
->xgrab_first
/ disp
->zoom_factor
),
476 (gint
) (disp
->ygrab_first
/ disp
->zoom_factor
),
477 (gint
) (disp
->xgrab_first
/ disp
->zoom_factor
),
478 (gint
) (y
/ disp
->zoom_factor
));
481 } else if (m_select
== H_SPANLENGTH_MS
) {
482 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d px y=%d px",
483 (gint
) (x
/ disp
->zoom_factor
),
484 (gint
) (y
/ disp
->zoom_factor
));
486 if (state
& GDK_BUTTON1_MASK
&& gci_line
!= NULL
) {
487 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d y=%d",
488 (gint
) (x
/ disp
->zoom_factor
),
489 (gint
) (disp
->ygrab_first
/ disp
->zoom_factor
));
490 update_line ((gint
) (disp
->xgrab_first
/ disp
->zoom_factor
),
491 (gint
) (disp
->ygrab_first
/ disp
->zoom_factor
),
492 (gint
) (x
/ disp
->zoom_factor
),
493 (gint
) (disp
->ygrab_first
/ disp
->zoom_factor
));
500 gnome_appbar_push(GNOME_APPBAR(disp
->appbar
), msg_display
);
501 gnome_appbar_push(GNOME_APPBAR(gpiv
->appbar
), msg_display
);
507 /* g_message("canvas_display_motion_notify: out of image borders"); */
510 gnome_canvas_points_free(points
);
517 canvas_display_button_press (GtkWidget
*widget
,
518 GdkEventButton
*event
,
521 /*-----------------------------------------------------------------------------
524 Display
*disp
= gtk_object_get_data(GTK_OBJECT(widget
), "disp");
525 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
528 gint index_x
= 0, index_y
= 0;
529 GdkModifierType state
;
530 GnomeCanvasPoints
*points
;
531 GtkWidget
*view_piv_display0
=
532 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
533 "view_piv_display0");
536 points
= gnome_canvas_points_new(2);
537 GtkMenu
*menu
= GTK_MENU (disp
->display_popupmenu
);
539 gdk_window_get_pointer(event
->window
, &x_grab
, &y_grab
, &state
);
545 if (event
->button
== 1) {
546 disp
->xgrab_first
= x
;
547 disp
->ygrab_first
= y
;
548 /* g_message ("canvas_display_button_press:: xgrab_first = %f ygrab_first = %f", */
549 /* disp->xgrab_first, disp->ygrab_first); */
553 if (m_select
== NO_MS
) {
554 cursor
= gdk_cursor_new (GDK_FLEUR
);
555 gdk_window_set_cursor (disp
->mwin
->window
, cursor
);
556 /* g_message ("canvas_display_button_press:: x_grab = %d y_grab = %d", */
557 /* x_grab, y_grab); */
558 /* g_message ("CANVAS_DISPLAY_BUTTON_PRESS:: x = %f y = %f", x, y); */
562 * select Area Of Interest
564 } else if (m_select
== AOI_MS
) {
566 * storige of original AOI
568 disp
->intreg
->col_start_old
= disp
->pida
->piv_par
->col_start
;
569 disp
->intreg
->row_start_old
= disp
->pida
->piv_par
->row_start
;
571 /* g_message ("CANVAS_DISPLAY_BUTTON_PRESS (AOI):: x_grab = %d y_grab = %d", */
572 /* x_grab, y_grab); */
574 disp
->xgrab_first
/ disp
->zoom_factor
,
575 disp
->ygrab_first
/ disp
->zoom_factor
);
578 * select at single interrogation area
580 } else if ((m_select
== SINGLE_AREA_MS
|| m_select
== DRAG_MS
) &&
581 disp
->img
->exist_img
) {
582 canvas_display_button_press__SINGLE_AREA_MS (gpiv
, disp
,
583 x
/ disp
->zoom_factor
,
584 y
/ disp
->zoom_factor
);
587 * select a single point
589 } else if (m_select
== SINGLE_POINT_MS
&& disp
->img
->exist_img
) {
590 canvas_display_button_press__SINGLE_POINT_MS (gpiv
, disp
,
591 x
/ disp
->zoom_factor
,
592 y
/ disp
->zoom_factor
);
596 * select a vertical line
598 } else if (m_select
== V_LINE_MS
&& display_act
->img
->exist_img
) {
599 /* g_message ("CANVAS_DISPLAY_BUTTON_PRESS (V_LINE_MS) 11:: x_grab = %d y_grab = %d", */
600 /* x_grab, y_grab); */
601 if (gci_line
!= NULL
) destroy_line();
603 disp
->xgrab_first
/ disp
->zoom_factor
,
604 disp
->ygrab_first
/ disp
->zoom_factor
,
605 disp
->xgrab_first
/ disp
->zoom_factor
,
606 disp
->ygrab_first
/ disp
->zoom_factor
);
610 * select a horizontal line
612 } else if (m_select
== H_LINE_MS
&& disp
->img
->exist_img
) {
613 /* g_message ("CANVAS_DISPLAY_BUTTON_PRESS (H_LINE_MS) 1:: x_grab = %d y_grab = %d", */
614 /* x_grab, y_grab); */
615 if (gci_line
!= NULL
) destroy_line();
617 disp
->xgrab_first
/ disp
->zoom_factor
,
618 disp
->ygrab_first
/ disp
->zoom_factor
,
619 disp
->xgrab_first
/ disp
->zoom_factor
,
620 disp
->ygrab_first
/ disp
->zoom_factor
);
622 } else if ( m_select
== ENABLE_POINT_MS
) {
624 * Only active with piv data
626 if (disp
->pida
->exist_piv
&& disp
->display_piv
627 /* && GTK_CHECK_MENU_ITEM(view_piv_display0)->active */
629 search_nearest_index (disp
, x
, y
, &index_x
, &index_y
,
630 /* DATA_TYPE__INTREG); */
632 disp
->pida
->piv_data
->peak_no
[index_y
][index_x
] = 1;
633 update_vector (disp
->pida
, index_y
, index_x
);
638 * Enabling and disabling only active with piv data
640 } else if ((m_select
== DISABLE_POINT_MS
641 || m_select
== ENABLE_AREA_MS
642 || m_select
== DISABLE_AREA_MS
)
643 && disp
->pida
->exist_piv
&& disp
->display_piv
) {
644 canvas_display_button_press__DISABLE_POINT_MS (disp
, x
, y
);
647 } else if (m_select
== SPANLENGTH_MS
648 && disp
->img
->exist_img
) {
649 if (gci_line
!= NULL
) destroy_line();
651 disp
->xgrab_first
/ disp
->zoom_factor
,
652 disp
->ygrab_first
/ disp
->zoom_factor
,
653 disp
->xgrab_first
/ disp
->zoom_factor
,
654 disp
->ygrab_first
/ disp
->zoom_factor
);
658 } else if (m_select
== V_SPANLENGTH_MS
659 && disp
->img
->exist_img
) {
660 if (gci_line
!= NULL
) destroy_line();
662 disp
->xgrab_first
/ disp
->zoom_factor
,
663 disp
->ygrab_first
/ disp
->zoom_factor
,
664 disp
->xgrab_first
/ disp
->zoom_factor
,
665 disp
->ygrab_first
/ disp
->zoom_factor
);
669 } else if (m_select
== H_SPANLENGTH_MS
670 && disp
->img
->exist_img
) {
671 if (gci_line
!= NULL
) destroy_line();
673 disp
->xgrab_first
/ disp
->zoom_factor
,
674 disp
->ygrab_first
/ disp
->zoom_factor
,
675 disp
->xgrab_first
/ disp
->zoom_factor
,
676 disp
->ygrab_first
/ disp
->zoom_factor
);
680 g_warning(_("canvas_display_button_press: should not arrive here; m_select=%d"),
685 } else if (event
->button
== 3) {
686 gtk_menu_popup (menu
, NULL
, NULL
, NULL
, NULL
,
687 event
->button
, event
->time
);
691 gnome_canvas_points_free(points
);
697 canvas_display_button_release (GtkWidget
*widget
,
698 GdkEventButton
*event
,
701 /*-----------------------------------------------------------------------------
704 Display
*disp
= gtk_object_get_data(GTK_OBJECT(widget
), "disp");
705 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
706 GtkWidget
*view_piv_display0
=
707 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
708 "view_piv_display0");
712 GdkModifierType state
;
715 shift_pressed
= event
->state
& GDK_SHIFT_MASK
;
716 gdk_window_get_pointer (event
->window
, &x_grab
, &y_grab
, &state
);
718 /* BUGFIX: repair for different mouse selections */
723 /* g_message ("canvas_display_button_release:: x = %f y = %f", x, y); */
724 if (event
->button
== 1) {
726 if (m_select
== AOI_MS
&& gci_aoi
!= NULL
) {
727 canvas_display_button_release__AOI_MS (disp
, gpiv
,
734 } else if ((m_select
== V_LINE_MS
|| m_select
== H_LINE_MS
)
735 && disp
->img
->exist_img
) {
736 /* g_message ("CANVAS_DISPLAY_BUTTON_RELEASE (HV_LINE):: x_grab = %d y_grab = %d", */
737 /* x_grab, y_grab); */
738 canvas_display_button_release__HVLINE_MS (disp
, gpiv
,
746 * analyse at single interrogation area
748 } else if ((m_select
== SINGLE_AREA_MS
|| m_select
== DRAG_MS
) &&
749 disp
->img
->exist_img
) {
750 canvas_display_button_release__SINGLE_AREA_MS(gpiv
, disp
,
756 } else if (m_select
== ENABLE_AREA_MS
&& gci_aoi
!= NULL
) {
759 if (disp
->pida
->exist_piv
) {
760 for (i
= 0; i
< disp
->pida
->piv_data
->ny
; i
++) {
761 for (j
= 0; j
< disp
->pida
->piv_data
->nx
; j
++) {
762 if (disp
->pida
->piv_data
->point_x
[i
][j
] >=
764 && disp
->pida
->piv_data
->point_x
[i
][j
] <
766 && disp
->pida
->piv_data
->point_y
[i
][j
] >=
768 && disp
->pida
->piv_data
->point_y
[i
][j
] <
770 disp
->pida
->piv_data
->peak_no
[i
][j
] = 1;
771 if (disp
->display_piv
)
772 update_vector(disp
->pida
, i
, j
);
778 if (gci_aoi
!= NULL
) destroy_rect();
782 } else if (m_select
== DISABLE_AREA_MS
&& gci_aoi
!= NULL
) {
785 if (disp
->pida
->exist_piv
) {
786 for (i
= 0; i
< disp
->pida
->piv_data
->ny
; i
++) {
787 for (j
= 0; j
< disp
->pida
->piv_data
->nx
; j
++) {
788 if (disp
->pida
->piv_data
->point_x
[i
][j
] >=
790 && disp
->pida
->piv_data
->point_x
[i
][j
] <
792 && disp
->pida
->piv_data
->point_y
[i
][j
] >=
794 && disp
->pida
->piv_data
->point_y
[i
][j
] <
796 disp
->pida
->piv_data
->peak_no
[i
][j
] = -1;
797 disp
->pida
->piv_data
->snr
[i
][j
] = GPIV_SNR_DISABLE
;
799 if (disp
->pida
->post_par
->set
== TRUE
) {
800 disp
->pida
->piv_data
->dx
[i
][j
] =
801 disp
->pida
->post_par
->set_dx
;
802 disp
->pida
->piv_data
->dy
[i
][j
] =
803 disp
->pida
->post_par
->set_dx
;
806 if (disp
->display_piv
)
807 update_vector(disp
->pida
, i
, j
);
813 if (gci_aoi
!= NULL
) destroy_rect();
817 } else if (m_select
== SPANLENGTH_MS
818 && disp
->img
->exist_img
821 gfloat hdist
= abs ((x
- disp
->xgrab_first
) / disp
->zoom_factor
);
822 gfloat vdist
= abs ((y
- disp
->ygrab_first
) / disp
->zoom_factor
);
824 gpiv_var
->img_span_px
= sqrt (hdist
* hdist
+ vdist
* vdist
);
825 if (gci_line
!= NULL
) destroy_line ();
826 gtk_spin_button_set_value (GTK_SPIN_BUTTON
827 (gpiv
->imgh
->spinbutton_sscale_px
),
828 gpiv_var
->img_span_px
833 } else if (m_select
== V_SPANLENGTH_MS
834 && disp
->img
->exist_img
837 gpiv_var
->img_span_px
= abs ((y
- disp
->ygrab_first
) / disp
->zoom_factor
);
838 if (gci_line
!= NULL
) destroy_line ();
839 gtk_spin_button_set_value (GTK_SPIN_BUTTON
840 (gpiv
->imgh
->spinbutton_sscale_px
),
841 gpiv_var
->img_span_px
);
845 } else if (m_select
== H_SPANLENGTH_MS
846 && disp
->img
->exist_img
849 gpiv_var
->img_span_px
= abs ((x
- disp
->xgrab_first
) / disp
->zoom_factor
);
850 if (gci_line
!= NULL
) destroy_line ();
851 gtk_spin_button_set_value (GTK_SPIN_BUTTON
852 (gpiv
->imgh
->spinbutton_sscale_px
),
853 gpiv_var
->img_span_px
);
860 } else if (m_select
== GPIV_NONE
861 || m_select
== SINGLE_POINT_MS
862 || m_select
== ENABLE_POINT_MS
863 || m_select
== DISABLE_POINT_MS
865 cursor
= gdk_cursor_new (GDK_DOTBOX
);
866 gdk_window_set_cursor (disp
->mwin
->window
, cursor
);
869 g_warning(_("canvas_display_button_release: should not arrive here; m_select=%d"),
880 canvas_display_leave_notify (GtkWidget
*widget
,
881 GdkEventMotion
*event
,
884 /*-----------------------------------------------------------------------------
887 Display
*disp
= gtk_object_get_data(GTK_OBJECT(widget
), "disp");
888 GpivConsole
*gpiv
= gtk_object_get_data(GTK_OBJECT(widget
), "gpiv");
889 GtkWidget
*view_piv_display0
=
890 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
891 "view_piv_display0");
894 gnome_appbar_push(GNOME_APPBAR(disp
->appbar
),
895 disp
->msg_display_default
);
896 gnome_appbar_push(GNOME_APPBAR(gpiv
->appbar
), msg_default
);
899 if (m_select
== SINGLE_POINT_MS
900 && GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
902 if (!disp
->intreg
->exist_int
) {
903 update_intreg1(disp
, m_select_index_y
, m_select_index_x
);
904 update_intreg2(disp
, m_select_index_y
, m_select_index_x
);
907 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
908 show_all_intregs(disp
);
912 if (disp
->pida
->exist_piv
&& disp
->display_piv
) {
913 show_all_vectors(disp
->pida
);
917 } else if (m_select
== DRAG_MS
) {
918 if (!disp
->intreg
->exist_int
) {
919 update_intreg1(disp
, disp
->index_y_old
, disp
->index_x_old
);
920 update_intreg2(disp
, disp
->index_y_old
, disp
->index_x_old
);
923 } else if (m_select
== SINGLE_AREA_MS
&& disp
->intreg
->exist_int
) {
924 if (!disp
->intreg
->exist_int
) {
925 update_intreg1(disp
, 0, 0);
926 update_intreg2(disp
, 0, 0);
930 } else if (m_select
== AOI_MS
931 || m_select
== V_LINE_MS
932 || m_select
== H_LINE_MS
) {
933 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
934 show_all_intregs(disp
);
937 if (disp
->pida
->exist_piv
&& disp
->display_piv
) {
938 show_all_vectors(disp
->pida
);
941 if (gci_line
!= NULL
) {
942 gtk_object_destroy(GTK_OBJECT(gci_line
));
950 if (GDK_BUTTON1_MASK
) {
952 * Cancel AOI_MS selection
954 if (m_select
== AOI_MS
) {
955 if (gci_aoi
!= NULL
) {
956 disp
->pida
->piv_par
->col_start
= disp
->intreg
->col_start_old
;
957 disp
->pida
->piv_par
->row_start
= disp
->intreg
->row_start_old
;
958 gtk_spin_button_set_value(GTK_SPIN_BUTTON
959 (gpiv
->piveval
->spinbutton_colstart
),
960 disp
->pida
->piv_par
->col_start
);
961 gtk_spin_button_set_value(GTK_SPIN_BUTTON
962 (gpiv
->piveval
->spinbutton_rowstart
),
963 disp
->pida
->piv_par
->row_start
);
964 if (gci_aoi
!= NULL
) destroy_rect();
967 /* show_all_intregs(disp); */
969 } else if ( m_select
== ENABLE_AREA_MS
970 || m_select
== DISABLE_AREA_MS
) {
971 enable_col_start
= 0;
972 enable_row_start
= 0;
975 if (gci_aoi
!= NULL
) destroy_rect();
978 * Cancel V_LINE_MS, LINE_MS selection
979 * (V_, H_) SPANLENGTH_MS
981 } else if (m_select
== V_LINE_MS
982 || m_select
== H_LINE_MS
983 || m_select
== SPANLENGTH_MS
984 || m_select
== V_SPANLENGTH_MS
985 || m_select
== H_SPANLENGTH_MS
987 if (gci_line
!= NULL
) destroy_line();
997 if (cursor
!= NULL
) {
998 gdk_cursor_destroy(cursor
);
1002 if (disp
->intreg
->gci_intreg2
[disp
->index_y_old
][disp
->index_x_old
]
1004 update_intreg2(disp
, disp
->index_y_old
, disp
->index_x_old
);
1007 if (disp
->intreg
->gci_intreg1
[disp
->index_y_old
][disp
->index_x_old
]
1009 update_intreg1(disp
, disp
->index_y_old
, disp
->index_x_old
);
1012 disp
->index_x_old
= 0;
1013 disp
->index_y_old
= 0;
1020 * Private display functions
1025 canvas_display_motion_notify__NO_MS (Display
*disp
,
1031 /*-----------------------------------------------------------------------------
1032 * Moves pointer over the display canvas if no mouse selection (NO_MS) is set
1035 GpivPivData
*piv_data
= disp
->pida
->piv_data
;
1036 GpivPivData
*piv_data_scaled
= disp
->pida
->piv_data_scaled
;
1037 GpivScalarData
*vor_data
= disp
->pida
->vor_data
;
1038 GpivScalarData
*vor_data_scaled
= disp
->pida
->vor_data_scaled
;
1039 GpivScalarData
*sstrain_data
= disp
->pida
->sstrain_data
;
1040 GpivScalarData
*sstrain_data_scaled
= disp
->pida
->sstrain_data_scaled
;
1041 GpivScalarData
*nstrain_data
= disp
->pida
->nstrain_data
;
1042 GpivScalarData
*nstrain_data_scaled
= disp
->pida
->nstrain_data_scaled
;
1043 GtkWidget
*view_piv_display0
=
1044 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
1045 "view_piv_display0");
1051 if ((disp
->pida
->exist_piv
&& disp
->display_piv
1052 && GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
1053 && piv_data
->ny
== disp
->intreg
->data
->ny
1054 && piv_data
->nx
== disp
->intreg
->data
->nx
1055 && piv_data
->point_y
[0][0] == disp
->intreg
->data
->point_y
[0][0]
1056 && piv_data
->point_x
[0][0] == disp
->intreg
->data
->point_x
[0][0]
1057 && piv_data
->point_y
[piv_data
->ny
- 1][piv_data
->nx
- 1] ==
1058 disp
->intreg
->data
->point_y
[disp
->intreg
->data
->ny
- 1]
1059 [disp
->intreg
->data
->nx
- 1]
1060 && piv_data
->point_x
[piv_data
->ny
- 1][piv_data
->nx
- 1] ==
1061 disp
->intreg
->data
->point_x
[disp
->intreg
->data
->ny
- 1]
1062 [disp
->intreg
->data
->nx
- 1] )
1063 || (disp
->pida
->exist_piv
&& disp
->display_piv
1064 && !GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
)
1067 search_nearest_index(disp
, x
, y
, index_x
, index_y
, DATA_TYPE__PIV
);
1068 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1069 highlight_intreg(*index_y
, *index_x
, disp
);
1073 if (disp
->pida
->exist_vor
1074 && disp
->display_scalar
== SHOW_SC_VORTICITY
) {
1075 if (disp
->pida
->scaled_piv
) {
1076 create_msg_display_with_pivscdata (piv_data_scaled
,
1081 disp
->pida
->scaled_piv
);
1083 create_msg_display_with_pivscdata (piv_data
,
1088 disp
->pida
->scaled_piv
);
1091 } else if (disp
->pida
->exist_sstrain
1092 && disp
->display_scalar
== SHOW_SC_SSTRAIN
) {
1093 if (disp
->pida
->scaled_piv
) {
1094 create_msg_display_with_pivscdata (piv_data_scaled
,
1095 sstrain_data_scaled
,
1099 disp
->pida
->scaled_piv
);
1101 create_msg_display_with_pivscdata (piv_data
,
1106 disp
->pida
->scaled_piv
);
1109 } else if (disp
->pida
->exist_nstrain
1110 && disp
->display_scalar
== SHOW_SC_NSTRAIN
) {
1112 if (disp
->pida
->scaled_piv
) {
1113 create_msg_display_with_pivscdata (piv_data_scaled
,
1114 nstrain_data_scaled
,
1118 disp
->pida
->scaled_piv
);
1120 create_msg_display_with_pivscdata (piv_data
,
1125 disp
->pida
->scaled_piv
);
1129 if (disp
->pida
->scaled_piv
) {
1130 create_msg_display_with_pivdata (piv_data_scaled
,
1133 disp
->pida
->scaled_piv
);
1136 create_msg_display_with_pivdata (piv_data
,
1139 disp
->pida
->scaled_piv
);
1145 * piv data exist, but are not displayed
1146 * displays eventually piv-derived scalar data
1148 } else if ((disp
->pida
->exist_piv
1149 && !disp
->display_piv
1150 && GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
1151 && piv_data
->ny
== disp
->intreg
->data
->ny
1152 && piv_data
->nx
== disp
->intreg
->data
->nx
1153 && piv_data
->point_y
[0][0] == disp
->intreg
->data
->point_y
[0][0]
1154 && piv_data
->point_x
[0][0] == disp
->intreg
->data
->point_x
[0][0]
1155 && piv_data
->point_y
[piv_data
->ny
- 1][piv_data
->nx
- 1] ==
1156 disp
->intreg
->data
->point_y
[disp
->intreg
->data
->ny
- 1]
1157 [disp
->intreg
->data
->nx
- 1]
1158 && piv_data
->point_x
[piv_data
->ny
- 1][piv_data
->nx
- 1] ==
1159 disp
->intreg
->data
->point_x
[disp
->intreg
->data
->ny
- 1]
1160 [disp
->intreg
->data
->nx
- 1]
1161 && ((disp
->pida
->exist_vor
1162 && disp
->display_scalar
== SHOW_SC_VORTICITY
)
1163 || (disp
->pida
->exist_sstrain
1164 && disp
->display_scalar
== SHOW_SC_SSTRAIN
)
1165 || (disp
->pida
->exist_nstrain
&&
1166 disp
->display_scalar
== SHOW_SC_NSTRAIN
))
1168 || (disp
->pida
->exist_piv
1169 && !disp
->display_piv
1170 && !GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
1171 && ((disp
->pida
->exist_vor
1172 && disp
->display_scalar
== SHOW_SC_VORTICITY
)
1173 || (disp
->pida
->exist_sstrain
1174 && disp
->display_scalar
== SHOW_SC_SSTRAIN
)
1175 || (disp
->pida
->exist_nstrain
1176 && disp
->display_scalar
== SHOW_SC_NSTRAIN
))
1180 search_nearest_index(disp
, x
, y
, index_x
, index_y
,
1182 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1183 highlight_intreg(*index_y
, *index_x
, disp
);
1186 if (disp
->pida
->exist_vor
&&
1187 disp
->display_scalar
== SHOW_SC_VORTICITY
) {
1188 if (disp
->pida
->scaled_piv
) {
1189 create_msg_display_with_scdata(vor_data_scaled
,
1193 disp
->pida
->scaled_piv
);
1195 create_msg_display_with_scdata(vor_data
,
1199 disp
->pida
->scaled_piv
);
1202 } else if (disp
->pida
->exist_sstrain
&&
1203 disp
->display_scalar
== SHOW_SC_SSTRAIN
) {
1204 if (disp
->pida
->scaled_piv
) {
1205 create_msg_display_with_scdata(sstrain_data_scaled
,
1209 disp
->pida
->scaled_piv
);
1211 create_msg_display_with_scdata(sstrain_data
,
1215 disp
->pida
->scaled_piv
);
1218 } else if (disp
->pida
->exist_nstrain
1219 && disp
->display_scalar
== SHOW_SC_NSTRAIN
) {
1220 if (disp
->pida
->scaled_piv
) {
1221 create_msg_display_with_scdata(nstrain_data_scaled
,
1225 disp
->pida
->scaled_piv
);
1227 create_msg_display_with_scdata(nstrain_data
,
1231 disp
->pida
->scaled_piv
);
1236 * PIV data (and resulting derivatives) do not exist are and not displayed
1237 * Interrogation area's are displayed
1239 } else if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1240 search_nearest_index(disp
, x
, y
, index_x
, index_y
, DATA_TYPE__INTREG
);
1241 highlight_intreg(*index_y
, *index_x
, disp
);
1243 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%3.2f y=%3.2f i=%d j=%d ",
1244 disp
->intreg
->data
->point_x
[*index_y
][*index_x
],
1245 disp
->intreg
->data
->point_y
[*index_y
][*index_x
],
1246 *index_y
, *index_x
);
1250 * Only image is displayed
1252 } else if (disp
->display_backgrnd
== SHOW_BG_IMG1
) {
1253 if (disp
->pida
->scaled_piv
) {
1254 g_snprintf(msg_display
, GPIV_MAX_CHARS
,
1255 "xp=%d px ==> %5.4f m yp=%d px ==> %5.4f m img #1: pixval=%d",
1257 disp
->img
->image
->header
->s_scale
* x
* 1e-3
1258 + disp
->img
->image
->header
->z_off_x
,
1260 disp
->img
->image
->header
->s_scale
* y
* 1e-3
1261 + disp
->img
->image
->header
->z_off_y
,
1262 disp
->img
->image
->frame1
[y
][x
]
1265 g_snprintf(msg_display
, GPIV_MAX_CHARS
,
1266 "xp=%d px yp=%d px img #1: pixval=%d",
1268 disp
->img
->image
->frame1
[y
][x
]
1272 } else if (disp
->display_backgrnd
== SHOW_BG_IMG2
) {
1273 if (disp
->pida
->scaled_piv
) {
1274 g_snprintf(msg_display
, GPIV_MAX_CHARS
,
1275 "xp=%d px ==> %5.4f m yp=%d px ==> %5.4f m img #1: pixval=%d",
1277 disp
->img
->image
->header
->s_scale
* x
* 1e-3
1278 + disp
->img
->image
->header
->z_off_x
,
1280 disp
->img
->image
->header
->s_scale
* y
* 1e-3
1281 + disp
->img
->image
->header
->z_off_y
,
1282 disp
->img
->image
->frame2
[y
][x
]
1285 g_snprintf(msg_display
, GPIV_MAX_CHARS
,
1286 "xp=%d px yp=%d px img #2: pixval=%d",
1288 disp
->img
->image
->frame2
[y
][x
]
1293 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "No data are displayed");
1301 canvas_display_button_release__AOI_MS (Display
*disp
,
1303 GtkWidget
*view_piv_display0
,
1307 /*-----------------------------------------------------------------------------
1308 * Performs action on mouse button release when AOI_MS has been enabled
1311 PivEval
*eval
= gpiv
->piveval
;
1312 gdouble l_col_start
, l_col_end
, l_row_start
, l_row_end
;
1315 if (gci_aoi
!= NULL
) destroy_rect();
1317 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1318 destroy_all_intregs(disp
);
1322 /* g_message ("canvas_display_button_release__AOI_MS:: x = %f y = %f" */
1323 /* " xgrab_first = %f ygrab_first = %f", */
1324 /* x, y, disp->xgrab_first, disp->ygrab_first); */
1326 if (x
>= disp
->xgrab_first
) {
1327 l_col_start
= disp
->xgrab_first
/ disp
->zoom_factor
;
1328 l_col_end
= x
/ disp
->zoom_factor
;
1329 disp
->pida
->piv_par
->col_start
= (gint
) l_col_start
;
1330 disp
->pida
->piv_par
->col_end
= (gint
) l_col_end
;
1332 l_col_end
= disp
->xgrab_first
/ disp
->zoom_factor
;
1333 l_col_start
= x
/ disp
->zoom_factor
;
1334 disp
->pida
->piv_par
->col_end
= (gint
) l_col_end
;
1335 disp
->pida
->piv_par
->col_start
= (gint
) l_col_start
;
1338 if (y
>= disp
->ygrab_first
) {
1339 l_row_start
= disp
->ygrab_first
/ disp
->zoom_factor
;
1340 l_row_end
= y
/ disp
->zoom_factor
;
1341 disp
->pida
->piv_par
->row_start
= (gint
) l_row_start
;
1342 disp
->pida
->piv_par
->row_end
= (gint
) l_row_end
;
1344 l_row_end
= disp
->ygrab_first
/ disp
->zoom_factor
;
1345 l_row_start
= y
/ disp
->zoom_factor
;
1346 disp
->pida
->piv_par
->row_end
= (gint
) l_row_end
;
1347 disp
->pida
->piv_par
->row_start
= (gint
) l_row_start
;
1352 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1353 (eval
->spinbutton_colstart
),
1354 (gdouble
)l_col_start
);
1356 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1357 (eval
->spinbutton_colend
),
1358 (gdouble
) l_col_end
);
1360 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1361 (eval
->spinbutton_rowstart
),
1362 (gdouble
) l_row_start
);
1364 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1365 (eval
->spinbutton_rowend
),
1366 (gdouble
) l_row_end
);
1368 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1369 create_all_intregs (disp
);
1377 canvas_display_motion_notify__DRAGINT_MS (Display
*disp
,
1383 /*-----------------------------------------------------------------------------
1384 * displaces interrogation area nearest to pointer
1387 if (disp
->intreg
->exist_int
) {
1388 if (!disp
->index_old
) {
1389 disp
->index_x_old
= *index_x
;
1390 disp
->index_y_old
= *index_y
;
1391 disp
->index_old
= TRUE
;
1394 if (*index_x
== disp
->index_x_old
1395 && *index_y
== disp
->index_y_old
) {
1397 gnome_canvas_item_set
1398 (GNOME_CANVAS_ITEM(disp
->intreg
->
1399 gci_intreg1
[*index_y
][*index_x
]),
1400 "x1", (double) x
- disp
->pida
->piv_par
->int_size_f
/ 2,
1401 "y1", (double) y
- disp
->pida
->piv_par
->int_size_f
/ 2,
1402 "x2", (double) x
+ disp
->pida
->piv_par
->int_size_f
/ 2,
1403 "y2", (double) y
+ disp
->pida
->piv_par
->int_size_f
/ 2,
1406 gnome_canvas_item_set
1407 (GNOME_CANVAS_ITEM(disp
->intreg
->
1408 gci_intreg2
[*index_y
][*index_x
]),
1409 "x1", (double) x
- disp
->pida
->piv_par
->int_size_i
/
1410 2 + disp
->pida
->piv_par
->pre_shift_col
,
1411 "y1", (double) y
- disp
->pida
->piv_par
->int_size_i
/
1412 2 + disp
->pida
->piv_par
->pre_shift_row
,
1413 "x2", (double) x
+ disp
->pida
->piv_par
->int_size_i
/
1414 2 + disp
->pida
->piv_par
->pre_shift_col
,
1415 "y2", (double) y
+ disp
->pida
->piv_par
->int_size_i
/
1416 2 + disp
->pida
->piv_par
->pre_shift_row
,
1419 * put the interrogation area back to its original location
1422 update_intreg1(disp
, disp
->index_y_old
, disp
->index_x_old
);
1423 update_intreg2(disp
, disp
->index_y_old
, disp
->index_x_old
);
1431 canvas_display_motion_notify__SINGLE_POINT_MS (Display
*disp
,
1435 /*-----------------------------------------------------------------------------
1436 * Interrogates at a single arbitrary point in the image.
1437 * I am using the first interrogation area ([0][0]) temporarly for
1441 GtkWidget
*view_piv_display0
=
1442 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
1443 "view_piv_display0");
1446 if (disp
->intreg
->gci_intreg1
[0][0] != NULL
&&
1447 disp
->intreg
->gci_intreg2
[0][0] != NULL
1449 if (!GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1451 if (disp
->intreg
->gci_intreg1
[0][0] != NULL
) {
1452 gnome_canvas_item_show
1453 (GNOME_CANVAS_ITEM(disp
->intreg
->gci_intreg1
[0][0]));
1455 if (disp
->intreg
->gci_intreg2
[0][0] != NULL
) {
1456 gnome_canvas_item_show
1457 (GNOME_CANVAS_ITEM(disp
->intreg
->gci_intreg2
[0][0]));
1459 disp
->display_intregs
= TRUE
;
1462 if (disp
->pida
->exist_piv
&& disp
->pida
->scaled_piv
) {
1463 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%3.2f mm y=%3.2f mm",
1464 (gfloat
) x
* disp
->img
->image
->header
->s_scale
*10e2
1465 + (gfloat
) disp
->img
->image
->header
->z_off_x
*10e2
,
1466 (gfloat
) y
* disp
->img
->image
->header
->s_scale
*10e2
1467 + (gfloat
) disp
->img
->image
->header
->z_off_y
*10e2
);
1469 g_snprintf(msg_display
, GPIV_MAX_CHARS
, "x=%d px y=%d px", x
, y
);
1472 gnome_canvas_item_set
1473 (GNOME_CANVAS_ITEM(disp
->intreg
->gci_intreg1
[0][0]),
1474 "x1", (double) x
- disp
->pida
->piv_par
->int_size_f
/ 2,
1475 "y1", (double) y
- disp
->pida
->piv_par
->int_size_f
/ 2,
1476 "x2", (double) x
+ disp
->pida
->piv_par
->int_size_f
/ 2,
1477 "y2", (double) y
+ disp
->pida
->piv_par
->int_size_f
/ 2,
1480 gnome_canvas_item_set
1481 (GNOME_CANVAS_ITEM(disp
->intreg
->gci_intreg2
[0][0]),
1482 "x1", (double) x
- disp
->pida
->piv_par
->int_size_f
/ 2
1483 + disp
->pida
->piv_par
->pre_shift_col
,
1484 "y1", (double) y
- disp
->pida
->piv_par
->int_size_f
/ 2
1485 + disp
->pida
->piv_par
->pre_shift_row
,
1486 "x2", (double) x
+ disp
->pida
->piv_par
->int_size_f
/ 2
1487 + disp
->pida
->piv_par
->pre_shift_col
,
1488 "y2", (double) y
+ disp
->pida
->piv_par
->int_size_f
/ 2
1489 + disp
->pida
->piv_par
->pre_shift_row
,
1493 create_intreg1 (disp
, 0, 0);
1494 create_intreg2 (disp
, 0, 0);
1502 canvas_display_button_press__SINGLE_AREA_MS (GpivConsole
*gpiv
,
1507 /*-----------------------------------------------------------------------------
1508 * Performs action on mouse button press when SINGLE_AREA_MS has been enabled
1511 char *err_msg
= NULL
;
1512 gint index_x
= 0, index_y
= 0;
1513 GtkWidget
*view_piv_display0
=
1514 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
1515 "view_piv_display0");
1518 if (disp
->pida
->exist_piv
1519 /* && GTK_CHECK_MENU_ITEM(view_piv_display0)->active */
1520 /* && disp->intreg->data->nx == disp->pida->piv_data->nx */
1521 /* && disp->intreg->data->ny == disp->pida->piv_data->ny */
1525 /* search_nearest_index(disp, x, y, &index_x, &index_y, */
1526 /* DATA_TYPE__INTREG); */
1527 search_nearest_index (disp
, x
, y
, &index_x
, &index_y
,
1531 if (m_select
== SINGLE_AREA_MS
) {
1532 /* if (disp->intreg->data->point_x[index_y][index_x] == */
1533 /* disp->pida->piv_data->point_x[index_y][index_x] */
1534 /* && disp->intreg->data->point_y[index_y][index_x] == */
1535 /* disp->pida->piv_data->point_y[index_y][index_x] */
1537 m_select_index_x
= index_x
;
1538 m_select_index_y
= index_y
;
1539 /* gpiv_warning("canvas_display_button_press__SINGLE_AREA_MS:: index_x=%d index_y = %d", index_x, index_y); */
1541 /* set__NO_MS(gpiv, disp); */
1542 /* err_msg = "Interrogation area's have to be at the same positions \nas the already existing piv data"; */
1543 /* warning_gpiv(err_msg); */
1544 /* return err_msg; */
1546 /* g_message("x=%d point_x=%d y=%d point_x=%d */
1548 } else if (m_select
== DRAG_MS
) {
1549 m_select_index_x
= index_x
;
1550 m_select_index_y
= index_y
;
1551 disp
->pida
->piv_data
->point_x
[m_select_index_y
]
1552 [m_select_index_x
] = (float) x
;
1553 disp
->pida
->piv_data
->point_y
[m_select_index_y
]
1554 [m_select_index_x
] = (float) y
;
1556 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1557 disp
->intreg
->data
->point_x
[m_select_index_y
]
1558 [m_select_index_x
] = (float) x
;
1559 disp
->intreg
->data
->point_y
[m_select_index_y
]
1560 [m_select_index_x
] = (float) y
;
1563 err_msg
= "canvas_display_button_press__SINGLE_AREA_MS: should not arrive here";
1564 error_gpiv(err_msg
);
1576 canvas_display_button_release__SINGLE_AREA_MS (GpivConsole
*gpiv
,
1581 /*-----------------------------------------------------------------------------
1582 * Performs action on mouse button release when SINGLE_AREA_MS has been enabled
1585 char *err_msg
= NULL
;
1586 gint index_x
= 0, index_y
= 0;
1587 GtkWidget
*view_piv_display0
=
1588 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
1589 "view_piv_display0");
1592 /* g_message ("canvas_display_button_release__SINGLE_AREA_MS:: x = %f y = %f" */
1593 /* " xgrab_first = %f ygrab_first = %f " */
1594 /* "m_select_index_x = %d m_select_index_y = %d", */
1595 /* x, y, disp->xgrab_first, disp->ygrab_first, */
1596 /* m_select_index_x, m_select_index_y */
1599 if (disp
->pida
->exist_piv
1600 /* && GTK_CHECK_MENU_ITEM(view_piv_display0)->active */
1601 /* && disp->intreg->data->nx == disp->pida->piv_data->nx */
1602 /* && disp->intreg->data->ny == disp->pida->piv_data->ny */
1606 * There will only be action if the pointer, during pressing the button (as
1607 * defined in canvas_display_button_press__SINGLE_AREA_MS), is at identical
1608 * position as during releasing the button->
1610 search_nearest_index(disp
, (gint
) x
, (gint
) y
, &index_x
, &index_y
,
1612 /* gpiv_warning("canvas_display_button_release__SINGLE_AREA_MS:: index_x=%d index_y = %d", index_x, index_y); */
1616 if (m_select_index_x
== index_x
1617 && m_select_index_y
== index_y
1619 gl_piv_par
->int_point_col
= m_select_index_x
;
1620 gl_piv_par
->int_point_row
= m_select_index_y
;
1621 disp
->pida
->piv_par
= gpiv_piv_cp_parameters (gl_piv_par
);
1623 /* g_message ("canvas_display_button_release__SINGLE_AREA_MS:: calling interrogate"); */
1625 disp
->pida
->piv_data
= interrogate_img (disp
->img
->image
,
1626 disp
->pida
->piv_par
,
1627 disp
->pida
->valid_par
,
1630 /* exec_piv (gpiv); */
1631 /* g_message ("canvas_display_button_release__SINGLE_AREA_MS:: back from interrogate"); */
1632 if (disp
->pida
->gci_vector
[m_select_index_y
][m_select_index_x
]
1634 update_vector (disp
->pida
, m_select_index_y
, m_select_index_x
);
1636 create_vector (disp
->pida
, m_select_index_y
, m_select_index_x
);
1639 /* g_message ("canvas_display_button_release__SINGLE_AREA_MS:: display vector"); */
1640 /* disp->pida->exist_piv = TRUE; */
1641 disp
->display_piv
= TRUE
;
1642 if (m_select
== DRAG_MS
) {
1644 gci_intreg1
[m_select_index_y
][m_select_index_x
]
1646 update_intreg1 (disp
, m_select_index_y
, m_select_index_x
);
1648 gci_intreg2
[m_select_index_y
][m_select_index_x
]
1650 update_intreg2 (disp
, m_select_index_y
, m_select_index_x
);
1654 err_msg
= "moved pointer too far away from \nintar to be interrogated";
1659 /* err_msg = "Interrogation area's and piv data must already exist \n and must be of identic quantity!"; */
1660 err_msg
= "Piv data must exist!";
1661 warning_gpiv (err_msg
);
1666 if (!shift_pressed
) set__NO_MS(gpiv
, disp
);
1675 canvas_display_button_press__SINGLE_POINT_MS (GpivConsole
*gpiv
,
1680 /*-----------------------------------------------------------------------------
1681 * Performs action on mouse button release when SINGLE_POINT_MS has
1685 GtkWidget
*view_piv_display0
=
1686 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
1687 "view_piv_display0");
1690 if (disp
->pida
->exist_piv
) {
1691 destroy_all_vectors(disp
->pida
);
1692 gpiv_free_pivdata (disp
->pida
->piv_data
);
1693 disp
->pida
->exist_piv
= FALSE
;
1694 if (disp
->pida
->scaled_piv
) {
1695 gpiv_free_pivdata (disp
->pida
->piv_data_scaled
);
1696 disp
->pida
->scaled_piv
= FALSE
;
1700 free_post_bufmems(disp
);
1701 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1702 destroy_all_intregs(disp
);
1704 m_select_index_x
= 0;
1705 m_select_index_y
= 0;
1706 disp
->pida
->piv_par
->int_point_col
= (float) x
;
1707 disp
->pida
->piv_par
->int_point_row
= (float) y
;
1708 disp
->pida
->piv_data
= gpiv_alloc_pivdata (1, 1);
1709 disp
->pida
->exist_piv
= TRUE
;
1711 disp
->pida
->piv_data
->point_x
[0][0] = (float) x
;
1712 disp
->pida
->piv_data
->point_y
[0][0] = (float) y
;
1714 disp
->intreg
->data
->nx
= 1;
1715 disp
->intreg
->data
->ny
= 1;
1716 create_all_intregs(disp
);
1717 disp
->intreg
->exist_int
= TRUE
;
1719 disp
->intreg
->data
->point_x
[0][0] = (float) x
;
1720 disp
->intreg
->data
->point_y
[0][0] = (float) y
;
1721 show_all_intregs(disp
);
1722 disp
->display_intregs
= TRUE
;
1724 disp
->pida
->piv_data
= interrogate_img (disp
->img
->image
,
1725 disp
->pida
->piv_par
,
1726 disp
->pida
->valid_par
,
1729 disp
->display_piv
= TRUE
;
1731 create_all_vectors(disp
->pida
);
1732 gnome_canvas_update_now(GNOME_CANVAS(disp
->canvas
));
1734 if (!shift_pressed
) set__NO_MS(gpiv
, disp
);
1740 canvas_display_button_release__HVLINE_MS (Display
*disp
,
1742 GtkWidget
*view_piv_display0
,
1746 /*-----------------------------------------------------------------------------
1747 * Performs action on mouse button release when H_LINE_MS or V_LINE_MS has
1751 gdouble l_col_start
,l_col_end
, l_row_start
, l_row_end
;
1752 gboolean reset_display_intregs
;
1755 /* g_message ("canvas_display_button_release__HVLINE_MS:: x = %f y = %f" */
1756 /* " xgrab_first = %f ygrab_first = %f", */
1757 /* x, y, disp->xgrab_first, disp->ygrab_first); */
1759 if (GTK_CHECK_MENU_ITEM (view_piv_display0
)->active
) {
1761 * Remove exixting intreg contours
1762 * Disable displaying temporarly to avoid several calls to
1763 * the 'on_spinbutton_piv_int' function
1765 destroy_all_intregs (disp
);
1766 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
1767 (view_piv_display0
),
1769 reset_display_intregs
= TRUE
;
1772 /* if (disp->pida->exist_piv) { */
1773 /* destroy_all_vectors(disp->pida); */
1774 /* disp->display_piv = FALSE; */
1778 m_select_index_x
= 0;
1779 m_select_index_y
= 0;
1782 * Vertical line selected
1784 if (m_select
== V_LINE_MS
) {
1785 if (y
>= disp
->ygrab_first
) {
1786 l_row_start
= (gdouble
) (disp
->ygrab_first
/ disp
->zoom_factor
);
1787 l_row_end
= (gdouble
) (y
/ disp
->zoom_factor
);
1788 disp
->pida
->piv_par
->row_start
= (gint
) l_row_start
;
1789 disp
->pida
->piv_par
->row_end
= (gint
) l_row_end
;
1790 disp
->pida
->piv_par
->int_line_row_end
= (gint
) l_row_end
;
1792 l_row_start
= (gdouble
) (y
/ disp
->zoom_factor
);
1793 l_row_end
= (gdouble
) (disp
->ygrab_first
/ disp
->zoom_factor
);
1794 disp
->pida
->piv_par
->row_start
= (gint
) l_row_start
;
1795 disp
->pida
->piv_par
->row_end
= (gint
) l_row_end
;
1796 disp
->pida
->piv_par
->int_line_row_end
= (gint
) l_row_end
;
1799 l_col_start
= (gdouble
) (disp
->xgrab_first
/ disp
->zoom_factor
-
1800 disp
->pida
->piv_par
->int_size_i
/ 2 + 1);
1801 disp
->pida
->piv_par
->col_start
= (gint
) l_col_start
;
1803 l_col_end
= (gdouble
) (disp
->xgrab_first
/ disp
->zoom_factor
+
1804 disp
->pida
->piv_par
->int_size_i
/ 2 +
1805 disp
->pida
->piv_par
->pre_shift_col
);
1806 disp
->pida
->piv_par
->col_end
= (gint
) l_col_end
;
1810 * Horizontal line selected
1812 } else if (m_select
== H_LINE_MS
) {
1813 if (x
>= disp
->xgrab_first
) {
1814 l_col_start
= (gdouble
) (disp
->xgrab_first
/ disp
->zoom_factor
);
1815 l_col_end
= (gdouble
) (x
/ disp
->zoom_factor
);
1816 disp
->pida
->piv_par
->col_start
= (gint
) l_col_start
;
1817 disp
->pida
->piv_par
->col_end
= (gint
) l_col_end
;
1818 disp
->pida
->piv_par
->int_line_col_end
= (gint
) l_col_end
;
1820 l_col_start
= (gdouble
) (x
/ disp
->zoom_factor
);
1821 l_col_end
= (gdouble
) (disp
->xgrab_first
/ disp
->zoom_factor
);
1822 disp
->pida
->piv_par
->col_start
= (gint
) l_col_start
;
1823 disp
->pida
->piv_par
->col_end
= (gint
) l_col_end
;
1824 disp
->pida
->piv_par
->int_line_col_end
= (gint
) l_col_end
;
1827 l_row_start
= (gdouble
) (disp
->ygrab_first
/ disp
->zoom_factor
-
1828 disp
->pida
->piv_par
->int_size_i
/ 2 + 1);
1829 disp
->pida
->piv_par
->row_start
= (gint
) l_row_start
;
1831 l_row_end
= (gdouble
) (disp
->ygrab_first
/ disp
->zoom_factor
+
1832 disp
->pida
->piv_par
->int_size_i
/ 2 +
1833 disp
->pida
->piv_par
->pre_shift_col
);
1834 disp
->pida
->piv_par
->row_end
= (gint
) l_row_end
;
1838 g_warning("canvas_display_button_release__HVLINE_MS: H_LINE_MS or V_LINE_MS inactive");
1841 if (gci_line
!= NULL
) destroy_line();
1842 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1843 create_all_intregs(disp
);
1847 * updating entry's for col/row_start_end
1849 /* g_message ("canvas_display_button_release__HVLINE_MS:: zoom_factor = %f col_start = %f col_end = %f" */
1850 /* " row_start = %f row_end = %f", */
1851 /* disp->zoom_factor, l_col_start, l_col_end, l_row_start, l_row_end); */
1853 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1854 (gpiv
->piveval
->spinbutton_colstart
),
1855 (gdouble
) l_col_start
);
1857 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1858 (gpiv
->piveval
->spinbutton_rowstart
),
1859 (gdouble
) l_row_start
);
1861 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1862 (gpiv
->piveval
->spinbutton_colend
),
1863 (gdouble
) l_col_end
);
1866 * The last call to on_spinbutton_piv_int will update the contours of the intregs
1868 if (reset_display_intregs
) {
1869 /* g_message ("release__HV:: resetting"); */
1870 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM
1871 (view_piv_display0
),
1875 gtk_spin_button_set_value (GTK_SPIN_BUTTON
1876 (gpiv
->piveval
->spinbutton_rowend
),
1877 (gdouble
) l_row_end
);
1879 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1880 /* create_all_intregs (disp); */
1888 canvas_display_button_press__DISABLE_POINT_MS (Display
*disp
,
1892 /*-----------------------------------------------------------------------------
1893 * Performs action on mouse button press when DISABLE_POINT_MS has
1898 gint index_x
= 0, index_y
= 0;
1899 GtkWidget
*view_piv_display0
=
1900 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
1901 "view_piv_display0");
1904 if ( m_select
== DISABLE_POINT_MS
) {
1905 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
) {
1906 search_nearest_index(disp
, x
, y
, &index_x
, &index_y
,
1909 search_nearest_index(disp
, x
, y
, &index_x
, &index_y
,
1913 disp
->pida
->piv_data
->peak_no
[index_y
][index_x
] = -1;
1914 disp
->pida
->piv_data
->snr
[index_y
][index_x
] = GPIV_SNR_DISABLE
;
1916 if (disp
->pida
->post_par
->set
== TRUE
) {
1917 disp
->pida
->piv_data
->dx
[index_y
][index_x
] =
1918 disp
->pida
->post_par
->set_dx
;
1919 disp
->pida
->piv_data
->dy
[index_y
][index_x
] =
1920 disp
->pida
->post_par
->set_dx
;
1922 update_vector(disp
->pida
, index_y
, index_x
);
1924 } else if ( m_select
== ENABLE_AREA_MS
) {
1925 enable_col_start
= x
;
1926 enable_row_start
= y
;
1927 assert( gci_aoi
== NULL
);
1929 gnome_canvas_item_new (gnome_canvas_root
1930 (GNOME_CANVAS(disp
->canvas
)),
1931 gnome_canvas_rect_get_type(),
1936 "outline_color", "yellow",
1937 "width_units", (double) THICKNESS
,
1941 } else if ( m_select
== DISABLE_AREA_MS
) {
1942 enable_col_start
= x
;
1943 enable_row_start
= y
;
1944 assert( gci_aoi
== NULL
);
1946 gnome_canvas_item_new (gnome_canvas_root
1947 (GNOME_CANVAS(disp
->canvas
)),
1948 gnome_canvas_rect_get_type(),
1953 "outline_color", "yellow",
1954 "width_units", (double) THICKNESS
,
1957 err_msg
= _("no image or piv data");
1958 warning_gpiv(err_msg
);
1966 set__NO_MS (GpivConsole
*gpiv
,
1969 /*-----------------------------------------------------------------------------
1970 * Reset mouse selection to inactive
1973 gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON
1974 (gpiv
->piveval
->radiobutton_mouse_1
),
1976 cursor
= gdk_cursor_new (GDK_DOTBOX
);
1977 gdk_window_set_cursor (disp
->mwin
->window
, cursor
);
1983 search_nearest_index (Display
*disp
,
1990 /*-----------------------------------------------------------------------------
1991 * Search nearest index belongin to x an y points
1994 gint i
, j
, x_min
= 10e4
, y_min
= 10e4
, dif
;
1997 if (data_type
== DATA_TYPE__INTREG
) {
1998 for (i
= 0, j
= 0; i
< disp
->intreg
->data
->ny
; i
++) {
1999 dif
= abs(y
- (int) disp
->intreg
->data
->point_y
[i
][j
]);
2006 for (i
= 0, j
= 0; j
< disp
->intreg
->data
->nx
; j
++) {
2007 dif
= abs(x
- (int) disp
->intreg
->data
->point_x
[i
][j
]);
2015 } else if (data_type
== DATA_TYPE__PIV
) {
2016 for (i
= 0, j
= 0; i
< disp
->pida
->piv_data
->ny
; i
++) {
2017 dif
= abs(y
- (int) disp
->pida
->piv_data
->point_y
[i
][j
]);
2024 for (i
= 0, j
= 0; j
< disp
->pida
->piv_data
->nx
; j
++) {
2025 dif
= abs(x
- (int) disp
->pida
->piv_data
->point_x
[i
][j
]);
2033 g_warning("search_nearest_index: Inavalid Data Type");
2041 highlight_intreg (gint index_y
,
2045 /*-----------------------------------------------------------------------------
2046 * Highlights first and second interrogation area's
2049 GtkWidget
*view_piv_display0
=
2050 gtk_object_get_data(GTK_OBJECT(disp
->mwin
),
2051 "view_piv_display0");
2054 if (GTK_CHECK_MENU_ITEM(view_piv_display0
)->active
2055 && index_y
<= disp
->intreg
->data
->ny
2056 && index_x
<= disp
->intreg
->data
->nx
) {
2058 if (disp
->intreg
->gci_intreg1
[disp
->index_y_old
][disp
->index_x_old
]
2060 gnome_canvas_item_set(disp
->intreg
->gci_intreg1
2061 [disp
->index_y_old
][disp
->index_x_old
],
2062 "outline_color", "red",
2066 if (disp
->intreg
->gci_intreg2
[disp
->index_y_old
][disp
->index_x_old
]
2068 gnome_canvas_item_set(disp
->intreg
->gci_intreg2
2069 [disp
->index_y_old
][disp
->index_x_old
],
2070 "outline_color", "blue",
2074 if (disp
->intreg
->gci_intreg1
[index_y
][index_x
] != NULL
) {
2075 gnome_canvas_item_set(disp
->intreg
->gci_intreg1
[index_y
][index_x
],
2076 "outline_color", "yellow",
2078 gnome_canvas_item_raise_to_top(disp
->intreg
->
2079 gci_intreg1
[index_y
][index_x
]);
2082 if (disp
->intreg
->gci_intreg2
[index_y
][index_x
] != NULL
) {
2083 gnome_canvas_item_set(disp
->intreg
->gci_intreg2
[index_y
][index_x
],
2084 "outline_color", "green",
2086 gnome_canvas_item_raise_to_top(disp
->intreg
->
2087 gci_intreg2
[index_y
][index_x
]);
2096 create_msg_display_with_pivdata (GpivPivData
*piv_data
,
2101 /*-----------------------------------------------------------------------------
2102 * Displays message with piv data values
2107 if (piv_data
->snr
[index_y
][index_x
] == GPIV_SNR_NAN
) {
2108 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2109 "xp=%3.2fmm yp=%3.2fmm %s",
2110 piv_data
->point_x
[index_y
][index_x
] * 1e3
,
2111 piv_data
->point_y
[index_y
][index_x
] * 1e3
,
2112 _("Disabled: not a number"));
2113 } else if (piv_data
->snr
[index_y
][index_x
] == GPIV_SNR_DISABLE
) {
2114 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2115 "xp=%3.2fmm yp=%3.2fmm %s",
2116 piv_data
->point_x
[index_y
][index_x
] * 1e3
,
2117 piv_data
->point_y
[index_y
][index_x
] * 1e3
,
2118 _("Disabled manually"));
2120 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2121 "xp=%3.2fmm yp=%3.2fmm U=%3.2fm/s V=%3.2fm/s"
2122 " snr=%3.2f peak #%d",
2123 piv_data
->point_x
[index_y
][index_x
] * 1e3
,
2124 piv_data
->point_y
[index_y
][index_x
] * 1e3
,
2125 piv_data
->dx
[index_y
][index_x
],
2126 piv_data
->dy
[index_y
][index_x
],
2127 piv_data
->snr
[index_y
][index_x
],
2128 piv_data
->peak_no
[index_y
][index_x
]);
2132 if (piv_data
->snr
[index_y
][index_x
] == GPIV_SNR_NAN
) {
2133 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2134 "xp=%3.0fpx yp=%3.0fpx %s",
2135 piv_data
->point_x
[index_y
][index_x
],
2136 piv_data
->point_y
[index_y
][index_x
],
2137 _("Disabled: not a number"));
2138 } else if (piv_data
->snr
[index_y
][index_x
] == GPIV_SNR_DISABLE
) {
2139 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2140 "xp=%3.0fpx yp=%3.0fpx %s",
2141 piv_data
->point_x
[index_y
][index_x
],
2142 piv_data
->point_y
[index_y
][index_x
],
2143 _("Disabled manually"));
2145 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2146 "xp=%3.0fpx yp=%3.0fpx dx=%3.2fpx dy=%3.2fpx"
2147 " snr=%3.2f peak #%d",
2148 piv_data
->point_x
[index_y
][index_x
],
2149 piv_data
->point_y
[index_y
][index_x
],
2150 piv_data
->dx
[index_y
][index_x
],
2151 piv_data
->dy
[index_y
][index_x
],
2152 piv_data
->snr
[index_y
][index_x
],
2153 piv_data
->peak_no
[index_y
][index_x
]);
2162 create_msg_display_with_scdata (GpivScalarData
*sc_data
,
2168 /*-----------------------------------------------------------------------------
2169 * Displays message with scalar data values
2173 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2174 "xp=%3.2fmm yp=%3.2fmm %s=%3.2f1/s",
2175 sc_data
->point_x
[index_y
][index_x
] * 1e3
,
2176 sc_data
->point_y
[index_y
][index_x
] * 1e3
,
2178 sc_data
->scalar
[index_y
][index_x
]);
2180 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2181 "xp=%3.0fpx yp=%3.0fpx %s=%3.2f",
2182 sc_data
->point_x
[index_y
][index_x
],
2183 sc_data
->point_y
[index_y
][index_x
],
2185 sc_data
->scalar
[index_y
][index_x
]);
2192 create_msg_display_with_pivscdata (GpivPivData
*piv_data
,
2193 GpivScalarData
*sc_data
,
2199 /*-----------------------------------------------------------------------------
2200 * Displays message with piv and scalar data values
2204 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2205 "xp=%3.2fmm yp=%3.2fmm U=%3.2fm/s V=%3.2fm/s "
2206 "snr=%3.2f peak #%d %s=%3.2f1/s",
2207 piv_data
->point_x
[index_y
][index_x
] * 1e3
,
2208 piv_data
->point_y
[index_y
][index_x
] * 1e3
,
2209 piv_data
->dx
[index_y
][index_x
],
2210 piv_data
->dy
[index_y
][index_x
],
2211 piv_data
->snr
[index_y
][index_x
],
2212 piv_data
->peak_no
[index_y
][index_x
],
2214 sc_data
->scalar
[index_y
][index_x
]);
2216 g_snprintf (msg_display
, GPIV_MAX_CHARS
,
2217 "xp=%3.0fpx yp=%3.0fpx dx=%3.2fpx dy=%3.2fpx "
2218 "snr=%3.2f peak #%d %s=%3.2f",
2219 piv_data
->point_x
[index_y
][index_x
],
2220 piv_data
->point_y
[index_y
][index_x
],
2221 piv_data
->dx
[index_y
][index_x
],
2222 piv_data
->dy
[index_y
][index_x
],
2223 piv_data
->snr
[index_y
][index_x
],
2224 piv_data
->peak_no
[index_y
][index_x
],
2226 sc_data
->scalar
[index_y
][index_x
]);
2233 create_line (Display
*disp
,
2239 /*-----------------------------------------------------------------------------
2242 GnomeCanvasPoints
*points
;
2243 points
= gnome_canvas_points_new (2);
2245 /* g_message("CREATE_LINE:: x1 = %d y1 = %d x2 = %d y2 = %d", x1, y1, x2, y2); */
2248 && gci_line
== NULL
) {
2250 points
->coords
[0] = x1
;
2251 points
->coords
[1] = y1
;
2252 points
->coords
[2] = x2
;
2253 points
->coords
[3] = y2
;
2255 gnome_canvas_item_new (gnome_canvas_root(GNOME_CANVAS(disp
->canvas
)),
2256 gnome_canvas_line_get_type(),
2258 "fill_color", "yellow",
2259 "width_units", (double) THICKNESS
,
2262 gnome_canvas_points_free (points
);
2268 update_line (gint x1
,
2273 /*-----------------------------------------------------------------------------
2276 GnomeCanvasPoints
*points
;
2277 points
= gnome_canvas_points_new (2);
2279 /* g_message("UPDATE_LINE:: x1 = %d y1 = %d x2 = %d y2 = %d", x1, y1, x2, y2); */
2281 if (gci_line
!= NULL
) {
2283 points
->coords
[0] = x1
;
2284 points
->coords
[1] = y1
;
2285 points
->coords
[2] = x2
;
2286 points
->coords
[3] = y2
;
2288 gnome_canvas_item_set (GNOME_CANVAS_ITEM(/* disp-> */gci_line
),
2290 "fill_color", "yellow",
2291 "width_units", (double) THICKNESS
,
2294 gnome_canvas_points_free (points
);
2301 /*-----------------------------------------------------------------------------
2304 if (gci_line
!= NULL
) {
2306 gtk_object_destroy(GTK_OBJECT (gci_line
));
2314 create_rect (Display
*disp
,
2318 /*-----------------------------------------------------------------------------
2322 && gci_aoi
== NULL
) {
2324 /* g_message("CREATE_RECT:: x = %d y = %d", x, y); */
2327 gnome_canvas_item_new (gnome_canvas_root
2328 (GNOME_CANVAS(disp
->canvas
)),
2329 gnome_canvas_rect_get_type(),
2334 "outline_color", "yellow",
2335 "width_units", (double) THICKNESS
,
2343 update_rect (gint x
,
2346 /*-----------------------------------------------------------------------------
2349 if (gci_aoi
!= NULL
) {
2351 gnome_canvas_item_set (GNOME_CANVAS_ITEM(gci_aoi
),
2361 /*-----------------------------------------------------------------------------
2364 if (gci_aoi
!= NULL
) {
2366 gtk_object_destroy (GTK_OBJECT (gci_aoi
));
2373 gtk_adjustment_get_lower (GtkAdjustment
*adjustment
)
2375 /* g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), 0.); */
2377 return adjustment
->lower
;
2383 pane_canvas (Display
*disp
,
2387 /*-----------------------------------------------------------------------------
2390 pane_canvas_x (disp
, x
);
2391 pane_canvas_y (disp
, y
);
2397 pane_canvas_x (Display
*disp
,
2400 /*-----------------------------------------------------------------------------
2403 GtkAdjustment
*adj
= GTK_ADJUSTMENT (disp
->hadj
);
2404 /* gdouble adj_value = gtk_adjustment_get_value */
2405 (GTK_ADJUSTMENT (disp
->hadj
));
2409 diff
= x
- disp
->xgrab_first
;
2410 /* g_message ("PANE_CANVAS_X:: x = %f x_first = %f => diff = %f", */
2411 /* x, disp->xgrab_first, diff); */
2413 adj_new
= (adj
->value
- diff
);
2414 /* g_message ("PANE_CANVAS_X:: value = %f lower = %f upper = %f page_s = %f => adj_new = %f", */
2415 /* adj->value, adj->lower, adj->upper, adj->page_size, adj_new); */
2417 if (adj_new
>= adj
->lower
2418 && adj_new
< adj
->upper
- adj
->page_size
) {
2419 /* g_message ("PANE_CANVAS_X:: passed if ()"); */
2421 gtk_adjustment_set_value (GTK_ADJUSTMENT (disp
->hadj
),
2431 pane_canvas_y (Display
*disp
,
2434 /*-----------------------------------------------------------------------------
2437 GtkAdjustment
*adj
= GTK_ADJUSTMENT (disp
->vadj
);
2438 /* gdouble adj_value = gtk_adjustment_get_value */
2439 /* (GTK_ADJUSTMENT (disp->vadj)); */
2443 diff
= y
- disp
->ygrab_first
;
2444 adj_new
= (adj
->value
- diff
);
2446 && adj_new
< adj
->upper
- adj
->page_size
) {
2447 gtk_adjustment_set_value (GTK_ADJUSTMENT (disp
->vadj
),