Ejemplo n.º 1
0
/**
 * Sends update to source for camera adjustment
 */
void exposure_value_changed (GtkAdjustment *adj, Win* w)
{
    /* exposure should be handled logarithmically */

    double rmin;
    double rmax;

    /* retrieve exposure boundaries */
    arv_camera_get_exposure_time_bounds (p.camera, &rmin, &rmax);

    /* get new value */
    double pos = adj->value;

    if (isnan(pos))
    {
        pos = 1.0;
    }

    /* since exposure is a logarithmic scale we do the math */
    
    double min = log(rmin);
    double rangelen = log(rmax) - min;
    double val = exp( min + rangelen / ABSVAL_SLIDER_TICKS * pos );

    if( val > rmax ) val = rmax;
    if( val < rmin ) val = rmin;

    /* always set exposure and gain via aravisrc to assure everybody gets the new values */
    g_object_set (G_OBJECT (p.source), "exposure", val, NULL);

    /* update our slides label */
    set_slider_label (GTK_LABEL(w->exposure_value_label), val);
}
Ejemplo n.º 2
0
static void
slider_changed (GtkRange * range, VidState * s)
{
  
    ControlInfo * ci = g_object_get_data (G_OBJECT (range), "control_info");
    InputControl * c = s->control + ci->idx;
    int val = (int) gtk_range_get_value (range);
    
    if (input_set_control (videoIn, c, val) == 0) {
        set_slider_label (range);
        printf ("changed to %d\n", val);
    }
    else {
        printf ("changed to %d, but set failed\n", val);
    }
    if (input_get_control (videoIn, c, &val) == 0) {
        printf ("hardware value is %d\n", val);
    }
    else {
        printf ("hardware get failed\n");
    }
	
}
void
EditButtonWindow::MessageReceived(BMessage *msg)
{
	BMessage mymsg(51000);
	int32 id,vl;
	BTextControl *xt = NULL;
	char *txt = "";
	WrkWindow *win = DefWin,*wi = OldWindow;

	msg->FindInt32("be:value",&vl);
	msg->FindInt32("index",&id);

	if (msg->FindPointer("source",(void **)&xt) == B_OK)
	{
		if (is_instance_of(xt,BTextControl))
		{
			txt = xt->Text();		
		}	
	}

	switch(msg->what)
	{
		case	73500:
		case	73501:
		case	73502:
		{
			CheckItemBox *it;
			int k;

			for (k = 0; k < idcmp->CountItems(); k++)
			{
				if (it = (CheckItemBox *)idcmp->ItemAt(k))
				{
					switch(msg->what)
					{
						case	73500:	it->checked = true;		break;
						case	73501:	it->checked = false;	break;
						case	73502:	it->checked = !it->checked;	break;
					}

					ChangeFlags(k,it->checked);

					idcmp->InvalidateItem(idcmp->IndexOf(it));
				}			
			}
		}
		break;

		case	73600:
		case	73601:
		case	73602:
		{
			CheckItemBox *it;
			int k;

			for (k = 0; k < lv->CountItems(); k++)
			{
				if (it = (CheckItemBox *)lv->ItemAt(k))
				{
					switch(msg->what)
					{
						case	73600:	it->checked = true;		break;
						case	73601:	it->checked = false;	break;
						case	73602:	it->checked = !it->checked;	break;
					}

					ChangeView(k,it->checked);

					lv->InvalidateItem(lv->IndexOf(it));
				}			
			}
		}
		break;

		case	2200:
		{
			OpenColorPicker(msg);
		}
		break;

		case BEAIM_NEW_COLOR_PICKED:
		{
			ColorView *bt;

			if (msg->FindPointer("pt",(void **)&bt) == B_OK)
			{
				rgb_color cl,*startColor;
				ssize_t size;
	
				msg->FindData( "color",B_RGB_COLOR_TYPE,(const void**)&startColor,&size );

				cl.red 		= startColor->red;
				cl.green 	= startColor->green;
				cl.blue 	= startColor->blue;

				bt->SetColor(cl);
			}

			SetNewColor(msg);
		}
		break;	

		case	tab_tab_list:
		{
			AddListWindow(win->sellist.ItemAt(0));
		}
		break;

		case	tab_menu_list:
		{
			create_mmxmenu();
		}
		break;

		case	tab_menu_editlist:
		{
			struct MyGadget *gad;

			if (gad = win->sellist.ItemAt(0))
			{
				window_menu(&gad->name);
			}
		}
		break;

		case	window_minh:
		{
			if (wi)
			{
				wi->minh = vl;			
			}
		}
		break;

		case	window_maxh:
		{
			if (wi)
			{
				wi->maxh = vl;			
			}
		}
		break;

		case	window_minw:
		{
			if (wi)
			{
				wi->minw = vl;			
			}
		}
		break;

		case	window_maxw:
		{
			if (wi)
			{
				wi->maxw = vl;			
			}
		}
		break;

		case	tab_font:
		{
			struct MyGadget *gad;

			if (wi = win)
			{
				if (gad = win->sellist.ItemAt(0))
				{
					font_window(gad->FontType,gad->FontSize,gad->FontAntiliasing,&gad->FontName[0],&gad->FontStyle[0]);
				}
					else
				{
					font_window(wi->FontType,wi->FontSize,wi->FontAntiliasing,&wi->FontName[0],&wi->FontStyle[0]);
				}
			}		
		}
		break;

		case	window_type:
		{
			if (wi)
			{
				wi->typewin = id;			

				ChangeWindowType(wi,id);
			}
		}
		break;

		case	window_look:
		{
			if (wi)
			{
				wi->look = id;			
			}
		}
		break;

		case	window_feel:
		{
			if (wi)
			{
				wi->feel = id;			
			}
		}
		break;

		case	window_workspace:
		{
			if (wi)
			{
				wi->wrk = id;			
			}
		}
		break;
			
		case	9000:
		{
			mymsg.AddInt32("x",vl);	
	
			win->PostMessage(&mymsg);
		}
		break;

		case	9001:
		{
			mymsg.AddInt32("y",vl);	
	
			win->PostMessage(&mymsg);
		}
		break;

		case	9002:
		{
			mymsg.AddInt32("w",vl);	
	
			win->PostMessage(&mymsg);
		}
		break;

		case	9003:
		{
			mymsg.AddInt32("h",vl);	
	
			win->PostMessage(&mymsg);
		}
		break;

		case	9004:
		{
			if (strcmp(txt,"") != 0)
			{
				if (is_title_available(txt))
				{
					if (win)
					{
						if (gad = win->sellist.ItemAt(0))
						{
							strcpy(&gad->Name[0],txt);		
						}
							else
						{
							strcpy(&win->Name[0],txt);		
						}
					}
				}
					else
				{
err:				if (EditorWin)
					{
						BAutolock lock(EditorWin);

						if (win)
						{
							if (gad = win->sellist.ItemAt(0))
							{
								EditorWin->name->SetText(&gad->Name[0]);
							}
								else
							{
								EditorWin->name->SetText(&win->Name[0]);
							}
						}	
					}	
				}	
			}
				else
			{
				::beep();
				
				goto err;
			}	
		}
		break;

		case	9005:
		{
			if (win)
			{
				if (gad = win->sellist.ItemAt(0))
				{
					strcpy(&gad->Title[0],txt);		

					ChangeGadgetLabel(gad,txt);
				}
					else
				{
					strcpy(&win->WTitle[0],txt);		

					win->Lock();

					win->ChangeTitleWindow();

					win->Unlock();
				}
			}	
		}
		break;

		case	9006:
		{
			if (gad)
			{
				gad->msg = atoi(txt);
			}
		}
		break;

		case	tab_focus:
		{
			gad->focus = id;		
		}
		break;

		case	align_type:
		{
			if (id == 2)
			{
				EnableRadio(true);

				SetChoiceInMenu(alignx->Menu(),gad->alignx,true);
				SetChoiceInMenu(aligny->Menu(),gad->aligny,true);

			}
				else
			{
				EnableRadio(false);
			}	

			gad->align = id;
		}
		break;
		
		case	align_x:
		{
			gad->alignx = id;
		}
		break;	

		case	align_y:
		{
			gad->aligny = id;
		}
		break;	

		case	gad_derived:
		{
			gad->derived = vl;
		}
		break;

//**************************** BUTTON *****************

		case	tab_button_default:
		{
			gad->data.button.defaut = id;

			set_button_defaut(gad,id);
		}
		break;

		case	tab_button_enabled:
		case	tab_checkbox_enabled:
		{
			gad->enable = id;

			SetEnableGadget(gad,id);
		}
		break;

//**************************** BBOX *****************

		case	tab_bbox_border:
		{
			gad->data.bbox.style = id;

			set_bbox_border(gad,id);
		}
		break;

		case	tab_bbox_label:
		{
			strcpy(&gad->data.bbox.Label[0],txt);

			set_bbox_label(gad,txt);		
		}
		break;

//**************************** CHECKBOX *****************

		case	tab_checkbox_checked:
		{
			gad->data.bcheckbox.checked = id;

			set_checkbox_checked(gad,id);
		}
		break;

//**************************** RADIO *****************

		case	tab_radio_value:
		{
			gad->data.rad.val = id;

			set_radio_checked(gad,id);
		}
		break;

		case	tab_radio_enable:
		{
			gad->enable = id;

			set_radio_enabled(gad,id);
		}
		break;

//**************************** STRING *****************

		case	tab_string_alignlab:
		{
			gad->data.string.alignlab = id;

			set_string_alignment_label(gad,id);		
		}
		break;

		case	tab_string_aligntxt:
		{
			gad->data.string.aligntxt = id;

			set_string_alignment_text(gad,id);		
		}
		break;

		case	tab_string_diviser:
		{
			gad->data.string.pixdiv = vl;

			set_string_divider(gad,vl);		
		}
		break;

		case	tab_string_label:
		{
			strcpy(&gad->data.string.Text[0],txt);

			set_string_label(gad,txt);		
		}
		break;

//**************************** STATUS *****************

		case	tab_status_trail:
		{
			strcpy(&gad->data.sta.Trail[0],txt);

			set_status_label(gad,txt);		
		}
		break;

		case	tab_status_label:
		{
			strcpy(&gad->data.sta.Label[0],txt);

			set_status_trail(gad,txt);		
		}
		break;

		case	tab_status_value:
		{
			gad->data.sta.value = vl;

			set_status_value(gad,vl);
		}
		break;

		case	tab_status_barheight:
		{
			gad->data.sta.barheight = vl;

			set_status_barheight(gad,vl);
		}
		break;

		case	tab_status_max:
		{
			gad->data.sta.maxvalue = vl;

			set_status_maxvalue(gad,vl);
		}
		break;

//**************************** SCROLLER *****************

		case	tab_scroller_value:
		{
			gad->data.bscroller.pos = vl;

			set_scroller_value(gad,vl);
		}
		break;

		case	tab_scroller_min:
		{
			gad->data.bscroller.min = vl;
		}
		break;

		case	tab_scroller_max:
		{
			gad->data.bscroller.max = vl;
		}
		break;

		case	tab_scroller_minstep:
		{
			gad->data.bscroller.minstep = vl;

			set_scroller_minstep(gad,vl);
		}
		break;

		case	tab_scroller_maxstep:
		{
			gad->data.bscroller.maxstep = vl;

			set_scroller_maxstep(gad,vl);
		}
		break;

		case	tab_scroller_minrange:
		{
			gad->data.bscroller.minrange = vl;

			set_scroller_minrange(gad,vl);
		}
		break;

		case	tab_scroller_maxrange:
		{
			gad->data.bscroller.maxrange = vl;

			set_scroller_maxrange(gad,vl);
		}
		break;

//**************************** TAB *****************

		case	tab_tab_width:
		{
			gad->data.tab.tabwidth = id;

			set_tab_width(gad,id);
		}
		break;

		case	tab_tab_height:
		{
			gad->data.tab.tabheight = vl;

			set_tab_height(gad,vl);
		}
		break;

		case	tab_tab_selected:
		{
			gad->data.tab.sel = vl;

			set_tab_select(gad,vl);
		}
		break;

//**************************** MX *****************

		case	tab_mx_align:
		{
			gad->data.mx.align = id;

			set_mx_align(gad,id);
		}
		break;

		case	tab_mx_diviser:
		{
			gad->data.mx.pixdiv = vl;

			set_mx_divider(gad,vl);
		}
		break;

		case	tab_mx_label:
		{
			strcpy(&gad->data.mx.Label[0],txt);

			set_mx_label(gad,txt);		
		}
		break;

//**************************** SLIDER *****************

		case	tab_slider_style:
		{
			gad->data.bslider.style = id;

			set_slider_style(gad,id);
		}
		break;

		case	tab_slider_hashtype:
		{
			gad->data.bslider.hashtype = id;

			set_slider_hashtype(gad,id);
		}
		break;

		case	tab_slider_hashcount:
		{
			gad->data.bslider.hashcount = vl;

			set_slider_hashcount(gad,vl);
		}
		break;

		case	tab_slider_value:
		{
			gad->data.bslider.pos = vl;

			set_slider_value(gad,vl);
		}
		break;

		case	tab_slider_min:
		{
			gad->data.bslider.min = vl;
		}
		break;

		case	tab_slider_max:
		{
			gad->data.bslider.max = vl;
		}
		break;

		case	tab_slider_thickness:
		{
			gad->data.bslider.thickness = vl;

			set_slider_thickness(gad,vl);
		}
		break;

		case	tab_slider_keyinc:
		{
			gad->data.bslider.keyinc = vl;

			set_slider_keyinc(gad,vl);
		}
		break;

		case	tab_slider_label:
		{
			strcpy(&gad->data.bslider.Label[0],txt);

			set_slider_label(gad,txt);		
		}
		break;

		case	tab_slider_minlabel:
		{
			strcpy(&gad->data.bslider.MinLabel[0],txt);

			set_slider_minlabel(gad,txt);		
		}
		break;

		case	tab_slider_maxlabel:
		{
			strcpy(&gad->data.bslider.MaxLabel[0],txt);

			set_slider_maxlabel(gad,txt);		
		}
		break;

//**************************** COLOR *****************

		case	tab_color_layout:
		{
			gad->data.col.layout = id;

			set_color_layout(gad,id);
		}
		break;

		case	tab_color_cellsize:
		{
			gad->data.col.cellsize = id;

			set_color_cellsize(gad,id);
		}
		break;

		case	tab_color_drawbuffered:
		{
			gad->data.col.redrawbuffer = id;
		}
		break;

//**************************** LV *****************

		case	tab_lv_multi:
		{
			gad->data.lv.multi = id;
		}
		break;

//**************************** OLV *****************

		case	tab_olv_multi:
		{
			gad->data.olv.multi = id;
		}
		break;

//**************************** TEXT *****************

		case	tab_text_align:
		{
			gad->data.txt.align = id;

			set_text_align(gad,id);
		}
		break;

		case	tab_number_align:
		{
			gad->data.num.align = id;

			set_text_align(gad,id);
		}
		break;

		case	tab_text_label:
		{
			strcpy(&gad->data.txt.Label[0],txt);

			set_text_text(gad,txt);		
		}
		break;

		case	tab_number_number:
		{
			strcpy(&gad->data.num.Label[0],txt);

			set_number_value(gad,atoi(txt));		
		}
		break;

//**************************** TEDIT *****************

		case	tab_tedit_align:
		{
			gad->data.edi.align = id;
		}
		break;

		case	tab_tedit_selectable:
		{
			gad->data.edi.selectable = id;
		}
		break;

		case	tab_tedit_editable:
		{
			gad->data.edi.editable = id;
		}
		break;

		case	tab_tedit_wordwrap:
		{
			gad->data.edi.wordwrap = id;
		}
		break;

		case	tab_tedit_setstylable:
		{
			gad->data.edi.stylable = id;
		}
		break;

		case	tab_tedit_autoident:
		{
			gad->data.edi.autoident = id;
		}
		break;

		case	tab_tedit_tabwidth:
		{
			gad->data.edi.tabwidth = vl;
		}
		break;

		case	tab_tedit_maxbytes:
		{
			gad->data.edi.maxchars = vl;
		}
		break;

//**************************** END *****************
	
		default:
		{
			BWindow::MessageReceived(msg);
		}
	}
}
Ejemplo n.º 4
0
static void
draw_controls (VidState *s)
{
    int i;
	
	
    if (s->control) {
        for (i = 0; i < s->num_controls; i++) {
            ControlInfo * ci = s->control_info + i;
            if (ci->widget)
                gtk_widget_destroy (ci->widget);
            if (ci->label)
                gtk_widget_destroy (ci->label);
            if (ci->labelval)
                gtk_widget_destroy (ci->labelval);
        }
        free (s->control_info);
        s->control_info = NULL;
        input_free_controls (s->control, s->num_controls);
        s->control = NULL;
    }
    
    s->control = input_enum_controls (videoIn, &s->num_controls);
    //fprintf(stderr,"V4L2_CID_BASE=0x%x\n",V4L2_CID_BASE);
	//fprintf(stderr,"V4L2_CID_PRIVATE_BASE=0x%x\n",V4L2_CID_PRIVATE_BASE);
	//fprintf(stderr,"V4L2_CID_PRIVATE_LAST=0x%x\n",V4L2_CID_PRIVATE_LAST);
    fprintf(stderr,"Controls:\n");
    for (i = 0; i < s->num_controls; i++) {
		fprintf(stderr,"control[%d]: 0x%x",i,s->control[i].id);
        fprintf (stderr,"  %s, %d:%d:%d, default %d\n", s->control[i].name,
                s->control[i].min, s->control[i].step, s->control[i].max,
                s->control[i].default_val);
    }

   if((s->control_info = malloc (s->num_controls * sizeof (ControlInfo)))==NULL){
   			printf("couldn't allocate memory for: s->control_info\n");
			exit(1); 
   }

    for (i = 0; i < s->num_controls; i++) {
        ControlInfo * ci = s->control_info + i;
        InputControl * c = s->control + i;

        ci->idx = i;
        ci->widget = NULL;
        ci->label = NULL;
        ci->labelval = NULL;
        
        if (c->id == V4L2_CID_EXPOSURE_AUTO) {
            int val;
            ci->widget = gtk_check_button_new_with_label (c->name);
            g_object_set_data (G_OBJECT (ci->widget), "control_info", ci);
            gtk_widget_show (ci->widget);
            gtk_table_attach (GTK_TABLE (s->table), ci->widget, 1, 3, 3+i, 4+i,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);

            if (input_get_control (videoIn, c, &val) == 0) {
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ci->widget),
                        val==AUTO_EXP ? TRUE : FALSE);
            }
            else {
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ci->widget),
                        c->default_val==AUTO_EXP ? TRUE : FALSE);
                gtk_widget_set_sensitive (ci->widget, FALSE);
            }

            if (!c->enabled) {
                gtk_widget_set_sensitive (ci->widget, FALSE);
            }
            
            g_signal_connect (G_OBJECT (ci->widget), "toggled",
                    G_CALLBACK (check_changed), s);
	        
	    } else if (c->type == INPUT_CONTROL_TYPE_INTEGER) {
            PangoFontDescription * desc;
            int val;

            if (c->step == 0)
                c->step = 1;
            ci->widget = gtk_hscale_new_with_range (c->min, c->max, c->step);
            gtk_scale_set_draw_value (GTK_SCALE (ci->widget), FALSE);

            /* This is a hack to use always round the HScale to integer
             * values.  Strangely, this functionality is normally only
             * available when draw_value is TRUE. */
            GTK_RANGE (ci->widget)->round_digits = 0;

            gtk_table_attach (GTK_TABLE (s->table), ci->widget, 1, 2, 3+i, 4+i,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);
            g_object_set_data (G_OBJECT (ci->widget), "control_info", ci);
            ci->maxchars = MAX (num_chars (c->min), num_chars (c->max));
            gtk_widget_show (ci->widget);
            
            ci->labelval = gtk_label_new (NULL);
            gtk_table_attach (GTK_TABLE (s->table), ci->labelval, 2, 3,
                    3+i, 4+i, GTK_FILL, 0, 0, 0);
            
            desc = pango_font_description_new ();
            pango_font_description_set_family_static (desc, "monospace");
            gtk_widget_modify_font (ci->labelval, desc);
            gtk_misc_set_alignment (GTK_MISC (ci->labelval), 1, 0.5);

            if (input_get_control (videoIn, c, &val) == 0) {
                gtk_range_set_value (GTK_RANGE (ci->widget), val);
            }
            else {
                gtk_range_set_value (GTK_RANGE (ci->widget), c->default_val);
                gtk_widget_set_sensitive (ci->widget, FALSE);
                gtk_widget_set_sensitive (ci->labelval, FALSE);
            }

            if (!c->enabled) {
                gtk_widget_set_sensitive (ci->widget, FALSE);
                gtk_widget_set_sensitive (ci->labelval, FALSE);
            }
            
            set_slider_label (GTK_RANGE (ci->widget));
            g_signal_connect (G_OBJECT (ci->widget), "value-changed",
                    G_CALLBACK (slider_changed), s);

            gtk_widget_show (ci->labelval);

            ci->label = gtk_label_new (g_strdup_printf ("%s:", c->name));
        }
        else if (c->type == INPUT_CONTROL_TYPE_BOOLEAN) {
            int val;
            ci->widget = gtk_check_button_new_with_label (c->name);
            g_object_set_data (G_OBJECT (ci->widget), "control_info", ci);
            gtk_widget_show (ci->widget);
            gtk_table_attach (GTK_TABLE (s->table), ci->widget, 1, 3, 3+i, 4+i,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);

            if (input_get_control (videoIn, c, &val) == 0) {
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ci->widget),
                        val ? TRUE : FALSE);
            }
            else {
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ci->widget),
                        c->default_val ? TRUE : FALSE);
                gtk_widget_set_sensitive (ci->widget, FALSE);
            }

            if (!c->enabled) {
                gtk_widget_set_sensitive (ci->widget, FALSE);
            }
            
            g_signal_connect (G_OBJECT (ci->widget), "toggled",
                    G_CALLBACK (check_changed), s);
        }
        else if (c->type == INPUT_CONTROL_TYPE_MENU) {
            int val, j;

            ci->widget = gtk_combo_box_new_text ();
            for (j = 0; j <= c->max; j++) {
                gtk_combo_box_append_text (GTK_COMBO_BOX (ci->widget), c->entries[j]);
            }

            gtk_table_attach (GTK_TABLE (s->table), ci->widget, 1, 3, 3+i, 4+i,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);
            g_object_set_data (G_OBJECT (ci->widget), "control_info", ci);
            gtk_widget_show (ci->widget);

            if (input_get_control (videoIn, c, &val) == 0) {
                gtk_combo_box_set_active (GTK_COMBO_BOX (ci->widget), val);
            }
            else {
                gtk_combo_box_set_active (GTK_COMBO_BOX (ci->widget), c->default_val);
                gtk_widget_set_sensitive (ci->widget, FALSE);
            }

            if (!c->enabled) {
                gtk_widget_set_sensitive (ci->widget, FALSE);
            }
            
            g_signal_connect (G_OBJECT (ci->widget), "changed",
                    G_CALLBACK (combo_changed), s);

            ci->label = gtk_label_new (g_strdup_printf ("%s:", c->name));
        }
        else {
            fprintf (stderr, "TODO: implement menu and button\n");
            continue;
        }

        if (ci->label) {
            gtk_misc_set_alignment (GTK_MISC (ci->label), 1, 0.5);

            gtk_table_attach (GTK_TABLE (s->table), ci->label, 0, 1, 3+i, 4+i,
                    GTK_FILL, 0, 0, 0);

            gtk_widget_show (ci->label);
        }
    }

}
Ejemplo n.º 5
0
/**
 * Initialize components for gtk window
 */
static Win* create_ui () 
{
    Win* w = malloc(sizeof(Win));

    /* create a new window */
    w->main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   
    /* area that will display our stream */
    w->video_window = gtk_drawing_area_new ();

    /* ===== framerate settings ===== */
    w->framerate_field = gtk_entry_new();

    /* connect button event to callback function */
    w->framerate_send_button = gtk_button_new_with_label("Set FrameRate");
    g_signal_connect (G_OBJECT (w->framerate_send_button), "clicked", G_CALLBACK (framerate_value_changed), w);

    /* ===== exposure scale ===== */
    w->exposure_label = gtk_label_new("Exposure:");

    gdouble value;
    g_object_get (G_OBJECT (p.source), "exposure", &value, NULL);

    w->exposure_value_label = gtk_label_new("0.0");
    /* the label should give enough space to not rezise */
    gtk_label_set_width_chars (GTK_LABEL(w->exposure_value_label), 10);
 
    /* the scale will have a range from 0 to 100 to use the percentage to implement a log scale */
    double rmin = 0;
    double rmax = 100;

    double rangelen2 = log(rmax) - log(rmin);
    double exposure_value = (ABSVAL_SLIDER_TICKS) / rangelen2 * ( log(value) - log(rmin) );
    
    gdouble exposure_lower          = 0.0;       /* min value */
    gdouble exposure_upper          = 100.0;     /* max value */
    gdouble exposure_step_increment = 1.0;       /* step size */
    gdouble exposure_page_increment = -10.0;     /* negatic value, to make page up increase value */
    gdouble exposure_page_size      = 0.0;

    GtkObject* wat = gtk_adjustment_new ( exposure_value,
                                          exposure_lower,
                                          exposure_upper,
                                          exposure_step_increment,
                                          exposure_page_increment,
                                          exposure_page_size);

    w->exposure_hscale = gtk_hscale_new (GTK_ADJUSTMENT(wat));
    gtk_scale_set_draw_value(GTK_SCALE (w->exposure_hscale), FALSE);
    gtk_widget_set_usize (GTK_WIDGET (w->exposure_hscale), 400, 30);
    g_signal_connect (G_OBJECT(wat), "value-changed", G_CALLBACK (exposure_value_changed), w);
    set_slider_label (GTK_LABEL(w->exposure_value_label), value);


    /* ===== gain part ===== */

    w->gain_label = gtk_label_new("Gain:");

    double gain_value;
    gdouble gain_lower; /* min value */
    gdouble gain_upper; /* max value */    

    w->gain_value_label = gtk_label_new("0.0");

    g_object_get (G_OBJECT (p.source), "gain", &gain_value, NULL);
    arv_camera_get_gain_bounds (p.camera, &gain_lower, &gain_upper);

    set_slider_label (GTK_LABEL(w->gain_value_label), gain_value);

    gdouble gain_step_increment = 0.1;       /* step size */
    gdouble gain_page_increment = -1.0;
    gdouble gain_page_size      = 0.0;

    GtkObject* range_gain = gtk_adjustment_new (gain_value,
                                                gain_lower,
                                                gain_upper,
                                                gain_step_increment,
                                                gain_page_increment,
                                                gain_page_size);

    w->gain_hscale = gtk_hscale_new (GTK_ADJUSTMENT(range_gain));
    gtk_scale_set_draw_value(GTK_SCALE (w->gain_hscale), FALSE);
    gtk_widget_set_usize (GTK_WIDGET (w->gain_hscale), 400, 50);
    g_signal_connect (G_OBJECT(range_gain), "value-changed", G_CALLBACK (gain_value_changed), w);

    
    GtkWidget* toggle;
    toggle = gtk_button_new_with_label("Start/Stop");
    g_signal_connect (G_OBJECT (toggle), "clicked", G_CALLBACK (togglePipelineState), NULL);


    /* ===== organize everything and place in window ===== */

    w->controls = gtk_hbox_new (FALSE, 0);

    gtk_box_pack_start (GTK_BOX (w->controls), toggle, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (w->controls), w->framerate_field, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (w->controls), w->framerate_send_button, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (w->controls), w->exposure_label, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (w->controls), w->exposure_value_label, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (w->controls), w->exposure_hscale, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (w->controls), w->gain_label, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (w->controls), w->gain_value_label, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (w->controls), w->gain_hscale, FALSE, FALSE, 2);
   
    w->main_hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (w->main_hbox), w->video_window, TRUE, TRUE, 0);
   
    w->main_box = gtk_vbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (w->main_box), w->main_hbox, TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (w->main_box), w->controls, FALSE, FALSE, 0);
    gtk_container_add (GTK_CONTAINER (w->main_window), w->main_box);

    gtk_window_set_default_size (GTK_WINDOW (w->main_window), HEIGHT, WIDTH);
   
    /* show all widgets we just added to out main window */
    gtk_widget_show_all (w->main_window);

    return w;
}
Ejemplo n.º 6
0
/**
 * Sends update to source for camera adjustment
 */
void gain_value_changed (GtkAdjustment *adj, Win* w)
{
    g_object_set (G_OBJECT (p.source), "gain", adj->value, NULL);

    set_slider_label (GTK_LABEL(w->gain_value_label), adj->value);
}