
#-------------------------------------------------------------------------------
# Module:     optimizeDataStruct.tk
# Activation: Dynamically loaded on user request
# Scope:      Configuration of data structures in optimization methods
#-------------------------------------------------------------------------------



proc ShowDataStructures {} {
    global WDDataStruct InternalWindowing DialogFrame DefPadX DefPadY

    if {$InternalWindowing} {
        set WDDataStruct $DialogFrame.dataopt
        if {![winfo exists $WDDataStruct]} {
            frame $WDDataStruct
        }
        
        RegisterDialog "Data Structures" $WDDataStruct ShowDataStructures {}
    } else {
        set WDDataStruct .dataopt
        if {![winfo exists $WDDataStruct]} {
            toplevel $WDDataStruct
            wm title $WDDataStruct "Data Structures"
            wm resizable $WDDataStruct 0 0
        } else {return}
    }

    frame $WDDataStruct.buttons
    button $WDDataStruct.buttons.done -text "Done" -command {
        if {$InternalWindowing} {
            DestroyActiveDialog
        } else {
            destroy $WDDataStruct
        }
    }
    pack $WDDataStruct.buttons.done -side left -fill x -padx 3m

    frame $WDDataStruct.heap
    label $WDDataStruct.heap.label -text "Priority Queues:" -anchor w
    radiobutton $WDDataStruct.heap.basic -text "Basic Impementation" \
        -variable goblinMethPQ -value 0 -anchor w
    radiobutton $WDDataStruct.heap.binary -text "Binary Heaps" \
        -variable goblinMethPQ -value 1 -anchor w
    radiobutton $WDDataStruct.heap.fibonacci -text "Fibonacci Heaps" \
        -variable goblinMethPQ -value 2 -anchor w
    pack $WDDataStruct.heap.label \
        $WDDataStruct.heap.basic \
        $WDDataStruct.heap.binary \
        $WDDataStruct.heap.fibonacci \
        -fill x
        
    frame $WDDataStruct.dsu
    label $WDDataStruct.dsu.label -text "Disjoint Set Union:" -anchor w
    checkbutton $WDDataStruct.dsu.enable -text "Enable Path Compression" \
        -variable goblinMethDSU -anchor w
    pack $WDDataStruct.dsu.label \
        $WDDataStruct.dsu.enable \
        -fill x
        
    frame $WDDataStruct.adjacency
    label $WDDataStruct.adjacency.label -text "Adjacencies:" -anchor w
    radiobutton $WDDataStruct.adjacency.search -text "Search Incidencies" \
        -variable goblinMethAdjacency -value 0 -anchor w
    radiobutton $WDDataStruct.adjacency.hash -text "Use Hash Table" \
        -variable goblinMethAdjacency -value 1 -anchor w
    pack $WDDataStruct.adjacency.label \
        $WDDataStruct.adjacency.search \
        $WDDataStruct.adjacency.hash \
        -fill x
     
    pack $WDDataStruct.buttons -padx 3m -pady 3m -side bottom
    pack $WDDataStruct.heap $WDDataStruct.dsu $WDDataStruct.adjacency \
        -side top -fill x -pady 5m -padx $DefPadX -anchor w

    if {$InternalWindowing} {
        pack $WDDataStruct -anchor nw
        AlignActiveDialog
    }
}

global WDDataStruct
if {![info exists WDDataStruct] || ![winfo exists $WDDataStruct]} {ShowDataStructures}
