Graphics.UsingTheDougDisplayCommand - lordmundi/wikidoctest GitHub Wiki
« Using the doug plugin command | EDGE User’s Guide | Using the doug scene command »
EDGE provides an extensive tcl scripting ability to DSP.
The doug.display command allows some interaction with the display and window settings. This can be convenient for overlay and custom menu development.
The doug.display commands are best explained via examples. The following example commands should illustrate most of the usage:
bind [doug.display get -ogl_window] <Motion> {+ set doug.mousex %x; set doug.mousey %y }
doug.display set -mousex $doug.mousex -mousey $doug.mousey
doug.display set -mousexvar doug.mousex -mouseyvar doug.mousey
doug.display set -background col
doug.display get -background
doug.display get -ogl_window
doug.display get -view_window
doug.display get -main_window
doug.display get -curview
doug.display get -views
doug.display get -channels
If the above examples are not enough info, or you need more information about a particular option, the source code implementing the doug.display command is below:
[Show DOUG_DISPLAY_cmd source code][4]
int
DOUG_DISPLAY_cmd( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] )
{
char *cmd;
char *opt;
Tcl_HashEntry *entry;
XColor *pcol;
int i;
Tcl_ResetResult( interp );
cmd = Tcl_GetString( objv[i=1] );
i++;
if( !strcmp( cmd, "set" ) )
{
while( i < objc )
{
opt = Tcl_GetString( objv[i] );
i++;
if( !DSF_strcmpi( opt, "-mousex" ) )
{
Tcl_GetIntFromObj( NULL, objv[i], &(DSV_doug->mousex) );
i++;
}
else if( !DSF_strcmpi( opt, "-format" ) )
{
strcpy( DOUG_data_format, Tcl_GetString( objv[i] ) );
i++;
}
else if( !DSF_strcmpi( opt, "-background" ) )
{
pcol = Tk_GetColor( DSV_doug->interp, DSV_doug->tkwin, Tcl_GetString( objv[i] ) );
DSF_BgnModifyScene( DSV_scene );
DSV_scene->background[0] = pcol->red / 65536.0;
DSV_scene->background[1] = pcol->green / 65536.0;
DSV_scene->background[2] = pcol->blue / 65536.0;
DSF_EndModifyScene( DSV_scene );
Tk_FreeColor( pcol );
i++;
}
else if( !DSF_strcmpi( opt, "-mousey" ) )
{
Tcl_GetIntFromObj( NULL, objv[i], &(DSV_doug->mousey) );
i++;
}
else if( !DSF_strcmpi( opt, "-mousexvar" ) )
{
if( entry = Tcl_FindHashEntry( &var_hash, Tcl_GetString( objv[i] ) ) )
{
i++;
mousex = (DOUG_USER_VARIABLE*)Tcl_GetHashValue( entry );
}
else
{
Tcl_AppendResult( interp, "unable to locate doug-variable '%s'", Tcl_GetString( objv[i] ), NULL );
return TCL_ERROR;
}
}
else if( !DSF_strcmpi( opt, "-mouseyvar" ) )
{
if( entry = Tcl_FindHashEntry( &var_hash, Tcl_GetString( objv[i] ) ) )
{
i++;
mousey = (DOUG_USER_VARIABLE*)Tcl_GetHashValue( entry );
}
else
{
Tcl_AppendResult( interp, "unable to locate doug-variable '%s'", Tcl_GetString( objv[i] ), NULL );
return TCL_ERROR;
}
}
else if( !DSF_strcmpi( opt, "-flags" ) )
{
/* NOT DONE */
}
else if( !DSF_strcmpi( opt, "-fullscreen" ) )
{
/* NOT DONE */
}
else
{
Tcl_AppendResult( interp, "invalid doug.display set option '%s'", opt, NULL );
return TCL_ERROR;
}
}
}
else if( !strcmp( cmd, "get" ) )
{
opt = Tcl_GetString( objv[i] );
i++;
if( !DSF_strcmpi( opt, "-flags" ) )
{
/* NOT DONE */
}
else if( !DSF_strcmpi( opt, "-background" ) )
{
static char rgbcol[30];
int R, G, B;
R = DSV_scene->background[0] * 255.0;
G = DSV_scene->background[1] * 255.0;
B = DSV_scene->background[2] * 255.0;
if( R > 255 ) R = 255;
if( G > 255 ) G = 255;
if( B > 255 ) B = 255;
sprintf( rgbcol, "#%02x%02x%02x", R, G, B );
Tcl_AppendResult( interp, rgbcol, NULL );
}
else if( !DSF_strcmpi( opt, "-fullscreen" ) )
{
/* NOT DONE */
}
else if( !DSF_strcmpi( opt, "-view_window" ) )
{
Tcl_SetResult( interp, "._dougmain.view", TCL_STATIC );
}
else if( !DSF_strcmpi( opt, "-format" ) )
{
Tcl_SetResult( interp, DOUG_data_format, TCL_VOLATILE );
}
else if( !DSF_strcmpi( opt, "-ogl_window" ) )
{
Tcl_SetResult( interp, "._dougmain.view.ogl", TCL_STATIC );
}
else if( !DSF_strcmpi( opt, "-main_window" ) )
{
Tcl_SetResult( interp, "._dougmain", TCL_STATIC );
}
else if( !DSF_strcmpi( opt, "-curview" ) )
{
if( DSV_doug->pixel_info.pview )
Tcl_SetResult( interp, DSV_doug->pixel_info.pview->name, TCL_VOLATILE );
else
Tcl_SetResult( interp, "NULL", TCL_STATIC );
}
else
{
Tcl_AppendResult( interp, "invalid doug.display get option '%s'", opt, NULL );
return TCL_ERROR;
}
}
else if( !strcmp( cmd, "update" ) )
{
/* NOT DONE */
}
else
{
Tcl_AppendResult( interp, "invalid doug.display command '%s'", Tcl_GetString( objv[1] ), NULL );
return TCL_ERROR;
}
return TCL_OK;
}
« Using the doug plugin command | EDGE User’s Guide | Using the doug scene command »
[4]: javascript:toggleObj('togglecode_id0','hide','Show DOUG_DISPLAY_cmd source code','Show DOUG_DISPLAY_cmd source code','')