Highlighting entities in GiD
Posted: Fri Aug 14, 2020 12:27 pm
Hi,
I have a double question concerning GiD pre-pro.
1.
Let's say I have a surface which is "linked" (i.e. is somehow related) to some lines not necessarily belonging to the surface. I would like to develop a tool that allows to highlight the lines linked to the surface when clicking on the surface itself.
As a nice-to-have, I would also like to have the selected surface being highlighted, in a different way (for instance by being "filled" with some color different from the one used to highlight lines).
For the moment, I can select the surface by clicking on it and retrieve all the information I need. In particular, I end up with the identifing numbers of the lines which are linked to the surface. To do that, I developed a specific tool accessed via a customized menu.
That was the easy part. Now, I would like to highlight the lines corresponding to these numbers.
Of course, I would also need the lines (and the surface) to be un-highlighted when escaping the selection tool (typically, by pressing the 'esc' key).
Do you have any idea/suggestion on the way I could accomplish that?
2.
As a first try, I simply tried to redraw those lines by using "GiD_openGL" commands but nothing is drawn. I post my code hereafter. Could you tell me what is wrong with it?
Thank you very much in advance.
ML
-----
CODE:
-----
foreach ln $lignes_char {
# --- Retrieving the coordinates of the points defining line 'ln' ---
set infoLine [GiD_Info list_entities lines $ln]
set indexPts [lsearch $infoLine "Points:"]
set pt1 [lindex $infoLine [expr $indexPts+1]]
set pt2 [lindex $infoLine [expr $indexPts+2]]
set infoPt1 [GiD_Info list_entities points $pt1]
set infoPt2 [GiD_Info list_entities points $pt2]
set indexCoord1 [lsearch $infoPt1 "Coord:"]
set xr1 [lindex $infoPt1 [expr $indexCoord1+1]]
set yr1 [lindex $infoPt1 [expr $indexCoord1+2]]
set zr1 [lindex $infoPt1 [expr $indexCoord1+3]]
set indexCoord2 [lsearch $infoPt2 "Coord:"]
set xr2 [lindex $infoPt2 [expr $indexCoord1+1]]
set yr2 [lindex $infoPt2 [expr $indexCoord1+2]]
set zr2 [lindex $infoPt2 [expr $indexCoord1+3]]
# ---
# --- Retrieving screen coordinates from 'world' coordinates ---
set vec1 [GiD_OpenGL project "$xr1 $xr2 $xr3"]
set vec2 [GiD_OpenGL project "$xr2 $yr2 $zr2"]
set x1 [lindex $vec1 0]
set y1 [lindex $vec1 1]
set z1 [lindex $vec1 2]
set x2 [lindex $vec2 0]
set y2 [lindex $vec2 1]
set z2 [lindex $vec2 2]
# ---
# --- Draw a red line connecting the two points (does not work) ---
GiD_OpenGL draw -begin lines
GiD_OpenGL draw -vertex [list $x1 $y1 $z1]
GiD_OpenGL draw -vertex [list $x2 $y2 $z2]
GiD_OpenGL draw -color [list 1.000 0.000 0.000]
GiD_OpenGL draw -linewidth 1.0
GiD_OpenGL draw -end
# ---
}
I have a double question concerning GiD pre-pro.
1.
Let's say I have a surface which is "linked" (i.e. is somehow related) to some lines not necessarily belonging to the surface. I would like to develop a tool that allows to highlight the lines linked to the surface when clicking on the surface itself.
As a nice-to-have, I would also like to have the selected surface being highlighted, in a different way (for instance by being "filled" with some color different from the one used to highlight lines).
For the moment, I can select the surface by clicking on it and retrieve all the information I need. In particular, I end up with the identifing numbers of the lines which are linked to the surface. To do that, I developed a specific tool accessed via a customized menu.
That was the easy part. Now, I would like to highlight the lines corresponding to these numbers.
Of course, I would also need the lines (and the surface) to be un-highlighted when escaping the selection tool (typically, by pressing the 'esc' key).
Do you have any idea/suggestion on the way I could accomplish that?
2.
As a first try, I simply tried to redraw those lines by using "GiD_openGL" commands but nothing is drawn. I post my code hereafter. Could you tell me what is wrong with it?
Thank you very much in advance.
ML
-----
CODE:
-----
foreach ln $lignes_char {
# --- Retrieving the coordinates of the points defining line 'ln' ---
set infoLine [GiD_Info list_entities lines $ln]
set indexPts [lsearch $infoLine "Points:"]
set pt1 [lindex $infoLine [expr $indexPts+1]]
set pt2 [lindex $infoLine [expr $indexPts+2]]
set infoPt1 [GiD_Info list_entities points $pt1]
set infoPt2 [GiD_Info list_entities points $pt2]
set indexCoord1 [lsearch $infoPt1 "Coord:"]
set xr1 [lindex $infoPt1 [expr $indexCoord1+1]]
set yr1 [lindex $infoPt1 [expr $indexCoord1+2]]
set zr1 [lindex $infoPt1 [expr $indexCoord1+3]]
set indexCoord2 [lsearch $infoPt2 "Coord:"]
set xr2 [lindex $infoPt2 [expr $indexCoord1+1]]
set yr2 [lindex $infoPt2 [expr $indexCoord1+2]]
set zr2 [lindex $infoPt2 [expr $indexCoord1+3]]
# ---
# --- Retrieving screen coordinates from 'world' coordinates ---
set vec1 [GiD_OpenGL project "$xr1 $xr2 $xr3"]
set vec2 [GiD_OpenGL project "$xr2 $yr2 $zr2"]
set x1 [lindex $vec1 0]
set y1 [lindex $vec1 1]
set z1 [lindex $vec1 2]
set x2 [lindex $vec2 0]
set y2 [lindex $vec2 1]
set z2 [lindex $vec2 2]
# ---
# --- Draw a red line connecting the two points (does not work) ---
GiD_OpenGL draw -begin lines
GiD_OpenGL draw -vertex [list $x1 $y1 $z1]
GiD_OpenGL draw -vertex [list $x2 $y2 $z2]
GiD_OpenGL draw -color [list 1.000 0.000 0.000]
GiD_OpenGL draw -linewidth 1.0
GiD_OpenGL draw -end
# ---
}