Updated because of cvs conflict
[gpiv.git] / src / dac_cam_interface.c
blobabdf1aaedde7bcb934f553cbd0e332a278a91155
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 * Data acquisition header interface
30 * $Log: dac_cam_interface.c,v $
31 * Revision 1.3 2007-06-06 17:00:48 gerber
32 * Retreives images/data from URI using Gnome Virtual File System.
34 * Revision 1.2 2007-01-29 11:27:43 gerber
35 * added image formats png, gif, tif png, bmp, improved buffer display
37 * Revision 1.1 2006-09-18 07:29:50 gerber
38 * Split up of triggering and image recording (camera)
41 #ifdef ENABLE_CAM
42 #ifdef HAVE_CONFIG_H
43 # include <config.h>
44 #endif
46 #include "gpiv_gui.h"
47 #include "dac_cam_interfac.h"
48 #include "dac_cam.h"
51 static void
52 create_camera_menu(GnomeApp *main_window,
53 Cam *cam
55 /*-----------------------------------------------------------------------------
56 * From coriander: build_menus.c BuildCameraMenu
59 int i;
60 char tmp[GPIV_MAX_CHARS];
63 * remove previous menu
65 if (cam->camera_select != NULL) {
66 gtk_widget_destroy(GTK_WIDGET (cam->camera_select));
69 cam->camera_select = gtk_option_menu_new ();
70 gtk_widget_ref (cam->camera_select);
71 gtk_object_set_data_full (GTK_OBJECT (main_window),
72 "camera_select",
73 cam->camera_select,
74 (GtkDestroyNotify) gtk_widget_unref);
75 gtk_widget_show (cam->camera_select);
76 gtk_container_add(GTK_CONTAINER (cam->vbox_cam),
77 cam->camera_select);
79 if (cam_var.numCameras >= 1) {
80 gtk_widget_set_sensitive (cam->camera_select, TRUE);
81 } else {
82 gtk_widget_set_sensitive (cam->camera_select, FALSE );
87 cam->camera_select_menu = gtk_menu_new ();
88 if (cam_var.numCameras > 0) {
89 for (i = 0; i < cam_var.numCameras; i++) {
90 g_snprintf(tmp,
91 GPIV_MAX_CHARS,
92 "Node %d: %s %s",
93 cam_var.camera[i].id,
94 cam_var.camera[i].vendor,
95 cam_var.camera[i].model);
96 cam->menu_item = gtk_menu_item_new_with_label (_(tmp));
97 gtk_widget_show (cam->menu_item);
98 gtk_menu_append (GTK_MENU (cam->camera_select_menu),
99 cam->menu_item);
100 gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->camera_select),
101 cam->camera_select_menu);
102 g_signal_connect (GTK_OBJECT (cam->menu_item),
103 "activate",
104 GTK_SIGNAL_FUNC (on_menu_camera_select),
105 (int *) i);
107 * BUGFIX apply last camera to img_par.source
109 g_snprintf(image_par.source, GPIV_MAX_CHARS, "%s %s",
110 cam_var.camera[i].vendor,
111 cam_var.camera[i].model);
112 image_par.source__set = TRUE;
114 } else {
115 g_snprintf(tmp,
116 GPIV_MAX_CHARS,
117 "No camera");
118 cam->menu_item = gtk_menu_item_new_with_label (_(tmp));
119 gtk_widget_show (cam->menu_item);
120 gtk_menu_append (GTK_MENU (cam->camera_select_menu),
121 cam->menu_item);
122 gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->camera_select),
123 cam->camera_select_menu);
125 g_snprintf(image_par.source, GPIV_MAX_CHARS, "No camera");
126 image_par.source__set = TRUE;
131 /* gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->camera_select), */
132 /* cam->camera_select_menu); */
135 * sets the active menu item:
137 gtk_option_menu_set_history (GTK_OPTION_MENU (cam->camera_select) ,
138 /* camera_act */ 0);
144 static void
145 create_format_menu(GnomeApp *main_window,
146 GpivConsole * gpiv,
147 Cam *cam
149 /*-----------------------------------------------------------------------------
150 * From coriander: build_menus.c BuildCameraMenu
153 int i;
154 char tmp[GPIV_MAX_CHARS];
155 quadlet_t modes, formats;
157 if (cam_var.numCameras > 0) {
158 dc1394_query_supported_formats(cam_var.camera[0].handle,
159 cam_var.camera[0].id,
160 &formats);
161 dc1394_query_supported_modes(cam_var.camera[0].handle,
162 cam_var.camera[0].id,
163 FORMAT_VGA_NONCOMPRESSED,
164 &modes);
167 * remove previous menu
169 if (cam->format_menu != NULL) {
170 gtk_widget_destroy(GTK_WIDGET (cam->format_menu));
173 cam->format_menu = gtk_option_menu_new ();
174 gtk_widget_ref (cam->format_menu);
175 gtk_object_set_data_full (GTK_OBJECT (main_window),
176 "format_menu",
177 cam->format_menu,
178 (GtkDestroyNotify) gtk_widget_unref);
179 gtk_widget_show (cam->format_menu);
180 gtk_container_add(GTK_CONTAINER (cam->vbox_cam),
181 cam->format_menu);
184 cam->format_menu_menu = gtk_menu_new ();
185 if (cam_var.numCameras > 0) {
187 * Format 0
189 if (formats & (0x1 << 31)) {
190 for (i = 0; i < NUM_FORMAT0_MODES; i++) {
191 if ( modes & (0x1 << (31-i))) {
192 g_snprintf(tmp,
193 GPIV_MAX_CHARS,
194 "Format 0: %s",
195 format0_desc[i]);
196 cam->menu_item = gtk_menu_item_new_with_label (_(tmp));
197 gtk_widget_show (cam->menu_item);
198 gtk_menu_append (GTK_MENU (cam->format_menu_menu),
199 cam->menu_item);
200 gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->format_menu),
201 cam->format_menu_menu);
203 gtk_widget_set_sensitive(cam->menu_item,
204 modes & (0x1 << (31-i)) );
207 gtk_object_set_data(GTK_OBJECT (cam->menu_item),
208 "gpiv",
209 gpiv);
210 g_signal_connect (GTK_OBJECT (cam->menu_item),
211 "activate",
212 GTK_SIGNAL_FUNC (on_menu_format),
213 (int*)(i + MODE_FORMAT0_MIN));
220 * Format 1
222 if (formats & (0x1 << 30)) {
223 for (i = 0; i < NUM_FORMAT1_MODES; i++) {
224 if ( modes & (0x1 << (30-i))) {
225 g_snprintf(tmp,
226 GPIV_MAX_CHARS,
227 "Format 1: %s",
228 format1_desc[i]);
229 cam->menu_item = gtk_menu_item_new_with_label (_(tmp));
230 gtk_widget_show (cam->menu_item);
231 gtk_menu_append (GTK_MENU (cam->format_menu_menu),
232 cam->menu_item);
233 gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->format_menu),
234 cam->format_menu_menu);
236 gtk_widget_set_sensitive(cam->menu_item,
237 modes & (0x1 << (30-i)) );
238 g_signal_connect (GTK_OBJECT (cam->menu_item),
239 "activate",
240 GTK_SIGNAL_FUNC (on_menu_format),
241 (int*)(i + MODE_FORMAT1_MIN));
249 * Format 2
251 if (formats & (0x1 << 29)) {
252 for (i = 0; i < NUM_FORMAT2_MODES; i++) {
253 if ( modes & (0x1 << (29-i))) {
254 g_snprintf(tmp,
255 GPIV_MAX_CHARS,
256 "Format 2: %s",
257 format2_desc[i]);
258 cam->menu_item = gtk_menu_item_new_with_label (_(tmp));
259 gtk_widget_show (cam->menu_item);
260 gtk_menu_append (GTK_MENU (cam->format_menu_menu),
261 cam->menu_item);
262 gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->format_menu),
263 cam->format_menu_menu);
265 gtk_widget_set_sensitive(cam->menu_item,
266 modes & (0x1 << (29-i)) );
268 g_signal_connect (GTK_OBJECT (cam->menu_item),
269 "activate",
270 GTK_SIGNAL_FUNC (on_menu_format),
271 (int*)(i + MODE_FORMAT2_MIN));
278 * Format 6
280 if (formats & (0x1 << 25)) {
281 for (i = 0; i < NUM_FORMAT6_MODES; i++) {
282 if ( modes & (0x1 << (25-i))) {
283 g_snprintf(tmp,
284 GPIV_MAX_CHARS,
285 "Format 6: %s",
286 format6_desc[i]);
287 cam->menu_item = gtk_menu_item_new_with_label (_(tmp));
288 gtk_widget_show (cam->menu_item);
289 gtk_menu_append (GTK_MENU (cam->format_menu_menu),
290 cam->menu_item);
291 gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->format_menu),
292 cam->format_menu_menu);
294 gtk_widget_set_sensitive(cam->menu_item,
295 modes & (0x1 << (25-i)) );
297 g_signal_connect (GTK_OBJECT (cam->menu_item),
298 "activate",
299 GTK_SIGNAL_FUNC (on_menu_format),
300 (int*)(i + MODE_FORMAT6_MIN));
306 } else {
307 g_snprintf(tmp,
308 GPIV_MAX_CHARS,
309 "No Formats");
310 cam->menu_item = gtk_menu_item_new_with_label (_(tmp));
311 gtk_widget_show (cam->menu_item);
312 gtk_menu_append (GTK_MENU (cam->format_menu_menu),
313 cam->menu_item);
314 gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->format_menu),
315 cam->format_menu_menu);
320 /* gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->format_menu), */
321 /* cam->format_menu_menu); */
324 * sets the active menu item:
326 gtk_option_menu_set_history (GTK_OPTION_MENU (cam->format_menu) ,
327 /* camera_act */ 0);
335 static void
336 create_fps_menu(GnomeApp *main_window,
337 Cam *cam
339 /*-----------------------------------------------------------------------------
340 * From coriander: build_menus.c BuildCameraMenu
343 dc1394bool_t cont=DC1394_TRUE;
344 gint new_framerate = 0;
345 gint index[NUM_FRAMERATES];
347 gint i, f, k = 0, err;
348 gchar tmp[GPIV_MAX_CHARS];
349 quadlet_t value;
351 if (cam_var.numCameras > 0) {
352 if (cam_var.misc_info[0].format == FORMAT_SCALABLE_IMAGE_SIZE) {
353 value = 0; /* format 7 has no fixed framerates */
354 } else {
355 err=dc1394_query_supported_framerates(cam_var.camera[0].handle,
356 cam_var.camera[0].id,
357 cam_var.misc_info[0].format,
358 cam_var.misc_info[0].mode,
359 &value);
360 if (!err) g_warning("Could not query supported framerates");
366 * remove previous menu
368 if (cam->fps_menu != NULL) {
369 gtk_widget_destroy(GTK_WIDGET (cam->fps_menu));
372 cam->fps_menu = gtk_option_menu_new ();
373 gtk_widget_ref (cam->fps_menu);
374 gtk_object_set_data_full (GTK_OBJECT (main_window),
375 "fps_menu",
376 cam->fps_menu,
377 (GtkDestroyNotify) gtk_widget_unref);
378 gtk_widget_show (cam->fps_menu);
379 gtk_container_add(GTK_CONTAINER (cam->vbox_cam),
380 cam->fps_menu);
383 cam->fps_menu_menu = gtk_menu_new ();
384 if (cam_var.numCameras > 0) {
385 k = 0;
386 for (f=FRAMERATE_MIN, i=0; f <= FRAMERATE_MAX; i++, f++) {
388 * 31 to 31-num_framerates
390 if (value & (0x1 << (31-i) ) ) {
391 index[i]=k;
392 k++;
393 cam->menu_item = gtk_menu_item_new_with_label (_(fps_label_list[i]));
394 gtk_widget_show (cam->menu_item);
395 gtk_menu_append (GTK_MENU (cam->fps_menu_menu),
396 cam->menu_item);
398 /* gtk_object_set_data(GTK_OBJECT (cam->menu_item), */
399 /* "gpiv", */
400 /* gpiv); */
401 g_signal_connect (GTK_OBJECT (cam->menu_item),
402 "activate",
403 GTK_SIGNAL_FUNC (on_menu_fps),
404 /* (int*)(i + MODE_FPS0_MIN)); */
405 (int*)f);
407 else
408 index[i] = -1; // framerate not supported
410 gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->fps_menu),
411 cam->fps_menu_menu);
413 if (index[cam_var.misc_info[0].framerate-FRAMERATE_MIN] < 0 ) {
414 // previously selected framerate unsupported!!
415 // automatically switch to nearest fps available
416 for (i = 1; i <= ((NUM_FRAMERATES>>1) +1); i++) {
417 // search radius is num_framerates/2 +1 for safe rounding
418 if (((cam_var.misc_info[0].framerate-FRAMERATE_MIN-i)>=0) && cont) {
419 if (index[cam_var.misc_info[0].framerate - FRAMERATE_MIN-i]
420 >= 0) {
421 // try down
422 new_framerate=cam_var.misc_info[0].framerate - i;
423 cont=DC1394_FALSE;
426 if (((cam_var.misc_info[0].framerate - FRAMERATE_MIN + i)
427 < NUM_FRAMERATES)
428 && cont) {
429 if (index[cam_var.misc_info[0].framerate - FRAMERATE_MIN + i]
430 >=0) {
431 // try up
432 new_framerate=cam_var.misc_info[0].framerate + i;
433 cont=DC1394_FALSE;
437 snprintf(tmp, GPIV_MAX_CHARS,
438 "create_fps_menu: Invalid framerate. Updating to nearest: %s\n",
439 fps_label_list[new_framerate-FRAMERATE_MIN]);
440 warning_gpiv(tmp);
441 err = dc1394_set_video_framerate(cam_var.camera[0].handle,
442 cam_var.camera[0].id,
443 new_framerate);
444 if (!err)
445 warning_gpiv("create_fps_menu: Cannot set video framerate");
446 cam_var.misc_info[0].framerate = new_framerate;
448 gtk_option_menu_set_history (GTK_OPTION_MENU (cam->fps_menu),
449 index[cam_var.misc_info[0].framerate -
450 FRAMERATE_MIN]);
459 static void
460 create_trigger_mode(GnomeApp *main_window,
461 Cam *cam
463 /*-----------------------------------------------------------------------------
464 * From coriander: build_menus.c BuildCameraMenu
467 gint err, i, f, modes = 0;
468 quadlet_t value;
469 gint k=0;
470 gint index[NUM_TRIGGER_MODE];
473 if (cam_var.numCameras > 0) {
474 err = dc1394_query_feature_characteristics(cam_var.camera[0].handle,
475 cam_var.camera[0].id,
476 FEATURE_TRIGGER,
477 &value);
478 if (!err) g_warning("Could not query trigger feature characteristics");
479 modes = ( (value & (0xF << 12))>>12 );
485 * remove previous menu
487 if (cam->trigger_mode != NULL) {
488 gtk_widget_destroy(GTK_WIDGET (cam->trigger_mode));
491 cam->trigger_mode = gtk_option_menu_new ();
492 gtk_widget_ref (cam->trigger_mode);
493 gtk_object_set_data_full (GTK_OBJECT (main_window),
494 "trigger_mode",
495 cam->trigger_mode,
496 (GtkDestroyNotify) gtk_widget_unref);
497 gtk_widget_show (cam->trigger_mode);
498 gtk_container_add(GTK_CONTAINER (cam->vbox_cam),
499 cam->trigger_mode);
502 cam->trigger_mode_menu = gtk_menu_new ();
503 if (cam_var.numCameras > 0) {
504 if (modes) {
506 * at least one mode present
507 * external trigger available:
509 for (f = TRIGGER_MODE_MIN, i = 0; f <= TRIGGER_MODE_MAX; i++, f++) {
510 if (modes & (0x1<<(TRIGGER_MODE_MAX-f))) {
511 index[i]=k;
512 k++;
513 cam->menu_item =
514 gtk_menu_item_new_with_label (_(trigger_mode_desc[i]));
515 gtk_widget_show (cam->menu_item);
516 gtk_menu_append (GTK_MENU (cam->trigger_mode_menu),
517 cam->menu_item);
518 g_signal_connect (GTK_OBJECT (cam->menu_item),
519 "activate",
520 GTK_SIGNAL_FUNC (on_trigger_mode_activate),
521 (int*) f);
523 else
524 index[i]=0;
527 gtk_option_menu_set_menu (GTK_OPTION_MENU (cam->trigger_mode),
528 cam->trigger_mode_menu);
530 * sets the active menu item:
532 gtk_option_menu_set_history (GTK_OPTION_MENU (cam->trigger_mode),
533 index[cam_var.feature_set[0].feature
534 [FEATURE_TRIGGER - FEATURE_MIN]
535 .trigger_mode]);
542 static void
543 create_camera_feature_menu_scale(GnomeApp *main_window,
544 Cam *cam,
545 gint FEATURE,
546 gchar *description,
547 gint row,
549 GtkWidget *option,
550 GtkWidget *option_menu,
551 GtkWidget *menu_item_option_man,
552 GtkWidget *menu_item_option_auto,
553 GtkWidget *menu_item_option_na,
554 GtkObject *adj_scale,
555 GtkWidget *scale
557 /*-----------------------------------------------------------------------------
560 GtkWidget *label;
561 gint col = 0;
563 label = gtk_label_new(_(description));
564 gtk_widget_ref(label);
565 gtk_object_set_data_full(GTK_OBJECT (main_window),
566 "label",
567 label,
568 (GtkDestroyNotify) gtk_widget_unref);
569 gtk_widget_show(label);
573 if (cam_var.numCameras > 0
574 && cam_var.feature_set[0].feature[FEATURE - FEATURE_MIN].
575 readout_capable) {
576 adj_scale =
577 gtk_adjustment_new(0,
578 cam_var.feature_set[0].
579 feature[FEATURE - FEATURE_MIN].min,
580 cam_var.feature_set[0].
581 feature[FEATURE - FEATURE_MIN].max,
585 } else {
586 adj_scale =
587 gtk_adjustment_new(0,
589 255,
594 scale = gtk_hscale_new (GTK_ADJUSTMENT
595 (adj_scale));
596 gtk_widget_ref (scale);
597 gtk_object_set_data_full (GTK_OBJECT (main_window),
598 "scale",
599 scale,
600 (GtkDestroyNotify) gtk_widget_unref);
601 gtk_widget_show (scale);
602 gtk_widget_set_sensitive (scale,
603 FALSE);
604 gtk_scale_set_digits (GTK_SCALE (scale),
607 if (cam_var.numCameras > 0) {
608 if (cam_var.feature_set[0].feature[FEATURE - FEATURE_MIN].
609 readout_capable) {
610 gtk_adjustment_set_value(GTK_ADJUSTMENT (adj_scale),
611 cam_var.feature_set[0].
612 feature[FEATURE - FEATURE_MIN].value);
615 if (cam_var.feature_set[0].feature[FEATURE - FEATURE_MIN].
616 manual_capable) {
618 * set glider active and connect
620 gtk_widget_set_sensitive (scale, TRUE);
621 g_signal_connect (GTK_OBJECT (adj_scale),
622 "value_changed",
623 GTK_SIGNAL_FUNC (on_scale_changed),
624 (int*) FEATURE);
630 option = gtk_option_menu_new ();
631 gtk_widget_ref (option);
632 gtk_object_set_data_full (GTK_OBJECT (main_window),
633 "option",
634 option,
635 (GtkDestroyNotify) gtk_widget_unref);
636 gtk_widget_show (option);
637 gtk_widget_set_sensitive (option, FALSE);
638 /* gtk_object_set_data(GTK_OBJECT (option), */
639 /* "dac", */
640 /* dac); */
644 option_menu = gtk_menu_new ();
645 if (cam_var.numCameras > 0) {
646 if (cam_var.feature_set[0].feature[FEATURE - FEATURE_MIN].
647 manual_capable) {
649 * add menu man
651 gtk_widget_set_sensitive (option,
652 TRUE);
653 menu_item_option_man =
654 gtk_menu_item_new_with_label (_("Man"));
655 gtk_widget_show (menu_item_option_man);
656 gtk_menu_append (GTK_MENU (option_menu),
657 menu_item_option_man);
658 gtk_object_set_data(GTK_OBJECT (menu_item_option_man),
659 "scale",
660 scale);
661 gtk_object_set_data(GTK_OBJECT (menu_item_option_man),
662 "var_type",
663 "0");
664 g_signal_connect (GTK_OBJECT (menu_item_option_man),
665 "activate",
666 GTK_SIGNAL_FUNC (on_man_auto_menu),
667 (int*) FEATURE);
670 if (cam_var.feature_set[0].feature[FEATURE - FEATURE_MIN].
671 auto_capable) {
673 * add menu auto
675 gtk_widget_set_sensitive (option, TRUE);
676 menu_item_option_auto = gtk_menu_item_new_with_label (_("Auto"));
677 gtk_widget_show (menu_item_option_auto);
678 gtk_menu_append (GTK_MENU (option_menu),
679 menu_item_option_auto);
680 gtk_object_set_data(GTK_OBJECT (menu_item_option_auto),
681 "scale",
682 scale);
683 gtk_object_set_data(GTK_OBJECT (menu_item_option_auto),
684 "var_type",
685 "1");
686 g_signal_connect (GTK_OBJECT (menu_item_option_auto),
687 "activate",
688 GTK_SIGNAL_FUNC (on_man_auto_menu),
689 (int*) FEATURE);
692 * add menu non avail.
694 if (!cam_var.feature_set[0].feature[FEATURE - FEATURE_MIN].auto_capable
695 && !cam_var.feature_set[0].feature[FEATURE - FEATURE_MIN].
696 manual_capable
698 gtk_widget_set_sensitive (option,
699 FALSE);
700 menu_item_option_na = gtk_menu_item_new_with_label (_("N/A"));
701 gtk_widget_show (menu_item_option_na);
702 gtk_menu_append (GTK_MENU (option_menu),
703 menu_item_option_na);
706 gtk_option_menu_set_menu (GTK_OPTION_MENU (option),
707 option_menu);
712 gtk_table_attach(GTK_TABLE(cam->table_cam),
713 label,
714 col,
715 col + 1,
716 row,
717 row + 1,
718 (GtkAttachOptions) 0,
719 (GtkAttachOptions) 0,
725 gtk_table_attach(GTK_TABLE(cam->table_cam),
726 option,
727 col + 1,
728 col + 2,
729 row,
730 row + 1,
731 (GtkAttachOptions) 0,
732 (GtkAttachOptions) (0),
737 gtk_table_attach(GTK_TABLE(cam->table_cam),
738 scale,
739 col + 2,
740 col + 3,
741 row,
742 row + 1,
743 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
744 (GtkAttachOptions) (GTK_FILL),
749 Cam *
750 create_cam(GnomeApp *main_window,
751 GtkWidget *container
753 /*-----------------------------------------------------------------------------
754 * Image Info window with data from header
757 GpivConsole * gpiv = gtk_object_get_data(GTK_OBJECT (main_window), "gpiv");
758 Cam * cam = g_new0(Cam, 1);
761 dac->cam->frame_cam = gtk_frame_new(_("Camera"));
762 gtk_widget_ref(dac->cam->frame_cam);
763 gtk_object_set_data_full(GTK_OBJECT (main_window),
764 "dac_frame_cam",
765 dac->cam->frame_cam,
766 (GtkDestroyNotify) gtk_widget_unref);
767 gtk_widget_show(dac->cam->frame_cam);
768 gtk_table_attach(GTK_TABLE(dac->table),
769 dac->cam->frame_cam,
774 (GtkAttachOptions) (GTK_FILL),
775 (GtkAttachOptions) (0),
781 dac->cam->vbox_cam = gtk_vbox_new(FALSE,
783 gtk_widget_ref(dac->cam->vbox_cam);
784 gtk_object_set_data_full(GTK_OBJECT (main_window),
785 "vbox_cam",
786 dac->cam->vbox_cam,
787 (GtkDestroyNotify) gtk_widget_unref);
788 gtk_widget_show(dac->cam->vbox_cam);
789 gtk_container_add(GTK_CONTAINER (dac->cam->frame_cam),
790 dac->cam->vbox_cam);
791 /* gtk_table_attach(GTK_TABLE(dac->cam->table_cam), */
792 /* dac->cam->vbox_cam, */
793 /* 0, */
794 /* 3, */
795 /* 6, */
796 /* 7, */
797 /* (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), */
798 /* (GtkAttachOptions) 0, */
799 /* 0, */
800 /* 0); */
802 /* gtk_container_add(GTK_CONTAINER (hbox), */
803 /* label); */
806 * Camera select
809 * Camera Shutter menu's and adjuster
812 create_camera_menu(main_window,
813 dac->cam);
815 create_format_menu(main_window,
816 gpiv,
817 dac->cam);
819 create_fps_menu(main_window,
820 dac->cam);
825 /* dac->cam->frame_trigger = gtk_frame_new(_("Trigger")); */
826 /* gtk_widget_ref(dac->cam->frame_trigger); */
827 /* gtk_object_set_data_full(GTK_OBJECT (main_window), */
828 /* "dac_frame_trigger", */
829 /* dac->cam->frame_trigger, */
830 /* (GtkDestroyNotify) gtk_widget_unref); */
831 /* gtk_widget_show(dac->cam->frame_trigger); */
832 /* gtk_container_add(GTK_CONTAINER (dac->cam->vbox_cam), */
833 /* dac->cam->frame_trigger); */
838 /* dac->cam->vbox_trigger = gtk_vbox_new(FALSE, */
839 /* 0); */
840 /* gtk_widget_ref(dac->cam->vbox_trigger); */
841 /* gtk_object_set_data_full(GTK_OBJECT (main_window), */
842 /* "vbox_trigger", */
843 /* dac->cam->vbox_trigger, */
844 /* (GtkDestroyNotify) gtk_widget_unref); */
845 /* gtk_widget_show(dac->cam->vbox_trigger); */
846 /* gtk_container_add(GTK_CONTAINER (dac->cam->frame_trigger), */
847 /* dac->cam->vbox_trigger); */
852 dac->cam->hbox_trigger = gtk_hbox_new(FALSE,
854 gtk_widget_ref(dac->cam->hbox_trigger);
855 gtk_object_set_data_full(GTK_OBJECT (main_window),
856 "hbox_trigger",
857 dac->cam->hbox_trigger,
858 (GtkDestroyNotify) gtk_widget_unref);
859 gtk_widget_show(dac->cam->hbox_trigger);
860 gtk_container_add(GTK_CONTAINER (dac->cam->vbox_cam),
861 dac->cam->hbox_trigger);
866 dac->cam->trigger_external = gtk_toggle_button_new_with_label (_("External trigger"));
867 gtk_widget_ref (dac->cam->trigger_external);
868 gtk_object_set_data_full (GTK_OBJECT (main_window),
869 "trigger_external",
870 dac->cam->trigger_external,
871 (GtkDestroyNotify) gtk_widget_unref);
872 gtk_widget_show (dac->cam->trigger_external);
873 gtk_container_add(GTK_CONTAINER (dac->cam->hbox_trigger),
874 dac->cam->trigger_external);
875 gtk_widget_set_sensitive (dac->cam->trigger_external,
876 FALSE);
877 g_signal_connect (GTK_OBJECT (dac->cam->trigger_external), "toggled",
878 GTK_SIGNAL_FUNC (on_trigger_external_toggled),
879 NULL);
884 dac->cam->trigger_polarity = gtk_toggle_button_new_with_label (_("Polarity"));
885 gtk_widget_ref (dac->cam->trigger_polarity);
886 gtk_object_set_data_full (GTK_OBJECT (main_window),
887 "trigger_polarity",
888 dac->cam->trigger_polarity,
889 (GtkDestroyNotify) gtk_widget_unref);
890 gtk_widget_show (dac->cam->trigger_polarity);
891 gtk_container_add(GTK_CONTAINER (dac->cam->hbox_trigger),
892 dac->cam->trigger_polarity);
893 gtk_widget_set_sensitive (dac->cam->trigger_polarity,
894 FALSE);
895 g_signal_connect (GTK_OBJECT (dac->cam->trigger_polarity), "toggled",
896 GTK_SIGNAL_FUNC (on_trigger_polarity_toggled),
897 NULL);
901 create_trigger_mode(main_window,
902 dac->cam);
904 * Enable triggering with the cam
906 #ifdef ENABLE_TRIG
907 dac->cam->checkbutton_camera_trigger =
908 gtk_check_button_new_with_label(_("RTAI triggering"));
909 gtk_widget_ref(dac->cam->checkbutton_camera_trigger);
910 gtk_object_set_data_full(GTK_OBJECT (main_window),
911 "button_camera_trigger",
912 dac->cam->checkbutton_camera_trigger,
913 (GtkDestroyNotify) gtk_widget_unref);
914 gtk_widget_show(dac->cam->checkbutton_camera_trigger);
915 gtk_container_add(GTK_CONTAINER (dac->cam->vbox_cam),
916 dac->cam->checkbutton_camera_trigger);
917 gtk_tooltips_set_tip(gpiv->tooltips,
918 dac->cam->checkbutton_camera_trigger,
919 _("Enables triggering of the camera and laser. "
920 "Else, the camera will 'free run', mostly at "
921 "30 frames per second."),
922 NULL);
924 gtk_object_set_data(GTK_OBJECT (dac->cam->checkbutton_camera_trigger),
925 "gpiv",
926 gpiv);
927 g_signal_connect(GTK_OBJECT (dac->cam->checkbutton_camera_trigger),
928 "enter",
929 G_CALLBACK (on_checkbutton_camera_trigger_enter),
930 NULL);
931 g_signal_connect(GTK_OBJECT (dac->cam->checkbutton_camera_trigger),
932 "leave",
933 G_CALLBACK (on_widget_leave),
934 NULL);
935 g_signal_connect(GTK_OBJECT (dac->cam->checkbutton_camera_trigger),
936 "clicked",
937 G_CALLBACK (on_checkbutton_camera_trigger),
938 NULL);
939 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON
940 (dac->cam->checkbutton_camera_trigger),
941 gpiv_par.trigger_cam);
942 #endif /* ENABLE_TRIG */
946 dac->cam->table_cam = gtk_table_new(9,
948 FALSE);
949 gtk_widget_ref(dac->cam->table_cam);
950 gtk_object_set_data_full(GTK_OBJECT (main_window),
951 "dac_table_cam",
952 dac->cam->table_cam,
953 (GtkDestroyNotify) gtk_widget_unref);
954 gtk_widget_show(dac->cam->table_cam);
955 gtk_container_add(GTK_CONTAINER (dac->cam->vbox_cam),
956 dac->cam->table_cam);
961 * Report Camera temperature
966 dac->cam->label_label_temp = gtk_label_new(_("temp (C): "));
967 gtk_widget_ref(dac->cam->label_label_temp);
968 gtk_object_set_data_full(GTK_OBJECT (main_window),
969 "dac_label_label_temp",
970 dac->cam->label_label_temp,
971 (GtkDestroyNotify) gtk_widget_unref);
972 gtk_widget_show(dac->cam->label_label_temp);
973 gtk_table_attach(GTK_TABLE(dac->cam->table_cam),
974 dac->cam->label_label_temp,
979 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
980 (GtkAttachOptions) 0,
987 dac->cam->label_temp = gtk_label_new("");
988 gtk_widget_ref(dac->cam->label_temp);
989 gtk_object_set_data_full(GTK_OBJECT (main_window),
990 "dac_label_temp",
991 dac->cam->label_temp,
992 (GtkDestroyNotify) gtk_widget_unref);
993 gtk_widget_show(dac->cam->label_temp);
994 gtk_table_attach(GTK_TABLE(dac->cam->table_cam),
995 dac->cam->label_temp,
1000 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1001 (GtkAttachOptions) 0,
1005 /* g_warning("cr_dac:: feature T; %s", */
1006 /* dc1394_feature_desc[FEATURE_TEMPERATURE - FEATURE_MIN]); */
1011 * Camera Exposure menu's and adjuster
1013 * First define the scale as its data are set for the menu items
1015 create_camera_feature_menu_scale(main_window,
1016 dac->cam,
1017 FEATURE_EXPOSURE,
1018 "Exp:",
1019 /* row */ 2,
1020 dac->cam->camera_exposure,
1021 dac->cam->camera_exposure_menu,
1022 dac->cam->menu_item_camera_exposure_man,
1023 dac->cam->menu_item_camera_exposure_auto,
1024 dac->cam->menu_item_camera_exposure_na,
1025 dac->cam->adj_exposure_scale,
1026 dac->cam->exposure_scale
1029 * Camera Iris menu's and adjuster
1031 create_camera_feature_menu_scale(main_window,
1032 dac->cam,
1033 FEATURE_IRIS,
1034 "Iris:",
1036 dac->cam->camera_iris,
1037 dac->cam->camera_iris_menu,
1038 dac->cam->menu_item_camera_iris_man,
1039 dac->cam->menu_item_camera_iris_auto,
1040 dac->cam->menu_item_camera_iris_na,
1041 dac->cam->adj_iris_scale,
1042 dac->cam->iris_scale
1046 * Camera Shutter menu's and adjuster
1048 create_camera_feature_menu_scale(main_window,
1049 dac->cam,
1050 FEATURE_SHUTTER,
1051 "Shut:",
1053 dac->cam->camera_shutter,
1054 dac->cam->camera_shutter_menu,
1055 dac->cam->menu_item_camera_shutter_man,
1056 dac->cam->menu_item_camera_shutter_auto,
1057 dac->cam->menu_item_camera_shutter_na,
1058 dac->cam->adj_shutter_scale,
1059 dac->cam->shutter_scale
1063 * Camera Gain menu's and adjuster
1065 create_camera_feature_menu_scale(main_window,
1066 dac->cam,
1067 FEATURE_GAIN,
1068 "Gain:",
1070 dac->cam->camera_gain,
1071 dac->cam->camera_gain_menu,
1072 dac->cam->menu_item_camera_gain_man,
1073 dac->cam->menu_item_camera_gain_auto,
1074 dac->cam->menu_item_camera_gain_na,
1075 dac->cam->adj_gain_scale,
1076 dac->cam->gain_scale
1080 * Camera Temperature menu's and adjuster
1082 create_camera_feature_menu_scale(main_window,
1083 dac->cam,
1084 FEATURE_TEMPERATURE,
1085 "Temp:",
1087 dac->cam->camera_temp,
1088 dac->cam->camera_temp_menu,
1089 dac->cam->menu_item_camera_temp_man,
1090 dac->cam->menu_item_camera_temp_auto,
1091 dac->cam->menu_item_camera_temp_na,
1092 dac->cam->adj_temp_scale,
1093 dac->cam->temp_scale
1097 * Camera Zoom menu's and adjuster
1099 create_camera_feature_menu_scale(main_window,
1100 dac->cam,
1101 FEATURE_ZOOM,
1102 "Zoom:",
1104 dac->cam->camera_zoom,
1105 dac->cam->camera_zoom_menu,
1106 dac->cam->menu_item_camera_zoom_man,
1107 dac->cam->menu_item_camera_zoom_auto,
1108 dac->cam->menu_item_camera_zoom_na,
1109 dac->cam->adj_zoom_scale,
1110 dac->cam->zoom_scale
1114 * Camera Pan menu's and adjuster
1116 create_camera_feature_menu_scale(main_window,
1117 dac->cam,
1118 FEATURE_PAN,
1119 "Pan:",
1121 dac->cam->camera_pan,
1122 dac->cam->camera_pan_menu,
1123 dac->cam->menu_item_camera_pan_man,
1124 dac->cam->menu_item_camera_pan_auto,
1125 dac->cam->menu_item_camera_pan_na,
1126 dac->cam->adj_pan_scale,
1127 dac->cam->pan_scale
1131 * Camera Tilt menu's and adjuster
1133 create_camera_feature_menu_scale(main_window,
1134 dac->cam,
1135 FEATURE_TILT,
1136 "Tilt:",
1138 dac->cam->camera_tilt,
1139 dac->cam->camera_tilt_menu,
1140 dac->cam->menu_item_camera_tilt_man,
1141 dac->cam->menu_item_camera_tilt_auto,
1142 dac->cam->menu_item_camera_tilt_na,
1143 dac->cam->adj_tilt_scale,
1144 dac->cam->tilt_scale
1148 * Record activating button
1150 dac->cam->button_cam_start = gtk_button_new_with_label(_("start camera"));
1151 gtk_widget_ref(dac->cam->button_cam_start);
1152 gtk_object_set_data_full(GTK_OBJECT (main_window),
1153 "button_cam_start",
1154 dac->cam->button_cam_start,
1155 (GtkDestroyNotify) gtk_widget_unref);
1156 gtk_widget_show(dac->cam->button_cam_start);
1157 gtk_table_attach(GTK_TABLE(dac->table),
1158 dac->cam->button_cam_start,
1163 (GtkAttachOptions) (GTK_FILL),
1164 (GtkAttachOptions) (GTK_FILL),
1167 gtk_tooltips_set_tip(gpiv->tooltips,
1168 dac->cam->button_cam_start,
1169 _("Starts camera to record PIV images of an area that is illuminated "
1170 "by a (double cavity Nd-YAG) laser and is observed "
1171 "by a CCD camera. Camera and lasers are eventually "
1172 "triggered by TTL pulses from the (parallel) output "
1173 "port."),
1174 NULL);
1176 gtk_object_set_data(GTK_OBJECT (dac->cam->button_cam_start),
1177 "gpiv",
1178 gpiv);
1179 g_signal_connect(GTK_OBJECT (dac->cam->button_cam_start),
1180 "enter",
1181 G_CALLBACK (on_button_dac_camstart_enter),
1182 NULL);
1183 g_signal_connect(GTK_OBJECT (dac->cam->button_cam_start),
1184 "leave",
1185 G_CALLBACK (on_widget_leave),
1186 NULL);
1187 g_signal_connect(GTK_OBJECT (dac->cam->button_cam_start),
1188 /* "clicked", */
1189 /* "released", */
1190 "pressed",
1191 G_CALLBACK (on_button_dac_camstart),
1192 NULL);
1196 * Record de-activating button
1198 dac->cam->button_cam_stop = gtk_button_new_with_label(_("stop camera"));
1199 gtk_widget_ref(dac->cam->button_cam_stop);
1200 gtk_object_set_data_full(GTK_OBJECT (main_window),
1201 "button_cam_stop",
1202 dac->cam->button_cam_stop,
1203 (GtkDestroyNotify) gtk_widget_unref);
1204 gtk_widget_show(dac->cam->button_cam_stop);
1205 gtk_table_attach(GTK_TABLE(dac->table),
1206 dac->cam->button_cam_stop,
1211 (GtkAttachOptions) (GTK_FILL),
1212 (GtkAttachOptions) (GTK_FILL),
1215 gtk_tooltips_set_tip(gpiv->tooltips,
1216 dac->cam->button_cam_stop,
1217 _("Stops camera to record of PIV images "
1218 "and, eventually, cancels sending of trigger pulses"),
1219 NULL);
1221 gtk_object_set_data(GTK_OBJECT (dac->cam->button_cam_stop),
1222 "gpiv",
1223 gpiv);
1224 g_signal_connect(GTK_OBJECT (dac->cam->button_cam_stop),
1225 "enter",
1226 G_CALLBACK (on_button_dac_camstop_enter),
1227 NULL);
1228 g_signal_connect(GTK_OBJECT (dac->cam->button_cam_stop),
1229 "leave",
1230 G_CALLBACK (on_widget_leave),
1231 NULL);
1232 g_signal_connect(GTK_OBJECT (dac->cam->button_cam_stop),
1233 "clicked",
1234 G_CALLBACK (on_button_dac_camstop),
1235 NULL);
1236 return cam;