  
   
proc InitGIDProject {dir} {

      set materials  [.central.s info materials] 
      set conditions [.central.s info conditions ovpnt] 

      CreateWindow $dir $materials $conditions

}




proc CreateWindow {dir mat cond} {
    

    set w .gid.win_example

    InitWindow $w "CMAS2D.TCL - Example tcl file" ExampleCMAS "" \
	    "" 1

    frame $w.top
    label $w.top.title_text -text " TCL window example for CMAS2D problem type "
   
    frame $w.information  -relief ridge -bd 2 
    label $w.information.path        -text " Problem Type path: $dir "
    label $w.information.materials   -text " Avalaible materials: $mat"
    label $w.information.conditions  -text " Avalaible conditions: $cond"

    frame $w.bottom
    button $w.bottom.start -text "CONTINUE" \
           -height 1 -width 14 -command "destroy $w"
    button $w.bottom.random -text "RANDOM SURFACE" \
            -height 1 -width 20 -command "CreateRandomSurface $w"



    pack $w.top.title_text -pady 10
    pack $w.information.path $w.information.materials \
         $w.information.conditions -side top -anchor w
    
    pack $w.bottom.start $w.bottom.random -side left -anchor center
    pack $w.top 
    pack $w.information -expand yes -fill both
    pack $w.bottom -side top -padx 6 -pady 10 -ipady 2
}



proc CreateRandomSurface {w} {

   set ret [tk_dialogRAM $w.dialog "Warning!!" \
       "Warning: this will create a nurbs surface in your \
        current project" "" 1 "ok" "cancel"]

   if {$ret ==0} {
       Create_surface
       destroy $w
   }
}







 proc Create_surface {} {


    set a_x [expr rand()*10]
    set a_y [expr rand()*10]

    set b_x [expr $a_x + rand()*10]
    set b_y [expr $a_y + rand()*10]

    set c_x [expr $b_x + rand()*10]
    set c_y [expr $b_y - rand()*10]


   
   if {$a_y < $c_y} {
           set d_y [expr $a_y - rand()*10]
	   set d_x [expr $a_x + rand()*10]
	   } else {
	   set d_y [expr $c_y - rand()*10] 
	   set d_x [expr $c_x - rand()*10]
	   }


    .central.s process escape escape escape escape 
    
    .central.s process geometry create line \
    $a_x,$a_y,0.000000tol0.176991 \
    $b_x,$b_y,0.000000tol0.176991 \
    $c_x,$c_y,0.000000tol0.176991 \
    $d_x,$d_y,0.000000tol0.176991 \
    close 



    .central.s process escape escape escape escape
    .central.s process geometry create NurbsSurface Automatic \
    4 \
    escape \

    .central.s process zoom frame escape escape escape escape 
 }




