#! /bin/sh
# the next line restarts using wish8.0 \
exec wish8.0 "$0" "$@"

# interface generated by SpecTcl version 1.1 from /usr2/people/ramsan/bin/specsamples/pref_meshing.ui
#   root     is the parent window for this user interface

proc pref_meshing_ui {root args} {

	# this treats "." as a special case
	global GidPriv

	if {$root == "."} {
	    set base ""
	} else {
	    set base $root
	}
    
	frame $base.frame#2 \
		-borderwidth 2 \
		-relief ridge

	frame $base.frame#4 \
		-borderwidth 2 \
		-relief ridge

	frame $base.frame#1 \
		-borderwidth 2 \
		-relief ridge

	frame $base.frame#5 \
		-borderwidth 2 \
		-relief ridge

	label $base.label#6 \
                -text [_ "Surface mesher:"]

	radiobutton $base.radiobutton#1 \
	        -text [_ "RFast"] \
		-variable ChangeVarInfo(SurfaceMesher) -value 0

	radiobutton $base.radiobutton#2 \
	        -text [_ "RSurf"] \
		-variable ChangeVarInfo(SurfaceMesher) -value 1

	radiobutton $base.radiobutton#3 \
	        -text [_ "2Dumg"] \
		-variable ChangeVarInfo(SurfaceMesher) -value 2

	#radiobutton $base.radiobutton#4 \
	#	-text [_ "RJump"] \
	#	-variable ChangeVarInfo(SurfaceMesher) -value 4

	GidHelp "$base.frame#2 $base.label#6 $base.radiobutton#1 \
		$base.radiobutton#2 $base.radiobutton#3 $base.radiobutton#4 " \
	        [_ "Surface meshers can be:\
		\n'Rfast': The most efficient in speed and reliability. With\
		deformed surfaces can give distorted elements.\
		\n'Rsurf': Meshes are generated directly in the space.\
		Quality is better but it is slower and can fail for distorted\
		surfaces.\
		\n'2dumg': The use of this mesher is deprecated."]
	#	"\n'2dumg': The use of this mesher is deprecated." \
	#	"\n'Rjump': Mesh in the space, but trying to jump the lines between surfaces."

#      GidHelp "$base.frame#2 $base.label#6 $base.radiobutton#1 \
#		$base.radiobutton#2 $base.radiobutton#3 " "Surface meshers can be:"\
#		"\n'Rfast': The most efficient in speed and reliability. With "\
#		"deformed surfaces can give distorted elements."\
#		"\n'Rsurf': Meshes are generated directly in the space. "\
#		"Quality is better but it is slower and can fail for distorted "\
#		"surfaces."\
#		"\n'2dumg': The use of this mesher is deprecated."


	checkbutton $base.checkbutton#1 \
                -text [_ "Mesh until end"] \
		-variable ChangeVarInfo(MeshUntilEnd)

	GidHelp $base.checkbutton#1 [_ "If this preference is set, the mesh\
		generator will continue until end although there are surfaces\
		or volumes that cannot be meshed."]

	checkbutton $base.checkbutton#2 \
	        -text [_ "Automatic correct sizes"] \
		-variable ChangeVarInfo(AutomaticCorrectSizes)

	GidHelp $base.checkbutton#2 [_ "If this preference is set, just when meshing\
		begins, there is a correction to the meshing sizes assigned to\
		entities so as to improve meshing."]

	label $base.label#4 \
	        -text [_ "Unstructured size transitions"]

	button $base.button#4 \
		-command {set ChangeVarInfo(SizeTransitions) [expr $ChangeVarInfo(SizeTransitions)-0.1]} \
		-disabledforeground grey60 \
		-text -

	scale $base.scale#4 \
		-highlightbackground black \
                -label [_ "slower"] \
		-length 1 \
		-orient h \
		-resolution 0.1 \
		-to 1.0 \
		-variable ChangeVarInfo(SizeTransitions) \
		-width 16

	button $base.button#3 \
		-command {set ChangeVarInfo(SizeTransitions) [expr $ChangeVarInfo(SizeTransitions)+0.1]} \
		-disabledforeground grey60 \
		-text +

	GidHelp "$base.frame#1 $base.label#4 $base.button#4 $base.scale#4 \
	        $base.button#3" [_ "It controls whether the transitions between\
	        different element sizes are slow or fast."]



	checkbutton $base.checkbutton#3 \
	        -text [_ "No mesh frozen layers"] \
		-variable ChangeVarInfo(NoMeshFrozenLayers)

	GidHelp $base.checkbutton#3 [_ "If this preference is set, no mesh will\
	        be generated over entities that belong to frozen layers. "]

	checkbutton $base.checkbutton#4 \
	        -text [_ "Allow automatic structured"] \
		-variable ChangeVarInfo(AllowAutomaticStructured)

	GidHelp $base.checkbutton#4 [_ "If this preference is set, functions\
		like 'Assign sizes by Cordal Error' will define some surfaces\
		as structured with highly distorted elements over them."]

	frame $base.frame#6

	label $base.label#7 \
	        -text [_ "Mesh always by default:"]
		# -wraplength 20m -justify left

	set pp [ $base cget -background]

	checkbutton $base.checkbutton#5 \
		-disabledforeground grey60 \
		-image $GidPriv(image_point16) \
		-indicatoron 0 \
		-variable ChangeVarInfo(ForceMeshPoints) -bd 1 -selectcolor $pp	
	
	checkbutton $base.checkbutton#6 \
		-disabledforeground grey60 \
		-image $GidPriv(image_line16) \
		-indicatoron 0 \
		-variable ChangeVarInfo(ForceMeshLines) -bd 1 -selectcolor $pp

	checkbutton $base.checkbutton#7 \
		-disabledforeground grey60 \
		-image $GidPriv(image_coonsurf16) \
		-indicatoron 0 \
		-variable ChangeVarInfo(ForceMeshSurfaces) -bd 1 -selectcolor $pp

	GidHelp "$base.label#7 $base.checkbutton#5 $base.checkbutton#6 $base.checkbutton#7" \
	        [_ "Changes the default meshing criteria. Entities will be always\
		meshed by default, although they have higher entities over them.\nExample:\
		If surfaces are checked, when meshing a volume, both volume elements and\
		surface elements will be obtained."]
	
	frame $base.frame#7
	label $base.label#8 \
	        -text [_ "Smoothing:"] -width 10 -justify left
	tk_optionMenuRAM $base.menubutton#1 ChangeVarInfo(HighQualitySmoothing) \
		[list [_ "Normal"] [_ "HighAngle"] [_ "HighGeom"]] \
		{"Normal" "HighAngle" "HighGeom"}
	$base.menubutton#1 conf -textvariable ChangeVarInfo(HighQualitySmoothing) -width 8 -anchor w

	GidHelp  "$base.label#8 $base.menubutton#1" [_ "Options for smoothing in order to enhance\
                the mesh after the generation. Options are:\
		\nNormal: only the standard smooth is performed\
		\nHighAngle: an additional smooth with angle criteria is performed\
		\nHighGeom: an additional smooth with cordal error criteria is performed"]
	

	# Geometry management

	grid $base.frame#2 -in $root	-row 1 -column 1 -sticky nesw -padx 6 -pady 3
	grid $base.frame#4 -in $root	-row 2 -column 1  -sticky nesw -padx 6 -pady 3
	grid $base.frame#1 -in $root	-row 3 -column 1  \
		-padx 6 \
		-sticky nesw -pady 3
	grid $base.frame#5 -in $root	-row 4 -column 1  -sticky nesw -padx 6 -pady 3
	grid $base.label#6 -in $base.frame#2	-row 1 -column 1  \
		-columnspan 3 \
		-sticky w
	grid $base.radiobutton#1 -in $base.frame#2	-row 2 -column 1 
	grid $base.radiobutton#2 -in $base.frame#2	-row 2 -column 2 
	grid $base.radiobutton#3 -in $base.frame#2	-row 2 -column 3 
	#grid $base.radiobutton#4 -in $base.frame#2	-row 2 -column 4 

	grid $base.checkbutton#1 -in $base.frame#4 -row 1 -column 1 -sticky nw
	grid $base.checkbutton#2 -in $base.frame#4 -row 2 -column 1 -sticky nw
	grid $base.label#4 -in $base.frame#1	-row 1 -column 1  \
		-columnspan 3
	grid $base.button#4 -in $base.frame#1	-row 2 -column 1 
	grid $base.scale#4 -in $base.frame#1	-row 2 -column 2  \
		-sticky nesw
	grid $base.button#3 -in $base.frame#1	-row 2 -column 3 

	grid $base.checkbutton#3 -in $base.frame#5 -row 1 -column 1 -sticky nw
	grid $base.checkbutton#4 -in $base.frame#5 -row 2 -column 1 -sticky nw

	grid $base.frame#6 -in $base.frame#5 -row 3 -column 1 -sticky nw -padx 3 -pady 3
	grid $base.label#7 -in $base.frame#6 -row 1 -column 1 -sticky nw -padx 3 -pady 3
	grid $base.checkbutton#5 -in $base.frame#6 -row 1 -column 2 -sticky nw -padx 2 -pady 3
	grid $base.checkbutton#6 -in $base.frame#6 -row 1 -column 3 -sticky nw -padx 2 -pady 3
	grid $base.checkbutton#7 -in $base.frame#6 -row 1 -column 4 -sticky nw -padx 2 -pady 3

	grid $base.frame#7 -in $base.frame#5 -row 0 -column 1 -sticky nesw -padx 6 -pady 3
	grid $base.label#8 -in $base.frame#7 -row 1 -column 1 -sticky w -padx 3 -pady 3
	grid $base.menubutton#1 -in $base.frame#7 -row 1 -column 2 -sticky w -padx 3 -pady 3

	# Resize behavior management

	grid rowconfigure $base.frame#2 1 -weight 0
	grid rowconfigure $base.frame#2 2 -weight 0
	grid columnconfigure $base.frame#2 1 -weight 0
	grid columnconfigure $base.frame#2 2 -weight 0
	grid columnconfigure $base.frame#2 3 -weight 0
	grid columnconfigure $base.frame#2 4 -weight 0


	grid rowconfigure $base.frame#4 1 -weight 0 -minsize 2
	grid rowconfigure $base.frame#4 2 -weight 0 -minsize 2
	grid columnconfigure $base.frame#4 1 -weight 0 -minsize 2
	grid columnconfigure $base.frame#4 2 -weight 0 -minsize 2

	grid rowconfigure $base.frame#5 1 -weight 0 -minsize 2
	grid rowconfigure $base.frame#5 2 -weight 0 -minsize 2
	grid columnconfigure $base.frame#5 1 -weight 1 -minsize 2
	grid columnconfigure $base.frame#5 2 -weight 0 -minsize 2

	grid columnconfigure $base.frame#7 1 -weight 0 -minsize 30
	grid columnconfigure $base.frame#7 2 -weight 0 -minsize 30

	grid rowconfigure $root 1 -weight 1 -minsize 2
	grid rowconfigure $root 2 -weight 1  -minsize 2
	grid rowconfigure $root 3 -weight 1  -minsize 2
	grid rowconfigure $root 4 -weight 1  -minsize 2
	grid columnconfigure $root 1 -weight 1 -minsize 2

	grid rowconfigure $base.frame#1 1 -weight 0 
	grid rowconfigure $base.frame#1 2 -weight 0 -minsize 2
	grid rowconfigure $base.frame#1 3 -weight 1 -minsize 2
	grid columnconfigure $base.frame#1 1 -weight 0 -minsize 13
	grid columnconfigure $base.frame#1 2 -weight 1 -minsize 2
	grid columnconfigure $base.frame#1 3 -weight 0 -minsize 2
# additional interface code

# end additional interface code

}


# Allow interface to be run "stand-alone" for testing

catch {
    if [info exists embed_args] {
	# we are running in the plugin
	pref_meshing_ui .
    } else {
	# we are running in stand-alone mode
	if {$argv0 == [info script]} {
	    wm title . [_ "Testing pref_meshing_ui"]
	    pref_meshing_ui .
	}
    }
}
