//Declare global variables
global string $gWindow;
global string $gTotalCountSlider;
global string $gAssembleStartPntSlider;
global string $gTotalAssembleTimeSlider;
global string $gMainSphereCntSlider;
global string $gMainSphereSizeSlider;
global string $gMainScatterCntSlider;
global string $gInsideSphereCntSlider;
global string $gInsideSphereSizeSlider;
global string $gInsideScatterCntSlider;
global string $gMScatterRangeSlider;
global string $gIScatterRangeSlider;
  
global proc generateGeneUI(){
    //using the already declared variable outside the proc
    global string $gWindow;
    
    int $exists = `window -exists $gWindow`;
    if($exists == 0) {
        $gWindow = `window -width 400
                       -height 150
                       -retain
                       -topLeftCorner 500 1000
                       -title  "Create Gene UI"`;
        //Add any sliders, buttons and other UI elements
        addWidgets();    
    }
    showWindow $gWindow;
}
  
//PROC: Static UI Version - Generate/delete gene object with animation
global proc addWidgets(){
    global string $gTotalCountSlider;
    global string $gAssembleStartPntSlider;
    global string $gTotalAssembleTimeSlider;
    global string $gMainSphereCntSlider;
    global string $gMainSphereSizeSlider;
    global string $gMainScatterCntSlider;
    global string $gInsideSphereCntSlider;
    global string $gInsideSphereSizeSlider;
    global string $gInsideScatterCntSlider;
    global string $gMScatterRangeSlider;
    global string $gIScatterRangeSlider;
    
    columnLayout -adjustableColumn true;
    image -image "/home/millee20/mount/stuhome/vsfx705/main.jpg" -width 400 -height 250;
  
    frameLayout -label "CREAT GENE" -collapsable true -borderStyle "etchedIn";
    columnLayout -columnAttach "both" 5 -rowSpacing 5 -columnWidth 400;
                        
            separator -height 2 -style none;
            $gTotalCountSlider = `intSliderGrp -label "Number of Lines in Gene" 
                                        -field true 
                                        -min 1 
                                        -max 50 
                                        -value 30 
                                        -step 1 
                                        -columnWidth 1 133`;
  
            separator -height 2 -style none;
            $gAssembleStartPntSlider = `intSliderGrp  -label "Assemble Ani Start Second"
                                          -columnWidth 1 144
                                          -field true
                                          -value 5
                                          -min 1 -max 50`;
  
            separator -height 2 -style none;
            $gTotalAssembleTimeSlider = `floatSliderGrp  -label "Assemble Ani Total Second"
                                          -columnWidth 1 145
                                          -field true
                                          -value 18.0
                                          -min 1 -max 50`;
  
            separator -height 2 -style none;
            $gMainSphereCntSlider = `intSliderGrp  -label "Body Sphere Count"
                                          -columnWidth 1 105
                                          -field true
                                          -value 80
                                          -min 1 -max 100`;
  
            separator -height 2 -style none;
            $gMainSphereSizeSlider = `floatSliderGrp  -label "Body Sphere Size"
                                          -columnWidth 1 98
                                          -field true
                                          -value 5
                                          -min 1 -max 100`;
  
            separator -height 2 -style none;
            $gMainScatterCntSlider = `intSliderGrp  -label "Body Sphere Scatter Count"
                                          -columnWidth 1 147
                                          -field true
                                          -value 5
                                          -min 1 -max 10`;
  
            separator -height 2 -style none;
            $gMScatterRangeSlider = `floatSliderGrp  -label "Body Sphere Scatter Range"
                                          -columnWidth 1 150
                                          -field true
                                          -value 5
                                          -min 1 -max 10`;
  
            separator -height 2 -style none;
            $gInsideSphereCntSlider = `intSliderGrp  -label "Inside Sphere Count"
                                          -columnWidth 1 110
                                          -field true
                                          -value 11
                                          -min 1 -max 20`;
  
            separator -height 2 -style none;
            $gInsideSphereSizeSlider = `floatSliderGrp  -label "Inside Sphere Size"
                                          -columnWidth 1 103
                                          -field true
                                          -value 5
                                          -min 1 -max 100`;
  
            separator -height 2 -style none;
            $gInsideScatterCntSlider = `intSliderGrp  -label "Inside Sphere Scatter Count"
                                          -columnWidth 1 152
                                          -field true
                                          -value 5
                                          -min 1 -max 103`;
  
            separator -height 2 -style none;
            $gIScatterRangeSlider = `floatSliderGrp  -label "Inside Sphere Scatter Range"
                                          -columnWidth 1 155
                                          -field true
                                          -value 5
                                          -min 1 -max 10`;
            
            separator -height 2 -style none;
            button -label "Generate Gene!" -command "makeGene";
            button -label "Delete Gene" -command "deleteGene";
            separator -style none -h 2;
        setParent ..;
    setParent ..;
}
  
//PROC: Generate gene
global proc makeGene() {
  
    global string $gTotalCountSlider;
    int $total = `intSliderGrp -q -value $gTotalCountSlider`;
  
    global string $gAssembleStartPntSlider;
    int $aniAssembleStartPoint = `intSliderGrp -q -value $gAssembleStartPntSlider`;
  
    global string $gTotalAssembleTimeSlider;
    float $aniTotalAssembleTime = `floatSliderGrp -q -value $gTotalAssembleTimeSlider`;
  
    global string $gMainSphereCntSlider;    
    int $mainSphereCnt = `intSliderGrp -q -value $gMainSphereCntSlider`;
  
    global string $gMainSphereSizeSlider;
    float $mainSphereSize = `floatSliderGrp -q -value $gMainSphereSizeSlider`;
  
    global string $gMainScatterCntSlider;
    int $mainScatterCnt = `intSliderGrp -q -value $gMainScatterCntSlider`;    
  
    global string $gInsideSphereCntSlider;
    int $insideSphereCnt = `intSliderGrp -q -value $gInsideSphereCntSlider`;
  
    global string $gInsideSphereSizeSlider;
    float $insideSphereSize = `floatSliderGrp -q -value $gInsideSphereSizeSlider`;        
  
    global string $gInsideScatterCntSlider;
    int $insideScatterCnt = `intSliderGrp -q -value $gInsideScatterCntSlider`;
    
    global string $gMScatterRangeSlider;
    float $MscatterRange = `floatSliderGrp -q -value $gMScatterRangeSlider`;    
    
    global string $gIScatterRangeSlider;        
    float $IscatterRange = `floatSliderGrp -q -value $gIScatterRangeSlider`;
 
    createGene($total, $aniAssembleStartPoint, $aniTotalAssembleTime, $mainSphereCnt, $mainSphereSize, $mainScatterCnt, 
    $insideSphereCnt, $insideScatterCnt, $insideSphereSize, $MscatterRange, $IscatterRange);   
}
  
//PROC: Delete gene
global proc deleteGene() {
  
    select "myGene";
    delete;
}