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|pgfontpgffont
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:

...


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:

Code Block
proc MyRedrawProcedure { } { ...body... }
set id [GiD_OpenGL register MyRedrawProcedure]

...


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 standard representation of the condition is avoided.

...


For elements it is possible to draw only a face, specifying items of element_id and face_id, whith with face_id a number from 1 to the number of faces of the element.
Example:

...

  • doscrzoffset <boolean> Special trick to avoid the lines on surfaces hidden by the surfaces.
  • font push <font_name font_size>|pop|measure <text>|current|metrics ?-ascent|-descent|-linespace|-fixed?

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:

Code Block
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>

...

  • pgffont pushfont|popfont|print|dimensions|foreground|background

Command for PG fonts

  • pgffont pushfont <font_type>

    Push sets the current OpenGL font and add to stack.
    font types are categories of GiD, valid values: defaultfont | axisfont | legendfont | labelfont | graphfont | asianfont | tkdrawoglfont| pmfont

  • pgffont popfont

Restores the previous font and remove from stack. Commands push/pop must be called always paired

  • pgffont print <text>

To draw a <text> in the current 3D location (set by GiD_OpenGL draw -rasterpos [list $x $y $z]). It is similar to GiD_OpenGL drawtext

  • pgffont dimensions <text>

Return the width of <text> and <height> of current font. Sizes in pixels, but result are float, not int as could be expected.

To convert to 3D sizes must be multiplied by a factor, an approximate value of this factor could be calculated like this:

Code Block
proc GetApproximateFactorPixelToWorld { } {
    lassign [GiD_Project view clip_planes_x] left_ortho right_ortho
    lassign [GidUtils::GetMainDrawAreaSize] w h
    set factor [expr double($right_ortho-$left_ortho)/$w]
    return $factor
}
  • pgffont foreground <red> <green> <blue> <alpha>
  • pgffont background <red> <green> <blue> <alpha>

Example:

Code Block
GiD_OpenGL pgffont push labelfont
GiD_OpenGL drawtext "hello world"
GiD_OpenGL pgffont pop


List of supported OpenGL functions:

...