Release 0.6.0 using parallelized code
[gpiv.git] / src / imgh.c
blobe47843b636661b60b7038b01d058770cb707bd8b
1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 c-style: "K&R" -*- */
3 /*----------------------------------------------------------------------
5 gpiv - Graphic program for Particle Image Velocimetry, based on gtk/gnome
6 libraries.
8 Copyright (C) 2002, 2003, 2004 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 * Image header window/tabulator callbacks
30 * $Log: imgh.c,v $
31 * Revision 1.12 2007-11-23 16:24:07 gerber
32 * release 0.5.0: Kafka
34 * Revision 1.11 2007-06-06 17:00:48 gerber
35 * Retreives images/data from URI using Gnome Virtual File System.
37 * Revision 1.10 2007-01-29 11:27:43 gerber
38 * added image formats png, gif, tif png, bmp, improved buffer display
40 * Revision 1.9 2006/01/31 14:28:12 gerber
41 * version 0.3.0
43 * Revision 1.7 2005/02/26 09:43:30 gerber
44 * parameter flags (parameter_logic) defined as gboolean
46 * Revision 1.6 2005/01/19 15:53:41 gerber
47 * Initiation of Data Acquisition (DAC); trigerring of lasers and camera
48 * by using RTAI and Realtime Linux, recording images from IEEE1394
49 * (Firewire) IIDC compliant camera's
51 * Revision 1.5 2004/10/15 19:24:05 gerber
52 * GPIV_ and Gpiv prefix to defines and structure names of libgpiv
54 * Revision 1.4 2004/06/14 21:19:23 gerber
55 * Image depth up to 16 bits.
56 * Improvement "single int" and "drag int" in Eval tab.
57 * Viewer's pop-up menu.
58 * Adaption for gpiv_matrix_* and gpiv_vector_*.
59 * Resizing console.
60 * See Changelog for further info.
62 * Revision 1.3 2003/09/01 11:17:15 gerber
63 * improved monitoring of interrogation process
65 * Revision 1.2 2003/08/22 15:24:52 gerber
66 * interactive spatial scaling
68 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
69 * Imported gpiv
74 #include "gpiv_gui.h"
75 #include "imgh.h"
77 void
78 on_radiobutton_imgh_mouse_1_enter (GtkWidget *widget,
79 GtkWidget *entry
81 /*-----------------------------------------------------------------------------
84 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
85 gchar *msg = _("No action");
86 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
91 void
92 on_radiobutton_imgh_mouse_2_enter (GtkWidget *widget,
93 GtkWidget *entry
95 /*-----------------------------------------------------------------------------
98 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
99 gchar *msg = _("Points the length spanned by a ruler in the image");
100 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
105 void
106 on_radiobutton_imgh_mouse_3_enter (GtkWidget *widget,
107 GtkWidget *entry
109 /*-----------------------------------------------------------------------------
112 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
113 gchar *msg = _("Points the vertical length by a ruler in the image");
114 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
119 void
120 on_radiobutton_imgh_mouse_4_enter (GtkWidget *widget,
121 GtkWidget *entry
123 /*-----------------------------------------------------------------------------
124 * Main program of gpiv
127 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
128 gchar *msg = _("Points the horizontal length by a ruler in the image");
129 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
134 void
135 on_radiobutton_imgh_mouse (GtkWidget *widget,
136 GtkWidget *entry
138 /*-----------------------------------------------------------------------------
141 m_select = atoi (gtk_object_get_data (GTK_OBJECT (widget),
142 "mouse_select"));
144 if (m_select == NO_MS) {
145 gl_piv_par->int_geo = GPIV_AOI;
146 } else if (m_select == SPANLENGTH_MS) {
147 } else if (m_select == V_SPANLENGTH_MS) {
148 } else if (m_select == H_SPANLENGTH_MS) {
149 } else {
150 g_warning ("on_radiobutton_imgh_mouse: should not arrive here");
157 void
158 on_spinbutton_post_scale_px (GtkSpinButton *widget,
159 GtkWidget *entry
161 /*-----------------------------------------------------------------------------
164 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
166 gpiv_var->img_span_px = gtk_spin_button_get_value_as_float (widget);
167 gnome_config_push_prefix ("/gpiv/RuntimeVariables/");
168 gnome_config_set_float ("span", gpiv_var->img_span_px);
169 gnome_config_pop_prefix ();
170 gnome_config_sync ();
172 gl_image_par->s_scale =
173 gpiv_var->img_length_mm / gpiv_var->img_span_px;
174 gtk_spin_button_set_value (GTK_SPIN_BUTTON
175 (gpiv->imgh->spinbutton_sscale),
176 gl_image_par->s_scale);
179 if (display_act != NULL) {
180 display_act->img->image->header->s_scale = gl_image_par->s_scale;
181 display_act->img->image->header->s_scale__set = TRUE;
182 display_act->img->saved_img = FALSE;
188 void
189 on_spinbutton_post_scale_mm (GtkSpinButton *widget,
190 GtkWidget *entry
192 /*-----------------------------------------------------------------------------
195 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
197 gpiv_var->img_length_mm = gtk_spin_button_get_value_as_float (widget);
198 gnome_config_set_float ("length", gpiv_var->img_length_mm);
199 gnome_config_sync ();
201 gl_image_par->s_scale =
202 gpiv_var->img_length_mm / gpiv_var->img_span_px;
203 gtk_spin_button_set_value (GTK_SPIN_BUTTON
204 (gpiv->imgh->spinbutton_sscale),
205 gl_image_par->s_scale);
207 if (display_act != NULL) {
208 display_act->img->image->header->s_scale = gl_image_par->s_scale;
209 display_act->img->image->header->s_scale__set = TRUE;
210 display_act->img->saved_img = FALSE;
215 void
216 on_entry_imgh_title (GtkSpinButton *widget,
217 GtkWidget *entry
219 /*-----------------------------------------------------------------------------
222 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
224 g_snprintf (gl_image_par->title, GPIV_MAX_CHARS, "%s",
225 gtk_entry_get_text (GTK_ENTRY (imgh->entry_imgtitle)));
226 gl_image_par->title__set = TRUE;
228 if (display_act != NULL) {
229 gint length = GTK_ENTRY (entry)->text_length;
230 if (length == 0) {
231 display_act->img->image->header->title__set = FALSE;
232 } else {
233 g_snprintf (display_act->img->image->header->title, GPIV_MAX_CHARS,
234 "%s", gl_image_par->title);
235 display_act->img->image->header->title__set = TRUE;
236 display_act->img->saved_img = FALSE;
242 void
243 on_entry_imgh_crdate (GtkSpinButton *widget,
244 GtkWidget *entry
246 /*-----------------------------------------------------------------------------
249 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
251 g_snprintf (gl_image_par->creation_date, GPIV_MAX_CHARS, "%s",
252 gtk_entry_get_text (GTK_ENTRY (imgh->entry_crdate)));
253 gl_image_par->creation_date__set = TRUE;
255 if (display_act != NULL) {
256 gint length = GTK_ENTRY (entry)->text_length;
257 if (length == 0) {
258 display_act->img->image->header->creation_date__set = FALSE;
259 } else {
260 g_snprintf (display_act->img->image->header->creation_date,
261 GPIV_MAX_CHARS, "%s", gl_image_par->creation_date);
262 display_act->img->image->header->creation_date__set = TRUE;
263 display_act->img->saved_img = FALSE;
269 void
270 on_entry_imgh_location (GtkSpinButton *widget,
271 GtkWidget *entry
273 /*-----------------------------------------------------------------------------
276 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
278 g_snprintf (gl_image_par->location, GPIV_MAX_CHARS, "%s",
279 gtk_entry_get_text (GTK_ENTRY (imgh->entry_location)));
280 gl_image_par->location__set = TRUE;
282 if (display_act != NULL) {
283 gint length = GTK_ENTRY (entry)->text_length;
284 if (length == 0) {
285 display_act->img->image->header->location__set = FALSE;
286 } else {
287 g_snprintf (display_act->img->image->header->location,
288 GPIV_MAX_CHARS,"%s", gl_image_par->location);
289 display_act->img->image->header->location__set = TRUE;
290 display_act->img->saved_img = FALSE;
296 void
297 on_entry_imgh_author (GtkSpinButton *widget,
298 GtkWidget *entry
300 /*-----------------------------------------------------------------------------
303 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
305 g_snprintf (gl_image_par->author, GPIV_MAX_CHARS, "%s",
306 gtk_entry_get_text (GTK_ENTRY (imgh->entry_author)));
307 gl_image_par->author__set = TRUE;
309 if (display_act != NULL) {
310 gint length = GTK_ENTRY (entry)->text_length;
311 if (length == 0) {
312 display_act->img->image->header->author__set = FALSE;
313 } else {
314 g_snprintf (display_act->img->image->header->author, GPIV_MAX_CHARS,
315 "%s", gl_image_par->author);
316 display_act->img->image->header->author__set = TRUE;
317 display_act->img->saved_img = FALSE;
323 void
324 on_entry_imgh_software (GtkSpinButton *widget,
325 GtkWidget *entry
327 /*-----------------------------------------------------------------------------
330 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
332 g_snprintf (gl_image_par->software, GPIV_MAX_CHARS, "%s",
333 gtk_entry_get_text (GTK_ENTRY (imgh->entry_software)));
334 gl_image_par->software__set = TRUE;
336 if (display_act != NULL) {
337 gint length = GTK_ENTRY (entry)->text_length;
338 if (length == 0) {
339 display_act->img->image->header->software__set = FALSE;
340 } else {
341 g_snprintf (display_act->img->image->header->software, GPIV_MAX_CHARS,
342 "%s", gl_image_par->software);
343 display_act->img->image->header->software__set = TRUE;
344 display_act->img->saved_img = FALSE;
350 void
351 on_entry_imgh_source (GtkSpinButton *widget,
352 GtkWidget *entry
354 /*-----------------------------------------------------------------------------
357 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
359 g_snprintf (gl_image_par->source, GPIV_MAX_CHARS, "%s",
360 gtk_entry_get_text (GTK_ENTRY (imgh->entry_source)));
361 gl_image_par->source__set = TRUE;
363 if (display_act != NULL) {
364 gint length = GTK_ENTRY (entry)->text_length;
365 if (length == 0) {
366 display_act->img->image->header->source__set = FALSE;
367 } else {
368 g_snprintf(display_act->img->image->header->source, GPIV_MAX_CHARS,
369 "%s", gl_image_par->source);
370 display_act->img->image->header->source__set = TRUE;
371 display_act->img->saved_img = FALSE;
377 void
378 on_entry_imgh_usertext (GtkSpinButton *widget,
379 GtkWidget *entry
381 /*-----------------------------------------------------------------------------
384 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
386 g_snprintf (gl_image_par->usertext, GPIV_MAX_CHARS, "%s",
387 gtk_entry_get_text (GTK_ENTRY (imgh->entry_usertext)));
388 gl_image_par->usertext__set = TRUE;
390 if (display_act != NULL) {
391 gint length = GTK_ENTRY (entry)->text_length;
392 if (length == 0) {
393 display_act->img->image->header->usertext__set = FALSE;
394 } else {
395 g_snprintf (display_act->img->image->header->usertext,
396 GPIV_MAX_CHARS, "%s", gl_image_par->usertext);
397 display_act->img->image->header->usertext__set = TRUE;
398 display_act->img->saved_img = FALSE;
404 void
405 on_entry_imgh_warning (GtkSpinButton *widget,
406 GtkWidget *entry
408 /*-----------------------------------------------------------------------------
411 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
413 g_snprintf (gl_image_par->warning, GPIV_MAX_CHARS, "%s",
414 gtk_entry_get_text (GTK_ENTRY (imgh->entry_warning)));
415 gl_image_par->warning__set = TRUE;
417 if (display_act != NULL) {
418 gint length = GTK_ENTRY (entry)->text_length;
419 if (length == 0) {
420 display_act->img->image->header->warning__set = FALSE;
421 } else {
422 g_snprintf (display_act->img->image->header->warning,
423 GPIV_MAX_CHARS, "%s", gl_image_par->warning);
424 display_act->img->image->header->warning__set = TRUE;
425 display_act->img->saved_img = FALSE;
431 void
432 on_entry_imgh_disclaimer (GtkSpinButton *widget,
433 GtkWidget *entry
435 /*-----------------------------------------------------------------------------
438 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
440 g_snprintf (gl_image_par->disclaimer, GPIV_MAX_CHARS, "%s",
441 gtk_entry_get_text (GTK_ENTRY (imgh->entry_disclaimer)));
442 gl_image_par->disclaimer__set = TRUE;
444 if (display_act != NULL) {
445 gint length = GTK_ENTRY (entry)->text_length;
446 if (length == 0) {
447 display_act->img->image->header->disclaimer__set = FALSE;
448 } else {
449 g_snprintf (display_act->img->image->header->disclaimer,
450 GPIV_MAX_CHARS, "%s", gl_image_par->disclaimer);
451 display_act->img->image->header->disclaimer__set = TRUE;
452 display_act->img->saved_img = FALSE;
458 void
459 on_entry_imgh_comment (GtkSpinButton *widget,
460 GtkWidget *entry
462 /*-----------------------------------------------------------------------------
465 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
467 g_snprintf (gl_image_par->comment, GPIV_MAX_CHARS, "%s",
468 gtk_entry_get_text (GTK_ENTRY (imgh->entry_comment)));
469 gl_image_par->comment__set = TRUE;
471 if (display_act != NULL) {
472 gint length = GTK_ENTRY (entry)->text_length;
473 if (length == 0) {
474 display_act->img->image->header->comment__set = FALSE;
475 } else {
476 g_snprintf (display_act->img->image->header->comment,
477 GPIV_MAX_CHARS, "%s", gl_image_par->comment);
478 display_act->img->image->header->comment__set = TRUE;
479 display_act->img->saved_img = FALSE;
485 void
486 on_entry_imgh_copyright (GtkSpinButton *widget,
487 GtkWidget *entry
489 /*-----------------------------------------------------------------------------
492 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
494 g_snprintf (gl_image_par->copyright, GPIV_MAX_CHARS, "%s",
495 gtk_entry_get_text (GTK_ENTRY (imgh->entry_copyright)));
496 gl_image_par->copyright__set = TRUE;
498 if (display_act != NULL) {
499 gint length = GTK_ENTRY (entry)->text_length;
500 if (length == 0) {
501 display_act->img->image->header->copyright__set = FALSE;
502 } else {
503 g_snprintf (display_act->img->image->header->copyright,
504 GPIV_MAX_CHARS, "%s", gl_image_par->copyright);
505 display_act->img->image->header->copyright__set = TRUE;
506 display_act->img->saved_img = FALSE;
512 void
513 on_entry_imgh_email (GtkSpinButton *widget,
514 GtkWidget *entry
516 /*-----------------------------------------------------------------------------
519 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
521 g_snprintf (gl_image_par->email, GPIV_MAX_CHARS, "%s",
522 gtk_entry_get_text (GTK_ENTRY (imgh->entry_email)));
523 gl_image_par->email__set = TRUE;
525 if (display_act != NULL) {
526 gint length = GTK_ENTRY (entry)->text_length;
527 if (length == 0) {
528 display_act->img->image->header->email__set = FALSE;
529 } else {
530 g_snprintf(display_act->img->image->header->email,
531 GPIV_MAX_CHARS, "%s", gl_image_par->email);
532 display_act->img->image->header->email__set = TRUE;
533 display_act->img->saved_img = FALSE;
539 void
540 on_entry_imgh_url (GtkSpinButton *widget,
541 GtkWidget *entry
543 /*-----------------------------------------------------------------------------
546 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
548 g_snprintf (gl_image_par->url, GPIV_MAX_CHARS, "%s",
549 gtk_entry_get_text (GTK_ENTRY (imgh->entry_url)));
550 gl_image_par->url__set = TRUE;
552 if (display_act != NULL) {
553 gint length = GTK_ENTRY (entry)->text_length;
554 if (length == 0) {
555 display_act->img->image->header->url__set = FALSE;
556 } else {
557 g_snprintf (display_act->img->image->header->url,
558 GPIV_MAX_CHARS, "%s", gl_image_par->url);
559 display_act->img->image->header->url__set = TRUE;
560 display_act->img->saved_img = FALSE;