Commit 21b54ca4 authored by Claes Sjofors's avatar Claes Sjofors

Xtt camera control added

parent fda40c50
!
! 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_a_cameraposition.wb_load -- Defines the class CameraPosition.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Data for camera position
! Data for camera position.
!*/
Object CameraPosition $ClassDef 655
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
!/**
! Optional description.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
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
......@@ -93,7 +93,6 @@ SObject pwrb:Class
Object X $Attribute 6
Body SysBody
Attr TypeRef = "pwrs:Type-$Int32"
Attr Flags = 0
EndBody
EndObject
!/**
......@@ -102,7 +101,6 @@ SObject pwrb:Class
Object Y $Attribute 7
Body SysBody
Attr TypeRef = "pwrs:Type-$Int32"
Attr Flags = 0
EndBody
EndObject
!/**
......@@ -111,7 +109,6 @@ SObject pwrb:Class
Object Width $Attribute 8
Body SysBody
Attr TypeRef = "pwrs:Type-$Int32"
Attr Flags = 0
EndBody
EndObject
!/**
......@@ -120,7 +117,6 @@ SObject pwrb:Class
Object Height $Attribute 9
Body SysBody
Attr TypeRef = "pwrs:Type-$Int32"
Attr Flags = 0
EndBody
EndObject
!/**
......@@ -132,10 +128,44 @@ SObject pwrb:Class
! - Iconify Open the graph iconified.
! - ControlPanel Show a control panel with progress bar, Play, Pause and Stop buttons.
!*/
Object Options $Attribute 15
Object Options $Attribute 10
Body SysBody
Attr TypeRef = "pwrb:Type-VideoOptionsMask"
Attr Flags = 0
EndBody
EndObject
!/**
! Protocol for camera control.
!*/
Object Control $Attribute 11
Body SysBody
Attr TypeRef = "pwrb:Type-CameraControlEnum"
EndBody
EndObject
!/**
! Width of stream in pixel.
!*/
Object StreamWidth $Attribute 12
Body SysBody
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
!/**
! Height of stream in pixel.
!*/
Object StreamHeight $Attribute 13
Body SysBody
Attr TypeRef = "pwrs:Type-$Int32"
EndBody
EndObject
!/**
! Camera preset positions.
!*/
Object PresetPosition $Attribute 14
Body SysBody
Attr TypeRef = "pwrb:Class-CameraPosition"
Attr Flags |= PWR_MASK_CLASS
Attr Flags |= PWR_MASK_ARRAY
Attr Elements = 10
EndBody
EndObject
EndObject
......
!
! 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_td_cameracontrolenum.wb_load -- Defines the enum type CameraControl
!
SObject pwrb:Type
!/**
! @Version 1.0
! @Group Types
! Enumeration for yes/no.
!*/
Object CameraControlEnum $TypeDef 81
Body SysBody
Attr TypeRef = "pwrs:Type-$Enum"
Attr PgmName = "CameraControlEnum"
EndBody
!/**
! No communication.
!*/
Object No $Value
Body SysBody
Attr PgmName = "No"
Attr Text = "No"
Attr Value = 0
EndBody
EndObject
!/**
! Communication with ONVIF.
!*/
Object ONVIF $Value
Body SysBody
Attr PgmName = "ONVIF"
Attr Text = "ONVIF"
Attr Value = 1
EndBody
EndObject
!/**
! Communication with VAPIX.
!*/
Object VAPIX $Value
Body SysBody
Attr PgmName = "VAPIX"
Attr Text = "VAPIX"
Attr Value = 2
EndBody
EndObject
EndObject
EndSObject
......@@ -737,7 +737,7 @@ XttMultiViewGtk::XttMultiViewGtk( GtkWidget *mv_parent_wid, void *mv_parent_ctx,
strmctx[i*rows + j] = new XttStreamGtk( toplevel, this, "No title",
xttvideo.URL,
mv.Action[i*rows+j].Width, mv.Action[i*rows+j].Height,
0, 0, 0, options, 1, sts);
0, 0, 0, options, 1, &aref, sts);
strmctx[i*rows + j]->close_cb = multiview_strm_close_cb;
......@@ -1275,7 +1275,7 @@ int XttMultiViewGtk::set_subwindow_source( const char *name, char *source, char
XttStreamGtk *ctx = new XttStreamGtk( toplevel, this, "No title",
xttvideo.URL, w, h, 0, 0,
0, xttvideo.Options, 1, &lsts);
0, xttvideo.Options, 1, &object_aref, &lsts);
GtkWidget *comp_w = (GtkWidget *)ctx->get_widget();
......
......@@ -423,6 +423,15 @@ gboolean XttStreamGtk::mousebutton_cb( GtkWidget *widget, GdkEvent *event, void
strm->mb_press_x = event->button.x;
strm->mb_press_y = event->button.y;
break;
case 3: {
int x1, y1;
int x = event->button.x + 8;
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);
break;
}
}
break;
case GDK_BUTTON_RELEASE:
......@@ -437,8 +446,11 @@ gboolean XttStreamGtk::mousebutton_cb( GtkWidget *widget, GdkEvent *event, void
dft = time_DToFloat( &dft, &dt);
if ( dft < 0.5 &&
abs( event->button.x - strm->mb_press_x) < 10 &&
abs( event->button.y - strm->mb_press_y) < 10)
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);
}
else if ( abs( event->button.x - strm->mb_press_x) > 20 &&
abs( event->button.y - strm->mb_press_y) > 20) {
int x = min( event->button.x, strm->mb_press_x) - offset_x;
......@@ -446,9 +458,17 @@ gboolean XttStreamGtk::mousebutton_cb( GtkWidget *widget, GdkEvent *event, void
int w = abs( event->button.x - strm->mb_press_x);
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);
}
break;
}
case 2: {
int x = min( event->button.x, strm->mb_press_x) - offset_x;
int y = min( event->button.y, strm->mb_press_y) - offset_y;
strm->action_mb2click( x, y);
break;
}
}
break;
case GDK_SCROLL:
......@@ -456,18 +476,35 @@ gboolean XttStreamGtk::mousebutton_cb( GtkWidget *widget, GdkEvent *event, void
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,
// event->button.x - offset_x, event->button.y - offset_y);
strm->scroll_direction = event->scroll.direction == GDK_SCROLL_UP ? 1 : 0;
strm->scroll_x = event->button.x - offset_x;
strm->scroll_y = event->button.y - offset_y;
strm->scroll_cnt++;
break;
default: ;
}
return TRUE;
}
void XttStreamGtk::scroll_cb( void *data)
{
XttStreamGtk *strm = (XttStreamGtk *)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);
}
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_tStatus *sts) :
XttStream( st_parent_ctx, name, st_uri, width, height, x, y, scan_time, st_options, st_embedded),
parent_wid(st_parent_wid)
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)
{
GstStateChangeReturn ret;
GstBus *bus;
......@@ -568,17 +605,208 @@ XttStreamGtk::XttStreamGtk( GtkWidget *st_parent_wid, void *st_parent_ctx, const
}
}
GtkWidget *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);
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)
gtk_box_pack_start( GTK_BOX( main_box), GTK_WIDGET(hbox), FALSE, FALSE, 0);
if ( !embedded) {
gtk_container_add( GTK_CONTAINER( toplevel), main_box);
gtk_window_set_default_size( GTK_WINDOW( toplevel), width, height);
gtk_widget_show_all( toplevel);
g_object_set( ptz_box, "visible", FALSE, NULL);
if ( options & pwr_mVideoOptionsMask_FullScreen)
gtk_window_fullscreen( GTK_WINDOW(toplevel));
else if ( options & pwr_mVideoOptionsMask_Maximize)
......@@ -614,6 +842,7 @@ XttStreamGtk::XttStreamGtk( GtkWidget *st_parent_wid, void *st_parent_ctx, const
wow = new CoWowGtk( toplevel);
timerid = wow->timer_new();
scroll_timerid = wow->timer_new();
timerid->add( scan_time, refresh, this);
*sts = XNAV__SUCCESS;
......@@ -622,6 +851,7 @@ XttStreamGtk::XttStreamGtk( GtkWidget *st_parent_wid, void *st_parent_ctx, const
XttStreamGtk::~XttStreamGtk()
{
timerid->remove();
scroll_timerid->remove();
gst_element_set_state( playbin2, GST_STATE_NULL);
gst_object_unref( playbin2);
......@@ -640,6 +870,380 @@ void XttStreamGtk::set_size( int width, int height)
gtk_window_resize( GTK_WINDOW(toplevel), width, height);
}
void XttStreamGtk::create_popup_menu( int x, int y)
{
GtkMenu *menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
GtkWidget *w = gtk_menu_item_new_with_label( "Zoom reset");
g_signal_connect( w, "activate",
G_CALLBACK(activate_zoomreset), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Zoom in");
g_signal_connect( w, "activate",
G_CALLBACK(activate_zoomin), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Zoom out");
g_signal_connect( w, "activate",
G_CALLBACK(activate_zoomout), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), w);
gtk_widget_show(w);
GtkWidget *preset_store = gtk_menu_item_new_with_label( "Preset store");
GtkMenu *menu_preset_store = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
w = gtk_menu_item_new_with_label( "Position 1");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos1), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Position 2");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos2), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Position 3");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos3), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Position 4");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos4), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Position 5");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos5), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Position 6");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos6), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Position 7");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos7), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Position 8");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos8), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Position 9");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos9), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
w = gtk_menu_item_new_with_label( "Position 10");
g_signal_connect( w, "activate",
G_CALLBACK(activate_preset_store_pos10), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_preset_store), w);
gtk_widget_show(w);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(preset_store),
GTK_WIDGET(menu_preset_store));
gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(preset_store));
gtk_widget_show(preset_store);
popupmenu_x = x + 5;
popupmenu_y = y;
gtk_menu_popup( menu, NULL, NULL, menu_position_func,
this, 0, gtk_get_current_event_time());
}
void XttStreamGtk::menu_position_func( GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
gpointer data)
{
XttStreamGtk *strm = (XttStreamGtk *)data;
*x = strm->popupmenu_x;
*y = strm->popupmenu_y;
*push_in = FALSE;
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
void XttStreamGtk::activate_get_position( GtkWidget *w, gpointer data)
{
XttStreamGtk *strm = (XttStreamGtk *)data;
double pan, tilt, zoom;
int sts;
char pan_str[20], tilt_str[20], zoom_str[20];
sts = strm->camera_control->get_position( &pan, &tilt, &zoom);
if ( EVEN(sts)) return;
sprintf( pan_str, "%6.2f", pan);
sprintf( tilt_str, "%6.2f", tilt);
sprintf( zoom_str, "%6.2f", zoom);
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 0
int main(int argc, char *argv[]) {
......
......@@ -59,26 +59,38 @@ class XttStreamGtk : public XttStream {
pwr_tTime mb_press_time;
int mb_press_x;
int mb_press_y;
int scroll_x;
int scroll_y;
int scroll_direction;
int scroll_cnt;
int popupmenu_x;
int popupmenu_y;
GtkWidget *slider; /* Slider widget to keep track of current position */
GtkWidget *parent_wid;
GtkWidget *toplevel;
GtkWidget *video_form;
GtkWidget *main_box;
// CoWowFocusTimerGtk focustimer;
GtkWidget *ptz_box;
GtkWidget *ptz_pan;
GtkWidget *ptz_tilt;
GtkWidget *ptz_zoom;
void *overlay;
static int gst_initialized;
XttStreamGtk( GtkWidget *parent_wid, void *parent_ctx, const char *name, const char *uri,
int width, int height, int x, int y,
double scan_time, unsigned int options, int embedded, pwr_tStatus *sts);
double scan_time, unsigned int options, int embedded, pwr_tAttrRef *arp, pwr_tStatus *sts);
~XttStreamGtk();
void pop();
void set_size( int width, int height);
void *get_widget() { return main_box;}
void create_popup_menu( int x, int y);
static void scroll_cb( void *data);
static void refresh( void *data);
static void refresh_ui( XttStreamGtk *strm);
......@@ -97,6 +109,40 @@ class XttStreamGtk : public XttStream {
static void state_changed_cb( GstBus *bus, GstMessage *msg, void *data);
static void application_cb( GstBus *bus, GstMessage *msg, void *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);
static void activate_zoomreset( GtkWidget *w, gpointer data);
static void activate_zoomin( GtkWidget *w, gpointer data);
static void activate_zoomout( GtkWidget *w, gpointer data);
static void activate_scroll_left( GtkWidget *w, gpointer data);
static void activate_scroll_right( GtkWidget *w, gpointer data);
static void activate_page_left( GtkWidget *w, gpointer data);
static void activate_page_right( GtkWidget *w, gpointer data);
static void activate_scroll_down( GtkWidget *w, gpointer data);
static void activate_scroll_up( GtkWidget *w, gpointer data);
static void activate_page_down( GtkWidget *w, gpointer data);
static void activate_page_up( GtkWidget *w, gpointer data);
static void activate_preset_position1( GtkWidget *w, gpointer data);
static void activate_preset_position2( GtkWidget *w, gpointer data);
static void activate_preset_position3( GtkWidget *w, gpointer data);
static void activate_preset_position4( GtkWidget *w, gpointer data);
static void activate_preset_position5( GtkWidget *w, gpointer data);
static void activate_preset_position6( GtkWidget *w, gpointer data);
static void activate_preset_position7( GtkWidget *w, gpointer data);
static void activate_preset_position8( GtkWidget *w, gpointer data);
static void activate_preset_position9( GtkWidget *w, gpointer data);
static void activate_preset_position10( GtkWidget *w, gpointer data);
static void activate_preset_store_pos1( GtkWidget *w, gpointer data);
static void activate_preset_store_pos2( GtkWidget *w, gpointer data);
static void activate_preset_store_pos3( GtkWidget *w, gpointer data);
static void activate_preset_store_pos4( GtkWidget *w, gpointer data);
static void activate_preset_store_pos5( GtkWidget *w, gpointer data);
static void activate_preset_store_pos6( GtkWidget *w, gpointer data);
static void activate_preset_store_pos7( GtkWidget *w, gpointer data);
static void activate_preset_store_pos8( GtkWidget *w, gpointer data);
static void activate_preset_store_pos9( GtkWidget *w, gpointer data);
static void activate_preset_store_pos10( GtkWidget *w, gpointer data);
static void activate_get_position( GtkWidget *w, gpointer data);
};
......
......@@ -352,10 +352,10 @@ XttMultiView *XNavGtk::multiview_new( const char *name, pwr_tAttrRef *aref,
XttStream *XNavGtk::stream_new( const char *name, const char *uri,
int width, int height, int x, int y, double scan_time,
unsigned int options, int embedded, pwr_tStatus *sts)
unsigned int options, int embedded, pwr_tAttrRef *arp, pwr_tStatus *sts)
{
return new XttStreamGtk( parent_wid, this, name, uri, width, height, x, y,
scan_time, options, embedded, sts);
scan_time, options, embedded, arp, sts);
}
GeCurve *XNavGtk::gecurve_new( char *name, char *filename, GeCurveData *data,
......
......@@ -103,7 +103,7 @@ class XNavGtk : public XNav {
int (*is_authorized_cb) (void *, unsigned int));
XttStream *stream_new( const char *name, const char *uri,
int width, int height, int x, int y, double scan_time,
unsigned int options, int embedded, pwr_tStatus *sts);
unsigned int options, int embedded, pwr_tAttrRef *arp, pwr_tStatus *sts);
GeCurve *gecurve_new( char *name, char *filename, GeCurveData *data,
int pos_right, unsigned int options);
XttFileview *fileview_new( pwr_tOid oid, char *title, char *dir, char *pattern,
......
/*
* 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.
*/
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "cow_wow.h"
#include "rt_xnav_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_curvectx.h"
#include "glow_curveapi.h"
#include "xtt_xnav.h"
#include "xtt_stream.h"
void XttStream::action_click( int x, int y)
{
pwr_tCmd cmd;
pwr_tURL node;
char *s;
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;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&center=%d,%d",
node, x, y);
system( cmd);
}
void XttStream::action_areaselect( int x, int y, int w, int h)
{
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;
x += w/2;
y += h/2;
x = 700. / width * x;
y = 580. / height * y;
if ( w == 0 || h == 0)
return;
fzoom = min( (float)width/w, (float)height/h);
zoom = 100 * fzoom;
if ( zoom > 9999)
zoom = 9999;
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_scroll( int direction, int x, int y, int cnt)
{
pwr_tCmd cmd;
pwr_tURL node;
char *s;
int zoom;
if ( direction)
zoom = cnt * 150;
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;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rzoom=%d",
node, zoom);
system( cmd);
}
void XttStream::action_mb2click( int x, int y)
{
pwr_tCmd cmd;
pwr_tURL node;
char *s;
int zoom = 1;
strncpy( node, uri, sizeof(node));
s = strchr( node, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
*s = 0;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&zoom=%d",
node, zoom);
system( cmd);
}
void XttStream::action_mb3click( int x, int y)
{
create_popup_menu( x, y);
}
void XttStream::activate_preset_position( int idx)
{
if ( cdh_ObjidIsNull( aref.Objid))
return;
pwr_tOName aname;
pwr_tAttrRef aaref;
pwr_tStatus sts;
sprintf( aname, "PresetPosition[%d]", idx);
sts = gdh_ArefANameToAref( &aref, aname, &aaref);
if ( EVEN(sts)) return;
pwr_sClass_CameraPosition pos;
sts = gdh_GetObjectInfoAttrref( &aaref, &pos, sizeof(pos));
if ( EVEN(sts)) return;
camera_control->pan_tilt_zoom_absolute( pos.Pan, pos.Tilt, pos.Zoom);
}
void XttStream::activate_preset_store_pos( int idx)
{
if ( cdh_ObjidIsNull( aref.Objid))
return;
pwr_tOName aname;
pwr_tAttrRef aaref;
pwr_tStatus sts;
double pan, tilt, zoom;
sprintf( aname, "PresetPosition[%d]", idx);
sts = gdh_ArefANameToAref( &aref, aname, &aaref);
if ( EVEN(sts)) return;
camera_control->get_position( &pan, &tilt, &zoom);
pwr_sClass_CameraPosition pos;
pos.Pan = pan;
pos.Tilt = tilt;
pos.Zoom = zoom;
sts = gdh_SetObjectInfoAttrref( &aaref, &pos, sizeof(pos));
if ( EVEN(sts)) return;
}
XttCameraControlVapix::XttCameraControlVapix( char *x_url) :
XttCameraControl(x_url)
{
strncpy( url, x_url, sizeof(url));
char *s = strchr( url, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
s = strchr( ++s, '/');
if ( s)
*s = 0;
}
// Relative zoom, factor is -100 - 100, - zoom out, + zoom in.
void XttCameraControlVapix::zoom_relative( double factor)
{
pwr_tCmd cmd;
int zoom = (int)(factor * 100);
if ( zoom > 9999)
zoom = 9999;
if ( zoom < -9999)
zoom = -9999;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rzoom=%d",
url, zoom);
system( cmd);
}
// Absolute zoom, 0 - 100, 0 is max out, 100 is max in.
void XttCameraControlVapix::zoom_absolute( double factor)
{
pwr_tCmd cmd;
int zoom = (int)(factor * 100);
if ( zoom < 1)
zoom = 1;
if ( zoom > 9999)
zoom = 9999;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&zoom=%d",
url, zoom);
system( cmd);
}
// Relative pan, value is -100 - 100.
void XttCameraControlVapix::pan_relative( double value)
{
pwr_tCmd cmd;
int pan = (int)(value/100 * 360);
if ( pan > 360)
pan = 360;
if ( pan < -360)
pan = -360;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rpan=%d",
url, pan);
system( cmd);
}
// Absolute pan, value is 0 - 100.
void XttCameraControlVapix::pan_absolute( double value)
{
pwr_tCmd cmd;
int pan = (int)(value / 100 * 360 - 180);
if ( pan > 180)
pan = 180;
if ( pan < -180)
pan = -180;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rpan=%d",
url, pan);
system( cmd);
}
// Relative tilt, value is -100 - 100.
void XttCameraControlVapix::tilt_relative( double value)
{
pwr_tCmd cmd;
int tilt = (int)(value/100 * 360);
if ( tilt > 360)
tilt = 360;
if ( tilt < -360)
tilt = -360;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rtilt=%d",
url, tilt);
system( cmd);
}
// Absolute tilt, value is 0 - 100.
void XttCameraControlVapix::tilt_absolute( double value)
{
pwr_tCmd cmd;
int tilt = (int)(value / 100 * 360 - 180);
if ( tilt > 180)
tilt = 180;
if ( tilt < -180)
tilt = -180;
sprintf( cmd, "wget --ignore-length %s/axis-cgi/com/ptz.cgi?camera=1\\&rtilt=%d",
url, tilt);
system( cmd);
}
// 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);
if ( ipan > 180)
ipan = 180;
if ( ipan < -180)
ipan = -180;
int itilt = (int)(tilt / 100 * 360 - 180);
if ( itilt > 180)
itilt = 180;
if ( itilt < -180)
itilt = -180;
int izoom = (int)(zoom * 100);
if ( izoom < 1)
zoom = 1;
if ( izoom > 9999)
izoom = 9999;
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);
}
// Get current pan, tilt and zoom.
int XttCameraControlVapix::get_position( double *pan, double *tilt, double *zoom)
{
pwr_tCmd cmd;
pwr_tFileName fname = "/tmp/campos.txt";
FILE *fp;
char line[100];
char *s;
int sts;
float cpan, ctilt, czoom;
int pan_found, tilt_found, zoom_found;
pwr_tTime old_time;
pwr_tTime time;
int old_file_found;
int new_file_found;
old_file_found = 0;
sts = dcli_file_time( fname, &old_time);
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);
new_file_found = 0;
sts = dcli_file_time( fname, &time);
if ( ODD(sts)) {
if ( !old_file_found)
new_file_found = 1;
else {
if ( time_Acomp( &old_time, &time) != 0)
new_file_found = 1;
}
}
if ( !new_file_found)
return 0;
fp = fopen( fname, "r");
if (!fp)
return 0;
pan_found = 0;
tilt_found = 0;
zoom_found = 0;
while( ODD( dcli_read_line( line, sizeof(line), fp))) {
if ( (s = strstr( line, "pan=")) != 0) {
sts = sscanf( s+4, "%f", &cpan);
if ( sts == 1)
pan_found = 1;
}
else if ( (s = strstr( line, "tilt=")) != 0) {
sts = sscanf( s+5, "%f", &ctilt);
if ( sts == 1)
tilt_found = 1;
}
else if ( (s = strstr( line, "zoom=")) != 0) {
sts = sscanf( s+5, "%f", &czoom);
if ( sts == 1)
zoom_found = 1;
}
if ( pan_found && tilt_found && zoom_found) {
break;
}
}
fclose(fp);
sprintf( cmd, "rm -f %s", fname);
system( cmd);
if ( !(pan_found && tilt_found && zoom_found))
return 0;
*pan = (cpan + 180) / 360 * 100;
*tilt = (ctilt + 180) / 360 * 100;
*zoom = czoom/100;
return 1;
}
......@@ -44,6 +44,35 @@
class CoWow;
class CoWowTimer;
class XttCameraControl {
public:
pwr_tURL url;
XttCameraControl( char *x_url) {}
~XttCameraControl() {}
virtual void zoom_relative( double factor) {}
virtual void zoom_absolute( double factor) {}
virtual void pan_relative( double value) {}
virtual void pan_absolute( double value) {}
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 int get_position( double *pan, double *tilt, double *zoom) { return 0;}
};
class XttCameraControlVapix : public XttCameraControl {
public:
XttCameraControlVapix( char *x_url);
~XttCameraControlVapix() {}
void zoom_relative( double factor);
void zoom_absolute( double factor);
void pan_relative( double value);
void pan_absolute( double value);
void tilt_relative( double value);
void tilt_absolute( double value);
void pan_tilt_zoom_absolute( double pan, double tilt, double zoom);
int get_position( double *pan, double *tilt, double *zoom);
};
class XttStream {
public:
void *parent_ctx;
......@@ -51,28 +80,47 @@ class XttStream {
int embedded;
pwr_tURL uri;
CoWowTimer *timerid;
CoWowTimer *scroll_timerid;
CoWow *wow;
int scan_time;
int width;
int height;
void (*close_cb)( void *, XttStream *);
XttCameraControl *camera_control;
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) :
parent_ctx(st_parent_ctx), options(st_options), embedded(st_embedded), timerid(0), width(st_width),
height(st_height), close_cb(0) {
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));
}
virtual ~XttStream() {}
virtual ~XttStream() {
delete camera_control;
}
void action_click( int x, int y);
void action_mb2click( int x, int y);
void action_mb3click( int x, int y);
void action_areaselect( int x, int y, int w, int h);
void action_scroll( int direction, int x, int y, int cnt);
void activate_preset_position( int idx);
void activate_preset_store_pos( int idx);
virtual void pop() {}
virtual void set_size( int width, int height) {}
virtual void *get_widget() { return 0;}
virtual void create_popup_menu( int x, int y) {}
};
#endif
......
......@@ -385,7 +385,7 @@ class XNav {
int (*is_authorized_cb) (void *, unsigned int)) {return 0;}
virtual XttStream *stream_new( const char *name, const char *uri,
int width, int height, int x, int y, double scan_time,
unsigned int options, int embedded, pwr_tStatus *sts) {return 0;}
unsigned int options, int embedded, pwr_tAttrRef *arp, pwr_tStatus *sts) {return 0;}
virtual GeCurve *gecurve_new( char *name, char *filename, GeCurveData *data,
int pos_right, unsigned int options) {return 0;}
virtual XttFileview *fileview_new( pwr_tOid oid, char *title, char *dir, char *pattern,
......
......@@ -3581,7 +3581,7 @@ static int xnav_open_func( void *client_data,
strmctx->pop();
}
else {
strmctx = xnav->stream_new( name_str, url_str, width, height, x, y, 0, options, 0, &sts);
strmctx = xnav->stream_new( name_str, url_str, width, height, x, y, 0, options, 0, &aref, &sts);
if ( EVEN(sts)) {
xnav->message(' ', XNav::get_message(sts));
return sts;
......@@ -3660,7 +3660,7 @@ static int xnav_open_func( void *client_data,
strmctx->pop();
}
else {
strmctx = xnav->stream_new( name_str, url_str, width, height, x, y, 0, options, 0, &sts);
strmctx = xnav->stream_new( name_str, url_str, width, height, x, y, 0, options, 0, 0, &sts);
if ( EVEN(sts)) {
xnav->message(' ', XNav::get_message(sts));
return sts;
......
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