Commit 755a618a authored by Claes Sjofors's avatar Claes Sjofors

More xtt camera control

parent 21b54ca4
......@@ -33,7 +33,7 @@
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_a_cameraposition.wb_load -- Defines the class CameraPosition.
! pwrb_c_a_cameraptz.wb_load -- Defines the class CameraPtz.
!
SObject pwrb:Class
!/**
......@@ -41,7 +41,7 @@ SObject pwrb:Class
! @Summary Data for camera position
! Data for camera position.
!*/
Object CameraPosition $ClassDef 655
Object CameraPtz $ClassDef 655
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
......@@ -49,7 +49,7 @@ SObject pwrb:Class
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "CameraPosition"
Attr StructName = "CameraPtz"
EndBody
!/**
! Optional description.
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2014 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_cameraposition.wb_load -- Defines the class CameraPosition.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Data for camera position method in xtt.
! Data for camera position method in xtt.
!*/
Object CameraPosition $ClassDef 656
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr PopEditor = 1
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "CameraPosition"
EndBody
!/**
! XttVideo object for the camera.
!*/
Object VideoObject $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$AttrRef"
EndBody
EndObject
!/**
! Pan value.
! Range 0 - 100.
!*/
Object Pan $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Tilt value.
! Range 0 - 100.
!*/
Object Tilt $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Zoom value.
! Range 0 - 100.
!*/
Object Zoom $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
EndObject
EndObject
EndSObject
......@@ -162,7 +162,7 @@ SObject pwrb:Class
!*/
Object PresetPosition $Attribute 14
Body SysBody
Attr TypeRef = "pwrb:Class-CameraPosition"
Attr TypeRef = "pwrb:Class-CameraPtz"
Attr Flags |= PWR_MASK_CLASS
Attr Flags |= PWR_MASK_ARRAY
Attr Elements = 10
......
......@@ -66,6 +66,16 @@ SObject pwrb:Type
Attr Value = 1
EndBody
EndObject
!/**
! HDF5.
!*/
Object HDF5 $Value
Body SysBody
Attr PgmName = "HDF5"
Attr Text = "HDF5"
Attr Value = 2
EndBody
EndObject
EndObject
EndSObject
......
......@@ -92,25 +92,35 @@ SObject pwrb:Type
EndBody
EndObject
!/**
! Display a control panel with Play, Pause and Stop buttons.
! Display a camera control panel.
!*/
Object ControlPanel $Bit
Object CameraControlPanel $Bit
Body SysBody
Attr PgmName = "ControlPanel"
Attr Text = "ControlPanel"
Attr PgmName = "CameraControlPanel"
Attr Text = "CameraControlPanel"
Attr Value = 16
EndBody
EndObject
!/**
! Add progress bar to control panel.
! Display a video control panel with Play, Pause and Stop buttons.
!*/
Object ProgressBar $Bit
Object VideoControlPanel $Bit
Body SysBody
Attr PgmName = "ProgressBar"
Attr Text = "ProgressBar"
Attr PgmName = "VideoControlPanel"
Attr Text = "VideoControlPanel"
Attr Value = 32
EndBody
EndObject
!/**
! Add progress bar to control panel.
!*/
Object VideoProgressBar $Bit
Body SysBody
Attr PgmName = "VideoProgressBar"
Attr Text = "VideoProgressBar"
Attr Value = 64
EndBody
EndObject
EndObject
EndSObject
......
......@@ -1034,6 +1034,13 @@ SObject pwrs:Class
Attr FilterName = "$Object-OpenFastFilter"
EndBody
EndObject
Object Camera $MenuButton
Body SysBody
Attr ButtonName = "Camera"
Attr MethodName = "$Object-Camera"
Attr FilterName = "$Object-CameraFilter"
EndBody
EndObject
Object HistEvent $MenuButton
Body SysBody
Attr ButtonName = "Event Log..."
......
......@@ -854,6 +854,10 @@ XttMultiViewGtk::XttMultiViewGtk( GtkWidget *mv_parent_wid, void *mv_parent_ctx,
if ( sevhist[i])
sevhist[i]->setup();
}
for ( int i = 0; i < MV_SIZE; i++) {
if ( strmctx[i])
strmctx[i]->setup();
}
if ( options & ge_mOptions_FullScreen ||
mv.Options & pwr_mMultiViewOptionsMask_FullScreen)
gtk_window_fullscreen( GTK_WINDOW(toplevel));
......
......@@ -182,8 +182,8 @@ void XttStreamGtk::refresh_ui( XttStreamGtk *strm)
GstFormat fmt = GST_FORMAT_TIME;
gint64 current = -1;
if ( !(strm->options & pwr_mVideoOptionsMask_ControlPanel &&
strm->options & pwr_mVideoOptionsMask_ProgressBar))
if ( !(strm->options & pwr_mVideoOptionsMask_VideoControlPanel &&
strm->options & pwr_mVideoOptionsMask_VideoProgressBar))
return;
/* We do not want to update anything unless we are in the PAUSED or PLAYING states */
......@@ -377,6 +377,22 @@ void XttStreamGtk::application_cb( GstBus *bus, GstMessage *msg, void *data)
}
}
void XttStreamGtk::resize_cb( GtkWidget *w, GtkAllocation *allocation, gpointer data)
{
XttStream *strm = (XttStream *)data;
strm->width = allocation->width;
strm->height = allocation->height;
if ( strm->width > strm->height * strm->stream_ratio) {
strm->x_offset = (strm->width - strm->height * strm->stream_ratio) / 2;
strm->y_offset = 0;
}
else {
strm->x_offset = 0;
strm->y_offset = (strm->height - ((float)strm->width) / strm->stream_ratio) / 2;
}
}
gboolean XttStreamGtk::mousebutton_cb( GtkWidget *widget, GdkEvent *event, void *data)
{
XttStreamGtk *strm = (XttStreamGtk *)data;
......@@ -429,7 +445,10 @@ gboolean XttStreamGtk::mousebutton_cb( GtkWidget *widget, GdkEvent *event, void
int y = event->button.y;
CoWowGtk::PopupPosition( strm->video_form, x, y, &x1, &y1);
strm->action_mb3click( x1, y1);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
break;
}
}
......@@ -449,7 +468,10 @@ gboolean XttStreamGtk::mousebutton_cb( GtkWidget *widget, GdkEvent *event, void
abs( event->button.y - strm->mb_press_y) < 10) {
printf( "Mb click %f %f\n", event->button.x - offset_x, event->button.y - offset_y);
strm->action_click( event->button.x - offset_x, event->button.y - offset_y);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
else if ( abs( event->button.x - strm->mb_press_x) > 20 &&
abs( event->button.y - strm->mb_press_y) > 20) {
......@@ -459,7 +481,10 @@ gboolean XttStreamGtk::mousebutton_cb( GtkWidget *widget, GdkEvent *event, void
int h = abs( event->button.y - strm->mb_press_y);
printf( "Mb zoom (%d,%d) rect %d,%d\n", x, y, w, h);
strm->action_areaselect( x, y, w, h);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
break;
}
......@@ -472,11 +497,6 @@ gboolean XttStreamGtk::mousebutton_cb( GtkWidget *widget, GdkEvent *event, void
}
break;
case GDK_SCROLL:
if ( event->scroll.direction == GDK_SCROLL_UP)
printf( "Scroll Up %f %f\n", event->scroll.x - offset_x, event->scroll.y - offset_y);
else if ( event->scroll.direction == GDK_SCROLL_DOWN)
printf( "Scroll Down %f %f\n", event->scroll.x - offset_x, event->scroll.y - offset_y);
strm->scroll_timerid->remove();
strm->scroll_timerid->add( 600, strm->scroll_cb, strm);
//strm->action_scroll( event->scroll.direction == GDK_SCROLL_UP ? 1 : 0,
......@@ -497,14 +517,17 @@ void XttStreamGtk::scroll_cb( void *data)
strm->action_scroll( strm->scroll_direction,
strm->scroll_x, strm->scroll_y, strm->scroll_cnt);
strm->scroll_cnt = 0;
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
XttStreamGtk::XttStreamGtk( GtkWidget *st_parent_wid, void *st_parent_ctx, const char *name, const char *st_uri,
int width, int height, int x, int y, double scan_time,
unsigned int st_options, int st_embedded, pwr_tAttrRef *st_arp, pwr_tStatus *sts) :
XttStream( st_parent_ctx, name, st_uri, width, height, x, y, scan_time, st_options, st_embedded, st_arp),
scroll_cnt(0), parent_wid(st_parent_wid)
scroll_cnt(0), ptz_box_displayed(0), parent_wid(st_parent_wid), ptz_box(0)
{
GstStateChangeReturn ret;
GstBus *bus;
......@@ -563,13 +586,14 @@ XttStreamGtk::XttStreamGtk( GtkWidget *st_parent_wid, void *st_parent_ctx, const
g_signal_connect( video_form, "button_press_event", G_CALLBACK( mousebutton_cb), this);
g_signal_connect( video_form, "button_release_event", G_CALLBACK( mousebutton_cb), this);
g_signal_connect( video_form, "scroll_event", G_CALLBACK( mousebutton_cb), this);
g_signal_connect( video_form, "size_allocate", G_CALLBACK(resize_cb), this);
gtk_widget_add_events( video_form, GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK);
// GtkWidget *controls;
GtkWidget *hbox = gtk_hbox_new( FALSE, 0);
if ( options & pwr_mVideoOptionsMask_ControlPanel) {
if ( options & pwr_mVideoOptionsMask_VideoControlPanel) {
GtkToolbar *controlbuttons;
controlbuttons = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);
......@@ -597,7 +621,7 @@ XttStreamGtk::XttStreamGtk( GtkWidget *st_parent_wid, void *st_parent_ctx, const
gtk_box_pack_start( GTK_BOX( hbox), GTK_WIDGET(controlbuttons), FALSE, FALSE, 2);
if ( options & pwr_mVideoOptionsMask_ProgressBar) {
if ( options & pwr_mVideoOptionsMask_VideoProgressBar) {
slider = gtk_hscale_new_with_range( 0, 100, 1);
gtk_scale_set_draw_value( GTK_SCALE( slider), 0);
slider_update_signal_id = g_signal_connect( G_OBJECT( slider), "value-changed", G_CALLBACK( slider_cb), this);
......@@ -605,197 +629,205 @@ XttStreamGtk::XttStreamGtk( GtkWidget *st_parent_wid, void *st_parent_ctx, const
}
}
GtkWidget *tools = gtk_toolbar_new();
tools = gtk_toolbar_new();
gtk_toolbar_set_style( GTK_TOOLBAR(tools), GTK_TOOLBAR_ICONS);
dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
GtkToolItem *tools_zoom_in = gtk_tool_button_new( gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_zoom_in, CoWowGtk::translate_utf8("Zoom in"));
g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(activate_zoomin), this);
g_object_set( tools_zoom_in, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_zoom_in, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_out.png");
GtkToolItem *tools_zoom_out = gtk_tool_button_new( gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_zoom_out, CoWowGtk::translate_utf8("Zoom out"));
g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(activate_zoomout), this);
g_object_set( tools_zoom_out, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_zoom_out, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_reset.png");
GtkToolItem *tools_zoom_reset = gtk_tool_button_new( gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_zoom_reset, CoWowGtk::translate_utf8("Zoom reset"));
g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(activate_zoomreset), this);
g_object_set( tools_zoom_reset, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_zoom_reset, -1);
gtk_toolbar_insert( GTK_TOOLBAR(tools), gtk_separator_tool_item_new(), -1);
dcli_translate_filename( fname, "$pwr_exe/ge_page_left.png");
GtkToolItem *tools_page_left = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_page_left, CoWowGtk::translate_utf8("Page left"));
g_signal_connect(tools_page_left, "clicked", G_CALLBACK(activate_page_left), this);
g_object_set( tools_page_left, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_page_left, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_scroll_left.png");
GtkToolItem *tools_scroll_left = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_scroll_left, CoWowGtk::translate_utf8("Scroll left"));
g_signal_connect(tools_scroll_left, "clicked", G_CALLBACK(activate_scroll_left), this);
g_object_set( tools_scroll_left, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_scroll_left, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_scroll_right.png");
GtkToolItem *tools_scroll_right = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_scroll_right, CoWowGtk::translate_utf8("Scroll right"));
g_signal_connect(tools_scroll_right, "clicked", G_CALLBACK(activate_scroll_right), this);
g_object_set( tools_scroll_right, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_scroll_right, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_page_right.png");
GtkToolItem *tools_page_right = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_page_right, CoWowGtk::translate_utf8("Page right"));
g_signal_connect(tools_page_right, "clicked", G_CALLBACK(activate_page_right), this);
g_object_set( tools_page_right, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_page_right, -1);
gtk_toolbar_insert( GTK_TOOLBAR(tools), gtk_separator_tool_item_new(), -1);
dcli_translate_filename( fname, "$pwr_exe/ge_page_down.png");
GtkToolItem *tools_page_down = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_page_down, CoWowGtk::translate_utf8("Page down"));
g_signal_connect(tools_page_down, "clicked", G_CALLBACK(activate_page_down), this);
g_object_set( tools_page_down, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_page_down, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_scroll_down.png");
GtkToolItem *tools_scroll_down = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_scroll_down, CoWowGtk::translate_utf8("Scroll down"));
g_signal_connect(tools_scroll_down, "clicked", G_CALLBACK(activate_scroll_down), this);
g_object_set( tools_scroll_down, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_scroll_down, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_scroll_up.png");
GtkToolItem *tools_scroll_up = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_scroll_up, CoWowGtk::translate_utf8("Scroll up"));
g_signal_connect(tools_scroll_up, "clicked", G_CALLBACK(activate_scroll_up), this);
g_object_set( tools_scroll_up, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_scroll_up, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_page_up.png");
GtkToolItem *tools_page_up = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_page_up, CoWowGtk::translate_utf8("Page up"));
g_signal_connect(tools_page_up, "clicked", G_CALLBACK(activate_page_up), this);
g_object_set( tools_page_up, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_page_up, -1);
gtk_toolbar_insert( GTK_TOOLBAR(tools), gtk_separator_tool_item_new(), -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos1.png");
GtkToolItem *tools_preset1 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset1, CoWowGtk::translate_utf8("Preset position 1"));
g_signal_connect(tools_preset1, "clicked", G_CALLBACK(activate_preset_position1), this);
g_object_set( tools_preset1, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset1, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos2.png");
GtkToolItem *tools_preset2 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset2, CoWowGtk::translate_utf8("Preset position 2"));
g_signal_connect(tools_preset2, "clicked", G_CALLBACK(activate_preset_position2), this);
g_object_set( tools_preset2, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset2, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos3.png");
GtkToolItem *tools_preset3 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset3, CoWowGtk::translate_utf8("Preset position 3"));
g_signal_connect(tools_preset3, "clicked", G_CALLBACK(activate_preset_position3), this);
g_object_set( tools_preset3, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset3, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos4.png");
GtkToolItem *tools_preset4 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset4, CoWowGtk::translate_utf8("Preset position 4"));
g_signal_connect(tools_preset4, "clicked", G_CALLBACK(activate_preset_position4), this);
g_object_set( tools_preset4, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset4, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos5.png");
GtkToolItem *tools_preset5 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset5, CoWowGtk::translate_utf8("Preset position 5"));
g_signal_connect(tools_preset5, "clicked", G_CALLBACK(activate_preset_position5), this);
g_object_set( tools_preset5, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset5, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos6.png");
GtkToolItem *tools_preset6 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset6, CoWowGtk::translate_utf8("Preset position 6"));
g_signal_connect(tools_preset6, "clicked", G_CALLBACK(activate_preset_position6), this);
g_object_set( tools_preset6, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset6, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos7.png");
GtkToolItem *tools_preset7 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset7, CoWowGtk::translate_utf8("Preset position 7"));
g_signal_connect(tools_preset7, "clicked", G_CALLBACK(activate_preset_position7), this);
g_object_set( tools_preset7, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset7, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos8.png");
GtkToolItem *tools_preset8 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset8, CoWowGtk::translate_utf8("Preset position 8"));
g_signal_connect(tools_preset8, "clicked", G_CALLBACK(activate_preset_position8), this);
g_object_set( tools_preset8, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset8, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos9.png");
GtkToolItem *tools_preset9 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset9, CoWowGtk::translate_utf8("Preset position 9"));
g_signal_connect(tools_preset9, "clicked", G_CALLBACK(activate_preset_position9), this);
g_object_set( tools_preset9, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset9, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos10.png");
GtkToolItem *tools_preset10 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset10, CoWowGtk::translate_utf8("Preset position 10"));
g_signal_connect(tools_preset10, "clicked", G_CALLBACK(activate_preset_position10), this);
g_object_set( tools_preset10, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset10, -1);
gtk_toolbar_insert( GTK_TOOLBAR(tools), gtk_separator_tool_item_new(), -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_get_pos.png");
GtkToolItem *tools_get_position = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_get_position, CoWowGtk::translate_utf8("Get position"));
g_signal_connect(tools_get_position, "clicked", G_CALLBACK(activate_get_position), this);
g_object_set( tools_get_position, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_get_position, -1);
GtkWidget *ptz_pan_label = gtk_label_new("Pan");
ptz_pan = gtk_label_new("0");
GtkWidget *ptz_tilt_label = gtk_label_new("Tilt");
ptz_tilt = gtk_label_new("0");
GtkWidget *ptz_zoom_label = gtk_label_new("Zoom");
ptz_zoom = gtk_label_new("0");
ptz_box = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_pan_label), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_pan), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(gtk_vseparator_new()), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_tilt_label), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_tilt), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(gtk_vseparator_new()), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_zoom_label), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_zoom), FALSE, FALSE, 5);
GtkWidget *tools_box = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX( tools_box), GTK_WIDGET(tools), TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX( tools_box), ptz_box, FALSE, FALSE, 0);
if ( control_protocol != pwr_eCameraControlEnum_No) {
dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
GtkToolItem *tools_zoom_in = gtk_tool_button_new( gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_zoom_in, CoWowGtk::translate_utf8("Zoom in"));
g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(activate_zoomin), this);
// g_object_set( tools_zoom_in, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_zoom_in, -1);
GTK_WIDGET_UNSET_FLAGS( tools_zoom_in, GTK_CAN_FOCUS);
dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_out.png");
GtkToolItem *tools_zoom_out = gtk_tool_button_new( gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_zoom_out, CoWowGtk::translate_utf8("Zoom out"));
g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(activate_zoomout), this);
g_object_set( tools_zoom_out, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_zoom_out, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_reset.png");
GtkToolItem *tools_zoom_reset = gtk_tool_button_new( gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_zoom_reset, CoWowGtk::translate_utf8("Zoom reset"));
g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(activate_zoomreset), this);
g_object_set( tools_zoom_reset, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_zoom_reset, -1);
gtk_toolbar_insert( GTK_TOOLBAR(tools), gtk_separator_tool_item_new(), -1);
dcli_translate_filename( fname, "$pwr_exe/ge_page_left.png");
GtkToolItem *tools_page_left = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_page_left, CoWowGtk::translate_utf8("Page left"));
g_signal_connect(tools_page_left, "clicked", G_CALLBACK(activate_page_left), this);
g_object_set( tools_page_left, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_page_left, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_scroll_left.png");
GtkToolItem *tools_scroll_left = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_scroll_left, CoWowGtk::translate_utf8("Scroll left"));
g_signal_connect(tools_scroll_left, "clicked", G_CALLBACK(activate_scroll_left), this);
g_object_set( tools_scroll_left, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_scroll_left, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_scroll_right.png");
GtkToolItem *tools_scroll_right = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_scroll_right, CoWowGtk::translate_utf8("Scroll right"));
g_signal_connect(tools_scroll_right, "clicked", G_CALLBACK(activate_scroll_right), this);
g_object_set( tools_scroll_right, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_scroll_right, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_page_right.png");
GtkToolItem *tools_page_right = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_page_right, CoWowGtk::translate_utf8("Page right"));
g_signal_connect(tools_page_right, "clicked", G_CALLBACK(activate_page_right), this);
g_object_set( tools_page_right, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_page_right, -1);
gtk_toolbar_insert( GTK_TOOLBAR(tools), gtk_separator_tool_item_new(), -1);
dcli_translate_filename( fname, "$pwr_exe/ge_page_down.png");
GtkToolItem *tools_page_down = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_page_down, CoWowGtk::translate_utf8("Page down"));
g_signal_connect(tools_page_down, "clicked", G_CALLBACK(activate_page_down), this);
g_object_set( tools_page_down, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_page_down, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_scroll_down.png");
GtkToolItem *tools_scroll_down = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_scroll_down, CoWowGtk::translate_utf8("Scroll down"));
g_signal_connect(tools_scroll_down, "clicked", G_CALLBACK(activate_scroll_down), this);
g_object_set( tools_scroll_down, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_scroll_down, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_scroll_up.png");
GtkToolItem *tools_scroll_up = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_scroll_up, CoWowGtk::translate_utf8("Scroll up"));
g_signal_connect(tools_scroll_up, "clicked", G_CALLBACK(activate_scroll_up), this);
g_object_set( tools_scroll_up, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_scroll_up, -1);
dcli_translate_filename( fname, "$pwr_exe/ge_page_up.png");
GtkToolItem *tools_page_up = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_page_up, CoWowGtk::translate_utf8("Page up"));
g_signal_connect(tools_page_up, "clicked", G_CALLBACK(activate_page_up), this);
g_object_set( tools_page_up, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_page_up, -1);
gtk_toolbar_insert( GTK_TOOLBAR(tools), gtk_separator_tool_item_new(), -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos1.png");
GtkToolItem *tools_preset1 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset1, CoWowGtk::translate_utf8("Preset position 1"));
g_signal_connect(tools_preset1, "clicked", G_CALLBACK(activate_preset_position1), this);
g_object_set( tools_preset1, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset1, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos2.png");
GtkToolItem *tools_preset2 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset2, CoWowGtk::translate_utf8("Preset position 2"));
g_signal_connect(tools_preset2, "clicked", G_CALLBACK(activate_preset_position2), this);
g_object_set( tools_preset2, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset2, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos3.png");
GtkToolItem *tools_preset3 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset3, CoWowGtk::translate_utf8("Preset position 3"));
g_signal_connect(tools_preset3, "clicked", G_CALLBACK(activate_preset_position3), this);
g_object_set( tools_preset3, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset3, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos4.png");
GtkToolItem *tools_preset4 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset4, CoWowGtk::translate_utf8("Preset position 4"));
g_signal_connect(tools_preset4, "clicked", G_CALLBACK(activate_preset_position4), this);
g_object_set( tools_preset4, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset4, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos5.png");
GtkToolItem *tools_preset5 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset5, CoWowGtk::translate_utf8("Preset position 5"));
g_signal_connect(tools_preset5, "clicked", G_CALLBACK(activate_preset_position5), this);
g_object_set( tools_preset5, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset5, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos6.png");
GtkToolItem *tools_preset6 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset6, CoWowGtk::translate_utf8("Preset position 6"));
g_signal_connect(tools_preset6, "clicked", G_CALLBACK(activate_preset_position6), this);
g_object_set( tools_preset6, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset6, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos7.png");
GtkToolItem *tools_preset7 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset7, CoWowGtk::translate_utf8("Preset position 7"));
g_signal_connect(tools_preset7, "clicked", G_CALLBACK(activate_preset_position7), this);
g_object_set( tools_preset7, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset7, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos8.png");
GtkToolItem *tools_preset8 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset8, CoWowGtk::translate_utf8("Preset position 8"));
g_signal_connect(tools_preset8, "clicked", G_CALLBACK(activate_preset_position8), this);
g_object_set( tools_preset8, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset8, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos9.png");
GtkToolItem *tools_preset9 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset9, CoWowGtk::translate_utf8("Preset position 9"));
g_signal_connect(tools_preset9, "clicked", G_CALLBACK(activate_preset_position9), this);
g_object_set( tools_preset9, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset9, -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_pos10.png");
GtkToolItem *tools_preset10 = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_preset10, CoWowGtk::translate_utf8("Preset position 10"));
g_signal_connect(tools_preset10, "clicked", G_CALLBACK(activate_preset_position10), this);
g_object_set( tools_preset10, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_preset10, -1);
gtk_toolbar_insert( GTK_TOOLBAR(tools), gtk_separator_tool_item_new(), -1);
dcli_translate_filename( fname, "$pwr_exe/xtt_get_pos.png");
GtkToolItem *tools_get_position = gtk_tool_button_new(gtk_image_new_from_file( fname), NULL);
gtk_tool_item_set_tooltip_text( tools_get_position, CoWowGtk::translate_utf8("Get position"));
g_signal_connect(tools_get_position, "clicked", G_CALLBACK(activate_get_position), this);
g_object_set( tools_get_position, "can-focus", FALSE, NULL);
gtk_toolbar_insert( GTK_TOOLBAR(tools), tools_get_position, -1);
GtkWidget *ptz_pan_label = gtk_label_new("Pan");
ptz_pan = gtk_label_new("0");
GtkWidget *ptz_tilt_label = gtk_label_new("Tilt");
ptz_tilt = gtk_label_new("0");
GtkWidget *ptz_zoom_label = gtk_label_new("Zoom");
ptz_zoom = gtk_label_new("0");
ptz_box = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_pan_label), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_pan), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(gtk_vseparator_new()), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_tilt_label), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_tilt), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(gtk_vseparator_new()), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_zoom_label), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( ptz_box), GTK_WIDGET(ptz_zoom), FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX( tools_box), GTK_WIDGET(tools), TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX( tools_box), ptz_box, FALSE, FALSE, 0);
}
else {
// Empty toolbar
gtk_widget_set_size_request( tools, -1, 32);
gtk_box_pack_start( GTK_BOX( tools_box), GTK_WIDGET(tools), TRUE, TRUE, 0);
}
main_box = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX( main_box), GTK_WIDGET(tools_box), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX( main_box), video_form, TRUE, TRUE, 0);
if ( options & pwr_mVideoOptionsMask_ControlPanel)
if ( options & pwr_mVideoOptionsMask_VideoControlPanel)
gtk_box_pack_start( GTK_BOX( main_box), GTK_WIDGET(hbox), FALSE, FALSE, 0);
......@@ -805,7 +837,10 @@ XttStreamGtk::XttStreamGtk( GtkWidget *st_parent_wid, void *st_parent_ctx, const
gtk_widget_show_all( toplevel);
g_object_set( ptz_box, "visible", FALSE, NULL);
if ( ptz_box)
g_object_set( ptz_box, "visible", FALSE, NULL);
if ( !(options & pwr_mVideoOptionsMask_CameraControlPanel))
g_object_set( tools, "visible", FALSE, NULL);
if ( options & pwr_mVideoOptionsMask_FullScreen)
gtk_window_fullscreen( GTK_WINDOW(toplevel));
......@@ -818,6 +853,10 @@ XttStreamGtk::XttStreamGtk( GtkWidget *st_parent_wid, void *st_parent_ctx, const
}
else {
gtk_widget_set_size_request( main_box, width, height);
if ( ptz_box)
g_object_set( ptz_box, "visible", FALSE, NULL);
if ( (options & pwr_mVideoOptionsMask_CameraControlPanel) == 0)
g_object_set( tools, "visible", FALSE, NULL);
}
/* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
......@@ -870,6 +909,14 @@ void XttStreamGtk::set_size( int width, int height)
gtk_window_resize( GTK_WINDOW(toplevel), width, height);
}
void XttStreamGtk::setup()
{
if ( ptz_box)
g_object_set( ptz_box, "visible", FALSE, NULL);
if ( !(options & pwr_mVideoOptionsMask_CameraControlPanel))
g_object_set( tools, "visible", FALSE, NULL);
}
void XttStreamGtk::create_popup_menu( int x, int y)
{
GtkMenu *menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
......@@ -981,7 +1028,10 @@ void XttStreamGtk::activate_zoomreset( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->zoom_absolute( 0);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_zoomin( GtkWidget *w, gpointer data)
......@@ -989,7 +1039,10 @@ void XttStreamGtk::activate_zoomin( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->zoom_relative( 5);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_zoomout( GtkWidget *w, gpointer data)
......@@ -997,7 +1050,10 @@ void XttStreamGtk::activate_zoomout( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->zoom_relative( -5);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_scroll_left( GtkWidget *w, gpointer data)
......@@ -1005,7 +1061,10 @@ void XttStreamGtk::activate_scroll_left( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->pan_relative( -3);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_scroll_right( GtkWidget *w, gpointer data)
......@@ -1013,7 +1072,10 @@ void XttStreamGtk::activate_scroll_right( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->pan_relative( 3);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_page_left( GtkWidget *w, gpointer data)
......@@ -1021,7 +1083,10 @@ void XttStreamGtk::activate_page_left( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->pan_relative( -15);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_page_right( GtkWidget *w, gpointer data)
......@@ -1029,7 +1094,10 @@ void XttStreamGtk::activate_page_right( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->pan_relative( 15);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_scroll_down( GtkWidget *w, gpointer data)
......@@ -1037,7 +1105,10 @@ void XttStreamGtk::activate_scroll_down( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->tilt_relative( -3);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_scroll_up( GtkWidget *w, gpointer data)
......@@ -1045,7 +1116,10 @@ void XttStreamGtk::activate_scroll_up( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->tilt_relative( 3);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_page_down( GtkWidget *w, gpointer data)
......@@ -1053,7 +1127,10 @@ void XttStreamGtk::activate_page_down( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->tilt_relative( -15);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_page_up( GtkWidget *w, gpointer data)
......@@ -1061,7 +1138,10 @@ void XttStreamGtk::activate_page_up( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->camera_control->tilt_relative( 15);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position1( GtkWidget *w, gpointer data)
......@@ -1069,7 +1149,10 @@ void XttStreamGtk::activate_preset_position1( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(0);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position2( GtkWidget *w, gpointer data)
......@@ -1077,7 +1160,10 @@ void XttStreamGtk::activate_preset_position2( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(1);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position3( GtkWidget *w, gpointer data)
......@@ -1085,7 +1171,10 @@ void XttStreamGtk::activate_preset_position3( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(2);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position4( GtkWidget *w, gpointer data)
......@@ -1093,7 +1182,10 @@ void XttStreamGtk::activate_preset_position4( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(3);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position5( GtkWidget *w, gpointer data)
......@@ -1101,7 +1193,10 @@ void XttStreamGtk::activate_preset_position5( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(4);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position6( GtkWidget *w, gpointer data)
......@@ -1109,7 +1204,10 @@ void XttStreamGtk::activate_preset_position6( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(5);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position7( GtkWidget *w, gpointer data)
......@@ -1117,7 +1215,10 @@ void XttStreamGtk::activate_preset_position7( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(6);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position8( GtkWidget *w, gpointer data)
......@@ -1125,7 +1226,10 @@ void XttStreamGtk::activate_preset_position8( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(7);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position9( GtkWidget *w, gpointer data)
......@@ -1133,7 +1237,10 @@ void XttStreamGtk::activate_preset_position9( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(8);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_position10( GtkWidget *w, gpointer data)
......@@ -1141,7 +1248,10 @@ void XttStreamGtk::activate_preset_position10( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_position(9);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos1( GtkWidget *w, gpointer data)
......@@ -1149,7 +1259,10 @@ void XttStreamGtk::activate_preset_store_pos1( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(0);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos2( GtkWidget *w, gpointer data)
......@@ -1157,7 +1270,10 @@ void XttStreamGtk::activate_preset_store_pos2( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(1);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos3( GtkWidget *w, gpointer data)
......@@ -1165,7 +1281,10 @@ void XttStreamGtk::activate_preset_store_pos3( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(2);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos4( GtkWidget *w, gpointer data)
......@@ -1173,7 +1292,10 @@ void XttStreamGtk::activate_preset_store_pos4( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(3);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos5( GtkWidget *w, gpointer data)
......@@ -1181,7 +1303,10 @@ void XttStreamGtk::activate_preset_store_pos5( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(4);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos6( GtkWidget *w, gpointer data)
......@@ -1189,7 +1314,10 @@ void XttStreamGtk::activate_preset_store_pos6( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(5);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos7( GtkWidget *w, gpointer data)
......@@ -1197,7 +1325,10 @@ void XttStreamGtk::activate_preset_store_pos7( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(6);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos8( GtkWidget *w, gpointer data)
......@@ -1205,7 +1336,10 @@ void XttStreamGtk::activate_preset_store_pos8( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(7);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos9( GtkWidget *w, gpointer data)
......@@ -1213,7 +1347,10 @@ void XttStreamGtk::activate_preset_store_pos9( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(8);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_preset_store_pos10( GtkWidget *w, gpointer data)
......@@ -1221,7 +1358,10 @@ void XttStreamGtk::activate_preset_store_pos10( GtkWidget *w, gpointer data)
XttStreamGtk *strm = (XttStreamGtk *)data;
strm->activate_preset_store_pos(9);
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
if ( strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", FALSE, NULL);
strm->ptz_box_displayed = 0;
}
}
void XttStreamGtk::activate_get_position( GtkWidget *w, gpointer data)
......@@ -1240,9 +1380,11 @@ void XttStreamGtk::activate_get_position( GtkWidget *w, gpointer data)
gtk_label_set_text( GTK_LABEL(strm->ptz_pan), pan_str);
gtk_label_set_text( GTK_LABEL(strm->ptz_tilt), tilt_str);
gtk_label_set_text( GTK_LABEL(strm->ptz_zoom), zoom_str);
printf( "Pan %f Tilt %f Zoom %f\n", pan, tilt, zoom);
g_object_set( strm->ptz_box, "visible", TRUE, NULL);
if ( !strm->ptz_box_displayed) {
g_object_set( strm->ptz_box, "visible", TRUE, NULL);
strm->ptz_box_displayed = 1;
}
}
#if 0
......
......@@ -65,6 +65,7 @@ class XttStreamGtk : public XttStream {
int scroll_cnt;
int popupmenu_x;
int popupmenu_y;
int ptz_box_displayed;
GtkWidget *slider; /* Slider widget to keep track of current position */
GtkWidget *parent_wid;
......@@ -75,6 +76,7 @@ class XttStreamGtk : public XttStream {
GtkWidget *ptz_pan;
GtkWidget *ptz_tilt;
GtkWidget *ptz_zoom;
GtkWidget *tools;
void *overlay;
......@@ -87,6 +89,7 @@ class XttStreamGtk : public XttStream {
void pop();
void set_size( int width, int height);
void setup();
void *get_widget() { return main_box;}
void create_popup_menu( int x, int y);
......@@ -108,6 +111,7 @@ class XttStreamGtk : public XttStream {
static void eos_cb( GstBus *bus, GstMessage *msg, void *data);
static void state_changed_cb( GstBus *bus, GstMessage *msg, void *data);
static void application_cb( GstBus *bus, GstMessage *msg, void *data);
static void resize_cb( GtkWidget *w, GtkAllocation *allocation, gpointer data);
static gboolean mousebutton_cb( GtkWidget *widget, GdkEvent *event, void *data);
static void menu_position_func( GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
gpointer data);
......
......@@ -474,6 +474,149 @@ static pwr_tStatus OpenTrendFilter( xmenu_sMenuCall *ip)
return XNAV__INVISIBLE;
}
//
// Camera
//
static pwr_tStatus Camera( xmenu_sMenuCall *ip)
{
pwr_tAName name;
char cmd[800];
int sts;
pwr_tObjid child;
pwr_tClassId classid;
int found;
pwr_sAttrRef defcamera;
pwr_sAttrRef *objar;
if (!ip->ItemList || cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid))
objar = &ip->Pointed;
else
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_CameraPosition) {
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
// Open video
sprintf( cmd, "open video /cameraposition=%s", name);
((XNav *)ip->EditorContext)->command( cmd);
return 1;
}
// Look for attribute Camera
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
strcat( name, ".DefCamera");
sts = gdh_GetObjectInfo( name, (void *)&defcamera, sizeof(defcamera));
if ( ODD(sts) && cdh_ObjidIsNotNull( defcamera.Objid)) {
// Default camera found
sts = gdh_GetAttrRefTid( &defcamera, &classid);
if ( ODD(sts) && classid == pwr_cClass_CameraPosition) {
sts = gdh_AttrrefToName( &defcamera, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
// Open video
sprintf( cmd, "open video /cameraposition=%s", name);
((XNav *)ip->EditorContext)->command( cmd);
return 1;
}
}
// Look for camera as child
if ( !ip->Pointed.Flags.b.Object)
return 0;
found = 0;
sts = gdh_GetChild( objar->Objid, &child);
while ( ODD(sts)) {
sts = gdh_GetObjectClass( child, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_CameraPosition) {
found = 1;
break;
}
sts = gdh_GetNextSibling( child, &child);
}
if ( !found)
return 1;
sts = gdh_ObjidToName( child, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
// Open video
sprintf( cmd, "open video /cameraposition=%s", name);
((XNav *)ip->EditorContext)->command( cmd);
return 1;
}
// Camera filter
static pwr_tStatus CameraFilter( xmenu_sMenuCall *ip)
{
int sts;
pwr_tObjid child;
pwr_tClassId classid, cid;
pwr_sAttrRef defcamera;
pwr_tAName name;
pwr_sAttrRef *objar;
if (!ip->ItemList || cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid))
objar = &ip->Pointed;
else
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( objar, &cid);
if ( EVEN(sts)) return sts;
switch ( cid) {
case pwr_cClass_CameraPosition:
return XNAV__SUCCESS;
}
// Check if attribute DefCamera exist
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
strcat( name, ".DefCamera");
sts = gdh_GetObjectInfo( name, (void *)&defcamera, sizeof(defcamera));
if ( ODD(sts) && cdh_ObjidIsNotNull( defcamera.Objid)) {
// Default Camera found
sts = gdh_GetAttrRefTid( &defcamera, &classid);
if ( ODD(sts) && classid == pwr_cClass_CameraPosition)
return XNAV__SUCCESS;
}
// Check if object has a CameraPosition as child
if ( cid == pwr_eClass_PlantHier)
return XNAV__INVISIBLE;
if ( !objar->Flags.b.Object)
return XNAV__INVISIBLE;
sts = gdh_GetChild( objar->Objid, &child);
while ( ODD(sts)) {
sts = gdh_GetObjectClass( child, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_CameraPosition)
return XNAV__SUCCESS;
sts = gdh_GetNextSibling( child, &child);
}
return XNAV__INVISIBLE;
}
//
// Open History
//
......@@ -2102,6 +2245,8 @@ pwr_dExport pwr_BindXttMethods($Object) = {
pwr_BindXttMethod(OpenTraceFilter),
pwr_BindXttMethod(OpenTrend),
pwr_BindXttMethod(OpenTrendFilter),
pwr_BindXttMethod(Camera),
pwr_BindXttMethod(CameraFilter),
pwr_BindXttMethod(OpenHistory),
pwr_BindXttMethod(OpenHistoryFilter),
pwr_BindXttMethod(OpenFast),
......
......@@ -61,121 +61,150 @@
#include "xtt_xnav.h"
#include "xtt_stream.h"
void XttStream::action_click( int x, int y)
static char outstr[20];
static int debug = 0;
XttStream::XttStream( void *st_parent_ctx, const char *name, const char *st_uri,
int st_width, int st_height, int x, int y,
double st_scan_time, unsigned int st_options, int st_embedded,
pwr_tAttrRef *st_arp) :
parent_ctx(st_parent_ctx), options(st_options), embedded(st_embedded), timerid(0), scroll_timerid(0),
x_offset(0), y_offset(0), width(st_width), height(st_height), stream_width(0), stream_height(0),
close_cb(0), camera_control(0), control_protocol(pwr_eCameraControlEnum_No)
{
pwr_tCmd cmd;
pwr_tURL node;
char *s;
pwr_tStatus sts;
strncpy( node, uri, sizeof(node));
s = strchr( node, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
*s = 0;
if ( debug)
strcpy( outstr, "");
x = 700. / width * x;
y = 580. / height * y;
strncpy( uri, st_uri, sizeof(uri));
if ( st_scan_time < 0.02)
scan_time = 1000;
else
scan_time = 1000 * st_scan_time;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&center=%d,%d",
node, x, y);
system( cmd);
if ( st_arp)
aref = *st_arp;
else
memset( &aref, 0, sizeof(aref));
if ( st_arp) {
pwr_tAttrRef aaref;
sts = gdh_ArefANameToAref( &aref, "StreamWidth", &aaref);
if ( ODD(sts))
sts = gdh_GetObjectInfoAttrref( &aaref, &stream_width, sizeof(stream_width));
if ( EVEN(sts))
stream_width = 0;
sts = gdh_ArefANameToAref( &aref, "StreamHeight", &aaref);
if ( ODD(sts))
sts = gdh_GetObjectInfoAttrref( &aaref, &stream_height, sizeof(stream_height));
if ( EVEN(sts))
stream_height = 0;
sts = gdh_ArefANameToAref( &aref, "Control", &aaref);
if ( ODD(sts))
sts = gdh_GetObjectInfoAttrref( &aaref, &control_protocol, sizeof(control_protocol));
if ( EVEN(sts))
control_protocol = pwr_eCameraControlEnum_No;
switch ( control_protocol) {
case pwr_eCameraControlEnum_VAPIX:
camera_control = new XttCameraControlVapix(uri);
if ( debug)
strcpy( outstr, "");
else
strcpy( outstr, "-o /dev/null");
break;
case pwr_eCameraControlEnum_ONVIF:
// Not yet implemented...
break;
default: ;
}
}
if ( stream_width == 0 || stream_height == 0) {
stream_width = 700;
stream_width = 580;
}
stream_ratio = ((float)stream_width)/stream_height;
if ( width > height * stream_ratio) {
x_offset = (width - height * stream_ratio) / 2;
y_offset = 0;
}
else {
x_offset = 0;
y_offset = (height - ((float)width) / stream_ratio) / 2;
}
}
void XttStream::action_areaselect( int x, int y, int w, int h)
void XttStream::position( double pan, double tilt, double zoom)
{
pwr_tCmd cmd;
pwr_tURL node;
char *s;
int zoom;
float fzoom;
strncpy( node, uri, sizeof(node));
s = strchr( node, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
*s = 0;
if ( !camera_control)
return;
x += w/2;
y += h/2;
camera_control->pan_tilt_zoom_absolute( pan, tilt, zoom);
}
x = 700. / width * x;
y = 580. / height * y;
if ( w == 0 || h == 0)
void XttStream::action_click( int x, int y)
{
if ( !camera_control)
return;
fzoom = min( (float)width/w, (float)height/h);
zoom = 100 * fzoom;
if ( zoom > 9999)
zoom = 9999;
camera_control->center( x - x_offset, y - y_offset, width - 2 * x_offset, height - 2 * y_offset, stream_width, stream_height);
}
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&areazoom=%d,%d,%d",
node, x, y, zoom);
system( cmd);
void XttStream::action_areaselect( int x, int y, int w, int h)
{
if ( !camera_control)
return;
camera_control->area_zoom( x - x_offset, y - y_offset, w, h, width - 2 * x_offset, height - 2 * y_offset,
stream_width, stream_height);
}
void XttStream::action_scroll( int direction, int x, int y, int cnt)
{
pwr_tCmd cmd;
pwr_tURL node;
char *s;
int zoom;
if ( !camera_control)
return;
double zoom;
if ( direction)
zoom = cnt * 150;
zoom = - cnt * 4;
else
zoom = - cnt * 150;
strncpy( node, uri, sizeof(node));
s = strchr( node, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
*s = 0;
x = 700. / width * x;
y = 580. / height * y;
zoom = cnt * 4;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rzoom=%d",
node, zoom);
system( cmd);
camera_control->zoom_relative( zoom);
}
void XttStream::action_mb2click( int x, int y)
{
pwr_tCmd cmd;
pwr_tURL node;
char *s;
int zoom = 1;
if ( !camera_control)
return;
strncpy( node, uri, sizeof(node));
s = strchr( node, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
*s = 0;
double zoom = 1;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&zoom=%d",
node, zoom);
system( cmd);
camera_control->zoom_absolute( zoom);
}
void XttStream::action_mb3click( int x, int y)
{
if ( !camera_control)
return;
create_popup_menu( x, y);
}
void XttStream::activate_preset_position( int idx)
{
if ( !camera_control)
return;
if ( cdh_ObjidIsNull( aref.Objid))
return;
......@@ -188,7 +217,7 @@ void XttStream::activate_preset_position( int idx)
sts = gdh_ArefANameToAref( &aref, aname, &aaref);
if ( EVEN(sts)) return;
pwr_sClass_CameraPosition pos;
pwr_sClass_CameraPtz pos;
sts = gdh_GetObjectInfoAttrref( &aaref, &pos, sizeof(pos));
if ( EVEN(sts)) return;
......@@ -197,6 +226,9 @@ void XttStream::activate_preset_position( int idx)
void XttStream::activate_preset_store_pos( int idx)
{
if ( !camera_control)
return;
if ( cdh_ObjidIsNull( aref.Objid))
return;
......@@ -212,7 +244,7 @@ void XttStream::activate_preset_store_pos( int idx)
camera_control->get_position( &pan, &tilt, &zoom);
pwr_sClass_CameraPosition pos;
pwr_sClass_CameraPtz pos;
pos.Pan = pan;
pos.Tilt = tilt;
pos.Zoom = zoom;
......@@ -244,9 +276,13 @@ void XttCameraControlVapix::zoom_relative( double factor)
if ( zoom < -9999)
zoom = -9999;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rzoom=%d",
url, zoom);
system( cmd);
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&rzoom=%d",
outstr, url, zoom);
int sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
}
// Absolute zoom, 0 - 100, 0 is max out, 100 is max in.
......@@ -259,9 +295,11 @@ void XttCameraControlVapix::zoom_absolute( double factor)
if ( zoom > 9999)
zoom = 9999;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&zoom=%d",
url, zoom);
system( cmd);
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&zoom=%d",
outstr, url, zoom);
int sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
}
// Relative pan, value is -100 - 100.
......@@ -274,9 +312,11 @@ void XttCameraControlVapix::pan_relative( double value)
if ( pan < -360)
pan = -360;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rpan=%d",
url, pan);
system( cmd);
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&rpan=%d",
outstr, url, pan);
int sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
}
// Absolute pan, value is 0 - 100.
......@@ -290,9 +330,11 @@ void XttCameraControlVapix::pan_absolute( double value)
pan = -180;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rpan=%d",
url, pan);
system( cmd);
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&rpan=%d",
outstr, url, pan);
int sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
}
// Relative tilt, value is -100 - 100.
......@@ -305,9 +347,11 @@ void XttCameraControlVapix::tilt_relative( double value)
if ( tilt < -360)
tilt = -360;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rtilt=%d",
url, tilt);
system( cmd);
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&rtilt=%d",
outstr, url, tilt);
int sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
}
// Absolute tilt, value is 0 - 100.
......@@ -321,36 +365,90 @@ void XttCameraControlVapix::tilt_absolute( double value)
tilt = -180;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rtilt=%d",
url, tilt);
system( cmd);
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&rtilt=%d",
outstr, url, tilt);
int sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
}
// Absolute pan, tilt and zoom.
void XttCameraControlVapix::pan_tilt_zoom_absolute( double pan, double tilt, double zoom)
{
pwr_tCmd cmd;
int ipan = (int)(pan / 100 * 360 - 180);
double ipan = pan / 100 * 360 - 180;
if ( ipan > 180)
ipan = 180;
if ( ipan < -180)
ipan = -180;
int itilt = (int)(tilt / 100 * 360 - 180);
double itilt = tilt / 100 * 360 - 180;
if ( itilt > 180)
itilt = 180;
if ( itilt < -180)
itilt = -180;
int izoom = (int)(zoom * 100);
int izoom = int(zoom * 100);
if ( izoom < 1)
zoom = 1;
if ( izoom > 9999)
izoom = 9999;
if ( izoom > 19999)
izoom = 19999;
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&pan=%.2f\\&tilt=%.2f\\&zoom=%d",
outstr, url, ipan, itilt, izoom);
int sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
}
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&pan=%d\\&tilt=%d\\&zoom=%d",
url, ipan, itilt, izoom);
system( cmd);
// Center coordinates. Coordinates in current camera window size.
void XttCameraControlVapix::center( int x, int y, int width, int height,
int stream_width, int stream_height)
{
pwr_tCmd cmd;
if ( stream_width == 0 || stream_height == 0) {
stream_width = 700;
stream_height = 580;
}
x = ((float)stream_width) / width * x;
y = ((float)stream_height) / height * y;
// sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&center=%d,%d\\&imagewidth=%d",
// outstr, url, x, y, width);
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&center=%d,%d",
outstr, url, x, y);
int sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
}
void XttCameraControlVapix::area_zoom( int x, int y, int width, int height, int window_width,
int window_height, int stream_width, int stream_height)
{
pwr_tCmd cmd;
int zoom;
float fzoom;
x += width/2;
y += height/2;
x = ((float)stream_width) / window_width * x;
y = ((float)stream_height) / window_height * y;
if ( width == 0 || height == 0)
return;
fzoom = min( (float)window_width/width, (float)window_height/height);
zoom = 100 * fzoom;
if ( zoom > 9999)
zoom = 9999;
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&areazoom=%d,%d,%d",
outstr, url, x, y, zoom);
int sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
}
// Get current pan, tilt and zoom.
......@@ -374,9 +472,11 @@ int XttCameraControlVapix::get_position( double *pan, double *tilt, double *zoom
if ( ODD(sts))
old_file_found = 1;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&query=position --output-document=%s",
url, fname);
system( cmd);
sprintf( cmd, "wget --ignore-length %s %s/axis-cgi/com/ptz.cgi?camera=1\\&query=position --output-document=%s",
outstr, url, fname);
sts = system( cmd);
if ( sts != 0)
printf( "** Error from wget: %d\n", sts >> 8);
new_file_found = 0;
sts = dcli_file_time( fname, &time);
......
......@@ -56,6 +56,9 @@ class XttCameraControl {
virtual void tilt_relative( double value) {}
virtual void tilt_absolute( double value) {}
virtual void pan_tilt_zoom_absolute( double pan, double tilt, double zoom) {}
virtual void center( int x, int y, int width, int height, int stream_width, int stream_height) {}
virtual void area_zoom( int x, int y, int width, int height, int window_width,
int window_height, int stream_width, int stream_height) {}
virtual int get_position( double *pan, double *tilt, double *zoom) { return 0;}
};
......@@ -70,6 +73,9 @@ class XttCameraControlVapix : public XttCameraControl {
void tilt_relative( double value);
void tilt_absolute( double value);
void pan_tilt_zoom_absolute( double pan, double tilt, double zoom);
void center( int x, int y, int width, int height, int stream_width, int stream_height);
void area_zoom( int x, int y, int width, int height, int window_width,
int window_height, int stream_width, int stream_height);
int get_position( double *pan, double *tilt, double *zoom);
};
......@@ -83,32 +89,26 @@ class XttStream {
CoWowTimer *scroll_timerid;
CoWow *wow;
int scan_time;
int x_offset;
int y_offset;
int width;
int height;
int stream_width;
int stream_height;
double stream_ratio;
void (*close_cb)( void *, XttStream *);
XttCameraControl *camera_control;
pwr_tAttrRef aref;
pwr_tEnum control_protocol;
pwr_tAttrRef aref;
XttStream( void *st_parent_ctx, const char *name, const char *st_uri,
int st_width, int st_height, int x, int y,
double st_scan_time, unsigned int st_options, int st_embedded, pwr_tAttrRef *st_arp) :
parent_ctx(st_parent_ctx), options(st_options), embedded(st_embedded), timerid(0), scroll_timerid(0),
width(st_width), height(st_height), close_cb(0) {
strncpy( uri, st_uri, sizeof(uri));
if ( st_scan_time < 0.02)
scan_time = 1000;
else
scan_time = 1000 * st_scan_time;
camera_control = new XttCameraControlVapix(uri);
if ( st_arp)
aref = *st_arp;
else
memset( &aref, 0, sizeof(aref));
}
double st_scan_time, unsigned int st_options, int st_embedded, pwr_tAttrRef *st_arp);
virtual ~XttStream() {
delete camera_control;
}
void position( double pan, double tilt, double zoom);
void action_click( int x, int y);
void action_mb2click( int x, int y);
void action_mb3click( int x, int y);
......@@ -119,6 +119,7 @@ class XttStream {
virtual void pop() {}
virtual void set_size( int width, int height) {}
virtual void setup() {}
virtual void *get_widget() { return 0;}
virtual void create_popup_menu( int x, int y) {}
};
......
......@@ -278,7 +278,9 @@ dcli_tCmdTable xnav_command_table[] = {
"/PINSTANCE", "/BYPASS",
"/CLOSEBUTTON", "/TARGET", "/TRIGGER", "/TYPE", "/FTYPE",
"/FULLSCREEN", "/MAXIMIZE", "/FULLMAXIMIZE", "/ICONIFY", "/HIDE",
"/XPOSITION", "/YPOSITION", "/X0", "/Y0", "/X1", "/Y1", "/URL", "/CONTINOUS", ""}
"/XPOSITION", "/YPOSITION", "/X0", "/Y0", "/X1", "/Y1", "/URL", "/CONTINOUS",
"/CAMERAPOSITION", "/CAMERACONTROLPANEL", "/VIDEOCONTROLPANEL",
"/VIDEOPROGRESSBAR", ""}
},
{
"CLOSE",
......@@ -3537,10 +3539,29 @@ static int xnav_open_func( void *client_data,
pwr_tStatus sts;
pwr_tURL url_str;
pwr_tAName object_str;
pwr_tAName camerapos_str;
int camerapos_found = 0;
pwr_sClass_CameraPosition pos;
// Command is "OPEN VIDEO"
if ( ODD( dcli_get_qualifier( "/OBJECT", object_str, sizeof(object_str)))) {
if ( ODD( dcli_get_qualifier( "/CAMERAPOSITION", camerapos_str, sizeof(camerapos_str)))) {
// CameraPosition object supplied
sts = gdh_GetObjectInfo( camerapos_str, &pos, sizeof(pos));
if (EVEN(sts)) {
xnav->message('E', "Object not found");
return XNAV__HOLDCOMMAND;
}
sts = gdh_AttrrefToName( &pos.VideoObject, object_str, sizeof(object_str), cdh_mNName);
if ( EVEN(sts)) {
xnav->message('E', "Configuration error, video object not found");
return XNAV__HOLDCOMMAND;
}
camerapos_found = 1;
}
if ( camerapos_found || ODD( dcli_get_qualifier( "/OBJECT", object_str, sizeof(object_str)))) {
// XttVideo object supplied, fetch data from object
pwr_tOName xttvideo_name;
pwr_sClass_XttVideo xttvideo;
......@@ -3590,6 +3611,8 @@ static int xnav_open_func( void *client_data,
xnav->appl.insert( applist_eType_Stream, (void *)strmctx, objid, name_str, url_str);
}
if ( camerapos_found)
strmctx->position( pos.Pan, pos.Tilt, pos.Zoom);
}
else {
/* Get the name qualifier */
......@@ -3609,10 +3632,12 @@ static int xnav_open_func( void *client_data,
options |= pwr_mVideoOptionsMask_FullMaximize;
if ( ODD( dcli_get_qualifier( "/ICONIFY", 0, 0)))
options |= pwr_mVideoOptionsMask_Iconify;
if ( ODD( dcli_get_qualifier( "/CONTROLPANEL", 0, 0)))
options |= pwr_mVideoOptionsMask_ControlPanel;
if ( ODD( dcli_get_qualifier( "/PROGRESSBAR", 0, 0)))
options |= pwr_mVideoOptionsMask_ProgressBar;
if ( ODD( dcli_get_qualifier( "/CAMERACONTROLPANEL", 0, 0)))
options |= pwr_mVideoOptionsMask_CameraControlPanel;
if ( ODD( dcli_get_qualifier( "/VIDEOCONTROLPANEL", 0, 0)))
options |= pwr_mVideoOptionsMask_VideoControlPanel;
if ( ODD( dcli_get_qualifier( "/VIDEOPROGRESSBAR", 0, 0)))
options |= pwr_mVideoOptionsMask_VideoProgressBar;
if ( ODD( dcli_get_qualifier( "/WIDTH", tmp_str, sizeof(tmp_str)))) {
nr = sscanf( tmp_str, "%d", &width);
......
xtt/mmi/xtt/src/xtt_get_pos.png

910 Bytes | W: | H:

xtt/mmi/xtt/src/xtt_get_pos.png

908 Bytes | W: | H:

xtt/mmi/xtt/src/xtt_get_pos.png
xtt/mmi/xtt/src/xtt_get_pos.png
xtt/mmi/xtt/src/xtt_get_pos.png
xtt/mmi/xtt/src/xtt_get_pos.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment