GiD - The personal pre and post processor
symbol
<symbol>
Every condition can have a symbol, that will be drawn when the user selects Draw symbols in the contextual menu that appears on user interactions such as right-mouse click operation.
The symbol is defined by a field <symbol> inside the condition. The available XML parameters are:
proc: Includes the name of a TCL proc to be defined in the TCL files of the problemtypes. In that proc, OpenGL is used to make the real drawing.
The procedure must return the id of a OpenGL drawing list (created by GiD_OpenGL draw -genlists 1), or a dict with some required keys depending on the orientation attribute value.
The proc is invoked adding automatically an extra argument: valuesList with a list of key value of the condition values stored in the tree.
orientation: can be global, local, localLA, free or have some special values section, shell_thickness, loads to invoke internally predefined drawings.
- global means that the symbol defined in the proc will be draw with its axes corresponding to that of the global axes of the model.
- local means that the symbol will be drawn related to a local axes system dependent on the entity.
- For lines, these local axes system will have x' axe parallel to the line. For surfaces, the z' axe will be parallel to the surface normal
(for lines some extra correction of the local axes could be applied) - localLA is similar to local, in this case is compulsory attach local axis to entities, implicit automatic local axis of lines and surfaces are not used (and without the extra correction in case of lines)
- section used for lines to draw bar section profiles in its local axes. (some extra correction of the local axes could be applied)
In this case the proc must return a dict Tcl object with keys named:
- obj the integer representing the opengl list to be drawn.
- shell_thickness to draw the surface with a thickness.
In this case the proc must return a dict Tcl object with keys named:
- thickness with the value of the thickness associated to the surface.
- cdg_pos (optional) with the list of the 3 components of the center position
- loads to represent loads.
In this case the proc must return a dict Tcl object with keys named:
- load_type with possible values global, global projected, local
- load_vector with a list of 3 components of the vector
e.g. return [dict create load_type $load_type load_vector $load_vector]
- free is another special value, in this case the Tcl procedure will be called once by entity with the condition to be draw, instead of only once by group.
The proc is invoked adding automatically some extra arguments: valuesList geom_mesh ov num pnts points ent_type center scale
this allow to know the information of the entity.
geom_mesh: GEOMETRYUSE or MESHUSE
ov: point line surface volume node element
num: <entity id>
pnts: in case of lines integer?, in case of surfaces its boundary lines and orientations <{line_1 SAME1ST|DIFF1ST} ... line_n SAME1ST|DIFF1ST}>
points: in case of lines <{x1 y1 z1} {x2 y2 z2}> start and end coordinates, in case of lines the boundary point coordinates
ent_type: STLINE, ...
center: <x y z>
scale: <scale_to_draw>
The local axes are defined by a special 'classical condition' (point_Local_axes, line_Local_axes, ...) assigned to the entities, or if there is not assigned this 'local axis' then the implicit local axis for lines and surfaces is used (based in its tangent and normal respectively)
There are Tcl predefined procedures to facilitate drawing with OpenGL:
- gid_groups_conds::import_gid_mesh_as_openGL <filename> <color_lines> <color_surfaces>
To automatically import a GiD mesh file to be drawn with OpenGL.
The filename to be read must be a GiD ASCII mesh of lines, triangles and quadrilaterals (with as few elements as as possible). This mesh could be exported from the menu Files->Export->GiD mesh. The procedure read the mesh and invoke GiD_OpenGL draw commands.
The mesh must represent a normalized shape, centered at the origin and contained in a box of size 1 for every of its dimensions (a 2x2x2 cube)
- gid_groups_conds::draw_symbol_image <image> <values_list>
To automatically import in image file to be drawn with OpenGL.
The image must use some valid image format (png, gif, jpg,...), and is expected to be inside a folder named /images of the problemtype
The values_list argument is currently not used.
- gid_groups_conds::draw_symbol_text <txt> <values_list>
To automatically print a text with OpenGL.
The values_list argument is currently not used.
Note: The package gid_draw_opengl also contains some predefined interesting procedures, and some .msh files with common symbols to be used by gid_groups_conds::import_gid_mesh_as_openGL
Example:
<condition n="Point_Weight" pn="Point Weight" ov="point" ovm="node" icon="constraints" help="Concentrated mass"> <value n="Weight" pn="Weight" v="0.0" unit_magnitude="M" units="kg" help="Specify the weight that you want to apply"/> <symbol proc="gid_groups_conds::draw_symbol_image darkorange-weight-18.png" orientation="global"/> </condition>
Example:
<condition n="Point_Weight" pn="Point Weight" ov="point" ovm="node" icon="constraints" help="Concentrated mass"> <value n="Weight" pn="Weight" v="0.0" unit_magnitude="M" units="kg" help="Specify the weight that you want to apply"/> <symbol proc="Cmas2d::DrawSymbolWeight" orientation="global"/> </condition>
And its Tcl drawing procedure, assuming that the mesh file named weight_2d.msh is located in the symbols folder or the problemtype:
proc Cmas2d::DrawSymbolWeight { values_list } { variable _opengl_draw_list if { ![info exists _opengl_draw_list(weight)] } { set _opengl_draw_list(weight) [GiD_OpenGL draw -genlists 1] GiD_OpenGL draw -newlist $_opengl_draw_list(weight) compile set filename_mesh [file join [Cmas2d::GetDir] symbols weight_2d.msh] gid_groups_conds::import_gid_mesh_as_openGL $filename_mesh black blue GiD_OpenGL draw -endlist } set weight_and_unit [lrange [lindex $values_list [lsearch -index 0 $values_list Weight]] 1 2] set weight [lindex $weight_and_unit 0] set scale [expr {$weight*0.1}] set transform_matrix [list $scale 0 0 0 0 $scale 0 0 0 0 $scale 0 0 0 0 1] set list_id [GiD_OpenGL draw -genlists 1] GiD_OpenGL draw -newlist $list_id compile GiD_OpenGL draw -pushmatrix -multmatrix $transform_matrix GiD_OpenGL draw -call $_opengl_draw_list(weight) GiD_OpenGL draw -popmatrix GiD_OpenGL draw -endlist return $list_id }
COPYRIGHT © 2022 · GID · CIMNE