
#-------------------------------------------------------------------------------
# Module:     editDelete.tk
# Activation: Dynamically loaded on user request
# Scope:      Dialog for deletion of potential solutions
#-------------------------------------------------------------------------------



proc DeleteSolutions {} {
    global WDDelete InternalWindowing DialogFrame DefPadX DefPadY

    if {$InternalWindowing} {
        set WDDelete $DialogFrame.deleteSolution
        if {![winfo exists $WDDelete]} {
            frame $WDDelete
        }
        
        RegisterDialog "Delete Labels" $WDDelete DeleteSolutions {}
    } else {
        set WDDelete .deleteSolution
        if {![winfo exists $WDDelete]} {
            toplevel $WDDelete
            wm title $WDDelete "Delete Labels"
            wm resizable $WDDelete 0 0
        } else {return}
    }

    global ThisSolution
    if {![info exists ThisSolution] || \
            ($ThisSolution!="subgraph" && $ThisSolution!="potentials" && \
             $ThisSolution!="partition" && $ThisSolution!="colours" && \
             $ThisSolution!="labels" && $ThisSolution!="predecessors")} {
        set ThisSolution "subgraph"
    }

    frame $WDDelete.options
    pack $WDDelete.options -padx $DefPadX -pady 5m -side top -anchor w

    label $WDDelete.options.label -text "Data Structure:" -anchor w
    radiobutton $WDDelete.options.subgraph -text "Subgraph" \
        -variable ThisSolution -value "subgraph" -anchor w
    radiobutton $WDDelete.options.labels -text "Distance Labels" \
        -variable ThisSolution -value "labels" -anchor w
    radiobutton $WDDelete.options.predecessors -text "Predecessor Labels" \
        -variable ThisSolution -value "predecessors" -anchor w
    radiobutton $WDDelete.options.colours -text "Node Colours" \
        -variable ThisSolution -value "colours" -anchor w
    radiobutton $WDDelete.options.potentials -text "Node Potentials" \
        -variable ThisSolution -value "potentials" -anchor w
    radiobutton $WDDelete.options.partition -text "Node Partition" \
        -variable ThisSolution -value "partition" -anchor w
    pack $WDDelete.options.label $WDDelete.options.subgraph \
        $WDDelete.options.labels $WDDelete.options.predecessors \
        $WDDelete.options.colours $WDDelete.options.potentials \
        $WDDelete.options.partition -side top -fill x
     
    frame $WDDelete.buttons
    pack $WDDelete.buttons -padx 3m -pady 3m -side bottom

    button $WDDelete.buttons.delete -text "Delete" -command { \
        $ThisGraph delete $ThisSolution
        PropagateModifications
    }    

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

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

global WDDelete
if {![info exists WDDelete] || ![winfo exists $WDDelete]} {DeleteSolutions}
