bugrepair: drag and drop
[gpiv.git] / src / imgh.c
blobde3c9ff3a7cbb81ad1544ceaf6f74baf97892313
1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 c-style: "K&R" -*- */
3 /*----------------------------------------------------------------------
5 gpiv - Graphic program for Particle Image Velocimetry, based on gtk/gnome
6 libraries.
8 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
9 Gerber van der Graaf
11 This file is part of gpiv.
13 Gpiv is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
16 any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ----------------------------------------------------------------------*/
30 * Image header window/tabulator callbacks
31 * $Log: imgh.c,v $
32 * Revision 1.12 2007-11-23 16:24:07 gerber
33 * release 0.5.0: Kafka
35 * Revision 1.11 2007-06-06 17:00:48 gerber
36 * Retreives images/data from URI using Gnome Virtual File System.
38 * Revision 1.10 2007-01-29 11:27:43 gerber
39 * added image formats png, gif, tif png, bmp, improved buffer display
41 * Revision 1.9 2006/01/31 14:28:12 gerber
42 * version 0.3.0
44 * Revision 1.7 2005/02/26 09:43:30 gerber
45 * parameter flags (parameter_logic) defined as gboolean
47 * Revision 1.6 2005/01/19 15:53:41 gerber
48 * Initiation of Data Acquisition (DAC); trigerring of lasers and camera
49 * by using RTAI and Realtime Linux, recording images from IEEE1394
50 * (Firewire) IIDC compliant camera's
52 * Revision 1.5 2004/10/15 19:24:05 gerber
53 * GPIV_ and Gpiv prefix to defines and structure names of libgpiv
55 * Revision 1.4 2004/06/14 21:19:23 gerber
56 * Image depth up to 16 bits.
57 * Improvement "single int" and "drag int" in Eval tab.
58 * Viewer's pop-up menu.
59 * Adaption for gpiv_matrix_* and gpiv_vector_*.
60 * Resizing console.
61 * See Changelog for further info.
63 * Revision 1.3 2003/09/01 11:17:15 gerber
64 * improved monitoring of interrogation process
66 * Revision 1.2 2003/08/22 15:24:52 gerber
67 * interactive spatial scaling
69 * Revision 1.1.1.1 2003/06/17 17:10:52 gerber
70 * Imported gpiv
75 #include "gpiv_gui.h"
76 #include "imgh.h"
78 void
79 on_radiobutton_imgh_mouse_1_enter (GtkWidget *widget,
80 GtkWidget *entry
82 /*-----------------------------------------------------------------------------
85 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
86 gchar *msg = _("No action");
87 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
92 void
93 on_radiobutton_imgh_mouse_2_enter (GtkWidget *widget,
94 GtkWidget *entry
96 /*-----------------------------------------------------------------------------
99 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
100 gchar *msg = _("Points the length spanned by a ruler in the image");
101 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
106 void
107 on_radiobutton_imgh_mouse_3_enter (GtkWidget *widget,
108 GtkWidget *entry
110 /*-----------------------------------------------------------------------------
113 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
114 gchar *msg = _("Points the vertical length by a ruler in the image");
115 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
120 void
121 on_radiobutton_imgh_mouse_4_enter (GtkWidget *widget,
122 GtkWidget *entry
124 /*-----------------------------------------------------------------------------
125 * Main program of gpiv
128 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
129 gchar *msg = _("Points the horizontal length by a ruler in the image");
130 gnome_appbar_set_status (GNOME_APPBAR (gpiv->appbar), msg);
135 void
136 on_radiobutton_imgh_mouse (GtkWidget *widget,
137 GtkWidget *entry
139 /*-----------------------------------------------------------------------------
142 m_select = atoi (gtk_object_get_data (GTK_OBJECT (widget),
143 "mouse_select"));
145 if (m_select == NO_MS) {
146 gl_piv_par->int_geo = GPIV_AOI;
147 } else if (m_select == SPANLENGTH_MS) {
148 } else if (m_select == V_SPANLENGTH_MS) {
149 } else if (m_select == H_SPANLENGTH_MS) {
150 } else {
151 g_warning ("on_radiobutton_imgh_mouse: should not arrive here");
158 void
159 on_spinbutton_post_scale_px (GtkSpinButton *widget,
160 GtkWidget *entry
162 /*-----------------------------------------------------------------------------
165 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
167 gpiv_var->img_span_px = gtk_spin_button_get_value_as_float (widget);
168 gnome_config_push_prefix ("/gpiv/RuntimeVariables/");
169 gnome_config_set_float ("span", gpiv_var->img_span_px);
170 gnome_config_pop_prefix ();
171 gnome_config_sync ();
173 gl_image_par->s_scale =
174 gpiv_var->img_length_mm / gpiv_var->img_span_px;
175 gtk_spin_button_set_value (GTK_SPIN_BUTTON
176 (gpiv->imgh->spinbutton_sscale),
177 gl_image_par->s_scale);
180 if (display_act != NULL) {
181 display_act->img->image->header->s_scale = gl_image_par->s_scale;
182 display_act->img->image->header->s_scale__set = TRUE;
183 display_act->img->saved_img = FALSE;
189 void
190 on_spinbutton_post_scale_mm (GtkSpinButton *widget,
191 GtkWidget *entry
193 /*-----------------------------------------------------------------------------
196 GpivConsole *gpiv = gtk_object_get_data (GTK_OBJECT (widget), "gpiv");
198 gpiv_var->img_length_mm = gtk_spin_button_get_value_as_float (widget);
199 gnome_config_set_float ("length", gpiv_var->img_length_mm);
200 gnome_config_sync ();
202 gl_image_par->s_scale =
203 gpiv_var->img_length_mm / gpiv_var->img_span_px;
204 gtk_spin_button_set_value (GTK_SPIN_BUTTON
205 (gpiv->imgh->spinbutton_sscale),
206 gl_image_par->s_scale);
208 if (display_act != NULL) {
209 display_act->img->image->header->s_scale = gl_image_par->s_scale;
210 display_act->img->image->header->s_scale__set = TRUE;
211 display_act->img->saved_img = FALSE;
216 void
217 on_entry_imgh_title (GtkSpinButton *widget,
218 GtkWidget *entry
220 /*-----------------------------------------------------------------------------
223 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
225 g_snprintf (gl_image_par->title, GPIV_MAX_CHARS, "%s",
226 gtk_entry_get_text (GTK_ENTRY (imgh->entry_imgtitle)));
227 gl_image_par->title__set = TRUE;
229 if (display_act != NULL) {
230 gint length = GTK_ENTRY (entry)->text_length;
231 if (length == 0) {
232 display_act->img->image->header->title__set = FALSE;
233 } else {
234 g_snprintf (display_act->img->image->header->title, GPIV_MAX_CHARS,
235 "%s", gl_image_par->title);
236 display_act->img->image->header->title__set = TRUE;
237 display_act->img->saved_img = FALSE;
243 void
244 on_entry_imgh_crdate (GtkSpinButton *widget,
245 GtkWidget *entry
247 /*-----------------------------------------------------------------------------
250 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
252 g_snprintf (gl_image_par->creation_date, GPIV_MAX_CHARS, "%s",
253 gtk_entry_get_text (GTK_ENTRY (imgh->entry_crdate)));
254 gl_image_par->creation_date__set = TRUE;
256 if (display_act != NULL) {
257 gint length = GTK_ENTRY (entry)->text_length;
258 if (length == 0) {
259 display_act->img->image->header->creation_date__set = FALSE;
260 } else {
261 g_snprintf (display_act->img->image->header->creation_date,
262 GPIV_MAX_CHARS, "%s", gl_image_par->creation_date);
263 display_act->img->image->header->creation_date__set = TRUE;
264 display_act->img->saved_img = FALSE;
270 void
271 on_entry_imgh_location (GtkSpinButton *widget,
272 GtkWidget *entry
274 /*-----------------------------------------------------------------------------
277 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
279 g_snprintf (gl_image_par->location, GPIV_MAX_CHARS, "%s",
280 gtk_entry_get_text (GTK_ENTRY (imgh->entry_location)));
281 gl_image_par->location__set = TRUE;
283 if (display_act != NULL) {
284 gint length = GTK_ENTRY (entry)->text_length;
285 if (length == 0) {
286 display_act->img->image->header->location__set = FALSE;
287 } else {
288 g_snprintf (display_act->img->image->header->location,
289 GPIV_MAX_CHARS,"%s", gl_image_par->location);
290 display_act->img->image->header->location__set = TRUE;
291 display_act->img->saved_img = FALSE;
297 void
298 on_entry_imgh_author (GtkSpinButton *widget,
299 GtkWidget *entry
301 /*-----------------------------------------------------------------------------
304 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
306 g_snprintf (gl_image_par->author, GPIV_MAX_CHARS, "%s",
307 gtk_entry_get_text (GTK_ENTRY (imgh->entry_author)));
308 gl_image_par->author__set = TRUE;
310 if (display_act != NULL) {
311 gint length = GTK_ENTRY (entry)->text_length;
312 if (length == 0) {
313 display_act->img->image->header->author__set = FALSE;
314 } else {
315 g_snprintf (display_act->img->image->header->author, GPIV_MAX_CHARS,
316 "%s", gl_image_par->author);
317 display_act->img->image->header->author__set = TRUE;
318 display_act->img->saved_img = FALSE;
324 void
325 on_entry_imgh_software (GtkSpinButton *widget,
326 GtkWidget *entry
328 /*-----------------------------------------------------------------------------
331 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
333 g_snprintf (gl_image_par->software, GPIV_MAX_CHARS, "%s",
334 gtk_entry_get_text (GTK_ENTRY (imgh->entry_software)));
335 gl_image_par->software__set = TRUE;
337 if (display_act != NULL) {
338 gint length = GTK_ENTRY (entry)->text_length;
339 if (length == 0) {
340 display_act->img->image->header->software__set = FALSE;
341 } else {
342 g_snprintf (display_act->img->image->header->software, GPIV_MAX_CHARS,
343 "%s", gl_image_par->software);
344 display_act->img->image->header->software__set = TRUE;
345 display_act->img->saved_img = FALSE;
351 void
352 on_entry_imgh_source (GtkSpinButton *widget,
353 GtkWidget *entry
355 /*-----------------------------------------------------------------------------
358 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
360 g_snprintf (gl_image_par->source, GPIV_MAX_CHARS, "%s",
361 gtk_entry_get_text (GTK_ENTRY (imgh->entry_source)));
362 gl_image_par->source__set = TRUE;
364 if (display_act != NULL) {
365 gint length = GTK_ENTRY (entry)->text_length;
366 if (length == 0) {
367 display_act->img->image->header->source__set = FALSE;
368 } else {
369 g_snprintf(display_act->img->image->header->source, GPIV_MAX_CHARS,
370 "%s", gl_image_par->source);
371 display_act->img->image->header->source__set = TRUE;
372 display_act->img->saved_img = FALSE;
378 void
379 on_entry_imgh_usertext (GtkSpinButton *widget,
380 GtkWidget *entry
382 /*-----------------------------------------------------------------------------
385 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
387 g_snprintf (gl_image_par->usertext, GPIV_MAX_CHARS, "%s",
388 gtk_entry_get_text (GTK_ENTRY (imgh->entry_usertext)));
389 gl_image_par->usertext__set = TRUE;
391 if (display_act != NULL) {
392 gint length = GTK_ENTRY (entry)->text_length;
393 if (length == 0) {
394 display_act->img->image->header->usertext__set = FALSE;
395 } else {
396 g_snprintf (display_act->img->image->header->usertext,
397 GPIV_MAX_CHARS, "%s", gl_image_par->usertext);
398 display_act->img->image->header->usertext__set = TRUE;
399 display_act->img->saved_img = FALSE;
405 void
406 on_entry_imgh_warning (GtkSpinButton *widget,
407 GtkWidget *entry
409 /*-----------------------------------------------------------------------------
412 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
414 g_snprintf (gl_image_par->warning, GPIV_MAX_CHARS, "%s",
415 gtk_entry_get_text (GTK_ENTRY (imgh->entry_warning)));
416 gl_image_par->warning__set = TRUE;
418 if (display_act != NULL) {
419 gint length = GTK_ENTRY (entry)->text_length;
420 if (length == 0) {
421 display_act->img->image->header->warning__set = FALSE;
422 } else {
423 g_snprintf (display_act->img->image->header->warning,
424 GPIV_MAX_CHARS, "%s", gl_image_par->warning);
425 display_act->img->image->header->warning__set = TRUE;
426 display_act->img->saved_img = FALSE;
432 void
433 on_entry_imgh_disclaimer (GtkSpinButton *widget,
434 GtkWidget *entry
436 /*-----------------------------------------------------------------------------
439 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
441 g_snprintf (gl_image_par->disclaimer, GPIV_MAX_CHARS, "%s",
442 gtk_entry_get_text (GTK_ENTRY (imgh->entry_disclaimer)));
443 gl_image_par->disclaimer__set = TRUE;
445 if (display_act != NULL) {
446 gint length = GTK_ENTRY (entry)->text_length;
447 if (length == 0) {
448 display_act->img->image->header->disclaimer__set = FALSE;
449 } else {
450 g_snprintf (display_act->img->image->header->disclaimer,
451 GPIV_MAX_CHARS, "%s", gl_image_par->disclaimer);
452 display_act->img->image->header->disclaimer__set = TRUE;
453 display_act->img->saved_img = FALSE;
459 void
460 on_entry_imgh_comment (GtkSpinButton *widget,
461 GtkWidget *entry
463 /*-----------------------------------------------------------------------------
466 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
468 g_snprintf (gl_image_par->comment, GPIV_MAX_CHARS, "%s",
469 gtk_entry_get_text (GTK_ENTRY (imgh->entry_comment)));
470 gl_image_par->comment__set = TRUE;
472 if (display_act != NULL) {
473 gint length = GTK_ENTRY (entry)->text_length;
474 if (length == 0) {
475 display_act->img->image->header->comment__set = FALSE;
476 } else {
477 g_snprintf (display_act->img->image->header->comment,
478 GPIV_MAX_CHARS, "%s", gl_image_par->comment);
479 display_act->img->image->header->comment__set = TRUE;
480 display_act->img->saved_img = FALSE;
486 void
487 on_entry_imgh_copyright (GtkSpinButton *widget,
488 GtkWidget *entry
490 /*-----------------------------------------------------------------------------
493 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
495 g_snprintf (gl_image_par->copyright, GPIV_MAX_CHARS, "%s",
496 gtk_entry_get_text (GTK_ENTRY (imgh->entry_copyright)));
497 gl_image_par->copyright__set = TRUE;
499 if (display_act != NULL) {
500 gint length = GTK_ENTRY (entry)->text_length;
501 if (length == 0) {
502 display_act->img->image->header->copyright__set = FALSE;
503 } else {
504 g_snprintf (display_act->img->image->header->copyright,
505 GPIV_MAX_CHARS, "%s", gl_image_par->copyright);
506 display_act->img->image->header->copyright__set = TRUE;
507 display_act->img->saved_img = FALSE;
513 void
514 on_entry_imgh_email (GtkSpinButton *widget,
515 GtkWidget *entry
517 /*-----------------------------------------------------------------------------
520 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
522 g_snprintf (gl_image_par->email, GPIV_MAX_CHARS, "%s",
523 gtk_entry_get_text (GTK_ENTRY (imgh->entry_email)));
524 gl_image_par->email__set = TRUE;
526 if (display_act != NULL) {
527 gint length = GTK_ENTRY (entry)->text_length;
528 if (length == 0) {
529 display_act->img->image->header->email__set = FALSE;
530 } else {
531 g_snprintf(display_act->img->image->header->email,
532 GPIV_MAX_CHARS, "%s", gl_image_par->email);
533 display_act->img->image->header->email__set = TRUE;
534 display_act->img->saved_img = FALSE;
540 void
541 on_entry_imgh_url (GtkSpinButton *widget,
542 GtkWidget *entry
544 /*-----------------------------------------------------------------------------
547 Imgheader *imgh = gtk_object_get_data (GTK_OBJECT (widget), "imgh");
549 g_snprintf (gl_image_par->url, GPIV_MAX_CHARS, "%s",
550 gtk_entry_get_text (GTK_ENTRY (imgh->entry_url)));
551 gl_image_par->url__set = TRUE;
553 if (display_act != NULL) {
554 gint length = GTK_ENTRY (entry)->text_length;
555 if (length == 0) {
556 display_act->img->image->header->url__set = FALSE;
557 } else {
558 g_snprintf (display_act->img->image->header->url,
559 GPIV_MAX_CHARS, "%s", gl_image_par->url);
560 display_act->img->image->header->url__set = TRUE;
561 display_act->img->saved_img = FALSE;