# $Source: /usr/local/SimSoft/Sfx3D/src/gts/gts01.tcl,v $
# $Revision: 1.2 $
# $Author: baum $
# $Date: 2001/11/29 15:18:10 $
#
# Login name of the user who locked the revision
# $Locker:  $
# Tag name used to checkout the file
# $Name: Release-14 $
# State assigned to revision
# $State: Exp $
#
#
# $Log: gts01.tcl,v $
# Revision 1.2  2001/11/29 15:18:10  baum
# -Realzeitsteuerung eingebaut
# -Handsteuerung eingebaut
#

# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++++++++++++  D I A L O G :  BausteinErzeugen  +++++++++++++++++++++++++++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

proc BausteinErzeugen {} {
   global DAT
   global BstListBox VarListBox
   set DAT(BezBst) ""
   set DAT(BezVar) ""
   set DAT(IBst)   0
   set DAT(IVar)   0

   set dlg [dialog_create "Baustein erzeugen" Dialog "Erzeugen" "Abbrechen"]
   set DAT(Typ) [dialog_entry $dlg "Baustein:" 10 "" 40 $DAT(BezBst)]
   $DAT(Typ) config -state disabled
   set DAT(Var) [dialog_entry $dlg "Variante:" 10 "" 40 $DAT(BezVar)]
   $DAT(Var) config -state disabled
   focus $dlg
   
   frame $dlg.x -borderwidth 5
   frame $dlg.x.bst   -relief sunken -borderwidth 2 
   frame $dlg.x.space -width 5m 
   frame $dlg.x.var   -relief sunken -borderwidth 2
   pack  $dlg.x -expand yes -fill x
   pack  $dlg.x.bst   -side left -expand yes -fill both  -padx 5 -pady 12
   pack  $dlg.x.space -side left -expand no  -fill y
   pack  $dlg.x.var   -side left -expand yes -fill both  -padx 5 -pady 12
   
   set BstListBox [dialog_lbox $dlg.x.bst]
   set VarListBox [dialog_lbox $dlg.x.var]
   
   set DAT(BErg) [DlgGrafik BSTERZEUGEN BASISTYP]
   foreach i $DAT(BErg) { $BstListBox insert end $i }
   set DAT(BezBst) [lindex $DAT(BErg) 0]
   $DAT(Typ) config -state normal
   $DAT(Typ) delete 0 end;  $DAT(Typ) insert 0 $DAT(BezBst)
   $DAT(Typ) config -state disabled
   
   set DAT(VErg) [DlgGrafik BSTERZEUGEN VARIANTTYP 0 0];
   foreach i $DAT(VErg) { $VarListBox insert end $i }
   set DAT(BezVar) [lindex $DAT(VErg) 0]
   $DAT(Var) config -state normal
   $DAT(Var) delete 0 end;  $DAT(Var) insert 0 $DAT(BezVar)
   $DAT(Var) config -state disabled

   bind $BstListBox <ButtonRelease-1> {
     set DAT(IBst)   [$BstListBox curselection]
     set DAT(BezBst) [lindex $DAT(BErg) [$BstListBox curselection]]
     $DAT(Typ) config -state normal
     $DAT(Typ) delete 0 end;  $DAT(Typ) insert 0 $DAT(BezBst)
     $DAT(Typ) config -state disabled
     set DAT(VErg) [DlgGrafik BSTERZEUGEN VARIANTTYP [$BstListBox curselection] 0]
     
     $VarListBox delete 0 end    
     foreach i $DAT(VErg) { $VarListBox insert end $i }
     set DAT(BezVar) [lindex $DAT(VErg) 0]
     $DAT(Var) config -state normal
     $DAT(Var) delete 0 end;  $DAT(Var) insert 0 $DAT(BezVar)
     $DAT(Var) config -state disabled
   }
   
   
   bind $VarListBox <ButtonRelease-1> {
     set DAT(IVar)   [$VarListBox curselection]
     set DAT(BezVar) [lindex $DAT(VErg) [$VarListBox curselection]]
     $DAT(Var) config -state normal
     $DAT(Var) delete 0 end;  $DAT(Var) insert 0 $DAT(BezVar)
     $DAT(Var) config -state disabled
   }
 
   global Confirm
   dialog_wait $dlg 
   set ok $Confirm($dlg)
   dialog_destroy $dlg
   
   if { $ok == 1} {
      if { [DlgGrafik BSTERZEUGEN BSTERZEUGEN $DAT(IBst) $DAT(IVar)] == 1 } {
        SetzAktMenueStatus .knoeppe.pfeil
        SetzMenueStatus "active"
        DlgGrafik ObjectMoving 0 0 0  
      }
   }
   unset DAT
   unset BstListBox 
   unset VarListBox
}
##  ENDE BausteinErzeugen

# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++++++++++++  D I A L O G :  BausteinErsetzen  +++++++++++++++++++++++++++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

proc BausteinErsetzen { bstnr bsttyp vartyp } {
   global DAT
   global VarListBox
   set DAT(BezBst) $bstnr
   set DAT(BezVar) $vartyp
   set DAT(NeuVar) $vartyp
   set DAT(IBst)   0
   set DAT(IVar)   0

   set dlg [dialog_create "Baustein ersetzen" Dialog "Ersetzen" "Abbrechen"]
   frame $dlg.top
   set DAT(Typ) [dialog_entry $dlg.top "Baustein:" 10 "" 5 $DAT(BezBst) "None" "" left]
   $DAT(Typ) config -state disabled
   set DAT(Var) [dialog_entry $dlg.top "Variante:" 10 "" 30 $DAT(BezVar) "None" "" left] 
   $DAT(Var) config -state disabled
   pack  $dlg.top -expand yes -fill x
   dialog_label $dlg "ersetzen durch" 10
   set DAT(Neu) [dialog_entry $dlg "Variante:" 10 "" -40 $DAT(NeuVar)]
   $DAT(Neu) config -state disabled
   focus $dlg
   
   frame $dlg.x -borderwidth 5
   frame $dlg.x.var  -relief sunken -borderwidth 2
   pack  $dlg.x -expand yes -fill x
   pack  $dlg.x.var  -side left -expand yes -fill both  -padx 5 -pady 12
   set VarListBox [dialog_lbox $dlg.x.var]
   
   set erg [DlgGrafik BSTERSETZEN INFO $bstnr $bsttyp];
   set DAT(VErg) [lindex $erg 0]
   foreach i $DAT(VErg) { $VarListBox insert end $i }
   set DAT(BezVar) [lindex $erg 1]
   set DAT(NeuVar) [lindex $erg 1]
   $DAT(Var) config -state normal
   $DAT(Var) delete 0 end;  $DAT(Var) insert 0 $DAT(BezVar)
   $DAT(Var) config -state disabled
   $DAT(Neu) config -state normal
   $DAT(Neu) delete 0 end;  $DAT(Neu) insert 0 $DAT(NeuVar)
   $DAT(Neu) config -state disabled
   
   
   bind $VarListBox <ButtonRelease-1> {
     set DAT(IVar)   [$VarListBox curselection]
     set DAT(BezVar) [lindex $DAT(VErg) [$VarListBox curselection]]
     $DAT(Neu) config -state normal
     $DAT(Neu) delete 0 end;  $DAT(Neu) insert 0 $DAT(BezVar)
     $DAT(Neu) config -state disabled
   }
   
   global Confirm
   dialog_wait $dlg 
   set ok $Confirm($dlg)
   dialog_destroy $dlg
   if { $ok == 1} {
     DlgGrafik BSTERSETZEN BSTERSETZEN $bstnr $bsttyp $DAT(IVar)];
   }
   unset DAT
   unset VarListBox
}
##  ENDE BausteinErsetzen

# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++++++++++  ENDE - D I A L O G :  BausteinErsetzen  ++++++++++++++++++++++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
