Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

GiD_OpenGL register|unregister|registercondition|unregistercondition|draw|drawtext|project|unproject|get|doscrzoffset|drawentity|font|pgfont
This command is a Tcl wrapper of some OpenGL functions. It allows to use OpenGL commands directly from GiD-Tcl.
For example, for C/C++ is used:
glBegin(GL_LINES);
glVertex(x1,y1,z1);
glVertex(x2,y2,z2);
glEnd();
For GiD-Tcl must use:
GiD_OpenGL draw -begin lines
GiD_OpenGL draw -vertex [list $x1 $y1 $z1]
GiD_OpenGL draw -vertex [list $x2 $y2 $z2]
GiD_OpenGL draw -end
The standard syntax must be changed according to these rules: - OpenGL constants: "GL" prefix and underscore character '_' must be removed; the command must be written in lowercase.
Example:
GL_COLOR_MATERIAL -> colormaterial

  • OpenGL functions: "GL" prefix must be removed and the command written in lowercase. Pass parameters as list, without using parentheses ()
    Example:
    glBegin(GL_LINES) -> glbegin lines
    The subcommand "GiD_OpenGL draw" provides access to standard OpenGL commands, but other "GiD_OpenGL" special GiD subcommands also exists:
    • register <tclfunc> Register a Tcl procedure to be invoked automatically when redrawing the scene. It returns a handle to unregister.


Example:
proc MyRedrawProcedure { } { ...body... }
set id [GiD_OpenGL register MyRedrawProcedure]

    • unregister <handle> Unregister a procedure previously registered with register.


Example:
GiD_OpenGL unregister $id

    • registercondition <tclfunc> <condition> Register a Tcl procedure to be invoked automatically when redrawing the specified condition.

The tcl funcion must have this prototype:
proc xxx { condition use entity_id values } {
...
return 1
}
The supplied parameters are:
condition :the condition name, defined in the .cnd file of the problemtype
use: GEOMETRYUSE, MESHUSE or POSTUSE
entity_id: the integer number that identity the entity where the condition is applied. The kind of entity is known because it is declared in the
definition of the condition in the .cnd, depending if the current state is geometry or mesh
values: a list of the field's values applied to this entity. The amount of values must match the amount of fields of the condition definition.
The return value of this procedure is important:
return 0: then the standard representation of the condition is also invoked after the procedure
return 1: the stardard representation of the condition is avoided.

    • unregistercondition <condition> Unregister a procedure previously registered with registercondition.

...

If -check_non_latin flag is provided, then the text is checked to detect non-latin characters, like a Japanese string, to be drawn properly (otherwise it is considered as a latin string). The flag must be provided only if <text> could potentially be non-latin, like translated strings. In case of numbers for example it is unneeded (more efficient without the extra check)
Example:
GiD_OpenGL draw -rasterpos [list $x $y $z]
GiD_OpenGL drawtext "hello world"

    • drawentity ?-mode normal|filled? point|line|surface|volume|node|element|dimension <id list> To draw an internal GiD preprocess entity.

...

return a list of values:
modelviewmatrix: 16 doubles
projectionmatrix: 16 doubles
viewport: 4 integers

    • doscrzoffset <boolean> Special trick to avoid the lines on surfaces hidden by the surfaces.

...

push sets the current OpenGL font, pop restores the previous one
measure <text> returns the amount of space in pixels to display this <text>
current returns a list with the current font name and size
metrics returns a list with current font metrics information: -ascent -descent and -linespace in pixels, -fixed is 1 if all characters have equal size
Example:
GiD_OpenGL font push {"Times New Roman" 18}
set with [GiD_OpenGL measure "hello world"]
GiD_OpenGL drawtext "hello world"
GiD_OpenGL pop

    • pgfont pushfont <font_type>|popfont|print <text>|dimensions <text>|foreground <red> <green> <blue> <alpha>|background <red> <green> <blue> <alpha>

...