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));
......
This diff is collapsed.
......@@ -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),
......
This diff is collapsed.
......@@ -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