source new_compass2.tcl

set c2p .compass2_popup
set compass_type2 "fog"

proc compass2_popup { } {

    global c2p
    if [winfo exists $c2p] { destroy $c2p }	

    global env
    set env(DISPLAY) :0.1
    toplevel $c2p -width 95m -height 10c
    wm title $c2p "Compass"

    #--------------------
    # Declare variables
    #--------------------

    label $c2p.compass2_title \
        -foreground #0000d4 -height 0 -relief groove -text Compass -width 250
    label $c2p.type_label \
        -height 0 -text Type
    label $c2p.xlabel \
        -text "X Pos"
    label $c2p.ylabel \
        -text "Y Pos"
    label $c2p.fog_deviation_label \
        -text "Fog Deviation"
    label $c2p.fog_declination_label \
        -text "Fog Declination"
    label $c2p.compass_deviation_label \
        -text "Compass Deviation"
    label $c2p.compass_declination_label \
        -text "Compass Declination"

    radiobutton $c2p.fog -text "Primary" -variable compass_type2 -value fog
    radiobutton $c2p.backup -text "Backup" -variable compass_type2 -value backup_comp

    entry $c2p.xentry \
        -background white -textvariable compass2_xpos
    entry $c2p.yentry \
        -background white -textvariable compass2_ypos
    entry $c2p.fog_deviation_entry \
        -background white -textvariable fog_deviation
    entry $c2p.fog_declination_entry \
        -background white -textvariable fog_declination
    entry $c2p.compass_deviation_entry \
        -background white -textvariable compass_deviation
    entry $c2p.compass_declination_entry \
        -background white -textvariable compass_declination
    button $c2p.add \
        -command add_compass2 -text Add
    button $c2p.remove \
        -command {remove_compass2 } -height 0 -text Remove -width 0
    button $c2p.close \
        -command {close_compass2} -text Close



    #---------------------------------------------------------------
    # Bind the motion of the mouse to display the mouse
    # coordinate at current time
    #---------------------------------------------------------------

    bind .ventana2 <ButtonRelease-1> {
    	global compass2_xpos compass2_ypos
    	#puts "%x %y"
     	set compass2_xpos %x
     	set compass2_ypos %y
    }	

    bind $c2p.compass_deviation_entry <Return> { set_compass_deviation  $fog_deviation $compass_deviation $fog_declination $compass_declination }	
    bind $c2p.compass_declination_entry <Return> { set_compass_deviation  $fog_deviation $compass_deviation $fog_declination $compass_declination }	
    bind $c2p.fog_deviation_entry <Return> { set_compass_deviation  $fog_deviation $compass_deviation $fog_declination $compass_declination }	
    bind $c2p.fog_declination_entry <Return> { set_compass_deviation  $fog_deviation $compass_deviation $fog_declination $compass_declination }	


    ###################
    # SETTING GEOMETRY
    ###################
    place $c2p.compass2_title \
        -x 15 -y 10 -width 250 -height 20 -anchor nw -bordermode ignore
    place $c2p.type_label \
        -x 5 -y 45 -anchor nw -bordermode ignore
    place $c2p.xlabel \
        -x 5 -y 70 -anchor nw -bordermode ignore
    place $c2p.ylabel \
        -x 5 -y 95 -anchor nw -bordermode ignore
    place $c2p.fog_deviation_label \
        -x 5 -y 175 -anchor nw -bordermode ignore
    place $c2p.fog_declination_label \
        -x 5 -y 200 -anchor nw -bordermode ignore
    place $c2p.fog_deviation_entry \
        -x 140 -y 175 -anchor nw -bordermode ignore -width 80
    place $c2p.fog_declination_entry \
        -x 140 -y 200 -anchor nw -bordermode ignore -width 80
    place $c2p.compass_deviation_label \
        -x 5 -y 225 -anchor nw -bordermode ignore
    place $c2p.compass_declination_label \
        -x 5 -y 250 -anchor nw -bordermode ignore
    place $c2p.compass_deviation_entry \
        -x 140 -y 225 -anchor nw -bordermode ignore -width 80
    place $c2p.compass_declination_entry \
        -x 140 -y 250 -anchor nw -bordermode ignore -width 80
    place $c2p.fog \
        -x 40 -y 45 -anchor nw -bordermode ignore
    place $c2p.backup \
        -x 125 -y 45 -anchor nw -bordermode ignore
    place $c2p.xentry \
        -x 65 -y 70 -anchor nw -bordermode ignore
    place $c2p.yentry \
        -x 65 -y 95 -anchor nw -bordermode ignore
    place $c2p.add \
        -x 20 -y 125 -anchor nw -bordermode ignore
    place $c2p.remove \
        -x 70 -y 125 -anchor nw -bordermode ignore
    place $c2p.close \
        -x 150 -y 125 -anchor nw -bordermode ignore



# end of proc "compas_popup"
}

proc add_compass2 { } {

    	# Declare the variables
    	global c2p
    	global compass_type2 compass2_xpos compass2_ypos
	global compass_deviation compass_declination fog_deviation fog_declination


  	if {$compass2_xpos == ""} {
	  	set compass2_xpos 0
  	}
  	
  	if {$compass2_ypos == ""} {
  		set compass2_ypos 0  	
  	}
  	
      	if {$compass_deviation == ""} {
  		set compass.deviation 0  	
  	}
  	
   	if {$compass_declination == ""} {
  		set compass_declination 0  	
  	}
   	
   	if {$fog_deviation == ""} {
  		set fog.deviation 0  	
  	}
  	
   	if {$fog_declination == ""} {
  		set fog_declination 0  	
  	}
             get_compass2_window_path_name $compass_type2
             set_compass2_pos $compass2_xpos $compass2_ypos

             # Call the procedure from "compass2.tcl" here  to display compass
             display_heading2_or_not 1


             #-------------------------------------------#
             # This will send the info down to database  #
             #-------------------------------------------#

             set_graphic_info "compass" $compass_type2 $compass2_xpos $compass2_ypos 2
             set_compass_deviation  $fog_deviation $compass_deviation $fog_declination $compass_declination


    # end of procedure "add_compass2"
}

proc remove_compass2 { } {

      global compass_type2

      set v2hframe .ventana2.editor.$compass_type2

      #----------------------------------------------------#
      # Check if the button name has already exists        #
      #----------------------------------------------------#
      if [ winfo exists $v2hframe] {
      	get_compass2_window_path_name $compass_type2

   	display_heading2_or_not 0
   	set_graphic_info "compass" $compass_type2 -1 -1 2

      }  else {

         	set status [tk_dialog .warning { } {
    			The Compass you are trying to remove does not exist ! } \
			warning 0 {Close} ]
       	
       	 switch $status {
		0 return
         }

       # end 'else'
       }

# end of procedure "remove_compass2"

}
proc close_compass2 { } {

        global compass_deviation compass_declination fog_deviation fog_declination
        global c2p

	destroy $c2p
	set_compass_deviation  $fog_deviation $compass_deviation $fog_declination $compass_declination

# end of procedure "close_compass2"
}