#!/bin/sh -f
#ListEntities  -*- TCL -*- Created: ramsan Mar-1996, Modified: ramsan Mar-1996

#----------------------CALCULATOR ALONE---------------------------
# the next line restarts using wish \
	exec wish "$0" "$@"

# set ListEntRunningAlone 0
# if { ![info exists GIDDEFAULT] } {
#     set ListEntRunningAlone 1
#     set tcl_interactive 0
#     set tk_strictMotif 1

#     if { [catch { set GIDDEFAULT $env(GIDDEFAULT)}]!=1 } {
#         set GIDDEFAULTTCL $GIDDEFAULT
#         catch { set GIDDEFAULTTCL $env(GIDDEFAULTTCL) }
#         set auto_path "$GIDDEFAULTTCL"
#         source $GIDDEFAULTTCL/init.tcl
#         source $GIDDEFAULTTCL/tk.tcl
#     }
#         wm withdraw .
#     proc GiveDpos {} {
#         return "-0+400"
#     }
# }

#  LOOK AT THE END OF THE FILE !!!
#-------------------------------------------------------------------


proc CreateEntry { w text { l -1} { fn ""}} {
    entry $w
    $w ins end $text
    set len [string length $text]
    incr len 4
    if { $l != -1} { set len $l}
    $w conf -state disabled -width $len -relief sunken
    if { "$fn" != ""} {
	$w conf -font $fn
    }
}

proc SelectMouselineInList { w } {
    $w.e delete 0 end 
    $w.e insert 0 \
	    [lindex [$w.f1.list get [lindex [$w.f1.list curselection] 0]] 0]
}

proc GoToShowEnt { w } {
    global InfoListEnt
    set iNumEnt [$w.list.e get]
    if { ![info exists InfoListEnt($iNumEnt,type)] } {
	tk_dialogRAM $w.list.err [_ "error"] \
	    [_ "Before pressing 'go' enter one entity number"] \
	    error 0 [_ "OK"]
	return
    }
    ShowEntity $w.enti $iNumEnt
    destroy $w.list
}

## Victor
proc FillListOfEntWithEnt { w listorder} {
    global ListOfEnt InfoListEnt

    GIDReportData::Reset

    set w2 $w.list
    if { [winfo exists $w2.f2.text] } {
	catch { pack forget $w2.f2 }
	pack $w2.f1 -fill both -expand yes -side top
    }
    $w2.f1.list del 0 end
    set num [lindex $ListOfEnt 0] 

    if { $InfoListEnt($num,type) == "POINT" || \
	    $InfoListEnt($num,type) == "NODES" || \
	    $InfoListEnt($num,type) == "POSTNODES" } {
	foreach i $ListOfEnt {
	    $w2.f1.list insert end "$i         $InfoListEnt($i,coord)"
	    GIDReportData::AddData $i "$InfoListEnt($i,coord)"
	}
    } else {
	if { $InfoListEnt($num,type) == "ELEMENTS" || \
	     $InfoListEnt($num,type) == "POSTELEMENTS" } {
	    foreach i $ListOfEnt {
		$w2.f1.list insert end "$i        $InfoListEnt($i,nodes)"
		GIDReportData::AddData $i "$InfoListEnt($i,nodes)"
	    } 
	} else {
	    foreach i $ListOfEnt {
		$w2.f1.list insert end $i
		GIDReportData::AddData $i
	    }    
	}
    }
    set trad [_ "Entities contents:"]
    $w2.buts.text conf -text [_ "View text"]  -command \
	    "FillListOfEntWithText $w [list $listorder]; $w2.buts.toReport conf -state disable; $w2.l conf -text \"$trad\""

    set InfoListEnt(ReportData) [ GIDReportData::GetDataHTML 1] 
}
## End Victor

## Victor
proc FillListOfEntWithText { w listorder} {

    set w2 $w.list
    if { ![winfo exists $w2.f2.text] } {
	PutText $w2 2 yes 15
    }
    pack forget $w2.f1
    pack $w2.f2 -fill both -expand yes -side top
    
    set cmd ".central.s info list_entities -more "
    foreach elem $listorder {
	append cmd " $elem"
    }
    set info [eval $cmd]
    set info [split $info \n]

    set que [ lindex $info 0]
    $w2.f2.text del 0.0 end

    if { ( "$que" != "POSTNODES") && ( "$que" != "POSTELEMENTS") } {
	$w2.f2.text conf -font Normal
	foreach aa $info {
	    $w2.f2.text ins end $aa\n
	}
    } else {
	$w2.f2.text conf -font fixed
	foreach aa $info {
	    #$w2.f2.text ins end $aa\n
	    set idx [ string first : $aa]
	    if { $idx == -1 } {
		$w2.f2.text ins end $aa\n
	    } else {
		set clave [ string range $aa 0 $idx]

		switch $clave {

		    "Num:" {
		        $w2.f2.text ins end "\n[ lindex $aa 0] [ lindex $aa 1]\t [ lindex $aa 2]\t [ lindex $aa 3]\t [ lindex $aa 4]\n"
		    }

		    "Current result:" {
		        set rr [ lrange $aa 2 end]
		        set nombres [ lindex $rr 0]
		        set resul_pgs [ lindex $rr 1]
		        set gausspoints ""
		        if { [ llength $nombres] == 2} {
		            set componentes [ lindex $nombres 1]
		        } else {
		            set gausspoints [ lindex $nombres 1]
		            set componentes [ lindex $nombres 2]
		        }
		        $w2.f2.text ins end " · Current result: [lindex $nombres 0]"
		        if { "$gausspoints" != ""} {
		            $w2.f2.text ins end " on '$gausspoints'"
		        }

		        if { [ llength $componentes] > 1} {
		            $w2.f2.text ins end "\n                 \t"
		            for { set i 0} { $i < [ llength $componentes]} { incr i} {
		                $w2.f2.text ins end " \t[lindex $componentes $i]"
		            }
		        }

		        for { set ipg 0} { $ipg < [ llength $resul_pgs]} { incr ipg} {
		            $w2.f2.text ins end "\n                 \t"
		            set valores [ lindex $resul_pgs $ipg]
		            if { [ llength $valores] == 1} {
		                $w2.f2.text ins end " \t[lindex $valores 0]"
		            } else {
		                set n [ llength $valores]
		                for { set i 0} { $i < $n} { incr i} {
		                    #set c [ lindex $componentes $i]
		                    set v [ lindex $valores $i]
		                    $w2.f2.text ins end " \t$v"
		                }
		            }
		        }
		        $w2.f2.text ins end \n
		    }

		    "More results:" {
		        set todos [ lindex $aa 2 ]
		        set nt [ llength $todos]
		        for { set it 0} { $it < $nt} { incr it} {
		            set rr [ lindex $todos $it]
		            set nombre [ lindex $rr 0]
		            set gausspoints ""
		            if { [ llength $rr] == 3} {
		                set componentes [ lindex $rr 1]
		                set resul_pgs [ lindex $rr 2]
		            } else {
		                set gausspoints [ lindex $rr 1]
		                set componentes [ lindex $rr 2]
		                set resul_pgs [ lindex $rr 3]
		            }
		            if { !$it} {
		                $w2.f2.text ins end " · More results: $nombre"
		            } else {
		                $w2.f2.text ins end "                 $nombre"
		            }
		            if { "$gausspoints" != ""} {
		                $w2.f2.text ins end " on '$gausspoints'"
		            }
		            if { [ llength $componentes] > 1} {
		                $w2.f2.text ins end "\n                 \t"
		                for { set i 0} { $i < [ llength $componentes]} { incr i} {
		                    $w2.f2.text ins end " \t[lindex $componentes $i]"
		                }
		            }
		            for { set ipg 0} { $ipg < [ llength $resul_pgs]} { incr ipg} {
		                $w2.f2.text ins end "\n                 \t"
		                set valores [ lindex $resul_pgs $ipg]
		                if { [ llength $valores] == 1} {
		                    $w2.f2.text ins end " \t[lindex $valores 0]"
		                } else {
		                    set n [ llength $valores]
		                    for { set i 0} { $i < $n} { incr i} {
		                        #set c [ lindex $componentes $i]
		                        set v [ lindex $valores $i]
		                        $w2.f2.text ins end " \t$v"
		                    }
		                }
		            }
		            $w2.f2.text ins end \n
		        }
		    }

		    "Gauss points:" {
		        set todos [ lrange $aa 2 end]
		        set nt [ llength $todos]
		        for { set it 0} { $it < $nt} { incr it} {
		            set rr [ lindex $todos $it]
		            set nombre [ lindex $rr 0]
		            set numero [ lindex $rr 1]
		            set que_coordenadas [ lindex $rr 2]
		            if { !$it} {
		                $w2.f2.text ins end " · Gauss points: '$nombre' $numero ppe with $que_coordenadas"
		            } else {
		                $w2.f2.text ins end "                 '$nombre' $numero ppe with $que_coordenadas"
		            }
		            $w2.f2.text ins end \n
		        }
		    }
		    default {
		        $w2.f2.text ins end $aa\n
		    }
		}
	    }
	}
    }

    set trad [_ "Select entity:"]
    $w2.buts.text conf -text [_ "View list"]  -command \
	    "FillListOfEntWithEnt $w [list $listorder]; $w2.buts.toReport conf -state normal; $w2.l conf -text \"$trad\""
}
## End Victor

## Victor
proc MakeListOfEnt { w listorder } {
    global ListOfEnt InfoListEnt

    set w2 $w.list
    
    if { ![winfo exists $w2] } {
	InitWindow $w2 [_ "List Entities Tot"] ListEntitiesTotWindowGeom
	set x [ winfo x [winfo parent $w2]]
	set y [ winfo y [winfo parent $w2]]
#        wm geometry $w2 210x420+[expr $x+20]+[expr $y-100]
	wm geometry $w2 +[expr $x+20]+[expr $y-100]
	
	label $w2.l -text [_ "Select entity:"]
	pack $w2.l -side top
	entry $w2.e -relief sunken
	$w2.e del 0 end
	$w2.e insert end [lindex $ListOfEnt 0]
	frame $w2.buts
	button $w2.buts.go -text [_ "Go"] -command "GoToShowEnt $w"
	button $w2.buts.text -text [_ "View text"]  -command \
		"FillListOfEntWithText $w [list $listorder]"
	button $w2.buts.close -text [_ "Close"] -command "destroy $w2"
	button $w2.buts.toReport -image [ GIDReport::GetImage ToReport] -command {
	    global InfoListEnt
	    if { "$InfoListEnt(ReportData)" != ""} {
		GIDReport::AddToReport $InfoListEnt(ReportData)
	    }
	}
	GiDPopUpHelp $w2.buts.toReport [ GIDReport::GetHelpForImage ToReport]
	pack $w2.buts.go $w2.buts.text $w2.buts.close -side left -ipadx 5 \
		-padx 3 -pady 5
	pack $w2.buts.toReport -side right -ipadx 5 \
		-padx 3 -pady 5
	pack $w2.buts -side bottom
	pack $w2.e -fill x -padx 5 -side bottom
	PutListBox $w2 1 yes 15
	
	bind $w2.f1.list <ButtonRelease-1> "SelectMouselineInList $w2"
	bind $w2.f1.list <Double-Button-1> "$w2.buts.go invoke ; break"
	bind $w2.e <Return> "$w2.buts.go invoke"
#        bind $w2 <Any-FocusIn> "focus $w2.e"
#        focus $w2.e
    }
    FillListOfEntWithEnt $w $listorder
}
## End Victor

## Victor
proc ReadAndDrawStatus { wListEnt info index line } {
	
    wm title $wListEnt [_ "Status"]
    wm iconname $wListEnt "Status"
    $wListEnt.ltit conf -text [_ "Status"]
    catch { destroy  $wListEnt.enti }
    if { [winfo height $wListEnt.buts.close] > 1 } {
	pack propagate $wListEnt.buts no
    }
    pack propagate $wListEnt.d no
    $wListEnt.d conf -text ""
    
    pack forget $wListEnt.buts.prev $wListEnt.buts.next $wListEnt.buts.list \
	    $wListEnt.buts.clone $wListEnt.buts.toReport
    pack $wListEnt.buts.close -anchor center -side left
    bind $wListEnt <Tab> ""
    bind $wListEnt <Shift-Tab> ""

    frame $wListEnt.enti -relief ridge -bd 2
    pack propagate $wListEnt.enti no
    pack $wListEnt.enti -fill both -expand yes -side top

    set ilistnum 0
    set maxindex [llength $info]
    while {$index <= $maxindex} {
	if { [info exists line] } {
	    set aa $line
	    unset line
	} else {
	    set aa [lindex $info $index]; incr index
	}
	switch -regexp $aa {
	    "Project name:" {
		regexp {Project name: (.*)$} $aa trash coo0
	    }
	    "Problem type:" {
		regexp {Problem type: (.*)$} $aa trash coo1
	    }
	    "Using LAYER:" {
		regexp {Using LAYER: (.*)$} $aa trash coo2
	    }
	    "number of nodes:" {
		regexp {number of nodes: (.*)$} $aa trash coo3
	    }
	    "Total number of elements:" {
		regexp {Total number of elements: (.*)$} $aa trash coo4
	    }
	    "There is no mesh" {
		# nothing
	    }
	    default {
		set inlist($ilistnum) $aa
		incr ilistnum
	    }    
	}
    }

    set w $wListEnt.enti
    set cc [list [_ "Project Name"]: [_ "Problem type"]: [_ "Using layer"]:  [_ "Num of nodes"]: \
	    [_ "Num of elems"]: ]
    for {set i 0} {$i < 5} {incr i} {
	if { ![info exists coo$i] } { 
	    if { $i == 3} {
		label $w.coo3  -text [_ "There is no mesh"]
		pack $w.coo3 -side top
		break
	    } 
	} else {
	    upvar 0 coo$i value
	    frame $w.coo$i
	    label $w.coo$i.cc -text [lindex $cc $i] \
		    -width 18
	    CreateEntry $w.coo$i.n $value
	    pack $w.coo$i.cc $w.coo$i.n \
		    -side left -anchor w 
	    pack $w.coo$i -side top -fill x -pady 2
	}
    }
    PutListBox $w 1 yes 9
    for {set i 0} {$i < $ilistnum} {incr i} {
	$w.f1.list insert end $inlist($i)
    }

}
## End Victor

## Victor
proc ReadListEnt { w listorder } {
    global NumEntList ListOfEnt InfoListEnt

    set ListOfEnt ""
    set NumEntList 0
    set LastPolyNum -1 ; set LastPolyNumLine -1
    set LastPolyNumLine2 -1

    set LastPolySurfNum -1
    set LastPolySurfNumSurf -1 ; set LastPolySurfNumIntLine -1 

    # Execute info
#     set listorder [split $listorder ]
#     set cmd ".central.s info list_entities "
# 
#     foreach elem $listorder {
#         set cmd "$cmd $elem"
#     }
    set cmd ".central.s info list_entities $listorder"

    #WarnWinText $cmd
    set info [eval $cmd]
    #WarnWinText $info
    set info [split $info \n]
    #WarnWinText $info
    set index 0
    set maxindex [llength $info]
    while {$index <= $maxindex} {
	set type [lindex $info $index]; incr index
	if { [string match "Project name:*" $type ] } { 
	    ReadAndDrawStatus $w $info $index $type
	    break
	}
	set NumToUse -1
	while 1 {
	    set aa [lindex $info $index]; incr index
	    if { [string match END* $aa] } {
		if { $LastPolyNum != -1 } {
		    set aa [lindex $info $index]; incr index
		    set InfoListEnt($NumToUse,orien) [lindex $aa 1]
		    set InfoListEnt($NumToUse,len) \
		            [string trimleft [lindex $aa 2] Length=]
		    set num $InfoListEnt($LastPolyNum,nlin)
		    set num2 0
		    if { $LastPolyNumLine2 != -1 } {
		        set idx "$LastPolyNum $LastPolyNumLine"
		        set num2 $InfoListEnt($idx,nlin)
		    }
		    if { ($num2>0 && $LastPolyNumLine2>=$num2) || \
		         ($num2==0 && $LastPolyNumLine >= $num) } {
		        set aa [lindex $info $index]; incr index
		        if { $LastPolyNumLine2 != -1 } {
		            set NumToUse "$LastPolyNum $LastPolyNumLine"
		            set LastPolyNumLine2 -1
		        } else {
		            set NumToUse $LastPolyNum
		            set LastPolyNum -1
		        }
		        set InfoListEnt($NumToUse,len) \
		                [string trimleft [lindex $aa 1] "Length="]
		        set InfoListEnt($NumToUse,upim) \
		                [lrange $aa 6 end]
		        continue
		    }
		} elseif { $LastPolySurfNum != -1 } {
		    if { $LastPolySurfNumSurf != -1 } {
		        set aa [lindex $info $index]; incr index
		        set InfoListEnt($NumToUse,orien) [lindex $aa 1]
		        set num $InfoListEnt($LastPolySurfNum,nsurf)
		        if { $LastPolySurfNumSurf >= $num } {
		            set NumToUse $LastPolySurfNum
		            set LastPolySurfNumSurf -1
		            continue
		        }
		    } elseif { $LastPolySurfNumIntLine != -1 } {
		        set num $InfoListEnt($LastPolySurfNum,nintln)
		        if { $LastPolySurfNumIntLine >= $num } {
		            set NumToUse $LastPolySurfNum
		            set LastPolySurfNumIntLine -1
		            set LastPolySurfNum  -1
		            continue
		        }
		    }
		}

		break 
	    }
	    if { $index >= $maxindex } { break }
	    switch -regexp -- $aa {
		Num: {
		    set NumToUse [lindex $aa 1]
		    if { $NumToUse == 0 } {
		        if { $LastPolyNum != -1 } {
		            if { $LastPolyNumLine2 != -1 } {
		                incr LastPolyNumLine2
		                set NumToUse \
		                        "$LastPolyNum $LastPolyNumLine $LastPolyNumLine2"
		            } else {
		                incr LastPolyNumLine
		                set NumToUse "$LastPolyNum $LastPolyNumLine"
		            }
		        } elseif { $LastPolySurfNum != -1 } {
		            if { $LastPolySurfNumSurf != -1 } {
		                incr LastPolySurfNumSurf
		                set NumToUse "$LastPolySurfNum S$LastPolySurfNumSurf"
		            } elseif { $LastPolySurfNumIntLine != -1 } {
		                incr LastPolySurfNumIntLine
		                set NumToUse "$LastPolySurfNum L$LastPolySurfNumIntLine"
		            }
		        }

		    } else { 
		        lappend ListOfEnt $NumToUse 
		        incr NumEntList 
		    }

		    set InfoListEnt($NumToUse,type) $type

		    if { "$type" == "POSTNODES" } {

		        set InfoListEnt($NumToUse,coord) [ lindex $aa 2]
		        set InfoListEnt($NumToUse,mat) 0
		        set InfoListEnt($NumToUse,CurrentResultName) ""
		        set InfoListEnt($NumToUse,MoreResults) ""
		        if { [ lsearch $aa GaussPoint] != -1} {
		            set InfoListEnt($NumToUse,EsPuntoGauss) 1
		        } else {
		            set InfoListEnt($NumToUse,EsPuntoGauss) 0
		        }

		    } elseif { "$type" == "POSTELEMENTS" } {

		        set InfoListEnt($NumToUse,nodes) [ lindex $aa 2]
		        set InfoListEnt($NumToUse,TipoElemento) [lindex $aa 3]
		        set InfoListEnt($NumToUse,mat) [lindex $aa 4]
		        set InfoListEnt($NumToUse,CurrentResultName) ""
		        set InfoListEnt($NumToUse,MoreResults) ""
		        set InfoListEnt($NumToUse,GaussPoints) ""

		    } else {
		        set InfoListEnt($NumToUse,HigherEnt) [lindex $aa 3]
		        set InfoListEnt($NumToUse,cond) [lindex $aa 5]
		        set InfoListEnt($NumToUse,mat) [lindex $aa 7]
		    }
		}
		Coord: { 
		    set InfoListEnt($NumToUse,coord) \
		            [string trimleft $aa "Coord: "]
		}
		Points: { 
		    set InfoListEnt($NumToUse,pts)  \
		            [string trimleft $aa "Points: "]
		}
		"2D center" {
		    set InfoListEnt($NumToUse,2DCEN) \
		            [string trimleft [lindex $aa 1] "center="]
		    set InfoListEnt($NumToUse,rad) \
		            [string trimleft [lindex $aa 2] "radius="]
		    set InfoListEnt($NumToUse,iang) \
		            [string trimleft [lindex $aa 3] "initang="]
		    set InfoListEnt($NumToUse,eang) \
		            [string trimleft [lindex $aa 4] "endang="]
		}
		"Transformation Matrix:" {
		    set InfoListEnt($NumToUse,mat1) \
		            [lindex $info $index]; incr index
		    set InfoListEnt($NumToUse,mat2) \
		            [lindex $info $index]; incr index
		    set InfoListEnt($NumToUse,mat3) \
		            [lindex $info $index]; incr index
		    set InfoListEnt($NumToUse,mat4) \
		            [lindex $info $index]; incr index
		}
		"Num of Control Points" {
		    set num [string trimleft $aa "Num of Control Points="]
		    set InfoListEnt($NumToUse,NCtrl) $num
		    for {set i 1} {$i <= $num} {incr i} {
		        set aa [lindex $info $index]; incr index
		        set InfoListEnt($NumToUse,Ctrl$i) \
		                [string trimleft [lindex $aa 2] "coords:"]
		    }
		}
		"Number of Control Points" {
		    regexp {=[ ]*(.*)[ ]*Degree=[ ]*(.*)$} $aa t num degree
		    set InfoListEnt($NumToUse,NCtrl) $num
		    set InfoListEnt($NumToUse,degree) $degree
		    if { [llength $num] == 2 } {
		        set NumCtrl [expr [lindex $num 0]*[lindex $num 1]]
		    } else { set NumCtrl $num }
		    for {set i 1} {$i <= $NumCtrl} {incr i} {
		        regexp {Point (.*) coords:(.*)$} [lindex $info $index] t \
		                ord val; incr index
		        set InfoListEnt($NumToUse,Ctrl$i) [format "%-6s %s" \
		                $ord $val ]
		    }
		}
		"Rational weights:" {
		    if { [llength $InfoListEnt($NumToUse,NCtrl)] == 2 } {
		        set NumCtrl [expr [lindex $InfoListEnt($NumToUse,NCtrl) 0]*\
		                [lindex $InfoListEnt($NumToUse,NCtrl) 1]]
		    } else { set NumCtrl $InfoListEnt($NumToUse,NCtrl) }
		    for {set i 1} {$i <= $NumCtrl} {incr i} {
		        set InfoListEnt($NumToUse,weights$i) [lindex $info $index]
		        incr index
		    }
		}
		"Number of knots=" {
		    set num [lindex $aa end]
		    set InfoListEnt($NumToUse,NKnots) $num
		    for {set i 1} {$i <= $num} {incr i} {
		        set aa [lindex $info $index]; incr index
		        set InfoListEnt($NumToUse,Knot$i) \
		                [string trimleft [lindex $aa 2] "value="]
		    }
		}
		"Number of knots in" {
		    regexp {in[ ]*([UVuv])=[ ]*([0-9]*)$} $aa t type num
		    set InfoListEnt($NumToUse,NKnots$type) $num
		    for {set i 1} {$i <= $num} {incr i} {
		        set aa [lindex $info $index]; incr index
		        set InfoListEnt($NumToUse,Knot$type$i) \
		                [string trimleft [lindex $aa 2] "value="]
		    }
		}
		IsTrimmed: {
		    set InfoListEnt($NumToUse,IsTrimmed) [lindex $aa 1]
		}
		"TotalLength" {
		    set num [lindex $aa 1]
		    set InfoListEnt($NumToUse,TotalLength) $num
		}
		"Num of Lines" {
		    set InfoListEnt($NumToUse,nlin) \
		            [string trimleft $aa "Num of Lines="]
		    if { $LastPolyNum == -1 } {
		        set LastPolyNum $NumToUse
		        set LastPolyNumLine 0
		    } else {
		        set LastPolyNumLine2 0
		    }
		    break
		}
		NumLines: {
		    set num [lindex $aa 1]
		    set InfoListEnt($NumToUse,nlin) $num
		    for {set i 1} {$i <= $num} {incr i} {
		        set aa [lindex $info $index]; incr index
		        set InfoListEnt($NumToUse,line$i) [lindex $aa 1]
		        if { [llength $aa]== 4 } {
		            set InfoListEnt($NumToUse,orien$i) [lindex $aa 3]
		        } else {
		            set InfoListEnt($NumToUse,orien$i) [lrange $aa 2 end]
		        }
		    }
		    
		}
		Center: {
		    set InfoListEnt($NumToUse,center) [lrange $aa 1 end]
		}
		Normal: {
		    set InfoListEnt($NumToUse,normal) [lrange $aa 1 end]
		}
		LAYER: {
		    set InfoListEnt($NumToUse,lay) [lindex $aa 1]
		}
		"Meshing Info:" {
		    set InfoListEnt($NumToUse,elmtype) \
		            [string trimleft [lindex $aa 3] "Elemtype="]

		    switch $InfoListEnt($NumToUse,elmtype) {
		        0 { set InfoListEnt($NumToUse,elmtype) None }
		        1 { set InfoListEnt($NumToUse,elmtype) Linear }
		        2 { set InfoListEnt($NumToUse,elmtype) Triangle }
		        3 { set InfoListEnt($NumToUse,elmtype) Quadrilateral }
		        4 { set InfoListEnt($NumToUse,elmtype) Tetrahedra }
		        5 { set InfoListEnt($NumToUse,elmtype) Hexahedra }
		        6 { set InfoListEnt($NumToUse,elmtype) Prisma }
		        7 { set InfoListEnt($NumToUse,elmtype) "Only points" }
		    }

		    set InfoListEnt($NumToUse,struc) \
		            [string trimleft [lindex $aa 4] \
		            "IsStructured="]
		    set InfoListEnt($NumToUse,size) \
		            [string trimleft [lindex $aa 5] "size="]
		    if { [string match weight=* [lindex $aa 6]] } {
		        set InfoListEnt($NumToUse,strucweight) \
		                [string trimleft [lindex $aa 6] "weight="]
		        set InfoListEnt($NumToUse,meshing) \
		                [string trimleft [lindex $aa 7] "Meshing="]
		    } else {
		        set InfoListEnt($NumToUse,meshing) \
		                [string trimleft [lindex $aa 6] "Meshing="]
		    }
		}
		"Num of Surfaces" {
		    set InfoListEnt($NumToUse,nsurf) \
		            [string trimleft $aa "Num of Surfaces="]
		    set LastPolySurfNum $NumToUse
		    set LastPolySurfNumSurf 0
		    set LastPolySurfNumIntLine -1
		    break
		}
		"Num of Interior Lines" {
		    set InfoListEnt($NumToUse,nintln) \
		            [string trimleft $aa "Num of InteriorLines="]
		    set LastPolySurfNumSurf -1
		    set LastPolySurfNumIntLine 0
		    break
		}
		NumSurfaces: {
		    set num [lindex $aa 1]
		    set InfoListEnt($NumToUse,nsur) $num
		    for {set i 1} {$i <= $num} {incr i} {
		        set aa [lindex $info $index]; incr index
		        set InfoListEnt($NumToUse,sur$i) [lindex $aa 1]
		        set InfoListEnt($NumToUse,orien$i) [lindex $aa 3]
		    }
		}
		"Segments used for special 4-sided surfaces:" {
		    set InfoListEnt($NumToUse,segments) [lindex $info $index]; incr index
		}
		"TRANSFORMATION MATRIX:" {
		    set InfoListEnt($NumToUse,matrix,row1) [lindex $info $index]; incr index
		    set InfoListEnt($NumToUse,matrix,row2) [lindex $info $index]; incr index
		    set InfoListEnt($NumToUse,matrix,row3) [lindex $info $index]; incr index
		    set InfoListEnt($NumToUse,matrix,row4) [lindex $info $index]; incr index
		}

		"Current result:" {
		    if { "$InfoListEnt($NumToUse,type)" == "POSTNODES" } {
		        set InfoListEnt($NumToUse,CurrentResultName) [ lindex $aa 2]
		        set InfoListEnt($NumToUse,CurrentResultValues) [ lindex $aa 3]
		    } elseif { "$InfoListEnt($NumToUse,type)" == "POSTELEMENTS" } {
		        set InfoListEnt($NumToUse,CurrentResultName) [ lindex $aa 2]
		        set InfoListEnt($NumToUse,CurrentResultValues) [ lindex $aa 3]
		    }
		}

		"More results:" {
		    if { "$InfoListEnt($NumToUse,type)" == "POSTNODES" } {
		        set InfoListEnt($NumToUse,MoreResults) [ lindex $aa 2]
		    } elseif { "$InfoListEnt($NumToUse,type)" == "POSTELEMENTS" } {
		        set InfoListEnt($NumToUse,MoreResults) [ lindex $aa 2]
		    }
		}

		"Gauss points:" {
		    if { "$InfoListEnt($NumToUse,type)" == "POSTELEMENTS" } {
		        set InfoListEnt($NumToUse,GaussPoints) [ lrange $aa 2 end]
		    }
		}

		default {
		    if { $type == "NODES" } {
		        set InfoListEnt($NumToUse,coord) \
		            [lrange $aa 1 end]


		    }
		    if { $type == "ELEMENTS" } {
		        if { $InfoListEnt($NumToUse,mat) == 0 } {
		            set InfoListEnt($NumToUse,nodes) \
		                    [lrange $aa 1 end]
		        } else {
		            set InfoListEnt($NumToUse,nodes) \
		                    [lrange $aa 1 [expr [llength $aa]-2]]
		        }
		    }

		}
	    }
	}
    }
}
## End Victor

proc PutIniEnd { w inum } {
    global InfoListEnt 
    set cc [list [_ "Initial Pnt"] [_ "End Pnt"]]
    frame $w.coo
    for {set i 0} {$i < 2} {incr i} {
	label $w.coo.c$i -text "[lindex $cc $i]:"
	CreateEntry $w.coo.r$i [lindex $InfoListEnt($inum,pts) $i]
	pack $w.coo.c$i $w.coo.r$i \
		-side left -anchor w 

	GIDReportData::AddData [lindex $cc $i] [lindex $InfoListEnt($inum,pts) $i]
    }
    pack $w.coo -side top -fill x -pady 2

}

proc PutListBox { w num { havey no } { ysize 4 } } {

    frame $w.f$num
    scrollbar $w.f$num.xscroll -relief sunken \
	    -orient horizontal \
	    -command "$w.f$num.list \
	    xview"
    listbox $w.f$num.list -width 27 -height $ysize -xscroll \
	    "$w.f$num.xscroll set" -relief sunken \
	    -selectmode extended 
    if { $havey != "no" } {
	scrollbar $w.f$num.yscroll -relief sunken -command \
	    "$w.f$num.list yview"
	$w.f$num.list conf -yscroll "$w.f$num.yscroll set"
	pack $w.f$num.yscroll -side right -fill y
    }
    pack $w.f$num -side top  -fill both -padx 2 -pady 2 -expand yes
    pack $w.f$num.xscroll -side bottom -fill x
    pack $w.f$num.list -fill both -side top -expand yes
    $w.f$num.list del 0 end
}

proc PutText { w num { havey no } { ysize 4 } } {

    frame $w.f$num
    scrollbar $w.f$num.xscroll -relief sunken \
	    -orient horizontal \
	    -command "$w.f$num.text \
	    xview"
    text $w.f$num.text -width 27 -height $ysize -xscroll \
	    "$w.f$num.xscroll set" -relief sunken
    if { $havey != "no" } {
	scrollbar $w.f$num.yscroll -relief sunken -command \
	    "$w.f$num.text yview"
	$w.f$num.text conf -yscroll "$w.f$num.yscroll set"
	pack $w.f$num.yscroll -side right -fill y
    }
    pack $w.f$num -side top  -fill both -padx 2 -pady 2 -expand yes
    pack $w.f$num.xscroll -side bottom -fill x
    pack $w.f$num.text -fill both -side top -expand yes
    $w.f$num.text del 1.0 end
}

proc FillForSurface { w inum} {
    global InfoListEnt
    frame $w.coo1
    label $w.coo1.cc0 -text [_ "Num Lines"]
    CreateEntry $w.coo1.n0 $InfoListEnt($inum,nlin)
    pack $w.coo1.cc0 $w.coo1.n0 \
	    -side left -anchor w 
    pack $w.coo1 -side top -fill x -pady 2
    GIDReportData::AddData [_ "Num Lines"] $InfoListEnt($inum,nlin)
    
    PutListBox $w 1 yes

    $w.f1.list insert end [format "%-10s%s" Line \
	    Orientation]
    GIDReportData::AddData Line Orientation
    for {set i 1} {$i <= $InfoListEnt($inum,nlin)} {incr i} {
	$w.f1.list insert end \
		[format "%-4i        %s" \
		$InfoListEnt($inum,line$i) \
		"$InfoListEnt($inum,orien$i)"]
	GIDReportData::AddData $InfoListEnt($inum,line$i) "$InfoListEnt($inum,orien$i)"
    }
    set cc { Center Normal }
    set rr { center normal }
    for {set i 0} {$i < 2} {incr i} {
	frame $w.cou$i
	label $w.cou$i.cc -text [lindex $cc $i]:
	CreateEntry $w.cou$i.n $InfoListEnt($inum,[lindex $rr $i])
	pack $w.cou$i.cc  -side left -anchor w
	pack $w.cou$i.n -side right -anchor e -fill x -expand yes
	pack $w.cou$i -side top -fill x -pady 2
	GIDReportData::AddData [lindex $cc $i] $InfoListEnt($inum,[lindex $rr $i])
    }
}

proc FillForPolyline { w inum} {
    global InfoListEnt
    frame $w.coo1
    label $w.coo1.cc0 -text [_ "Num Lines"]
    CreateEntry $w.coo1.n0 $InfoListEnt($inum,nlin)
    pack $w.coo1.cc0 $w.coo1.n0 \
	    -side left -anchor w 
    pack $w.coo1 -side top -fill x -pady 2
    GIDReportData::AddData [_ "Num Lines"] $InfoListEnt($inum,nlin)
    
    PutListBox $w 1 yes
    $w.f1.list insert end [format "%-6s%-12s%-11s%s" Line \
	    Orientation Type Length]
    GIDReportData::AddData Line Orientation Type Length

    for {set i 1} {$i <= $InfoListEnt($inum,nlin)} {incr i} {
	$w.f1.list insert end \
		[format "%-6i%-12s%-11s%s" $i \
		$InfoListEnt($inum $i,orien) \
		$InfoListEnt($inum $i,type) \
		$InfoListEnt($inum $i,len)] 
	GIDReportData::AddData $i $InfoListEnt($inum $i,orien) $InfoListEnt($inum $i,type) $InfoListEnt($inum $i,len)
    }
    frame $w.buts
    entry $w.buts.e -width 5 -relief sunken
    $w.buts.e del 0 end
    $w.buts.e insert end 1
    set polynum [$w.n.num2 get]
    button $w.buts.b -text [_ "See"] -command \
	"ListPolyEntitiesEnt $w \"$polynum\" $InfoListEnt($inum,nlin) $w.buts.e"
    label $w.buts.l -text [_ "'Use Return'"]

    focus $w.buts.e
    set pp [winfo parent $w]
    bind $w.buts.e <Tab> "$pp.buts.next invoke ; break"
    bind $w.buts.e <Shift-Tab> "$pp.buts.prev invoke ; break"
    bind $w.buts.e <Return> "$w.buts.b invoke"
    
    bind $w.f1.list <ButtonRelease-1> "SelectMouseline $w"
    bind $w.f1.list <Double-Button-1> "$w.buts.b invoke ; break"

    pack $w.buts.e  $w.buts.b $w.buts.l -side left -padx 2 -pady 2
    pack  $w.buts -side top
    if { ![info exists InfoListEnt($inum,segments)] } {
	set InfoListEnt($inum,segments) NONE
    }
    set cc { Length "Use Pnts in meshing" "used segments"}
    set rr { len upim segments}
    for {set i 0} {$i < 3} {incr i} {
	frame $w.cou$i
	label $w.cou$i.cc -text [lindex $cc $i]:
	CreateEntry $w.cou$i.n $InfoListEnt($inum,[lindex $rr $i])
	pack $w.cou$i.cc  -side left -anchor w
	pack $w.cou$i.n -side left -anchor w
	pack $w.cou$i -side top -fill x -pady 2
	GIDReportData::AddData [lindex $cc $i] $InfoListEnt($inum,[lindex $rr $i])
    }
}


proc SelectMouseline { w } {
    $w.buts.e delete 0 end 
    $w.buts.e insert 0 \
	    [lindex [$w.f1.list get [$w.f1.list curselection]] 0]
} 

proc FrameForPolySurfLines { w iNumEnt} {
    global InfoListEnt

    frame $w
    frame $w.coo1
    label $w.coo1.cc0 -text [_ "Num Lines"]
    CreateEntry $w.coo1.n0 $InfoListEnt($iNumEnt,nlin)
    pack $w.coo1.cc0 $w.coo1.n0 \
	    -side left -anchor w 
    pack $w.coo1 -side top -fill x -pady 2
    GIDReportData::AddData [_ "Num Lines"] $InfoListEnt($iNumEnt,nlin)
    
    PutListBox $w 1 yes
    $w.f1.list insert end [format "%-10s%s" Line \
	    Orientation]
    GIDReportData::AddData Line Orientation
    for {set i 1} {$i <= $InfoListEnt($iNumEnt,nlin)} {incr i} {
	$w.f1.list insert end \
		[format "%-4i        %s" \
		$InfoListEnt($iNumEnt,line$i) \
		"$InfoListEnt($iNumEnt,orien$i)"]
	GIDReportData::AddData $InfoListEnt($iNumEnt,line$i) "$InfoListEnt($iNumEnt,orien$i)"
    }
    return $w
}


proc FrameForPolySurfSurfaces { w inum} {
    global InfoListEnt
    frame $w
    frame $w.coon1
     
    label $w.coon1.cc0 -text [_ "Num Surfaces"]
    CreateEntry $w.coon1.n0 $InfoListEnt($inum,nsurf)
    pack $w.coon1.cc0 $w.coon1.n0 \
	    -side left -anchor w 
    pack $w.coon1 -side top -fill x -pady 2
    GIDReportData::AddData [_ "Num Surfaces"] $InfoListEnt($inum,nsurf)
    
    PutListBox $w 1 yes
    $w.f1.list insert end [format "%-8s%-12s%-11s" Surface \
	    Orientation Type]
    GIDReportData::AddData Surface Orientation Type
    for {set i 1} {$i <= $InfoListEnt($inum,nsurf)} {incr i} {
	$w.f1.list insert end \
		[format "%-12i%-12s%-11s" $i \
		$InfoListEnt($inum S$i,orien) \
		$InfoListEnt($inum S$i,type)]
	GIDReportData::AddData $i $InfoListEnt($inum S$i,orien) $InfoListEnt($inum S$i,type)
    }
    return $w
}

proc FrameForPolySurfIntLines { w inum} {
    global InfoListEnt
    frame $w
    frame $w.coon2
     
    label $w.coon2.cc0 -text [_ "Num Int.Lines"]
    CreateEntry $w.coon2.n0 $InfoListEnt($inum,nintln)
    pack $w.coon2.cc0 $w.coon2.n0 \
	    -side left -anchor w 
    pack $w.coon2 -side top -fill x -pady 2
    GIDReportData::AddData [_ "Num Int.Lines"] $InfoListEnt($inum,nintln)
    
    PutListBox $w 1 yes
    $w.f1.list insert end [format "%-6s%s" Line Type]
    GIDReportData::AddData Line Type
    for {set i 1} {$i <= $InfoListEnt($inum,nintln)} {incr i} {
	$w.f1.list insert end \
		[format "%-6i%s" $i \
		$InfoListEnt($inum L$i,type)]
	GIDReportData::AddData $i $InfoListEnt($inum L$i,type)
    }
}

proc FillForVolume { w inum} {
    global InfoListEnt
    frame $w.coo1
    label $w.coo1.cc0 -text [_ "Num Surfaces"]
    CreateEntry $w.coo1.n0 $InfoListEnt($inum,nsur)
    pack $w.coo1.cc0 $w.coo1.n0 \
	    -side left -anchor w 
    pack $w.coo1 -side top -fill x -pady 2
    GIDReportData::AddData [_ "Num Surfaces"] $InfoListEnt($inum,nsur)
    
    PutListBox $w 1 yes
    $w.f1.list insert end [format "%-10s%s" Surface \
	    Orientation]
    GIDReportData::AddData Surface Orientation
    for {set i 1} {$i <= $InfoListEnt($inum,nsur)} {incr i} {
	$w.f1.list insert end \
		[format "%-4i        %s" \
		$InfoListEnt($inum,sur$i) \
		$InfoListEnt($inum,orien$i)]
	GIDReportData::AddData $InfoListEnt($inum,sur$i) $InfoListEnt($inum,orien$i)
    }
    frame $w.cou
    label $w.cou.cc -text [_ "Center:"]
    CreateEntry $w.cou.n $InfoListEnt($inum,center)
    pack $w.cou.cc  -side left -anchor w
    pack $w.cou.n -side right -anchor e
    pack $w.cou -side top -fill x -pady 2
    GIDReportData::AddData [_ "Center"] $InfoListEnt($inum,center)
}

proc FillForContactVolume { w inum} {
    global InfoListEnt
    
    PutListBox $w 1 no 3
    $w.f1.list insert end [format "%-10s%s" Surface \
	    Orientation]
    GIDReportData::AddData Surface Orientation
    for {set i 1} {$i <= $InfoListEnt($inum,nsur)} {incr i} {
	$w.f1.list insert end \
		[format "%-4i        %s" \
		$InfoListEnt($inum,sur$i) \
		$InfoListEnt($inum,orien$i)]
	GIDReportData::AddData $InfoListEnt($inum,sur$i) $InfoListEnt($inum,orien$i)
    }
    if { [info exists InfoListEnt($inum,matrix,row1)] } {
	PutListBox $w 2 yes 5
	$w.f2.list insert end "   Transformation matrix"
	GIDReportData::AddData "Transformation matrix"
	for {set i 1} {$i <= 4} {incr i} {
	    $w.f2.list insert end \
		    $InfoListEnt($inum,matrix,row$i)
	    GIDReportData::AddData $InfoListEnt($inum,matrix,row$i)
	}
    }
    frame $w.cou
    label $w.cou.cc -text [_ "Center:"]
    CreateEntry $w.cou.n $InfoListEnt($inum,center)
    pack $w.cou.cc  -side left -anchor w
    pack $w.cou.n -side right -anchor e
    pack $w.cou -side top -fill x -pady 2
    GIDReportData::AddData [_ "Center"] $InfoListEnt($inum,center)
}

proc FrameForNURBSurfLines { w iNumEnt} {
    global InfoListEnt

    frame $w
    frame $w.coo1
    label $w.coo1.cc0 -text [_ "Num Lines"]
    CreateEntry $w.coo1.n0 $InfoListEnt($iNumEnt,nlin)
    pack $w.coo1.cc0 $w.coo1.n0 \
	    -side left -anchor w 
    pack $w.coo1 -side top -fill x -pady 2
    
    GIDReportData::AddData [_ "Num Lines"] $InfoListEnt($iNumEnt,nlin)

    PutListBox $w 1 yes
    $w.f1.list insert end [format "%-10s%s" Line \
	    Orientation]
    GIDReportData::AddData Line Orientation

    for {set i 1} {$i <= $InfoListEnt($iNumEnt,nlin)} {incr i} {
	$w.f1.list insert end \
		[format "%-4i        %s" \
		$InfoListEnt($iNumEnt,line$i) \
		"$InfoListEnt($iNumEnt,orien$i)"]
	GIDReportData::AddData $InfoListEnt($iNumEnt,line$i) "$InfoListEnt($iNumEnt,orien$i)"
    }
    return $w
}

proc SignalControlPoint { list } {
    set sel [$list curselection]
    if { [llength $sel] == 1 } {
	set coords [lindex [$list get  [$list curselection]] 1]
	if { $coords != "" } {
	    GiD_Process escape escape escape escape utilities signalentities point nojoin $coords
	}
    }
}

proc FrameForNURBSurfPoints { w iNumEnt} {
    global InfoListEnt

    frame $w
    frame $w.coon1
    label $w.coon1.cc0 -text [_ "Num Points:"]
    CreateEntry $w.coon1.n0 $InfoListEnt($iNumEnt,NCtrl)

    label $w.coon1.cc1 -text [_ "Degree:"]
    CreateEntry $w.coon1.n1 $InfoListEnt($iNumEnt,degree)
    GIDReportData::AddData [_ "Degree"] $InfoListEnt($iNumEnt,degree)

    pack $w.coon1.cc0 $w.coon1.n0 $w.coon1.cc1 $w.coon1.n1\
	    -side left -anchor w 
    pack $w.coon1 -side top -fill x -pady 2

    if { [info exists InfoListEnt($iNumEnt,weights1)] } {
	label $w.coon2 -text [_ "Rational"]
	GIDReportData::AddData [_ "Rational"]
    } else {
	label $w.coon2 -text [_ "Non rational"]
	GIDReportData::AddData [_ "Non rational"]
    }
    pack $w.coon2 -side top -pady 2 -anchor w
    
    GIDReportData::AddData [_ "Num Points"] $InfoListEnt($iNumEnt,NCtrl)

    PutListBox $w 2 yes

    bind $w.f2.list <Double-Button-1> "SignalControlPoint $w.f2.list"

    if { [llength $InfoListEnt($iNumEnt,NCtrl)] == 2 } {
	set NumCtrl [expr [lindex $InfoListEnt($iNumEnt,NCtrl) 0]*\
		[lindex $InfoListEnt($iNumEnt,NCtrl) 1]]
    } else { set NumCtrl $InfoListEnt($iNumEnt,NCtrl) }

    if { ![info exists InfoListEnt($iNumEnt,weights1)] } {
	for {set i 1} {$i <= $NumCtrl} {incr i} {
	    $w.f2.list insert end $InfoListEnt($iNumEnt,Ctrl$i)
	    if { [ regexp {^([^ ]+) +([^ ]+)$} $InfoListEnt($iNumEnt,Ctrl$i) hola id coords]} {
		GIDReportData::AddData $id $coords
	    } else {
		GIDReportData::AddData $InfoListEnt($iNumEnt,Ctrl$i)
	    }
	}
    } else {
	for {set i 1} {$i <= $NumCtrl} {incr i} {
	    $w.f2.list insert end \
		    [format "%s W=%f" $InfoListEnt($iNumEnt,Ctrl$i) \
		    $InfoListEnt($iNumEnt,weights$i)]
	    if { [ regexp {^([^ ]+) +([^ ]+)$} $InfoListEnt($iNumEnt,Ctrl$i) hola id coords]} {
		GIDReportData::AddData $id $coords [ format "W=%f" $InfoListEnt($iNumEnt,weights$i)]
	    } else {
		GIDReportData::AddData $InfoListEnt($iNumEnt,Ctrl$i) [ format "W=%f" $InfoListEnt($iNumEnt,weights$i)]
	    }
	}
    }
    return $w
}

proc FrameForNURBSurfKnots { w iNumEnt {type ""} } {
    global InfoListEnt

    frame $w
    frame $w.coon2
    label $w.coon2.cc1 -text [_ "Num Knots:"]
    CreateEntry $w.coon2.n1 $InfoListEnt($iNumEnt,NKnots$type)
    pack $w.coon2.cc1 $w.coon2.n1 \
	    -side left -anchor w 
    pack $w.coon2 -side top -fill x -pady 2
    GIDReportData::AddData [_ "Num Knots $type"] $InfoListEnt($iNumEnt,NKnots$type)

    PutListBox $w 3 yes

    for {set i 1} {$i<= $InfoListEnt($iNumEnt,NKnots$type)} {incr i} {
	$w.f3.list insert end \
		[format "%-4i %s" $i \
		$InfoListEnt($iNumEnt,Knot$type$i)]
	GIDReportData::AddData $i "$InfoListEnt($iNumEnt,Knot$type$i)"
    }
    return $w
}

proc ShowEntity { w iNumEnt } {

    global InfoListEnt GIDDEFAULT

    GIDReportData::Reset

    catch { destroy $w }
    frame $w -relief ridge -bd 2

    # para quitarlos de cuando creamos el Scrolled Canvas
    bind [winfo toplevel $w] <4> {}
    bind [winfo toplevel $w] <5> {}

    pack propagate $w no
    pack $w -fill both -expand yes -side top

    set pp [winfo parent $w]
#    focus $pp.buts.next

    set type $InfoListEnt($iNumEnt,type)

    $pp.ltit conf -text $type

    GIDReportData::AddData [_ "Entity type"] $type

    frame $w.n
    label $w.n.num1 -text [_ "Num"]
    CreateEntry $w.n.num2 $iNumEnt
    GIDReportData::AddData [_ "Num"] $iNumEnt

    if { ( "$type" != "POSTNODES") && ( "$type" != "POSTELEMENTS")} {
	label $w.n.lay1 -text [_ "Layer"]
	set lay "*****"
	catch { set lay $InfoListEnt($iNumEnt,lay) }
	CreateEntry $w.n.lay2 $lay
	GIDReportData::AddData [_ "Layer"] $lay 

	pack $w.n.num1 $w.n.num2 \
		$w.n.lay1 \
		-side left -padx 5 -anchor w 
	pack $w.n.lay2 -side left -padx 5 -anchor w -expand yes -fill x
	
	set HigherEnt $InfoListEnt($iNumEnt,HigherEnt) 
	set cond $InfoListEnt($iNumEnt,cond)
	frame $w.n2
	label $w.n2.num1 -text [_ "HigherEnt:"]
	CreateEntry $w.n2.num2 $HigherEnt
	GIDReportData::AddData [_ "HigherEnt"] $HigherEnt

	label $w.n2.lay1 -text [_ "Cond"]:
	CreateEntry $w.n2.lay2 $cond
	GIDReportData::AddData [_ "Cond"] $cond

	pack $w.n2.num1 $w.n2.num2 \
		$w.n2.lay1 $w.n2.lay2 \
		-side left -padx 5 -anchor w 
    } else {
	pack $w.n.num1 $w.n.num2 -side left -padx 5 -anchor w 
	if { "$type" == "POSTELEMENTS"} {
	    label $w.n.tel -text $InfoListEnt($iNumEnt,TipoElemento) -bg grey80
	    pack $w.n.tel -side left -padx 5 -anchor w
	    GIDReportData::AddData [_ "Element type"] $InfoListEnt($iNumEnt,TipoElemento)
	}

	frame $w.n2 -bd 0

	if { ![ info exist InfoListEnt(SeparadorHorizontal)] } {
	    set InfoListEnt(SeparadorHorizontal) [ image create photo -file $GIDDEFAULT/bitmaps/sep_hori_largo2.gif]
	}

	label $w.n2.l -image $InfoListEnt(SeparadorHorizontal)
	pack $w.n2.l -pady 2

    }
    
    if { ( "$type" != "POSTNODES") && ( "$type" != "POSTELEMENTS")} {
	frame $w.m -bd 0
	frame $w.m2 -bd 0
	if { [catch { set elmtype $InfoListEnt($iNumEnt,elmtype) }] } {
	    label $w.m.l -text [_ "No meshing information"]
	    pack $w.m.l -side left -ipadx 4
	    GIDReportData::AddData [_ "No meshing information"]
	} else {
	    if { $InfoListEnt($iNumEnt,struc) == 0 } {
		set lnames { ElmType IsStruc Size Meshing }
	    } else { set lnames { ElmType IsStruc Num\ncells Meshing } }
	    set inames { elmtype struc size meshing }
	    for {set i 0} {$i < 2} {incr i} {
		label $w.m.l$i -text [lindex $lnames $i] -justify right
		CreateEntry $w.m.i$i $InfoListEnt($iNumEnt,[lindex $inames $i])
		GIDReportData::AddData [lindex $lnames $i] \
		        $InfoListEnt($iNumEnt,[lindex $inames $i])

		pack $w.m.l$i $w.m.i$i -side left
	    }
	    for {set i 2} {$i < 4} {incr i} {
		label $w.m2.l$i -text [lindex $lnames $i]
		CreateEntry $w.m2.i$i $InfoListEnt($iNumEnt,[lindex $inames $i])
		GIDReportData::AddData [lindex $lnames $i] \
		        $InfoListEnt($iNumEnt,[lindex $inames $i])
		pack $w.m2.l$i $w.m2.i$i -side left \
		        -anchor w 
	    }
	    if { [info exists InfoListEnt($iNumEnt,strucweight)] } {
	    #with weighs at start and end of line, are stored two values: (w0,w1)
	    #if { [expr abs($InfoListEnt($iNumEnt,strucweight))] > 1.0e-5 } {
		frame $w.m25
		label $w.m25.l -text [_ "Struct weight"]
		CreateEntry $w.m25.i $InfoListEnt($iNumEnt,strucweight)
		GIDReportData::AddData  [_ "Struct weight"] $InfoListEnt($iNumEnt,strucweight)

		pack $w.m25.l $w.m25.i -side left \
		        -anchor w 
	    #}
	    }
	}
	pack $w.n $w.n2 $w.m $w.m2 \
		-side top -pady 2 -fill x
	if { [winfo exists $w.m25] } {
	    pack $w.m25 -side top -pady 2 -fill x
	}
    } else {
	pack $w.n $w.n2 -side top -pady 2 -fill x
    }

    if { $InfoListEnt($iNumEnt,mat) != 0 } {
	frame $w.nm
	label $w.nm.mat -text [_ "Material:"]
	if { ( "$type" != "POSTNODES") && ( "$type" != "POSTELEMENTS")} {
	    CreateEntry $w.nm.mat2 $InfoListEnt($iNumEnt,mat)
	    GIDReportData::AddData [_ "Material"] $InfoListEnt($iNumEnt,mat)
	} else {
	    label $w.nm.mat2 -text $InfoListEnt($iNumEnt,mat) -bg grey80
	    GIDReportData::AddData [_ "Material"] $InfoListEnt($iNumEnt,mat)
	}
	pack $w.nm.mat $w.nm.mat2 \
		-side left -padx 5 -anchor w
	pack $w.nm -side top -anchor w 
    }

    switch $type {
	POINT {
	    set cc { x: y: z: }
	    for {set i 0} {$i < 3} {incr i} {
		frame $w.coo$i
		label $w.coo$i.cc -text [lindex $cc $i] \
		        -width 4
		CreateEntry $w.coo$i.n [lindex $InfoListEnt($iNumEnt,coord) $i]
		GIDReportData::AddData [lindex $cc $i] [lindex $InfoListEnt($iNumEnt,coord) $i]
		pack $w.coo$i.cc $w.coo$i.n \
		        -side left -anchor w 
		pack $w.coo$i -side top -fill x -pady 2
	    }
	}
	STLINE {
	    PutIniEnd $w $iNumEnt
	}
	ARCLINE {
	    PutIniEnd $w $iNumEnt
	    set cc { "2D center" Radius IniAng EndAng  }
	    set rr { 2DCEN rad iang eang }
	    for {set i 0} {$i < 4} {incr i} {
		frame $w.coo$i
		label $w.coo$i.cc -text "[lindex $cc $i]:"
		CreateEntry $w.coo$i.n $InfoListEnt($iNumEnt,[lindex $rr $i])
		GIDReportData::AddData [lindex $cc $i] $InfoListEnt($iNumEnt,[lindex $rr $i])
		pack $w.coo$i.cc  -side left -anchor w
		pack $w.coo$i.n -side left -anchor w
		pack $w.coo$i -side top -fill x -pady 2
	    }
	    PutListBox $w 1 yes
	    for {set i 1} {$i <= 4} {incr i} {
		$w.f1.list insert end \
		        $InfoListEnt($iNumEnt,mat$i)
		GIDReportData::AddData \
		        $InfoListEnt($iNumEnt,mat$i)
	    }
	}
	SPLINELINE {
	    PutIniEnd  $w $iNumEnt
	    set cc { "Num Points" "Num Knots" }
	    set rr { NCtrl NKnots }
	    frame $w.coo1
	    label $w.coo1.cc0 -text "[lindex $cc 0]:"
	    label $w.coo1.n0 -text \
		    $InfoListEnt($iNumEnt,[lindex $rr 0]) \
		    -relief sunken -width 4
	    pack $w.coo1.cc0 $w.coo1.n0 \
		    -side left -anchor w 
	    pack $w.coo1 -side top -fill x -pady 2
	    
	    set antes ""
	    set txt ""
	    PutListBox $w 1 yes
	    for {set i 1} {$i <= $InfoListEnt($iNumEnt,NCtrl)} {incr i} {
		$w.f1.list insert end \
		        [format "%-4i %s" $i \
		        $InfoListEnt($iNumEnt,Ctrl$i)]
		append txt ${antes}[format "%-4i %s" $i $InfoListEnt($iNumEnt,Ctrl$i)]
		set antes <br>
	    }
	    GIDReportData::AddData [lindex $cc 0] $txt

	    frame $w.coo2
	    label $w.coo2.cc1 -text "[lindex $cc 1]:"
	    label $w.coo2.n1 -text \
		    $InfoListEnt($iNumEnt,[lindex $rr 1]) \
		    -relief sunken -width 4
	    pack $w.coo2.cc1 $w.coo2.n1 \
		    -side left -anchor w 
	    pack $w.coo2 -side top -fill x -pady 2
	    set antes ""
	    set txt ""
	    PutListBox $w 2 yes
	    for {set i 1} {$i<= $InfoListEnt($iNumEnt,NKnots)} {incr i} {
		$w.f2.list insert end \
		        [format "%-4i %s" $i \
		        $InfoListEnt($iNumEnt,Knot$i)]
		append txt ${antes}[format "%-4i %s" $i $InfoListEnt($iNumEnt,Knot$i)]
		set antes <br>
	    }
	    GIDReportData::AddData [lindex $cc 1] $txt

	}
	NURBLINE {
	    PutIniEnd  $w $iNumEnt
	    frame $w.coo3
	    label $w.coo3.cc0 -text [_ "Length:"]
	    CreateEntry $w.coo3.n0 $InfoListEnt($iNumEnt,TotalLength)
	    GIDReportData::AddData [_ "Length"] $InfoListEnt($iNumEnt,TotalLength)

	    pack $w.coo3.cc0 $w.coo3.n0 -side left -anchor w 
	    pack $w.coo3 -side bottom -fill x -pady 2

	    FrameForNURBSurfPoints $w.f1 $iNumEnt
	    FrameForNURBSurfKnots $w.f2 $iNumEnt ""
	    optionbar $w.opt "Points $w.f1 {}" "Knots $w.f2 {}" 

	    pack $w.opt -fill both -expand yes -side top
	    
	}
	NURBSURFACE {

	    set cc { "Is trimmed" Center Normal }
	    set rr { IsTrimmed center normal }
	    for {set i 0} {$i < 3} {incr i} {
		frame $w.cou$i
		label $w.cou$i.cc -text [lindex $cc $i]:
		CreateEntry $w.cou$i.n $InfoListEnt($iNumEnt,[lindex $rr $i])
		GIDReportData::AddData [lindex $cc $i] $InfoListEnt($iNumEnt,[lindex $rr $i])

		pack $w.cou$i.cc  -side left -anchor w
		pack $w.cou$i.n -side right -anchor e -fill x -expand yes
		pack $w.cou$i -side bottom -fill x -pady 2
	    }

	    FrameForNURBSurfLines $w.f1 $iNumEnt
	    FrameForNURBSurfPoints $w.f2 $iNumEnt
	    FrameForNURBSurfKnots $w.f3 $iNumEnt U
	    FrameForNURBSurfKnots $w.f4 $iNumEnt V

	    optionbar $w.opt "Lines $w.f1 {}" "Points $w.f2 {}" \
		    "{Knots in U} $w.f3 {}" "{Knots in V} $w.f4 {}"

	    pack $w.opt -fill both -expand yes -side top

	}
	POLYLINE {
	    PutIniEnd $w $iNumEnt
	    FillForPolyline $w $iNumEnt
	}
	COONSURFACE {
	    FillForSurface $w $iNumEnt
	}
	PLSURFACE {
	    FillForSurface $w $iNumEnt
	}
	CONTACTSURFACE {
	    FillForSurface $w $iNumEnt
	}
	POLYSURFACE {
	    set cc { Center Normal }
	    set rr { center normal }
	    for {set i 0} {$i < 2} {incr i} {
		frame $w.cou$i
		label $w.cou$i.cc -text [lindex $cc $i]:
		CreateEntry $w.cou$i.n $InfoListEnt($iNumEnt,[lindex $rr $i])
		GIDReportData::AddData [lindex $cc $i] $InfoListEnt($iNumEnt,[lindex $rr $i])

		pack $w.cou$i.cc  -side left -anchor w
		pack $w.cou$i.n -side right -anchor e -fill x -expand yes
		pack $w.cou$i -side bottom -fill x -pady 2
	    }
	    FrameForPolySurfLines $w.f1 $iNumEnt
	    FrameForPolySurfSurfaces $w.f2 $iNumEnt
	    FrameForPolySurfIntLines $w.f3 $iNumEnt 

	    optionbar $w.opt "Lines $w.f1 {}" "Surfaces $w.f2 {}" \
		    "Int.Lines $w.f3 {}"

	    pack $w.opt -fill both -expand yes -side top
	}
	VOLUME {
	    FillForVolume $w $iNumEnt
	}
	CONTACTVOLUME {
	    FillForContactVolume $w $iNumEnt
	}
	NODES {
	    set cc { x y z }
	    for {set i 0} {$i < 3} {incr i} {
		frame $w.coo$i
		label $w.coo$i.cc -text [lindex $cc $i]: \
		        -width 5
		CreateEntry $w.coo$i.n [lindex $InfoListEnt($iNumEnt,coord) $i] 12
		GIDReportData::AddData [lindex $cc $i] [lindex $InfoListEnt($iNumEnt,coord) $i]

		pack $w.coo$i.cc $w.coo$i.n \
		        -side left -anchor w 
		pack $w.coo$i -side top -fill x -pady 2
	    }
	}
	ELEMENTS {
	    frame $w.coo
	    label $w.coo.cc -text [_ "Nodes:"] \
		    -width 6
	    CreateEntry $w.coo.n $InfoListEnt($iNumEnt,nodes)
	    GIDReportData::AddData [_ "Nodes"] $InfoListEnt($iNumEnt,nodes)
	    pack $w.coo.cc $w.coo.n \
		    -side left -anchor w -ipadx 2
	    pack $w.coo -side top -fill x -pady 2
	}

	POSTNODES {
	    frame $w.f
	    if { $InfoListEnt($iNumEnt,EsPuntoGauss)} {
		label $w.f.pgl -text [_ "Gauss Point"] -font BigFont
		pack $w.f.pgl -side left -anchor w -pady 2
		GIDReportData::AddData [_ "Gauss Point"]
	    }
	    set cc { x y z }
	    for {set i 0} {$i < 3} {incr i} {
		frame $w.f.coo$i
		label $w.f.coo$i.cc -text [lindex $cc $i]: \
		        -width 5
		CreateEntry $w.f.coo$i.n [lindex $InfoListEnt($iNumEnt,coord) $i] 12
		pack $w.f.coo$i.cc $w.f.coo$i.n \
		        -side left -anchor w 
		pack $w.f.coo$i -side top -fill x -pady 2
		GIDReportData::AddData [lindex $cc $i] [lindex $InfoListEnt($iNumEnt,coord) $i]
	    }
	    pack $w.f -side top -fill x -anchor w

	    if { [ info exist InfoListEnt($iNumEnt,CurrentResultName)] && \
		    ( $InfoListEnt($iNumEnt,CurrentResultName) != "") } {

		if { [ winfo exist $w.fc]} { destroy $w.fc}
		set c [ CreateScrolledCanvas $w.fc]

		bind [winfo toplevel $w] <4> "$c yview scroll -3 units"
		bind [winfo toplevel $w] <5> "$c yview scroll 3 units"

		pack $w.fc -fill both -expand yes

		frame $c.ressep
		label $c.ressep.s1 -image $InfoListEnt(SeparadorHorizontal)
		label $c.ressep.l -text [_ "Current result"] -font BigFont
		label $c.ressep.s2 -image $InfoListEnt(SeparadorHorizontal)
		pack $c.ressep.s1 $c.ressep.l $c.ressep.s2 -pady 2
		#pack $c.ressep -side top -fill x -pady 2
		GIDReportData::AddData [_ "Current result"]

		AddToScrolledCanvas $w.fc $c.ressep

		frame $c.curres -bd 0
		label $c.curres.l -text [ lindex $InfoListEnt($iNumEnt,CurrentResultName) 0]
		pack $c.curres.l -side left -anchor e -pady 2 -padx 2
		
		# para crear la entrada:    Vector   x: 2.3  y: 3.3 z: -3.0 ||: 45.3
		set comp_desc [ lindex $InfoListEnt($iNumEnt,CurrentResultName) 1]
		# switch $lr {
		#     4 {        set comp_desc "x y z |v|" }
		#     9 { set comp_desc "Sxx Syy Szz Sxy Syz Sxz Si Sii Siii" }
		#     3 { set comp_desc "A1 A2 A3" }
		# }

		set CurrentResultValues [ lindex $InfoListEnt($iNumEnt,CurrentResultValues) 0]

		set lr [ llength $CurrentResultValues]

		for { set ir 0} { $ir < $lr} { incr ir} {
		    set val [ lindex $CurrentResultValues $ir]
		    if { [ scan $val %g pp] == 1} {
		        set width_entry 10
		    } else {
		        set width_entry [ string length $val]
		    }

		    if { "[ lindex $comp_desc $ir]" == "" } {
		        CreateEntry $c.curres.e$ir $val $width_entry
		        #CreateEntry $c.curres.e$ir [ lindex $InfoListEnt($iNumEnt,CurrentResultValues) $ir]$val 10
		        pack $c.curres.e$ir -side left -anchor w -pady 2 -padx 2
		        if { !$ir} {
		            GIDReportData::AddData [ lindex $InfoListEnt($iNumEnt,CurrentResultName) 0] $val
		        } else {
		            GIDReportData::AddData {} $val
		        }
		    } else {
		        frame $c.curres.fe$ir -bd 0
		        set desc " [ lindex $comp_desc $ir]"
		        label $c.curres.fe$ir.l -text ${desc}:
		        CreateEntry $c.curres.fe$ir.e $val $width_entry
		        pack $c.curres.fe$ir.l $c.curres.fe$ir.e -side left -anchor w
		        pack $c.curres.fe$ir -side left -anchor w -pady 2 -padx 2
		        if { !$ir} {
		            GIDReportData::AddData [ lindex $InfoListEnt($iNumEnt,CurrentResultName) 0] "$desc" $val
		        } else {
		            GIDReportData::AddData {} "$desc" $val
		        }
		    }
		}
		#pack $c.curres -side top -fill x -pady 2

		AddToScrolledCanvas $w.fc $c.curres

	    }

	    if { [ info exist InfoListEnt($iNumEnt,MoreResults)] && \
		    ( $InfoListEnt($iNumEnt,MoreResults) != "") } {
		
		if { ![ info exist c] || ![ winfo exist $c]} {
		    if { [ winfo exist $w.fc]} { destroy $w.fc}
		    set c [ CreateScrolledCanvas $w.fc]

		    bind [winfo toplevel $w] <4> "$c yview scroll -3 units"
		    bind [winfo toplevel $w] <5> "$c yview scroll 3 units"

		    pack $w.fc -fill both -expand yes
		}

		frame $c.ressep2
		label $c.ressep2.s1 -image $InfoListEnt(SeparadorHorizontal)
		label $c.ressep2.l -text [_ "All results"] -font BigFont
		label $c.ressep2.s2 -image $InfoListEnt(SeparadorHorizontal)
		pack $c.ressep2.s1 $c.ressep2.l $c.ressep2.s2 -pady 2
		#pack $c.ressep2 -side top -fill x -pady 2
		GIDReportData::AddData [_ "All results"]

		AddToScrolledCanvas $w.fc $c.ressep2

		set ifr 0
		#WarnWinText "InfoListEnt($iNumEnt,MoreResults) = //$InfoListEnt($iNumEnt,MoreResults)//"
		frame $c.res -bd 0

		foreach res $InfoListEnt($iNumEnt,MoreResults) {
		    label $c.res.l$ifr -text [ lindex $res 0]

		    set comp_desc [ lindex $res 1]
		    # switch $lr {
		    #           4 {        set comp_desc "x y z |v|" }
		    #           9 { set comp_desc "Sxx Syy Szz Sxy Syz Sxz Si Sii Siii" }
		    #           3 { set comp_desc "A1 A2 A3" }
		    # }

		    set resval [ lindex [ lindex $res 2] 0]
		    set lr [ llength $resval]

		    grid $c.res.l$ifr -row $ifr -column 0 -sticky e -pady 2 -padx 2
		    frame $c.res.f$ifr -border 0
		    for { set ir 0} { $ir < $lr} { incr ir} {
		        set val [ lindex $resval $ir]
		        if { [ scan $val %g pp] == 1} {
		            set width_entry 10
		        } else {
		            set width_entry [ string length $val]
		        }

		        if { "[ lindex $comp_desc $ir]" == "" } {
		            CreateEntry $c.res.f${ifr}.e$ir $val $width_entry
		            # CreateEntry $c.res.e${ifr}_$ir [ lindex $resval $ir] 10
		            #grid $c.res.e${ifr}_$ir -row $ifr -column [ expr $ir + 1] -sticky w -pady 2
		            grid $c.res.f${ifr}.e$ir -row 0 -column $ir -sticky w
		            if { !$ir} {
		                GIDReportData::AddData [ lindex $res 0] $val
		            } else {
		                GIDReportData::AddData {} $val
		            }
		        } else {
		            frame $c.res.f${ifr}.fe$ir -bd 0
		            set desc " [ lindex $comp_desc $ir]"

		            label $c.res.f${ifr}.fe$ir.l -text ${desc}:
		            CreateEntry $c.res.f${ifr}.fe$ir.e $val $width_entry
		            grid $c.res.f${ifr}.fe$ir.l $c.res.f${ifr}.fe$ir.e -sticky e

		            #grid $c.res.fe${ifr}_$ir -row $ifr -column [ expr $ir + 1] -sticky w -pady 2
		            grid $c.res.f${ifr}.fe$ir -row 0 -column $ir -sticky w

		            if { !$ir} {
		                GIDReportData::AddData [ lindex $res 0] "$desc" $val
		            } else {
		                GIDReportData::AddData {} "$desc" $val
		            }
		        }
		    }
		    grid $c.res.f$ifr -row $ifr -column 1 -sticky w -pady 2 -padx 2
		    #pack $c.res$ifr -side top -fill x -pady 2
		    incr ifr
		}

		AddToScrolledCanvas $w.fc $c.res
		label $c.s1 -image $InfoListEnt(SeparadorHorizontal)
		AddToScrolledCanvas $w.fc $c.s1
	    }
	}

	POSTELEMENTS {
	    frame $w.coo
	    label $w.coo.cc -text [_ "Nodes:"] \
		    -width 6
	    CreateEntry $w.coo.n $InfoListEnt($iNumEnt,nodes)
	    pack $w.coo.cc $w.coo.n \
		    -side left -anchor w -ipadx 2
	    pack $w.coo -side top -fill x -pady 2
	    GIDReportData::AddData [_ "Nodes"] $InfoListEnt($iNumEnt,nodes)

	    if { [ info exist InfoListEnt($iNumEnt,GaussPoints)] && \
		    ( $InfoListEnt($iNumEnt,GaussPoints) != "") } {

		if { [ winfo exist $w.fc]} { destroy $w.fc}
		set c [ CreateScrolledCanvas $w.fc]

		bind [winfo toplevel $w] <4> "$c yview scroll -3 units"
		bind [winfo toplevel $w] <5> "$c yview scroll 3 units"

		pack $w.fc -fill both -expand yes

		frame $c.pgsep
		label $c.pgsep.s1 -image $InfoListEnt(SeparadorHorizontal)
		label $c.pgsep.l -text [_ "Gauss points"] -font BigFont
		label $c.pgsep.s2 -image $InfoListEnt(SeparadorHorizontal)
		pack $c.pgsep.s1 $c.pgsep.l $c.pgsep.s2 -pady 2
		#pack $c.pgsep -side top -fill x -pady 2
		GIDReportData::AddData [_ "Gauss points"]

		AddToScrolledCanvas $w.fc $c.pgsep

		set ifr 0
		#WarnWinText "InfoListEnt($iNumEnt,GaussPoints) = //$InfoListEnt($iNumEnt,GaussPoints)//"
		frame $c.pg -bd 0
		foreach res $InfoListEnt($iNumEnt,GaussPoints) {
		    set gp_name "[ lindex $res 0]: "
		    label $c.pg.l$ifr -text $gp_name
		    grid $c.pg.l$ifr -row $ifr -column 0 -sticky e -pady 2
		    set desc "[ lindex $res 1] points, "
		    append desc "[ lindex $res 2]"
		    if { [ llength $res] == 4} {
		        append desc ", [ lindex $res 3]"
		    }
		    CreateEntry $c.pg.e$ifr $desc 40
		    grid $c.pg.e$ifr -row $ifr -column 1 -sticky w -pady 2

		    GIDReportData::AddData $gp_name $desc
		    
		    incr ifr
		}
		#pack $c.pg -side top -fill x -pady 2

		AddToScrolledCanvas $w.fc $c.pg
	    }

	    if { [ info exist InfoListEnt($iNumEnt,CurrentResultName)] && \
		    ( $InfoListEnt($iNumEnt,CurrentResultName) != "") } {

		if { ![ info exist c] || ![ winfo exist $c]} {
		    if { [ winfo exist $w.fc]} { destroy $w.fc}
		    set c [ CreateScrolledCanvas $w.fc]

		    bind [winfo toplevel $w] <4> "$c yview scroll -3 units"
		    bind [winfo toplevel $w] <5> "$c yview scroll 3 units"

		    pack $w.fc -fill both -expand yes
		}

		frame $c.ressep
		label $c.ressep.s1 -image $InfoListEnt(SeparadorHorizontal)
		label $c.ressep.l -text [_ "Current result"] -font BigFont
		label $c.ressep.s2 -image $InfoListEnt(SeparadorHorizontal)
		pack $c.ressep.s1 $c.ressep.l $c.ressep.s2 -pady 2
		#pack $c.ressep -side top -fill x -pady 2
		GIDReportData::AddData [_ "Current result"]

		AddToScrolledCanvas $w.fc $c.ressep

		frame $c.curres -bd 0
		frame $c.curres.fn -bd 0
		label $c.curres.fn.l -text [ lindex $InfoListEnt($iNumEnt,CurrentResultName) 0]
		# -width 20
		label $c.curres.fn.lpg -text [_ "on '%s'" [ lindex $InfoListEnt($iNumEnt,CurrentResultName) 1]]

		set res_name [ lindex $InfoListEnt($iNumEnt,CurrentResultName) 0]
		append res_name " "
		append res_name [_ "on '%s'" [ lindex $InfoListEnt($iNumEnt,CurrentResultName) 1]]

		# -width 20
		#pack $c.curres.l -side left -anchor w -pady 2
		grid $c.curres.fn.l -sticky ne -pady 2
		grid $c.curres.fn.lpg -sticky ne -pady 2

		set comp_desc [ lindex $InfoListEnt($iNumEnt,CurrentResultName) 2]
		frame $c.curres.fv -bd 0
		set l 0
		foreach iv $InfoListEnt($iNumEnt,CurrentResultValues) {
		    set lr [ llength $iv]
		
		    # para crear la entrada:    Vector   x: 2.3  y: 3.3 z: -3.0 ||: 45.3

		    for { set ir 0} { $ir < $lr} { incr ir} {
		        set val [ lindex $iv $ir]
		        if { [ scan $val %g pp] == 1} {
		            set width_entry 10
		        } else {
		            set width_entry [ string length $val]
		        }

		        if { "[ lindex $comp_desc $ir]" == "" } {
		            CreateEntry $c.curres.fv.e${l}_$ir [ lindex $iv $ir] $width_entry
		            #CreateEntry $c.curres.e${l}_$ir [ lindex $iv $ir] 10
		            #pack $c.curres.e$ir -side left -anchor w -pady 2
		            grid $c.curres.fv.e${l}_$ir -row $l -column $ir -sticky w
		            if { !$l && !$ir} {
		                GIDReportData::AddData $res_name [ lindex $iv $ir]
		            } else {
		                GIDReportData::AddData {} [ lindex $iv $ir]
		            }
		        } else {
		            frame $c.curres.fv.fe${l}_$ir -bd 0
		            set desc " [ lindex $comp_desc $ir]"
		            label $c.curres.fv.fe${l}_$ir.l -text ${desc}:
		            CreateEntry $c.curres.fv.fe${l}_$ir.e $val $width_entry
		            grid $c.curres.fv.fe${l}_$ir.l $c.curres.fv.fe${l}_$ir.e -sticky e
		            grid $c.curres.fv.fe${l}_$ir -row $l -column $ir -sticky w
		            if { !$l && !$ir} {
		                GIDReportData::AddData $res_name "$desc" $val
		            } else {
		                GIDReportData::AddData {} "$desc" $val
		            }
		        }
		    }
		    incr l
		}

		grid $c.curres.fn $c.curres.fv -sticky ne -pady 2 -padx 2
		    #pack $c.curres -side top -fill x -pady 2

		AddToScrolledCanvas $w.fc $c.curres

	    }

	    if { [ info exist InfoListEnt($iNumEnt,MoreResults)] && \
		    ( $InfoListEnt($iNumEnt,MoreResults) != "") } {

		if { ![ info exist c] || ![ winfo exist $c]} {
		    if { [ winfo exist $w.fc]} { destroy $w.fc}
		    set c [ CreateScrolledCanvas $w.fc]

		    bind [winfo toplevel $w] <4> "$c yview scroll -3 units"
		    bind [winfo toplevel $w] <5> "$c yview scroll 3 units"

		    pack $w.fc -fill both -expand yes
		}

		frame $c.ressep2
		label $c.ressep2.s1 -image $InfoListEnt(SeparadorHorizontal)
		label $c.ressep2.l -text [_ "All results"] -font BigFont
		label $c.ressep2.s2 -image $InfoListEnt(SeparadorHorizontal)
		pack $c.ressep2.s1 $c.ressep2.l $c.ressep2.s2 -pady 2
		#pack $c.ressep -side top -fill x -pady 2
		GIDReportData::AddData [_ "Al results"]

		AddToScrolledCanvas $w.fc $c.ressep2

		frame $c.res -bd 0
		set ir 0
		foreach or $InfoListEnt($iNumEnt,MoreResults) {
		    #label $c.res.l$ir -text [ lindex $or 0] -width 17
		    frame $c.res.fl$ir
		    label $c.res.fl$ir.l -text [ lindex $or 0]
		    label $c.res.fl$ir.lpg -text [_ "on '%s'" [ lindex $or 1]]
		    #pack $c.res.l -side left -anchor w -pady 2
		    #grid $c.res.l$ir -row $ir -column 0 -sticky ne -pady 2
		    grid $c.res.fl$ir.l -sticky ne
		    grid $c.res.fl$ir.lpg -sticky ne
		    set res_name [ lindex $or 0]
		    append res_name " "
		    append res_name [_ "on '%s'" [ lindex $or 1]]
		    set comp_desc [ lindex $or 2]
		    
		    frame $c.res.f$ir -bd 0
		    set ifr 0
		    foreach iv [ lindex $or 3] {
		        set lr [ llength $iv]
		
		        # para crear la entrada:    Vector   x: 2.3  y: 3.3 z: -3.0 |v|: 45.3
		        for { set iir 0} { $iir < $lr} { incr iir} {
		            set val [ lindex $iv $iir]
		            if { [ scan $val %g pp] == 1} {
		                set width_entry 10
		            } else {
		                set width_entry [ string length $val]
		            }
#WarnWin "-[ lindex $comp_desc $iir]-  -row $ifr -column $iir"
		            if { "[ lindex $comp_desc $iir]" == "" } {
		                CreateEntry $c.res.f${ir}.e${ifr}_$iir $val $width_entry
		                #CreateEntry $c.res.e${ir}_$iir [ lindex $iv $iir] 10
		                #pack $c.res.e$ir -side left -anchor w -pady 2
		                #grid $c.res.f${ir}.e$iir -row $ir -column [ expr $iir + 1] -sticky w -pady 2
		                grid $c.res.f${ir}.e${ifr}_$iir -row $ifr -column $iir -sticky w
		                if { !$ifr && !$iir} {
		                    GIDReportData::AddData $res_name $val
		                } else {
		                    GIDReportData::AddData {} $val
		                }
		            } else {
		                frame $c.res.f${ir}.fe${ifr}_$iir -bd 0
		                set desc " [ lindex $comp_desc $iir]"
		                label $c.res.f${ir}.fe${ifr}_$iir.l -text ${desc}:
		                CreateEntry $c.res.f${ir}.fe${ifr}_$iir.e $val $width_entry
		                # grid $c.res.fe${ir}_$iir.l $c.res.fe${ir}_$iir.e -sticky e
		                # grid $c.res.fe${ir}_$iir -row $ir -column [ expr $iir + 1] -sticky w -pady 2
		                grid $c.res.f${ir}.fe${ifr}_$iir.l $c.res.f${ir}.fe${ifr}_$iir.e -sticky e
		                grid $c.res.f${ir}.fe${ifr}_$iir -row $ifr -column $iir -sticky w
		                if { !$ifr && !$iir} {
		                    GIDReportData::AddData $res_name "$desc" $val
		                } else {
		                    GIDReportData::AddData {} "$desc" $val
		                }
		            }
		        }
		        incr ifr
		    }
		    #pack $c.res -side top -fill x -pady 2
		    grid $c.res.fl$ir -row $ir -column 0 -sticky ne -pady 2 -padx 2
		    grid $c.res.f$ir -row $ir -column 1 -sticky nw -pady 2 -padx 2
		    incr ir
		}

		AddToScrolledCanvas $w.fc $c.res
	    }

	}
    }
    set InfoListEnt(ReportData) [ GIDReportData::GetDataHTML 1] 
}

proc ListPolyEntitiesEnt { w entnum maxnum entr} {
    set inum [$entr get]
    if { $inum <= 0 || $inum > $maxnum } {
	set w2 [winfo parent $w]
	mkDialogN $w2.modal [list -text [_ "Line number out of limits"] -aspect 250 \
		-justify left] [list [_ "Ok"] OK ]
	return
    }
    ListPolyEntities $w.enti $inum $entnum $maxnum
}

proc ChangeFocusTo { w } {

    if { [winfo exists $w.enti.buts.e] } { 
	focus $w.enti.buts.e
    } else { catch { focus $w.buts.next } }

}

proc ListPolyEntities { w inum entnum maxnum } {

    set inumnext [expr $inum+1]
    if { $inumnext > $maxnum } { set inumnext 1 }
    set inumprev [expr $inum-1]
    if { $inumprev <= 0 } { set inumprev $maxnum }
    if { ![winfo exists $w] } {
	InitWindow $w [_ "List Poly Entities"] ListPolyEntitiesWindowGeom
	set x [ winfo x [winfo parent [winfo parent $w]]]
	set y [ winfo y [winfo parent [winfo parent $w]]]
	wm geometry $w 210x420+[expr $x+20]+[expr $y-100]
	wm minsize $w 210 420

	label $w.ltit -relief ridge -bd 3 -bg white -width 25
	frame $w.buts
	button $w.buts.list -text [_ "List"]
	button $w.buts.prev -text [_ "Prev"] 
	button $w.buts.next -text [_ "Next"]
	bind $w <Tab> "$w.buts.next invoke ; break "
	bind $w <Shift-Tab> "$w.buts.prev invoke ; break"
	button $w.buts.close -text [_ "Close"] -command "destroy $w"
	label $w.d -text [_ "Use 'Tab' and 'Shift-Tab'"]
	pack $w.buts.list $w.buts.prev $w.buts.next $w.buts.close \
		-side left -ipadx 1

	pack $w.ltit -side top
	pack $w.d $w.buts -side bottom
    }
    $w.buts.prev conf -command "ListPolyEntities $w $inumprev \"$entnum\" $maxnum"
    $w.buts.next conf -command "ListPolyEntities $w $inumnext \"$entnum\" $maxnum"
    set entnum "$entnum $inum"
    ShowEntity $w.enti $entnum
}

proc NextEntity { iNumEntList w } {
    global ListOfEnt NumEntList
    incr iNumEntList
    if { $iNumEntList >= $NumEntList } { set iNumEntList 0 }
    ShowEntity $w.enti [lindex $ListOfEnt $iNumEntList]
    $w.buts.next conf -command "NextEntity $iNumEntList $w"
    $w.buts.prev conf -command "PrevEntity $iNumEntList $w"
}

proc PrevEntity { iNumEntList w } {
    global ListOfEnt NumEntList
    incr iNumEntList -1
    if { $iNumEntList < 0 } { 
	set iNumEntList [expr $NumEntList-1]
    }
    ShowEntity $w.enti [lindex $ListOfEnt $iNumEntList]
    $w.buts.next conf -command "NextEntity $iNumEntList $w"
    $w.buts.prev conf -command "PrevEntity $iNumEntList $w"
}

proc CloseListWindow { w } {
    global NumListWindows
    incr NumListWindows -1
    if { $NumListWindows < 0 } { set NumListWindows 0 }
    if { $NumListWindows == 0 } {
	catch { unset ListOfEnt }
	catch { unset InfoListEnt }
    }
    destroy $w
}

## Victor
proc ListEntities { listorder {w .listent }} {
    global wListEnt ListOfEnt NumEntList NumListWindows InfoListEnt

    if { ![winfo exists $w] } {
	if { [InitWindow $w [_ "List Entities"] ListEntitiesWindowGeom] == "close" } {
	    return
	}
    } else { raise $w }
    
    if { ![info exists NumListWindows] || $NumListWindows == 0 } { 
	set NumListWindows 1
    }
    if { $listorder == "" } {
	incr NumListWindows
    } else {
	for {set i 2} {$i <= $NumListWindows} {incr i} {
	    CloseListWindow .listent$i
	}
    }


    if { $NumListWindows != 1 } {
	if { $NumListWindows == 2 } {
	    set wbefore .listent
	} else { set wbefore .listent[expr $NumListWindows-1] }
	catch {
	regexp {([^x]*)x([^+-]*)([+-][^+-]*)([+-].*)} [wm geom $wbefore] trash \
		wf hf xf yf

	set yfnew [expr $yf-20]
	if { $yfnew<0 && $yf>=0 } { set yfnew -0}
	if { $yfnew > 0 } { set yfnew +$yfnew }

	if { $yf > 0 } { set yf +$yf }
	wm geometry $w [join "$wf x $hf $xf $yfnew" ""]
	}
    }

    set wListEnt $w
    if { ![winfo exists $w.ltit] } {
	label $w.ltit -relief ridge -bd 3 -bg white -width 25
    }
    if { ![winfo exists $w.buts] } {
	frame $w.buts
	button $w.buts.list -text [_ "List"] -command "MakeListOfEnt $w [list $listorder]" 
#         button $w.buts.prev -text Prev -command {
#             incr iNumEntList -1
#             if { $iNumEntList < 0 } { 
#                 set iNumEntList [expr $NumEntList-1]
#             }
#             ShowEntity $wListEnt.enti [lindex $ListOfEnt $iNumEntList]
#         }
#         button $w.buts.next -text Next -command {
#             incr iNumEntList
#             if { $iNumEntList >= $NumEntList } { set iNumEntList 0 }
#             ShowEntity $wListEnt.enti [lindex $ListOfEnt $iNumEntList]
#         }


	button $w.buts.prev -text [_ "Prev"] -command "PrevEntity 0 $w"
	button $w.buts.next -text [_ "Next"] -command "NextEntity 0 $w"


	button $w.buts.close -text [_ "Close"] -command "CloseListWindow $w"
	button $w.buts.clone -text [_ "Clone"] -command {
		ListEntities {} .listent[expr $NumListWindows+1]
	}
	button $w.buts.toReport -image [ GIDReport::GetImage ToReport] -command {
	    global InfoListEnt
	    if { "$InfoListEnt(ReportData)" != ""} {
		GIDReport::AddToReport $InfoListEnt(ReportData)
	    }
	}
	GiDPopUpHelp $w.buts.toReport [ GIDReport::GetHelpForImage ToReport]

	label $w.d
	#miguel 18.4.2000
    } else {
	$w.buts.list conf -command "MakeListOfEnt $w [list $listorder]" 
	#end miguel 18.4.2000
    }

    $w.d conf -text [_ "Use 'Tab' and 'Shift-Tab'"]
    bind $w <Tab> "$w.buts.next invoke ; break"
    bind $w <Shift-Tab> "$w.buts.prev invoke  ; break"
    catch {
	bind $w <ISO_Left_Tab> "$w.buts.prev invoke  ; break"
    }
    pack forget $w.buts.close
    pack $w.buts.list $w.buts.prev $w.buts.next $w.buts.close \
	    $w.buts.clone -side left -ipadx 1
    pack $w.buts.toReport -side right -ipadx 1
    
    pack $w.ltit -side top
    pack $w.d $w.buts -side bottom -fill x

#    focus $w.buts.next
    if { $listorder != "" } {
	catch {
	    unset ListOfEnt 
	    unset NumEntList
	}
	catch { unset InfoListEnt }
	ReadListEnt $w $listorder
    }

    if { $NumEntList > 0 } { ShowEntity $w.enti [lindex $ListOfEnt 0] }


    # la ventana de "List Entitities Tot"
    #miguel 18.4.2000
    set w2 $w.list
    if { [winfo exists $w2] } { 
	MakeListOfEnt $w [list $listorder]
    }
    #end miguel 18.4.2000

}
## End Victor

#----------------------LIST ENTITIES ALONE------------------------
# if { $ListEntRunningAlone == 1 } {
#     ListEntities [lindex $argv 0]
# } 
#-----------------------------------------------------------------
