Graphics.UsingTheDougViewCommand - lordmundi/wikidoctest GitHub Wiki
« Using the doug scene command | EDGE User’s Guide | Using the doug dynamic plugin loading commands »
EDGE provides an extensive tcl scripting ability to DSP.
The doug.view command can be used to manipulate or query viewports in the scene
The doug.view commands are best explained via examples. The following example commands should illustrate most of the usage:
doug.view MAIN set -camera JimboCam
doug.view [doug.display get -curview] set -flags "~WIRE"
doug.view [doug.display get -curview] set -flags "~WIRE ~HIDE" -fullscreen 1
doug.view [doug.display get -curview] set -fullscreen [expr [doug.view name get -fullscreen] != 1]
doug.view [doug.display get -curview] get -geometry
doug.view [doug.display get -curview] get -width
doug.view [doug.display get -curview] get -height
doug.view [doug.display get -curview] get -x
doug.view [doug.display get -curview] get -y
If the above examples are not enough info, or you need more information about a particular option, the source code implementing the doug.view command is below:
[Show DOUG_VIEW_cmd source code][4]
int
DOUG_VIEW_cmd( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] )
{
#if 0
doug.view MAIN set -camera JimboCam
doug.view [doug.display get -curview] set -flags "~WIRE"
doug.view [doug.display get -curview] set -flags "~WIRE ~HIDE" -fullscreen 1
doug.view [doug.display get -curview] set -fullscreen [expr [doug.view name get -fullscreen] != 1]
#endif
int i;
char *view;
char *cmd;
char *opt;
DSS_VIEWPORT *pview;
DSS_PROCESS_DATA *pproc;
DSS_CHANNEL *pchan;
char buff[200];
char *sep = " \n\t,;";
char *tok_ptr;
char *tok;
int fval;
int new_item;
int *pint;
Tcl_HashEntry *entry;
static DSS_VIEWPORT viewstr;
static Tcl_HashTable fparams;
static Tcl_HashTable fbits;
static int first_pass = 1;
# define BYTE_OFFSET2(P) (((char*)(&viewstr.P)) - ((char*)(&viewstr)))
if( first_pass )
{
Tcl_InitHashTable( &fparams, TCL_STRING_KEYS );
Tcl_InitHashTable( &fbits, TCL_STRING_KEYS );
Tcl_SetHashValue( Tcl_CreateHashEntry( &fparams, "WIRE", &new_item ), BYTE_OFFSET2(flags) );
Tcl_SetHashValue( Tcl_CreateHashEntry( &fparams, "HIDE", &new_item ), BYTE_OFFSET2(attrib) );
Tcl_SetHashValue( Tcl_CreateHashEntry( &fbits, "WIRE", &new_item ), DSD_WIRE_FLAG );
Tcl_SetHashValue( Tcl_CreateHashEntry( &fbits, "HIDE", &new_item ), DSD_HIDE_ATTRIB );
first_pass = 0;
}
Tcl_ResetResult( interp );
if( objc < 3 )
{
Tcl_AppendResult( interp, "improper syntax used for 'doug.view' command", NULL );
return TCL_ERROR;
}
view = Tcl_GetString( objv[1] );
pproc = &(DSV_display->proc_data[DSV_proc_id]);
for( i = 0; i < pproc->num_channels; i++ )
{
pchan = pproc->channels[i];
pview = pchan->view_list;
while( pview )
{
if( !strcmp( pview->name, view ) )
break;
pview = pview->pnext;
}
if( pview )
break;
}
i = 2;
if( !pview )
{
Tcl_AppendResult( interp, "doug.view ", view, " --- no such view available", NULL );
return TCL_ERROR;
}
else
{
cmd = Tcl_GetString( objv[i] );
i++;
if( !strcmp( cmd, "set" ) )
{
DSF_BgnModifyScene( DSV_scene );
while( i < objc )
{
opt = Tcl_GetString( objv[i] );
i++;
if( !DSF_strcmpi( opt, "-flags" ) )
{
strcpy( buff, Tcl_GetString( objv[i] ) );
i++;
tok_ptr = 0;
tok = DSF_strtok_r( buff, sep, &tok_ptr );
while( tok )
{
/* IF CLEAR/TOGGLE FLAG */
if( tok[0] == '!' || tok[0] == '~' )
{
if( entry = Tcl_FindHashEntry( &fbits, &tok[1] ) )
{
fval = (int)Tcl_GetHashValue( entry );
}
else
{
Tcl_AppendResult( interp, "doug.view ", view, " set -flags (unknown flag \"", &tok[1], "\")", NULL );
DSF_EndModifyScene( DSV_scene );
return TCL_ERROR;
}
if( entry = Tcl_FindHashEntry( &fparams, &tok[1] ) )
{
pint = (int*)(((char*)pview) + (int)Tcl_GetHashValue( entry ));
/* IF CLEAR FLAG */
if( tok[0] == '!' )
*pint &= ~fval;
/* ELSE TOGGLE FLAG */
else
*pint = (*pint & ~fval) | ((~(*pint)) & fval);
}
}
/* SET FLAG */
else
{
if( entry = Tcl_FindHashEntry( &fbits, tok ) )
{
fval = (int)Tcl_GetHashValue( entry );
}
else
{
Tcl_AppendResult( interp, "doug.view ", view, " set -flags (unknown flag \"", &tok[1], "\")", NULL );
DSF_EndModifyScene( DSV_scene );
return TCL_ERROR;
}
if( entry = Tcl_FindHashEntry( &fparams, tok ) )
{
pint = (int*)(((char*)pview) + (int)Tcl_GetHashValue( entry ));
*pint |= fval;
}
}
tok = DSF_strtok_r( 0L, sep, &tok_ptr );
}
}
else if( !DSF_strcmpi( opt, "-fullscreen" ) )
{
int ival;
Tcl_GetIntFromObj( NULL, objv[i], &ival );
i++;
if( ival )
{
pchan->cur_view = pview;
}
else if( pchan->cur_view == pview )
{
pchan->cur_view = NULL;
}
}
else if( !DSF_strcmpi( opt, "-camera" ) )
{
int id;
pview->node_id = DSF_GetNodeID( Tcl_GetString( objv[i] ) );
i++;
}
else
{
Tcl_AppendResult( interp, "invalid doug.view ", view, " set option '", opt, "'", NULL );
DSF_EndModifyScene( DSV_scene );
return TCL_ERROR;
}
}
DSF_EndModifyScene( DSV_scene );
}
else if( !strcmp( cmd, "get" ) )
{
opt = Tcl_GetString( objv[i] );
i++;
if( !DSF_strcmpi( opt, "-camera" ) )
{
if( pview->node_id > -1 )
Tcl_SetResult( interp, DSV_scene->node_list[pview->node_id].name, TCL_VOLATILE );
else
Tcl_SetResult( interp, "NULL", TCL_STATIC );
}
else if( !DSF_strcmpi( opt, "-flags" ) )
{
char *hide = " HIDE";
char *wire = " WIRE";
int sub = 1;
if( pview->attrib & DSD_HIDE_ATTRIB )
{
Tcl_AppendResult( interp, hide+sub, NULL );
sub = 0;
}
if( pview->flags & DSD_WIRE_FLAG )
{
Tcl_AppendResult( interp, wire+sub, NULL );
sub = 0;
}
}
else if( !DSF_strcmpi( opt, "-fullscreen" ) )
{
if( pchan->cur_view == pview )
Tcl_SetResult( interp, "1", TCL_STATIC );
else
Tcl_SetResult( interp, "0", TCL_STATIC );
}
else
{
Tcl_AppendResult( interp, "invalid doug.view ", view, " get option '", opt, "'", NULL );
return TCL_ERROR;
}
}
else
{
Tcl_AppendResult( interp, "invalid doug.view command '", cmd, "'", NULL );
return TCL_ERROR;
}
}
return TCL_OK;
}
« Using the doug scene command | EDGE User’s Guide | Using the doug dynamic plugin loading commands »
[4]: javascript:toggleObj('togglecode_id0','hide','Show DOUG_VIEW_cmd source code','Show DOUG_VIEW_cmd source code','')