# file:    ssman1d.tk
# authors: Hinke Osinga and Reza Rokni - University of Exeter
# date:    April 2003

proc ssman1d(build) name {
    global SSMan1D Model Fixed

    build_Title $name "One-D Strong (Un)Stable Manifolds"

    if {![winfo exists $name.options]} {
        build_Menubar $name options \
	   {"Help" \
 	     {"Help working with SSMan1D..." "window(open) help_ssman1d"} \
	     {} \
	     {"About SSMan1D..." "window(open) help_ssman1d_about"} \
	   }
    }

    set cmd [build_CmdFrame $name cmd]

    build_Message $cmd m0 \
    "One-D Strong Stable and Unstable Manifold Computation for Vector Fields"
    build_Message $cmd m1 \
    "Copyright 2003 by Hinke Osinga and Reza Rokni --- University of Exeter"
    build_Message $cmd m2 " "

    build_PopupMenu $cmd p1 "Compute:" \
	SSMan1D(Side) ssman1d(leave) {"both sides" "positive side" "negative side"}	

    build_LabelEntryColumns $cmd le0 \
	    {text {} {"Number of Fixed Points in the Memory:"}} \
	    {ilabel {} {Fixed(Found)}}
    bind_LabelEntryColumns $cmd.le0 1 <Return> ssman1d(update)

    build_LabelEntryColumns $cmd le1 \
	{text {} {"		     initial step:"\
                  "arclength strong stable manifold:" \
		  "arclength strong unstable manifold:"}} \
        {dentry {} {SSMan1D(Ini_Step) SSMan1D(Stab_ARC) SSMan1D(Unstab_ARC)}}
    bind_LabelEntryColumns $cmd.le1 1 <Return> ssman1d(update)

    build_LabelEntryColumns $cmd le2 \
	{text {} {"			maximal integration steps:"}} \
	{ientry {} {SSMan1D(Tot_Steps)}} \

    bind_LabelEntryColumns $cmd.le2 1 <Return> ssman1d(update)

    build_Message $cmd m3 " "
    build_Message $cmd m4 "Parameters for mesh point reduction by curvature"

    build_PopupMenu $cmd p2 "" \
	SSMan1D(Curve) ssman1d(leave) {"reduce mesh points" "do not reduce mesh points"}	

    build_LabelEntryColumns $cmd le3 \
	{text {} {"	    alpha_min:" \
		  "alpha_max:" \
		  "(Delta alpha)_min:" \
		  "(Delta alpha)_max:"}} \
	{dentry {} {SSMan1D(alpha_min) \
                    SSMan1D(alpha_max) \
      		    SSMan1D(Delta_alpha_min) \
                    SSMan1D(Delta_alpha_max)}}
    bind_LabelEntryColumns $cmd.le3 1 <Return> ssman1d(update)

    build_DismissButtonbar $name dbbar "window(dismiss) ssman1d"\
        {"Clear manifolds" ssman1d(clear_mans) }

    build_Buttonbar $name bb0 \
	{"Strong Stable manifold" ssman1d(compute_ssman1d)} \
	{"Strong Unstable manifold" ssman1d(compute_suman1d) } 
    pack $name.bb0 -side bottom

    pack $cmd -fill both -expand 1
}

proc ssman1d(enter) {} {
    pm_to_tcl SSMan1D
}

proc ssman1d(leave) {} {
    tcl_to_pm SSMan1D
    pm_to_tcl SSMan1D     
}

proc ssman1d(update) {} {
    tcl_to_pm SSMan1D
    pm_to_tcl SSMan1D
}

proc ssman1d(compute_ssman1d) {} {
	begin_wait "Computing Strong Stable Manifold..."
	tcl_to_pm SSMan1D
	pm_to_tcl SSMan1D
	pm EXEC SSMan1D.compute_ssman1d
	pm_to_tcl SSMan1D Memory
	end_wait "...Done..."
}

proc ssman1d(compute_suman1d) {} {
	begin_wait "Computing Strong Unstable Manifold..."
	tcl_to_pm SSMan1D
	pm_to_tcl SSMan1D
	pm EXEC SSMan1D.compute_suman1d
	pm_to_tcl SSMan1D Memory
	end_wait "...Done..."
}

proc ssman1d(clear_mans) {} {
    global Defaults

    begin_wait "Clearing manifolds..."
    tcl_to_pm SSMan1D
    pm EXEC SSMan1D.clear_mans
    pm_to_tcl SSMan1D Memory
    if {$Defaults(Auto_Refresh) == 1} {
        oneD(refresh_all)
        twoD(refresh_all)
    }
    end_wait "Manifolds Cleared"
}









